Skip to content

Prevent strip_tags() deprecation notices with add_submenu_page()#23003

Merged
leonidasmi merged 8 commits intoYoast:trunkfrom
sabernhardt:trunk
Mar 6, 2026
Merged

Prevent strip_tags() deprecation notices with add_submenu_page()#23003
leonidasmi merged 8 commits intoYoast:trunkfrom
sabernhardt:trunk

Conversation

@sabernhardt
Copy link
Contributor

@sabernhardt sabernhardt commented Feb 17, 2026

Context

To prevent deprecation notices on any administration page, #19124 and #19191 changed the null value for parent slug in add_submenu_page() functions to an empty string. However, the empty string can still result in one deprecation notice on specific Yoast SEO pages.
Deprecated: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated in ...\wp-admin\admin-header.php on line 41

Summary

This PR can be summarized in the following changelog entry:

  • Fixes a bug where Deprecated: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated notices appeared on certain actions, like when activating the plugin, or saving a Yoast setting. Props to @sabernhardt.

For comparison, Yoast SEO 19.12 listed the change from null to empty string under the "Other" heading:

Reduces noise from PHP 8.1 deprecations.

Relevant technical choices:

  • 'options.php' comes from the WordPress Codex example, which incorrectly suggested null before mentioning the possibility of using a string value.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps (combining steps from PR 19191 and issue 22029):

  • Use a PHP version of 8.1 or newer.
  • Enable the WordPress debug log.
  • To test the installation-success-integration, open {site_url}/wp-admin/admin.php?page=wpseo_installation_successful_free. Its main heading should be "You've successfully installed Yoast SEO!" (or a translation). With the PR applied, the page <title> would start with "Installation Successful" and the deprecation notice should not appear on the page or in the debug log.
  • To test the settings-integration, navigate directly to {site_url}/wp-admin/admin.php?page=wpseo_page_settings_saved and confirm that you dont get deprecation notices in the debug.log.
    • For regression test: Make sure you are able to change and save settings in the Yoast settings page. Again confirm that you dont get deprecation notices in the debug.log.
    • Do the same in a network site too.
  • For old-configuration-integration, there were no deprecation messages ever shown because we redirect immediately, but we changed it like the other places, to keep things aligned.
    • For regression test: Go to {site_url}/wp-admin/admin.php?page=wpseo_configurator and make sure you get redirected to {site_url}/wp-admin/admin.php?page=wpseo_dashboard#top#first-time-configuration.
  • For setup-url-interceptor, there were no deprecation messages ever shown because we redirect immediately, but we changed it like the other places, to keep things aligned.

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

QA can test this PR by following these steps:

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.
  • This PR also affects Yoast SEO for Google Docs. I have added a changelog entry starting with [yoast-doc-extension], added test instructions for Yoast SEO for Google Docs and attached the Google Docs Add-on label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.
  • I have run grunt build:images and commited the results, if my PR introduces new images or SVGs.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes #22029

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses PHP 8.1+ deprecation notices (strip_tags(null)) on specific Yoast admin pages by ensuring the affected “hidden/dummy” admin pages are registered via add_submenu_page() with a valid parent slug.

Changes:

  • Update several add_submenu_page() calls to use options.php as the parent slug (instead of an empty string).
  • Align unit tests with the updated add_submenu_page() expectations.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/integrations/settings-integration.php Registers the settings “saved” dummy page under options.php to avoid null-title edge cases.
src/integrations/admin/old-configuration-integration.php Registers the old configurator redirect page under options.php to prevent deprecation noise.
src/integrations/admin/installation-success-integration.php Registers the installation success page under options.php so WP can resolve a non-null page title.
src/dashboard/user-interface/setup/setup-url-interceptor.php Registers the Site Kit setup in-between page under options.php to avoid null-title behavior.
tests/Unit/Integrations/Settings_Integration_Test.php Updates expected add_submenu_page() parent slug to options.php.
tests/Unit/Integrations/Admin/Old_Configuration_Integration_Test.php Updates expected add_submenu_page() parent slug to options.php.
tests/Unit/Integrations/Admin/Installation_Success_Integration_Test.php Updates expected add_submenu_page() parent slug to options.php.
tests/Unit/Dashboard/User_Interface/Setup/Setup_Url_Interceptor_Add_Redirect_Page_Test.php Updates expected add_submenu_page() parent slug to options.php.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@leonidasmi leonidasmi added this to the 27.3 milestone Mar 6, 2026
Copy link
Contributor

@leonidasmi leonidasmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR + Acceptance is ✅

Thanks for contributing!

@leonidasmi leonidasmi merged commit ede936a into Yoast:trunk Mar 6, 2026
25 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: bugfix Needs to be included in the 'Bugfixes' category in the changelog community-patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

E_DEPRECATED: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated

5 participants