From c00450a4549baafdc46f471338a08fa58717cc44 Mon Sep 17 00:00:00 2001 From: Igor <35524806+igorschoester@users.noreply.github.com> Date: Mon, 21 Oct 2024 13:13:08 +0200 Subject: [PATCH 01/23] fix: dashboard problem/notification button styling * override the WP button style "white-space: nowrap" with "white-space: normal" * rest is apply difference to align the comment and an auto-format --- css/src/general-page.css | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/css/src/general-page.css b/css/src/general-page.css index d5e1d9a1f3d..1c7988fb4d8 100644 --- a/css/src/general-page.css +++ b/css/src/general-page.css @@ -1,13 +1,13 @@ body.toplevel_page_wpseo_dashboard { .notice, .yoast-migrated-notice { - display:none; + display: none; } - .yoast-general-page-notices:last-child{ + .yoast-general-page-notices:last-child { margin-bottom: 2rem; } - .yoast-general-page-notice, .yoast-webinar-dashboard{ + .yoast-general-page-notice, .yoast-webinar-dashboard { background: white; padding: 0.75rem; border-radius: 0.375rem; @@ -36,15 +36,15 @@ body.toplevel_page_wpseo_dashboard { hover:yst-text-slate-500 } - .yoast-general-page-notice .notice-dismiss:before{ + .yoast-general-page-notice .notice-dismiss:before { display: none; } - .yoast-general-page-notice .notice-yoast img{ + .yoast-general-page-notice .notice-yoast img { display: none; } - .yoast-general-page-notice a{ + .yoast-general-page-notice a { font-weight: 500; } @@ -53,40 +53,40 @@ body.toplevel_page_wpseo_dashboard { margin-top: 0; } - .yoast-webinar-dashboard .notice-dismiss:before{ + .yoast-webinar-dashboard .notice-dismiss:before { /* yst-text-slate-400 */ background: url("data:image/svg+xml,"); content: ''; } - .yoast-webinar-dashboard .notice-dismiss:hover:before{ + .yoast-webinar-dashboard .notice-dismiss:hover:before { /* yst-text-slate-500 */ background: url("data:image/svg+xml,"); content: ''; } - .yoast-webinar-dashboard p{ + .yoast-webinar-dashboard p { padding-left: 1.8rem; } - .yoast-webinar-dashboard .yoast-icon{ + .yoast-webinar-dashboard .yoast-icon { width: 17px; height: 17px; margin-right: 12px; } - .yoast-notice-migrated-header{ + .yoast-notice-migrated-header { font-weight: 500; font-size: .8125rem; - color: #1E293B; + color: #1e293b; line-height: 19px; } - .yoast-webinar-dashboard a{ + .yoast-webinar-dashboard a { font-weight: 500; } - .yoast-webinar-dashboard .notice-yoast__container{ + .yoast-webinar-dashboard .notice-yoast__container { padding: 0; } @@ -213,10 +213,10 @@ body.toplevel_page_wpseo_dashboard { yst-text-xs yst-leading-4 yst-px-2.5 - yst-py-1.5 + yst-py-1.5; /* custom for general page */ - yst-mt-3; + @apply yst-mt-3 yst-whitespace-normal; } .button-link { @@ -237,7 +237,7 @@ body.toplevel_page_wpseo_dashboard { visited:hover:yst-text-primary-400; } - .ul-disc{ + .ul-disc { @apply yst-list-disc yst-pl-3 @@ -246,6 +246,7 @@ body.toplevel_page_wpseo_dashboard { } } } + /* RTL */ &.rtl { From ae350dfde50d9a2030d391505e79bbc331b462f6 Mon Sep 17 00:00:00 2001 From: Igor <35524806+igorschoester@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:45:44 +0200 Subject: [PATCH 02/23] refactor: remove unneeded wrappers --- .../js/src/general/components/alerts-list.js | 47 ++++++++++--------- .../js/src/general/routes/alert-center.js | 33 ++++++------- 2 files changed, 38 insertions(+), 42 deletions(-) diff --git a/packages/js/src/general/components/alerts-list.js b/packages/js/src/general/components/alerts-list.js index 3c111b6687b..2cf9296a3b4 100644 --- a/packages/js/src/general/components/alerts-list.js +++ b/packages/js/src/general/components/alerts-list.js @@ -1,9 +1,9 @@ -import { Fragment, useContext, useCallback } from "@wordpress/element"; +import { EyeIcon, EyeOffIcon } from "@heroicons/react/outline"; import { useDispatch } from "@wordpress/data"; -import PropTypes from "prop-types"; +import { useCallback, useContext } from "@wordpress/element"; import { Button } from "@yoast/ui-library"; -import { EyeOffIcon, EyeIcon } from "@heroicons/react/outline"; import classNames from "classnames"; +import PropTypes from "prop-types"; import { AlertsContext } from "../contexts/alerts-context"; import { STORE_NAME } from "../constants/index"; @@ -17,7 +17,7 @@ import { STORE_NAME } from "../constants/index"; * * @returns {JSX.Element} The alert item component. */ -const AlertItem = ( { id, nonce, dismissed, message } ) => { +const AlertItem = ( { id, nonce, dismissed, message } ) => { const { bulletClass = "" } = useContext( AlertsContext ); const { toggleAlertStatus } = useDispatch( STORE_NAME ); const Eye = dismissed ? EyeIcon : EyeOffIcon; @@ -26,27 +26,28 @@ const AlertItem = ( { id, nonce, dismissed, message } ) => { toggleAlertStatus( id, nonce, dismissed ); }, [ id, nonce, dismissed, toggleAlertStatus ] ); - return -
  • -
    -
    - - - -
    -
    - - + return ( +
  • +
    + + +
    +
    + +
  • -
    ; + ); }; AlertItem.propTypes = { diff --git a/packages/js/src/general/routes/alert-center.js b/packages/js/src/general/routes/alert-center.js index 22cda07ca79..d2982f38bb1 100644 --- a/packages/js/src/general/routes/alert-center.js +++ b/packages/js/src/general/routes/alert-center.js @@ -4,8 +4,8 @@ import { Paper, Title } from "@yoast/ui-library"; import { PremiumUpsellList } from "../../shared-admin/components/premium-upsell-list"; import SidebarRecommendations from "../../shared-admin/components/sidebar-recommendations"; import { Notifications, Problems } from "../components"; +import { STORE_NAME } from "../constants"; import { useSelectGeneralPage } from "../hooks"; -import { STORE_NAME } from ".././constants"; /** * @returns {JSX.Element} The general page content placeholder. @@ -19,29 +19,24 @@ export const AlertCenter = () => { const { isPromotionActive } = useSelect( STORE_NAME ); return
    - { /* Alert center */ }
    -
    -
    - { __( "Alert center", "wordpress-seo" ) } -

    - { __( "Monitor and manage potential SEO problems affecting your site and stay informed with important notifications and updates.", "wordpress-seo" ) } -

    -
    +
    + { __( "Alert center", "wordpress-seo" ) } +

    + { __( "Monitor and manage potential SEO problems affecting your site and stay informed with important notifications and updates.", "wordpress-seo" ) } +

    -
    -
    - - -
    - { ! isPremium && } +
    + +
    + { ! isPremium && }
    { ! isPremium &&
    From 02622a622803a6064db62c43488fcea198bb5538 Mon Sep 17 00:00:00 2001 From: Igor <35524806+igorschoester@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:59:20 +0200 Subject: [PATCH 03/23] feat!: add @tailwindcss/container-queries plugin See: https://github.com/tailwindlabs/tailwindcss-container-queries BREAKING CHANGE: added peer dependency --- packages/tailwindcss-preset/index.js | 1 + packages/tailwindcss-preset/package.json | 1 + packages/tailwindcss-preset/readme.md | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/tailwindcss-preset/index.js b/packages/tailwindcss-preset/index.js index 8101752ccba..5d8cbf8729b 100644 --- a/packages/tailwindcss-preset/index.js +++ b/packages/tailwindcss-preset/index.js @@ -39,6 +39,7 @@ module.exports = { }, important: true, plugins: [ + require( "@tailwindcss/container-queries" ), require( "@tailwindcss/forms" )( { strategy: "class", } ), diff --git a/packages/tailwindcss-preset/package.json b/packages/tailwindcss-preset/package.json index 4fd8540a3f8..5b09e786590 100644 --- a/packages/tailwindcss-preset/package.json +++ b/packages/tailwindcss-preset/package.json @@ -7,6 +7,7 @@ "license": "GPL-3.0", "private": false, "peerDependencies": { + "@tailwindcss/container-queries": "^0.1.1", "@tailwindcss/forms": "^0.5.3", "tailwindcss": "^3.2.4" } diff --git a/packages/tailwindcss-preset/readme.md b/packages/tailwindcss-preset/readme.md index 7f3bda399d7..1a1cf54bfc6 100644 --- a/packages/tailwindcss-preset/readme.md +++ b/packages/tailwindcss-preset/readme.md @@ -6,7 +6,7 @@ This package aims to provide a Tailwind CSS preset for building Yoast packages. Start with installing the package and its peer dependencies from NPM: ```shell -yarn add --dev @yoast/tailwindcss-preset tailwindcss @tailwindcss/forms +yarn add --dev @yoast/tailwindcss-preset tailwindcss @tailwindcss/container-queries @tailwindcss/forms ``` Then, in your `tailwind.config.js` file, extend the preset like so: @@ -16,4 +16,4 @@ module.exports = { presets: [ require( "@yoast/tailwindcss-preset" ) ], // Your custom configuration. }; -``` \ No newline at end of file +``` From c2abb202f8da1b114e00cffd8bd0a6a9d334ae8b Mon Sep 17 00:00:00 2001 From: Igor <35524806+igorschoester@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:01:28 +0200 Subject: [PATCH 04/23] feat: add container-queries dep * needed to work with the updated tailwindcss-preset * https://github.com/tailwindlabs/tailwindcss-container-queries --- package.json | 1 + packages/ui-library/package.json | 1 + yarn.lock | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/package.json b/package.json index 21bb16b3d3f..019a8bcd3ee 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "devDependencies": { "@babel/core": "^7.18.5", "@slack/webhook": "^5.0.2", + "@tailwindcss/container-queries": "^0.1.1", "@tailwindcss/forms": "^0.5.2", "@wordpress/dependency-extraction-webpack-plugin": "^4.28.0", "@wordpress/scripts": "^26.16.0", diff --git a/packages/ui-library/package.json b/packages/ui-library/package.json index a6d07513170..83a094737a5 100644 --- a/packages/ui-library/package.json +++ b/packages/ui-library/package.json @@ -49,6 +49,7 @@ "@storybook/react": "^7.6.17", "@storybook/react-webpack5": "^7.6.17", "@storybook/theming": "^7.6.17", + "@tailwindcss/container-queries": "^0.1.1", "@tailwindcss/forms": "^0.5.3", "@wordpress/jest-preset-default": "^8.0.1", "@yoast/browserslist-config": "^1.2.3", diff --git a/yarn.lock b/yarn.lock index 4e32897f0cf..cf7376ce4b9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5305,6 +5305,11 @@ resolved "https://registry.yarnpkg.com/@swc/types/-/types-0.1.5.tgz#043b731d4f56a79b4897a3de1af35e75d56bc63a" integrity sha512-myfUej5naTBWnqOCc/MdVOLVjXUXtIA+NpDrDBKJtLLg2shUjBu3cZmB/85RyitKc55+lUUyl7oRfLOvkr2hsw== +"@tailwindcss/container-queries@^0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@tailwindcss/container-queries/-/container-queries-0.1.1.tgz#9a759ce2cb8736a4c6a0cb93aeb740573a731974" + integrity sha512-p18dswChx6WnTSaJCSGx6lTmrGzNNvm2FtXmiO6AuA1V4U5REyoqwmT6kgAsIMdjo07QdAfYXHJ4hnMtfHzWgA== + "@tailwindcss/forms@^0.5.2": version "0.5.2" resolved "https://registry.yarnpkg.com/@tailwindcss/forms/-/forms-0.5.2.tgz#4ef45f9916dcb37838cbe7fecdcc4ba7a7c2ab59" From d7ab0c177c52487803998e4bfc14d57b688238a3 Mon Sep 17 00:00:00 2001 From: Igor <35524806+igorschoester@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:46:04 +0200 Subject: [PATCH 05/23] fix: look at container width instead of screen width --- packages/js/src/general/routes/alert-center.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/js/src/general/routes/alert-center.js b/packages/js/src/general/routes/alert-center.js index d2982f38bb1..1c3031fd1d7 100644 --- a/packages/js/src/general/routes/alert-center.js +++ b/packages/js/src/general/routes/alert-center.js @@ -19,7 +19,7 @@ export const AlertCenter = () => { const { isPromotionActive } = useSelect( STORE_NAME ); return
    -
    +
    { __( "Alert center", "wordpress-seo" ) } @@ -28,7 +28,7 @@ export const AlertCenter = () => {

    -
    +
    From 87cd0b8f1901d28053fbdc68cdee5767b8f54695 Mon Sep 17 00:00:00 2001 From: Igor <35524806+igorschoester@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:46:24 +0200 Subject: [PATCH 06/23] fix: unset WP styles --- css/src/general-page.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/css/src/general-page.css b/css/src/general-page.css index 1c7988fb4d8..273b6b5ccbb 100644 --- a/css/src/general-page.css +++ b/css/src/general-page.css @@ -215,8 +215,8 @@ body.toplevel_page_wpseo_dashboard { yst-px-2.5 yst-py-1.5; - /* custom for general page */ - @apply yst-mt-3 yst-whitespace-normal; + /* custom for general page and reset WP styles */ + @apply yst-mt-3 yst-whitespace-normal yst-min-h-[unset] yst-mb-[unset] yst-align-[unset]; } .button-link { From fdfbfe70c2d73ae9b39f19f1c8dee8f2f1cd3e8d Mon Sep 17 00:00:00 2001 From: Igor <35524806+igorschoester@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:46:53 +0200 Subject: [PATCH 07/23] feat: center button text Looks better, approved by Kai --- css/src/general-page.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/css/src/general-page.css b/css/src/general-page.css index 273b6b5ccbb..d134b01a032 100644 --- a/css/src/general-page.css +++ b/css/src/general-page.css @@ -190,7 +190,8 @@ body.toplevel_page_wpseo_dashboard { yst-rounded-md yst-text-sm yst-font-medium - yst-leading-4 + yst-leading-5 + yst-text-center focus:yst-outline-none focus:yst-ring-2 From 4c70f8b70ba0faed80ee3a26b4c8e538e77183ae Mon Sep 17 00:00:00 2001 From: Igor <35524806+igorschoester@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:55:39 +0200 Subject: [PATCH 08/23] fix: adjust spacing to match design And while Kai was looking: spacing should be 24px instead of 32px --- packages/js/src/general/routes/alert-center.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/js/src/general/routes/alert-center.js b/packages/js/src/general/routes/alert-center.js index 1c3031fd1d7..7b0dd581959 100644 --- a/packages/js/src/general/routes/alert-center.js +++ b/packages/js/src/general/routes/alert-center.js @@ -18,7 +18,7 @@ export const AlertCenter = () => { const academyLink = useSelectGeneralPage( "selectLink", [], "https://yoa.st/3t6" ); const { isPromotionActive } = useSelect( STORE_NAME ); - return
    + return
    @@ -28,7 +28,7 @@ export const AlertCenter = () => {

    -
    +
    From 5b3a8ec665a790627165ebb66b5e2066a9f3feb1 Mon Sep 17 00:00:00 2001 From: Igor <35524806+igorschoester@users.noreply.github.com> Date: Tue, 22 Oct 2024 12:37:52 +0200 Subject: [PATCH 09/23] fix: update snapshots --- .../__snapshots__/alerts-list.test.js.snap | 332 +++++++++--------- .../__snapshots__/notifications.test.js.snap | 312 ++++++++-------- .../__snapshots__/problems.test.js.snap | 318 ++++++++--------- 3 files changed, 457 insertions(+), 505 deletions(-) diff --git a/packages/js/tests/general/components/__snapshots__/alerts-list.test.js.snap b/packages/js/tests/general/components/__snapshots__/alerts-list.test.js.snap index af643eb38c0..90c35b3a684 100644 --- a/packages/js/tests/general/components/__snapshots__/alerts-list.test.js.snap +++ b/packages/js/tests/general/components/__snapshots__/alerts-list.test.js.snap @@ -6,206 +6,190 @@ exports[`AlertsList should match snapshot 1`] = ` class="" >
  • -
    - - - -
    -
    - You've added a new type of content. We recommend that you review the corresponding Search appearance settings. -
    - + +
    +
    + You've added a new type of content. We recommend that you review the corresponding Search appearance settings. +
    +
  • -
    - - - -
    -
    - We notice that you have installed WPML. To make sure your canonical URLs are set correctly, install and activate the WPML SEO add-on as well! -
    - + +
    +
    + We notice that you have installed WPML. To make sure your canonical URLs are set correctly, install and activate the WPML SEO add-on as well! +
    +
  • -
    - - - -
    -
    - Huge SEO Issue: You're blocking access to robots. If you want search engines to show this site in their results, you must go to your Reading Settings and uncheck the box for Search Engine Visibility. I don't want this site to show in the search results. -
    - + +
    +
    + Huge SEO Issue: You're blocking access to robots. If you want search engines to show this site in their results, you must go to your Reading Settings and uncheck the box for Search Engine Visibility. I don't want this site to show in the search results. +
    +
  • -
    - - - -
    -
    - We need to re-analyze some of your SEO data because of a change in the visibility of your taxonomies. Please help us do that by running the SEO data optimization. We estimate this will take less than a minute. -
    - + +
    +
    + We need to re-analyze some of your SEO data because of a change in the visibility of your taxonomies. Please help us do that by running the SEO data optimization. We estimate this will take less than a minute. +
    +
  • diff --git a/packages/js/tests/general/components/__snapshots__/notifications.test.js.snap b/packages/js/tests/general/components/__snapshots__/notifications.test.js.snap index d6ad489a2f7..6a544c5228e 100644 --- a/packages/js/tests/general/components/__snapshots__/notifications.test.js.snap +++ b/packages/js/tests/general/components/__snapshots__/notifications.test.js.snap @@ -40,196 +40,180 @@ exports[`AlertsList should match snapshot 1`] = ` class="" >
  • -
    - - - -
    -
    - You've added a new type of content. We recommend that you review the corresponding Search appearance settings. -
    - + +
    +
    + You've added a new type of content. We recommend that you review the corresponding Search appearance settings. +
    +
  • -
    - - - -
    -
    - We notice that you have installed WPML. To make sure your canonical URLs are set correctly, install and activate the WPML SEO add-on as well! -
    - + +
    +
    + We notice that you have installed WPML. To make sure your canonical URLs are set correctly, install and activate the WPML SEO add-on as well! +
    +
  • -
    - - - -
    -
    - Huge SEO Issue: You're blocking access to robots. If you want search engines to show this site in their results, you must go to your Reading Settings and uncheck the box for Search Engine Visibility. I don't want this site to show in the search results. -
    - + +
    +
    + Huge SEO Issue: You're blocking access to robots. If you want search engines to show this site in their results, you must go to your Reading Settings and uncheck the box for Search Engine Visibility. I don't want this site to show in the search results. +
    +
  • -
    - - - -
    -
    - We need to re-analyze some of your SEO data because of a change in the visibility of your taxonomies. Please help us do that by running the SEO data optimization. We estimate this will take less than a minute. -
    - + +
    +
    + We need to re-analyze some of your SEO data because of a change in the visibility of your taxonomies. Please help us do that by running the SEO data optimization. We estimate this will take less than a minute. +
    +
  • -
    - - - -
    -
    - You've added a new type of content. We recommend that you review the corresponding Search appearance settings. -
    - + +
    +
    + You've added a new type of content. We recommend that you review the corresponding Search appearance settings. +
    +
  • -
    - - - -
    -
    - We notice that you have installed WPML. To make sure your canonical URLs are set correctly, install and activate the WPML SEO add-on as well! -
    - + +
    +
    + We notice that you have installed WPML. To make sure your canonical URLs are set correctly, install and activate the WPML SEO add-on as well! +
    +
  • -
    - - - -
    -
    - - Huge SEO Issue: - - You're blocking access to robots. If you want search engines to show this site in their results, you must go to your Reading Settings and uncheck the box for Search Engine Visibility. I don't want this site to show in the search results. -
    - + +
    +
    + + Huge SEO Issue: + + You're blocking access to robots. If you want search engines to show this site in their results, you must go to your Reading Settings and uncheck the box for Search Engine Visibility. I don't want this site to show in the search results. +
    +
  • -
    - - - -
    -
    - We need to re-analyze some of your SEO data because of a change in the visibility of your taxonomies. Please help us do that by running the SEO data optimization. We estimate this will take less than a minute. -
    - + +
    +
    + We need to re-analyze some of your SEO data because of a change in the visibility of your taxonomies. Please help us do that by running the SEO data optimization. We estimate this will take less than a minute. +
    +
  • Date: Wed, 23 Oct 2024 09:58:17 +0000 Subject: [PATCH 10/23] Bump version to 23.8-RC2 --- package.json | 2 +- wp-seo-main.php | 2 +- wp-seo.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 019a8bcd3ee..529e347df63 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "webpack-bundle-analyzer": "^4.9.1" }, "yoast": { - "pluginVersion": "23.8-RC1" + "pluginVersion": "23.8-RC2" }, "version": "0.0.0" } diff --git a/wp-seo-main.php b/wp-seo-main.php index e057f6f1cd1..809cf5f97ec 100644 --- a/wp-seo-main.php +++ b/wp-seo-main.php @@ -15,7 +15,7 @@ * {@internal Nobody should be able to overrule the real version number as this can cause * serious issues with the options, so no if ( ! defined() ).}} */ -define( 'WPSEO_VERSION', '23.8-RC1' ); +define( 'WPSEO_VERSION', '23.8-RC2' ); if ( ! defined( 'WPSEO_PATH' ) ) { diff --git a/wp-seo.php b/wp-seo.php index d34c0ca2756..4bf8c762483 100644 --- a/wp-seo.php +++ b/wp-seo.php @@ -8,7 +8,7 @@ * * @wordpress-plugin * Plugin Name: Yoast SEO - * Version: 23.8-RC1 + * Version: 23.8-RC2 * Plugin URI: https://yoa.st/1uj * Description: The first true all-in-one SEO solution for WordPress, including on-page content analysis, XML sitemaps and much more. * Author: Team Yoast From 9f6762bca680ce1f8e933de5c65ecf5463bcb319 Mon Sep 17 00:00:00 2001 From: Leonidas Milosis Date: Wed, 23 Oct 2024 15:03:42 +0300 Subject: [PATCH 11/23] Request only necessary option and populate options cache only for the option that was requested --- inc/class-wpseo-meta.php | 2 +- inc/options/class-wpseo-option-social.php | 2 +- inc/options/class-wpseo-options.php | 15 ++++++++------- wp-seo-main.php | 4 ++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/inc/class-wpseo-meta.php b/inc/class-wpseo-meta.php index 9c75815f1d2..69009ec8f11 100644 --- a/inc/class-wpseo-meta.php +++ b/inc/class-wpseo-meta.php @@ -240,7 +240,7 @@ class WPSEO_Meta { */ public static function init() { foreach ( self::$social_networks as $option => $network ) { - if ( WPSEO_Options::get( $option, false ) === true ) { + if ( WPSEO_Options::get( $option, false, [ 'wpseo_social' ] ) === true ) { foreach ( self::$social_fields as $box => $type ) { self::$meta_fields['social'][ $network . '-' . $box ] = [ 'type' => $type, diff --git a/inc/options/class-wpseo-option-social.php b/inc/options/class-wpseo-option-social.php index 220dd6f8229..a2aaa69b80c 100644 --- a/inc/options/class-wpseo-option-social.php +++ b/inc/options/class-wpseo-option-social.php @@ -107,7 +107,7 @@ public static function get_instance() { * @return void */ public function translate_defaults() { - self::$twitter_card_types['summary_large_image'] = __( 'Summary with large image', 'wordpress-seo' ); + self::$twitter_card_types['summary_large_image'] = 'Summary with large image'; } /** diff --git a/inc/options/class-wpseo-options.php b/inc/options/class-wpseo-options.php index eaae33400cd..96ea47d62f6 100644 --- a/inc/options/class-wpseo-options.php +++ b/inc/options/class-wpseo-options.php @@ -214,8 +214,9 @@ public static function get_option_names() { * * @return array Array combining the values of all the options. */ - public static function get_all() { - static::$option_values = static::get_options( static::get_option_names() ); + public static function get_all( $specific_options = [] ) { + $option_names = ( empty( $specific_options ) ) ? static::get_option_names() : $specific_options; + static::$option_values = static::get_options( $option_names ); return static::$option_values; } @@ -274,9 +275,9 @@ public static function get_option( $option_name ) { * * @return mixed Returns value if found, $default_value if not. */ - public static function get( $key, $default_value = null ) { - if ( static::$option_values === null ) { - static::prime_cache(); + public static function get( $key, $default_value = null, $option_groups = [] ) { + if ( ! isset( static::$option_values[ $key ] ) || static::$option_values[ $key ] === null ) { + static::prime_cache( $option_groups ); } if ( isset( static::$option_values[ $key ] ) ) { return static::$option_values[ $key ]; @@ -299,8 +300,8 @@ public static function clear_cache() { * * @return void */ - private static function prime_cache() { - static::$option_values = static::get_all(); + private static function prime_cache( $option_groups = [] ) { + static::$option_values = static::get_all( $option_groups ); static::$option_values = static::add_ms_option( static::$option_values ); } diff --git a/wp-seo-main.php b/wp-seo-main.php index 809cf5f97ec..7ee5f2e76a0 100644 --- a/wp-seo-main.php +++ b/wp-seo-main.php @@ -341,7 +341,7 @@ function wpseo_init() { WPSEO_Options::get_instance(); WPSEO_Meta::init(); - if ( version_compare( WPSEO_Options::get( 'version', 1 ), WPSEO_VERSION, '<' ) ) { + if ( version_compare( WPSEO_Options::get( 'version', 1, ['wpseo'] ), WPSEO_VERSION, '<' ) ) { if ( function_exists( 'opcache_reset' ) ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Prevent notices when opcache.restrict_api is set. @opcache_reset(); @@ -355,7 +355,7 @@ function wpseo_init() { $GLOBALS['wpseo_rewrite'] = new WPSEO_Rewrite(); } - if ( WPSEO_Options::get( 'enable_xml_sitemap' ) === true ) { + if ( WPSEO_Options::get( 'enable_xml_sitemap', null, ['wpseo'] ) === true ) { $GLOBALS['wpseo_sitemaps'] = new WPSEO_Sitemaps(); } From 4fdc7e44499353551fea617c697e572f837c2035 Mon Sep 17 00:00:00 2001 From: Leonidas Milosis Date: Wed, 23 Oct 2024 15:08:43 +0300 Subject: [PATCH 12/23] Move checking if attachments are disable inside the 'wpseo_accessible_post_types' hook --- admin/class-admin.php | 4 +--- inc/class-post-type.php | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/admin/class-admin.php b/admin/class-admin.php index 5b6578edf14..ef935eea758 100644 --- a/admin/class-admin.php +++ b/admin/class-admin.php @@ -49,9 +49,7 @@ public function __construct() { add_action( 'delete_category', [ $this, 'schedule_rewrite_flush' ] ); } - if ( WPSEO_Options::get( 'disable-attachment' ) === true ) { - add_filter( 'wpseo_accessible_post_types', [ 'WPSEO_Post_Type', 'filter_attachment_post_type' ] ); - } + add_filter( 'wpseo_accessible_post_types', [ 'WPSEO_Post_Type', 'filter_attachment_post_type' ] ); add_filter( 'plugin_action_links_' . WPSEO_BASENAME, [ $this, 'add_action_link' ], 10, 2 ); add_filter( 'network_admin_plugin_action_links_' . WPSEO_BASENAME, [ $this, 'add_action_link' ], 10, 2 ); diff --git a/inc/class-post-type.php b/inc/class-post-type.php index 54085d58b6c..944e1f669b0 100644 --- a/inc/class-post-type.php +++ b/inc/class-post-type.php @@ -51,7 +51,9 @@ public static function is_post_type_indexable( $post_type_name ) { * @return array The filtered array. */ public static function filter_attachment_post_type( array $post_types ) { - unset( $post_types['attachment'] ); + if ( WPSEO_Options::get( 'disable-attachment' ) === true ) { + unset( $post_types['attachment'] ); + } return $post_types; } From fe28c6ddce2a0546a8b633fba81002e96ae8e382 Mon Sep 17 00:00:00 2001 From: Leonidas Milosis Date: Wed, 23 Oct 2024 15:09:29 +0300 Subject: [PATCH 13/23] Stop removing the upgrade notice since it's never added --- admin/class-admin.php | 13 ------------- inc/class-upgrade.php | 4 ---- 2 files changed, 17 deletions(-) diff --git a/admin/class-admin.php b/admin/class-admin.php index ef935eea758..294f6cc4955 100644 --- a/admin/class-admin.php +++ b/admin/class-admin.php @@ -73,8 +73,6 @@ public function __construct() { add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ] ); } - $this->set_upsell_notice(); - $this->initialize_cornerstone_content(); if ( WPSEO_Utils::is_plugin_network_active() ) { @@ -365,17 +363,6 @@ private function localize_admin_global_script() { ); } - /** - * Sets the upsell notice. - * - * @return void - */ - protected function set_upsell_notice() { - $upsell = new WPSEO_Product_Upsell_Notice(); - $upsell->dismiss_notice_listener(); - $upsell->initialize(); - } - /** * Whether we are on the admin dashboard page. * diff --git a/inc/class-upgrade.php b/inc/class-upgrade.php index 25936b54290..149224b946e 100644 --- a/inc/class-upgrade.php +++ b/inc/class-upgrade.php @@ -103,10 +103,6 @@ public function __construct() { add_action( 'init', [ $this, 'upgrade_125' ] ); } - // Since 3.7. - $upsell_notice = new WPSEO_Product_Upsell_Notice(); - $upsell_notice->set_upgrade_notice(); - /** * Filter: 'wpseo_run_upgrade' - Runs the upgrade hook which are dependent on Yoast SEO. * From 684bde4cf38c306b754b6c47e450465341071e9b Mon Sep 17 00:00:00 2001 From: Leonidas Milosis Date: Wed, 23 Oct 2024 15:23:34 +0300 Subject: [PATCH 14/23] Move checking if we strip the category base inside the hooked function instead of before registering the hooks --- admin/class-admin.php | 12 +++++++----- inc/class-rewrite.php | 18 ++++++++++++++++-- wp-seo-main.php | 10 +++------- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/admin/class-admin.php b/admin/class-admin.php index 294f6cc4955..824a9d5e400 100644 --- a/admin/class-admin.php +++ b/admin/class-admin.php @@ -43,11 +43,9 @@ public function __construct() { WPSEO_Options::maybe_set_multisite_defaults( false ); } - if ( WPSEO_Options::get( 'stripcategorybase' ) === true ) { - add_action( 'created_category', [ $this, 'schedule_rewrite_flush' ] ); - add_action( 'edited_category', [ $this, 'schedule_rewrite_flush' ] ); - add_action( 'delete_category', [ $this, 'schedule_rewrite_flush' ] ); - } + add_action( 'created_category', [ $this, 'schedule_rewrite_flush' ] ); + add_action( 'edited_category', [ $this, 'schedule_rewrite_flush' ] ); + add_action( 'delete_category', [ $this, 'schedule_rewrite_flush' ] ); add_filter( 'wpseo_accessible_post_types', [ 'WPSEO_Post_Type', 'filter_attachment_post_type' ] ); @@ -115,6 +113,10 @@ public function __construct() { * @return void */ public function schedule_rewrite_flush() { + if ( WPSEO_Options::get( 'stripcategorybase' ) !== true ) { + return; + } + // Bail if this is a multisite installation and the site has been switched. if ( is_multisite() && ms_is_switched() ) { return; diff --git a/inc/class-rewrite.php b/inc/class-rewrite.php index 82ed1206915..87709fd586f 100644 --- a/inc/class-rewrite.php +++ b/inc/class-rewrite.php @@ -32,7 +32,9 @@ public function __construct() { * @return void */ public function schedule_flush() { - add_action( 'shutdown', 'flush_rewrite_rules' ); + if ( WPSEO_Options::get( 'stripcategorybase' ) === true ) { + add_action( 'shutdown', 'flush_rewrite_rules' ); + } } /** @@ -45,6 +47,10 @@ public function schedule_flush() { * @return string */ public function no_category_base( $link, $term, $taxonomy ) { + if ( WPSEO_Options::get( 'stripcategorybase' ) !== true ) { + return $link; + } + if ( $taxonomy !== 'category' ) { return $link; } @@ -91,6 +97,10 @@ public function query_vars( $query_vars ) { * @return array The query vars. */ public function request( $query_vars ) { + if ( WPSEO_Options::get( 'stripcategorybase' ) !== true ) { + return $query_vars; + } + if ( ! isset( $query_vars['wpseo_category_redirect'] ) ) { return $query_vars; } @@ -104,7 +114,11 @@ public function request( $query_vars ) { * * @return array The category rewrite rules. */ - public function category_rewrite_rules() { + public function category_rewrite_rules( $rules ) { + if ( WPSEO_Options::get( 'stripcategorybase' ) !== true ) { + return $rules; + } + global $wp_rewrite; $category_rewrite = []; diff --git a/wp-seo-main.php b/wp-seo-main.php index 7ee5f2e76a0..6f274110dc0 100644 --- a/wp-seo-main.php +++ b/wp-seo-main.php @@ -221,10 +221,8 @@ function _wpseo_activate() { WPSEO_Options::ensure_options_exist(); if ( ! is_multisite() || ! ms_is_switched() ) { - if ( WPSEO_Options::get( 'stripcategorybase' ) === true ) { - // Constructor has side effects so this registers all hooks. - $GLOBALS['wpseo_rewrite'] = new WPSEO_Rewrite(); - } + // Constructor has side effects so this registers all hooks. + $GLOBALS['wpseo_rewrite'] = new WPSEO_Rewrite(); } add_action( 'shutdown', [ 'WPSEO_Utils', 'clear_rewrites' ] ); @@ -351,9 +349,7 @@ function wpseo_init() { // Get a cleaned up version of the $options. } - if ( WPSEO_Options::get( 'stripcategorybase' ) === true ) { - $GLOBALS['wpseo_rewrite'] = new WPSEO_Rewrite(); - } + new WPSEO_Rewrite(); if ( WPSEO_Options::get( 'enable_xml_sitemap', null, ['wpseo'] ) === true ) { $GLOBALS['wpseo_sitemaps'] = new WPSEO_Sitemaps(); From 2eee0a5076626ea336949fd43232dc251b6f4baa Mon Sep 17 00:00:00 2001 From: Leonidas Milosis Date: Thu, 24 Oct 2024 12:15:44 +0300 Subject: [PATCH 15/23] Make setting an option straight to the specific groupt it belongs to possible and do that for setting the version options --- inc/class-upgrade.php | 4 ++-- inc/options/class-wpseo-options.php | 27 ++++++++++++++++++--------- src/helpers/options-helper.php | 9 +++++---- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/inc/class-upgrade.php b/inc/class-upgrade.php index 149224b946e..f0788250ed9 100644 --- a/inc/class-upgrade.php +++ b/inc/class-upgrade.php @@ -150,9 +150,9 @@ protected function add_upgrade_history( $current_version, $new_version ) { */ protected function finish_up( $previous_version = null ) { if ( $previous_version ) { - WPSEO_Options::set( 'previous_version', $previous_version ); + WPSEO_Options::set( 'previous_version', $previous_version, 'wpseo' ); } - WPSEO_Options::set( 'version', WPSEO_VERSION ); + WPSEO_Options::set( 'version', WPSEO_VERSION, 'wpseo' ); // Just flush rewrites, always, to at least make them work after an upgrade. add_action( 'shutdown', 'flush_rewrite_rules' ); diff --git a/inc/options/class-wpseo-options.php b/inc/options/class-wpseo-options.php index 96ea47d62f6..9b16a67da2c 100644 --- a/inc/options/class-wpseo-options.php +++ b/inc/options/class-wpseo-options.php @@ -212,6 +212,8 @@ public static function get_option_names() { /** * Retrieve all the options for the SEO plugin in one go. * + * @param array $specific_options The option groups of the option you want to get. + * * @return array Array combining the values of all the options. */ public static function get_all( $specific_options = [] ) { @@ -270,8 +272,9 @@ public static function get_option( $option_name ) { /** * Retrieve a single field from any option for the SEO plugin. Keys are always unique. * - * @param string $key The key it should return. - * @param mixed $default_value The default value that should be returned if the key isn't set. + * @param string $key The key it should return. + * @param mixed $default_value The default value that should be returned if the key isn't set. + * @param array $option_groups The option groups to retrieve the option from. * * @return mixed Returns value if found, $default_value if not. */ @@ -298,6 +301,8 @@ public static function clear_cache() { /** * Primes our cache. * + * @param array $option_groups The option groups to prime the cache with. + * * @return void */ private static function prime_cache( $option_groups = [] ) { @@ -308,13 +313,14 @@ private static function prime_cache( $option_groups = [] ) { /** * Retrieve a single field from an option for the SEO plugin. * - * @param string $key The key to set. - * @param mixed $value The value to set. + * @param string $key The key to set. + * @param mixed $value The value to set. + * @param string $option_group The lookup table which represents the option_group where the key is stored. * * @return mixed|null Returns value if found, $default if not. */ - public static function set( $key, $value ) { - $lookup_table = static::get_lookup_table(); + public static function set( $key, $value, $option_group = '' ) { + $lookup_table = static::get_lookup_table( $option_group ); if ( isset( $lookup_table[ $key ] ) ) { return static::save_option( $lookup_table[ $key ], $key, $value ); @@ -563,12 +569,15 @@ protected static function is_multisite() { /** * Retrieves a lookup table to find in which option_group a key is stored. * + * @param string $option_group The option_group where the key is stored. + * * @return array The lookup table. */ - private static function get_lookup_table() { - $lookup_table = []; + private static function get_lookup_table( $option_group = '' ) { + $lookup_table = []; + $option_groups = ( $option_group === '' ) ? static::$options : [ $option_group => static::$options[ $option_group ] ]; - foreach ( array_keys( static::$options ) as $option_name ) { + foreach ( array_keys( $option_groups ) as $option_name ) { $full_option = static::get_option( $option_name ); foreach ( $full_option as $key => $value ) { $lookup_table[ $key ] = $option_name; diff --git a/src/helpers/options-helper.php b/src/helpers/options-helper.php index 1352e4343c5..210ceb322b5 100644 --- a/src/helpers/options-helper.php +++ b/src/helpers/options-helper.php @@ -28,13 +28,14 @@ public function get( $key, $default_value = null ) { /** * Sets a single field to the options. * - * @param string $key The key to set. - * @param mixed $value The value to set. + * @param string $key The key to set. + * @param mixed $value The value to set. + * @param string $option_group The lookup table which represents the option_group where the key is stored. * * @return mixed|null Returns value if found. */ - public function set( $key, $value ) { - return WPSEO_Options::set( $key, $value ); + public function set( $key, $value, $option_group = '' ) { + return WPSEO_Options::set( $key, $value, $option_group ); } /** From d89e2213945bf2781fbb6a64700ce55e67f62268 Mon Sep 17 00:00:00 2001 From: Leonidas Milosis Date: Thu, 24 Oct 2024 12:38:43 +0300 Subject: [PATCH 16/23] Fix BC of class rewrite change --- inc/class-rewrite.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/inc/class-rewrite.php b/inc/class-rewrite.php index 87709fd586f..9622ada0aad 100644 --- a/inc/class-rewrite.php +++ b/inc/class-rewrite.php @@ -17,7 +17,7 @@ public function __construct() { add_filter( 'query_vars', [ $this, 'query_vars' ] ); add_filter( 'term_link', [ $this, 'no_category_base' ], 10, 3 ); add_filter( 'request', [ $this, 'request' ] ); - add_filter( 'category_rewrite_rules', [ $this, 'category_rewrite_rules' ] ); + add_filter( 'category_rewrite_rules', [ $this, 'category_rewrite_rules_wrapper' ] ); add_action( 'created_category', [ $this, 'schedule_flush' ] ); add_action( 'edited_category', [ $this, 'schedule_flush' ] ); @@ -110,15 +110,26 @@ public function request( $query_vars ) { } /** - * This function taken and only slightly adapted from WP No Category Base plugin by Saurabh Gupta. + * Wrapper for the category_rewrite_rules() below, so we can add the $rules param in a BC way. + * + * @param array $rules Rewrite rules generated for the current permastruct, keyed by their regex pattern. * * @return array The category rewrite rules. */ - public function category_rewrite_rules( $rules ) { + public function category_rewrite_rules_wrapper( $rules ) { if ( WPSEO_Options::get( 'stripcategorybase' ) !== true ) { return $rules; } + return $this->category_rewrite_rules(); + } + + /** + * This function taken and only slightly adapted from WP No Category Base plugin by Saurabh Gupta. + * + * @return array The category rewrite rules. + */ + public function category_rewrite_rules() { global $wp_rewrite; $category_rewrite = []; From 30138f58acaf5e0f2ca20b6266c53f7f0290c671 Mon Sep 17 00:00:00 2001 From: Leonidas Milosis Date: Thu, 24 Oct 2024 12:49:52 +0300 Subject: [PATCH 17/23] Fix PHPCS --- inc/options/class-wpseo-options.php | 2 +- wp-seo-main.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/inc/options/class-wpseo-options.php b/inc/options/class-wpseo-options.php index 9b16a67da2c..b162fdb2eb0 100644 --- a/inc/options/class-wpseo-options.php +++ b/inc/options/class-wpseo-options.php @@ -212,7 +212,7 @@ public static function get_option_names() { /** * Retrieve all the options for the SEO plugin in one go. * - * @param array $specific_options The option groups of the option you want to get. + * @param array $specific_options The option groups of the option you want to get. * * @return array Array combining the values of all the options. */ diff --git a/wp-seo-main.php b/wp-seo-main.php index 6f274110dc0..5510059141a 100644 --- a/wp-seo-main.php +++ b/wp-seo-main.php @@ -339,7 +339,7 @@ function wpseo_init() { WPSEO_Options::get_instance(); WPSEO_Meta::init(); - if ( version_compare( WPSEO_Options::get( 'version', 1, ['wpseo'] ), WPSEO_VERSION, '<' ) ) { + if ( version_compare( WPSEO_Options::get( 'version', 1, [ 'wpseo' ] ), WPSEO_VERSION, '<' ) ) { if ( function_exists( 'opcache_reset' ) ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Prevent notices when opcache.restrict_api is set. @opcache_reset(); @@ -351,7 +351,7 @@ function wpseo_init() { new WPSEO_Rewrite(); - if ( WPSEO_Options::get( 'enable_xml_sitemap', null, ['wpseo'] ) === true ) { + if ( WPSEO_Options::get( 'enable_xml_sitemap', null, [ 'wpseo' ] ) === true ) { $GLOBALS['wpseo_sitemaps'] = new WPSEO_Sitemaps(); } From aa40fe485c50296339f613156a0e06f8f5fba989 Mon Sep 17 00:00:00 2001 From: Leonidas Milosis Date: Thu, 24 Oct 2024 13:06:24 +0300 Subject: [PATCH 18/23] Fix unit tests --- tests/Unit/Admin/Admin_Features_Test.php | 43 ++---------------------- 1 file changed, 3 insertions(+), 40 deletions(-) diff --git a/tests/Unit/Admin/Admin_Features_Test.php b/tests/Unit/Admin/Admin_Features_Test.php index 91eeabe8f7e..df4aba3b4fe 100644 --- a/tests/Unit/Admin/Admin_Features_Test.php +++ b/tests/Unit/Admin/Admin_Features_Test.php @@ -5,12 +5,9 @@ use Brain\Monkey; use Mockery; use Wincher_Dashboard_Widget; -use WP_User; use WPSEO_Admin; use WPSEO_Primary_Term_Admin; use Yoast\WP\SEO\Helpers\Current_Page_Helper; -use Yoast\WP\SEO\Helpers\Product_Helper; -use Yoast\WP\SEO\Helpers\Short_Link_Helper; use Yoast\WP\SEO\Helpers\Url_Helper; use Yoast\WP\SEO\Tests\Unit\TestCase; use Yoast_Dashboard_Widget; @@ -22,32 +19,6 @@ */ final class Admin_Features_Test extends TestCase { - /** - * Returns an instance with set expectations for the dependencies. - * - * @return WPSEO_Admin Instance to test against. - */ - private function get_admin_with_expectations() { - Monkey\Functions\expect( 'admin_url' ) - ->once() - ->with( '?page=' . WPSEO_Admin::PAGE_IDENTIFIER . '&yoast_dismiss=upsell' ) - ->andReturn( 'https://example.org' ); - - Monkey\Functions\expect( 'wp_nonce_url' ) - ->once() - ->with( 'https://example.org', 'dismiss-5star-upsell' ) - ->andReturn( 'https://example.org?_wpnonce=test-nonce' ); - - $admin_user = Mockery::mock( WP_User::class ); - $admin_user->ID = 1; - - Monkey\Functions\expect( 'get_current_user_id' ) - ->once() - ->andReturn( $admin_user->ID ); - - return new WPSEO_Admin(); - } - /** * Sets up the YoastSEO function with the right expectations. * @@ -59,26 +30,18 @@ private function setup_yoastseo_with_expectations() { $current_page_helper = Mockery::mock( Current_Page_Helper::class ); $current_page_helper->expects( 'is_yoast_seo_page' )->once()->andReturn( true ); - $product_helper = Mockery::mock( Product_Helper::class ); - $product_helper->expects( 'is_premium' )->once()->andReturn( false ); - - $short_link = Mockery::mock( Short_Link_Helper::class ); - $short_link->expects( 'get' )->times( 3 )->andReturn( 'https://www.example.com?some=var' ); - $url_helper = Mockery::mock( Url_Helper::class ); $url_helper->expects( 'is_plugin_network_active' )->twice()->andReturn( false ); $container = $this->create_container_with( [ Current_Page_Helper::class => $current_page_helper, - Product_Helper::class => $product_helper, - Short_Link_Helper::class => $short_link, Url_Helper::class => $url_helper, ] ); Monkey\Functions\expect( 'YoastSEO' ) - ->times( 7 ) + ->times( 3 ) ->andReturn( (object) [ 'helpers' => $this->create_helper_surface( $container ) ] ); Monkey\Functions\expect( 'get_user_locale' ) @@ -98,7 +61,7 @@ public function test_get_admin_features_ON_post_edit() { $this->setup_yoastseo_with_expectations(); - $class_instance = $this->get_admin_with_expectations(); + $class_instance = new WPSEO_Admin(); $admin_features = [ 'primary_category' => new WPSEO_Primary_Term_Admin(), @@ -122,7 +85,7 @@ public function test_get_admin_features_NOT_ON_post_edit() { $this->setup_yoastseo_with_expectations(); - $class_instance = $this->get_admin_with_expectations(); + $class_instance = new WPSEO_Admin(); $admin_features = [ 'dashboard_widget' => new Yoast_Dashboard_Widget(), From b28111ae63930944662e9a171e01d3d8f99b86b1 Mon Sep 17 00:00:00 2001 From: Leonidas Milosis Date: Fri, 25 Oct 2024 13:01:51 +0300 Subject: [PATCH 19/23] Get options related to posts asking only the wpseo option --- admin/class-admin-init.php | 2 +- admin/metabox/class-metabox.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/admin/class-admin-init.php b/admin/class-admin-init.php index 168e789a45b..44b21376377 100644 --- a/admin/class-admin-init.php +++ b/admin/class-admin-init.php @@ -250,7 +250,7 @@ private function register_premium_upsell_admin_block() { * @return void */ private function load_xml_sitemaps_admin() { - if ( WPSEO_Options::get( 'enable_xml_sitemap', false ) ) { + if ( WPSEO_Options::get( 'enable_xml_sitemap', null, [ 'wpseo' ] ) ) { new WPSEO_Sitemaps_Admin(); } } diff --git a/admin/metabox/class-metabox.php b/admin/metabox/class-metabox.php index d514cdc8e28..71b0c4a4c77 100644 --- a/admin/metabox/class-metabox.php +++ b/admin/metabox/class-metabox.php @@ -87,8 +87,8 @@ public function __construct() { $this->editor = new WPSEO_Metabox_Editor(); $this->editor->register_hooks(); - $this->social_is_enabled = WPSEO_Options::get( 'opengraph', false ) || WPSEO_Options::get( 'twitter', false ); - $this->is_advanced_metadata_enabled = WPSEO_Capability_Utils::current_user_can( 'wpseo_edit_advanced_metadata' ) || WPSEO_Options::get( 'disableadvanced_meta' ) === false; + $this->social_is_enabled = WPSEO_Options::get( 'opengraph', false, [ 'wpseo_social' ] ) || WPSEO_Options::get( 'twitter', false, [ 'wpseo_social' ] ); + $this->is_advanced_metadata_enabled = WPSEO_Capability_Utils::current_user_can( 'wpseo_edit_advanced_metadata' ) || WPSEO_Options::get( 'disableadvanced_meta', null, [ 'wpseo' ] ) === false; $this->seo_analysis = new WPSEO_Metabox_Analysis_SEO(); $this->readability_analysis = new WPSEO_Metabox_Analysis_Readability(); From 927084cf143a001e37c1e77cf8bceb6fc0b75f7d Mon Sep 17 00:00:00 2001 From: Leonidas Milosis Date: Tue, 29 Oct 2024 10:36:08 +0200 Subject: [PATCH 20/23] Move enqueuing explanation assets in a later hook --- admin/filters/class-abstract-post-filter.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/admin/filters/class-abstract-post-filter.php b/admin/filters/class-abstract-post-filter.php index be3da94431f..08232076870 100644 --- a/admin/filters/class-abstract-post-filter.php +++ b/admin/filters/class-abstract-post-filter.php @@ -61,7 +61,7 @@ public function register_hooks() { add_action( 'restrict_manage_posts', [ $this, 'render_hidden_input' ] ); } - if ( $this->is_filter_active() && $this->get_explanation() !== null ) { + if ( $this->is_filter_active() ) { add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_explanation_assets' ] ); } } @@ -83,13 +83,19 @@ public function add_filter_links() { * @return void */ public function enqueue_explanation_assets() { + $explanation = $this->get_explanation(); + + if ( $explanation === null ) { + return; + } + $asset_manager = new WPSEO_Admin_Asset_Manager(); $asset_manager->enqueue_script( 'filter-explanation' ); $asset_manager->enqueue_style( 'filter-explanation' ); $asset_manager->localize_script( 'filter-explanation', 'yoastFilterExplanation', - [ 'text' => $this->get_explanation() ] + [ 'text' => $explanation ] ); } From 7cc305a521f6d08c8fdaea31e1145415a6198217 Mon Sep 17 00:00:00 2001 From: Leonidas Milosis Date: Tue, 29 Oct 2024 12:31:28 +0200 Subject: [PATCH 21/23] Restore adding the WPSEO_Sitemaps instance in the global object --- wp-seo-main.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-seo-main.php b/wp-seo-main.php index 5510059141a..8495168e82c 100644 --- a/wp-seo-main.php +++ b/wp-seo-main.php @@ -349,7 +349,7 @@ function wpseo_init() { // Get a cleaned up version of the $options. } - new WPSEO_Rewrite(); + $GLOBALS['wpseo_rewrite'] = new WPSEO_Rewrite(); if ( WPSEO_Options::get( 'enable_xml_sitemap', null, [ 'wpseo' ] ) === true ) { $GLOBALS['wpseo_sitemaps'] = new WPSEO_Sitemaps(); From b9fd9a3b4b048329d34108a685d26251dea3d5c6 Mon Sep 17 00:00:00 2001 From: Leonidas Milosis Date: Tue, 29 Oct 2024 16:56:04 +0200 Subject: [PATCH 22/23] Check only for option key existence before priming cache --- inc/options/class-wpseo-options.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/options/class-wpseo-options.php b/inc/options/class-wpseo-options.php index b162fdb2eb0..41c884f21ff 100644 --- a/inc/options/class-wpseo-options.php +++ b/inc/options/class-wpseo-options.php @@ -279,7 +279,7 @@ public static function get_option( $option_name ) { * @return mixed Returns value if found, $default_value if not. */ public static function get( $key, $default_value = null, $option_groups = [] ) { - if ( ! isset( static::$option_values[ $key ] ) || static::$option_values[ $key ] === null ) { + if ( ! isset( static::$option_values[ $key ] ) ) { static::prime_cache( $option_groups ); } if ( isset( static::$option_values[ $key ] ) ) { From 3c3bfbb310806baec98bf2eb8a077cd1e3b37289 Mon Sep 17 00:00:00 2001 From: Leonidas Milosis Date: Tue, 29 Oct 2024 17:04:56 +0200 Subject: [PATCH 23/23] Use previous default value for enable_xml_sitemap option --- admin/class-admin-init.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/class-admin-init.php b/admin/class-admin-init.php index 44b21376377..dbd3a983bc2 100644 --- a/admin/class-admin-init.php +++ b/admin/class-admin-init.php @@ -250,7 +250,7 @@ private function register_premium_upsell_admin_block() { * @return void */ private function load_xml_sitemaps_admin() { - if ( WPSEO_Options::get( 'enable_xml_sitemap', null, [ 'wpseo' ] ) ) { + if ( WPSEO_Options::get( 'enable_xml_sitemap', false, [ 'wpseo' ] ) ) { new WPSEO_Sitemaps_Admin(); } }