From 8ce87974d83c72d62d338852d55a86b91874de15 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Sat, 17 Oct 2026 04:58:15 +0000 Subject: [PATCH 001/236] Docs: Use `@link` instead of `@see` for URL references. The WordPress inline documentation standards for PHP and JavaScript reserve `@see` for references to functions, methods, classes, and hooks, and use `@link` for URLs. While phpDocumentor and JSDoc both accept a URL in `@see`, core had used both forms for external references such as specifications, Trac tickets, and GitHub pull requests, so the remaining `@see` tags pointing to URLs are converted to `@link` across core, the bundled themes, core scripts, and the unit tests. On the touched lines, `@see` is kept ahead of `@link` where both appear, per the standards; links to developer.wordpress.org pages for core functions in Twenty Twenty become `@see` references to those functions; and links that no longer resolve are updated. The block files synced from Gutenberg, the bundled pomo library, and other third-party code are left unchanged, and the HTML API is handled separately. Developed in https://github.com/WordPress/wordpress-develop/pull/10804. Follow-up to r63569. Props huzaifaalmesbah, westonruter, noruzzaman, shailu25. See #65860. git-svn-id: https://develop.svn.wordpress.org/trunk@64436 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/deprecated/fakejshint.js | 4 ++-- .../lib/codemirror/javascript-lint.js | 6 ++--- .../twentyfifteen/inc/custom-header.php | 4 ++-- .../class-twentytwenty-walker-comment.php | 10 ++++---- src/wp-includes/blocks.php | 2 +- .../class-wp-http-requests-hooks.php | 4 ++-- src/wp-includes/class-wp-script-modules.php | 6 ++--- src/wp-includes/class-wp-theme-json.php | 12 +++++----- .../class-wp-url-pattern-prefixer.php | 2 +- src/wp-includes/class-wpdb.php | 2 +- src/wp-includes/compat-utf8.php | 4 ++-- src/wp-includes/compat.php | 4 ++-- .../class-wp-customize-custom-css-setting.php | 2 +- src/wp-includes/deprecated.php | 10 ++++---- src/wp-includes/formatting.php | 10 ++++---- src/wp-includes/functions.php | 24 +++++++++---------- .../global-styles-and-settings.php | 4 ++-- src/wp-includes/kses.php | 4 ++-- src/wp-includes/media.php | 6 ++--- src/wp-includes/nav-menu-template.php | 2 +- src/wp-includes/pluggable.php | 2 +- src/wp-includes/script-loader.php | 10 ++++---- src/wp-includes/speculative-loading.php | 2 +- src/wp-includes/style-engine.php | 4 ++-- src/wp-includes/theme-previews.php | 2 +- src/wp-includes/user.php | 2 +- src/wp-includes/utf8.php | 10 ++++---- src/wp-load.php | 2 +- tests/phpunit/tests/actions.php | 2 +- tests/phpunit/tests/auth.php | 2 +- tests/phpunit/tests/blocks/serialize.php | 4 ++-- .../phpunit/tests/formatting/balanceTags.php | 4 ++-- tests/phpunit/tests/pomo/pluralForms.php | 2 +- .../rest-api/wpRestMenuItemsController.php | 2 +- 34 files changed, 86 insertions(+), 86 deletions(-) diff --git a/src/js/_enqueues/deprecated/fakejshint.js b/src/js/_enqueues/deprecated/fakejshint.js index b3290c4406064..c064d4d505c5a 100644 --- a/src/js/_enqueues/deprecated/fakejshint.js +++ b/src/js/_enqueues/deprecated/fakejshint.js @@ -6,8 +6,8 @@ * @since 4.9.3 * @deprecated 7.0.0 * @output wp-includes/js/codemirror/fakejshint.js - * @see https://core.trac.wordpress.org/ticket/42850 - * @see https://core.trac.wordpress.org/ticket/64558 + * @link https://core.trac.wordpress.org/ticket/42850 + * @link https://core.trac.wordpress.org/ticket/64558 */ /* jshint -W057, -W058 */ diff --git a/src/js/_enqueues/lib/codemirror/javascript-lint.js b/src/js/_enqueues/lib/codemirror/javascript-lint.js index 15fefe832805c..20c50d548d6f1 100644 --- a/src/js/_enqueues/lib/codemirror/javascript-lint.js +++ b/src/js/_enqueues/lib/codemirror/javascript-lint.js @@ -9,7 +9,7 @@ import CodeMirror from 'codemirror'; /** * CodeMirror Lint Error. * - * @see https://codemirror.net/5/doc/manual.html#addon_lint + * @link https://codemirror.net/5/doc/manual.html#addon_lint * * @typedef {Object} CodeMirrorLintError * @property {string} message Error message. @@ -21,8 +21,8 @@ import CodeMirror from 'codemirror'; /** * JSHint options supported by Espree. * - * @see https://jshint.com/docs/options/ - * @see https://www.npmjs.com/package/espree#options + * @link https://jshint.com/docs/options/ + * @link https://www.npmjs.com/package/espree#options * * @typedef {Object} SupportedJSHintOptions * @property {import('espree').Options['ecmaVersion']} [esversion] "This option is used to specify the ECMAScript version to which the code must adhere." diff --git a/src/wp-content/themes/twentyfifteen/inc/custom-header.php b/src/wp-content/themes/twentyfifteen/inc/custom-header.php index 699d72cec7b31..68ebb0a398f62 100644 --- a/src/wp-content/themes/twentyfifteen/inc/custom-header.php +++ b/src/wp-content/themes/twentyfifteen/inc/custom-header.php @@ -146,7 +146,7 @@ function twentyfifteen_header_style() { /* * No shorthand so the Customizer can override individual properties. - * @see https://core.trac.wordpress.org/ticket/31460 + * @link https://core.trac.wordpress.org/ticket/31460 */ background-image: url(); background-repeat: no-repeat; @@ -162,7 +162,7 @@ function twentyfifteen_header_style() { /* * No shorthand so the Customizer can override individual properties. - * @see https://core.trac.wordpress.org/ticket/31460 + * @link https://core.trac.wordpress.org/ticket/31460 */ background-image: url(); background-repeat: no-repeat; diff --git a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-walker-comment.php b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-walker-comment.php index 8012677ce8e76..329f7164ee518 100644 --- a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-walker-comment.php +++ b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-walker-comment.php @@ -22,11 +22,11 @@ class TwentyTwenty_Walker_Comment extends Walker_Comment { * @since Twenty Twenty 1.0 * * @see wp_list_comments() - * @see https://developer.wordpress.org/reference/functions/get_comment_author_url/ - * @see https://developer.wordpress.org/reference/functions/get_comment_author/ - * @see https://developer.wordpress.org/reference/functions/get_avatar/ - * @see https://developer.wordpress.org/reference/functions/get_comment_reply_link/ - * @see https://developer.wordpress.org/reference/functions/get_edit_comment_link/ + * @see get_comment_author_url() + * @see get_comment_author() + * @see get_avatar() + * @see get_comment_reply_link() + * @see get_edit_comment_link() * * @param WP_Comment $comment Comment to display. * @param int $depth Depth of the current comment. diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 1701548d8d3fa..626e7b7f14f4a 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -2843,7 +2843,7 @@ function build_query_vars_from_query_block( $block, $page ) { * Logic should be used beforehand to determine if WP_Query should be used in the event that the array * being passed to post__in is empty. * - * @see https://core.trac.wordpress.org/ticket/28099 + * @link https://core.trac.wordpress.org/ticket/28099 */ $query['post__in'] = ! empty( $sticky ) ? $sticky : array( 0 ); $query['ignore_sticky_posts'] = 1; diff --git a/src/wp-includes/class-wp-http-requests-hooks.php b/src/wp-includes/class-wp-http-requests-hooks.php index f399acc860229..aac172892f293 100644 --- a/src/wp-includes/class-wp-http-requests-hooks.php +++ b/src/wp-includes/class-wp-http-requests-hooks.php @@ -64,10 +64,10 @@ public function dispatch( $hook, $parameters = array() ) { * * This action maps Requests internal hook to a native WordPress action. * - * @see https://github.com/WordPress/Requests/blob/master/docs/hooks.md - * * @since 4.7.0 * + * @link https://github.com/WordPress/Requests/blob/stable/docs/hooks.md + * * @param array $parameters Parameters from Requests internal hook. * @param array $request Request data in WP_Http format. * @param string $url URL to request. diff --git a/src/wp-includes/class-wp-script-modules.php b/src/wp-includes/class-wp-script-modules.php index 9c9f8a762af5e..180b42362db1a 100644 --- a/src/wp-includes/class-wp-script-modules.php +++ b/src/wp-includes/class-wp-script-modules.php @@ -1102,9 +1102,9 @@ public function print_script_module_data(): void { * is not encoded in UTF-8 then it's not safe to include those literals. They must * be escaped to avoid encoding issues. * - * @see https://www.rfc-editor.org/rfc/rfc8259.html for details on encoding requirements. - * @see https://www.php.net/manual/en/json.constants.php for details on these constants. - * @see https://html.spec.whatwg.org/#script-data-state for details on script tag parsing. + * @link https://www.rfc-editor.org/rfc/rfc8259.html for details on encoding requirements. + * @link https://www.php.net/manual/en/json.constants.php for details on these constants. + * @link https://html.spec.whatwg.org/#script-data-state for details on script tag parsing. */ $json_encode_flags = JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_LINE_TERMINATORS; if ( ! is_utf8_charset() ) { diff --git a/src/wp-includes/class-wp-theme-json.php b/src/wp-includes/class-wp-theme-json.php index f665f9acd19eb..f5cdc1b43c6a1 100644 --- a/src/wp-includes/class-wp-theme-json.php +++ b/src/wp-includes/class-wp-theme-json.php @@ -1583,7 +1583,7 @@ protected static function append_to_selector( $selector, $to_append ) { * there should be no way for a comma to mean anything other than a * comma token. The exception are syntax errors, which are not handled here. * - * @see https://www.w3.org/TR/css-syntax-3/#parse-comma-separated-list-of-component-values + * @link https://www.w3.org/TR/css-syntax-3/#parse-comma-separated-list-of-component-values */ if ( strlen( $selector ) === strcspn( $selector, '/\'"(<\\' ) ) { return preg_replace( '~[ \t\n]*,[ \t\n]*~', "{$to_append}, ", trim( $selector, " \t\n" ) ) . $to_append; @@ -1632,7 +1632,7 @@ protected static function prepend_to_selector( $selector, $to_prepend ) { * there should be no way for a comma to mean anything other than a * comma token. The exception are syntax errors, which are not handled here. * - * @see https://www.w3.org/TR/css-syntax-3/#parse-comma-separated-list-of-component-values + * @link https://www.w3.org/TR/css-syntax-3/#parse-comma-separated-list-of-component-values */ if ( strlen( $selector ) === strcspn( $selector, '/\'"(<\\' ) ) { return $to_prepend . preg_replace( '~[ \t\n]*,[ \t\n]*~', ", {$to_prepend}", trim( $selector, " \t\n" ) ); @@ -1677,8 +1677,8 @@ protected static function prepend_to_selector( $selector, $to_prepend ) { * // Comments stay with the selector they follow. * array( '.a /* a, the first *\/', '.b' ) === self::split_selector_list( '.a /* a, the first *\/,.b' ); * - * @see https://www.w3.org/TR/selectors/#parse-selector - * @see https://www.w3.org/TR/css-syntax-3/ + * @link https://www.w3.org/TR/selectors/#parse-selector + * @link https://www.w3.org/TR/css-syntax-3/ * * @since 7.1.0 * @@ -1785,8 +1785,8 @@ protected static function split_selector_list( $selector ): array { * > not included in this definition, as they are converted * > to U+000A LINE FEED during preprocessing. * - * @see https://www.w3.org/TR/css-syntax/#whitespace - * @see https://www.w3.org/TR/css-syntax/#newline + * @link https://www.w3.org/TR/css-syntax/#whitespace + * @link https://www.w3.org/TR/css-syntax/#newline */ $selectors[] = trim( substr( $selector, $was_at, $next_at - $was_at ), " \t\n" ); $at = $next_at + 1; diff --git a/src/wp-includes/class-wp-url-pattern-prefixer.php b/src/wp-includes/class-wp-url-pattern-prefixer.php index a79e6e10c8cc0..3e94db53ff7b2 100644 --- a/src/wp-includes/class-wp-url-pattern-prefixer.php +++ b/src/wp-includes/class-wp-url-pattern-prefixer.php @@ -124,7 +124,7 @@ public static function get_default_contexts(): array { * Escapes a string for use in a URL pattern component. * * @since 6.8.0 - * @see https://urlpattern.spec.whatwg.org/#escape-a-pattern-string + * @link https://urlpattern.spec.whatwg.org/#escape-a-pattern-string * * @param string $str String to be escaped. * @return string String with backslashes added where required. diff --git a/src/wp-includes/class-wpdb.php b/src/wp-includes/class-wpdb.php index f961813c3f386..9537cdc57cf2c 100644 --- a/src/wp-includes/class-wpdb.php +++ b/src/wp-includes/class-wpdb.php @@ -1992,7 +1992,7 @@ public function db_connect( $allow_bail = true ) { /* * If using the `mysqlnd` library, the IPv6 address needs to be enclosed * in square brackets, whereas it doesn't while using the `libmysqlclient` library. - * @see https://bugs.php.net/bug.php?id=67563 + * @link https://bugs.php.net/bug.php?id=67563 */ if ( $is_ipv6 && extension_loaded( 'mysqlnd' ) ) { $host = "[$host]"; diff --git a/src/wp-includes/compat-utf8.php b/src/wp-includes/compat-utf8.php index 5fa8cde158789..326786fe608f2 100644 --- a/src/wp-includes/compat-utf8.php +++ b/src/wp-includes/compat-utf8.php @@ -120,7 +120,7 @@ function _wp_scan_utf8( string $bytes, int &$at, int &$invalid_length, ?int $max * │ U+100000..U+10FFFF │ F4 │ 80..8F │ 80..BF │ 80..BF │ * ╰─────────────────────┴────────────┴──────────────┴─────────────┴──────────────╯ * - * @see https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-3/#G27506 + * @link https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-3/#G27506 */ // Valid two-byte code points. @@ -197,7 +197,7 @@ function _wp_scan_utf8( string $bytes, int &$at, int &$invalid_length, ?int $max * > Furthermore, this practice can be defined consistently for better * > interoperability between different implementations of conversion. * - * @see https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-5/#G40630 + * @link https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-5/#G40630 */ invalid_utf8: $at = $i; diff --git a/src/wp-includes/compat.php b/src/wp-includes/compat.php index bd0c09881a4e4..0aac0481c5d23 100644 --- a/src/wp-includes/compat.php +++ b/src/wp-includes/compat.php @@ -18,7 +18,7 @@ * * @since 0.71 * - * @see https://php.net/manual/en/function.gettext.php + * @link https://php.net/manual/en/function.gettext.php * * @param string $message The message being translated. * @return string @@ -459,7 +459,7 @@ function utf8_decode( $utf8_text ): string { * * An array is considered a list if its keys consist of consecutive numbers from 0 to count($array)-1. * - * @see https://github.com/symfony/polyfill-php81/tree/main + * @link https://github.com/symfony/polyfill-php81/tree/main * * @since 6.5.0 * diff --git a/src/wp-includes/customize/class-wp-customize-custom-css-setting.php b/src/wp-includes/customize/class-wp-customize-custom-css-setting.php index 58897a7e72742..ed825618b2dc1 100644 --- a/src/wp-includes/customize/class-wp-customize-custom-css-setting.php +++ b/src/wp-includes/customize/class-wp-customize-custom-css-setting.php @@ -201,7 +201,7 @@ public function validate( $value ) { * that would have broken out of the containing STYLE element, thus * corrupting the page and potentially introducing security issues. * - * @see https://html.spec.whatwg.org/multipage/parsing.html#rawtext-end-tag-name-state + * @link https://html.spec.whatwg.org/multipage/parsing.html#rawtext-end-tag-name-state */ $possible_style_close_tag = 0 === substr_compare( $css, diff --git a/src/wp-includes/deprecated.php b/src/wp-includes/deprecated.php index df621af9267c4..63aa0d3abe8bc 100644 --- a/src/wp-includes/deprecated.php +++ b/src/wp-includes/deprecated.php @@ -6384,12 +6384,12 @@ function wp_get_global_styles_custom_css() { * that can use dynamic data (modify the stylesheet depending on some option, * settings depending on user permissions, etc.). * See some of the existing hooks to modify theme.json behavior: - * @see https://make.wordpress.org/core/2022/10/10/filters-for-theme-json-data/ + * @link https://make.wordpress.org/core/2022/10/10/filters-for-theme-json-data/ * * A different alternative considered was to invalidate the cache upon certain * events such as options add/update/delete, user meta, etc. * It was judged not enough, hence this approach. - * @see https://github.com/WordPress/gutenberg/pull/45372 + * @link https://github.com/WordPress/gutenberg/pull/45372 */ $cache_key = 'wp_get_global_styles_custom_css'; $cache_group = 'theme_json'; @@ -6517,9 +6517,9 @@ function wp_add_editor_classic_theme_styles( $editor_settings ) { * @deprecated 6.9.0 Use wp_enqueue_img_auto_sizes_contain_css_fix() instead. * @see wp_enqueue_img_auto_sizes_contain_css_fix() * - * @see https://html.spec.whatwg.org/multipage/rendering.html#img-contain-size - * @see https://core.trac.wordpress.org/ticket/62413 - * @see https://core.trac.wordpress.org/ticket/62731 + * @link https://html.spec.whatwg.org/multipage/rendering.html#img-contain-size + * @link https://core.trac.wordpress.org/ticket/62413 + * @link https://core.trac.wordpress.org/ticket/62731 */ function wp_print_auto_sizes_contain_css_fix() { _deprecated_function( __FUNCTION__, '6.9.0', 'wp_enqueue_img_auto_sizes_contain_css_fix' ); diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index 58d39a98a7a3c..d261721d70ccf 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -2054,9 +2054,9 @@ function sanitize_file_name( $filename ) { * The “Zs” in the pattern selects characters in the `Space_Separator` * category, which is what Unicode considers space characters. * - * @see https://www.unicode.org/reports/tr44/#General_Category_Values - * @see https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-6/#G17548 - * @see https://www.php.net/manual/en/regexp.reference.unicode.php + * @link https://www.unicode.org/reports/tr44/#General_Category_Values + * @link https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-6/#G17548 + * @link https://www.php.net/manual/en/regexp.reference.unicode.php */ $filename = preg_replace( '#\p{Zs}#siu', ' ', $filename ); } @@ -2655,8 +2655,8 @@ function force_balance_tags( $text ) { * To get the pattern as a string without the comments paste into a PHP * REPL like `php -a`. * - * @see https://html.spec.whatwg.org/#elements-2 - * @see https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name + * @link https://html.spec.whatwg.org/#elements-2 + * @link https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name * * @example * ~# php -a diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index b56f4986fa9a2..3b8f5bd555a4c 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -1077,7 +1077,7 @@ function build_query( $data ) { * @since 3.2.0 * @access private * - * @see https://www.php.net/manual/en/function.http-build-query.php + * @link https://www.php.net/manual/en/function.http-build-query.php * * @param array|object $data An array or object of data. Converted to array. * @param string $prefix Optional. Numeric index. If set, start parameter numbering with it. @@ -2330,8 +2330,8 @@ function wp_is_writable( $path ) { * * @since 2.8.0 * - * @see https://bugs.php.net/bug.php?id=27609 - * @see https://bugs.php.net/bug.php?id=30931 + * @link https://bugs.php.net/bug.php?id=27609 + * @link https://bugs.php.net/bug.php?id=30931 * * @param string $path Windows path to check for write-ability. * @return bool Whether the path is writable. @@ -3265,8 +3265,8 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { * finfo_file() can return duplicate mime type for Google docs, * this conditional reduces it to a single instance. * - * @see https://bugs.php.net/bug.php?id=77784 - * @see https://core.trac.wordpress.org/ticket/57898 + * @link https://bugs.php.net/bug.php?id=77784 + * @link https://core.trac.wordpress.org/ticket/57898 */ if ( 2 === substr_count( $real_mime, $google_docs_type ) ) { $real_mime = $google_docs_type; @@ -7047,7 +7047,7 @@ function wp_timezone_choice( $selected_zone, $locale = null ) { * @since 2.8.0 * @access private * - * @see https://core.trac.wordpress.org/ticket/8497 + * @link https://core.trac.wordpress.org/ticket/8497 * * @param string $str Header comment to clean up. * @return string Cleaned header comment. @@ -7257,8 +7257,8 @@ function __return_empty_string() { // phpcs:ignore WordPress.NamingConventions.V * * @since 3.0.0 * - * @see https://blogs.msdn.com/ie/archive/2008/07/02/ie8-security-part-v-comprehensive-protection.aspx - * @see https://src.chromium.org/viewvc/chrome?view=rev&revision=6985 + * @link https://learn.microsoft.com/en-us/archive/blogs/ie/ie8-security-part-v-comprehensive-protection + * @link https://fetch.spec.whatwg.org/#x-content-type-options-header */ function send_nosniff_header() { header( 'X-Content-Type-Options: nosniff' ); @@ -7375,8 +7375,8 @@ function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = ar * * @since 3.1.3 * - * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Frame-Options - * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/frame-ancestors + * @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Frame-Options + * @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/frame-ancestors */ function send_frame_options_header() { if ( ! headers_sent() ) { @@ -7454,7 +7454,7 @@ function wp_allowed_protocols() { * * @since 3.4.0 * - * @see https://core.trac.wordpress.org/ticket/19589 + * @link https://core.trac.wordpress.org/ticket/19589 * * @param string $ignore_class Optional. A class to ignore all function calls within - useful * when you want to just give info about the callee. Default null. @@ -7827,7 +7827,7 @@ function is_utf8_charset( $blog_charset = null ) { * @since 3.6.0 * @access private * - * @see https://core.trac.wordpress.org/ticket/23688 + * @link https://core.trac.wordpress.org/ticket/23688 * * @param string $charset A charset name, e.g. "UTF-8", "Windows-1252", "SJIS". * @return string The canonical form of the charset. diff --git a/src/wp-includes/global-styles-and-settings.php b/src/wp-includes/global-styles-and-settings.php index 8c9affa79a575..efa1c08d0758d 100644 --- a/src/wp-includes/global-styles-and-settings.php +++ b/src/wp-includes/global-styles-and-settings.php @@ -144,12 +144,12 @@ function wp_get_global_stylesheet( $types = array() ) { * that can use dynamic data (modify the stylesheet depending on some option, * settings depending on user permissions, etc.). * See some of the existing hooks to modify theme.json behavior: - * @see https://make.wordpress.org/core/2022/10/10/filters-for-theme-json-data/ + * @link https://make.wordpress.org/core/2022/10/10/filters-for-theme-json-data/ * * A different alternative considered was to invalidate the cache upon certain * events such as options add/update/delete, user meta, etc. * It was judged not enough, hence this approach. - * @see https://github.com/WordPress/gutenberg/pull/45372 + * @link https://github.com/WordPress/gutenberg/pull/45372 */ $cache_group = 'theme_json'; $cache_key = 'wp_get_global_stylesheet'; diff --git a/src/wp-includes/kses.php b/src/wp-includes/kses.php index aba6e0d2a559a..cbe2f4d04c3a7 100644 --- a/src/wp-includes/kses.php +++ b/src/wp-includes/kses.php @@ -2489,7 +2489,7 @@ function wp_kses_split2( $content, $allowed_html, $allowed_protocols ) { * * Preserve these comments and do not treat them like tags. * - * @see https://html.spec.whatwg.org/#bogus-comment-state + * @link https://html.spec.whatwg.org/#bogus-comment-state */ if ( 1 === preg_match( '~^(?:]*>|]*>)$~', $content ) ) { /** @@ -3389,7 +3389,7 @@ function wp_kses_normalize_entities3( $matches ) { * * @since 2.7.0 * - * @see https://www.w3.org/TR/xml/#charsets + * @link https://www.w3.org/TR/xml/#charsets * * @param int $i Unicode codepoint. * @return bool Whether or not the codepoint is a valid Unicode codepoint. diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index 2ffa92f2edba0..3bb70456116d6 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -2189,9 +2189,9 @@ function wp_sizes_attribute_includes_valid_auto( string $sizes_attr ): bool { * * @since 6.9.0 * - * @see https://html.spec.whatwg.org/multipage/rendering.html#img-contain-size - * @see https://core.trac.wordpress.org/ticket/62413 - * @see https://core.trac.wordpress.org/ticket/62731 + * @link https://html.spec.whatwg.org/multipage/rendering.html#img-contain-size + * @link https://core.trac.wordpress.org/ticket/62413 + * @link https://core.trac.wordpress.org/ticket/62731 */ function wp_enqueue_img_auto_sizes_contain_css_fix(): void { // Back-compat for plugins that disable functionality by unhooking this action. diff --git a/src/wp-includes/nav-menu-template.php b/src/wp-includes/nav-menu-template.php index bad702e35d081..c11f00855cf0d 100644 --- a/src/wp-includes/nav-menu-template.php +++ b/src/wp-includes/nav-menu-template.php @@ -651,7 +651,7 @@ function _nav_menu_item_id_use_once( $id, $item ) { * WordPress 3.0.0 so this needs to allow for cases in which the filter is * called without them. * - * @see https://core.trac.wordpress.org/ticket/56926 + * @link https://core.trac.wordpress.org/ticket/56926 * * @since 6.2.0 * diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index d13769cf84afe..0aaeabbb3b9c0 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -2392,7 +2392,7 @@ function wp_new_user_notification( $user_id, $deprecated = null, $notify = '' ) * end in a period. To avoid the ambiguity, ensure that the login is not the last query * arg in the URL. If moving it to the end, a trailing period will need to be escaped. * - * @see https://core.trac.wordpress.org/tickets/42957 + * @link https://core.trac.wordpress.org/ticket/42957 */ $message .= network_site_url( 'wp-login.php?login=' . rawurlencode( $user->user_login ) . "&key=$key&action=rp", 'login' ) . "\r\n"; diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index cd1d53a5fb93f..dfaaf73ede55a 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -178,7 +178,7 @@ function wp_default_packages_vendor( $scripts ) { * These scripts enable hot module replacement (HMR) for block development * when using `wp-scripts start --hot`. * - * @see https://github.com/WordPress/gutenberg/tree/trunk/packages/scripts#start + * @link https://github.com/WordPress/gutenberg/tree/trunk/packages/scripts#start * * @since 6.0.0 * @@ -3051,7 +3051,7 @@ function wp_prefetch_admin_assets(): void { /** * Prefetches the page's rel=prefetch links with fetch() in browsers that do not support rel=prefetch. * - * @see https://caniuse.com/link-rel-prefetch + * @link https://caniuse.com/link-rel-prefetch */ () => { if ( document.createElement( 'link' ).relList?.supports?.( 'prefetch' ) ) { @@ -4657,8 +4657,8 @@ public function replace( string $text ): void { * * @since 6.9.0 * - * @see https://html.spec.whatwg.org/#concept-domstringmap-pairs * @see \wp_html_custom_data_attribute_name() + * @link https://html.spec.whatwg.org/#concept-domstringmap-pairs * * @param string $html_attribute_name Raw attribute name as found in the source HTML. * @return string|null Transformed `dataset` name, if interpretable as a custom data attribute, else `null`. @@ -4684,7 +4684,7 @@ function wp_js_dataset_name( string $html_attribute_name ): ?string { * > U+002D HYPHEN-MINUS character (-) and replace the character that * > followed it by the same character converted to ASCII uppercase. * - * @see https://html.spec.whatwg.org/#concept-domstringmap-pairs + * @link https://html.spec.whatwg.org/#concept-domstringmap-pairs */ $custom_name = ''; $at = 5; @@ -4735,8 +4735,8 @@ function wp_js_dataset_name( string $html_attribute_name ): ?string { * * @since 6.9.0 * - * @see https://html.spec.whatwg.org/#concept-domstringmap-pairs * @see \wp_js_dataset_name() + * @link https://html.spec.whatwg.org/#concept-domstringmap-pairs * * @param string $js_dataset_name Name of JS `dataset` property to transform. * @return string|null Corresponding name of an HTML custom data attribute for the given dataset name, diff --git a/src/wp-includes/speculative-loading.php b/src/wp-includes/speculative-loading.php index dd33cc5395ab5..bb20f805a738a 100644 --- a/src/wp-includes/speculative-loading.php +++ b/src/wp-includes/speculative-loading.php @@ -51,7 +51,7 @@ function wp_get_speculation_rules_configuration(): ?array { * indicating that speculative loading is entirely disabled. * * @since 6.8.0 - * @see https://developer.chrome.com/docs/web-platform/prerender-pages + * @link https://developer.chrome.com/docs/web-platform/prerender-pages * * @param array|null $config Associative array with 'mode' and 'eagerness' keys, or `null`. The * default value for both of the keys is 'auto'. Other possible values diff --git a/src/wp-includes/style-engine.php b/src/wp-includes/style-engine.php index b5c7c968631b4..835f1c3f1b723 100644 --- a/src/wp-includes/style-engine.php +++ b/src/wp-includes/style-engine.php @@ -32,8 +32,8 @@ * * @since 6.1.0 * - * @see https://developer.wordpress.org/block-editor/reference-guides/theme-json-reference/theme-json-living/#styles - * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/ + * @link https://developer.wordpress.org/block-editor/reference-guides/theme-json-reference/theme-json-living/#styles + * @link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/ * * @param array $block_styles The style object. * @param array $options { diff --git a/src/wp-includes/theme-previews.php b/src/wp-includes/theme-previews.php index 287559c984360..8b0695cd054f3 100644 --- a/src/wp-includes/theme-previews.php +++ b/src/wp-includes/theme-previews.php @@ -61,7 +61,7 @@ function wp_attach_theme_preview_middleware() { * Sets the JavaScript global WP_BLOCK_THEME_ACTIVATE_NONCE containing the nonce * required to activate a theme. For use within the site editor. * - * @see https://github.com/WordPress/gutenberg/pull/41836 + * @link https://github.com/WordPress/gutenberg/pull/41836 * * @since 6.3.0 * @access private diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php index 30c418ee264cc..e1030ee025278 100644 --- a/src/wp-includes/user.php +++ b/src/wp-includes/user.php @@ -3421,7 +3421,7 @@ function retrieve_password( $user_login = '' ) { * end in a period. To avoid the ambiguity, ensure that the login is not the last query * arg in the URL. If moving it to the end, a trailing period will need to be escaped. * - * @see https://core.trac.wordpress.org/tickets/42957 + * @link https://core.trac.wordpress.org/ticket/42957 */ $message .= network_site_url( 'wp-login.php?login=' . rawurlencode( $user_login ) . "&key=$key&action=rp", 'login' ) . '&wp_lang=' . $locale . "\r\n\r\n"; diff --git a/src/wp-includes/utf8.php b/src/wp-includes/utf8.php index 6be22a61ff83a..666d1d4260557 100644 --- a/src/wp-includes/utf8.php +++ b/src/wp-includes/utf8.php @@ -29,7 +29,7 @@ * byte sequence required by UTF-8, and that no sequence encodes a UTF-16 surrogate * code point or any character above the representable range. * - * @see https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-3/#G32860 + * @link https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-3/#G32860 * * @since 6.9.0 * @@ -101,7 +101,7 @@ function wp_is_valid_utf8( string $string ): bool { * * @since 6.9.0 * - * @see https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-5/#G40630 + * @link https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-5/#G40630 * * @param string $text String which is assumed to be UTF-8 but may contain invalid sequences of bytes. * @return string Input text with invalid sequences of bytes replaced with the Unicode replacement character. @@ -146,9 +146,9 @@ function wp_scrub_utf8( $text ) { * - U+FFFE–U+FFFF * - U+1FFFE, U+1FFFF, U+2FFFE, U+2FFFF, …, U+10FFFE, U+10FFFF * - * @see https://www.unicode.org/versions/Unicode17.0.0/core-spec/chapter-23/#G12612 - * @see https://www.w3.org/TR/xml/#charsets - * @see https://html.spec.whatwg.org/#attributes-2 + * @link https://www.unicode.org/versions/Unicode17.0.0/core-spec/chapter-23/#G12612 + * @link https://www.w3.org/TR/xml/#charsets + * @link https://html.spec.whatwg.org/#attributes-2 * * @since 6.9.0 * diff --git a/src/wp-load.php b/src/wp-load.php index 40c141f74034b..684797f8c4de3 100644 --- a/src/wp-load.php +++ b/src/wp-load.php @@ -31,7 +31,7 @@ * Initialize error reporting to a known set of levels. * * This will be adapted in wp_debug_mode() located in wp-includes/load.php based on WP_DEBUG. - * @see https://www.php.net/manual/en/errorfunc.constants.php List of known error levels. + * @link https://www.php.net/manual/en/errorfunc.constants.php List of known error levels. */ error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR ); } diff --git a/tests/phpunit/tests/actions.php b/tests/phpunit/tests/actions.php index 4e25cca0e2e99..f3144e4f954e9 100644 --- a/tests/phpunit/tests/actions.php +++ b/tests/phpunit/tests/actions.php @@ -187,7 +187,7 @@ public function test_action_args_2() { * Test that multiple callbacks receive the correct number of args even when the number * is less than, or greater than previous hooks. * - * @see https://core.trac.wordpress.org/ticket/17817#comment:72 + * @link https://core.trac.wordpress.org/ticket/17817#comment:72 * @ticket 17817 * * @covers ::do_action diff --git a/tests/phpunit/tests/auth.php b/tests/phpunit/tests/auth.php index a290d11e118e6..e832303869e66 100644 --- a/tests/phpunit/tests/auth.php +++ b/tests/phpunit/tests/auth.php @@ -679,7 +679,7 @@ public function test_setting_password_beyond_bcrypt_length_limit_is_rejected() { } /** - * @see https://core.trac.wordpress.org/changeset/30466 + * @link https://core.trac.wordpress.org/changeset/30466 */ public function test_invalid_password_at_phpass_length_limit_is_rejected() { $limit = str_repeat( 'a', self::$phpass_length_limit ); diff --git a/tests/phpunit/tests/blocks/serialize.php b/tests/phpunit/tests/blocks/serialize.php index 5d119e655babc..4ace7bf8cba47 100644 --- a/tests/phpunit/tests/blocks/serialize.php +++ b/tests/phpunit/tests/blocks/serialize.php @@ -88,8 +88,8 @@ public static function data_serialize_identity_from_parsed(): array { * Ensure that the previous escape form can be parsed compatibly and serialized back to * the new form. * - * @see https://github.com/WordPress/wordpress-develop/pull/9558 - * @see https://github.com/WordPress/gutenberg/pull/71291 + * @link https://github.com/WordPress/wordpress-develop/pull/9558 + * @link https://github.com/WordPress/gutenberg/pull/71291 * * @ticket 63917 * diff --git a/tests/phpunit/tests/formatting/balanceTags.php b/tests/phpunit/tests/formatting/balanceTags.php index 47e505c362924..a25b7e5511e4d 100644 --- a/tests/phpunit/tests/formatting/balanceTags.php +++ b/tests/phpunit/tests/formatting/balanceTags.php @@ -75,7 +75,7 @@ public function test_ignores_unsupported_custom_tag_names( $tag ) { /** * These are valid custom elements but we don't support them yet. * - * @see https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name + * @link https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name */ public function data_unsupported_valid_tag_names() { return array( @@ -143,7 +143,7 @@ public function test_detects_supported_invalid_tag_names( $tag ) { /** * These are invalid custom elements but we support them right now in order to keep the parser simpler. * - * @see https://w3c.github.io/webcomponents/spec/custom/#valid-custom-element-name + * @link https://w3c.github.io/webcomponents/spec/custom/#valid-custom-element-name */ public function data_supported_invalid_tag_names() { return array( diff --git a/tests/phpunit/tests/pomo/pluralForms.php b/tests/phpunit/tests/pomo/pluralForms.php index f3b5d82a01b4b..aace128123e2a 100644 --- a/tests/phpunit/tests/pomo/pluralForms.php +++ b/tests/phpunit/tests/pomo/pluralForms.php @@ -65,7 +65,7 @@ public function test_regression( int $nplurals, string $expression ): void { /** * Distinct plural expressions from the GlotPress locales file, keyed by one locale that uses each. * - * @see https://github.com/GlotPress/GlotPress/blob/1bf58a783e1888849faf45b53dbc84bc169b3246/locales/locales.php + * @link https://github.com/GlotPress/GlotPress/blob/1bf58a783e1888849faf45b53dbc84bc169b3246/locales/locales.php * * @return array */ diff --git a/tests/phpunit/tests/rest-api/wpRestMenuItemsController.php b/tests/phpunit/tests/rest-api/wpRestMenuItemsController.php index 85d5618ab964c..7ddc12d0492a9 100644 --- a/tests/phpunit/tests/rest-api/wpRestMenuItemsController.php +++ b/tests/phpunit/tests/rest-api/wpRestMenuItemsController.php @@ -310,7 +310,7 @@ public function test_get_item_term_posts() { * Test that title.raw contains the verbatim title and that title.rendered * has been passed through the_title which escapes & characters. * - * @see https://github.com/WordPress/gutenberg/pull/24673 + * @link https://github.com/WordPress/gutenberg/pull/24673 * * @ticket 40878 * @covers ::get_item From 6ea74c8115f1be08d133906018315df65c0dfab2 Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Sat, 17 Oct 2026 16:17:30 +0000 Subject: [PATCH 002/236] REST API: Correct the `action-unfiltered-html` link's target schema. The target schema of the `https://api.w.org/action-unfiltered-html` link description object nested `raw` directly under `content`, without the `type` and `properties` keywords. `raw` isn't a JSON Schema keyword, so the schema put no constraint on `content`. Wraps `raw` in an object schema, like the `content` property of the post schema, and adds a test for it. Developed in https://github.com/WordPress/wordpress-develop/pull/14362. Follow-up to [43974]. Props jorgefilipecosta. Fixes #66332. git-svn-id: https://develop.svn.wordpress.org/trunk@64437 602fd350-edb4-49c9-b593-d223f7449a82 --- .../class-wp-rest-posts-controller.php | 7 ++-- .../tests/rest-api/rest-posts-controller.php | 36 +++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php index 1ba360419082a..0a747714504ec 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php @@ -2900,8 +2900,11 @@ protected function get_schema_links() { 'type' => 'object', 'properties' => array( 'content' => array( - 'raw' => array( - 'type' => 'string', + 'type' => 'object', + 'properties' => array( + 'raw' => array( + 'type' => 'string', + ), ), ), ), diff --git a/tests/phpunit/tests/rest-api/rest-posts-controller.php b/tests/phpunit/tests/rest-api/rest-posts-controller.php index c85e9af679be3..e78e5f764c3d4 100644 --- a/tests/phpunit/tests/rest-api/rest-posts-controller.php +++ b/tests/phpunit/tests/rest-api/rest-posts-controller.php @@ -5207,6 +5207,42 @@ public function test_publish_action_ldo_registered() { $this->assertCount( 1, $publish, 'LDO found on schema.' ); } + /** + * @ticket 66332 + * + * @covers WP_REST_Posts_Controller::get_schema_links + */ + public function test_unfiltered_html_action_ldo_target_schema() { + $response = rest_get_server()->dispatch( new WP_REST_Request( 'OPTIONS', '/wp/v2/posts' ) ); + $data = $response->get_data(); + $schema = $data['schema']; + + $this->assertArrayHasKey( 'links', $schema, 'The schema should have links.' ); + $unfiltered_html = wp_list_filter( $schema['links'], array( 'rel' => 'https://api.w.org/action-unfiltered-html' ) ); + + $this->assertCount( 1, $unfiltered_html, 'The action-unfiltered-html LDO should be on the schema once.' ); + + $ldo = array_shift( $unfiltered_html ); + + $this->assertSame( + array( + 'type' => 'object', + 'properties' => array( + 'content' => array( + 'type' => 'object', + 'properties' => array( + 'raw' => array( + 'type' => 'string', + ), + ), + ), + ), + ), + $ldo['targetSchema'], + 'The target schema should describe content.raw as a string.' + ); + } + public function test_sticky_action_ldo_registered_for_posts() { $response = rest_get_server()->dispatch( new WP_REST_Request( 'OPTIONS', '/wp/v2/posts' ) ); $data = $response->get_data(); From 5fad21a1766dd480f27aab1a000518e77e7d7a7a Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Sat, 17 Oct 2026 16:45:30 +0000 Subject: [PATCH 003/236] Connectors: Preload the screen's REST API responses. The Connectors screen requested the site settings, the `OPTIONS` response of the plugins endpoint, and the records of the AI plugin and of each connector's plugin only after its scripts loaded, which delayed its first render. Adds the private `_wp_connectors_preload_paths()` callback to the `wp_options_connectors_wp_admin_preload_paths` filter, so these responses are embedded in the page. Only successful responses are preloaded, so the screen still requests the records of plugins that aren't installed. The filter is applied by the page that the Gutenberg build generates, so the preloading takes effect once the pinned Gutenberg version includes https://github.com/WordPress/gutenberg/pull/77353. Developed in https://github.com/WordPress/wordpress-develop/pull/11790 and https://github.com/WordPress/gutenberg/pull/77353. Props westonruter, wildworks, jorgefilipecosta, mukesh27, apermo, ugyensupport, gziolo, justlevine, peterwilsoncc, ellatrix, cbravobernal. Fixes #65215. git-svn-id: https://develop.svn.wordpress.org/trunk@64438 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/options-connectors.php | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/wp-admin/options-connectors.php b/src/wp-admin/options-connectors.php index ddad78f4f135f..eacb9bdb5f7aa 100644 --- a/src/wp-admin/options-connectors.php +++ b/src/wp-admin/options-connectors.php @@ -32,6 +32,48 @@ // Set parent file for menu highlighting. $parent_file = 'options-general.php'; +/** + * Preloads the REST API responses the Connectors UI fetches on mount. + * + * Without this, the page does a network round-trip for site settings, + * plugin capability discovery, and each connector's plugin record after + * the JS hydrates, which noticeably delays first paint. + * + * @since 7.2.0 + * @access private + * + * @param array $preload_paths Paths already queued for preloading. + * @return array Paths with the Connectors-specific requests appended. + * + * @phpstan-param array $preload_paths + * @phpstan-return array + */ +function _wp_connectors_preload_paths( array $preload_paths ): array { + // getEntityRecord( 'root', 'site' ) in use-connector-plugin.ts / ai-plugin-callout.tsx. + $preload_paths[] = '/wp/v2/settings'; + + // canUser( 'create', { kind: 'root', name: 'plugin' } ) in stage.tsx. + $preload_paths[] = array( '/wp/v2/plugins', 'OPTIONS' ); + + // AiPluginCallout in routes/connectors-home/ai-plugin-callout.tsx queries this + // hardcoded ID to check whether the WP AI plugin is installed/active. + $preload_paths[] = '/wp/v2/plugins/ai/ai?context=edit'; + + // getEntityRecord( 'root', 'plugin', ) per connector in use-connector-plugin.ts. + foreach ( wp_get_connectors() as $connector_data ) { + if ( empty( $connector_data['plugin']['file'] ) ) { + continue; + } + // core-data's plugin entity uses the basename with `.php` stripped + // as the record key (see routes/connectors-home/use-connector-plugin.ts). + $basename = preg_replace( '/\.php$/', '', plugin_basename( $connector_data['plugin']['file'] ) ); + $preload_paths[] = '/wp/v2/plugins/' . $basename . '?context=edit'; + } + + return $preload_paths; +} +add_filter( 'wp_options_connectors_wp_admin_preload_paths', '_wp_connectors_preload_paths' ); + require_once ABSPATH . 'wp-admin/admin-header.php'; // Render the Connectors page. From 69c05ffb665e29924d0715d815444cd2ba5ed867 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 18:50:30 +0000 Subject: [PATCH 004/236] Tests: Make formatting test data providers static. Declare the data providers in `tests/phpunit/tests/formatting/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions. Use static properties for the emoji CDN fixture values. Developed in: https://github.com/WordPress/wordpress-develop/pull/14381 Props rejaulalomkhan, mukesh27. See #66211. git-svn-id: https://develop.svn.wordpress.org/trunk@64439 602fd350-edb4-49c9-b593-d223f7449a82 --- .../phpunit/tests/formatting/antispambot.php | 4 +- .../autopNewlinePreservationHelper.php | 6 +-- .../phpunit/tests/formatting/balanceTags.php | 18 +++---- .../tests/formatting/convertSmilies.php | 12 ++--- tests/phpunit/tests/formatting/date.php | 2 +- tests/phpunit/tests/formatting/emoji.php | 32 ++++++------- tests/phpunit/tests/formatting/ent2ncr.php | 2 +- tests/phpunit/tests/formatting/escXml.php | 4 +- .../formatting/excerptRemoveFootnotes.php | 2 +- .../phpunit/tests/formatting/getBloginfo.php | 2 +- .../tests/formatting/getUrlInContent.php | 2 +- .../tests/formatting/humanTimeDiff.php | 4 +- .../tests/formatting/linksAddBaseUrl.php | 2 +- .../tests/formatting/linksAddTarget.php | 2 +- .../tests/formatting/makeClickable.php | 10 ++-- .../tests/formatting/maybeHashHexColor.php | 2 +- .../tests/formatting/normalizeWhitespace.php | 2 +- tests/phpunit/tests/formatting/redirect.php | 8 ++-- .../tests/formatting/sanitizeEmail.php | 2 +- .../tests/formatting/sanitizeFileName.php | 4 +- .../tests/formatting/sanitizeHexColor.php | 2 +- .../formatting/sanitizeHexColorNoHash.php | 2 +- .../phpunit/tests/formatting/sanitizeKey.php | 6 +-- .../tests/formatting/sanitizeLocaleName.php | 4 +- .../tests/formatting/sanitizeOrderby.php | 4 +- .../tests/formatting/sanitizeTextField.php | 2 +- .../formatting/sanitizeTitleWithDashes.php | 8 ++-- .../formatting/sanitizeTrackbackUrls.php | 2 +- tests/phpunit/tests/formatting/urlShorten.php | 4 +- .../tests/formatting/urlencodeDeep.php | 2 +- .../tests/formatting/utf8UriEncode.php | 2 +- tests/phpunit/tests/formatting/wpAutop.php | 2 +- .../phpunit/tests/formatting/wpHtmlSplit.php | 4 +- tests/phpunit/tests/formatting/wpParseStr.php | 4 +- .../tests/formatting/wpRelNofollow.php | 2 +- tests/phpunit/tests/formatting/wpRelUgc.php | 2 +- .../tests/formatting/wpReplaceInHtmlTags.php | 2 +- tests/phpunit/tests/formatting/wpSlash.php | 2 +- .../tests/formatting/wpSpecialchars.php | 4 +- .../tests/formatting/wpStripAllTags.php | 4 +- .../phpunit/tests/formatting/wpTexturize.php | 48 +++++++++---------- .../tests/formatting/wpTruncateSlug.php | 2 +- 42 files changed, 118 insertions(+), 118 deletions(-) diff --git a/tests/phpunit/tests/formatting/antispambot.php b/tests/phpunit/tests/formatting/antispambot.php index e426696c3186d..387fc258fe328 100644 --- a/tests/phpunit/tests/formatting/antispambot.php +++ b/tests/phpunit/tests/formatting/antispambot.php @@ -28,7 +28,7 @@ public function test_returns_valid_utf8( $email ) { * * return array[] */ - public function data_returns_valid_utf8() { + public static function data_returns_valid_utf8() { return array( 'plain' => array( 'bob@example.com' ), 'plain with ip' => array( 'ace@204.32.222.14' ), @@ -76,7 +76,7 @@ public function test_antispambot_obfuscates( $provided ) { * * @return Generator */ - public function data_antispambot_obfuscates() { + public static function data_antispambot_obfuscates() { $addresses = array( 'example@example.com', '#@example.com', diff --git a/tests/phpunit/tests/formatting/autopNewlinePreservationHelper.php b/tests/phpunit/tests/formatting/autopNewlinePreservationHelper.php index d26ee81d4ab9c..a0c8a7ebfa429 100644 --- a/tests/phpunit/tests/formatting/autopNewlinePreservationHelper.php +++ b/tests/phpunit/tests/formatting/autopNewlinePreservationHelper.php @@ -26,7 +26,7 @@ public function test_should_replace_newlines_with_placeholders( $matches, $expec * * @return array[] */ - public function data_should_replace_newlines_with_placeholders() { + public static function data_should_replace_newlines_with_placeholders() { return array( 'an empty string' => array( 'matches' => array( '' ), @@ -89,7 +89,7 @@ public function test_should_only_replace_line_feeds( $matches, $expected ) { * * @return array[] */ - public function data_should_only_replace_line_feeds() { + public static function data_should_only_replace_line_feeds() { return array( 'a carriage return' => array( 'matches' => array( "a\rb" ), @@ -151,7 +151,7 @@ public function test_should_preserve_newlines_as_a_preg_replace_callback( $text, * * @return array[] */ - public function data_should_preserve_newlines_as_a_preg_replace_callback() { + public static function data_should_preserve_newlines_as_a_preg_replace_callback() { return array( 'a script element' => array( 'text' => "", diff --git a/tests/phpunit/tests/formatting/balanceTags.php b/tests/phpunit/tests/formatting/balanceTags.php index a25b7e5511e4d..72d14373e4e01 100644 --- a/tests/phpunit/tests/formatting/balanceTags.php +++ b/tests/phpunit/tests/formatting/balanceTags.php @@ -17,7 +17,7 @@ public function test_detects_traditional_tag_names( $tag ) { $this->assertSame( "<$normalized>inside", balanceTags( "<$tag>inside", true ) ); } - public function data_supported_traditional_tag_names() { + public static function data_supported_traditional_tag_names() { return array( array( 'a' ), array( 'div' ), @@ -37,7 +37,7 @@ public function test_detects_supported_custom_element_tag_names( $tag ) { $this->assertSame( "<$tag>inside", balanceTags( "<$tag>inside", true ) ); } - public function data_supported_custom_element_tag_names() { + public static function data_supported_custom_element_tag_names() { return array( array( 'custom-element' ), array( 'my-custom-element' ), @@ -57,7 +57,7 @@ public function test_ignores_invalid_tag_names( $input, $output ) { $this->assertSame( $output, balanceTags( $input, true ) ); } - public function data_invalid_tag_names() { + public static function data_invalid_tag_names() { return array( array( '<0-day>inside', '<0-day>inside' ), // Can't start with a number - handled by the "<3" fix. array( 'inside', 'inside' ), // Custom elements cannot be uppercase. @@ -77,7 +77,7 @@ public function test_ignores_unsupported_custom_tag_names( $tag ) { * * @link https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name */ - public function data_unsupported_valid_tag_names() { + public static function data_unsupported_valid_tag_names() { return array( // We don't allow ending in a dash. array( 'inside' ), @@ -145,7 +145,7 @@ public function test_detects_supported_invalid_tag_names( $tag ) { * * @link https://w3c.github.io/webcomponents/spec/custom/#valid-custom-element-name */ - public function data_supported_invalid_tag_names() { + public static function data_supported_invalid_tag_names() { return array( // Reserved names for custom elements. array( 'annotation-xml' ), @@ -181,7 +181,7 @@ public function test_selfcloses_known_single_tags_having_closing_tag( $tag ) { } // This is a complete(?) listing of valid single/self-closing tags. - public function data_single_tags() { + public static function data_single_tags() { return array( array( 'area' ), array( 'base' ), @@ -219,7 +219,7 @@ public function test_closes_unknown_single_tags_with_closing_tag( $input, $expec * * @return array> */ - public function data_unknown_single_tags_with_closing_tag() { + public static function data_unknown_single_tags_with_closing_tag() { return array( 'default' => array( '', '' ), 'with-space' => array( '', '' ), @@ -278,7 +278,7 @@ public function test_balances_nestable_tags( $tag ) { } } - public function data_nestable_tags() { + public static function data_nestable_tags() { return array( array( 'article' ), array( 'aside' ), @@ -390,7 +390,7 @@ public function test_removes_extraneous_closing_tags() { * * @return array Data. */ - public function data_custom_elements() { + public static function data_custom_elements() { return array( // Valid custom element tags. array( diff --git a/tests/phpunit/tests/formatting/convertSmilies.php b/tests/phpunit/tests/formatting/convertSmilies.php index 24c2a8087a93f..fa9ce713f968f 100644 --- a/tests/phpunit/tests/formatting/convertSmilies.php +++ b/tests/phpunit/tests/formatting/convertSmilies.php @@ -39,7 +39,7 @@ public function test_convert_standard_smilies( $input, $converted ) { * } * } */ - public function data_convert_standard_smilies() { + public static function data_convert_standard_smilies() { $includes_path = includes_url( 'images/smilies/' ); return array( @@ -109,7 +109,7 @@ public function test_convert_custom_smilies( $input, $converted ) { * } * } */ - public function data_convert_custom_smilies() { + public static function data_convert_custom_smilies() { $includes_path = includes_url( 'images/smilies/' ); return array( @@ -153,7 +153,7 @@ public function test_ignore_smilies_in_tags( $element ) { * } * } */ - public function data_ignore_smilies_in_tags() { + public static function data_ignore_smilies_in_tags() { return array( array( 'pre' ), array( 'code' ), @@ -189,7 +189,7 @@ public function test_smilies_combinations( $input, $converted ) { * } * } */ - public function data_smilies_combinations() { + public static function data_smilies_combinations() { $includes_path = includes_url( 'images/smilies/' ); return array( @@ -258,7 +258,7 @@ public function test_single_smilies_in_wpsmiliestrans( $input, $converted ) { * } * } */ - public function data_single_smilies_in_wpsmiliestrans() { + public static function data_single_smilies_in_wpsmiliestrans() { $includes_path = includes_url( 'images/smilies/' ); return array( @@ -301,7 +301,7 @@ public function test_spaces_around_smilies( $input, $converted ) { * } * } */ - public function data_spaces_around_smilies() { + public static function data_spaces_around_smilies() { $nbsp = "\xC2\xA0"; return array( diff --git a/tests/phpunit/tests/formatting/date.php b/tests/phpunit/tests/formatting/date.php index 60635c5bdc939..c7c1bd2902e07 100644 --- a/tests/phpunit/tests/formatting/date.php +++ b/tests/phpunit/tests/formatting/date.php @@ -231,7 +231,7 @@ public function test_is8601_to_datetime_correct_time( $timezone_string, $gmt_off * * @return array */ - public function data_timezone_provider() { + public static function data_timezone_provider() { return array( 'valid timezone string and GMT offset' => array( 'timezone_string' => 'Europe/Helsinki', diff --git a/tests/phpunit/tests/formatting/emoji.php b/tests/phpunit/tests/formatting/emoji.php index d885c49fd7289..56ffa301a591c 100644 --- a/tests/phpunit/tests/formatting/emoji.php +++ b/tests/phpunit/tests/formatting/emoji.php @@ -6,8 +6,8 @@ */ class Tests_Formatting_Emoji extends WP_UnitTestCase { - private $png_cdn = 'https://s.w.org/images/core/emoji/17.0.2/72x72/'; - private $svg_cdn = 'https://s.w.org/images/core/emoji/17.0.2/svg/'; + private static $png_cdn = 'https://s.w.org/images/core/emoji/17.0.2/72x72/'; + private static $svg_cdn = 'https://s.w.org/images/core/emoji/17.0.2/svg/'; /** * Tests that the emoji detection script is hooked onto the front end footer @@ -192,9 +192,9 @@ public function test_script_tag_printing() { array( 'baseUrl', 'ext', 'svgUrl', 'svgExt', 'source' ), array_keys( $settings ) ); - $this->assertSame( $this->png_cdn, $settings['baseUrl'] ); + $this->assertSame( self::$png_cdn, $settings['baseUrl'] ); $this->assertSame( '.png', $settings['ext'] ); - $this->assertSame( $this->svg_cdn, $settings['svgUrl'] ); + $this->assertSame( self::$svg_cdn, $settings['svgUrl'] ); $this->assertSame( '.svg', $settings['svgExt'] ); $this->assertIsArray( $settings['source'] ); $this->assertArrayHasKey( 'wpemoji', $settings['source'] ); @@ -216,8 +216,8 @@ public function test_unfiltered_emoji_cdns() { self::touch( ABSPATH . WPINC . '/js/wp-emoji-loader.js' ); $output = get_echo( '_print_emoji_detection_script' ); - $this->assertStringContainsString( wp_json_encode( $this->png_cdn, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), $output ); - $this->assertStringContainsString( wp_json_encode( $this->svg_cdn, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), $output ); + $this->assertStringContainsString( wp_json_encode( self::$png_cdn, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), $output ); + $this->assertStringContainsString( wp_json_encode( self::$svg_cdn, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), $output ); } public function _filtered_emoji_svg_cdn( $cdn = '' ) { @@ -238,8 +238,8 @@ public function test_filtered_emoji_svn_cdn() { self::touch( ABSPATH . WPINC . '/js/wp-emoji-loader.js' ); $output = get_echo( '_print_emoji_detection_script' ); - $this->assertStringContainsString( wp_json_encode( $this->png_cdn, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), $output ); - $this->assertStringNotContainsString( wp_json_encode( $this->svg_cdn, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), $output ); + $this->assertStringContainsString( wp_json_encode( self::$png_cdn, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), $output ); + $this->assertStringNotContainsString( wp_json_encode( self::$svg_cdn, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), $output ); $this->assertStringContainsString( wp_json_encode( $filtered_svn_cdn, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), $output ); remove_filter( 'emoji_svg_url', array( $this, '_filtered_emoji_svg_cdn' ) ); @@ -264,8 +264,8 @@ public function test_filtered_emoji_png_cdn() { $output = get_echo( '_print_emoji_detection_script' ); $this->assertStringContainsString( wp_json_encode( $filtered_png_cdn, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), $output ); - $this->assertStringNotContainsString( wp_json_encode( $this->png_cdn, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), $output ); - $this->assertStringContainsString( wp_json_encode( $this->svg_cdn, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), $output ); + $this->assertStringNotContainsString( wp_json_encode( self::$png_cdn, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), $output ); + $this->assertStringContainsString( wp_json_encode( self::$svg_cdn, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), $output ); remove_filter( 'emoji_url', array( $this, '_filtered_emoji_png_cdn' ) ); } @@ -295,7 +295,7 @@ public function test_wp_emoji_list_returns_data() { $this->assertNotSame( $default, $partials ); } - public function data_wp_encode_emoji() { + public static function data_wp_encode_emoji() { return array( array( // Not emoji. @@ -335,7 +335,7 @@ public function test_wp_encode_emoji( $emoji, $expected ) { $this->assertSame( $expected, wp_encode_emoji( $emoji ) ); } - public function data_wp_staticize_emoji() { + public static function data_wp_staticize_emoji() { $data = array( array( // Not emoji. @@ -345,22 +345,22 @@ public function data_wp_staticize_emoji() { array( // Simple emoji. '🙂', - '🙂', + '🙂', ), array( // Skin tone, gender, ZWJ, emoji selector. '👮🏼‍♀️', - '👮🏼‍♀️', + '👮🏼‍♀️', ), array( // Unicode 10. '🧚', - '🧚', + '🧚', ), array( // Hairy creature (Unicode 17). '🫈', - '🫈', + '🫈', ), ); diff --git a/tests/phpunit/tests/formatting/ent2ncr.php b/tests/phpunit/tests/formatting/ent2ncr.php index db60ba97ffa45..309a86e53a132 100644 --- a/tests/phpunit/tests/formatting/ent2ncr.php +++ b/tests/phpunit/tests/formatting/ent2ncr.php @@ -19,7 +19,7 @@ public function test_converts_named_entities_to_numeric_character_references( $e * Get test data from files, one test per line. * Comments start with "###". */ - public function data_entities() { + public static function data_entities() { $entities = file( DIR_TESTDATA . '/formatting/entities.txt' ); $data_provided = array(); foreach ( $entities as $line ) { diff --git a/tests/phpunit/tests/formatting/escXml.php b/tests/phpunit/tests/formatting/escXml.php index 6fdbd136a7236..195620f7dc021 100644 --- a/tests/phpunit/tests/formatting/escXml.php +++ b/tests/phpunit/tests/formatting/escXml.php @@ -27,7 +27,7 @@ public function test_esc_xml_basics( $source, $expected ) { * @type string $expected The expected escaped value of `$source`. * } */ - public function data_esc_xml_basics() { + public static function data_esc_xml_basics() { return array( // Simple string. array( @@ -102,7 +102,7 @@ public function test_ignores_cdata_sections( $source, $expected ) { * @type string $expected The expected escaped value of `$source`. * } */ - public function data_ignores_cdata_sections() { + public static function data_ignores_cdata_sections() { return array( // basic CDATA Section containing chars that would otherwise be escaped if not in a CDATA Section // not to mention the CDATA Section markup itself :-) diff --git a/tests/phpunit/tests/formatting/excerptRemoveFootnotes.php b/tests/phpunit/tests/formatting/excerptRemoveFootnotes.php index 12ea3acb04cbe..eabf3bfc2f47d 100644 --- a/tests/phpunit/tests/formatting/excerptRemoveFootnotes.php +++ b/tests/phpunit/tests/formatting/excerptRemoveFootnotes.php @@ -24,7 +24,7 @@ public function test_remove_footnotes( $expected, $content ) { * * @return array */ - public function data_remove_footnotes() { + public static function data_remove_footnotes() { return array( 'no footnote' => array( 'expected' => '

This is a paragraph1.

', diff --git a/tests/phpunit/tests/formatting/getBloginfo.php b/tests/phpunit/tests/formatting/getBloginfo.php index 37f449bac6ab5..89113d219dfe8 100644 --- a/tests/phpunit/tests/formatting/getBloginfo.php +++ b/tests/phpunit/tests/formatting/getBloginfo.php @@ -22,7 +22,7 @@ public function test_get_bloginfo_language( $test_locale, $expected ) { $locale = $old_locale; } - public function data_get_bloginfo_language() { + public static function data_get_bloginfo_language() { return array( // Locale, language code. array( 'en_US', 'en-US' ), diff --git a/tests/phpunit/tests/formatting/getUrlInContent.php b/tests/phpunit/tests/formatting/getUrlInContent.php index ce99099ef5ad1..cc09748786047 100644 --- a/tests/phpunit/tests/formatting/getUrlInContent.php +++ b/tests/phpunit/tests/formatting/getUrlInContent.php @@ -26,7 +26,7 @@ public function test_get_url_in_content( $input, $expected ) { * } * } */ - public function data_get_url_in_content() { + public static function data_get_url_in_content() { return array( array( // Empty content. '', diff --git a/tests/phpunit/tests/formatting/humanTimeDiff.php b/tests/phpunit/tests/formatting/humanTimeDiff.php index 2f460b848a297..843561edd77e4 100644 --- a/tests/phpunit/tests/formatting/humanTimeDiff.php +++ b/tests/phpunit/tests/formatting/humanTimeDiff.php @@ -19,7 +19,7 @@ public function test_human_time_diff( $expected, $stopdate, $message ) { } // Data for test_human_time_diff. - public function data_human_time_diff() { + public static function data_human_time_diff() { return array( array( '37 seconds', @@ -94,7 +94,7 @@ public function test_human_time_diff_unit_boundaries( int $diff, string $expecte * * @return array */ - public function data_human_time_diff_unit_boundaries(): array { + public static function data_human_time_diff_unit_boundaries(): array { return array( 'no difference' => array( 0, '1 second' ), '1 second' => array( 1, '1 second' ), diff --git a/tests/phpunit/tests/formatting/linksAddBaseUrl.php b/tests/phpunit/tests/formatting/linksAddBaseUrl.php index cbc8489a500e0..077d2e143208b 100644 --- a/tests/phpunit/tests/formatting/linksAddBaseUrl.php +++ b/tests/phpunit/tests/formatting/linksAddBaseUrl.php @@ -34,7 +34,7 @@ public function test_links_add_base_url( $content, $base, $attrs, $expected ) { * } * } */ - public function data_links_add_base_url() { + public static function data_links_add_base_url() { return array( 'https' => array( 'content' => '', diff --git a/tests/phpunit/tests/formatting/linksAddTarget.php b/tests/phpunit/tests/formatting/linksAddTarget.php index 31bc4cdcb3b84..8f063adb29a33 100644 --- a/tests/phpunit/tests/formatting/linksAddTarget.php +++ b/tests/phpunit/tests/formatting/linksAddTarget.php @@ -35,7 +35,7 @@ public function test_links_add_target( $content, $target, $tags, $expected ) { * } * } */ - public function data_links_add_target() { + public static function data_links_add_target() { return array( array( 'MY CONTENT END TEXT', diff --git a/tests/phpunit/tests/formatting/makeClickable.php b/tests/phpunit/tests/formatting/makeClickable.php index 5e4c62a1494ef..09ca0d48cff68 100644 --- a/tests/phpunit/tests/formatting/makeClickable.php +++ b/tests/phpunit/tests/formatting/makeClickable.php @@ -25,7 +25,7 @@ public function test_valid_mailto( $email ) { * * @return array */ - public function data_valid_mailto() { + public static function data_valid_mailto() { return array( array( 'foo@example.com' ), array( 'foo.bar@example.com' ), @@ -49,7 +49,7 @@ public function test_invalid_mailto( $email ) { * * @return array */ - public function data_invalid_mailto() { + public static function data_invalid_mailto() { return array( array( 'foo' ), array( 'foo@' ), @@ -81,7 +81,7 @@ public function test_urls( $text, $expected ) { * * @return array */ - public function data_urls() { + public static function data_urls() { return array( // Does not link trailing periods, commas, and (semi-)colons in URLs with protocol (i.e. http://wordpress.org). 'URL only' => array( @@ -463,7 +463,7 @@ public function test_dont_link_script_and_style_tags( $tag ) { $this->assertSame( $tag, make_clickable( $tag ) ); } - public function data_script_and_style_tags() { + public static function data_script_and_style_tags() { return array( array( '', @@ -499,7 +499,7 @@ public function test_add_rel_ugc_in_comments( $content, $expected ) { $this->assertStringContainsString( $expected, make_clickable( $comment_text ) ); } - public function data_add_rel_ugc_in_comments() { + public static function data_add_rel_ugc_in_comments() { $home_url_http = set_url_scheme( home_url(), 'http' ); $home_url_https = set_url_scheme( home_url(), 'https' ); diff --git a/tests/phpunit/tests/formatting/maybeHashHexColor.php b/tests/phpunit/tests/formatting/maybeHashHexColor.php index 88ed38e8e9bc9..246bbb37a588c 100644 --- a/tests/phpunit/tests/formatting/maybeHashHexColor.php +++ b/tests/phpunit/tests/formatting/maybeHashHexColor.php @@ -26,7 +26,7 @@ public function test_maybe_hash_hex_color( $color, $expected ) { * * @return array[] */ - public function data_sanitize_hex_color_no_hash() { + public static function data_sanitize_hex_color_no_hash() { return array( '$maybe_alpha = false, 3 digit' => array( 'color' => '#123', diff --git a/tests/phpunit/tests/formatting/normalizeWhitespace.php b/tests/phpunit/tests/formatting/normalizeWhitespace.php index 3c2038b076018..8c9a75ffa206b 100644 --- a/tests/phpunit/tests/formatting/normalizeWhitespace.php +++ b/tests/phpunit/tests/formatting/normalizeWhitespace.php @@ -25,7 +25,7 @@ public function test_normalize_whitespace( $input, $expected ) { * } * } */ - public function data_normalize_whitespace() { + public static function data_normalize_whitespace() { return array( array( ' ', diff --git a/tests/phpunit/tests/formatting/redirect.php b/tests/phpunit/tests/formatting/redirect.php index c4b1d682094f4..a08e222037a7b 100644 --- a/tests/phpunit/tests/formatting/redirect.php +++ b/tests/phpunit/tests/formatting/redirect.php @@ -31,7 +31,7 @@ public function test_wp_redirect_bad_status_code( $location, $status ) { wp_redirect( $location, $status ); } - public function data_wp_redirect_bad_status_code() { + public static function data_wp_redirect_bad_status_code() { return array( // Tests for bad arguments. array( '/wp-admin', 404 ), @@ -84,7 +84,7 @@ public function test_wp_validate_redirect_valid_url( $url, $expected ) { $this->assertSame( $expected, wp_validate_redirect( $url ) ); } - public function data_wp_validate_redirect_valid_url() { + public static function data_wp_validate_redirect_valid_url() { return array( array( 'http://example.com', 'http://example.com' ), array( 'http://example.com/', 'http://example.com/' ), @@ -112,7 +112,7 @@ public function test_wp_validate_redirect_invalid_url( $url, $expected = false ) $this->assertSame( $expected, wp_validate_redirect( $url, false ) ); } - public function data_wp_validate_redirect_invalid_url() { + public static function data_wp_validate_redirect_invalid_url() { return array( // parse_url() fails. array( '', '' ), @@ -221,7 +221,7 @@ public function test_wp_validate_redirect_relative_url( $current_uri, $url, $exp * string Expected destination. * } */ - public function data_wp_validate_redirect_relative_url() { + public static function data_wp_validate_redirect_relative_url() { return array( array( '/', diff --git a/tests/phpunit/tests/formatting/sanitizeEmail.php b/tests/phpunit/tests/formatting/sanitizeEmail.php index 5490374d0a5e7..97167eed74a97 100644 --- a/tests/phpunit/tests/formatting/sanitizeEmail.php +++ b/tests/phpunit/tests/formatting/sanitizeEmail.php @@ -39,7 +39,7 @@ public function test_returns_stripped_email_address( $address, $expected ) { * * @return array[] */ - public function data_sanitized_email_pairs() { + public static function data_sanitized_email_pairs() { return array( 'shorter than 6 characters' => array( 'a@b', '' ), 'contains no @' => array( 'ab', '' ), diff --git a/tests/phpunit/tests/formatting/sanitizeFileName.php b/tests/phpunit/tests/formatting/sanitizeFileName.php index d0e366f121a5a..fb79b91e92e76 100644 --- a/tests/phpunit/tests/formatting/sanitizeFileName.php +++ b/tests/phpunit/tests/formatting/sanitizeFileName.php @@ -91,7 +91,7 @@ public function test_replaces_invalid_utf8_characters( $input, $expected ) { $this->assertSame( $expected, sanitize_file_name( $input ) ); } - public function data_wp_filenames() { + public static function data_wp_filenames() { return array( array( urldecode( '%B1myfile.png' ), 'myfile.png' ), array( urldecode( '%B1myfile' ), 'myfile' ), @@ -120,7 +120,7 @@ public function test_sanitize_file_name_should_replace_consecutive_periods_with_ * * @return array[] */ - public function data_sanitize_file_name_should_replace_consecutive_periods_with_a_single_period() { + public static function data_sanitize_file_name_should_replace_consecutive_periods_with_a_single_period() { return array( 'consecutive periods at the start' => array( 'filename' => '...filename.png', diff --git a/tests/phpunit/tests/formatting/sanitizeHexColor.php b/tests/phpunit/tests/formatting/sanitizeHexColor.php index 77c058be3dc00..ff3a7e6c9f3e4 100644 --- a/tests/phpunit/tests/formatting/sanitizeHexColor.php +++ b/tests/phpunit/tests/formatting/sanitizeHexColor.php @@ -26,7 +26,7 @@ public function test_sanitize_hex_color( $color, $expected ) { * * @return array[] */ - public function data_sanitize_hex_color() { + public static function data_sanitize_hex_color() { return array( '$maybe_alpha = false, 3 digit' => array( 'color' => '#123', diff --git a/tests/phpunit/tests/formatting/sanitizeHexColorNoHash.php b/tests/phpunit/tests/formatting/sanitizeHexColorNoHash.php index 4c22006e403f7..58c3a402b91f3 100644 --- a/tests/phpunit/tests/formatting/sanitizeHexColorNoHash.php +++ b/tests/phpunit/tests/formatting/sanitizeHexColorNoHash.php @@ -26,7 +26,7 @@ public function test_sanitize_hex_color_no_hash( $color, $expected ) { * * @return array[] */ - public function data_sanitize_hex_color_no_hash() { + public static function data_sanitize_hex_color_no_hash() { return array( '$maybe_alpha = false, 3 digit' => array( 'color' => '#123', diff --git a/tests/phpunit/tests/formatting/sanitizeKey.php b/tests/phpunit/tests/formatting/sanitizeKey.php index bdf1c881d7611..c159063b19b0c 100644 --- a/tests/phpunit/tests/formatting/sanitizeKey.php +++ b/tests/phpunit/tests/formatting/sanitizeKey.php @@ -23,7 +23,7 @@ public function test_sanitize_key( $key, $expected ) { * * @return array */ - public function data_sanitize_key() { + public static function data_sanitize_key() { return array( 'an empty string key' => array( 'key' => '', @@ -76,7 +76,7 @@ public function test_sanitize_key_nonstring_scalar( $key, $expected ) { * * @return array */ - public function data_sanitize_key_nonstring_scalar() { + public static function data_sanitize_key_nonstring_scalar() { return array( 'integer type' => array( 'key' => 0, @@ -122,7 +122,7 @@ function ( $sanitized_key, $key ) use ( $nonscalar_key ) { * * @return array */ - public function data_sanitize_key_with_non_scalars() { + public static function data_sanitize_key_with_non_scalars() { return array( 'array type' => array( 'key' => array( 'key' ), diff --git a/tests/phpunit/tests/formatting/sanitizeLocaleName.php b/tests/phpunit/tests/formatting/sanitizeLocaleName.php index 844584cb65606..59428099f4904 100644 --- a/tests/phpunit/tests/formatting/sanitizeLocaleName.php +++ b/tests/phpunit/tests/formatting/sanitizeLocaleName.php @@ -13,7 +13,7 @@ public function test_sanitize_locale_name_returns_non_empty_string( $expected, $ $this->assertSame( $expected, sanitize_locale_name( $input ) ); } - public function data_sanitize_locale_name_returns_non_empty_string() { + public static function data_sanitize_locale_name_returns_non_empty_string() { return array( // array( expected, input ) array( 'en_US', 'en_US' ), @@ -37,7 +37,7 @@ public function test_sanitize_locale_name_returns_empty_string( $input ) { $this->assertSame( '', sanitize_locale_name( $input ) ); } - public function data_sanitize_locale_name_returns_empty_string() { + public static function data_sanitize_locale_name_returns_empty_string() { return array( // array( input ) array( '$<>' ), diff --git a/tests/phpunit/tests/formatting/sanitizeOrderby.php b/tests/phpunit/tests/formatting/sanitizeOrderby.php index fec1d417134e5..01cb6d291e694 100644 --- a/tests/phpunit/tests/formatting/sanitizeOrderby.php +++ b/tests/phpunit/tests/formatting/sanitizeOrderby.php @@ -13,7 +13,7 @@ class Tests_Formatting_SanitizeOrderby extends WP_UnitTestCase { public function test_sanitize_sql_orderby_valid( $orderby ) { $this->assertSame( $orderby, sanitize_sql_orderby( $orderby ) ); } - public function data_sanitize_sql_orderby_valid() { + public static function data_sanitize_sql_orderby_valid() { return array( array( '1' ), array( '1 ASC' ), @@ -39,7 +39,7 @@ public function data_sanitize_sql_orderby_valid() { public function test_sanitize_sql_orderby_invalid( $orderby ) { $this->assertFalse( sanitize_sql_orderby( $orderby ) ); } - public function data_sanitize_sql_orderby_invalid() { + public static function data_sanitize_sql_orderby_invalid() { return array( array( '' ), array( '1 2' ), diff --git a/tests/phpunit/tests/formatting/sanitizeTextField.php b/tests/phpunit/tests/formatting/sanitizeTextField.php index 664301ac8d6cd..aae55cb3af51c 100644 --- a/tests/phpunit/tests/formatting/sanitizeTextField.php +++ b/tests/phpunit/tests/formatting/sanitizeTextField.php @@ -24,7 +24,7 @@ public function test_sanitize_text_field( $str, $expected ) { $this->assertSameIgnoreEOL( $expected_multiline, sanitize_textarea_field( $str ) ); } - public function data_sanitize_text_field() { + public static function data_sanitize_text_field() { return array( array( 'оРангутанг', // Ensure UTF-8 text is safe. The Р is D0 A0 and A0 is the non-breaking space. diff --git a/tests/phpunit/tests/formatting/sanitizeTitleWithDashes.php b/tests/phpunit/tests/formatting/sanitizeTitleWithDashes.php index 8a2ee4f9d9fee..c0b9f50b55409 100644 --- a/tests/phpunit/tests/formatting/sanitizeTitleWithDashes.php +++ b/tests/phpunit/tests/formatting/sanitizeTitleWithDashes.php @@ -180,7 +180,7 @@ public function test_removes_non_visible_characters_without_width( $title, $expe * * @return array */ - public function data_removes_non_visible_characters_without_width() { + public static function data_removes_non_visible_characters_without_width() { return array( // Only the non-visible characters. 'only %e2%80%8b' => array( '%e2%80%8b' ), @@ -233,7 +233,7 @@ public function test_non_visible_characters_without_width_when_not_save( $title, * * @return array */ - public function data_non_visible_characters_without_width_when_not_save() { + public static function data_non_visible_characters_without_width_when_not_save() { return array( // Just the non-visible characters. 'only %e2%80%8b' => array( '%e2%80%8b', '%e2%80%8b' ), @@ -285,7 +285,7 @@ public function test_converts_non_visible_characters_with_width_to_hyphen( $titl * * @return array */ - public function data_converts_non_visible_characters_with_width_to_hyphen() { + public static function data_converts_non_visible_characters_with_width_to_hyphen() { return array( // Only the non-visible characters. 'only %e2%80%80' => array( '%e2%80%80' ), @@ -343,7 +343,7 @@ public function test_non_visible_characters_with_width_to_hyphen_when_not_save( * * @return array */ - public function data_non_visible_characters_with_width_to_hyphen_when_not_save() { + public static function data_non_visible_characters_with_width_to_hyphen_when_not_save() { return array( // Just the non-visible characters. 'only %e2%80%8b' => array( '%e2%80%8b', '%e2%80%8b' ), diff --git a/tests/phpunit/tests/formatting/sanitizeTrackbackUrls.php b/tests/phpunit/tests/formatting/sanitizeTrackbackUrls.php index b560ad5c75530..e39c7cb238f06 100644 --- a/tests/phpunit/tests/formatting/sanitizeTrackbackUrls.php +++ b/tests/phpunit/tests/formatting/sanitizeTrackbackUrls.php @@ -17,7 +17,7 @@ public function test_sanitize_trackback_urls_with_multiple_urls( $separator ) { ); } - public function data_sanitize_trackback_urls_with_multiple_urls() { + public static function data_sanitize_trackback_urls_with_multiple_urls() { return array( array( "\r\n\t " ), array( "\r" ), diff --git a/tests/phpunit/tests/formatting/urlShorten.php b/tests/phpunit/tests/formatting/urlShorten.php index fb42d55d419c8..61a2cc9d86ca1 100644 --- a/tests/phpunit/tests/formatting/urlShorten.php +++ b/tests/phpunit/tests/formatting/urlShorten.php @@ -17,7 +17,7 @@ public function test_url_shorten( $url, $expected ) { $this->assertSame( $expected, url_shorten( $url ) ); } - public function data_url_shorten() { + public static function data_url_shorten() { // When shortened, the URL is cut to ( $length - 3 ) characters before '…' is appended. return array( 'escaped slashes are not stripped' => array( @@ -60,7 +60,7 @@ public function test_url_shorten_respects_custom_length( $url, $length, $expecte $this->assertSame( $expected, url_shorten( $url, $length ) ); } - public function data_url_shorten_custom_length() { + public static function data_url_shorten_custom_length() { // The URL below is 41 characters long after cleaning. $url = 'http://wordpress.org/about/philosophy/#decisions'; diff --git a/tests/phpunit/tests/formatting/urlencodeDeep.php b/tests/phpunit/tests/formatting/urlencodeDeep.php index 9436ba09afc16..7783f3a002b05 100644 --- a/tests/phpunit/tests/formatting/urlencodeDeep.php +++ b/tests/phpunit/tests/formatting/urlencodeDeep.php @@ -23,7 +23,7 @@ public function test_urlencode_deep_should_encode_individual_value( $input, $exp /** * Data provider. */ - public function data_urlencode_deep() { + public static function data_urlencode_deep() { return array( array( 'qwerty123456', 'qwerty123456' ), array( '|!"£$%&/()=?', '%7C%21%22%C2%A3%24%25%26%2F%28%29%3D%3F' ), diff --git a/tests/phpunit/tests/formatting/utf8UriEncode.php b/tests/phpunit/tests/formatting/utf8UriEncode.php index cb6f513c8edef..7d7b33da35328 100644 --- a/tests/phpunit/tests/formatting/utf8UriEncode.php +++ b/tests/phpunit/tests/formatting/utf8UriEncode.php @@ -25,7 +25,7 @@ public function test_output_is_not_longer_than_optional_length_argument( $utf8, $this->assertLessThanOrEqual( $max_length, strlen( utf8_uri_encode( $utf8, $max_length ) ) ); } - public function data() { + public static function data() { $utf8_urls = file( DIR_TESTDATA . '/formatting/utf-8/utf-8.txt' ); $urlencoded = file( DIR_TESTDATA . '/formatting/utf-8/urlencoded.txt' ); $data_provided = array(); diff --git a/tests/phpunit/tests/formatting/wpAutop.php b/tests/phpunit/tests/formatting/wpAutop.php index ee4d90645d09c..2cf71e6cb171a 100644 --- a/tests/phpunit/tests/formatting/wpAutop.php +++ b/tests/phpunit/tests/formatting/wpAutop.php @@ -500,7 +500,7 @@ public function test_element_sanity( $input, $output ) { return $this->assertSame( $output, wpautop( $input ) ); } - public function data_element_sanity() { + public static function data_element_sanity() { return array( array( "Hello ", diff --git a/tests/phpunit/tests/formatting/wpHtmlSplit.php b/tests/phpunit/tests/formatting/wpHtmlSplit.php index 750ad3821cc54..5635b3a9a3b27 100644 --- a/tests/phpunit/tests/formatting/wpHtmlSplit.php +++ b/tests/phpunit/tests/formatting/wpHtmlSplit.php @@ -16,7 +16,7 @@ public function test_basic_features( $input, $output ) { return $this->assertSame( $output, wp_html_split( $input ) ); } - public function data_basic_features() { + public static function data_basic_features() { return array( array( 'abcd efgh', @@ -50,7 +50,7 @@ public function test_pcre_performance( $input ) { return $this->assertLessThan( 200, $result ); } - public function data_whole_posts() { + public static function data_whole_posts() { require_once DIR_TESTDATA . '/formatting/whole-posts.php'; return data_whole_posts(); } diff --git a/tests/phpunit/tests/formatting/wpParseStr.php b/tests/phpunit/tests/formatting/wpParseStr.php index 502715b97bf3b..09cd548fd0522 100644 --- a/tests/phpunit/tests/formatting/wpParseStr.php +++ b/tests/phpunit/tests/formatting/wpParseStr.php @@ -28,7 +28,7 @@ public function test_wp_parse_str( $input, $expected ) { * * @return array */ - public function data_wp_parse_str() { + public static function data_wp_parse_str() { return array( 'null' => array( 'input' => null, @@ -103,7 +103,7 @@ public function test_wp_parse_str_result_array_is_always_overwritten( $output, $ * * @return array */ - public function data_wp_parse_str_result_array_is_always_overwritten() { + public static function data_wp_parse_str_result_array_is_always_overwritten() { // Standard value for expected output. $expected = array( 'key' => '25', diff --git a/tests/phpunit/tests/formatting/wpRelNofollow.php b/tests/phpunit/tests/formatting/wpRelNofollow.php index 83a9c00c23e95..bdcd93550709d 100644 --- a/tests/phpunit/tests/formatting/wpRelNofollow.php +++ b/tests/phpunit/tests/formatting/wpRelNofollow.php @@ -33,7 +33,7 @@ public function test_wp_rel_nofollow( $input, $output, $expect_deprecation = fal $this->assertEqualHTML( $output, stripslashes( wp_rel_nofollow( $input ) ) ); } - public function data_wp_rel_nofollow() { + public static function data_wp_rel_nofollow() { $home_url_http = set_url_scheme( home_url(), 'http' ); $home_url_https = set_url_scheme( home_url(), 'https' ); diff --git a/tests/phpunit/tests/formatting/wpRelUgc.php b/tests/phpunit/tests/formatting/wpRelUgc.php index b1109ed745594..07b1b8c2f7bbe 100644 --- a/tests/phpunit/tests/formatting/wpRelUgc.php +++ b/tests/phpunit/tests/formatting/wpRelUgc.php @@ -33,7 +33,7 @@ public function test_wp_rel_ugc( $input, $output, $expect_deprecation = false ) $this->assertEqualHTML( $output, stripslashes( wp_rel_ugc( $input ) ) ); } - public function data_wp_rel_ugc() { + public static function data_wp_rel_ugc() { $home_url_http = set_url_scheme( home_url(), 'http' ); $home_url_https = set_url_scheme( home_url(), 'https' ); diff --git a/tests/phpunit/tests/formatting/wpReplaceInHtmlTags.php b/tests/phpunit/tests/formatting/wpReplaceInHtmlTags.php index b461e3bfe8e3c..22407e728fb52 100644 --- a/tests/phpunit/tests/formatting/wpReplaceInHtmlTags.php +++ b/tests/phpunit/tests/formatting/wpReplaceInHtmlTags.php @@ -15,7 +15,7 @@ public function test_wp_replace_in_html_tags( $input, $output ) { return $this->assertSame( $output, wp_replace_in_html_tags( $input, array( "\n" => ' ' ) ) ); } - public function data_wp_replace_in_html_tags() { + public static function data_wp_replace_in_html_tags() { return array( array( "Hello \n World", diff --git a/tests/phpunit/tests/formatting/wpSlash.php b/tests/phpunit/tests/formatting/wpSlash.php index 3617b4bfa4ea0..8ddbc81f65748 100644 --- a/tests/phpunit/tests/formatting/wpSlash.php +++ b/tests/phpunit/tests/formatting/wpSlash.php @@ -29,7 +29,7 @@ public function test_wp_slash( $value, $expected ) { * } * } */ - public function data_wp_slash() { + public static function data_wp_slash() { return array( array( 123, 123 ), array( 123.4, 123.4 ), diff --git a/tests/phpunit/tests/formatting/wpSpecialchars.php b/tests/phpunit/tests/formatting/wpSpecialchars.php index edbf29336cc26..23280c0715390 100644 --- a/tests/phpunit/tests/formatting/wpSpecialchars.php +++ b/tests/phpunit/tests/formatting/wpSpecialchars.php @@ -58,7 +58,7 @@ public function test_double_encoding( $input, $output ) { return $this->assertSame( $output, _wp_specialchars( $input, ENT_NOQUOTES, false, true ) ); } - public function data_double_encoding() { + public static function data_double_encoding() { return array( array( 'This & that, this & that, — " " Ú   " " " " " $ ×', @@ -85,7 +85,7 @@ public function test_no_double_encoding( $input, $output ) { return $this->assertSame( $output, _wp_specialchars( $input, ENT_NOQUOTES, false, false ) ); } - public function data_no_double_encoding() { + public static function data_no_double_encoding() { return array( array( 'This & that, this & that, — " " Ú   " " " " " $ ×', diff --git a/tests/phpunit/tests/formatting/wpStripAllTags.php b/tests/phpunit/tests/formatting/wpStripAllTags.php index 6afcbed79fc48..046b22a2122f1 100644 --- a/tests/phpunit/tests/formatting/wpStripAllTags.php +++ b/tests/phpunit/tests/formatting/wpStripAllTags.php @@ -63,7 +63,7 @@ public function test_wp_strip_all_tags_should_return_empty_string_and_trigger_an * * @return array[] */ - public function data_wp_strip_all_tags_should_return_empty_string_and_trigger_an_error_for_non_string_arg() { + public static function data_wp_strip_all_tags_should_return_empty_string_and_trigger_an_error_for_non_string_arg() { return array( 'an empty array' => array( 'non_string' => array() ), 'a non-empty array' => array( 'non_string' => array( 'a string' ) ), @@ -90,7 +90,7 @@ public function test_wp_strip_all_tags_should_cast_scalar_values_to_string( $tex * * @return array[] */ - public function data_wp_strip_all_tags_should_cast_scalar_values_to_string() { + public static function data_wp_strip_all_tags_should_cast_scalar_values_to_string() { return array( '(int) 0' => array( 'text' => 0 ), '(int) 1' => array( 'text' => 1 ), diff --git a/tests/phpunit/tests/formatting/wpTexturize.php b/tests/phpunit/tests/formatting/wpTexturize.php index db847c8fea5fb..61b8b46c46a26 100644 --- a/tests/phpunit/tests/formatting/wpTexturize.php +++ b/tests/phpunit/tests/formatting/wpTexturize.php @@ -271,7 +271,7 @@ public function test_spaces_around_quotes( $input, $output ) { $this->assertSame( $output, wptexturize( $input ) ); } - public function data_spaces_around_quotes() { + public static function data_spaces_around_quotes() { $nbsp = "\xC2\xA0"; $pi = "\xCE\xA0"; @@ -327,7 +327,7 @@ public function test_apos_before_digits( $input, $output ) { $this->assertSame( $output, wptexturize( $input ) ); } - public function data_apos_before_digits() { + public static function data_apos_before_digits() { return array( array( "word '99 word", @@ -368,7 +368,7 @@ public function test_opening_single_quote( $input, $output ) { $this->assertSame( $output, wptexturize( $input ) ); } - public function data_opening_single_quote() { + public static function data_opening_single_quote() { return array( array( "word 'word word", @@ -497,7 +497,7 @@ public function test_double_prime( $input, $output ) { $this->assertSame( $output, wptexturize( $input ) ); } - public function data_double_prime() { + public static function data_double_prime() { return array( array( 'word 99" word', @@ -530,7 +530,7 @@ public function test_single_prime( $input, $output ) { $this->assertSame( $output, wptexturize( $input ) ); } - public function data_single_prime() { + public static function data_single_prime() { return array( array( "word 99' word", @@ -563,7 +563,7 @@ public function test_contractions( $input, $output ) { $this->assertSame( $output, wptexturize( $input ) ); } - public function data_contractions() { + public static function data_contractions() { return array( array( "word word's word", @@ -604,7 +604,7 @@ public function test_opening_quote( $input, $output ) { $this->assertSame( $output, wptexturize( $input ) ); } - public function data_opening_quote() { + public static function data_opening_quote() { return array( array( 'word "word word', @@ -681,7 +681,7 @@ public function test_closing_quote( $input, $output ) { $this->assertSame( $output, wptexturize( $input ) ); } - public function data_closing_quote() { + public static function data_closing_quote() { return array( array( 'word word" word', @@ -770,7 +770,7 @@ public function test_closing_single_quote( $input, $output ) { $this->assertSame( $output, wptexturize( $input ) ); } - public function data_closing_single_quote() { + public static function data_closing_single_quote() { return array( array( "word word' word", @@ -860,7 +860,7 @@ public function test_multiplication( $input, $output ) { $this->assertSame( $output, wptexturize( $input ) ); } - public function data_multiplication() { + public static function data_multiplication() { return array( array( '9x9', @@ -910,7 +910,7 @@ public function test_ampersand( $input, $output ) { $this->assertSame( $output, wptexturize( $input ) ); } - public function data_ampersand() { + public static function data_ampersand() { return array( array( 'word & word', @@ -975,7 +975,7 @@ public function test_cockney( $input, $output ) { $this->assertSame( $output, wptexturize( $input ) ); } - public function data_cockney() { + public static function data_cockney() { return array( array( "word 'tain't word", @@ -1036,7 +1036,7 @@ public function test_smart_dashes( $input, $output ) { $this->assertSame( $output, wptexturize( $input ) ); } - public function data_smart_dashes() { + public static function data_smart_dashes() { return array( array( 'word --- word', @@ -1089,7 +1089,7 @@ public function test_misc_static_replacements( $input, $output ) { $this->assertSame( $output, wptexturize( $input ) ); } - public function data_misc_static_replacements() { + public static function data_misc_static_replacements() { return array( array( 'word ... word', @@ -1144,7 +1144,7 @@ public function test_quoted_numbers( $input, $output ) { $this->assertSame( $output, wptexturize( $input ) ); } - public function data_quoted_numbers() { + public static function data_quoted_numbers() { return array( array( 'word "42.00" word', @@ -1195,7 +1195,7 @@ public function test_quotes_and_dashes( $input, $output ) { $this->assertSame( $output, wptexturize( $input ) ); } - public function data_quotes_and_dashes() { + public static function data_quotes_and_dashes() { return array( array( 'word---"quote"', @@ -1258,7 +1258,7 @@ public function test_tag_avoidance( $input, $output ) { $this->assertSame( $output, wptexturize( $input ) ); } - public function data_tag_avoidance() { + public static function data_tag_avoidance() { return array( array( '[ ... ]', @@ -1481,7 +1481,7 @@ public function test_year_abbr( $input, $output ) { $this->assertSame( $output, wptexturize( $input ) ); } - public function data_year_abbr() { + public static function data_year_abbr() { return array( array( "word '99 word", @@ -1606,7 +1606,7 @@ public function filter_translate( $translations, $text, $context, $domain ) { } } - public function data_translate() { + public static function data_translate() { return array( array( "word '99 word", @@ -1797,7 +1797,7 @@ public function test_element_stack( $input, $output ) { $this->assertSame( $output, wptexturize( $input ) ); } - public function data_element_stack() { + public static function data_element_stack() { return array( array( 'hello---', @@ -1858,7 +1858,7 @@ public function filter_shortcodes( $disabled ) { return $disabled; } - public function data_unregistered_shortcodes() { + public static function data_unregistered_shortcodes() { return array( array( '[a]a--b[audio]---[/audio]a--b[/a]', @@ -1933,7 +1933,7 @@ public function test_primes_vs_quotes( $input, $output ) { $this->assertSame( $output, wptexturize( $input ) ); } - public function data_primes_vs_quotes() { + public static function data_primes_vs_quotes() { return array( array( "George's porch is 99' long.", @@ -2029,7 +2029,7 @@ public function filter_translate2( $translations, $text, $context, $domain ) { } } - public function data_primes_quotes_translation() { + public static function data_primes_quotes_translation() { return array( array( "George's porch is 99' long.", @@ -2111,7 +2111,7 @@ public function test_trailing_less_than() { $this->assertSame( 'F–oo<', wptexturize( 'F--oo<', true ) ); } - public function data_whole_posts() { + public static function data_whole_posts() { require_once DIR_TESTDATA . '/formatting/whole-posts.php'; return data_whole_posts(); } diff --git a/tests/phpunit/tests/formatting/wpTruncateSlug.php b/tests/phpunit/tests/formatting/wpTruncateSlug.php index 1dc3898f93415..59e00f0b7e9fe 100644 --- a/tests/phpunit/tests/formatting/wpTruncateSlug.php +++ b/tests/phpunit/tests/formatting/wpTruncateSlug.php @@ -29,7 +29,7 @@ public function test_wp_truncate_slug_should_truncate( $slug, $length, $expected * * @return array[] */ - public function data_wp_truncate_slug_should_truncate() { + public static function data_wp_truncate_slug_should_truncate() { return array( 'a slug that is too long' => array( 'slug' => 'truncated slug', From 30a849a424f87e7ba17213254eb59751131d8bc5 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 18:53:58 +0000 Subject: [PATCH 005/236] Tests: Make function test data providers static. Declare the data providers in `tests/phpunit/tests/functions/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions. Make the daylight-saving-time helper static so the timezone provider does not require an instance. Developed in: https://github.com/WordPress/wordpress-develop/pull/14382 Props rejaulalomkhan, huzaifaalmesbah. See #66211. git-svn-id: https://develop.svn.wordpress.org/trunk@64440 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/functions/absint.php | 8 ++++---- tests/phpunit/tests/functions/addMagicQuotes.php | 2 +- tests/phpunit/tests/functions/allowedProtocols.php | 2 +- tests/phpunit/tests/functions/anonymization.php | 4 ++-- .../phpunit/tests/functions/cleanDirsizeCache.php | 4 ++-- .../tests/functions/cleanupHeaderComment.php | 2 +- tests/phpunit/tests/functions/doEnclose.php | 2 +- tests/phpunit/tests/functions/forceSslAdmin.php | 2 +- tests/phpunit/tests/functions/getFileData.php | 2 +- tests/phpunit/tests/functions/getNonCachedIds.php | 4 ++-- .../tests/functions/getStatusHeaderDesc.php | 2 +- tests/phpunit/tests/functions/getTagRegex.php | 2 +- tests/phpunit/tests/functions/isNewDay.php | 2 +- .../tests/functions/isPhpVersionCompatible.php | 2 +- tests/phpunit/tests/functions/isSerialized.php | 6 +++--- .../phpunit/tests/functions/isSerializedString.php | 2 +- .../tests/functions/isWpVersionCompatible.php | 6 +++--- tests/phpunit/tests/functions/listFiles.php | 2 +- tests/phpunit/tests/functions/maybeSerialize.php | 6 +++--- tests/phpunit/tests/functions/removeQueryArg.php | 2 +- tests/phpunit/tests/functions/sizeFormat.php | 2 +- tests/phpunit/tests/functions/wpAdminNotice.php | 2 +- .../phpunit/tests/functions/wpArraySliceAssoc.php | 2 +- tests/phpunit/tests/functions/wpCacheGetSalted.php | 2 +- .../tests/functions/wpCheckAlternateFileNames.php | 2 +- tests/phpunit/tests/functions/wpCheckFiletype.php | 2 +- tests/phpunit/tests/functions/wpFilesize.php | 4 ++-- .../phpunit/tests/functions/wpFuzzyNumberMatch.php | 2 +- tests/phpunit/tests/functions/wpGetAdminNotice.php | 4 ++-- tests/phpunit/tests/functions/wpGuessUrl.php | 2 +- tests/phpunit/tests/functions/wpHash.php | 2 +- tests/phpunit/tests/functions/wpIsNumericArray.php | 2 +- tests/phpunit/tests/functions/wpListFilter.php | 2 +- tests/phpunit/tests/functions/wpListPluck.php | 2 +- tests/phpunit/tests/functions/wpListSort.php | 4 ++-- tests/phpunit/tests/functions/wpListUtil.php | 14 +++++++------- tests/phpunit/tests/functions/wpMysqlWeek.php | 2 +- tests/phpunit/tests/functions/wpNonceField.php | 2 +- tests/phpunit/tests/functions/wpNonceUrl.php | 4 ++-- tests/phpunit/tests/functions/wpParseIdList.php | 4 ++-- tests/phpunit/tests/functions/wpParseList.php | 2 +- tests/phpunit/tests/functions/wpParseSlugList.php | 4 ++-- tests/phpunit/tests/functions/wpRefererField.php | 2 +- tests/phpunit/tests/functions/wpTimezoneChoice.php | 6 +++--- .../functions/wpTimezoneChoiceUsortCallback.php | 2 +- .../tests/functions/wpTimezoneOverrideOffset.php | 6 +++--- tests/phpunit/tests/functions/wpToKebabCase.php | 2 +- tests/phpunit/tests/functions/wpTriggerError.php | 2 +- .../tests/functions/wpUniqueIdFromValues.php | 4 ++-- .../phpunit/tests/functions/wpUniquePrefixedId.php | 6 +++--- .../phpunit/tests/functions/wpValidateBoolean.php | 2 +- 51 files changed, 82 insertions(+), 82 deletions(-) diff --git a/tests/phpunit/tests/functions/absint.php b/tests/phpunit/tests/functions/absint.php index f7b9d0d5cae0c..57db8bcb56bc7 100644 --- a/tests/phpunit/tests/functions/absint.php +++ b/tests/phpunit/tests/functions/absint.php @@ -26,7 +26,7 @@ public function test_absint( $test_value, int $expected_value ) { * * @return array */ - public function data_absint(): array { + public static function data_absint(): array { return array( '1 int' => array( 'test_value' => 1, @@ -99,7 +99,7 @@ public function test_absint_other_types( $test_value, int $expected_value ): voi * * @return array */ - public function data_absint_other_types(): array { + public static function data_absint_other_types(): array { /* * The largest power of two which fits in an integer, and which is therefore * also exactly representable as a float: 2^62 on 64-bit builds, 2^30 on @@ -184,7 +184,7 @@ public function test_absint_extreme_values( $test_value, int $expected_value ): * * @return array */ - public function data_absint_extreme_values(): array { + public static function data_absint_extreme_values(): array { return array( 'PHP_INT_MAX' => array( 'test_value' => PHP_INT_MAX, @@ -242,7 +242,7 @@ public function test_absint_unrepresentable_floats( float $test_value, int $expe * * @return array */ - public function data_absint_unrepresentable_floats(): array { + public static function data_absint_unrepresentable_floats(): array { return array( '(float) PHP_INT_MAX (2^63)' => array( 'test_value' => (float) PHP_INT_MAX, diff --git a/tests/phpunit/tests/functions/addMagicQuotes.php b/tests/phpunit/tests/functions/addMagicQuotes.php index 2ad1a4ed98ebc..406d8dae2adae 100644 --- a/tests/phpunit/tests/functions/addMagicQuotes.php +++ b/tests/phpunit/tests/functions/addMagicQuotes.php @@ -28,7 +28,7 @@ public function test_add_magic_quotes( $test_array, $expected ) { * @type array $expected Expected return value. * } */ - public function data_add_magic_quotes() { + public static function data_add_magic_quotes() { return array( array( array( diff --git a/tests/phpunit/tests/functions/allowedProtocols.php b/tests/phpunit/tests/functions/allowedProtocols.php index 63ca3ab0945ce..adcade6e48085 100644 --- a/tests/phpunit/tests/functions/allowedProtocols.php +++ b/tests/phpunit/tests/functions/allowedProtocols.php @@ -42,7 +42,7 @@ public function test_allowed_protocols( $protocol, $url ) { * * @return array[] */ - public function data_example_urls() { + public static function data_example_urls() { return array( array( 'http', 'http://example.com' ), // RFC7230 array( 'https', 'https://example.com' ), // RFC7230 diff --git a/tests/phpunit/tests/functions/anonymization.php b/tests/phpunit/tests/functions/anonymization.php index c4b979bfe92b2..7485b2423a102 100644 --- a/tests/phpunit/tests/functions/anonymization.php +++ b/tests/phpunit/tests/functions/anonymization.php @@ -46,7 +46,7 @@ public function test_wp_privacy_anonymize_ip( $raw_ip, $expected_result ) { * } * } */ - public function data_wp_privacy_anonymize_ip() { + public static function data_wp_privacy_anonymize_ip() { return array( // Invalid IP. array( @@ -200,7 +200,7 @@ public function test_wp_privacy_anonymize_ip_with_inet_dependency( $raw_ip, $exp * } * } */ - public function data_wp_privacy_anonymize_ip_with_inet_dependency() { + public static function data_wp_privacy_anonymize_ip_with_inet_dependency() { return array( // Malformed string with valid IP substring. Sometimes proxies add things like this, or other arbitrary strings. array( diff --git a/tests/phpunit/tests/functions/cleanDirsizeCache.php b/tests/phpunit/tests/functions/cleanDirsizeCache.php index c30517c115277..c675f7c21a2da 100644 --- a/tests/phpunit/tests/functions/cleanDirsizeCache.php +++ b/tests/phpunit/tests/functions/cleanDirsizeCache.php @@ -31,7 +31,7 @@ public function test_clean_dirsize_cache_with_invalid_inputs( $path, $expected_m * * @return array */ - public function data_clean_dirsize_cache_with_invalid_inputs() { + public static function data_clean_dirsize_cache_with_invalid_inputs() { return array( 'null' => array( 'path' => null, @@ -78,7 +78,7 @@ public function test_clean_dirsize_cache_with_non_path_string( $path, $expected_ * * @return array */ - public function data_clean_dirsize_cache_with_non_path_string() { + public static function data_clean_dirsize_cache_with_non_path_string() { return array( 'single dot' => array( 'path' => '.', diff --git a/tests/phpunit/tests/functions/cleanupHeaderComment.php b/tests/phpunit/tests/functions/cleanupHeaderComment.php index 95c1b88d20bf1..5192b64dbca03 100644 --- a/tests/phpunit/tests/functions/cleanupHeaderComment.php +++ b/tests/phpunit/tests/functions/cleanupHeaderComment.php @@ -31,7 +31,7 @@ public function test_cleanup_header_comment( $test_string, $expected ) { * @type string $expected Expected return value. * } */ - public function data_cleanup_header_comment() { + public static function data_cleanup_header_comment() { return array( // Set 0: A string. array( diff --git a/tests/phpunit/tests/functions/doEnclose.php b/tests/phpunit/tests/functions/doEnclose.php index 425b28c9dd6d0..9acf3f9542419 100644 --- a/tests/phpunit/tests/functions/doEnclose.php +++ b/tests/phpunit/tests/functions/doEnclose.php @@ -73,7 +73,7 @@ public function test_function_with_implicit_content_input( $content, $expected ) * } * } */ - public function data_do_enclose() { + public static function data_do_enclose() { return array( 'null' => array( 'content' => null, diff --git a/tests/phpunit/tests/functions/forceSslAdmin.php b/tests/phpunit/tests/functions/forceSslAdmin.php index dd7b99e65e787..cdf6668d3d374 100644 --- a/tests/phpunit/tests/functions/forceSslAdmin.php +++ b/tests/phpunit/tests/functions/forceSslAdmin.php @@ -44,7 +44,7 @@ public function test_force_ssl_admin( $input, $expected ) { * * @return array[] */ - public function data_force_ssl_admin() { + public static function data_force_ssl_admin() { return array( 'default' => array( null, false ), 'true' => array( true, true ), diff --git a/tests/phpunit/tests/functions/getFileData.php b/tests/phpunit/tests/functions/getFileData.php index cbba3e2319e4d..69f3b4452206e 100644 --- a/tests/phpunit/tests/functions/getFileData.php +++ b/tests/phpunit/tests/functions/getFileData.php @@ -46,7 +46,7 @@ public function test_get_file_data( $file, $headers, $context, $expected ) { * expected: array, * }> */ - public function data_test_get_data_file() { + public static function data_test_get_data_file() { return array( 'theme headers' => array( 'file' => '/themedir1/default/style.css', diff --git a/tests/phpunit/tests/functions/getNonCachedIds.php b/tests/phpunit/tests/functions/getNonCachedIds.php index 0f6b93227d710..5536453701e83 100644 --- a/tests/phpunit/tests/functions/getNonCachedIds.php +++ b/tests/phpunit/tests/functions/getNonCachedIds.php @@ -45,7 +45,7 @@ public function test_valid_ids_should_be_returned_as_integers( $object_id ) { * * @return array[] */ - public function data_valid_ids_should_be_returned_as_integers() { + public static function data_valid_ids_should_be_returned_as_integers() { return array( '(int) 1' => array( 1 ), '(string) 1' => array( '1' ), @@ -87,7 +87,7 @@ public function test_invalid_cache_ids_should_throw_a_notice( $object_id ) { * * @return array[] */ - public function data_invalid_cache_ids_should_throw_a_notice() { + public static function data_invalid_cache_ids_should_throw_a_notice() { return array( 'null' => array( null ), 'false' => array( false ), diff --git a/tests/phpunit/tests/functions/getStatusHeaderDesc.php b/tests/phpunit/tests/functions/getStatusHeaderDesc.php index 5fc7f1e016e00..6f05f7c57673e 100644 --- a/tests/phpunit/tests/functions/getStatusHeaderDesc.php +++ b/tests/phpunit/tests/functions/getStatusHeaderDesc.php @@ -26,7 +26,7 @@ public function test_get_status_header_desc( $code, $expected ) { * * @return array[] */ - public function data_get_status_header_desc() { + public static function data_get_status_header_desc() { return array( array( 200, 'OK' ), array( 301, 'Moved Permanently' ), diff --git a/tests/phpunit/tests/functions/getTagRegex.php b/tests/phpunit/tests/functions/getTagRegex.php index e8e1893e4c4c1..a1fb9d5c8d76f 100644 --- a/tests/phpunit/tests/functions/getTagRegex.php +++ b/tests/phpunit/tests/functions/getTagRegex.php @@ -36,7 +36,7 @@ public function test_get_tag_regex_matches( $tag, $content, $expected ) { * * @return array[] */ - public function data_get_tag_regex_matches() { + public static function data_get_tag_regex_matches() { // Each case embeds the element(s) within surrounding HTML, mirroring the // original usage in get_media_embedded_in_content(), which is passed a // string of HTML that may contain media elements rather than the bare diff --git a/tests/phpunit/tests/functions/isNewDay.php b/tests/phpunit/tests/functions/isNewDay.php index 27c9b5232fe4c..664c57850d8dd 100644 --- a/tests/phpunit/tests/functions/isNewDay.php +++ b/tests/phpunit/tests/functions/isNewDay.php @@ -32,7 +32,7 @@ public function test_is_new_date( $currentday_string, $previousday_string, $expe * * @return array[] */ - public function data_is_new_date() { + public static function data_is_new_date() { return array( array( '21.05.19', '21.05.19', 0 ), array( '21.05.19', '20.05.19', 1 ), diff --git a/tests/phpunit/tests/functions/isPhpVersionCompatible.php b/tests/phpunit/tests/functions/isPhpVersionCompatible.php index e471a2ea98000..0835cb917cb91 100644 --- a/tests/phpunit/tests/functions/isPhpVersionCompatible.php +++ b/tests/phpunit/tests/functions/isPhpVersionCompatible.php @@ -27,7 +27,7 @@ public function test_is_php_version_compatible( $required, $expected ) { * * @return array[] */ - public function data_is_php_version_compatible() { + public static function data_is_php_version_compatible() { $php_version = PHP_VERSION; $version_parts = explode( '.', $php_version ); diff --git a/tests/phpunit/tests/functions/isSerialized.php b/tests/phpunit/tests/functions/isSerialized.php index fdc7e124fb42e..4273789e94e02 100644 --- a/tests/phpunit/tests/functions/isSerialized.php +++ b/tests/phpunit/tests/functions/isSerialized.php @@ -27,7 +27,7 @@ public function test_is_serialized( $data, $expected ) { * * @return array[] */ - public function data_is_serialized() { + public static function data_is_serialized() { return array( 'serialized empty array' => array( 'data' => serialize( array() ), @@ -99,7 +99,7 @@ public function data_is_serialized() { * * @return array[] */ - public function data_is_not_serialized() { + public static function data_is_not_serialized() { return array( 'an empty array' => array( 'data' => array(), @@ -197,7 +197,7 @@ public function test_is_serialized_should_return_true_for_large_floats( $value ) * * @return array[] */ - public function data_is_serialized_should_return_true_for_large_floats() { + public static function data_is_serialized_should_return_true_for_large_floats() { return array( array( serialize( 1.7976931348623157E+308 ) ), array( serialize( array( 1.7976931348623157E+308, 1.23e50 ) ) ), diff --git a/tests/phpunit/tests/functions/isSerializedString.php b/tests/phpunit/tests/functions/isSerializedString.php index cc0099e96bfc4..103238dd3a1bf 100644 --- a/tests/phpunit/tests/functions/isSerializedString.php +++ b/tests/phpunit/tests/functions/isSerializedString.php @@ -26,7 +26,7 @@ public function test_is_serialized_string( $data, $expected ) { * * @return array[] */ - public function data_is_serialized_string() { + public static function data_is_serialized_string() { return array( 'an array' => array( 'data' => array(), diff --git a/tests/phpunit/tests/functions/isWpVersionCompatible.php b/tests/phpunit/tests/functions/isWpVersionCompatible.php index fba8af3e14fdd..137e7de3f7340 100644 --- a/tests/phpunit/tests/functions/isWpVersionCompatible.php +++ b/tests/phpunit/tests/functions/isWpVersionCompatible.php @@ -60,7 +60,7 @@ public function test_is_wp_version_compatible( $required, $expected ) { * * @return array[] */ - public function data_is_wp_version_compatible() { + public static function data_is_wp_version_compatible() { $wp_version = wp_get_wp_version(); $version_parts = explode( '.', $wp_version ); $lower_version = $version_parts; @@ -152,7 +152,7 @@ public function test_is_wp_version_compatible_should_gracefully_handle_trailing_ * * @return array[] */ - public function data_is_wp_version_compatible_should_gracefully_handle_trailing_point_zero_version_numbers() { + public static function data_is_wp_version_compatible_should_gracefully_handle_trailing_point_zero_version_numbers() { return array( 'an incorrect trailing .0 and the same version' => array( 'required' => '5.2.0', @@ -224,7 +224,7 @@ public function test_is_wp_version_compatible_with_development_versions( $requir * * @return array[] */ - public function data_is_wp_version_compatible_with_development_versions() { + public static function data_is_wp_version_compatible_with_development_versions() { // For consistent results, remove possible suffixes. list( $version ) = explode( '-', wp_get_wp_version() ); diff --git a/tests/phpunit/tests/functions/listFiles.php b/tests/phpunit/tests/functions/listFiles.php index a7e7346956dc6..0e02b11ac19d3 100644 --- a/tests/phpunit/tests/functions/listFiles.php +++ b/tests/phpunit/tests/functions/listFiles.php @@ -57,7 +57,7 @@ public function test_list_files_should_optionally_include_hidden_files( $filenam * * @return array[] */ - public function data_list_files_should_optionally_include_hidden_files() { + public static function data_list_files_should_optionally_include_hidden_files() { return array( '$include_hidden = false and no exclusions' => array( 'filename' => '.hidden_file', diff --git a/tests/phpunit/tests/functions/maybeSerialize.php b/tests/phpunit/tests/functions/maybeSerialize.php index 32d1488d9f54f..47e760ad6b59f 100644 --- a/tests/phpunit/tests/functions/maybeSerialize.php +++ b/tests/phpunit/tests/functions/maybeSerialize.php @@ -56,7 +56,7 @@ public function test_maybe_unserialize( $value, $is_serialized ) { * * @return array[] */ - public function data_is_serialized() { + public static function data_is_serialized() { return array( 'serialized empty array' => array( 'data' => serialize( array() ), @@ -124,7 +124,7 @@ public function data_is_serialized() { * * @return array[] */ - public function data_is_not_serialized() { + public static function data_is_not_serialized() { return array( 'an empty array' => array( 'data' => array(), @@ -234,7 +234,7 @@ public function test_deserialize_request_utility_filtered_iterator_objects( $val * * @return array[] */ - public function data_serialize_deserialize_objects() { + public static function data_serialize_deserialize_objects() { return array( 'filtered iterator using md5' => array( new WpOrg\Requests\Utility\FilteredIterator( array( 1 ), 'md5' ), diff --git a/tests/phpunit/tests/functions/removeQueryArg.php b/tests/phpunit/tests/functions/removeQueryArg.php index 43252fc11c4e8..f7dfc18771a43 100644 --- a/tests/phpunit/tests/functions/removeQueryArg.php +++ b/tests/phpunit/tests/functions/removeQueryArg.php @@ -22,7 +22,7 @@ public function test_remove_query_arg( $keys_to_remove, $url, $expected ) { * * @return array[] */ - public function data_remove_query_arg() { + public static function data_remove_query_arg() { return array( array( 'foo', 'edit.php?foo=test1&baz=test1', 'edit.php?baz=test1' ), array( array( 'foo' ), 'edit.php?foo=test2&baz=test2', 'edit.php?baz=test2' ), diff --git a/tests/phpunit/tests/functions/sizeFormat.php b/tests/phpunit/tests/functions/sizeFormat.php index b4a038408b47b..fb9e1415612b8 100644 --- a/tests/phpunit/tests/functions/sizeFormat.php +++ b/tests/phpunit/tests/functions/sizeFormat.php @@ -18,7 +18,7 @@ class Tests_Functions_SizeFormat extends WP_UnitTestCase { * * @return array[] */ - public function data_size_format() { + public static function data_size_format() { return array( // Invalid values. array( array(), 0, false ), diff --git a/tests/phpunit/tests/functions/wpAdminNotice.php b/tests/phpunit/tests/functions/wpAdminNotice.php index 3fb5391dead3e..9ced4e920937a 100644 --- a/tests/phpunit/tests/functions/wpAdminNotice.php +++ b/tests/phpunit/tests/functions/wpAdminNotice.php @@ -33,7 +33,7 @@ public function test_should_output_admin_notice( $message, $args, $expected ) { * * @return array[] */ - public function data_should_output_admin_notice() { + public static function data_should_output_admin_notice() { return array( 'defaults' => array( 'message' => 'A notice with defaults.', diff --git a/tests/phpunit/tests/functions/wpArraySliceAssoc.php b/tests/phpunit/tests/functions/wpArraySliceAssoc.php index 9e3cb65e8114b..6f7ad9c7762a7 100644 --- a/tests/phpunit/tests/functions/wpArraySliceAssoc.php +++ b/tests/phpunit/tests/functions/wpArraySliceAssoc.php @@ -31,7 +31,7 @@ public function test_wp_array_slice_assoc( $target_array, $keys, $expected ) { * * @return array[] */ - public function data_wp_array_slice_assoc_arrays() { + public static function data_wp_array_slice_assoc_arrays() { return array( array( array( 1 => 1 ), diff --git a/tests/phpunit/tests/functions/wpCacheGetSalted.php b/tests/phpunit/tests/functions/wpCacheGetSalted.php index d54a68274eee6..9d748ce87ef0b 100644 --- a/tests/phpunit/tests/functions/wpCacheGetSalted.php +++ b/tests/phpunit/tests/functions/wpCacheGetSalted.php @@ -74,7 +74,7 @@ public function test_wp_cache_get_salted_return_false( $cache_value ) { * * @return array[] Data provider. */ - public function data_wp_cache_get_salted_return_false() { + public static function data_wp_cache_get_salted_return_false() { return array( array( false ), array( null ), diff --git a/tests/phpunit/tests/functions/wpCheckAlternateFileNames.php b/tests/phpunit/tests/functions/wpCheckAlternateFileNames.php index 47a99244d726a..fca5846097dcb 100644 --- a/tests/phpunit/tests/functions/wpCheckAlternateFileNames.php +++ b/tests/phpunit/tests/functions/wpCheckAlternateFileNames.php @@ -26,7 +26,7 @@ public function test_wp_check_alternate_file_names( $filenames, $dir, $files, $e * * @return array[] */ - public function data_wp_check_alternate_file_names() { + public static function data_wp_check_alternate_file_names() { return array( 'an existing file' => array( 'filenames' => array( 'canola.jpg' ), diff --git a/tests/phpunit/tests/functions/wpCheckFiletype.php b/tests/phpunit/tests/functions/wpCheckFiletype.php index 37d7afdd01696..8ff86adda37ac 100644 --- a/tests/phpunit/tests/functions/wpCheckFiletype.php +++ b/tests/phpunit/tests/functions/wpCheckFiletype.php @@ -30,7 +30,7 @@ public function test_wp_check_filetype( $filename, $mimes, $expected ) { * * @return array[] */ - public function data_wp_check_filetype() { + public static function data_wp_check_filetype() { return array( '.jpg filename and default allowed' => array( 'filename' => 'canola.jpg', diff --git a/tests/phpunit/tests/functions/wpFilesize.php b/tests/phpunit/tests/functions/wpFilesize.php index 07a62ac2004aa..cd98053671d3d 100644 --- a/tests/phpunit/tests/functions/wpFilesize.php +++ b/tests/phpunit/tests/functions/wpFilesize.php @@ -73,7 +73,7 @@ public function test_wp_filesize_pre_wp_filesize_filter_negative( $value ): void * * @return array */ - public function data_wp_filesize_pre_wp_filesize_filter_negative(): array { + public static function data_wp_filesize_pre_wp_filesize_filter_negative(): array { return array( 'negative int' => array( -1 ), 'negative numeric string' => array( '-1' ), @@ -98,7 +98,7 @@ public function test_wp_filesize_wp_filesize_filter_invalid_value( $value ): voi * * @return array */ - public function data_wp_filesize_filter_invalid_value(): array { + public static function data_wp_filesize_filter_invalid_value(): array { return array( 'negative' => array( -1 ), 'null' => array( null ), diff --git a/tests/phpunit/tests/functions/wpFuzzyNumberMatch.php b/tests/phpunit/tests/functions/wpFuzzyNumberMatch.php index 1935edefefea4..573b455d17b04 100644 --- a/tests/phpunit/tests/functions/wpFuzzyNumberMatch.php +++ b/tests/phpunit/tests/functions/wpFuzzyNumberMatch.php @@ -33,7 +33,7 @@ public function test_wp_fuzzy_number_match( $expected, $actual, $precision, $res * @type bool $result Whether the numbers match within the specified precision. * } */ - public function data_wp_fuzzy_number_match() { + public static function data_wp_fuzzy_number_match() { return array( 'expected 1 int, actual 1 int' => array( 'expected' => 1, diff --git a/tests/phpunit/tests/functions/wpGetAdminNotice.php b/tests/phpunit/tests/functions/wpGetAdminNotice.php index 87343479a2670..0c1716c3ce3b8 100644 --- a/tests/phpunit/tests/functions/wpGetAdminNotice.php +++ b/tests/phpunit/tests/functions/wpGetAdminNotice.php @@ -29,7 +29,7 @@ public function test_should_return_admin_notice( $message, $args, $expected ) { * * @return array[] */ - public function data_should_return_admin_notice() { + public static function data_should_return_admin_notice() { return array( 'defaults' => array( 'message' => 'A notice with defaults.', @@ -317,7 +317,7 @@ public function test_should_apply_filters( $hook_name ) { * * @return array[] */ - public function data_should_apply_filters() { + public static function data_should_apply_filters() { return array( 'wp_admin_notice_args' => array( 'hook_name' => 'wp_admin_notice_args' ), 'wp_admin_notice_markup' => array( 'hook_name' => 'wp_admin_notice_markup' ), diff --git a/tests/phpunit/tests/functions/wpGuessUrl.php b/tests/phpunit/tests/functions/wpGuessUrl.php index 88347c7f17524..916a0beb76245 100644 --- a/tests/phpunit/tests/functions/wpGuessUrl.php +++ b/tests/phpunit/tests/functions/wpGuessUrl.php @@ -27,7 +27,7 @@ public function test_wp_guess_url_should_return_site_url( $url ) { * * @return array[] */ - public function data_wp_guess_url_should_return_site_url() { + public static function data_wp_guess_url_should_return_site_url() { return array( 'no trailing slash' => array( 'url' => 'wp-admin' ), 'trailing slash' => array( 'url' => 'wp-admin/' ), diff --git a/tests/phpunit/tests/functions/wpHash.php b/tests/phpunit/tests/functions/wpHash.php index 63744b188dace..570692b62d8fa 100644 --- a/tests/phpunit/tests/functions/wpHash.php +++ b/tests/phpunit/tests/functions/wpHash.php @@ -20,7 +20,7 @@ public function test_wp_hash_uses_specified_algorithm( string $algo, int $expect $this->assertSame( $expected_length, strlen( $hash ) ); } - public function data_wp_hash_uses_specified_algorithm() { + public static function data_wp_hash_uses_specified_algorithm() { return array( array( 'md5', 32 ), array( 'sha1', 40 ), diff --git a/tests/phpunit/tests/functions/wpIsNumericArray.php b/tests/phpunit/tests/functions/wpIsNumericArray.php index 4bf7b0cc1695b..3d38edae7b948 100644 --- a/tests/phpunit/tests/functions/wpIsNumericArray.php +++ b/tests/phpunit/tests/functions/wpIsNumericArray.php @@ -24,7 +24,7 @@ public function test_wp_is_numeric_array( $input, $expected ) { * * @return array[] */ - public function data_wp_is_numeric_array() { + public static function data_wp_is_numeric_array() { return array( 'no index' => array( 'test_array' => array( 'www', 'eee' ), diff --git a/tests/phpunit/tests/functions/wpListFilter.php b/tests/phpunit/tests/functions/wpListFilter.php index d9fca8cf5c494..1039b70f3ec20 100644 --- a/tests/phpunit/tests/functions/wpListFilter.php +++ b/tests/phpunit/tests/functions/wpListFilter.php @@ -27,7 +27,7 @@ public function test_wp_list_filter( $input_list, $args, $operator, $expected ) * * @return array[] */ - public function data_wp_list_filter() { + public static function data_wp_list_filter() { return array( 'string instead of array' => array( 'foo', diff --git a/tests/phpunit/tests/functions/wpListPluck.php b/tests/phpunit/tests/functions/wpListPluck.php index 8313116294519..428555ad0a40d 100644 --- a/tests/phpunit/tests/functions/wpListPluck.php +++ b/tests/phpunit/tests/functions/wpListPluck.php @@ -221,7 +221,7 @@ public function test_wp_list_pluck( $input_list, $field, $index_key, $expected ) * * @return array[] */ - public function data_wp_list_pluck() { + public static function data_wp_list_pluck() { return array( 'arrays' => array( array( diff --git a/tests/phpunit/tests/functions/wpListSort.php b/tests/phpunit/tests/functions/wpListSort.php index 8bcf8e54414ee..b5f70f0a28470 100644 --- a/tests/phpunit/tests/functions/wpListSort.php +++ b/tests/phpunit/tests/functions/wpListSort.php @@ -25,7 +25,7 @@ public function test_wp_list_sort( $input_list, $orderby, $order, $expected ) { * * @return array[] */ - public function data_wp_list_sort() { + public static function data_wp_list_sort() { return array( 'single orderby ascending' => array( array( @@ -355,7 +355,7 @@ public function test_wp_list_sort_preserve_keys( $input_list, $orderby, $order, * * @return array[] */ - public function data_wp_list_sort_preserve_keys() { + public static function data_wp_list_sort_preserve_keys() { return array( 'single orderby ascending' => array( array( diff --git a/tests/phpunit/tests/functions/wpListUtil.php b/tests/phpunit/tests/functions/wpListUtil.php index fd068387fd64c..e7d92c90f8106 100644 --- a/tests/phpunit/tests/functions/wpListUtil.php +++ b/tests/phpunit/tests/functions/wpListUtil.php @@ -89,7 +89,7 @@ public function test_wp_list_util_pluck( $target_array, $target_key, $expected, * * @return array[] */ - public function data_wp_list_util_pluck() { + public static function data_wp_list_util_pluck() { return array( 'simple' => array( 'target_array' => array( @@ -149,7 +149,7 @@ public function test_wp_list_pluck_should_throw_doing_it_wrong_with_index_key_an * * @return array[] */ - public function data_wp_list_pluck_should_throw_doing_it_wrong_with_invalid_input() { + public static function data_wp_list_pluck_should_throw_doing_it_wrong_with_invalid_input() { return array( 'int[] 0' => array( array( 0 ) ), 'int[] 1' => array( array( 1 ) ), @@ -246,7 +246,7 @@ public function test_wp_list_util_sort( $expected, $target_array, $orderby = arr * * @return array[] */ - public function data_wp_list_util_sort_string_arrays() { + public static function data_wp_list_util_sort_string_arrays() { return array( 'string[], no keys, no ordering' => array( 'expected' => array( 'four', 'two', 'three', 'one' ), @@ -322,7 +322,7 @@ public function data_wp_list_util_sort_string_arrays() { * * @return array[] */ - public function data_wp_list_util_sort_int_arrays() { + public static function data_wp_list_util_sort_int_arrays() { return array( 'int[], no keys, no ordering' => array( 'expected' => array( 4, 2, 3, 1 ), @@ -398,7 +398,7 @@ public function data_wp_list_util_sort_int_arrays() { * * @return array[] */ - public function data_wp_list_util_sort_arrays_of_arrays() { + public static function data_wp_list_util_sort_arrays_of_arrays() { return array( 'array[], no keys, no ordering' => array( 'expected' => array( @@ -774,7 +774,7 @@ public function data_wp_list_util_sort_arrays_of_arrays() { * * @return array[] */ - public function data_wp_list_util_sort_object_arrays() { + public static function data_wp_list_util_sort_object_arrays() { return array( 'object[], no keys, no ordering' => array( 'expected' => array( @@ -1007,7 +1007,7 @@ public function data_wp_list_util_sort_object_arrays() { * * @return array[] */ - public function data_wp_list_util_sort_non_existent_orderby_fields() { + public static function data_wp_list_util_sort_non_existent_orderby_fields() { return array( 'int[], int keys, $orderby a non-existent field, $order = ASC and $preserve_keys = false' => array( 'expected' => array( 4, 2, 3, 1 ), diff --git a/tests/phpunit/tests/functions/wpMysqlWeek.php b/tests/phpunit/tests/functions/wpMysqlWeek.php index 3649ee6c4c98c..bb6af062b647c 100644 --- a/tests/phpunit/tests/functions/wpMysqlWeek.php +++ b/tests/phpunit/tests/functions/wpMysqlWeek.php @@ -29,7 +29,7 @@ static function ( $value ) use ( $start_of_week ) { /** * @return array[] */ - public function data_wp_mysql_week() { + public static function data_wp_mysql_week() { return array( array( '1969-12-25', 0, 'WEEK( col_name, 0 )' ), array( '1969-12-25', 1, 'WEEK( col_name, 1 )' ), diff --git a/tests/phpunit/tests/functions/wpNonceField.php b/tests/phpunit/tests/functions/wpNonceField.php index 7ca6e80d0da77..2d6e1e3c9c0e2 100644 --- a/tests/phpunit/tests/functions/wpNonceField.php +++ b/tests/phpunit/tests/functions/wpNonceField.php @@ -46,7 +46,7 @@ public function test_wp_nonce_field_return( $action, $name, $referer, $expected_ * * @return array[] */ - public function data_wp_nonce_field() { + public static function data_wp_nonce_field() { return array( 'default' => array( 'action' => -1, diff --git a/tests/phpunit/tests/functions/wpNonceUrl.php b/tests/phpunit/tests/functions/wpNonceUrl.php index a4d409dd86d4c..04d531cefd0b7 100644 --- a/tests/phpunit/tests/functions/wpNonceUrl.php +++ b/tests/phpunit/tests/functions/wpNonceUrl.php @@ -39,7 +39,7 @@ public function test_should_append_nonce_name_and_value( $actionurl, $action = - * * @return array[] */ - public function data_should_append_nonce_name_and_value() { + public static function data_should_append_nonce_name_and_value() { return array( 'http:// and default action/name' => array( 'actionurl' => 'http://example.org/', @@ -126,7 +126,7 @@ public function test_should_handle_existing_query_args( $actionurl, $expected ) * * @return array[] */ - public function data_should_handle_existing_query_args() { + public static function data_should_handle_existing_query_args() { return array( 'one query arg' => array( 'actionurl' => 'http://example.org/?hello=world', diff --git a/tests/phpunit/tests/functions/wpParseIdList.php b/tests/phpunit/tests/functions/wpParseIdList.php index 8ce97960f8f20..fbf2ccb9f48e6 100644 --- a/tests/phpunit/tests/functions/wpParseIdList.php +++ b/tests/phpunit/tests/functions/wpParseIdList.php @@ -39,7 +39,7 @@ public function test_wp_parse_id_list( $input_list, array $expected ): void { * * @return array }> */ - public function data_wp_parse_id_list(): array { + public static function data_wp_parse_id_list(): array { return array( 'regular' => array( 'input_list' => '1,2,3,4', @@ -94,7 +94,7 @@ public function data_wp_parse_id_list(): array { * * @return array }> */ - public function data_unexpected_input(): array { + public static function data_unexpected_input(): array { return array( 'string with commas' => array( 'input_list' => '1,2,string with spaces', diff --git a/tests/phpunit/tests/functions/wpParseList.php b/tests/phpunit/tests/functions/wpParseList.php index 42edfe3df45f2..73a7f87593080 100644 --- a/tests/phpunit/tests/functions/wpParseList.php +++ b/tests/phpunit/tests/functions/wpParseList.php @@ -37,7 +37,7 @@ public function test_wp_parse_list( $input_list, array $expected ): void { * * @return array }> */ - public function data_wp_parse_list(): array { + public static function data_wp_parse_list(): array { return array( 'ids only' => array( 'input_list' => '1,2,3,4', diff --git a/tests/phpunit/tests/functions/wpParseSlugList.php b/tests/phpunit/tests/functions/wpParseSlugList.php index bdb6d2cdc7f49..c20d79b59216e 100644 --- a/tests/phpunit/tests/functions/wpParseSlugList.php +++ b/tests/phpunit/tests/functions/wpParseSlugList.php @@ -39,7 +39,7 @@ public function test_wp_parse_slug_list( $input_list, array $expected ): void { * * @return array }> */ - public function data_wp_parse_slug_list(): array { + public static function data_wp_parse_slug_list(): array { return array( 'regular' => array( 'input_list' => 'apple,banana,carrot,dog', @@ -107,7 +107,7 @@ public function data_wp_parse_slug_list(): array { * * @return array }> */ - public function data_unexpected_input(): array { + public static function data_unexpected_input(): array { return array( 'string with commas' => array( 'input_list' => '1,2,string with spaces', diff --git a/tests/phpunit/tests/functions/wpRefererField.php b/tests/phpunit/tests/functions/wpRefererField.php index 72e2fe99d5fde..8bc72dc106490 100644 --- a/tests/phpunit/tests/functions/wpRefererField.php +++ b/tests/phpunit/tests/functions/wpRefererField.php @@ -50,7 +50,7 @@ public function test_wp_referer_field_should_respect_display_arg( $display ) { * * @return array[] */ - public function data_wp_referer_field_should_respect_display_arg() { + public static function data_wp_referer_field_should_respect_display_arg() { return array( 'true' => array( true ), '(int) 1' => array( 1 ), diff --git a/tests/phpunit/tests/functions/wpTimezoneChoice.php b/tests/phpunit/tests/functions/wpTimezoneChoice.php index 7ca94c0c5a29f..802c62d171b7a 100644 --- a/tests/phpunit/tests/functions/wpTimezoneChoice.php +++ b/tests/phpunit/tests/functions/wpTimezoneChoice.php @@ -37,7 +37,7 @@ public function test_wp_timezone_choice( string $expected ): void { * * @return array */ - public function data_wp_timezone_choice(): array { + public static function data_wp_timezone_choice(): array { return array( 'placeholder option' => array( '' ), 'city in Americas' => array( '' ), @@ -70,7 +70,7 @@ public function test_wp_timezone_choice_selected( string $selected_zone, string * * @return array */ - public function data_wp_timezone_choice_selected(): array { + public static function data_wp_timezone_choice_selected(): array { return array( 'city from the list' => array( 'America/Los_Angeles', @@ -109,7 +109,7 @@ public function test_wp_timezone_choice_es( string $expected ): void { * * @return array */ - public function data_wp_timezone_choice_es(): array { + public static function data_wp_timezone_choice_es(): array { return array( 'placeholder remains in English (no translation override passed)' => array( '' ), 'spanish city translation' => array( '' ), diff --git a/tests/phpunit/tests/functions/wpTimezoneChoiceUsortCallback.php b/tests/phpunit/tests/functions/wpTimezoneChoiceUsortCallback.php index 5c89cbaf4eb8f..7db290dbaa295 100644 --- a/tests/phpunit/tests/functions/wpTimezoneChoiceUsortCallback.php +++ b/tests/phpunit/tests/functions/wpTimezoneChoiceUsortCallback.php @@ -20,7 +20,7 @@ public function test_wp_timezone_choice_usort_callback( $unsorted, $sorted ) { $this->assertSame( $sorted, $unsorted ); } - public function data_wp_timezone_choice_usort_callback() { + public static function data_wp_timezone_choice_usort_callback() { return array( 'just GMT+' => array( 'unsorted' => array( diff --git a/tests/phpunit/tests/functions/wpTimezoneOverrideOffset.php b/tests/phpunit/tests/functions/wpTimezoneOverrideOffset.php index 10c90b7037c3b..49b30c2326b78 100644 --- a/tests/phpunit/tests/functions/wpTimezoneOverrideOffset.php +++ b/tests/phpunit/tests/functions/wpTimezoneOverrideOffset.php @@ -27,13 +27,13 @@ public function test_wp_timezone_override_offset( $timezone_string, $expected ) * @type string $expected Expected return value. * } */ - public function data_wp_timezone_override_offset() { + public static function data_wp_timezone_override_offset() { return array( 'no timezone string option set' => array( '', false ), 'bad option set' => array( 'BAD_TIME_ZONE', false ), 'UTC option set' => array( 'UTC', 0.0 ), 'EST option set' => array( 'EST', -5.0 ), - 'NST option set' => array( 'America/St_Johns', $this->is_timezone_in_dst( 'America/St_Johns' ) ? -2.5 : -3.5 ), + 'NST option set' => array( 'America/St_Johns', self::is_timezone_in_dst( 'America/St_Johns' ) ? -2.5 : -3.5 ), ); } @@ -43,7 +43,7 @@ public function data_wp_timezone_override_offset() { * @param string $timezone_string The timezone identifier (e.g., 'America/St_Johns'). * @return bool Whether the timezone is observing DST. */ - private function is_timezone_in_dst( $timezone_string ) { + private static function is_timezone_in_dst( $timezone_string ) { $timezone = new DateTimeZone( $timezone_string ); $timestamp = time(); $transitions = $timezone->getTransitions( $timestamp, $timestamp ); diff --git a/tests/phpunit/tests/functions/wpToKebabCase.php b/tests/phpunit/tests/functions/wpToKebabCase.php index c7fb5a4a7ed54..332f0e58150f1 100644 --- a/tests/phpunit/tests/functions/wpToKebabCase.php +++ b/tests/phpunit/tests/functions/wpToKebabCase.php @@ -33,7 +33,7 @@ public function test_wp_to_kebab_case( $test_value, $expected ) { * @type string $expected Expected return value. * } */ - public function data_wp_to_kebab_case() { + public static function data_wp_to_kebab_case() { return array( array( 'white', 'white' ), array( 'white+black', 'white-black' ), diff --git a/tests/phpunit/tests/functions/wpTriggerError.php b/tests/phpunit/tests/functions/wpTriggerError.php index 6d577cc294fc8..31eaccdb30f87 100644 --- a/tests/phpunit/tests/functions/wpTriggerError.php +++ b/tests/phpunit/tests/functions/wpTriggerError.php @@ -80,7 +80,7 @@ public function test_should_trigger_deprecation( $function_name, $message, $expe * * @return array[] */ - public function data_should_trigger_error() { + public static function data_should_trigger_error() { return array( 'function name and message are given' => array( 'function_name' => 'some_function', diff --git a/tests/phpunit/tests/functions/wpUniqueIdFromValues.php b/tests/phpunit/tests/functions/wpUniqueIdFromValues.php index d46afd12f5fba..5051a14cc7e0d 100644 --- a/tests/phpunit/tests/functions/wpUniqueIdFromValues.php +++ b/tests/phpunit/tests/functions/wpUniqueIdFromValues.php @@ -73,7 +73,7 @@ public function test_wp_unique_id_from_values_uniqueness( $data ) { * * @return array[] */ - public function data_wp_unique_id_from_values() { + public static function data_wp_unique_id_from_values() { return array( 'string' => array( array( 'value' => 'text' ) ), 'integer' => array( array( 'value' => 123 ) ), @@ -141,7 +141,7 @@ public function test_wp_unique_id_from_values_invalid_data( $data ) { * * @return array[] */ - public function data_wp_unique_id_from_values_invalid_data() { + public static function data_wp_unique_id_from_values_invalid_data() { return array( 'string' => array( 'text' ), 'integer' => array( 123 ), diff --git a/tests/phpunit/tests/functions/wpUniquePrefixedId.php b/tests/phpunit/tests/functions/wpUniquePrefixedId.php index ed6e489a3e259..9f5a35de52833 100644 --- a/tests/phpunit/tests/functions/wpUniquePrefixedId.php +++ b/tests/phpunit/tests/functions/wpUniquePrefixedId.php @@ -38,7 +38,7 @@ public function test_should_create_unique_prefixed_ids( $prefix, $expected ) { * * @return array[] */ - public function data_should_create_unique_prefixed_ids() { + public static function data_should_create_unique_prefixed_ids() { return array( 'prefix as empty string' => array( 'prefix' => '', @@ -103,7 +103,7 @@ public function test_should_raise_notice_and_use_empty_string_prefix_when_nonstr * * @return array[] */ - public function data_should_raise_notice_and_use_empty_string_prefix_when_nonstring_given() { + public static function data_should_raise_notice_and_use_empty_string_prefix_when_nonstring_given() { $message = 'wp_unique_prefixed_id(): The prefix must be a string. "%s" data type given.'; return array( 'prefix as null' => array( @@ -177,7 +177,7 @@ public function test_same_prefixes_should_generate_unique_ids( array $prefixes, * * @return array[] */ - public function data_same_prefixes_should_generate_unique_ids() { + public static function data_same_prefixes_should_generate_unique_ids() { return array( 'prefixes = empty string' => array( 'prefixes' => array( null, true, '' ), diff --git a/tests/phpunit/tests/functions/wpValidateBoolean.php b/tests/phpunit/tests/functions/wpValidateBoolean.php index 832e28ffc5b3a..0357484d27774 100644 --- a/tests/phpunit/tests/functions/wpValidateBoolean.php +++ b/tests/phpunit/tests/functions/wpValidateBoolean.php @@ -32,7 +32,7 @@ public function test_wp_validate_boolean( $test_value, $expected ) { * @type bool $expected Expected return value. * } */ - public function data_wp_validate_boolean() { + public static function data_wp_validate_boolean() { $std = new \stdClass(); return array( From 9cbfedb3af3c0cfcaedc2966752c2f2d50bfb0c8 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 19:00:34 +0000 Subject: [PATCH 006/236] Tests: Make admin test data providers static. Declare the data providers in `tests/phpunit/tests/admin/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions. Update direct calls to the submenu provider to use `self::`. Developed in: https://github.com/WordPress/wordpress-develop/pull/14389 Props rejaulalomkhan. See #66211. git-svn-id: https://develop.svn.wordpress.org/trunk@64441 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/admin/exportWp.php | 2 +- .../tests/admin/includes/comment/EditComment_Test.php | 2 +- .../misc/CustomizerMobileViewportMeta_Test.php | 2 +- .../admin/includes/misc/WpAdminCanonicalUrl_Test.php | 2 +- .../admin/includes/misc/WpAdminViewportMeta_Test.php | 2 +- .../tests/admin/includes/misc/WpDocLinkParse_Test.php | 2 +- .../includes/misc/WpHeartbeatSetSuspension_Test.php | 2 +- .../admin/includes/misc/WpMakeThemeFileTree_Test.php | 2 +- .../WpPrivacySettingsFilterDraftPageTitles_Test.php | 2 +- .../plugin-install/WpGetPluginActionButton_Test.php | 2 +- ...IsAuthorizeApplicationPasswordRequestValid_Test.php | 2 +- .../WpIsAuthorizeApplicationRedirectUrlValid_Test.php | 2 +- tests/phpunit/tests/admin/includesFile.php | 10 +++++----- tests/phpunit/tests/admin/includesMedia.php | 4 ++-- tests/phpunit/tests/admin/includesPlugin.php | 10 +++++----- tests/phpunit/tests/admin/includesSchema.php | 6 +++--- tests/phpunit/tests/admin/includesScreen.php | 2 +- tests/phpunit/tests/admin/includesTemplate.php | 8 ++++---- .../plugin-dependencies/getDependencyFilepath.php | 2 +- .../admin/plugin-dependencies/getDependentFilepath.php | 2 +- .../plugin-dependencies/hasCircularDependency.php | 2 +- .../tests/admin/plugin-dependencies/initialize.php | 6 +++--- tests/phpunit/tests/admin/wpAutomaticUpdater.php | 6 +++--- tests/phpunit/tests/admin/wpCommentsListTable.php | 2 +- tests/phpunit/tests/admin/wpCommunityEvents.php | 2 +- tests/phpunit/tests/admin/wpListTable.php | 8 ++++---- tests/phpunit/tests/admin/wpMediaListTable.php | 4 ++-- tests/phpunit/tests/admin/wpPluginsListTable.php | 2 +- tests/phpunit/tests/admin/wpPostsListTable.php | 4 ++-- tests/phpunit/tests/admin/wpPrivacyRequestsTable.php | 2 +- tests/phpunit/tests/admin/wpSiteHealth.php | 6 +++--- tests/phpunit/tests/admin/wpUpgrader.php | 8 ++++---- tests/phpunit/tests/admin/wpUpgraderSkin.php | 4 ++-- 33 files changed, 62 insertions(+), 62 deletions(-) diff --git a/tests/phpunit/tests/admin/exportWp.php b/tests/phpunit/tests/admin/exportWp.php index 6390f66f230dc..7976aa5878df5 100644 --- a/tests/phpunit/tests/admin/exportWp.php +++ b/tests/phpunit/tests/admin/exportWp.php @@ -136,7 +136,7 @@ public function test_should_include_attachments( array $args, array $expected ) * * @return array */ - public function data_should_include_attachments() { + public static function data_should_include_attachments() { return array( 'for all content' => array( 'args' => array( diff --git a/tests/phpunit/tests/admin/includes/comment/EditComment_Test.php b/tests/phpunit/tests/admin/includes/comment/EditComment_Test.php index 3afe61cee0634..4fde09524389c 100644 --- a/tests/phpunit/tests/admin/includes/comment/EditComment_Test.php +++ b/tests/phpunit/tests/admin/includes/comment/EditComment_Test.php @@ -415,7 +415,7 @@ public function test_should_reject_spam_or_trashed_parent( $comment_approved ) { * * @return array[] */ - public function data_should_reject_spam_or_trashed_parent() { + public static function data_should_reject_spam_or_trashed_parent() { return array( 'a spam parent' => array( 'spam' ), 'a trashed parent' => array( 'trash' ), diff --git a/tests/phpunit/tests/admin/includes/misc/CustomizerMobileViewportMeta_Test.php b/tests/phpunit/tests/admin/includes/misc/CustomizerMobileViewportMeta_Test.php index fd29f47220568..887b7b2504199 100644 --- a/tests/phpunit/tests/admin/includes/misc/CustomizerMobileViewportMeta_Test.php +++ b/tests/phpunit/tests/admin/includes/misc/CustomizerMobileViewportMeta_Test.php @@ -29,7 +29,7 @@ public function test_customizer_mobile_viewport_meta( $viewport_meta, $expected * expected: string, * }> */ - public function data_customizer_mobile_viewport_meta(): array { + public static function data_customizer_mobile_viewport_meta(): array { return array( 'default' => array( 'viewport_meta' => 'width=device-width,initial-scale=1.0', diff --git a/tests/phpunit/tests/admin/includes/misc/WpAdminCanonicalUrl_Test.php b/tests/phpunit/tests/admin/includes/misc/WpAdminCanonicalUrl_Test.php index bf51c161e85c1..dbecc0573a132 100644 --- a/tests/phpunit/tests/admin/includes/misc/WpAdminCanonicalUrl_Test.php +++ b/tests/phpunit/tests/admin/includes/misc/WpAdminCanonicalUrl_Test.php @@ -57,7 +57,7 @@ public function test_wp_admin_canonical_url( array $server_vars, $expected ) { * expected: string * }> */ - public function data_wp_admin_canonical_url(): array { + public static function data_wp_admin_canonical_url(): array { return array( 'no removable query args' => array( 'server_vars' => array( diff --git a/tests/phpunit/tests/admin/includes/misc/WpAdminViewportMeta_Test.php b/tests/phpunit/tests/admin/includes/misc/WpAdminViewportMeta_Test.php index 4323afb3ece45..1fc831c80ca07 100644 --- a/tests/phpunit/tests/admin/includes/misc/WpAdminViewportMeta_Test.php +++ b/tests/phpunit/tests/admin/includes/misc/WpAdminViewportMeta_Test.php @@ -39,7 +39,7 @@ function () use ( $filter_value ) { * expected: string, * }> */ - public function data_wp_admin_viewport_meta(): array { + public static function data_wp_admin_viewport_meta(): array { return array( 'default value' => array( 'filter_value' => null, diff --git a/tests/phpunit/tests/admin/includes/misc/WpDocLinkParse_Test.php b/tests/phpunit/tests/admin/includes/misc/WpDocLinkParse_Test.php index 298cd3d77cbac..0d86b046bf857 100644 --- a/tests/phpunit/tests/admin/includes/misc/WpDocLinkParse_Test.php +++ b/tests/phpunit/tests/admin/includes/misc/WpDocLinkParse_Test.php @@ -28,7 +28,7 @@ public function test_wp_doc_link_parse( $content, $expected ) { * expected: string[], * }> */ - public function data_wp_doc_link_parse(): array { + public static function data_wp_doc_link_parse(): array { return array( 'empty string' => array( 'content' => '', diff --git a/tests/phpunit/tests/admin/includes/misc/WpHeartbeatSetSuspension_Test.php b/tests/phpunit/tests/admin/includes/misc/WpHeartbeatSetSuspension_Test.php index e799efda53353..3833f6daf1a03 100644 --- a/tests/phpunit/tests/admin/includes/misc/WpHeartbeatSetSuspension_Test.php +++ b/tests/phpunit/tests/admin/includes/misc/WpHeartbeatSetSuspension_Test.php @@ -59,7 +59,7 @@ public function test_wp_heartbeat_set_suspension( $pagenow_value, $expected ) { * expected: string, * }> */ - public function data_wp_heartbeat_set_suspension(): array { + public static function data_wp_heartbeat_set_suspension(): array { return array( 'post.php' => array( 'pagenow_value' => 'post.php', diff --git a/tests/phpunit/tests/admin/includes/misc/WpMakeThemeFileTree_Test.php b/tests/phpunit/tests/admin/includes/misc/WpMakeThemeFileTree_Test.php index 151cb9e8bdc85..407c723dd07ad 100644 --- a/tests/phpunit/tests/admin/includes/misc/WpMakeThemeFileTree_Test.php +++ b/tests/phpunit/tests/admin/includes/misc/WpMakeThemeFileTree_Test.php @@ -28,7 +28,7 @@ public function test_wp_make_theme_file_tree( $allowed_files, $expected ) { * expected: array, * }> */ - public function data_wp_make_theme_file_tree(): array { + public static function data_wp_make_theme_file_tree(): array { return array( 'empty list' => array( 'allowed_files' => array(), diff --git a/tests/phpunit/tests/admin/includes/misc/WpPrivacySettingsFilterDraftPageTitles_Test.php b/tests/phpunit/tests/admin/includes/misc/WpPrivacySettingsFilterDraftPageTitles_Test.php index 9726833d667f5..fe6232e525b20 100644 --- a/tests/phpunit/tests/admin/includes/misc/WpPrivacySettingsFilterDraftPageTitles_Test.php +++ b/tests/phpunit/tests/admin/includes/misc/WpPrivacySettingsFilterDraftPageTitles_Test.php @@ -40,7 +40,7 @@ public function test_wp_privacy_settings_filter_draft_page_titles( $expected, $t * screen_id: string, * }> */ - public function data_wp_privacy_settings_filter_draft_page_titles(): array { + public static function data_wp_privacy_settings_filter_draft_page_titles(): array { return array( 'draft page on privacy screen' => array( 'expected' => 'Privacy Policy (Draft)', diff --git a/tests/phpunit/tests/admin/includes/plugin-install/WpGetPluginActionButton_Test.php b/tests/phpunit/tests/admin/includes/plugin-install/WpGetPluginActionButton_Test.php index ce358850dd2d0..54d9c55a629f7 100644 --- a/tests/phpunit/tests/admin/includes/plugin-install/WpGetPluginActionButton_Test.php +++ b/tests/phpunit/tests/admin/includes/plugin-install/WpGetPluginActionButton_Test.php @@ -123,7 +123,7 @@ public function test_should_not_return_empty_string_with_proper_capabilities_sin * * @return array[] */ - public function data_capabilities() { + public static function data_capabilities() { return self::text_array_to_dataprovider( array( 'install_plugins', 'update_plugins' ) ); } diff --git a/tests/phpunit/tests/admin/includes/user/WpIsAuthorizeApplicationPasswordRequestValid_Test.php b/tests/phpunit/tests/admin/includes/user/WpIsAuthorizeApplicationPasswordRequestValid_Test.php index a2e1320b2a150..31325411ddd4b 100644 --- a/tests/phpunit/tests/admin/includes/user/WpIsAuthorizeApplicationPasswordRequestValid_Test.php +++ b/tests/phpunit/tests/admin/includes/user/WpIsAuthorizeApplicationPasswordRequestValid_Test.php @@ -35,7 +35,7 @@ public function test_is_authorize_application_password_request_valid( $request, } } - public function data_is_authorize_application_password_request_valid() { + public static function data_is_authorize_application_password_request_valid() { $environment_types = array( 'local', 'development', 'staging', 'production' ); $datasets = array(); diff --git a/tests/phpunit/tests/admin/includes/user/WpIsAuthorizeApplicationRedirectUrlValid_Test.php b/tests/phpunit/tests/admin/includes/user/WpIsAuthorizeApplicationRedirectUrlValid_Test.php index 3ba7b9045ac28..bcb84bc4df593 100644 --- a/tests/phpunit/tests/admin/includes/user/WpIsAuthorizeApplicationRedirectUrlValid_Test.php +++ b/tests/phpunit/tests/admin/includes/user/WpIsAuthorizeApplicationRedirectUrlValid_Test.php @@ -39,7 +39,7 @@ public function test_wp_is_authorize_application_redirect_url_valid( $url, $expe * * @return array[] */ - public function data_wp_is_authorize_application_redirect_url_valid() { + public static function data_wp_is_authorize_application_redirect_url_valid() { $environment_types = array( 'local', 'development', 'staging', 'production' ); $datasets = array(); diff --git a/tests/phpunit/tests/admin/includesFile.php b/tests/phpunit/tests/admin/includesFile.php index 6eddd1d6c529e..29e41d4867de4 100644 --- a/tests/phpunit/tests/admin/includesFile.php +++ b/tests/phpunit/tests/admin/includesFile.php @@ -110,7 +110,7 @@ public function test_download_url_should_respect_filename_from_content_dispositi * * @return array */ - public function data_download_url_should_respect_filename_from_content_disposition_header() { + public static function data_download_url_should_respect_filename_from_content_disposition_header() { return array( 'valid parameters' => array( 'filter_content_disposition_header_with_filename' ), 'path traversal' => array( 'filter_content_disposition_header_with_filename_with_path_traversal' ), @@ -143,7 +143,7 @@ public function test_save_to_temp_directory_when_getting_filename_from_content_d * * @return array */ - public function data_save_to_temp_directory_when_getting_filename_from_content_disposition_header() { + public static function data_save_to_temp_directory_when_getting_filename_from_content_disposition_header() { return array( 'valid parameters' => array( 'filter_content_disposition_header_with_filename' ), ); @@ -228,7 +228,7 @@ public function test_download_url_should_reject_filename_from_invalid_content_di * * @return array */ - public function data_download_url_should_reject_filename_from_invalid_content_disposition_header() { + public static function data_download_url_should_reject_filename_from_invalid_content_disposition_header() { return array( 'no context' => array( 'filter_content_disposition_header_with_filename_without_context' ), 'inline context' => array( 'filter_content_disposition_header_with_filename_with_inline_context' ), @@ -310,7 +310,7 @@ public function test_download_url_empty_url( $url ) { * * @return array */ - public function data_download_url_empty_url() { + public static function data_download_url_empty_url() { return array( 'null' => array( null ), 'false' => array( false ), @@ -420,7 +420,7 @@ public function test_download_url_should_use_the_content_type_header_to_set_exte * * @return Generator */ - public function data_download_url_should_use_the_content_type_header_to_set_extension_of_a_file_if_extension_was_not_determined() { + public static function data_download_url_should_use_the_content_type_header_to_set_extension_of_a_file_if_extension_was_not_determined() { yield 'Content-Type header in the response' => array( function () { return array( diff --git a/tests/phpunit/tests/admin/includesMedia.php b/tests/phpunit/tests/admin/includesMedia.php index 2debdc226ad35..073c6ac1b04dd 100644 --- a/tests/phpunit/tests/admin/includesMedia.php +++ b/tests/phpunit/tests/admin/includesMedia.php @@ -70,7 +70,7 @@ public function test_attachment_submitbox_metadata_filesize( $filesize, ?int $ex * * @return array|null }> */ - public function data_attachment_submitbox_metadata_filesize(): array { + public static function data_attachment_submitbox_metadata_filesize(): array { return array( 'an integer' => array( 'filesize' => 12345, @@ -167,7 +167,7 @@ public function test_attachment_submitbox_metadata_filesize_falls_back_to_the_fi * * @return array */ - public function data_attachment_submitbox_metadata_filesize_falls_back_to_the_file(): array { + public static function data_attachment_submitbox_metadata_filesize_falls_back_to_the_file(): array { return array( 'a value smaller than a byte' => array( 'filesize' => 0.5 ), 'zero' => array( 'filesize' => 0 ), diff --git a/tests/phpunit/tests/admin/includesPlugin.php b/tests/phpunit/tests/admin/includesPlugin.php index 813ba3429c204..6eff4098a0b22 100644 --- a/tests/phpunit/tests/admin/includesPlugin.php +++ b/tests/phpunit/tests/admin/includesPlugin.php @@ -222,7 +222,7 @@ public function test_submenu_position( $position, $expected_position ) { // Setup a menu with some items. $parent = add_menu_page( 'Test Toplevel', 'Test Toplevel', 'manage_options', 'mt-top-level-handle', 'mt_toplevel_page' ); - foreach ( $this->submenus_to_add() as $menu_to_add ) { + foreach ( self::submenus_to_add() as $menu_to_add ) { add_submenu_page( $parent, $menu_to_add[0], $menu_to_add[1], $menu_to_add[2], $menu_to_add[3], $menu_to_add[4] ); } @@ -326,7 +326,7 @@ public function test_submenu_helpers_position( $position, $expected_position ) { foreach ( $helper_functions as $helper_function ) { // Build up demo pages on the menu root. - foreach ( $this->submenus_to_add() as $menu_to_add ) { + foreach ( self::submenus_to_add() as $menu_to_add ) { add_menu_page( $menu_to_add[0], $menu_to_add[1], $menu_to_add[2], $helper_function['menu_root'], $helper_function['menu_root'] ); } @@ -362,7 +362,7 @@ public function test_submenu_helpers_position( $position, $expected_position ) { * } * } */ - private function submenus_to_add() { + private static function submenus_to_add() { return array( array( 'Submenu Position', 'Submenu Position', 'manage_options', 'sub-page', '' ), array( 'Submenu Position 2', 'Submenu Position 2', 'manage_options', 'sub-page2', '' ), @@ -384,8 +384,8 @@ private function submenus_to_add() { * } * } */ - public function data_submenu_position() { - $menu_count = count( $this->submenus_to_add() ); + public static function data_submenu_position() { + $menu_count = count( self::submenus_to_add() ); return array( array( null, $menu_count ), // Insert at the end of the menu if null is passed. Default behavior. array( 0, 0 ), // Insert at the beginning of the menu if 0 is passed. diff --git a/tests/phpunit/tests/admin/includesSchema.php b/tests/phpunit/tests/admin/includesSchema.php index cb8cd90abf04c..f6c96169659a5 100644 --- a/tests/phpunit/tests/admin/includesSchema.php +++ b/tests/phpunit/tests/admin/includesSchema.php @@ -141,7 +141,7 @@ public function test_populate_options( $options, $expected ) { $this->assertSame( $expected, $results ); } - public function data_populate_options() { + public static function data_populate_options() { return array( array( array(), @@ -275,7 +275,7 @@ public function test_populate_site_meta( $meta, $expected ) { $this->assertSame( $expected, $results ); } - public function data_populate_site_meta() { + public static function data_populate_site_meta() { return array( array( array(), @@ -323,7 +323,7 @@ public function test_populate_network_meta( $meta, $expected ) { $this->assertSame( $expected, $results ); } - public function data_populate_network_meta() { + public static function data_populate_network_meta() { return array( array( array(), diff --git a/tests/phpunit/tests/admin/includesScreen.php b/tests/phpunit/tests/admin/includesScreen.php index 0c6ce7cbd4dea..ae1ad0755a26e 100644 --- a/tests/phpunit/tests/admin/includesScreen.php +++ b/tests/phpunit/tests/admin/includesScreen.php @@ -639,7 +639,7 @@ public function setup_block_editor_test( $hook = 'post.php' ) { /** * Data provider for testing is_block_editor. */ - public function data_is_block_editor() { + public static function data_is_block_editor() { return array( array( // Edit post: Post type supports `show_in_rest`, no filters. diff --git a/tests/phpunit/tests/admin/includesTemplate.php b/tests/phpunit/tests/admin/includesTemplate.php index fd65828a55e1b..6e8c9461c7e61 100644 --- a/tests/phpunit/tests/admin/includesTemplate.php +++ b/tests/phpunit/tests/admin/includesTemplate.php @@ -46,7 +46,7 @@ public function test_wp_terms_checklist_with_popular_cats( $term_id ) { $this->assertStringContainsString( 'class="popular-category"', $output ); } - public function data_wp_terms_checklist_with_selected_cats() { + public static function data_wp_terms_checklist_with_selected_cats() { return array( array( '1' ), array( 1 ), @@ -279,7 +279,7 @@ public function test_add_settings_section_without_any_fields( $extra_args, $expe * * @return array */ - public function data_extra_args_for_add_settings_section() { + public static function data_extra_args_for_add_settings_section() { return array( 'class placeholder section_class present' => array( array( @@ -446,7 +446,7 @@ public function test_settings_errors_css_classes( $type, $expected ) { $this->assertStringNotContainsString( 'notice-notice-', $output ); } - public function data_settings_errors_css_classes() { + public static function data_settings_errors_css_classes() { return array( // The admin notices default types will generate CSS classes in this order. array( 'error', 'notice notice-error is-dismissible settings-error' ), @@ -542,7 +542,7 @@ public function test_get_submit_button_expands_type_shorthands( $type, $expected * * @return array[] */ - public function data_get_submit_button_shorthand() { + public static function data_get_submit_button_shorthand() { return array( 'primary shorthand' => array( 'primary', 'button button-primary' ), 'small shorthand' => array( 'small', 'button button-small' ), diff --git a/tests/phpunit/tests/admin/plugin-dependencies/getDependencyFilepath.php b/tests/phpunit/tests/admin/plugin-dependencies/getDependencyFilepath.php index 04b4948e63f72..68b0fb2801ca1 100644 --- a/tests/phpunit/tests/admin/plugin-dependencies/getDependencyFilepath.php +++ b/tests/phpunit/tests/admin/plugin-dependencies/getDependencyFilepath.php @@ -69,7 +69,7 @@ public function test_should_return_filepaths_for_installed_dependencies( $depend * * @return array[] */ - public function data_get_dependency_filepath() { + public static function data_get_dependency_filepath() { return array( 'no plugins' => array( 'dependency_slug' => 'dependency', diff --git a/tests/phpunit/tests/admin/plugin-dependencies/getDependentFilepath.php b/tests/phpunit/tests/admin/plugin-dependencies/getDependentFilepath.php index 1cfdb30b137bf..fb82323847d64 100644 --- a/tests/phpunit/tests/admin/plugin-dependencies/getDependentFilepath.php +++ b/tests/phpunit/tests/admin/plugin-dependencies/getDependentFilepath.php @@ -43,7 +43,7 @@ public function test_should_return_filepaths_for_installed_dependents( $dependen * * @return array[] */ - public function data_get_dependent_filepath() { + public static function data_get_dependent_filepath() { return array( 'a plugin that exists' => array( 'dependent_slug' => 'dependent', diff --git a/tests/phpunit/tests/admin/plugin-dependencies/hasCircularDependency.php b/tests/phpunit/tests/admin/plugin-dependencies/hasCircularDependency.php index 10d00d96b7637..a43a4f5025853 100644 --- a/tests/phpunit/tests/admin/plugin-dependencies/hasCircularDependency.php +++ b/tests/phpunit/tests/admin/plugin-dependencies/hasCircularDependency.php @@ -77,7 +77,7 @@ public function test_should_return_true_when_a_plugin_has_circular_dependency( $ * * @return array[] */ - public function data_circular_dependencies() { + public static function data_circular_dependencies() { return array( 'a plugin that depends on itself' => array( 'plugin_to_check' => 'dependency/dependency.php', diff --git a/tests/phpunit/tests/admin/plugin-dependencies/initialize.php b/tests/phpunit/tests/admin/plugin-dependencies/initialize.php index 375e30c4bd6e2..58e3392dcd8b0 100644 --- a/tests/phpunit/tests/admin/plugin-dependencies/initialize.php +++ b/tests/phpunit/tests/admin/plugin-dependencies/initialize.php @@ -62,7 +62,7 @@ public function test_should_only_initialize_once( $property_name ) { * * @return array[] */ - public function data_static_properties_set_during_initialization() { + public static function data_static_properties_set_during_initialization() { /* * This does not include 'dependency_api_data' as it is only set * on certain pages. This is tested later. @@ -117,7 +117,7 @@ public function test_should_set_dependency_api_data_on_certain_screens( $screen * * @return array[] */ - public function data_screens() { + public static function data_screens() { return array( 'plugins.php' => array( 'screen' => 'plugins.php', @@ -167,7 +167,7 @@ public function test_initialize_should_load_and_sanitize_dependency_slugs_from_p * * @return array[] */ - public function data_should_sanitize_slugs() { + public static function data_should_sanitize_slugs() { return array( // Valid slugs. 'one dependency' => array( diff --git a/tests/phpunit/tests/admin/wpAutomaticUpdater.php b/tests/phpunit/tests/admin/wpAutomaticUpdater.php index 2aca85616cb5f..213c0c381edc3 100644 --- a/tests/phpunit/tests/admin/wpAutomaticUpdater.php +++ b/tests/phpunit/tests/admin/wpAutomaticUpdater.php @@ -112,7 +112,7 @@ function ( $args ) use ( $urls ) { * * @return array */ - public function data_send_plugin_theme_email_should_append_plugin_urls() { + public static function data_send_plugin_theme_email_should_append_plugin_urls() { return array( 'successful updates, the current version and the plugin url' => array( 'urls' => array( 'http://example.org/successful-plugin' ), @@ -380,7 +380,7 @@ function ( $args ) use ( $urls ) { * * @return array */ - public function data_send_plugin_theme_email_should_not_append_plugin_urls() { + public static function data_send_plugin_theme_email_should_not_append_plugin_urls() { return array( 'successful updates, the current version, but no plugin url' => array( 'urls' => array( 'http://example.org/successful-plugin' ), @@ -704,7 +704,7 @@ public function test_is_allowed_dir_should_throw_doing_it_wrong_with_invalid_dir * * @return array[] */ - public function data_is_allowed_dir_should_throw_doing_it_wrong_with_invalid_dir() { + public static function data_is_allowed_dir_should_throw_doing_it_wrong_with_invalid_dir() { return array( // Type checks and boolean comparisons. 'null' => array( 'dir' => null ), diff --git a/tests/phpunit/tests/admin/wpCommentsListTable.php b/tests/phpunit/tests/admin/wpCommentsListTable.php index 47b9bec57f140..dee76c3bdaeb1 100644 --- a/tests/phpunit/tests/admin/wpCommentsListTable.php +++ b/tests/phpunit/tests/admin/wpCommentsListTable.php @@ -269,7 +269,7 @@ public function test_comments_list_table_does_not_show_note_comment_type( string * * @return array */ - public function data_comment_type(): array { + public static function data_comment_type(): array { return array( 'note type explicitly requested' => array( 'note' ), 'all type requested' => array( 'all' ), diff --git a/tests/phpunit/tests/admin/wpCommunityEvents.php b/tests/phpunit/tests/admin/wpCommunityEvents.php index fd44a86e272a4..a38351b5fbece 100644 --- a/tests/phpunit/tests/admin/wpCommunityEvents.php +++ b/tests/phpunit/tests/admin/wpCommunityEvents.php @@ -573,7 +573,7 @@ public function test_get_unsafe_client_ip( $raw_ip, $expected_result ) { * * @return array */ - public function data_get_unsafe_client_ip() { + public static function data_get_unsafe_client_ip() { return array( // Handle '::' returned from `wp_privacy_anonymize_ip()`. array( diff --git a/tests/phpunit/tests/admin/wpListTable.php b/tests/phpunit/tests/admin/wpListTable.php index ee6cca5cf53de..909b232a2020c 100644 --- a/tests/phpunit/tests/admin/wpListTable.php +++ b/tests/phpunit/tests/admin/wpListTable.php @@ -98,7 +98,7 @@ public function test_should_only_add_primary_column_when_needed( $list_class, $h * * @return array */ - public function data_should_only_add_primary_column_when_needed() { + public static function data_should_only_add_primary_column_when_needed() { /* * `WP_Post_Comments_List_Table` overrides `get_column_info()` rather than * use the default `WP_List_Table::get_column_info()`. Therefore it is @@ -187,7 +187,7 @@ public function test_get_views_links( $link_data, $expected ) { * * @return array */ - public function data_get_views_links() { + public static function data_get_views_links() { return array( 'one "current" link' => array( 'link_data' => array( @@ -301,7 +301,7 @@ public function test_get_views_links_doing_it_wrong( $link_data ) { * * @return array */ - public function data_get_views_links_doing_it_wrong() { + public static function data_get_views_links_doing_it_wrong() { return array( 'non-array $link_data' => array( 'link_data' => 'https://example.org, All, class="current" aria-current="page"', @@ -509,7 +509,7 @@ public function test_should_throw_deprecation_when_unset_of_dynamic_property() { * * @return array */ - public function data_compat_fields() { + public static function data_compat_fields() { return array( '_args' => array( 'property_name' => '_args', diff --git a/tests/phpunit/tests/admin/wpMediaListTable.php b/tests/phpunit/tests/admin/wpMediaListTable.php index 31d2bfa7cbb9d..05dea63c8fbc2 100644 --- a/tests/phpunit/tests/admin/wpMediaListTable.php +++ b/tests/phpunit/tests/admin/wpMediaListTable.php @@ -206,7 +206,7 @@ public function test_get_row_actions_should_include_action( $action, $role, $tra * * @return array[] */ - public function data_get_row_actions_should_include_action() { + public static function data_get_row_actions_should_include_action() { return array( '"edit" while not on "trash"' => array( 'action' => 'edit', @@ -291,7 +291,7 @@ public function test_get_row_actions_should_not_include_action( $action, $role, * * @return array[] */ - public function data_get_row_actions_should_not_include_action() { + public static function data_get_row_actions_should_not_include_action() { return array( '"edit" while on "trash"' => array( 'action' => 'edit', diff --git a/tests/phpunit/tests/admin/wpPluginsListTable.php b/tests/phpunit/tests/admin/wpPluginsListTable.php index daa54750fdf9e..12af1d606f4e8 100644 --- a/tests/phpunit/tests/admin/wpPluginsListTable.php +++ b/tests/phpunit/tests/admin/wpPluginsListTable.php @@ -291,7 +291,7 @@ public function test_single_row_should_not_add_the_autoupdates_column_for_mustus * * @return array[] */ - public function data_status_mustuse_and_dropins() { + public static function data_status_mustuse_and_dropins() { return array( 'Must-Use' => array( 'mustuse' ), 'Drop-ins' => array( 'dropins' ), diff --git a/tests/phpunit/tests/admin/wpPostsListTable.php b/tests/phpunit/tests/admin/wpPostsListTable.php index eb00894bc4b2c..50fd032c86265 100644 --- a/tests/phpunit/tests/admin/wpPostsListTable.php +++ b/tests/phpunit/tests/admin/wpPostsListTable.php @@ -524,7 +524,7 @@ public function test_column_date_should_show_scheduled_post_status( $offset, $ex /** * @return array[] */ - public function data_scheduled_post_date_column_status() { + public static function data_scheduled_post_date_column_status() { return array( 'future date' => array( DAY_IN_SECONDS, 'Scheduled' ), 'past due date' => array( -DAY_IN_SECONDS, 'Missed schedule' ), @@ -591,7 +591,7 @@ public function test_no_title_excerpt_visibility( $mode_value, $post_args, $shou * * @return array[] */ - public function data_no_title_excerpt_visibility() { + public static function data_no_title_excerpt_visibility() { return array( 'compact view, untitled' => array( 'list', array(), true ), 'extended view, untitled' => array( 'excerpt', array(), false ), diff --git a/tests/phpunit/tests/admin/wpPrivacyRequestsTable.php b/tests/phpunit/tests/admin/wpPrivacyRequestsTable.php index 66e3e02501cfb..2ea649bc74cb8 100644 --- a/tests/phpunit/tests/admin/wpPrivacyRequestsTable.php +++ b/tests/phpunit/tests/admin/wpPrivacyRequestsTable.php @@ -129,7 +129,7 @@ public function filter_posts_request( $request ) { * } * } */ - public function data_columns_should_be_sortable() { + public static function data_columns_should_be_sortable() { return array( // Default order (ID) DESC. array( diff --git a/tests/phpunit/tests/admin/wpSiteHealth.php b/tests/phpunit/tests/admin/wpSiteHealth.php index 6080b477f54c3..2ad2052369ba1 100644 --- a/tests/phpunit/tests/admin/wpSiteHealth.php +++ b/tests/phpunit/tests/admin/wpSiteHealth.php @@ -126,7 +126,7 @@ public function test_cron_health_checks( $times, $expected_status, $expected_lab * 4. bool Expected outcome has_late_cron() * 5. bool Expected outcome has_missed_cron() */ - public function data_cron_health_checks() { + public static function data_cron_health_checks() { return array( array( '+5 minutes', @@ -269,7 +269,7 @@ function ( $response, $parsed_args ) use ( &$responses, &$is_unauthorized, $has_ * delay_the_response?: bool, * }> */ - public function data_get_page_cache(): array { + public static function data_get_page_cache(): array { $recommended_label = 'Page cache is not detected but the server response time is OK'; $good_label = 'Page cache is detected and the server response time is good'; $critical_label = 'Page cache is not detected and the server response time is slow'; @@ -561,7 +561,7 @@ static function ( $thresholds ) use ( $threshold, $count ) { * * @ticket 56040 */ - public function data_object_cache_thresholds() { + public static function data_object_cache_thresholds() { return array( array( 'comments_count', 0 ), array( 'posts_count', 0 ), diff --git a/tests/phpunit/tests/admin/wpUpgrader.php b/tests/phpunit/tests/admin/wpUpgrader.php index 59930164a238a..78744f774d35b 100644 --- a/tests/phpunit/tests/admin/wpUpgrader.php +++ b/tests/phpunit/tests/admin/wpUpgrader.php @@ -126,7 +126,7 @@ public function test_init_should_initialize_strings( $key ) { * * @return array[] */ - public function data_init_should_initialize_strings() { + public static function data_init_should_initialize_strings() { return self::text_array_to_dataprovider( array( 'bad_request', @@ -186,7 +186,7 @@ public function test_flatten_dirlist_should_flatten_the_provided_directory_list( * * @return array[] */ - public function data_should_flatten_dirlist() { + public static function data_should_flatten_dirlist() { return array( 'empty array, default path' => array( 'expected' => array(), @@ -780,7 +780,7 @@ public function test_install_package_should_return_wp_error_with_invalid_destina * * @return array[] */ - public function data_install_package_invalid_paths() { + public static function data_install_package_invalid_paths() { return array( 'empty string' => array( 'path' => '' ), @@ -1272,7 +1272,7 @@ function ( $removed, $local_destination, $remote_destination ) use ( $expected ) * * @return array[] */ - public function data_install_package_should_make_remote_destination_safe_when_set_to_a_protected_directory() { + public static function data_install_package_should_make_remote_destination_safe_when_set_to_a_protected_directory() { return array( 'ABSPATH' => array( 'protected_directory' => ABSPATH, diff --git a/tests/phpunit/tests/admin/wpUpgraderSkin.php b/tests/phpunit/tests/admin/wpUpgraderSkin.php index 945cd8b8742fd..a4746e78a7375 100644 --- a/tests/phpunit/tests/admin/wpUpgraderSkin.php +++ b/tests/phpunit/tests/admin/wpUpgraderSkin.php @@ -58,7 +58,7 @@ public function test_decrement_update_count_should_print_nothing_without_a_usabl * * @return array */ - public function data_results_that_should_print_nothing(): array { + public static function data_results_that_should_print_nothing(): array { return array( 'a false result' => array( 'result' => false ), 'a WP_Error result' => array( 'result' => new WP_Error( 'test_error' ) ), @@ -113,7 +113,7 @@ static function ( array $attributes ) use ( $nonce ): array { * * @return array */ - public function data_update_types(): array { + public static function data_update_types(): array { return array( 'a plugin type' => array( 'type' => 'plugin' ), 'a theme type' => array( 'type' => 'theme' ), From 1e7d5ea9ffe8c2138ded11c81f6c2bdab37a2996 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 19:01:38 +0000 Subject: [PATCH 007/236] Tests: Make bookmark test data providers static. Declare the data providers in `tests/phpunit/tests/bookmark/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions. Developed in: https://github.com/WordPress/wordpress-develop/pull/14391 Props rejaulalomkhan. See #66211. git-svn-id: https://develop.svn.wordpress.org/trunk@64442 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/bookmark/getBookmark.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/tests/bookmark/getBookmark.php b/tests/phpunit/tests/bookmark/getBookmark.php index 50e59bddf5c8e..e541eaef03eea 100644 --- a/tests/phpunit/tests/bookmark/getBookmark.php +++ b/tests/phpunit/tests/bookmark/getBookmark.php @@ -75,7 +75,7 @@ public function test_should_return_null( $args ) { /** * Path 1 data provider, i.e. when given empty bookmark. */ - public function data_when_empty_bookmark() { + public static function data_when_empty_bookmark() { return array( // Unhappy path. 'with bookmark type mismatch' => array( @@ -151,7 +151,7 @@ public function test_should_cache_bookmark_when_given_instance( $args ) { /** * Path 2 data provider, i.e. when bookmark instance is given. */ - public function data_when_instance_bookmark() { + public static function data_when_instance_bookmark() { return array( // Unhappy path. 'with incomplete bookmark data' => array( @@ -312,7 +312,7 @@ public function test_should_return_existing_bookmark_from_database( $args ) { * Path 3's data provider which covers the "else" branch, i.e. when the bookmark argument is not empty and * not an object. */ - public function data_when_else() { + public static function data_when_else() { return array( // Unhappy path. 'with invalid output' => array( From 05d314ae619b9787cca947dfe903341f967087be Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 19:02:48 +0000 Subject: [PATCH 008/236] Tests: Make sitemap test data providers static. Declare the data providers in `tests/phpunit/tests/sitemaps/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions. Developed in: https://github.com/WordPress/wordpress-develop/pull/14392 Props rejaulalomkhan. See #66211. git-svn-id: https://develop.svn.wordpress.org/trunk@64443 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/sitemaps/functions.php | 4 ++-- tests/phpunit/tests/sitemaps/sitemaps.php | 2 +- tests/phpunit/tests/sitemaps/wpSitemapsRegistry.php | 4 ++-- tests/phpunit/tests/sitemaps/wpSitemapsRenderer.php | 2 +- tests/phpunit/tests/sitemaps/wpSitemapsStylesheet.php | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/tests/sitemaps/functions.php b/tests/phpunit/tests/sitemaps/functions.php index 0620d465d4795..19dd831e90a4b 100644 --- a/tests/phpunit/tests/sitemaps/functions.php +++ b/tests/phpunit/tests/sitemaps/functions.php @@ -96,7 +96,7 @@ public function test_get_sitemap_url_pretty_permalinks( $name, $subtype_name, $p * @type string|false $4 Sitemap URL. * } */ - public function data_get_sitemap_url_plain_permalinks() { + public static function data_get_sitemap_url_plain_permalinks() { return array( array( 'posts', 'post', 1, home_url( '/?sitemap=posts&sitemap-subtype=post&paged=1' ) ), array( 'posts', 'post', 0, home_url( '/?sitemap=posts&sitemap-subtype=post&paged=1' ) ), @@ -128,7 +128,7 @@ public function data_get_sitemap_url_plain_permalinks() { * @type string|false $4 Sitemap URL. * } */ - public function data_get_sitemap_url_pretty_permalinks() { + public static function data_get_sitemap_url_pretty_permalinks() { return array( array( 'posts', 'post', 1, home_url( '/wp-sitemap-posts-post-1.xml' ) ), array( 'posts', 'post', 0, home_url( '/wp-sitemap-posts-post-1.xml' ) ), diff --git a/tests/phpunit/tests/sitemaps/sitemaps.php b/tests/phpunit/tests/sitemaps/sitemaps.php index a4062e887123c..521f278bb77fe 100644 --- a/tests/phpunit/tests/sitemaps/sitemaps.php +++ b/tests/phpunit/tests/sitemaps/sitemaps.php @@ -544,7 +544,7 @@ public function test_unusable_sitemap_query_var_should_return_404( string $query * * @return array */ - public function data_unusable_sitemap_query_vars(): array { + public static function data_unusable_sitemap_query_vars(): array { return array( 'value stripped by sanitizing' => array( '?sitemap=<>' ), 'array sitemap value' => array( '?sitemap[]=index' ), diff --git a/tests/phpunit/tests/sitemaps/wpSitemapsRegistry.php b/tests/phpunit/tests/sitemaps/wpSitemapsRegistry.php index 169288819b566..57d9975136709 100644 --- a/tests/phpunit/tests/sitemaps/wpSitemapsRegistry.php +++ b/tests/phpunit/tests/sitemaps/wpSitemapsRegistry.php @@ -54,7 +54,7 @@ public function test_get_provider_should_return_null_with_non_string_name( $name * * @return array */ - public function data_get_provider_should_return_null_with_non_string_name() { + public static function data_get_provider_should_return_null_with_non_string_name() { return array( 'array' => array( array() ), 'object' => array( new stdClass() ), @@ -121,7 +121,7 @@ static function () use ( $invalid_provider ) { * * @return array */ - public function data_invalid_sitemap_providers() { + public static function data_invalid_sitemap_providers() { return array( 'null' => array( null ), 'false' => array( false ), diff --git a/tests/phpunit/tests/sitemaps/wpSitemapsRenderer.php b/tests/phpunit/tests/sitemaps/wpSitemapsRenderer.php index 31c3cb6bb7aef..e778c73ca9401 100644 --- a/tests/phpunit/tests/sitemaps/wpSitemapsRenderer.php +++ b/tests/phpunit/tests/sitemaps/wpSitemapsRenderer.php @@ -300,7 +300,7 @@ public function test_stylesheet_url_methods_are_deprecated(): void { * * @return array */ - public function data_deprecated_stylesheet_filters(): array { + public static function data_deprecated_stylesheet_filters(): array { return array( 'stylesheet URL' => array( 'hook_name' => 'wp_sitemaps_stylesheet_url', diff --git a/tests/phpunit/tests/sitemaps/wpSitemapsStylesheet.php b/tests/phpunit/tests/sitemaps/wpSitemapsStylesheet.php index 663180cce0aa9..9e341a097d003 100644 --- a/tests/phpunit/tests/sitemaps/wpSitemapsStylesheet.php +++ b/tests/phpunit/tests/sitemaps/wpSitemapsStylesheet.php @@ -29,7 +29,7 @@ public function test_deprecated_methods( string $method ): void { * * @return array */ - public function data_deprecated_methods(): array { + public static function data_deprecated_methods(): array { return array( 'sitemap stylesheet' => array( 'method' => 'get_sitemap_stylesheet' ), 'index stylesheet' => array( 'method' => 'get_sitemap_index_stylesheet' ), From b65c05703054d92119de75b0803164dec2d2b351 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 19:05:50 +0000 Subject: [PATCH 009/236] Tests: Make comment test data providers static. Declare the data providers in `tests/phpunit/tests/comment/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions. Developed in: https://github.com/WordPress/wordpress-develop/pull/14393 Props rejaulalomkhan. See #66211. git-svn-id: https://develop.svn.wordpress.org/trunk@64444 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/comment/checkComment.php | 2 +- tests/phpunit/tests/comment/commentTime.php | 2 +- tests/phpunit/tests/comment/commentsTemplate.php | 2 +- tests/phpunit/tests/comment/getCommentAuthor.php | 2 +- tests/phpunit/tests/comment/getCommentAuthorLink.php | 2 +- tests/phpunit/tests/comment/isAvatarCommentType.php | 2 +- tests/phpunit/tests/comment/query.php | 2 +- tests/phpunit/tests/comment/template.php | 2 +- tests/phpunit/tests/comment/wpAllowComment.php | 2 +- tests/phpunit/tests/comment/wpComment.php | 2 +- tests/phpunit/tests/comment/wpHandleCommentSubmission.php | 4 ++-- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/phpunit/tests/comment/checkComment.php b/tests/phpunit/tests/comment/checkComment.php index 56bd5737f7459..2f63f480f9f52 100644 --- a/tests/phpunit/tests/comment/checkComment.php +++ b/tests/phpunit/tests/comment/checkComment.php @@ -410,7 +410,7 @@ static function ( $approve, $source_id ) use ( &$observed ) { * * @return array[] */ - public function data_ping_types() { + public static function data_ping_types() { return array( 'pingback' => array( 'pingback' ), 'trackback' => array( 'trackback' ), diff --git a/tests/phpunit/tests/comment/commentTime.php b/tests/phpunit/tests/comment/commentTime.php index a155ec158c203..890f7a329ee4a 100644 --- a/tests/phpunit/tests/comment/commentTime.php +++ b/tests/phpunit/tests/comment/commentTime.php @@ -68,7 +68,7 @@ public function test_should_output_the_same_value_that_get_comment_time_returns( * * @return array[] */ - public function data_should_output_the_same_value_that_get_comment_time_returns() { + public static function data_should_output_the_same_value_that_get_comment_time_returns() { return array( 'an empty format' => array( 'format' => '', diff --git a/tests/phpunit/tests/comment/commentsTemplate.php b/tests/phpunit/tests/comment/commentsTemplate.php index 8ee623e8c828c..3c222cad725a6 100644 --- a/tests/phpunit/tests/comment/commentsTemplate.php +++ b/tests/phpunit/tests/comment/commentsTemplate.php @@ -1048,7 +1048,7 @@ static function ( $args ) use ( $top_level_query_args ) { $this->assertSame( $expected['offset'], $offset ); } - public function data_comments_template_top_level_query_args() { + public static function data_comments_template_top_level_query_args() { return array( array( array( diff --git a/tests/phpunit/tests/comment/getCommentAuthor.php b/tests/phpunit/tests/comment/getCommentAuthor.php index 61e8c213b54b9..0f963efb1f6b2 100644 --- a/tests/phpunit/tests/comment/getCommentAuthor.php +++ b/tests/phpunit/tests/comment/getCommentAuthor.php @@ -82,7 +82,7 @@ public function test_should_return_author_when_given_object_without_comment_id( * * @return array */ - public function data_should_return_author_when_given_object_without_comment_id() { + public static function data_should_return_author_when_given_object_without_comment_id() { return array( 'with no author' => array( 'comment_props' => new stdClass(), diff --git a/tests/phpunit/tests/comment/getCommentAuthorLink.php b/tests/phpunit/tests/comment/getCommentAuthorLink.php index c3d1033d837b5..759d0d954120b 100644 --- a/tests/phpunit/tests/comment/getCommentAuthorLink.php +++ b/tests/phpunit/tests/comment/getCommentAuthorLink.php @@ -83,7 +83,7 @@ public function test_should_return_author_when_given_object_without_comment_id( * * @return array */ - public function data_should_return_author_when_given_object_without_comment_id() { + public static function data_should_return_author_when_given_object_without_comment_id() { return array( 'with no author' => array( 'comment_props' => new stdClass(), diff --git a/tests/phpunit/tests/comment/isAvatarCommentType.php b/tests/phpunit/tests/comment/isAvatarCommentType.php index aa91a6d6fe806..6d243c1390ee5 100644 --- a/tests/phpunit/tests/comment/isAvatarCommentType.php +++ b/tests/phpunit/tests/comment/isAvatarCommentType.php @@ -34,7 +34,7 @@ public function test_function( $comment_type, $expected ) { * } * } */ - public function data_is_avatar_comment_type() { + public static function data_is_avatar_comment_type() { return array( array( null, false ), array( '', false ), diff --git a/tests/phpunit/tests/comment/query.php b/tests/phpunit/tests/comment/query.php index 0fc0ff33d10be..3218ffe675591 100644 --- a/tests/phpunit/tests/comment/query.php +++ b/tests/phpunit/tests/comment/query.php @@ -5507,7 +5507,7 @@ static function ( int $comment_id ): string { * * @return array, expected_types: string[] }> */ - public function data_note_type_exclusion(): array { + public static function data_note_type_exclusion(): array { return array( 'default query excludes note' => array( 'query_args' => array(), diff --git a/tests/phpunit/tests/comment/template.php b/tests/phpunit/tests/comment/template.php index 712f4f864a773..a110601c0a4bb 100644 --- a/tests/phpunit/tests/comment/template.php +++ b/tests/phpunit/tests/comment/template.php @@ -133,7 +133,7 @@ public function enable_comment_number_declension( $translation, $text, $context, * } * } */ - public function data_get_comments_number_text_declension() { + public static function data_get_comments_number_text_declension() { return array( array( 2, diff --git a/tests/phpunit/tests/comment/wpAllowComment.php b/tests/phpunit/tests/comment/wpAllowComment.php index 6a2a4cf8c1357..d2e077e46872d 100644 --- a/tests/phpunit/tests/comment/wpAllowComment.php +++ b/tests/phpunit/tests/comment/wpAllowComment.php @@ -108,7 +108,7 @@ public function test_should_approve_a_pingback_only_when_it_comes_from_this_site * * @return array[] */ - public function data_should_approve_a_pingback_only_when_it_comes_from_this_site() { + public static function data_should_approve_a_pingback_only_when_it_comes_from_this_site() { return array( 'a pingback from this site' => array( true, 1 ), 'a pingback from another site' => array( false, 0 ), diff --git a/tests/phpunit/tests/comment/wpComment.php b/tests/phpunit/tests/comment/wpComment.php index 44982205e15d2..5014431e5a4d2 100644 --- a/tests/phpunit/tests/comment/wpComment.php +++ b/tests/phpunit/tests/comment/wpComment.php @@ -115,7 +115,7 @@ public function test_get_instance_replaces_a_poisoned_cache_value( $cache_value * * @return array */ - public function data_get_instance_treats_a_poisoned_cache_value_as_a_cache_miss(): array { + public static function data_get_instance_treats_a_poisoned_cache_value_as_a_cache_miss(): array { return array( 'true' => array( true ), 'a non-numeric string' => array( 'not-a-comment' ), diff --git a/tests/phpunit/tests/comment/wpHandleCommentSubmission.php b/tests/phpunit/tests/comment/wpHandleCommentSubmission.php index 3f2ba84194a0d..8ee32de824ac5 100644 --- a/tests/phpunit/tests/comment/wpHandleCommentSubmission.php +++ b/tests/phpunit/tests/comment/wpHandleCommentSubmission.php @@ -901,7 +901,7 @@ public function test_should_only_allow_replying_to_an_approved_parent_comment( $ * * @return array[] */ - public function data_should_only_allow_replying_to_an_approved_parent_comment() { + public static function data_should_only_allow_replying_to_an_approved_parent_comment() { return array( 'an approved parent comment' => array( 'approved' => 1 ), 'an unapproved parent comment' => array( 'approved' => 0 ), @@ -963,7 +963,7 @@ public function test_should_only_allow_replying_to_an_existing_parent_comment( $ * * @return array[] */ - public function data_should_only_allow_replying_to_an_existing_parent_comment() { + public static function data_should_only_allow_replying_to_an_existing_parent_comment() { return array( 'an existing parent comment' => array( 'exists' => true ), 'a non-existent parent comment' => array( 'exists' => false ), From 6969ec3836bf388e43b73c63f17c8f4220f05750 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 19:07:00 +0000 Subject: [PATCH 010/236] Tests: Make term test data providers static. Declare the data providers in `tests/phpunit/tests/term/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions. Call the existing static `text_array_to_dataprovider()` helper with `self::`. Developed in: https://github.com/WordPress/wordpress-develop/pull/14395 Props rejaulalomkhan. See #66211. git-svn-id: https://develop.svn.wordpress.org/trunk@64445 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/term/getTermLink.php | 6 +++--- tests/phpunit/tests/term/getTerms.php | 2 +- .../tests/term/isTermPubliclyViewable.php | 2 +- tests/phpunit/tests/term/meta.php | 4 ++-- tests/phpunit/tests/term/query.php | 2 +- tests/phpunit/tests/term/sanitizeTerm.php | 2 +- tests/phpunit/tests/term/termCounts.php | 18 +++++++++--------- .../phpunit/tests/term/wpGenerateTagCloud.php | 2 +- tests/phpunit/tests/term/wpSetObjectTerms.php | 2 +- tests/phpunit/tests/term/wpTerm.php | 2 +- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/phpunit/tests/term/getTermLink.php b/tests/phpunit/tests/term/getTermLink.php index 94307ba6970a4..37cc99e606313 100644 --- a/tests/phpunit/tests/term/getTermLink.php +++ b/tests/phpunit/tests/term/getTermLink.php @@ -274,7 +274,7 @@ function ( $location, $term ) { * * @return array */ - public function data_term_link_filter_should_receive_term_object() { + public static function data_term_link_filter_should_receive_term_object() { return array( 'category passing term_id' => array( 'taxonomy' => 'category', @@ -325,9 +325,9 @@ public function test_get_term_feed_link_should_use_term_taxonomy_when_term_id_is * * @return array */ - public function data_get_term_feed_link_should_use_term_taxonomy_when_term_id_is_passed() { + public static function data_get_term_feed_link_should_use_term_taxonomy_when_term_id_is_passed() { $taxonomies = array( 'category', 'post_tag', 'wptests_tax' ); - return $this->text_array_to_dataprovider( $taxonomies ); + return self::text_array_to_dataprovider( $taxonomies ); } } diff --git a/tests/phpunit/tests/term/getTerms.php b/tests/phpunit/tests/term/getTerms.php index 3b35c6ac4e3ec..d11ecb9850fd7 100644 --- a/tests/phpunit/tests/term/getTerms.php +++ b/tests/phpunit/tests/term/getTerms.php @@ -3175,7 +3175,7 @@ public function test_cache_key_generation( $args_1, $args_2 ) { * * @return array */ - public function data_same_term_args() { + public static function data_same_term_args() { return array( 'all fields vs ids' => array( array( diff --git a/tests/phpunit/tests/term/isTermPubliclyViewable.php b/tests/phpunit/tests/term/isTermPubliclyViewable.php index 0ddddf137cccf..912d654c47aed 100644 --- a/tests/phpunit/tests/term/isTermPubliclyViewable.php +++ b/tests/phpunit/tests/term/isTermPubliclyViewable.php @@ -42,7 +42,7 @@ public function test_is_term_publicly_viewable( $taxonomy, $expected ) { * @type bool $expected The expected result of the function call. * } */ - public function data_is_term_publicly_viewable() { + public static function data_is_term_publicly_viewable() { return array( array( 'category', true ), array( 'post_tag', true ), diff --git a/tests/phpunit/tests/term/meta.php b/tests/phpunit/tests/term/meta.php index 49e5eafa89887..b4149d2dd9193 100644 --- a/tests/phpunit/tests/term/meta.php +++ b/tests/phpunit/tests/term/meta.php @@ -491,7 +491,7 @@ public function test_register_term_meta( $taxonomy, $meta_key, $args ) { $this->assertSame( $args, $this->last_register_meta_call['args'] ); } - public function data_register_term_meta() { + public static function data_register_term_meta() { return array( array( 'wptests_tax', 'registered_key1', array( 'single' => true ) ), array( 'category', 'registered_key2', array() ), @@ -525,7 +525,7 @@ public function test_unregister_term_meta( $taxonomy, $meta_key ) { $this->assertEmpty( $actual ); } - public function data_unregister_term_meta() { + public static function data_unregister_term_meta() { return array( array( 'wptests_tax', 'registered_key1' ), array( 'category', 'registered_key2' ), diff --git a/tests/phpunit/tests/term/query.php b/tests/phpunit/tests/term/query.php index 954781569cd15..16e46db097d1f 100644 --- a/tests/phpunit/tests/term/query.php +++ b/tests/phpunit/tests/term/query.php @@ -1106,7 +1106,7 @@ public function test_generate_cache_key_placeholder( $args ) { * * @return array[] Test parameters. */ - public function data_query_cache() { + public static function data_query_cache() { return array( 'empty query' => array( 'args' => array(), diff --git a/tests/phpunit/tests/term/sanitizeTerm.php b/tests/phpunit/tests/term/sanitizeTerm.php index 44e57d71c27ed..40762c37c104e 100644 --- a/tests/phpunit/tests/term/sanitizeTerm.php +++ b/tests/phpunit/tests/term/sanitizeTerm.php @@ -47,7 +47,7 @@ public function test_sanitize_term( Closure $input_callback, string $context, st * expected_description: string, * }> */ - public function data_sanitize_term(): array { + public static function data_sanitize_term(): array { $description = 'Test Description'; return array( diff --git a/tests/phpunit/tests/term/termCounts.php b/tests/phpunit/tests/term/termCounts.php index a0df17eb3460a..8bb75bcac23f2 100644 --- a/tests/phpunit/tests/term/termCounts.php +++ b/tests/phpunit/tests/term/termCounts.php @@ -104,7 +104,7 @@ public function test_term_count_changes_for_post_statuses( $post_status, $change * @type int $change Expected change. * } */ - public function data_term_count_changes_for_post_statuses() { + public static function data_term_count_changes_for_post_statuses() { return array( // 0. Published post array( 'publish', 1 ), @@ -146,7 +146,7 @@ public function test_term_counts_incremented_on_publish( $original_post_status, * @type int $change Expected change upon publish. * } */ - public function data_term_counts_incremented_on_publish() { + public static function data_term_counts_incremented_on_publish() { return array( // 0. Published post array( 'publish', 0 ), @@ -193,7 +193,7 @@ public function test_term_count_transitions_update_term_counts( $original_post_s * @type int $change Expected change upon publish. * } */ - public function data_term_count_transitions_update_term_counts() { + public static function data_term_count_transitions_update_term_counts() { return array( // 0. Draft -> published post array( 'draft', 'publish', 1 ), @@ -269,7 +269,7 @@ public function test_term_count_changes_for_update_post_term_count_statuses_filt * @type int $change Expected change. * } */ - public function data_term_count_changes_for_update_post_term_count_statuses_filter() { + public static function data_term_count_changes_for_update_post_term_count_statuses_filter() { return array( // 0. Published post array( 'publish', 2 ), @@ -319,7 +319,7 @@ public function test_term_count_changes_for_post_statuses_with_attachments( $pos * @type int $change Expected change. * } */ - public function data_term_count_changes_for_post_statuses_with_attachments() { + public static function data_term_count_changes_for_post_statuses_with_attachments() { return array( // 0. Published post array( 'publish', 2 ), @@ -370,7 +370,7 @@ public function test_term_counts_incremented_on_publish_with_attachments( $origi * @type int $change Expected change upon publish. * } */ - public function data_term_counts_incremented_on_publish_with_attachments() { + public static function data_term_counts_incremented_on_publish_with_attachments() { return array( // 0. Published post array( 'publish', 0 ), @@ -426,7 +426,7 @@ public function test_term_count_transitions_update_term_counts_with_attachments( * @type int $change Expected change upon publish. * } */ - public function data_term_count_transitions_update_term_counts_with_attachments() { + public static function data_term_count_transitions_update_term_counts_with_attachments() { return array( // 0. Draft -> published post array( 'draft', 'publish', 2 ), @@ -494,7 +494,7 @@ public function test_term_counts_incremented_on_publish_with_untermed_attachment * @type int $change Expected change upon publish. * } */ - public function data_term_counts_incremented_on_publish_with_untermed_attachments() { + public static function data_term_counts_incremented_on_publish_with_untermed_attachments() { return array( // 0. Published post array( 'publish', 0 ), @@ -549,7 +549,7 @@ public function test_term_count_transitions_update_term_counts_with_untermed_att * @type int $change Expected change upon publish. * } */ - public function data_term_count_transitions_update_term_counts_with_untermed_attachments() { + public static function data_term_count_transitions_update_term_counts_with_untermed_attachments() { return array( // 0. Draft -> published post array( 'draft', 'publish', 1 ), diff --git a/tests/phpunit/tests/term/wpGenerateTagCloud.php b/tests/phpunit/tests/term/wpGenerateTagCloud.php index e2d539299aa46..5fe81e7e2377a 100644 --- a/tests/phpunit/tests/term/wpGenerateTagCloud.php +++ b/tests/phpunit/tests/term/wpGenerateTagCloud.php @@ -41,7 +41,7 @@ public function test_empty_tags_list_returned( $expected, $args ) { * * @return array */ - public function data_empty_tags() { + public static function data_empty_tags() { return array( // When 'format' => 'array', we should be getting an empty array back. array( diff --git a/tests/phpunit/tests/term/wpSetObjectTerms.php b/tests/phpunit/tests/term/wpSetObjectTerms.php index 889ef74fdeed9..3734b00828ba1 100644 --- a/tests/phpunit/tests/term/wpSetObjectTerms.php +++ b/tests/phpunit/tests/term/wpSetObjectTerms.php @@ -466,7 +466,7 @@ public function test_empty_value_should_clear_terms( $empty_value ) { * * @return array[] */ - public function data_empty_value_should_clear_terms() { + public static function data_empty_value_should_clear_terms() { return array( '(bool) false' => array( false ), 'null' => array( null ), diff --git a/tests/phpunit/tests/term/wpTerm.php b/tests/phpunit/tests/term/wpTerm.php index f7a2934baa473..0eda866356514 100644 --- a/tests/phpunit/tests/term/wpTerm.php +++ b/tests/phpunit/tests/term/wpTerm.php @@ -164,7 +164,7 @@ public function test_get_instance_replaces_a_poisoned_cache_value( $cache_value * * @return array */ - public function data_get_instance_treats_a_poisoned_cache_value_as_a_cache_miss(): array { + public static function data_get_instance_treats_a_poisoned_cache_value_as_a_cache_miss(): array { return array( 'true' => array( true ), 'a non-numeric string' => array( 'not-a-term' ), From 4aa62b3834912799a0ac1ab3f606149c82906c65 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 19:08:11 +0000 Subject: [PATCH 011/236] Tests: Make compatibility test data providers static. Declare the data providers in `tests/phpunit/tests/compat/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions. Developed in: https://github.com/WordPress/wordpress-develop/pull/14396 Props rejaulalomkhan. See #66211. git-svn-id: https://develop.svn.wordpress.org/trunk@64446 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/compat/arrayAll.php | 2 +- tests/phpunit/tests/compat/arrayAny.php | 2 +- tests/phpunit/tests/compat/arrayFind.php | 2 +- tests/phpunit/tests/compat/arrayFindKey.php | 2 +- tests/phpunit/tests/compat/arrayFirst.php | 2 +- tests/phpunit/tests/compat/arrayIsList.php | 2 +- tests/phpunit/tests/compat/arrayLast.php | 2 +- tests/phpunit/tests/compat/clamp.php | 8 ++++---- tests/phpunit/tests/compat/isIterable.php | 2 +- tests/phpunit/tests/compat/mbStrlen.php | 2 +- tests/phpunit/tests/compat/mbSubstr.php | 4 ++-- tests/phpunit/tests/compat/strContains.php | 2 +- tests/phpunit/tests/compat/strEndsWith.php | 2 +- tests/phpunit/tests/compat/strStartsWith.php | 2 +- 14 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/phpunit/tests/compat/arrayAll.php b/tests/phpunit/tests/compat/arrayAll.php index 4eeff04bc886e..818123350f24e 100644 --- a/tests/phpunit/tests/compat/arrayAll.php +++ b/tests/phpunit/tests/compat/arrayAll.php @@ -34,7 +34,7 @@ public function test_array_all( bool $expected, array $arr, callable $callback ) * * @return array[] */ - public function data_array_all(): array { + public static function data_array_all(): array { return array( 'empty array' => array( 'expected' => true, diff --git a/tests/phpunit/tests/compat/arrayAny.php b/tests/phpunit/tests/compat/arrayAny.php index 97cfce1f89574..e6bd28fb2943f 100644 --- a/tests/phpunit/tests/compat/arrayAny.php +++ b/tests/phpunit/tests/compat/arrayAny.php @@ -34,7 +34,7 @@ public function test_array_any( bool $expected, array $arr, callable $callback ) * * @return array[] */ - public function data_array_any(): array { + public static function data_array_any(): array { return array( 'empty array' => array( 'expected' => false, diff --git a/tests/phpunit/tests/compat/arrayFind.php b/tests/phpunit/tests/compat/arrayFind.php index 62c3c7386a57d..770428737c69d 100644 --- a/tests/phpunit/tests/compat/arrayFind.php +++ b/tests/phpunit/tests/compat/arrayFind.php @@ -34,7 +34,7 @@ public function test_array_find( $expected, array $arr, callable $callback ) { * * @return array[] */ - public function data_array_find(): array { + public static function data_array_find(): array { return array( 'empty array' => array( 'expected' => null, diff --git a/tests/phpunit/tests/compat/arrayFindKey.php b/tests/phpunit/tests/compat/arrayFindKey.php index 140067b0dbc49..4512abfc95dc8 100644 --- a/tests/phpunit/tests/compat/arrayFindKey.php +++ b/tests/phpunit/tests/compat/arrayFindKey.php @@ -34,7 +34,7 @@ public function test_array_find_key( $expected, array $arr, callable $callback ) * * @return array[] */ - public function data_array_find_key(): array { + public static function data_array_find_key(): array { return array( 'empty array' => array( 'expected' => null, diff --git a/tests/phpunit/tests/compat/arrayFirst.php b/tests/phpunit/tests/compat/arrayFirst.php index cd3708d06403b..1d5543149fdb1 100644 --- a/tests/phpunit/tests/compat/arrayFirst.php +++ b/tests/phpunit/tests/compat/arrayFirst.php @@ -34,7 +34,7 @@ public function test_array_first( $expected, $arr ): void { * * @return array[] */ - public function data_array_first(): array { + public static function data_array_first(): array { $obj = new \stdClass(); return array( 'string values' => array( diff --git a/tests/phpunit/tests/compat/arrayIsList.php b/tests/phpunit/tests/compat/arrayIsList.php index 90e500103e694..38ad3dcdeccf7 100644 --- a/tests/phpunit/tests/compat/arrayIsList.php +++ b/tests/phpunit/tests/compat/arrayIsList.php @@ -33,7 +33,7 @@ public function test_array_is_list( $expected, $arr ) { * * @return array[] */ - public function data_array_is_list() { + public static function data_array_is_list() { return array( 'empty array' => array( 'expected' => true, diff --git a/tests/phpunit/tests/compat/arrayLast.php b/tests/phpunit/tests/compat/arrayLast.php index fc6ba394d2a02..638644a549988 100644 --- a/tests/phpunit/tests/compat/arrayLast.php +++ b/tests/phpunit/tests/compat/arrayLast.php @@ -33,7 +33,7 @@ public function test_array_last( $expected, $arr ): void { * * @return array[] */ - public function data_array_last(): array { + public static function data_array_last(): array { $obj = new \stdClass(); return array( 'string values' => array( diff --git a/tests/phpunit/tests/compat/clamp.php b/tests/phpunit/tests/compat/clamp.php index 707bfa580b958..3bb9924d7797e 100644 --- a/tests/phpunit/tests/compat/clamp.php +++ b/tests/phpunit/tests/compat/clamp.php @@ -37,7 +37,7 @@ public function test_clamp( $expected, $value, $min, $max ): void { * * @return array */ - public function data_clamp(): array { + public static function data_clamp(): array { return array( 'integer within range' => array( 'expected' => 5, @@ -201,7 +201,7 @@ public function test_clamp_with_datetime( DateTimeImmutable $expected, DateTimeI * * @return array */ - public function data_clamp_datetime(): array { + public static function data_clamp_datetime(): array { $min = new DateTimeImmutable( '2025-01-01' ); $max = new DateTimeImmutable( '2025-01-31' ); @@ -256,7 +256,7 @@ public function test_clamp_with_null_bound( $expected, $value, $min, $max ): voi * * @return array */ - public function data_clamp_with_null_bound(): array { + public static function data_clamp_with_null_bound(): array { return array( // The upper bound is checked before the lower bound, so $max wins when both compare as exceeded. 'null max, both bounds exceeded' => array( @@ -329,7 +329,7 @@ public function test_clamp_throws_for_null_max( $value, $min ): void { * * @return array */ - public function data_clamp_throws_for_null_max(): array { + public static function data_clamp_throws_for_null_max(): array { return array( 'value below min' => array( 'value' => -9999, diff --git a/tests/phpunit/tests/compat/isIterable.php b/tests/phpunit/tests/compat/isIterable.php index e09bb18278ccb..2f2b3f652b4bb 100644 --- a/tests/phpunit/tests/compat/isIterable.php +++ b/tests/phpunit/tests/compat/isIterable.php @@ -42,7 +42,7 @@ public function test_is_iterable_functionality( $variable, $is_iterable ) { * } * } */ - public function data_is_iterable_functionality() { + public static function data_is_iterable_functionality() { return array( 'empty array' => array( 'variable' => array(), diff --git a/tests/phpunit/tests/compat/mbStrlen.php b/tests/phpunit/tests/compat/mbStrlen.php index 4be968e3f39ce..f0d0245b85d36 100644 --- a/tests/phpunit/tests/compat/mbStrlen.php +++ b/tests/phpunit/tests/compat/mbStrlen.php @@ -55,7 +55,7 @@ public function test_8bit_mb_strlen( $input_string ) { * * @return array */ - public function data_utf8_strings() { + public static function data_utf8_strings() { return array( array( 'баба' ), array( 'баб' ), diff --git a/tests/phpunit/tests/compat/mbSubstr.php b/tests/phpunit/tests/compat/mbSubstr.php index 5aee9616b16d1..dfe0610872ae1 100644 --- a/tests/phpunit/tests/compat/mbSubstr.php +++ b/tests/phpunit/tests/compat/mbSubstr.php @@ -45,7 +45,7 @@ public function test_8bit_mb_substr( $input_string, $start, $length ) { * * @return array[] */ - public function data_utf8_substrings() { + public static function data_utf8_substrings() { return array( 'positive start, positive length' => array( 'баба', 0, 3 ), 'positive start, negative length' => array( 'баба', 0, -1 ), @@ -113,7 +113,7 @@ public function test_mb_substr_phpcore_input_type_handling( $input, $expected ) * * @return array */ - public function data_mb_substr_phpcore_input_type_handling() { + public static function data_mb_substr_phpcore_input_type_handling() { $heredoc = << array( 'expected' => true, diff --git a/tests/phpunit/tests/compat/strEndsWith.php b/tests/phpunit/tests/compat/strEndsWith.php index 8467675613191..3fb5ddab8069a 100644 --- a/tests/phpunit/tests/compat/strEndsWith.php +++ b/tests/phpunit/tests/compat/strEndsWith.php @@ -34,7 +34,7 @@ public function test_str_ends_with( $expected, $haystack, $needle ) { * * @return array[] */ - public function data_str_ends_with() { + public static function data_str_ends_with() { return array( 'empty needle' => array( 'expected' => true, diff --git a/tests/phpunit/tests/compat/strStartsWith.php b/tests/phpunit/tests/compat/strStartsWith.php index a7ea8ff3d9ff9..157d1c853373e 100644 --- a/tests/phpunit/tests/compat/strStartsWith.php +++ b/tests/phpunit/tests/compat/strStartsWith.php @@ -34,7 +34,7 @@ public function test_str_starts_with( $expected, $haystack, $needle ) { * * @return array[] */ - public function data_str_starts_with() { + public static function data_str_starts_with() { return array( 'empty needle' => array( 'expected' => true, From 4b285427f2d6448bd7d5fd1150e3b2aa8e290d48 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 19:09:16 +0000 Subject: [PATCH 012/236] Tests: Make date test data providers static. Declare the data providers in `tests/phpunit/tests/date/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions. Developed in: https://github.com/WordPress/wordpress-develop/pull/14397 Props rejaulalomkhan. See #66211. git-svn-id: https://develop.svn.wordpress.org/trunk@64447 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/date/currentTime.php | 4 ++-- tests/phpunit/tests/date/dateI18n.php | 4 ++-- tests/phpunit/tests/date/getFeedBuildDate.php | 2 +- tests/phpunit/tests/date/maybeDeclineDate.php | 2 +- tests/phpunit/tests/date/query.php | 4 ++-- tests/phpunit/tests/date/wpCheckdate.php | 2 +- tests/phpunit/tests/date/wpDate.php | 2 +- tests/phpunit/tests/date/wpTimezone.php | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/phpunit/tests/date/currentTime.php b/tests/phpunit/tests/date/currentTime.php index a4f51ab41bc40..7b40e31a5abc7 100644 --- a/tests/phpunit/tests/date/currentTime.php +++ b/tests/phpunit/tests/date/currentTime.php @@ -145,7 +145,7 @@ public function test_should_return_correct_local_time( $timezone ) { * * @return array[] */ - public function data_timezones() { + public static function data_timezones() { return array( array( 'Europe/Helsinki' ), array( 'Indian/Antananarivo' ), @@ -255,7 +255,7 @@ public function test_partial_hour_timezones_match_datetime_offset( $partial_hour * * @return array[] */ - public function data_partial_hour_timezones_with_timestamp() { + public static function data_partial_hour_timezones_with_timestamp() { return array( '+12:45' => array( 12.75, 'Pacific/Chatham' ), // New Zealand, Chatham Islands. '+9:30' => array( 9.5, 'Australia/Darwin' ), // Australian Northern Territory. diff --git a/tests/phpunit/tests/date/dateI18n.php b/tests/phpunit/tests/date/dateI18n.php index 74233289697f5..5a528ba0e189e 100644 --- a/tests/phpunit/tests/date/dateI18n.php +++ b/tests/phpunit/tests/date/dateI18n.php @@ -151,7 +151,7 @@ public function test_date_i18n_handles_shorthand_formats( $short, $full ) { $this->assertSame( $short, date_i18n( '\\' . $short ) ); } - public function data_formats() { + public static function data_formats() { return array( array( 'c', @@ -216,7 +216,7 @@ public function test_should_handle_dst( $time, $timezone ) { $this->assertSame( $datetime->format( $format ), date_i18n( $format, $wp_timestamp ) ); } - public function data_should_handle_dst() { + public static function data_should_handle_dst() { return array( 'Before DST start' => array( '2019-03-31 02:59:00', 'Europe/Helsinki' ), 'After DST start' => array( '2019-03-31 04:01:00', 'Europe/Helsinki' ), diff --git a/tests/phpunit/tests/date/getFeedBuildDate.php b/tests/phpunit/tests/date/getFeedBuildDate.php index b79e022ac39bd..e5530af9783db 100644 --- a/tests/phpunit/tests/date/getFeedBuildDate.php +++ b/tests/phpunit/tests/date/getFeedBuildDate.php @@ -178,7 +178,7 @@ public function test_should_return_correct_build_date_for_cold_query_fields( str * * @return array */ - public function data_cold_post_query_fields(): array { + public static function data_cold_post_query_fields(): array { return array( 'IDs' => array( 'ids' ), 'partial' => array( 'id=>parent' ), diff --git a/tests/phpunit/tests/date/maybeDeclineDate.php b/tests/phpunit/tests/date/maybeDeclineDate.php index 4c26d2ae0e004..3b57b1973aadc 100644 --- a/tests/phpunit/tests/date/maybeDeclineDate.php +++ b/tests/phpunit/tests/date/maybeDeclineDate.php @@ -71,7 +71,7 @@ public function filter__enable_months_names_declension( $translation, $text, $co return $translation; } - public function data_wp_maybe_decline_date() { + public static function data_wp_maybe_decline_date() { return array( array( 'ru_RU', 'j F', '21 Июнь', '21 июня' ), array( 'ru_RU', 'j F Y', '1 Январь 2016', '1 января 2016' ), diff --git a/tests/phpunit/tests/date/query.php b/tests/phpunit/tests/date/query.php index a894572d01d78..e69859c148ac3 100644 --- a/tests/phpunit/tests/date/query.php +++ b/tests/phpunit/tests/date/query.php @@ -548,7 +548,7 @@ public function test_build_mysql_datetime( $datetime, $expected, $default_to_max $this->assertEqualsWithDelta( strtotime( $expected ), strtotime( $found ), 10, $message ); } - public function data_build_mysql_datetime() { + public static function data_build_mysql_datetime() { return array( array( '2019-06-04T08:18:24+03:00', '2019-06-04 05:18:24' ), array( '2019-06-04T05:18:24+00:00', '2019-06-04 05:18:24' ), @@ -583,7 +583,7 @@ public function test_build_mysql_datetime_with_custom_timezone( $datetime, $expe $this->assertEqualsWithDelta( strtotime( $expected ), strtotime( $found ), 10, $message ); } - public function data_build_mysql_datetime_with_custom_timezone() { + public static function data_build_mysql_datetime_with_custom_timezone() { return array( array( '2019-06-04T08:18:24+03:00', '2019-06-04 08:18:24' ), array( '2019-06-04T05:18:24+00:00', '2019-06-04 08:18:24' ), diff --git a/tests/phpunit/tests/date/wpCheckdate.php b/tests/phpunit/tests/date/wpCheckdate.php index 96cd38e7d8f05..ea0579d37d52d 100644 --- a/tests/phpunit/tests/date/wpCheckdate.php +++ b/tests/phpunit/tests/date/wpCheckdate.php @@ -31,7 +31,7 @@ public function test_wp_checkdate( $month, $day, $year, $source_date, $expected * * @return array */ - public function data_wp_checkdate() { + public static function data_wp_checkdate() { return array( 'integers' => array( 1, 1, 1, '1-1-1', true ), 'strings' => array( '1', '1', '1', '1-1-1', true ), diff --git a/tests/phpunit/tests/date/wpDate.php b/tests/phpunit/tests/date/wpDate.php index c80a2a997b125..cff2f11967f3b 100644 --- a/tests/phpunit/tests/date/wpDate.php +++ b/tests/phpunit/tests/date/wpDate.php @@ -106,7 +106,7 @@ public function test_should_format_date( $expected, $format ) { * * @return array */ - public function data_should_format_date() { + public static function data_should_format_date() { return array( 'Swatch Internet Time' => array( 'expected' => '041', diff --git a/tests/phpunit/tests/date/wpTimezone.php b/tests/phpunit/tests/date/wpTimezone.php index d4e7e7e220fdd..17e96f1f85349 100644 --- a/tests/phpunit/tests/date/wpTimezone.php +++ b/tests/phpunit/tests/date/wpTimezone.php @@ -44,7 +44,7 @@ public function test_should_convert_gmt_offset( $gmt_offset, $tz_name ) { * * @return array */ - public function data_should_convert_gmt_offset() { + public static function data_should_convert_gmt_offset() { return array( array( -12, '-12:00' ), array( -11.5, '-11:30' ), From 716a3297d422dbde4bf9b65bcbcad8ea8229ba06 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 19:10:25 +0000 Subject: [PATCH 013/236] Tests: Make font test data providers static. Declare the data providers in `tests/phpunit/tests/fonts/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions. Developed in: https://github.com/WordPress/wordpress-develop/pull/14400 Props rejaulalomkhan. See #66211. git-svn-id: https://develop.svn.wordpress.org/trunk@64448 602fd350-edb4-49c9-b593-d223f7449a82 --- .../wpFontFaceResolver/getFontsFromThemeJson.php | 4 ++-- .../font-library/wpFontCollection/getData.php | 4 ++-- .../font-library/wpFontUtils/getFontFaceSlug.php | 2 +- .../wpFontUtils/sanitizeFontFamily.php | 2 +- .../wpFontUtils/sanitizeFromSchema.php | 2 +- .../font-library/wpRestFontFacesController.php | 8 ++++---- .../font-library/wpRestFontFamiliesController.php | 14 +++++++------- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/phpunit/tests/fonts/font-face/wpFontFaceResolver/getFontsFromThemeJson.php b/tests/phpunit/tests/fonts/font-face/wpFontFaceResolver/getFontsFromThemeJson.php index a24a1e862e219..e84e52b82d405 100644 --- a/tests/phpunit/tests/fonts/font-face/wpFontFaceResolver/getFontsFromThemeJson.php +++ b/tests/phpunit/tests/fonts/font-face/wpFontFaceResolver/getFontsFromThemeJson.php @@ -93,7 +93,7 @@ static function ( $font ) use ( $font_name, $font_weight, $font_style ) { * * @return array */ - public function data_should_replace_src_file_placeholder() { + public static function data_should_replace_src_file_placeholder() { return array( // Theme's theme.json. 'DM Sans: 400 normal' => array( @@ -174,7 +174,7 @@ function ( $font ) use ( $expected_name ) { * * @return array */ - public function data_should_get_font_family_name() { + public static function data_should_get_font_family_name() { $font_face = array( array( 'fontFamily' => 'DM Sans', diff --git a/tests/phpunit/tests/fonts/font-library/wpFontCollection/getData.php b/tests/phpunit/tests/fonts/font-library/wpFontCollection/getData.php index 97ea664d4867d..dc82b2a67fdb8 100644 --- a/tests/phpunit/tests/fonts/font-library/wpFontCollection/getData.php +++ b/tests/phpunit/tests/fonts/font-library/wpFontCollection/getData.php @@ -86,7 +86,7 @@ public function test_should_get_data_from_json_url( $slug, $config, $expected_da * * @return array */ - public function data_create_font_collection() { + public static function data_create_font_collection() { return array( 'font collection with required data' => array( 'slug' => 'my-collection', @@ -225,7 +225,7 @@ public function test_should_error_when_missing_properties( $config ) { * * @return array */ - public function data_should_error_when_missing_properties() { + public static function data_should_error_when_missing_properties() { return array( 'missing name' => array( 'config' => array( diff --git a/tests/phpunit/tests/fonts/font-library/wpFontUtils/getFontFaceSlug.php b/tests/phpunit/tests/fonts/font-library/wpFontUtils/getFontFaceSlug.php index de0b02e63185e..ea24c14ebb049 100644 --- a/tests/phpunit/tests/fonts/font-library/wpFontUtils/getFontFaceSlug.php +++ b/tests/phpunit/tests/fonts/font-library/wpFontUtils/getFontFaceSlug.php @@ -28,7 +28,7 @@ public function test_get_font_face_slug_normalizes_values( $settings, $expected_ * * @return array */ - public function data_get_font_face_slug_normalizes_values() { + public static function data_get_font_face_slug_normalizes_values() { return array( 'Sets defaults' => array( 'settings' => array( diff --git a/tests/phpunit/tests/fonts/font-library/wpFontUtils/sanitizeFontFamily.php b/tests/phpunit/tests/fonts/font-library/wpFontUtils/sanitizeFontFamily.php index ff6b083ecaebd..5facec63795fc 100644 --- a/tests/phpunit/tests/fonts/font-library/wpFontUtils/sanitizeFontFamily.php +++ b/tests/phpunit/tests/fonts/font-library/wpFontUtils/sanitizeFontFamily.php @@ -32,7 +32,7 @@ public function test_should_sanitize_font_family( $font_family, $expected ) { * * @return array */ - public function data_should_sanitize_font_family() { + public static function data_should_sanitize_font_family() { return array( 'data_families_with_spaces_and_numbers' => array( 'font_family' => 'Arial, Rock 3D , Open Sans,serif', diff --git a/tests/phpunit/tests/fonts/font-library/wpFontUtils/sanitizeFromSchema.php b/tests/phpunit/tests/fonts/font-library/wpFontUtils/sanitizeFromSchema.php index 88983fe15a14e..b712c7fad846e 100644 --- a/tests/phpunit/tests/fonts/font-library/wpFontUtils/sanitizeFromSchema.php +++ b/tests/phpunit/tests/fonts/font-library/wpFontUtils/sanitizeFromSchema.php @@ -24,7 +24,7 @@ public function test_sanitize_from_schema( $data, $schema, $expected ) { $this->assertSame( $result, $expected ); } - public function data_sanitize_from_schema() { + public static function data_sanitize_from_schema() { return array( 'One level associative array' => array( 'data' => array( diff --git a/tests/phpunit/tests/fonts/font-library/wpRestFontFacesController.php b/tests/phpunit/tests/fonts/font-library/wpRestFontFacesController.php index a4bc7bbfef5e7..eea334c927626 100644 --- a/tests/phpunit/tests/fonts/font-library/wpRestFontFacesController.php +++ b/tests/phpunit/tests/fonts/font-library/wpRestFontFacesController.php @@ -178,7 +178,7 @@ public function test_context_param( $single_route = false ) { * * @return array */ - public function data_get_context_param() { + public static function data_get_context_param() { return array( 'Collection' => array( false ), 'Single' => array( true ), @@ -682,7 +682,7 @@ public function test_create_item_invalid_theme_json_version( $theme_json_version * * @return array */ - public function data_create_item_invalid_theme_json_version() { + public static function data_create_item_invalid_theme_json_version() { return array( array( 1 ), array( 4 ), @@ -712,7 +712,7 @@ public function test_create_item_invalid_settings( $settings ) { * * @return array */ - public function data_create_item_invalid_settings() { + public static function data_create_item_invalid_settings() { return array( 'Missing fontFamily' => array( 'settings' => array_diff_key( self::$default_settings, array( 'fontFamily' => '' ) ), @@ -860,7 +860,7 @@ public function test_create_item_sanitize_font_face_settings( $settings, $expect * * @return array */ - public function data_sanitize_font_face_settings() { + public static function data_sanitize_font_face_settings() { return array( 'settings with tags, extra whitespace, new lines' => array( 'settings' => array( diff --git a/tests/phpunit/tests/fonts/font-library/wpRestFontFamiliesController.php b/tests/phpunit/tests/fonts/font-library/wpRestFontFamiliesController.php index 0879c186a2530..0992ddf9f28c8 100644 --- a/tests/phpunit/tests/fonts/font-library/wpRestFontFamiliesController.php +++ b/tests/phpunit/tests/fonts/font-library/wpRestFontFamiliesController.php @@ -194,7 +194,7 @@ public function test_context_param( $single_route = false ) { * * @return array */ - public function data_get_context_param() { + public static function data_get_context_param() { return array( 'Collection' => array( false ), 'Single' => array( true ), @@ -423,7 +423,7 @@ public function test_create_item_invalid_theme_json_version( $theme_json_version * * @return array */ - public function data_create_item_invalid_theme_json_version() { + public static function data_create_item_invalid_theme_json_version() { return array( array( 1 ), array( 4 ), @@ -458,7 +458,7 @@ public function test_create_item_with_default_preview( $settings ) { * * @return array */ - public function data_create_item_with_default_preview() { + public static function data_create_item_with_default_preview() { $default_settings = array( 'name' => 'Open Sans', 'slug' => 'open-sans-2', @@ -503,7 +503,7 @@ public function test_create_item_sanitize_font_family_settings( $settings, $expe * * @return array */ - public function data_sanitize_font_family_settings() { + public static function data_sanitize_font_family_settings() { return array( 'settings with tags, extra whitespace, new lines' => array( 'settings' => array( @@ -574,7 +574,7 @@ public function test_create_item_invalid_settings( $settings ) { * * @return array */ - public function data_create_item_invalid_settings() { + public static function data_create_item_invalid_settings() { return array( 'Missing name' => array( 'settings' => array_diff_key( self::$default_settings, array( 'name' => '' ) ), @@ -746,7 +746,7 @@ public function test_update_item_individual_settings( $settings ) { * * @return array */ - public function data_update_item_individual_settings() { + public static function data_update_item_individual_settings() { return array( array( array( 'name' => 'Opened Sans' ) ), array( array( 'fontFamily' => '"Opened Sans", sans-serif' ) ), @@ -806,7 +806,7 @@ public function test_update_item_empty_settings( $settings ) { * * @return array */ - public function data_update_item_invalid_settings() { + public static function data_update_item_invalid_settings() { return array( 'Empty name' => array( array( 'name' => '' ), From a2297e0ed5ce1ce34f8958f93bf27aabaeb8ccbe Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 19:12:12 +0000 Subject: [PATCH 014/236] Tests: Make block support test data providers static. Declare the data providers in `tests/phpunit/tests/block-supports/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions. Developed in: https://github.com/WordPress/wordpress-develop/pull/14398 Props rejaulalomkhan. See #66211. git-svn-id: https://develop.svn.wordpress.org/trunk@64449 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/block-supports/anchor.php | 4 ++-- .../tests/block-supports/aria-label.php | 2 +- .../phpunit/tests/block-supports/duotone.php | 6 ++--- tests/phpunit/tests/block-supports/layout.php | 22 +++++++++---------- tests/phpunit/tests/block-supports/shadow.php | 2 +- .../tests/block-supports/typography.php | 18 +++++++-------- .../wpApplyDimensionsSupport.php | 8 +++---- .../wpGetBlockStyleVariationNameFromClass.php | 2 +- .../tests/block-supports/wpGetLayoutStyle.php | 2 +- .../wpRenderBackgroundSupport.php | 4 ++-- .../wpRenderCustomCssClassName.php | 4 ++-- .../wpRenderCustomCssSupportStyles.php | 4 ++-- .../wpRenderDimensionsSupport.php | 2 +- .../wpRenderElementsSupport.php | 2 +- .../wpRenderElementsSupportStyles.php | 2 +- .../wpRenderPositionSupport.php | 2 +- .../wpStripCustomCssFromBlocks.php | 2 +- 17 files changed, 44 insertions(+), 44 deletions(-) diff --git a/tests/phpunit/tests/block-supports/anchor.php b/tests/phpunit/tests/block-supports/anchor.php index 7e837800924a0..a8905e132cd9d 100644 --- a/tests/phpunit/tests/block-supports/anchor.php +++ b/tests/phpunit/tests/block-supports/anchor.php @@ -75,7 +75,7 @@ public function test_wp_apply_anchor_support( bool $support, $value, array $expe * * @return array> */ - public function data_wp_register_anchor_support(): array { + public static function data_wp_register_anchor_support(): array { return array( 'anchor attribute is registered when block supports anchor' => array( 'support' => true, @@ -130,7 +130,7 @@ public function data_wp_register_anchor_support(): array { * * @return array> */ - public function data_wp_apply_anchor_support(): array { + public static function data_wp_apply_anchor_support(): array { return array( 'anchor id attribute is applied' => array( 'support' => true, diff --git a/tests/phpunit/tests/block-supports/aria-label.php b/tests/phpunit/tests/block-supports/aria-label.php index 691c2fa0f1d16..0d23b821c6297 100644 --- a/tests/phpunit/tests/block-supports/aria-label.php +++ b/tests/phpunit/tests/block-supports/aria-label.php @@ -70,7 +70,7 @@ public function test_wp_apply_aria_label_support( $support, $value, $expected ) * * @return array */ - public function data_aria_label_block_support() { + public static function data_aria_label_block_support() { return array( 'aria-label attribute is applied' => array( 'support' => true, diff --git a/tests/phpunit/tests/block-supports/duotone.php b/tests/phpunit/tests/block-supports/duotone.php index f4eaa63faec99..44aab85fea63a 100644 --- a/tests/phpunit/tests/block-supports/duotone.php +++ b/tests/phpunit/tests/block-supports/duotone.php @@ -96,7 +96,7 @@ public function test_get_slug_from_attribute( $data_attr, $expected ) { * * @return array[]. */ - public function data_get_slug_from_attribute() { + public static function data_get_slug_from_attribute() { return array( 'pipe-slug' => array( 'var:preset|duotone|blue-orange', 'blue-orange' ), 'css-var' => array( 'var(--wp--preset--duotone--blue-orange)', 'blue-orange' ), @@ -173,7 +173,7 @@ public function test_is_preset( $data_attr, $expected ) { * * @return array[]. */ - public function data_is_preset() { + public static function data_is_preset() { return array( 'pipe-slug' => array( 'var:preset|duotone|blue-orange', true ), 'css-var' => array( 'var(--wp--preset--duotone--blue-orange)', true ), @@ -203,7 +203,7 @@ public function test_colord_parse_hue( $value, $unit, $expected ) { * * @return array[]. */ - public function data_colord_parse_hue() { + public static function data_colord_parse_hue() { return array( 'deg-angle-unit' => array( 120, 'deg', 120.0 ), 'grad-angle-unit' => array( 120, 'grad', 108.0 ), diff --git a/tests/phpunit/tests/block-supports/layout.php b/tests/phpunit/tests/block-supports/layout.php index 3e88c609ac092..9cade9763635f 100644 --- a/tests/phpunit/tests/block-supports/layout.php +++ b/tests/phpunit/tests/block-supports/layout.php @@ -111,7 +111,7 @@ public function test_sanitize_block_gap_value_normalizes_zero_and_rejects_other_ * * @return array[] Test data. */ - public function data_sanitize_block_gap_value() { + public static function data_sanitize_block_gap_value() { return array( 'string value' => array( '1rem', '1rem' ), 'empty string' => array( '', null ), @@ -158,7 +158,7 @@ public function test_wp_get_layout_style( $args, $expected_output ) { * * @return array[] Test data. */ - public function data_wp_get_layout_style() { + public static function data_wp_get_layout_style() { return array( 'flex layout uses the default for malformed gap values' => array( 'args' => array( @@ -307,7 +307,7 @@ public function test_additional_styles_moved_to_restored_outer_container_for_ali * } * } */ - public function data_block_image_html_restored_outer_container() { + public static function data_block_image_html_restored_outer_container() { $expected = '
'; return array( @@ -376,7 +376,7 @@ public function test_layout_support_flag_renders_classnames_on_wrapper( $args, $ * * @return array */ - public function data_layout_support_flag_renders_classnames_on_wrapper() { + public static function data_layout_support_flag_renders_classnames_on_wrapper() { return array( 'single wrapper block layout with flow type' => array( 'args' => array( @@ -589,7 +589,7 @@ public function test_restore_group_inner_container( $args, $expected_output ) { * * @return array */ - public function data_restore_group_inner_container() { + public static function data_restore_group_inner_container() { return array( 'group block with existing inner container' => array( 'args' => array( @@ -684,7 +684,7 @@ public function test_wp_get_child_layout_style_rules( $child_layout, $viewport_o * * @return array */ - public function data_wp_get_child_layout_style_rules() { + public static function data_wp_get_child_layout_style_rules() { return array( 'legacy fixed sizing remains shrinkable' => array( 'child_layout' => array( @@ -836,7 +836,7 @@ public function test_wp_add_parent_layout_to_parsed_block( $block, $parent_block * * @return array */ - public function data_wp_add_parent_layout_to_parsed_block() { + public static function data_wp_add_parent_layout_to_parsed_block() { return array( 'block with no parent layout' => array( 'block' => array( @@ -950,7 +950,7 @@ public function test_layout_support_flag_renders_consistent_container_hash( $blo * * @return array */ - public function data_layout_support_flag_renders_consistent_container_hash() { + public static function data_layout_support_flag_renders_consistent_container_hash() { return array( 'default type block gap 12px' => array( 'block_attributes' => array( @@ -1086,7 +1086,7 @@ public function test_layout_classname_includes_namespace_for_custom_blocks( $blo * * @return array */ - public function data_layout_classname_with_custom_blocks() { + public static function data_layout_classname_with_custom_blocks() { return array( 'custom block with constrained layout' => array( 'block_name' => 'foo/bar', @@ -1180,7 +1180,7 @@ public function test_get_block_style_variation_name_from_registered_style( $clas * * @return array */ - public function data_get_block_style_variation_name_from_registered_style() { + public static function data_get_block_style_variation_name_from_registered_style() { return array( 'empty class name' => array( 'class_name' => '', @@ -1589,7 +1589,7 @@ public function test_get_layout_style_with_non_numeric_grid_counts( $layout, $ex * * @return array */ - public function data_get_layout_style_with_non_numeric_grid_counts() { + public static function data_get_layout_style_with_non_numeric_grid_counts() { return array( 'non-numeric columnCount falls back to the responsive default' => array( 'layout' => array( diff --git a/tests/phpunit/tests/block-supports/shadow.php b/tests/phpunit/tests/block-supports/shadow.php index b0f1222150f61..bc2bb53b10ea4 100644 --- a/tests/phpunit/tests/block-supports/shadow.php +++ b/tests/phpunit/tests/block-supports/shadow.php @@ -74,7 +74,7 @@ public function test_wp_apply_shadow_support( $support, $value, $expected ) { * * @return array */ - public function data_generate_shadow_fixtures() { + public static function data_generate_shadow_fixtures() { return array( 'with no styles' => array( 'support' => true, diff --git a/tests/phpunit/tests/block-supports/typography.php b/tests/phpunit/tests/block-supports/typography.php index fd89a276bfb16..e141391c0ace4 100644 --- a/tests/phpunit/tests/block-supports/typography.php +++ b/tests/phpunit/tests/block-supports/typography.php @@ -358,7 +358,7 @@ public function test_wp_get_typography_font_size_value( $font_size_preset, $sett * * @return array */ - public function data_generate_font_size_preset_fixtures() { + public static function data_generate_font_size_preset_fixtures() { return array( 'returns value when fluid typography is deactivated' => array( 'font_size_preset' => array( @@ -874,7 +874,7 @@ public function test_wp_get_typography_font_size_value_should_use_fluid_typograp * * @return array */ - public function data_generate_font_size_preset_should_use_fluid_typography_deprecated_fixtures() { + public static function data_generate_font_size_preset_should_use_fluid_typography_deprecated_fixtures() { return array( 'returns value when fluid typography is deactivated' => array( 'font_size' => array( @@ -925,7 +925,7 @@ public function test_should_override_theme_settings( $font_size, $settings, $exp * * @return array */ - public function data_generate_should_override_theme_settings_fixtures() { + public static function data_generate_should_override_theme_settings_fixtures() { return array( 'returns clamp value when theme activates fluid typography' => array( 'font_size' => array( @@ -1052,7 +1052,7 @@ public function test_should_covert_font_sizes_to_fluid_values( $font_size_value, * * @return array */ - public function data_generate_block_supports_font_size_fixtures() { + public static function data_generate_block_supports_font_size_fixtures() { return array( 'returns value when fluid typography is not active' => array( 'font_size_value' => '15px', @@ -1130,7 +1130,7 @@ public function test_should_replace_inline_font_styles_with_fluid_values( $block * * @return array */ - public function data_generate_replace_inline_font_styles_with_fluid_values_fixtures() { + public static function data_generate_replace_inline_font_styles_with_fluid_values_fixtures() { return array( 'default_return_content' => array( 'block_content' => '', @@ -1206,7 +1206,7 @@ public function test_should_add_fit_text_class_name( string $block_content, stri * * @return array */ - public function data_should_add_fit_text_class_name(): array { + public static function data_should_add_fit_text_class_name(): array { return array( 'wrapper without a class attribute' => array( 'block_content' => '

Site Title

', @@ -1266,7 +1266,7 @@ public function test_valid_size_wp_get_typography_value_and_unit( $raw_value, $e * * @return array */ - public function data_valid_size_wp_get_typography_value_and_unit() { + public static function data_valid_size_wp_get_typography_value_and_unit() { return array( 'size: 10vh with default units do not match' => array( 'raw_value' => '10vh', @@ -1353,7 +1353,7 @@ public function test_invalid_size_wp_get_typography_value_and_unit( $raw_value ) * * @return array */ - public function data_invalid_size_wp_get_typography_value_and_unit() { + public static function data_invalid_size_wp_get_typography_value_and_unit() { return array( 'size: null' => array( null ), 'size: false' => array( false ), @@ -1393,7 +1393,7 @@ public function test_wp_get_computed_fluid_typography_value( $args, $expected_ou * * @return array */ - public function data_wp_get_computed_fluid_typography_value() { + public static function data_wp_get_computed_fluid_typography_value() { return array( 'returns clamped value with valid args' => array( 'args' => array( diff --git a/tests/phpunit/tests/block-supports/wpApplyDimensionsSupport.php b/tests/phpunit/tests/block-supports/wpApplyDimensionsSupport.php index 6fd58f4e56dec..c10fcebc73548 100644 --- a/tests/phpunit/tests/block-supports/wpApplyDimensionsSupport.php +++ b/tests/phpunit/tests/block-supports/wpApplyDimensionsSupport.php @@ -71,7 +71,7 @@ public function test_minimum_height_block_support( $block_name, $dimensions, $ex * * @return array */ - public function data_minimum_height_block_support() { + public static function data_minimum_height_block_support() { return array( 'style is applied' => array( 'block_name' => 'test/dimensions-block-supports', @@ -150,7 +150,7 @@ public function test_width_block_support( $block_name, $dimensions, $expected ) * * @return array */ - public function data_width_block_support() { + public static function data_width_block_support() { return array( 'style is applied' => array( 'block_name' => 'test/width-style-is-applied', @@ -221,7 +221,7 @@ public function test_height_block_support( $block_name, $dimensions, $expected ) * * @return array */ - public function data_height_block_support() { + public static function data_height_block_support() { return array( 'style is applied' => array( 'block_name' => 'test/height-style-is-applied', @@ -292,7 +292,7 @@ public function test_minimum_width_block_support( $block_name, $dimensions, $exp * * @return array */ - public function data_minimum_width_block_support() { + public static function data_minimum_width_block_support() { return array( 'style is applied' => array( 'block_name' => 'test/min-width-style-is-applied', diff --git a/tests/phpunit/tests/block-supports/wpGetBlockStyleVariationNameFromClass.php b/tests/phpunit/tests/block-supports/wpGetBlockStyleVariationNameFromClass.php index de36658ef47b2..c5c336f4079b2 100644 --- a/tests/phpunit/tests/block-supports/wpGetBlockStyleVariationNameFromClass.php +++ b/tests/phpunit/tests/block-supports/wpGetBlockStyleVariationNameFromClass.php @@ -33,7 +33,7 @@ public function test_block_style_variation_name_extraction( $class_string, $expe * * @return array */ - public function data_block_style_variation_name_extraction() { + public static function data_block_style_variation_name_extraction() { return array( // @ticket 61312 'missing class string' => array( diff --git a/tests/phpunit/tests/block-supports/wpGetLayoutStyle.php b/tests/phpunit/tests/block-supports/wpGetLayoutStyle.php index 4088a260fc157..c9a8dea379062 100644 --- a/tests/phpunit/tests/block-supports/wpGetLayoutStyle.php +++ b/tests/phpunit/tests/block-supports/wpGetLayoutStyle.php @@ -45,7 +45,7 @@ public function test_wp_get_layout_style( array $args, $expected_output ) { * * @return array */ - public function data_wp_get_layout_style() { + public static function data_wp_get_layout_style() { return array( 'no args should return empty value' => array( 'args' => array(), diff --git a/tests/phpunit/tests/block-supports/wpRenderBackgroundSupport.php b/tests/phpunit/tests/block-supports/wpRenderBackgroundSupport.php index 6f0a6cc023db7..01eb2f8fa92bd 100644 --- a/tests/phpunit/tests/block-supports/wpRenderBackgroundSupport.php +++ b/tests/phpunit/tests/block-supports/wpRenderBackgroundSupport.php @@ -124,7 +124,7 @@ public function test_background_block_support( $theme_name, $block_name, $backgr * * @return array */ - public function data_background_block_support() { + public static function data_background_block_support() { return array( 'background image style is applied' => array( 'theme_name' => 'block-theme-child-with-fluid-typography', @@ -312,7 +312,7 @@ public function test_background_gradient_values_pass_kses( $css ) { * * @return array[] */ - public function data_background_gradient_values_pass_kses() { + public static function data_background_gradient_values_pass_kses() { return array( 'gradient first with rgb colors' => array( 'background-image: linear-gradient(135deg, rgb(255,0,0) 0%, rgb(0,0,255) 100%), url(https://example.com/image.jpg)', diff --git a/tests/phpunit/tests/block-supports/wpRenderCustomCssClassName.php b/tests/phpunit/tests/block-supports/wpRenderCustomCssClassName.php index 1247ca65a1a33..21f3dabb456ca 100644 --- a/tests/phpunit/tests/block-supports/wpRenderCustomCssClassName.php +++ b/tests/phpunit/tests/block-supports/wpRenderCustomCssClassName.php @@ -40,7 +40,7 @@ public function test_adds_class_to_content( $block_content, $block, $expected_cl * expected_class: string, * }> */ - public function data_adds_class_to_content(): array { + public static function data_adds_class_to_content(): array { return array( 'class is added to block content' => array( 'block_content' => '
Test content
', @@ -121,7 +121,7 @@ public function test_returns_unchanged_content( $block_content, $block ) { * * @return array */ - public function data_returns_unchanged_content() { + public static function data_returns_unchanged_content() { return array( 'no custom CSS class in attrs' => array( 'block_content' => '
Test content
', diff --git a/tests/phpunit/tests/block-supports/wpRenderCustomCssSupportStyles.php b/tests/phpunit/tests/block-supports/wpRenderCustomCssSupportStyles.php index 2cb7e334a2fa2..b4e00aeacadac 100644 --- a/tests/phpunit/tests/block-supports/wpRenderCustomCssSupportStyles.php +++ b/tests/phpunit/tests/block-supports/wpRenderCustomCssSupportStyles.php @@ -70,7 +70,7 @@ public function test_adds_class_name( $block_name, $supports, $parsed_block ) { * * @return array */ - public function data_adds_class_name() { + public static function data_adds_class_name() { return array( 'class name is added when custom CSS is present' => array( 'block_name' => 'test/custom-css-block', @@ -188,7 +188,7 @@ public function test_does_not_add_class_name( $block_name, $supports, $parsed_bl * * @return array */ - public function data_does_not_add_class_name() { + public static function data_does_not_add_class_name() { return array( 'support is disabled' => array( 'block_name' => 'test/custom-css-disabled', diff --git a/tests/phpunit/tests/block-supports/wpRenderDimensionsSupport.php b/tests/phpunit/tests/block-supports/wpRenderDimensionsSupport.php index 7296ea4668b7b..a3452df1ec073 100644 --- a/tests/phpunit/tests/block-supports/wpRenderDimensionsSupport.php +++ b/tests/phpunit/tests/block-supports/wpRenderDimensionsSupport.php @@ -119,7 +119,7 @@ public function test_dimensions_block_support( $theme_name, $block_name, $dimens * * @return array */ - public function data_dimensions_block_support() { + public static function data_dimensions_block_support() { return array( 'aspect ratio style is applied, with min-height and height unset' => array( 'theme_name' => 'block-theme-child-with-fluid-typography', diff --git a/tests/phpunit/tests/block-supports/wpRenderElementsSupport.php b/tests/phpunit/tests/block-supports/wpRenderElementsSupport.php index ad60844813188..aae61805ab5f0 100644 --- a/tests/phpunit/tests/block-supports/wpRenderElementsSupport.php +++ b/tests/phpunit/tests/block-supports/wpRenderElementsSupport.php @@ -228,7 +228,7 @@ public function test_elements_block_support_class_with_duplicate_blocks(): void * * @return array */ - public function data_elements_block_support_class() { + public static function data_elements_block_support_class() { $color_styles = array( 'text' => 'var:preset|color|vivid-red', 'background' => '#fff', diff --git a/tests/phpunit/tests/block-supports/wpRenderElementsSupportStyles.php b/tests/phpunit/tests/block-supports/wpRenderElementsSupportStyles.php index 386d2a0041159..cc36a4ee52cf0 100644 --- a/tests/phpunit/tests/block-supports/wpRenderElementsSupportStyles.php +++ b/tests/phpunit/tests/block-supports/wpRenderElementsSupportStyles.php @@ -130,7 +130,7 @@ public function test_elements_block_support_styles_with_duplicate_blocks(): void * * @return array */ - public function data_elements_block_support_styles() { + public static function data_elements_block_support_styles() { $color_styles = array( 'text' => 'var:preset|color|vivid-red', 'background' => '#fff', diff --git a/tests/phpunit/tests/block-supports/wpRenderPositionSupport.php b/tests/phpunit/tests/block-supports/wpRenderPositionSupport.php index 94032a7b024a3..a331c810e64e0 100644 --- a/tests/phpunit/tests/block-supports/wpRenderPositionSupport.php +++ b/tests/phpunit/tests/block-supports/wpRenderPositionSupport.php @@ -132,7 +132,7 @@ public function test_position_block_support( $theme_name, $block_name, $position * * @return array */ - public function data_position_block_support() { + public static function data_position_block_support() { return array( 'sticky position style is applied' => array( 'theme_name' => 'block-theme-child-with-fluid-typography', diff --git a/tests/phpunit/tests/block-supports/wpStripCustomCssFromBlocks.php b/tests/phpunit/tests/block-supports/wpStripCustomCssFromBlocks.php index 4aed7f1841fb0..7cdba49d33cde 100644 --- a/tests/phpunit/tests/block-supports/wpStripCustomCssFromBlocks.php +++ b/tests/phpunit/tests/block-supports/wpStripCustomCssFromBlocks.php @@ -30,7 +30,7 @@ public function test_strips_css_from_blocks( $content, $message ) { * * @return array */ - public function data_strips_css_from_blocks() { + public static function data_strips_css_from_blocks() { return array( 'single block' => array( 'content' => '

Hello

', From 66e0f0b3f2933124ad9b6e97860302533afbf5c4 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 19:14:32 +0000 Subject: [PATCH 015/236] Tests: Make canonical redirect test data providers static. Declare the data providers in `tests/phpunit/tests/canonical/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions. Developed in: https://github.com/WordPress/wordpress-develop/pull/14399 Props rejaulalomkhan. See #66211. git-svn-id: https://develop.svn.wordpress.org/trunk@64450 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/canonical/category.php | 2 +- tests/phpunit/tests/canonical/customRules.php | 2 +- tests/phpunit/tests/canonical/noRewrite.php | 4 ++-- tests/phpunit/tests/canonical/pageOnFront.php | 2 +- tests/phpunit/tests/canonical/sitemaps.php | 2 +- tests/phpunit/tests/canonical/stripFragmentFromUrl.php | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/tests/canonical/category.php b/tests/phpunit/tests/canonical/category.php index 9619d708ca50f..2aaa5b61e1379 100644 --- a/tests/phpunit/tests/canonical/category.php +++ b/tests/phpunit/tests/canonical/category.php @@ -31,7 +31,7 @@ public function test_canonical_category( $test_url, $expected, $ticket = 0, $exp $this->assertCanonical( $test_url, $expected, $ticket, $expected_doing_it_wrong ); } - public function data_canonical_category() { + public static function data_canonical_category() { /* * Data format: * [0]: Test URL. diff --git a/tests/phpunit/tests/canonical/customRules.php b/tests/phpunit/tests/canonical/customRules.php index b76f5d4879a37..ee4fc7d17edf8 100644 --- a/tests/phpunit/tests/canonical/customRules.php +++ b/tests/phpunit/tests/canonical/customRules.php @@ -22,7 +22,7 @@ public function test( $test_url, $expected, $ticket = 0, $expected_doing_it_wron $this->assertCanonical( $test_url, $expected, $ticket, $expected_doing_it_wrong ); } - public function data() { + public static function data() { /* * Data format: * [0]: Test URL. diff --git a/tests/phpunit/tests/canonical/noRewrite.php b/tests/phpunit/tests/canonical/noRewrite.php index e48440a8cfffe..f4895332c2a87 100644 --- a/tests/phpunit/tests/canonical/noRewrite.php +++ b/tests/phpunit/tests/canonical/noRewrite.php @@ -28,7 +28,7 @@ public function test( $test_url, $expected, $ticket = 0, $expected_doing_it_wron $this->assertCanonical( $test_url, $expected, $ticket, $expected_doing_it_wrong ); } - public function data() { + public static function data() { /* * Test URL. * [0]: Test URL. @@ -303,7 +303,7 @@ static function () use ( $wp_home ) { * * @return array[] */ - public function data_missing_host_header() { + public static function data_missing_host_header() { return array( 'no port' => array( 'wp_home' => 'http://example.com', diff --git a/tests/phpunit/tests/canonical/pageOnFront.php b/tests/phpunit/tests/canonical/pageOnFront.php index e8833dd660bc1..1fda823de2519 100644 --- a/tests/phpunit/tests/canonical/pageOnFront.php +++ b/tests/phpunit/tests/canonical/pageOnFront.php @@ -39,7 +39,7 @@ public function test( $test_url, $expected, $ticket = 0, $expected_doing_it_wron $this->assertCanonical( $test_url, $expected, $ticket, $expected_doing_it_wrong ); } - public function data() { + public static function data() { /* * Data format: * [0]: Test URL. diff --git a/tests/phpunit/tests/canonical/sitemaps.php b/tests/phpunit/tests/canonical/sitemaps.php index 1ec0c8a0a81ee..bd03baae8467d 100644 --- a/tests/phpunit/tests/canonical/sitemaps.php +++ b/tests/phpunit/tests/canonical/sitemaps.php @@ -104,7 +104,7 @@ public function test_sitemaps_canonical_ugly_redirects( $test_url, $expected ) { * @type string $1 The expected canonical URL. * } */ - public function data_sitemaps_canonical_ugly_redirects() { + public static function data_sitemaps_canonical_ugly_redirects() { return array( // Ugly permalinks remain ugly. array( '/?sitemap=index', '/?sitemap=index' ), diff --git a/tests/phpunit/tests/canonical/stripFragmentFromUrl.php b/tests/phpunit/tests/canonical/stripFragmentFromUrl.php index efb54d26a2030..5c188bd5c3637 100644 --- a/tests/phpunit/tests/canonical/stripFragmentFromUrl.php +++ b/tests/phpunit/tests/canonical/stripFragmentFromUrl.php @@ -27,7 +27,7 @@ public function test_strip_fragment_from_url( $test_url, $expected ) { * @type string $1 The expected canonical URL. * } */ - public function data_strip_fragment_from_url() { + public static function data_strip_fragment_from_url() { return array( array( '//example.com', '//example.com' ), array( 'http://example.com', 'http://example.com' ), From 3cf871247c2f15899268138b0e1c9b28097cdd8f Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 19:20:38 +0000 Subject: [PATCH 016/236] Tests: Cover REST page response preparation. Replace the empty `test_prepare_item()` stub with assertions for page fields in the edit context and the `self`, `collection`, and `about` links returned by `WP_REST_Posts_Controller::prepare_item_for_response()`. Developed in: https://github.com/WordPress/wordpress-develop/pull/14384 Props rejaulalomkhan, huzaifaalmesbah. See #40538. git-svn-id: https://develop.svn.wordpress.org/trunk@64451 602fd350-edb4-49c9-b593-d223f7449a82 --- .../tests/rest-api/rest-pages-controller.php | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/tests/rest-api/rest-pages-controller.php b/tests/phpunit/tests/rest-api/rest-pages-controller.php index 3aabf5dfc4e4e..12badd6d9c5a0 100644 --- a/tests/phpunit/tests/rest-api/rest-pages-controller.php +++ b/tests/phpunit/tests/rest-api/rest-pages-controller.php @@ -614,10 +614,45 @@ public function test_delete_item() { } /** - * @doesNotPerformAssertions + * @ticket 40538 */ public function test_prepare_item() { - // Controller does not implement prepare_item(). + wp_set_current_user( self::$editor_id ); + + $page_id = self::factory()->post->create( + array( + 'post_type' => 'page', + 'post_title' => 'Sample Page', + 'post_content' => 'Sample content', + 'post_status' => 'publish', + 'post_author' => self::$editor_id, + ) + ); + + $endpoint = new WP_REST_Posts_Controller( 'page' ); + $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/pages/%d', $page_id ) ); + $request->set_param( 'context', 'edit' ); + $page = get_post( $page_id ); + $response = $endpoint->prepare_item_for_response( $page, $request ); + + $this->assertInstanceOf( WP_REST_Response::class, $response ); + $this->assertSame( 200, $response->get_status() ); + + $data = $response->get_data(); + $this->assertSame( $page_id, $data['id'] ); + $this->assertSame( 'page', $data['type'] ); + $this->assertSame( 'Sample Page', $data['title']['raw'] ); + $this->assertSame( 'Sample content', $data['content']['raw'] ); + $this->assertSame( 'publish', $data['status'] ); + $this->assertSame( self::$editor_id, $data['author'] ); + $this->assertSame( $page->post_excerpt, $data['excerpt']['raw'] ); + $this->assertSame( 0, $data['parent'] ); + $this->assertSame( 0, $data['menu_order'] ); + + $links = test_rest_expand_compact_links( $response->get_links() ); + $this->assertSame( rest_url( sprintf( 'wp/v2/pages/%d', $page_id ) ), $links['self'][0]['href'] ); + $this->assertSame( rest_url( 'wp/v2/pages' ), $links['collection'][0]['href'] ); + $this->assertSame( rest_url( 'wp/v2/types/page' ), $links['about'][0]['href'] ); } public function test_prepare_item_limit_fields() { From 27f834b26a8208d5d4c71b365e3bef1ddcf88c77 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 19:21:48 +0000 Subject: [PATCH 017/236] Tests: Cover navigation fallback response preparation. Replace the empty `test_prepare_item()` stub with assertions for the navigation ID, response status, and embeddable `self` link returned by `WP_REST_Navigation_Fallback_Controller::prepare_item_for_response()`. Verify that requesting only `id` through `_fields` omits links. Developed in: https://github.com/WordPress/wordpress-develop/pull/14385 Props rejaulalomkhan. See #40538, #66073. git-svn-id: https://develop.svn.wordpress.org/trunk@64452 602fd350-edb4-49c9-b593-d223f7449a82 --- .../rest-navigation-fallback-controller.php | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/tests/rest-api/rest-navigation-fallback-controller.php b/tests/phpunit/tests/rest-api/rest-navigation-fallback-controller.php index c481ab64a5681..476f7dfe9ac6a 100644 --- a/tests/phpunit/tests/rest-api/rest-navigation-fallback-controller.php +++ b/tests/phpunit/tests/rest-api/rest-navigation-fallback-controller.php @@ -191,10 +191,55 @@ private function get_navigations_in_database() { } /** - * @doesNotPerformAssertions + * @ticket 40538 + * + * @covers WP_REST_Navigation_Fallback_Controller::prepare_item_for_response */ public function test_prepare_item() { - // Covered by the core test. + $post_id = self::factory()->post->create( + array( + 'post_type' => 'wp_navigation', + 'post_title' => 'Test Navigation Menu', + ) + ); + + $post = get_post( $post_id ); + $controller = new WP_REST_Navigation_Fallback_Controller(); + $request = new WP_REST_Request( 'GET', '/wp-block-editor/v1/navigation-fallback' ); + + $response = $controller->prepare_item_for_response( $post, $request ); + + $this->assertInstanceOf( WP_REST_Response::class, $response ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( array( 'id' => $post_id ), $response->get_data() ); + + $links = $response->get_links(); + $this->assertArrayHasKey( 'self', $links ); + $this->assertSame( rest_url( rest_get_route_for_post( $post_id ) ), $links['self'][0]['href'] ); + $this->assertTrue( $links['self'][0]['attributes']['embeddable'] ); + } + + /** + * @ticket 40538 + * + * @covers WP_REST_Navigation_Fallback_Controller::prepare_item_for_response + */ + public function test_prepare_item_limit_fields() { + $post_id = self::factory()->post->create( + array( + 'post_type' => 'wp_navigation', + 'post_title' => 'Test Navigation Menu', + ) + ); + + $post = get_post( $post_id ); + $controller = new WP_REST_Navigation_Fallback_Controller(); + $request = new WP_REST_Request( 'GET', '/wp-block-editor/v1/navigation-fallback' ); + $request->set_param( '_fields', 'id' ); + + $response = $controller->prepare_item_for_response( $post, $request ); + $this->assertSame( array( 'id' => $post_id ), $response->get_data() ); + $this->assertEmpty( $response->get_links() ); } /** From 1a95edb1d1a194db29406fbc98153b8dd6b59e8a Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:09:40 +0000 Subject: [PATCH 018/236] Tests: Cover whitespace and character references in `class_list()`. Check leading and trailing whitespace, whitespace-only values, encoded separators, and character-reference boundaries in `class_list()`. Prevent empty class names and incorrect decoding from passing unnoticed. Developed in: https://github.com/WordPress/wordpress-develop/pull/14300 Props jonsurrell. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64453 602fd350-edb4-49c9-b593-d223f7449a82 --- .../tests/html-api/wpHtmlTagProcessor.php | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php index 7f59239608d6b..d45199373f529 100644 --- a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php +++ b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php @@ -2688,6 +2688,62 @@ public function test_class_list_null_bytes_replaced() { $this->assertSame( array( 'a', "\u{FFFD}", "b\u{FFFD}", "\u{FFFD}c\u{FFFD}" ), $found_classes ); } + /** + * @ticket 59209 + * + * @covers WP_HTML_Tag_Processor::class_list + * + * @dataProvider data_class_list + * + * @param string $html HTML containing a DIV with a class attribute. + * @param string[] $expected_class_names Class names class_list() should yield. + */ + public function test_class_list( string $html, array $expected_class_names ): void { + $processor = new WP_HTML_Tag_Processor( $html ); + $this->assertTrue( $processor->next_tag(), 'Should have found the DIV tag.' ); + + $this->assertSame( + $expected_class_names, + iterator_to_array( $processor->class_list() ), + 'Should have yielded the expected class names.' + ); + } + + /** + * Data provider. + * + * @return array + */ + public static function data_class_list(): array { + return array( + 'Leading whitespace' => array( "
", array( 'foo' ) ), + 'Trailing whitespace' => array( "
", array( 'foo' ) ), + 'Only spaces' => array( "
", array() ), + 'Only mixed whitespace' => array( "
", array() ), + 'Form feed separator' => array( "
", array( 'a', 'b' ) ), + 'Encoded carriage return separator' => array( "
", array( 'a', 'b' ) ), + 'Encoded space separator' => array( "
", array( 'a', 'b' ) ), + 'Encoded leading and trailing whitespace' => array( "
", array( 'a' ) ), + 'Vertical tab is not a separator' => array( "
", array( "a\vb" ) ), + 'No-break space is not a separator' => array( "
", array( "a\u{A0}b" ) ), + 'Legacy reference at end' => array( "
", array( '&' ) ), + 'Legacy reference before space' => array( "
", array( '&', 'x' ) ), + 'Legacy reference before hyphen' => array( "
", array( '&-x' ) ), + 'Legacy reference before ampersand' => array( "
", array( '<>' ) ), + 'Uppercase legacy reference' => array( "
", array( '&' ) ), + 'Legacy reference before letter' => array( "
", array( '&x' ) ), + 'Legacy reference before digit' => array( "
", array( '©2026' ) ), + 'Legacy reference before equals sign' => array( "
", array( '&=' ) ), + 'Legacy prefix of a longer reference' => array( "
", array( '¬in' ) ), + 'Legacy and full forms are duplicates' => array( "
", array( '&' ) ), + 'Non-legacy reference without semicolon' => array( "
", array( '&hellip' ) ), + 'Unknown reference' => array( "
", array( '&foo;' ) ), + 'Decimal reference without semicolon' => array( "
", array( 'a', 'b' ) ), + 'Hex reference without semicolon' => array( "
", array( 'a', 'g' ) ), + 'Bare ampersand' => array( "
", array( '&' ) ), + ); + } + /** * Ensures that the tag processor matches class names with null bytes correctly. * From c7c91ef28ffc4650ce7b5031c1367599ff2886a1 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:11:34 +0000 Subject: [PATCH 019/236] Tests: Add coverage for `WP_Importer` and `get_cli_args()`. Verify importer mappings, blog and user selection, request options, quota handling, and command-line argument parsing. Cover the 100-row boundary in `get_imported_posts()`. Developed in: https://github.com/WordPress/wordpress-develop/pull/14327 Props huzaifaalmesbah. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64454 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/admin/wpImporter.php | 533 +++++++++++++++++++++++ 1 file changed, 533 insertions(+) create mode 100644 tests/phpunit/tests/admin/wpImporter.php diff --git a/tests/phpunit/tests/admin/wpImporter.php b/tests/phpunit/tests/admin/wpImporter.php new file mode 100644 index 0000000000000..f5620f01d6d29 --- /dev/null +++ b/tests/phpunit/tests/admin/wpImporter.php @@ -0,0 +1,533 @@ +had_argv = array_key_exists( 'argv', $_SERVER ); + $this->orig_argv = $this->had_argv ? $_SERVER['argv'] : null; + } + + public function tear_down() { + if ( $this->had_argv ) { + $_SERVER['argv'] = $this->orig_argv; + } else { + unset( $_SERVER['argv'] ); + } + + parent::tear_down(); + } + + /** + * Tests that imported permalinks are mapped to their post IDs for the given importer and blog. + * + * @ticket 65819 + * + * @covers WP_Importer::get_imported_posts + */ + public function test_get_imported_posts_maps_permalinks_to_post_ids() { + $first = self::factory()->post->create(); + $second = self::factory()->post->create(); + + add_post_meta( $first, 'blogger_7_permalink', '/2026/01/first.html' ); + add_post_meta( $second, 'blogger_7_permalink', '/2026/02/second.html' ); + add_post_meta( $second, 'blogger_8_permalink', '/other-blog.html' ); + add_post_meta( $second, 'other_7_permalink', '/other-importer.html' ); + + $this->assertSame( + array( + '/2026/01/first.html' => $first, + '/2026/02/second.html' => $second, + ), + ( new WP_Importer() )->get_imported_posts( 'blogger', 7 ) + ); + } + + /** + * Tests that imported permalinks are read in chunks of 100 until none are left. + * + * @ticket 65819 + * + * @covers WP_Importer::get_imported_posts + */ + public function test_get_imported_posts_reads_all_chunks() { + global $wpdb; + + $post_id = self::factory()->post->create(); + + for ( $i = 1; $i <= 101; $i++ ) { + $wpdb->insert( + $wpdb->postmeta, + array( + 'post_id' => $post_id, + 'meta_key' => 'blogger_7_permalink', + 'meta_value' => "/post-{$i}.html", + ) + ); + } + + $imported = ( new WP_Importer() )->get_imported_posts( 'blogger', 7 ); + + $this->assertCount( 101, $imported, 'Permalinks after the first chunk should be included.' ); + $this->assertSame( $post_id, $imported['/post-101.html'] ); + } + + /** + * Tests that no imported posts gives an empty array. + * + * @ticket 65819 + * + * @covers WP_Importer::get_imported_posts + */ + public function test_get_imported_posts_returns_empty_array_without_imports() { + $this->assertSame( array(), ( new WP_Importer() )->get_imported_posts( 'blogger', 7 ) ); + } + + /** + * Tests the number of imported permalinks for the given importer and blog. + * + * @ticket 65819 + * + * @covers WP_Importer::count_imported_posts + */ + public function test_count_imported_posts() { + $post_id = self::factory()->post->create(); + + add_post_meta( $post_id, 'blogger_7_permalink', '/first.html' ); + add_post_meta( $post_id, 'blogger_7_permalink', '/second.html' ); + add_post_meta( $post_id, 'blogger_8_permalink', '/other-blog.html' ); + + $importer = new WP_Importer(); + + $this->assertSame( 2, $importer->count_imported_posts( 'blogger', 7 ), 'Permalinks for the blog should be counted.' ); + $this->assertSame( 0, $importer->count_imported_posts( 'blogger', 9 ), 'A blog without imports should have none.' ); + } + + /** + * Tests that imported comments are mapped from their source comment ID for the given blog. + * + * @ticket 65819 + * + * @covers WP_Importer::get_imported_comments + */ + public function test_get_imported_comments_maps_source_ids_for_blog() { + $post_id = self::factory()->post->create(); + + $first = self::factory()->comment->create( + array( + 'comment_post_ID' => $post_id, + 'comment_agent' => '7-15', + ) + ); + $second = self::factory()->comment->create( + array( + 'comment_post_ID' => $post_id, + 'comment_agent' => '7-16', + ) + ); + self::factory()->comment->create( + array( + 'comment_post_ID' => $post_id, + 'comment_agent' => '8-17', + ) + ); + + $this->assertSame( + array( + 15 => $first, + 16 => $second, + ), + ( new WP_Importer() )->get_imported_comments( '7' ) + ); + } + + /** + * Tests that a numeric blog ID is returned as an integer. + * + * @ticket 65819 + * + * @covers WP_Importer::set_blog + * + * @group ms-excluded + */ + public function test_set_blog_returns_numeric_blog_id() { + $this->assertSame( 1, ( new WP_Importer() )->set_blog( '1' ) ); + } + + /** + * Tests that set_blog() switches to the blog on multisite, resolving it by ID or URL. + * + * @ticket 65819 + * + * @covers WP_Importer::set_blog + * + * @group ms-required + * + * @dataProvider data_set_blog_on_multisite + * + * @param string $blog Blog ID placeholder or URL passed to set_blog(). + */ + public function test_set_blog_switches_to_blog_on_multisite( $blog ) { + $blog_id = self::factory()->blog->create( + array( + 'domain' => 'importer.example.org', + 'path' => '/target/', + ) + ); + + $blog = str_replace( '%id%', $blog_id, $blog ); + + $result = ( new WP_Importer() )->set_blog( $blog ); + + $current = get_current_blog_id(); + restore_current_blog(); + + $this->assertSame( $blog_id, $result, 'The blog ID should be returned.' ); + $this->assertSame( $blog_id, $current, 'The blog should be switched to.' ); + } + + /** + * Data provider. + * + * @return array[] + */ + public static function data_set_blog_on_multisite() { + return array( + 'numeric ID' => array( '%id%' ), + 'URL with scheme' => array( 'https://importer.example.org/target/' ), + 'URL without scheme' => array( 'importer.example.org/target/' ), + ); + } + + /** + * Tests that set_user() sets the current user by ID or login. + * + * @ticket 65819 + * + * @covers WP_Importer::set_user + * + * @dataProvider data_set_user + * + * @param bool $by_login Whether to pass the user login instead of the ID. + */ + public function test_set_user( $by_login ) { + $user_id = self::factory()->user->create( array( 'user_login' => 'importer_user' ) ); + + $this->assertSame( $user_id, ( new WP_Importer() )->set_user( $by_login ? 'importer_user' : (string) $user_id ) ); + $this->assertSame( $user_id, get_current_user_id(), 'The user should be set as the current user.' ); + } + + /** + * Data provider. + * + * @return array[] + */ + public static function data_set_user() { + return array( + 'user ID' => array( false ), + 'user login' => array( true ), + ); + } + + /** + * Tests that cmpr_strlen() sorts the longest string first. + * + * @ticket 65819 + * + * @covers WP_Importer::cmpr_strlen + */ + public function test_cmpr_strlen_sorts_longest_first() { + $importer = new WP_Importer(); + $strings = array( 'bb', 'a', 'dddd', 'ccc' ); + + usort( $strings, array( $importer, 'cmpr_strlen' ) ); + + $this->assertSame( array( 'dddd', 'ccc', 'bb', 'a' ), $strings, 'Strings should be sorted by length, longest first.' ); + $this->assertSame( 0, $importer->cmpr_strlen( 'ab', 'cd' ), 'Strings of the same length should compare equal.' ); + $this->assertSame( 2, $importer->cmpr_strlen( 'a', 'abc' ), 'A shorter first string should sort after the longer one.' ); + } + + /** + * Tests the request made by get_page(). + * + * @ticket 65819 + * + * @covers WP_Importer::get_page + * @covers WP_Importer::bump_request_timeout + * + * @dataProvider data_get_page_requests + * + * @param string $username Username. + * @param string $password Password. + * @param bool $head Whether to make a HEAD request. + * @param string $method Expected request method. + * @param string|null $authorization Expected Authorization header, or null for none. + */ + public function test_get_page_request( $username, $password, $head, $method, $authorization ) { + $requests = array(); + + add_filter( + 'pre_http_request', + static function ( $response, $args, $url ) use ( &$requests ) { + $requests[] = array( $url, $args ); + + return array( + 'headers' => array(), + 'body' => 'page body', + 'response' => array( + 'code' => 200, + 'message' => 'OK', + ), + 'cookies' => array(), + ); + }, + 10, + 3 + ); + + $response = ( new WP_Importer() )->get_page( 'https://example.org/feed', $username, $password, $head ); + + $this->assertSame( 'page body', wp_remote_retrieve_body( $response ), 'The response should be returned.' ); + $this->assertCount( 1, $requests, 'One request should be made.' ); + + list( $url, $args ) = $requests[0]; + + $this->assertSame( 'https://example.org/feed', $url, 'The URL did not match.' ); + $this->assertSame( $method, $args['method'], 'The request method did not match.' ); + $this->assertSame( 60, $args['timeout'], 'The request timeout should be bumped.' ); + $this->assertTrue( $args['reject_unsafe_urls'], 'The request should be a safe request.' ); + + if ( null === $authorization ) { + $this->assertArrayNotHasKey( 'Authorization', $args['headers'], 'No Authorization header should be sent.' ); + } else { + $this->assertSame( $authorization, $args['headers']['Authorization'], 'The Authorization header did not match.' ); + } + } + + /** + * Data provider. + * + * @return array[] + */ + public static function data_get_page_requests() { + return array( + 'GET without credentials' => array( '', '', false, 'GET', null ), + 'HEAD request' => array( '', '', true, 'HEAD', null ), + 'truthy head is not HEAD' => array( '', '', 1, 'GET', null ), + 'with credentials' => array( 'admin', 'secret', false, 'GET', 'Basic YWRtaW46c2VjcmV0' ), + 'username only' => array( 'admin', '', false, 'GET', null ), + 'password only' => array( '', 'secret', false, 'GET', null ), + ); + } + + /** + * Tests that bump_request_timeout() always returns 60 seconds. + * + * @ticket 65819 + * + * @covers WP_Importer::bump_request_timeout + */ + public function test_bump_request_timeout() { + $this->assertSame( 60, ( new WP_Importer() )->bump_request_timeout( 5 ) ); + } + + /** + * Tests that the user is never over quota on a single site. + * + * @ticket 65819 + * + * @covers WP_Importer::is_user_over_quota + * + * @group ms-excluded + */ + public function test_is_user_over_quota_on_single_site() { + $this->assertFalse( ( new WP_Importer() )->is_user_over_quota() ); + } + + /** + * Tests the quota check on multisite. + * + * @ticket 65819 + * + * @covers WP_Importer::is_user_over_quota + * + * @group ms-required + * + * @dataProvider data_quota_usage + * + * @param int $space_used Space used, in megabytes. + * @param bool $expected Whether the user should be over quota. + * @param string $output Expected output. + */ + public function test_is_user_over_quota_on_multisite( $space_used, $expected, $output ) { + require_once ABSPATH . 'wp-admin/includes/ms.php'; + + update_site_option( 'upload_space_check_disabled', 0 ); + add_filter( + 'get_space_allowed', + static function () { + return 10; + } + ); + add_filter( + 'pre_get_space_used', + static function () use ( $space_used ) { + return $space_used; + } + ); + + $this->expectOutputString( $output ); + $this->assertSame( $expected, ( new WP_Importer() )->is_user_over_quota() ); + } + + /** + * Data provider. + * + * @return array[] + */ + public static function data_quota_usage() { + return array( + 'under quota' => array( 5, false, '' ), + 'over quota' => array( 20, true, 'Sorry, you have used your space allocation of 10 MB. Please delete some files to upload more files.' ), + ); + } + + /** + * Tests that runs of whitespace are replaced with a single space. + * + * @ticket 65819 + * + * @covers WP_Importer::min_whitespace + * + * @dataProvider data_min_whitespace + * + * @param string $text Text. + * @param string $expected Expected text. + */ + public function test_min_whitespace( $text, $expected ) { + $this->assertSame( $expected, ( new WP_Importer() )->min_whitespace( $text ) ); + } + + /** + * Data provider. + * + * @return array[] + */ + public static function data_min_whitespace() { + return array( + 'mixed whitespace' => array( "one \r\n\ttwo three", 'one two three' ), + 'single spaces' => array( 'one two', 'one two' ), + 'leading and trailing' => array( "\n one \t", ' one ' ), + 'no whitespace' => array( 'one', 'one' ), + 'empty string' => array( '', '' ), + 'zero string' => array( '0', '0' ), + ); + } + + /** + * Tests that stop_the_insanity() resets the query log and the action counts. + * + * @ticket 65819 + * + * @covers WP_Importer::stop_the_insanity + */ + public function test_stop_the_insanity_resets_queries_and_actions() { + global $wpdb, $wp_actions; + + $orig_queries = $wpdb->queries; + $orig_wp_actions = $wp_actions; + + try { + $wpdb->queries = array( array( 'SELECT 1', 0.1, 'caller' ) ); + do_action( 'test_stop_the_insanity' ); + + ( new WP_Importer() )->stop_the_insanity(); + + $this->assertSame( array(), $wpdb->queries, 'The query log should be emptied.' ); + $this->assertSame( array(), $wp_actions, 'The action counts should be emptied.' ); + } finally { + $wpdb->queries = $orig_queries; + $wp_actions = $orig_wp_actions; + } + } + + /** + * Tests the command line arguments returned by get_cli_args(). + * + * @ticket 65819 + * + * @covers ::get_cli_args + * + * @dataProvider data_get_cli_args + * + * @param array $argv Command line arguments, including the script name. + * @param string $param Parameter name. + * @param string|true|null $expected Expected value. + */ + public function test_get_cli_args( $argv, $param, $expected ) { + $_SERVER['argv'] = $argv; + + $this->assertSame( $expected, get_cli_args( $param ) ); + } + + /** + * Data provider. + * + * @return array[] + */ + public static function data_get_cli_args() { + return array( + 'long option with a value' => array( array( 'import.php', '--blog=7' ), 'blog', '7' ), + 'long option without a value' => array( array( 'import.php', '--verbose' ), 'verbose', true ), + 'value after a long option' => array( array( 'import.php', '--user', 'admin' ), 'user', 'admin' ), + 'short options' => array( array( 'import.php', '-vq' ), 'q', true ), + 'value after short options' => array( array( 'import.php', '-vq', 'quiet' ), 'q', 'quiet' ), + 'later option overrides' => array( array( 'import.php', '--blog=1', '--blog=2' ), 'blog', '2' ), + 'script name is ignored' => array( array( '--blog=7' ), 'blog', null ), + 'value without an option' => array( array( 'import.php', 'orphan' ), 'orphan', null ), + 'missing optional parameter' => array( array( 'import.php', '--blog=7' ), 'user', null ), + 'empty value' => array( array( 'import.php', '--blog=' ), 'blog', '' ), + 'zero value' => array( array( 'import.php', '--blog=0' ), 'blog', '0' ), + ); + } + + /** + * Tests that get_cli_args() returns null when `$_SERVER['argv']` is not an array. + * + * @ticket 65819 + * + * @covers ::get_cli_args + */ + public function test_get_cli_args_without_argv_array() { + $_SERVER['argv'] = 'not an array'; + + $this->assertNull( get_cli_args( 'blog' ) ); + } +} From b877d725eb390da93c6019cf19802aa8bb798d89 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:12:48 +0000 Subject: [PATCH 020/236] Tests: Cover serialized parent block helpers. Verify that `extract_serialized_parent_block()` retains the outer block and `remove_serialized_parent_block()` returns its inner content across nested blocks, attributes, comments, and whitespace. Developed in: https://github.com/WordPress/wordpress-develop/pull/14331 Props rejaulalomkhan. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64455 602fd350-edb4-49c9-b593-d223f7449a82 --- .../tests/blocks/serializedParentBlock.php | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 tests/phpunit/tests/blocks/serializedParentBlock.php diff --git a/tests/phpunit/tests/blocks/serializedParentBlock.php b/tests/phpunit/tests/blocks/serializedParentBlock.php new file mode 100644 index 0000000000000..758a0747a44cc --- /dev/null +++ b/tests/phpunit/tests/blocks/serializedParentBlock.php @@ -0,0 +1,83 @@ +assertSame( $parent_block, extract_serialized_parent_block( $serialized_block ) ); + } + + /** + * Tests that the parent block's delimiters are dropped and its inner content is kept. + * + * @ticket 65819 + * + * @covers ::remove_serialized_parent_block + * + * @dataProvider data_serialized_parent_blocks + * + * @param string $serialized_block Serialized parent block. + * @param string $parent_block Unused; the parent block without its inner content. + * @param string $inner_content Expected inner content. + */ + public function test_remove_serialized_parent_block( $serialized_block, $parent_block, $inner_content ) { + $this->assertSame( $inner_content, remove_serialized_parent_block( $serialized_block ) ); + } + + /** + * Data provider. + * + * @return array + */ + public static function data_serialized_parent_blocks() { + return array( + 'parent with inner blocks' => array( + '

Hello

', + '', + '

Hello

', + ), + 'parent with attributes' => array( + '
Text
', + '', + '
Text
', + ), + 'parent without inner content' => array( + '', + '', + '', + ), + 'nested block of the same type' => array( + '

Inner

', + '', + '

Inner

', + ), + 'inner content with an HTML comment' => array( + '', + '', + '', + ), + 'whitespace around inner content' => array( + "\n

Text

\n", + '', + "\n

Text

\n", + ), + ); + } +} From d57569e42dc57dd050a5da5b3997578749bb6b96 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:14:15 +0000 Subject: [PATCH 021/236] Tests: Add coverage for `get_category()`. Covers category lookup by ID and object, array output, edit-con filtering, and invalid or wrong-taxonomy inputs. Developed in: https://github.com/WordPress/wordpress-develop/pull/14363 Props shailu25. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64456 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/category/getCategory.php | 187 +++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 tests/phpunit/tests/category/getCategory.php diff --git a/tests/phpunit/tests/category/getCategory.php b/tests/phpunit/tests/category/getCategory.php new file mode 100644 index 0000000000000..14a2505d2e73b --- /dev/null +++ b/tests/phpunit/tests/category/getCategory.php @@ -0,0 +1,187 @@ +category->create( + array( + 'name' => 'Parent Category', + 'slug' => 'parent-category', + ) + ); + + self::$category = $factory->category->create_and_get( + array( + 'name' => 'Child Category', + 'slug' => 'child-category', + 'description' => 'Category description', + 'parent' => self::$parent_id, + ) + ); + } + + /** + * Tests that get_category() returns a WP_Term object with backwards-compatible properties by default. + * + * @ticket 65819 + */ + public function test_returns_category_object_with_compat_properties() { + $category = get_category( self::$category->term_id ); + + $this->assertInstanceOf( WP_Term::class, $category ); + $this->assertSame( 'category', $category->taxonomy ); + $this->assertSame( 'raw', $category->filter ); + $this->assertSame( self::$category->term_id, $category->cat_ID ); + $this->assertSame( self::$category->count, $category->category_count ); + $this->assertSame( 'Category description', $category->category_description ); + $this->assertSame( 'Child Category', $category->cat_name ); + $this->assertSame( 'child-category', $category->category_nicename ); + $this->assertSame( self::$parent_id, $category->category_parent ); + } + + /** + * Tests that get_category() accepts a term object and populates backwards-compatible properties. + * + * @ticket 65819 + */ + public function test_accepts_category_object() { + $raw_object = (object) self::$category->to_array(); + + $category = get_category( $raw_object ); + + $this->assertInstanceOf( WP_Term::class, $category ); + $this->assertSame( self::$category->term_id, $category->cat_ID ); + $this->assertSame( 'Child Category', $category->cat_name ); + $this->assertSame( 'child-category', $category->category_nicename ); + $this->assertSame( self::$parent_id, $category->category_parent ); + } + + /** + * Tests that ARRAY_A output returns an associative array with backwards-compatible alias keys. + * + * @ticket 65819 + */ + public function test_returns_associative_array_with_compat_keys() { + $category = get_category( self::$category->term_id, ARRAY_A ); + + $this->assertIsArray( $category ); + $this->assertSame( self::$category->term_id, $category['term_id'] ); + $this->assertSame( self::$category->term_id, $category['cat_ID'] ); + $this->assertSame( self::$category->count, $category['category_count'] ); + $this->assertSame( 'Category description', $category['category_description'] ); + $this->assertSame( 'Child Category', $category['cat_name'] ); + $this->assertSame( 'child-category', $category['category_nicename'] ); + $this->assertSame( self::$parent_id, $category['category_parent'] ); + } + + /** + * Tests that ARRAY_N output returns a numerically indexed array of term values. + * + * @ticket 65819 + */ + public function test_returns_numeric_array() { + $category = get_category( self::$category->term_id, ARRAY_N ); + + $this->assertIsArray( $category ); + $this->assertSame( array_values( self::$category->to_array() ), $category ); + } + + /** + * Tests that the filter parameter sanitizes the returned category in the requested context. + * + * @ticket 65819 + */ + public function test_applies_filter_context() { + add_filter( + 'edit_category_name', + static function ( $name ) { + return $name . ' (edited)'; + } + ); + + $category = get_category( self::$category->term_id, OBJECT, 'edit' ); + + $this->assertInstanceOf( WP_Term::class, $category ); + $this->assertSame( 'edit', $category->filter ); + $this->assertSame( 'Child Category (edited)', $category->name ); + $this->assertSame( 'Child Category (edited)', $category->cat_name ); + } + + /** + * Tests that empty category values return an invalid_term WP_Error. + * + * @ticket 65819 + * + * @dataProvider data_empty_category_values + * + * @param mixed $empty_value Empty category input. + */ + public function test_returns_wp_error_for_empty_category( $empty_value ) { + $result = get_category( $empty_value ); + + $this->assertWPError( $result ); + $this->assertSame( 'invalid_term', $result->get_error_code() ); + } + + /** + * Data provider. + * + * @return array[] + */ + public static function data_empty_category_values() { + return array( + 'empty string' => array( '' ), + 'zero int' => array( 0 ), + 'zero string' => array( '0' ), + 'null' => array( null ), + 'false' => array( false ), + ); + } + + /** + * Tests that a non-existent category ID returns null. + * + * @ticket 65819 + */ + public function test_returns_null_for_non_existent_category() { + $this->assertNull( get_category( 99999999 ) ); + } + + /** + * Tests that a term ID belonging to another taxonomy returns null. + * + * @ticket 65819 + */ + public function test_returns_null_for_term_in_another_taxonomy() { + $tag_id = self::factory()->tag->create(); + + $this->assertNull( get_category( $tag_id ) ); + } +} From 696c1f43c3bd5a705dd3e826d09aba75fc8d2350 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:19:34 +0000 Subject: [PATCH 022/236] Tests: Add coverage for `cat_is_ancestor_of()`. Checks direct and indirect ancestry, unrelated categories, and term IDs from another taxonomy. Developed in: https://github.com/WordPress/wordpress-develop/pull/14364 Props shailu25. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64457 602fd350-edb4-49c9-b593-d223f7449a82 --- .../tests/category/catIsAncestorOf.php | 141 ++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 tests/phpunit/tests/category/catIsAncestorOf.php diff --git a/tests/phpunit/tests/category/catIsAncestorOf.php b/tests/phpunit/tests/category/catIsAncestorOf.php new file mode 100644 index 0000000000000..14a346d93cdca --- /dev/null +++ b/tests/phpunit/tests/category/catIsAncestorOf.php @@ -0,0 +1,141 @@ +category->create_and_get( + array( + 'name' => 'Grandparent Category', + ) + ); + + self::$parent = $factory->category->create_and_get( + array( + 'name' => 'Parent Category', + 'parent' => self::$grandparent->term_id, + ) + ); + + self::$child = $factory->category->create_and_get( + array( + 'name' => 'Child Category', + 'parent' => self::$parent->term_id, + ) + ); + + self::$unrelated = $factory->category->create_and_get( + array( + 'name' => 'Unrelated Category', + ) + ); + } + + /** + * Tests that cat_is_ancestor_of() returns true for direct and indirect descendants + * when given category IDs, WP_Term objects, or a mix of both. + * + * @ticket 65819 + */ + public function test_returns_true_for_direct_and_indirect_descendants() { + // Category IDs. + $this->assertTrue( cat_is_ancestor_of( self::$parent->term_id, self::$child->term_id ) ); + $this->assertTrue( cat_is_ancestor_of( self::$grandparent->term_id, self::$child->term_id ) ); + $this->assertTrue( cat_is_ancestor_of( self::$grandparent->term_id, self::$parent->term_id ) ); + + // Category objects. + $this->assertTrue( cat_is_ancestor_of( self::$parent, self::$child ) ); + $this->assertTrue( cat_is_ancestor_of( self::$grandparent, self::$child ) ); + + // Mixed ID and object inputs. + $this->assertTrue( cat_is_ancestor_of( self::$parent->term_id, self::$child ) ); + $this->assertTrue( cat_is_ancestor_of( self::$grandparent, self::$child->term_id ) ); + } + + /** + * Tests that cat_is_ancestor_of() returns false when the first category is not an ancestor. + * + * @ticket 65819 + */ + public function test_returns_false_for_non_ancestors() { + // Child is not an ancestor of its parent or grandparent. + $this->assertFalse( cat_is_ancestor_of( self::$child->term_id, self::$parent->term_id ) ); + $this->assertFalse( cat_is_ancestor_of( self::$child->term_id, self::$grandparent->term_id ) ); + $this->assertFalse( cat_is_ancestor_of( self::$child, self::$parent ) ); + + // A category is not an ancestor of itself. + $this->assertFalse( cat_is_ancestor_of( self::$parent->term_id, self::$parent->term_id ) ); + $this->assertFalse( cat_is_ancestor_of( self::$parent, self::$parent ) ); + + // Unrelated categories. + $this->assertFalse( cat_is_ancestor_of( self::$unrelated->term_id, self::$child->term_id ) ); + $this->assertFalse( cat_is_ancestor_of( self::$parent->term_id, self::$unrelated->term_id ) ); + + // Non-existent category IDs. + $this->assertFalse( cat_is_ancestor_of( 99999999, self::$child->term_id ) ); + $this->assertFalse( cat_is_ancestor_of( self::$parent->term_id, 99999999 ) ); + } + + /** + * Tests that cat_is_ancestor_of() returns false for hierarchical term IDs from another taxonomy. + * + * @ticket 65819 + */ + public function test_returns_false_for_term_ids_from_another_taxonomy() { + register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) ); + + $parent_term_id = self::factory()->term->create( + array( + 'taxonomy' => 'wptests_tax', + ) + ); + $child_term_id = self::factory()->term->create( + array( + 'taxonomy' => 'wptests_tax', + 'parent' => $parent_term_id, + ) + ); + + $this->assertFalse( cat_is_ancestor_of( $parent_term_id, $child_term_id ) ); + } +} From 2695d61a077f41b6883824e72a8571ee9034ccb3 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 17 Oct 2026 23:21:34 +0000 Subject: [PATCH 023/236] Database: Avoid a fatal error in `wpdb::load_col_info()` if the result is not set. This resolves an error if `mysqli_num_fields()` is called before a successful SELECT-type query is performed: {{{ mysqli_num_fields(): Argument #1 ($result) must be of type mysqli_result, false given }}} Developed in https://github.com/WordPress/wordpress-develop/pull/13099. Follow-up to r21472. Props joehorntw, akshat2802, mukesh27, rejaulalomkhan, SergeyBiryukov. Fixes #64130. git-svn-id: https://develop.svn.wordpress.org/trunk@64458 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wpdb.php | 2 +- tests/phpunit/tests/db.php | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/class-wpdb.php b/src/wp-includes/class-wpdb.php index 9537cdc57cf2c..07bc04e28edd8 100644 --- a/src/wp-includes/class-wpdb.php +++ b/src/wp-includes/class-wpdb.php @@ -3951,7 +3951,7 @@ protected function get_table_from_query( $query ) { * @since 3.5.0 */ protected function load_col_info() { - if ( $this->col_info ) { + if ( $this->col_info || ! $this->result instanceof mysqli_result ) { return; } diff --git a/tests/phpunit/tests/db.php b/tests/phpunit/tests/db.php index cd4de3353496d..55b80c3fbdae1 100644 --- a/tests/phpunit/tests/db.php +++ b/tests/phpunit/tests/db.php @@ -585,6 +585,40 @@ public function test_get_col_info() { $this->assertSame( $wpdb->users, $wpdb->get_col_info( 'table', 0 ) ); } + /** + * @ticket 64130 + * + * @covers wpdb::get_col_info + * + * @dataProvider data_get_col_info_without_result_set + * + * @param string $query Query that does not produce a result set. + */ + public function test_get_col_info_without_result_set( $query ) { + global $wpdb; + + $suppress = $wpdb->suppress_errors( true ); + // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared + $wpdb->query( sprintf( $query, $wpdb->options ) ); + $wpdb->suppress_errors( $suppress ); + + $this->assertNull( $wpdb->get_col_info(), 'get_col_info() should return null.' ); + $this->assertNull( $wpdb->col_info, 'The col_info property should be null.' ); + } + + /** + * Data provider. + * + * @return array + */ + public static function data_get_col_info_without_result_set() { + return array( + 'failed query' => array( 'SELECT ID FROM table_that_does_not_exist' ), + 'update query' => array( "UPDATE %s SET option_value = option_value WHERE option_name = 'blogname'" ), + 'set query' => array( 'SET @wp_test_64130 = 1' ), + ); + } + public function test_query_and_delete() { global $wpdb; $rows = $wpdb->query( "INSERT INTO $wpdb->users (display_name) VALUES ('Walter Sobchak')" ); From 9f29727aa3f0edec8c4a2acc499a165bc13d69c3 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:23:58 +0000 Subject: [PATCH 024/236] Tests: Add coverage for `clean_category_cache()`. Verifies category cache invalidation and its action, plus regeneration of the category hierarchy option. Developed in: https://github.com/WordPress/wordpress-develop/pull/14365 Props shailu25, mukesh27. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64459 602fd350-edb4-49c9-b593-d223f7449a82 --- .../tests/category/cleanCategoryCache.php | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 tests/phpunit/tests/category/cleanCategoryCache.php diff --git a/tests/phpunit/tests/category/cleanCategoryCache.php b/tests/phpunit/tests/category/cleanCategoryCache.php new file mode 100644 index 0000000000000..545001a1b6ff4 --- /dev/null +++ b/tests/phpunit/tests/category/cleanCategoryCache.php @@ -0,0 +1,69 @@ +category->create( + array( + 'name' => 'Original Category', + ) + ); + + // Seed stale category data in the term cache. + $stale_category = clone get_category( $category_id ); + $stale_category->name = 'Stale Category'; + wp_cache_set( $category_id, $stale_category, 'terms' ); + $this->assertSame( 'Stale Category', get_category( $category_id )->name ); + + $action = new MockAction(); + add_action( 'clean_term_cache', array( $action, 'action' ), 10, 3 ); + + clean_category_cache( $category_id ); + + $this->assertSame( 'Original Category', get_category( $category_id )->name ); + $this->assertSame( 1, $action->get_call_count() ); + $this->assertSame( + array( + array( $category_id ), + 'category', + true, + ), + $action->get_args()[0] + ); + } + + /** + * Tests that clean_category_cache() replaces a stale category_children hierarchy option. + * + * @ticket 65819 + */ + public function test_regenerates_category_hierarchy_option() { + $parent_id = self::factory()->category->create(); + $child_id = self::factory()->category->create( array( 'parent' => $parent_id ) ); + + // Seed a stale empty hierarchy option. + update_option( 'category_children', array() ); + $this->assertSame( array(), get_option( 'category_children' ) ); + + clean_category_cache( $parent_id ); + + $hierarchy = get_option( 'category_children' ); + $this->assertIsArray( $hierarchy ); + $this->assertArrayHasKey( $parent_id, $hierarchy ); + $this->assertContains( $child_id, $hierarchy[ $parent_id ] ); + } +} From 2fa1b23aae86fdd97243157f0ef8fa77b8ef902f Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:25:34 +0000 Subject: [PATCH 025/236] Tests: Add coverage for `sanitize_category()`. Covers object and array sanitization, filter arguments, and preservation of unset fields. Developed in: https://github.com/WordPress/wordpress-develop/pull/14366 Props shailu25, mukesh27. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64460 602fd350-edb4-49c9-b593-d223f7449a82 --- .../tests/category/sanitizeCategory.php | 146 ++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 tests/phpunit/tests/category/sanitizeCategory.php diff --git a/tests/phpunit/tests/category/sanitizeCategory.php b/tests/phpunit/tests/category/sanitizeCategory.php new file mode 100644 index 0000000000000..5f400f2d9f363 --- /dev/null +++ b/tests/phpunit/tests/category/sanitizeCategory.php @@ -0,0 +1,146 @@ + '42', + 'name' => 'Category Name', + 'description' => 'Category Description', + 'slug' => 'category-name', + 'count' => '7', + 'parent' => '-3', + 'term_group' => '2', + 'term_taxonomy_id' => '55', + 'object_id' => '100', + ); + + $result = sanitize_category( $category ); + + $this->assertIsObject( $result ); + $this->assertSame( 42, $result->term_id ); + $this->assertSame( 7, $result->count ); + $this->assertSame( 0, $result->parent ); + $this->assertSame( 2, $result->term_group ); + $this->assertSame( 55, $result->term_taxonomy_id ); + $this->assertSame( 100, $result->object_id ); + $this->assertSame( 'display', $result->filter ); + } + + /** + * Tests that sanitize_category() sanitizes a category array, casts integer fields + * to non-negative integers, and sets the 'filter' key to the given context. + * + * @ticket 65819 + */ + public function test_sanitizes_category_array() { + $category = array( + 'term_id' => '15', + 'name' => 'Category', + 'description' => '

Description

', + 'slug' => 'category', + 'count' => '-5', + 'parent' => '3', + 'term_group' => '-1', + 'term_taxonomy_id' => '19', + 'object_id' => '8', + ); + + $result = sanitize_category( $category, 'edit' ); + + $this->assertIsArray( $result ); + $this->assertSame( 15, $result['term_id'] ); + $this->assertSame( esc_attr( 'Category' ), $result['name'] ); + $this->assertSame( esc_html( '

Description

' ), $result['description'] ); + $this->assertSame( 0, $result['count'] ); + $this->assertSame( 3, $result['parent'] ); + $this->assertSame( 0, $result['term_group'] ); + $this->assertSame( 19, $result['term_taxonomy_id'] ); + $this->assertSame( 8, $result['object_id'] ); + $this->assertSame( 'edit', $result['filter'] ); + } + + /** + * Tests that sanitize_category() passes the category ID and 'category' taxonomy + * to the context filters, defaulting term_id to 0 when omitted. + * + * @ticket 65819 + */ + public function test_passes_category_id_and_taxonomy_to_filters() { + $term_filter = new MockAction(); + $category_filter = new MockAction(); + + add_filter( 'edit_term_name', array( $term_filter, 'filter' ), 10, 3 ); + add_filter( 'edit_category_name', array( $category_filter, 'filter' ), 10, 2 ); + + sanitize_category( + array( + 'term_id' => 25, + 'name' => 'News', + ), + 'edit' + ); + + // Also test when term_id is omitted (defaults to 0). + sanitize_category( + (object) array( + 'name' => 'Updates', + ), + 'edit' + ); + + $this->assertSame( + array( + array( 'News', 25, 'category' ), + array( 'Updates', 0, 'category' ), + ), + $term_filter->get_args() + ); + $this->assertSame( + array( + array( 'News', 25 ), + array( 'Updates', 0 ), + ), + $category_filter->get_args() + ); + } + + /** + * Tests that sanitize_category() does not add fields that are not set on the input. + * + * @ticket 65819 + */ + public function test_does_not_add_unset_fields() { + $object_result = sanitize_category( (object) array( 'name' => 'Only Name' ), 'raw' ); + $this->assertSame( + array( + 'name' => 'Only Name', + 'filter' => 'raw', + ), + get_object_vars( $object_result ) + ); + + $array_result = sanitize_category( array( 'name' => 'Only Name' ), 'raw' ); + $this->assertSame( + array( + 'name' => 'Only Name', + 'filter' => 'raw', + ), + $array_result + ); + } +} From 119c23cbccb7be64ee8fb5a7e0bb162f39647297 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:26:45 +0000 Subject: [PATCH 026/236] Tests: Add coverage for `sanitize_category_field()`. Checks field casting, con-specific filters and escaping, including the database slug path. Developed in: https://github.com/WordPress/wordpress-develop/pull/14367 Props shailu25, mukesh27. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64461 602fd350-edb4-49c9-b593-d223f7449a82 --- .../tests/category/sanitizeCategoryField.php | 309 ++++++++++++++++++ 1 file changed, 309 insertions(+) create mode 100644 tests/phpunit/tests/category/sanitizeCategoryField.php diff --git a/tests/phpunit/tests/category/sanitizeCategoryField.php b/tests/phpunit/tests/category/sanitizeCategoryField.php new file mode 100644 index 0000000000000..de4e53244bd9b --- /dev/null +++ b/tests/phpunit/tests/category/sanitizeCategoryField.php @@ -0,0 +1,309 @@ +Bold & "double" \'single\''; + + /** + * Filter calls recorded by record_filters(). + * + * @var array[] + */ + private $calls = array(); + + /** + * Records every call to the hooks the function could fire for a field, + * and appends the hook name to the filtered value. + * + * @param string $field Category field name. + */ + private function record_filters( $field ) { + $hooks = array( + "edit_term_{$field}", + "edit_category_{$field}", + "pre_term_{$field}", + "pre_category_{$field}", + 'pre_category_nicename', + "term_{$field}_rss", + "category_{$field}_rss", + "term_{$field}", + "category_{$field}", + ); + + foreach ( $hooks as $hook ) { + add_filter( + $hook, + function ( ...$args ) use ( $hook ) { + $this->calls[] = array( $hook, $args ); + + return $args[0] . '|' . $hook; + }, + 10, + 4 + ); + } + } + + /** + * Tests that integer fields are cast to non-negative integers across contexts. + * + * @ticket 65819 + * + * @dataProvider data_casts_integer_fields + * + * @param string $field Category field name. + * @param mixed $value Field value. + * @param string $context Sanitization context. + * @param int $expected Expected sanitized integer. + */ + public function test_casts_integer_fields( $field, $value, $context, $expected ) { + $this->assertSame( $expected, sanitize_category_field( $field, $value, self::CATEGORY_ID, $context ) ); + } + + /** + * Data provider. + * + * @return array[] + */ + public static function data_casts_integer_fields() { + return array( + 'parent, raw' => array( 'parent', '12abc', 'raw', 12 ), + 'parent, negative value' => array( 'parent', -5, 'raw', 0 ), + 'term_id, display' => array( 'term_id', '5', 'display', 5 ), + 'count, edit' => array( 'count', '6', 'edit', 6 ), + 'count, negative string' => array( 'count', '-10', 'display', 0 ), + 'term_group, attribute' => array( 'term_group', '7', 'attribute', 7 ), + 'term_taxonomy_id, db' => array( 'term_taxonomy_id', '8', 'db', 8 ), + 'object_id, js' => array( 'object_id', '9', 'js', 9 ), + 'object_id, empty string' => array( 'object_id', '', 'display', 0 ), + ); + } + + /** + * Tests that the raw context (case-insensitive) returns non-integer values unfiltered. + * + * @ticket 65819 + * + * @dataProvider data_raw_contexts + * + * @param string $context Raw context variation. + */ + public function test_raw_context_returns_value_unfiltered( $context ) { + $this->record_filters( 'foo' ); + + $this->assertSame( self::MARKUP, sanitize_category_field( 'foo', self::MARKUP, self::CATEGORY_ID, $context ) ); + $this->assertSame( array(), $this->calls, 'No filter should run in the raw context.' ); + } + + /** + * Data provider. + * + * @return array[] + */ + public static function data_raw_contexts() { + return array( + 'lowercase raw' => array( 'raw' ), + 'uppercase RAW' => array( 'RAW' ), + 'mixed Raw' => array( 'Raw' ), + ); + } + + /** + * Tests the filters that run for each context and the arguments they receive. + * + * @ticket 65819 + * + * @dataProvider data_filters_for_context + * + * @param string $context Sanitization context. + * @param string $expected_value Expected return value. + * @param array[] $expected_calls Expected filter calls. + */ + public function test_applies_filters_for_context( $context, $expected_value, $expected_calls ) { + $this->record_filters( 'foo' ); + + $this->assertSame( $expected_value, sanitize_category_field( 'foo', 'value', self::CATEGORY_ID, $context ) ); + $this->assertSame( $expected_calls, $this->calls ); + } + + /** + * Data provider. + * + * @return array[] + */ + public static function data_filters_for_context() { + return array( + 'edit' => array( + 'edit', + 'value|edit_term_foo|edit_category_foo', + array( + array( 'edit_term_foo', array( 'value', self::CATEGORY_ID, 'category' ) ), + array( 'edit_category_foo', array( 'value|edit_term_foo', self::CATEGORY_ID ) ), + ), + ), + 'db' => array( + 'db', + 'value|pre_term_foo|pre_category_foo', + array( + array( 'pre_term_foo', array( 'value', 'category' ) ), + array( 'pre_category_foo', array( 'value|pre_term_foo' ) ), + ), + ), + 'rss' => array( + 'rss', + 'value|term_foo_rss|category_foo_rss', + array( + array( 'term_foo_rss', array( 'value', 'category' ) ), + array( 'category_foo_rss', array( 'value|term_foo_rss' ) ), + ), + ), + 'display' => array( + 'display', + 'value|term_foo|category_foo', + array( + array( 'term_foo', array( 'value', self::CATEGORY_ID, 'category', 'display' ) ), + array( 'category_foo', array( 'value|term_foo', self::CATEGORY_ID, 'display' ) ), + ), + ), + 'attribute uses display filters' => array( + 'attribute', + 'value|term_foo|category_foo', + array( + array( 'term_foo', array( 'value', self::CATEGORY_ID, 'category', 'attribute' ) ), + array( 'category_foo', array( 'value|term_foo', self::CATEGORY_ID, 'attribute' ) ), + ), + ), + 'js uses display filters' => array( + 'js', + 'value|term_foo|category_foo', + array( + array( 'term_foo', array( 'value', self::CATEGORY_ID, 'category', 'js' ) ), + array( 'category_foo', array( 'value|term_foo', self::CATEGORY_ID, 'js' ) ), + ), + ), + 'unknown context uses display filters' => array( + 'other', + 'value|term_foo|category_foo', + array( + array( 'term_foo', array( 'value', self::CATEGORY_ID, 'category', 'other' ) ), + array( 'category_foo', array( 'value|term_foo', self::CATEGORY_ID, 'other' ) ), + ), + ), + ); + } + + /** + * Tests that sanitizing the 'slug' field in the 'db' context also applies the + * backwards-compatible 'pre_category_nicename' filter. + * + * @ticket 65819 + */ + public function test_db_context_slug_applies_pre_category_nicename_filter() { + remove_all_filters( 'pre_term_slug' ); + $this->record_filters( 'slug' ); + + $result = sanitize_category_field( 'slug', 'my-slug', self::CATEGORY_ID, 'db' ); + + $this->assertSame( 'my-slug|pre_term_slug|pre_category_slug|pre_category_nicename', $result ); + $this->assertSame( + array( + array( 'pre_term_slug', array( 'my-slug', 'category' ) ), + array( 'pre_category_slug', array( 'my-slug|pre_term_slug' ) ), + array( 'pre_category_nicename', array( 'my-slug|pre_term_slug|pre_category_slug' ) ), + ), + $this->calls + ); + } + + /** + * Tests the escaping applied in each context. + * + * @ticket 65819 + * + * @dataProvider data_escaping_for_context + * + * @param string $field Category field name. + * @param string $context Sanitization context. + * @param string $expected Expected escaped value. + */ + public function test_escapes_value_for_context( $field, $context, $expected ) { + $this->assertSame( $expected, sanitize_category_field( $field, self::MARKUP, self::CATEGORY_ID, $context ) ); + } + + /** + * Data provider. + * + * @return array[] + */ + public static function data_escaping_for_context() { + return array( + 'edit non-description uses esc_attr' => array( 'foo', 'edit', '<b>Bold</b> & "double" 'single'' ), + 'edit description uses esc_html' => array( 'description', 'edit', '<b>Bold</b> & "double" 'single'' ), + 'attribute uses esc_attr' => array( 'foo', 'attribute', '<b>Bold</b> & "double" 'single'' ), + 'js uses esc_js' => array( 'foo', 'js', '<b>Bold</b> & "double" \\\'single\\\'' ), + 'db does not escape' => array( 'foo', 'db', self::MARKUP ), + 'rss does not escape' => array( 'foo', 'rss', self::MARKUP ), + 'display does not escape' => array( 'foo', 'display', self::MARKUP ), + ); + } + + /** + * Tests that the 'description' field is escaped with esc_html() in the edit context, + * and other fields with esc_attr(). + * + * @ticket 65819 + * + * @dataProvider data_edit_escaping_function + * + * @param string $field Category field name. + * @param string $filter Filter run by the expected escaping function. + */ + public function test_edit_context_escaping_function( $field, $filter ) { + $escaping_filters = array( + 'esc_html' => new MockAction(), + 'attribute_escape' => new MockAction(), + ); + + foreach ( $escaping_filters as $hook => $mock ) { + add_filter( $hook, array( $mock, 'filter' ) ); + } + + sanitize_category_field( $field, self::MARKUP, self::CATEGORY_ID, 'edit' ); + + foreach ( $escaping_filters as $hook => $mock ) { + $this->assertSame( $hook === $filter ? 1 : 0, $mock->get_call_count(), "The {$hook} filter call count did not match." ); + } + } + + /** + * Data provider. + * + * @return array[] + */ + public static function data_edit_escaping_function() { + return array( + 'description' => array( 'description', 'esc_html' ), + 'other field' => array( 'foo', 'attribute_escape' ), + ); + } +} From 29302445cb2bd4da60e583aaba9830361d7ae682 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:28:36 +0000 Subject: [PATCH 027/236] Tests: Add coverage for `get_the_category()`. Covers post ID and global-post lookup, empty results, compatibility properties, and the categories filter. Developed in: https://github.com/WordPress/wordpress-develop/pull/14368 Props shailu25, mukesh27. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64462 602fd350-edb4-49c9-b593-d223f7449a82 --- .../phpunit/tests/category/getTheCategory.php | 129 ++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 tests/phpunit/tests/category/getTheCategory.php diff --git a/tests/phpunit/tests/category/getTheCategory.php b/tests/phpunit/tests/category/getTheCategory.php new file mode 100644 index 0000000000000..79b66768d6cd3 --- /dev/null +++ b/tests/phpunit/tests/category/getTheCategory.php @@ -0,0 +1,129 @@ +category->create( + array( + 'name' => 'Parent Category', + 'slug' => 'parent-category', + ) + ); + + self::$category = $factory->category->create_and_get( + array( + 'name' => 'Child Category', + 'slug' => 'child-category', + 'description' => 'Child category description', + 'parent' => self::$parent_id, + ) + ); + + self::$post_id = $factory->post->create( + array( + 'post_category' => array( self::$category->term_id ), + ) + ); + } + + /** + * Tests that get_the_category() returns a zero-indexed array of WP_Term objects + * with backwards-compatible properties for a given post ID. + * + * @ticket 65819 + */ + public function test_returns_categories_with_compat_properties_for_post_id() { + $categories = get_the_category( self::$post_id ); + + $this->assertCount( 1, $categories ); + $this->assertTrue( array_is_list( $categories ) ); + $this->assertInstanceOf( WP_Term::class, $categories[0] ); + $this->assertSame( self::$category->term_id, $categories[0]->term_id ); + $this->assertSame( self::$category->term_id, $categories[0]->cat_ID ); + $this->assertSame( 1, $categories[0]->category_count ); + $this->assertSame( 'Child category description', $categories[0]->category_description ); + $this->assertSame( 'Child Category', $categories[0]->cat_name ); + $this->assertSame( 'child-category', $categories[0]->category_nicename ); + $this->assertSame( self::$parent_id, $categories[0]->category_parent ); + } + + /** + * Tests that get_the_category() defaults to the global post when no post ID is passed. + * + * @ticket 65819 + */ + public function test_defaults_to_global_post_when_post_id_is_omitted() { + $GLOBALS['post'] = get_post( self::$post_id ); + + $categories = get_the_category(); + + $this->assertCount( 1, $categories ); + $this->assertSame( self::$category->term_id, $categories[0]->term_id ); + $this->assertSame( self::$category->term_id, $categories[0]->cat_ID ); + } + + /** + * Tests that get_the_category() returns an empty array when a post has no categories + * or when the post does not exist. + * + * @ticket 65819 + */ + public function test_returns_empty_array_when_no_categories_or_invalid_post() { + $unassigned_post_id = self::factory()->post->create(); + wp_set_object_terms( $unassigned_post_id, array(), 'category' ); + + $this->assertSame( array(), get_the_category( $unassigned_post_id ) ); + $this->assertSame( array(), get_the_category( 99999999 ) ); + $this->assertSame( array(), get_the_category( 0 ) ); + } + + /** + * Tests that get_the_category() applies the 'get_the_categories' filter + * with the categories array and post ID. + * + * @ticket 65819 + */ + public function test_applies_get_the_categories_filter() { + $filter = new MockAction(); + add_filter( 'get_the_categories', array( $filter, 'filter' ), 10, 2 ); + + $categories = get_the_category( self::$post_id ); + + $this->assertSame( 1, $filter->get_call_count() ); + $this->assertSame( array( $categories, self::$post_id ), $filter->get_args()[0] ); + } +} From 883b5b57c442aacb96b32e1b8d90bc8b1d468b05 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:29:46 +0000 Subject: [PATCH 028/236] Tests: Add coverage for `has_category()`. Checks matching and missing categories, the empty-category case, global-post fallback, and invalid posts. Developed in: https://github.com/WordPress/wordpress-develop/pull/14369 Props shailu25, mukesh27. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64463 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/category/hasCategory.php | 114 +++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 tests/phpunit/tests/category/hasCategory.php diff --git a/tests/phpunit/tests/category/hasCategory.php b/tests/phpunit/tests/category/hasCategory.php new file mode 100644 index 0000000000000..2c2419d81027b --- /dev/null +++ b/tests/phpunit/tests/category/hasCategory.php @@ -0,0 +1,114 @@ +category->create_and_get( + array( + 'name' => 'Assigned Category', + 'slug' => 'assigned-category', + ) + ); + + self::$other_category = $factory->category->create_and_get( + array( + 'name' => 'Other Category', + 'slug' => 'other-category', + ) + ); + + self::$post = $factory->post->create_and_get( + array( + 'post_category' => array( self::$category->term_id ), + ) + ); + } + + /** + * Tests that has_category() returns true when the post has the specified category + * by ID, name, slug, or an array of values, and accepts a post ID or WP_Post object. + * + * @ticket 65819 + */ + public function test_returns_true_when_post_has_matching_category() { + $this->assertTrue( has_category( self::$category->term_id, self::$post->ID ) ); + $this->assertTrue( has_category( self::$category->name, self::$post->ID ) ); + $this->assertTrue( has_category( self::$category->slug, self::$post->ID ) ); + $this->assertTrue( has_category( array( self::$other_category->slug, self::$category->slug ), self::$post->ID ) ); + $this->assertTrue( has_category( self::$category->term_id, self::$post ) ); + } + + /** + * Tests that has_category() with an empty category check returns true when the post + * has at least one category and false when it has no categories. + * + * @ticket 65819 + */ + public function test_empty_category_checks_if_post_has_any_category() { + $this->assertTrue( has_category( '', self::$post->ID ) ); + + $unassigned_post_id = self::factory()->post->create(); + wp_set_object_terms( $unassigned_post_id, array(), 'category' ); + + $this->assertFalse( has_category( '', $unassigned_post_id ) ); + } + + /** + * Tests that has_category() defaults to the global post when no post parameter is passed. + * + * @ticket 65819 + */ + public function test_defaults_to_global_post_when_post_is_omitted() { + $GLOBALS['post'] = self::$post; + + $this->assertTrue( has_category( self::$category->term_id ) ); + $this->assertFalse( has_category( self::$other_category->term_id ) ); + } + + /** + * Tests that has_category() returns false when the post does not have the category + * or when the post does not exist. + * + * @ticket 65819 + */ + public function test_returns_false_for_non_matching_category_or_invalid_post() { + $this->assertFalse( has_category( self::$other_category->term_id, self::$post->ID ) ); + $this->assertFalse( has_category( self::$other_category->name, self::$post->ID ) ); + $this->assertFalse( has_category( self::$other_category->slug, self::$post->ID ) ); + $this->assertFalse( has_category( self::$category->term_id, 99999999 ) ); + } +} From 13416341d272b36c7ff81838559830fbd03b0d67 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:30:54 +0000 Subject: [PATCH 029/236] Tests: Add coverage for `user_can_access_admin_page()`. Check capability and registration decisions for core submenus, plugin pages, hidden pages, and parent-menu fallbacks. Restore menu and request globals between cases. Developed in: https://github.com/WordPress/wordpress-develop/pull/14372 Props huzaifaalmesbah, mukesh27. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64464 602fd350-edb4-49c9-b593-d223f7449a82 --- .../plugin/userCanAccessAdminPage.php | 314 ++++++++++++++++++ 1 file changed, 314 insertions(+) create mode 100644 tests/phpunit/tests/admin/includes/plugin/userCanAccessAdminPage.php diff --git a/tests/phpunit/tests/admin/includes/plugin/userCanAccessAdminPage.php b/tests/phpunit/tests/admin/includes/plugin/userCanAccessAdminPage.php new file mode 100644 index 0000000000000..e6a5eeaaef30c --- /dev/null +++ b/tests/phpunit/tests/admin/includes/plugin/userCanAccessAdminPage.php @@ -0,0 +1,314 @@ +user->create( array( 'role' => $role ) ); + } + } + + public function set_up() { + parent::set_up(); + + require_once ABSPATH . 'wp-admin/includes/plugin.php'; + + $this->orig_globals = array(); + + foreach ( self::GLOBALS_USED as $name ) { + if ( array_key_exists( $name, $GLOBALS ) ) { + $this->orig_globals[ $name ] = $GLOBALS[ $name ]; + } + + unset( $GLOBALS[ $name ] ); + } + + $GLOBALS['menu'] = array( + 2 => array( 'Dashboard', 'read', 'index.php' ), + 25 => array( 'My Plugin', 'manage_options', 'my-plugin' ), + 80 => array( 'Settings', 'manage_options', 'options-general.php' ), + ); + $GLOBALS['submenu'] = array( + 'index.php' => array( + 0 => array( 'Home', 'read', 'index.php' ), + ), + 'my-plugin' => array( + 0 => array( 'My Plugin', 'manage_options', 'my-plugin' ), + 1 => array( 'Sub Page', 'edit_posts', 'my-plugin-sub' ), + ), + 'options-general.php' => array( + 10 => array( 'General', 'manage_options', 'options-general.php' ), + 50 => array( 'My Settings', 'manage_options', 'my-settings' ), + ), + ); + $GLOBALS['admin_page_hooks'] = array( + 'my-plugin' => 'my-plugin', + 'options-general.php' => 'settings', + ); + $GLOBALS['_registered_pages'] = array(); + $GLOBALS['_wp_menu_nopriv'] = array(); + $GLOBALS['_wp_submenu_nopriv'] = array(); + } + + public function tear_down() { + foreach ( self::GLOBALS_USED as $name ) { + if ( array_key_exists( $name, $this->orig_globals ) ) { + $GLOBALS[ $name ] = $this->orig_globals[ $name ]; + } else { + unset( $GLOBALS[ $name ] ); + } + } + + parent::tear_down(); + } + + /** + * Tests whether the current user can access the current admin page. + * + * @ticket 65819 + * + * @dataProvider data_user_can_access_admin_page + * + * @param array $globals Globals describing the current request, merged into the defaults set up for each test. + * @param string $role Role of the current user. + * @param bool $expected Whether the user should be able to access the page. + */ + public function test_user_can_access_admin_page( $globals, $role, $expected ) { + foreach ( $globals as $name => $value ) { + if ( is_array( $value ) && isset( $GLOBALS[ $name ] ) && is_array( $GLOBALS[ $name ] ) && in_array( $name, array( 'menu', 'submenu' ), true ) ) { + $GLOBALS[ $name ] = array_merge( $GLOBALS[ $name ], $value ); + } else { + $GLOBALS[ $name ] = $value; + } + } + + wp_set_current_user( self::$user_ids[ $role ] ); + + $this->assertSame( $expected, user_can_access_admin_page() ); + } + + /** + * Data provider. + * + * @return array[] + */ + public static function data_user_can_access_admin_page() { + $book_menu = array( + 'menu' => array( 26 => array( 'Books', 'edit_posts', 'edit.php?post_type=book' ) ), + 'submenu' => array( + 'edit.php?post_type=book' => array( + 5 => array( 'All Books', 'manage_options', 'edit.php?post_type=book' ), + ), + ), + 'pagenow' => 'edit.php', + 'typenow' => 'book', + ); + + return array( + // Core pages in a submenu use the capability of the submenu item. + 'submenu page, user has the capability' => array( + array( 'pagenow' => 'options-general.php' ), + 'administrator', + true, + ), + 'submenu page, user lacks the capability' => array( + array( 'pagenow' => 'options-general.php' ), + 'editor', + false, + ), + 'submenu page marked as not accessible' => array( + array( + 'pagenow' => 'options-general.php', + '_wp_submenu_nopriv' => array( 'options-general.php' => array( 'options-general.php' => true ) ), + ), + 'administrator', + false, + ), + + // Plugin pages must be registered, and use the capability of their menu item. + 'plugin subpage, registered, user has the capability' => array( + array( + 'pagenow' => 'options-general.php', + 'plugin_page' => 'my-settings', + '_registered_pages' => array( 'settings_page_my-settings' => true ), + ), + 'administrator', + true, + ), + 'plugin subpage, registered, user lacks the capability' => array( + array( + 'pagenow' => 'options-general.php', + 'plugin_page' => 'my-settings', + '_registered_pages' => array( 'settings_page_my-settings' => true ), + ), + 'editor', + false, + ), + 'plugin subpage that is not registered' => array( + array( + 'pagenow' => 'options-general.php', + 'plugin_page' => 'my-settings', + ), + 'administrator', + false, + ), + 'plugin subpage marked as not accessible' => array( + array( + 'pagenow' => 'options-general.php', + 'plugin_page' => 'my-settings', + '_registered_pages' => array( 'settings_page_my-settings' => true ), + '_wp_submenu_nopriv' => array( 'options-general.php' => array( 'my-settings' => true ) ), + ), + 'administrator', + false, + ), + 'top-level plugin page, user has the capability' => array( + array( + 'pagenow' => 'admin.php', + 'plugin_page' => 'my-plugin', + '_registered_pages' => array( 'toplevel_page_my-plugin' => true ), + ), + 'administrator', + true, + ), + 'top-level plugin page, user lacks the capability' => array( + array( + 'pagenow' => 'admin.php', + 'plugin_page' => 'my-plugin', + '_registered_pages' => array( 'toplevel_page_my-plugin' => true ), + ), + 'editor', + false, + ), + 'plugin page under a top-level plugin menu uses its own capability' => array( + array( + 'pagenow' => 'admin.php', + 'plugin_page' => 'my-plugin-sub', + '_registered_pages' => array( 'my-plugin_page_my-plugin-sub' => true ), + ), + 'editor', + true, + ), + 'top-level plugin page marked as not accessible' => array( + array( + 'pagenow' => 'admin.php', + 'plugin_page' => 'hidden-plugin', + '_registered_pages' => array( 'admin_page_hidden-plugin' => true ), + '_wp_menu_nopriv' => array( 'hidden-plugin' => true ), + ), + 'administrator', + false, + ), + + // Pages without a parent are accessible unless a menu marks them as not accessible. + 'page without a parent' => array( + array( 'pagenow' => 'profile.php' ), + 'subscriber', + true, + ), + 'page without a parent, not accessible as a menu' => array( + array( + 'pagenow' => 'profile.php', + '_wp_menu_nopriv' => array( 'profile.php' => true ), + ), + 'subscriber', + false, + ), + 'page without a parent, not accessible as its own submenu' => array( + array( + 'pagenow' => 'profile.php', + '_wp_submenu_nopriv' => array( 'profile.php' => array( 'profile.php' => true ) ), + ), + 'subscriber', + false, + ), + 'page without a parent, not accessible in another submenu' => array( + array( + 'pagenow' => 'profile.php', + '_wp_submenu_nopriv' => array( 'users.php' => array( 'profile.php' => true ) ), + ), + 'subscriber', + false, + ), + 'plugin page without a parent' => array( + array( + 'pagenow' => 'profile.php', + 'plugin_page' => 'orphan', + '_registered_pages' => array( 'admin_page_orphan' => true ), + ), + 'subscriber', + true, + ), + 'plugin page without a parent, not accessible as a menu' => array( + array( + 'pagenow' => 'profile.php', + 'plugin_page' => 'orphan', + '_registered_pages' => array( 'admin_page_orphan' => true ), + '_wp_menu_nopriv' => array( 'orphan' => true ), + ), + 'subscriber', + false, + ), + 'plugin page without a parent, not accessible in another submenu' => array( + array( + 'pagenow' => 'profile.php', + 'plugin_page' => 'orphan', + '_registered_pages' => array( 'admin_page_orphan' => true ), + '_wp_submenu_nopriv' => array( 'users.php' => array( 'orphan' => true ) ), + ), + 'subscriber', + false, + ), + + // When no submenu item matches the page, the capability of the parent menu item is used. + 'parent menu capability, user has it' => array( $book_menu, 'editor', true ), + 'parent menu capability, user lacks it' => array( $book_menu, 'subscriber', false ), + 'parent that is not in the menu' => array( + array_merge( $book_menu, array( 'menu' => array() ) ), + 'subscriber', + true, + ), + ); + } +} From 023740f902f8eaf61efde39bf171fcc3d16806d2 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:31:55 +0000 Subject: [PATCH 030/236] Tests: Add coverage for `the_category()`. Checks the default category list and custom separator, parent, and post-ID output. Developed in: https://github.com/WordPress/wordpress-develop/pull/14373 Props shailu25, mukesh27. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64465 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/category/theCategory.php | 88 ++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 tests/phpunit/tests/category/theCategory.php diff --git a/tests/phpunit/tests/category/theCategory.php b/tests/phpunit/tests/category/theCategory.php new file mode 100644 index 0000000000000..7ca164a93e709 --- /dev/null +++ b/tests/phpunit/tests/category/theCategory.php @@ -0,0 +1,88 @@ +category->create( + array( + 'name' => 'Parent Category', + 'slug' => 'parent-category', + ) + ); + + self::$child_id = $factory->category->create( + array( + 'name' => 'Child Category', + 'slug' => 'child-category', + 'parent' => self::$parent_id, + ) + ); + + self::$post_id = $factory->post->create( + array( + 'post_category' => array( self::$child_id ), + ) + ); + } + + /** + * Tests that the_category() outputs the unordered category list by default for the global post. + * + * @ticket 65819 + */ + public function test_outputs_default_unordered_list_for_global_post() { + $GLOBALS['post'] = get_post( self::$post_id ); + + $this->expectOutputString( get_the_category_list() ); + + the_category(); + } + + /** + * Tests that the_category() forwards the separator, parents, and post_id parameters + * to get_the_category_list(). + * + * @ticket 65819 + */ + public function test_outputs_category_list_with_separator_parents_and_post_id() { + $expected = get_the_category_list( ' / ', 'multiple', self::$post_id ); + + $this->expectOutputString( $expected ); + + the_category( ' / ', 'multiple', self::$post_id ); + } +} From 795df587d3632c7b2255ee8fb31ea657ca326466 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:32:55 +0000 Subject: [PATCH 031/236] Tests: Add coverage for `walk_category_tree()`. Covers the default walker, invalid-walker fallback, and a supplied custom walker. Developed in: https://github.com/WordPress/wordpress-develop/pull/14374 Props shailu25, mukesh27. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64466 602fd350-edb4-49c9-b593-d223f7449a82 --- .../tests/category/walkCategoryTree.php | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 tests/phpunit/tests/category/walkCategoryTree.php diff --git a/tests/phpunit/tests/category/walkCategoryTree.php b/tests/phpunit/tests/category/walkCategoryTree.php new file mode 100644 index 0000000000000..fdf9f017fc848 --- /dev/null +++ b/tests/phpunit/tests/category/walkCategoryTree.php @@ -0,0 +1,118 @@ +category->create_and_get( + array( + 'name' => 'Parent Category', + 'slug' => 'parent-category', + ) + ); + + self::$child = $factory->category->create_and_get( + array( + 'name' => 'Child Category', + 'slug' => 'child-category', + 'parent' => self::$parent->term_id, + ) + ); + } + + /** + * Tests that walk_category_tree() uses Walker_Category by default when no custom walker is provided. + * + * @ticket 65819 + */ + public function test_uses_default_walker_category() { + $elements = array( self::$parent, self::$child ); + $args = array( + 'style' => 'list', + 'use_desc_for_title' => 0, + ); + + $default_walker = new Walker_Category(); + $expected = $default_walker->walk( $elements, 0, $args ); + + $this->assertStringContainsString( 'cat-item-' . self::$child->term_id, $expected ); + $this->assertSame( $expected, walk_category_tree( $elements, 0, $args ) ); + } + + /** + * Tests that walk_category_tree() falls back to Walker_Category when the 'walker' argument + * is not a Walker instance. + * + * @ticket 65819 + */ + public function test_falls_back_to_default_walker_when_walker_arg_is_invalid() { + $elements = array( self::$parent, self::$child ); + $args = array( + 'style' => 'list', + 'use_desc_for_title' => 0, + 'walker' => new stdClass(), + ); + + $default_walker = new Walker_Category(); + $expected = $default_walker->walk( $elements, 0, $args ); + + $this->assertStringContainsString( 'cat-item-' . self::$child->term_id, $expected ); + $this->assertSame( $expected, walk_category_tree( $elements, 0, $args ) ); + } + + /** + * Tests that walk_category_tree() uses a custom Walker instance when passed in $args['walker']. + * + * @ticket 65819 + */ + public function test_uses_custom_walker_instance_when_provided() { + $custom_walker = new class() extends Walker { + public $tree_type = 'category'; + public $db_fields = array( + 'parent' => 'parent', + 'id' => 'term_id', + ); + + public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_object_id = 0 ) { + $output .= 'custom:' . $data_object->slug . '|'; + } + }; + + $elements = array( self::$parent, self::$child ); + $args = array( + 'walker' => $custom_walker, + ); + + $this->assertSame( + 'custom:parent-category|custom:child-category|', + walk_category_tree( $elements, 0, $args ) + ); + } +} From 6c132f5f1076d6bd89f19f55cfbf58454484e94e Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:34:14 +0000 Subject: [PATCH 032/236] Tests: Add coverage for `get_tag()`. Covers tag lookup by ID and object, array output, edit-con filtering, and invalid or wrong-taxonomy inputs. Developed in: https://github.com/WordPress/wordpress-develop/pull/14375 Props rejaulalomkhan, mukesh27. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64467 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/category/getTag.php | 189 ++++++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 tests/phpunit/tests/category/getTag.php diff --git a/tests/phpunit/tests/category/getTag.php b/tests/phpunit/tests/category/getTag.php new file mode 100644 index 0000000000000..37f9cd240b04a --- /dev/null +++ b/tests/phpunit/tests/category/getTag.php @@ -0,0 +1,189 @@ +tag->create( + array( + 'name' => 'Test Tag', + 'slug' => 'test-tag', + 'description' => 'Tag description', + ) + ); + + self::$tag = get_term( self::$tag_id, 'post_tag' ); + } + + /** + * Tests that get_tag() returns a WP_Term object by tag ID. + * + * @ticket 65819 + */ + public function test_returns_tag_object_by_id() { + $tag = get_tag( self::$tag_id ); + + $this->assertInstanceOf( WP_Term::class, $tag ); + $this->assertSame( 'post_tag', $tag->taxonomy ); + $this->assertSame( 'raw', $tag->filter ); + $this->assertSame( self::$tag_id, $tag->term_id ); + $this->assertSame( 'Test Tag', $tag->name ); + $this->assertSame( 'test-tag', $tag->slug ); + $this->assertSame( 'Tag description', $tag->description ); + } + + /** + * Tests that get_tag() accepts a tag object. + * + * @ticket 65819 + */ + public function test_accepts_tag_object() { + $tag = get_tag( self::$tag ); + + $this->assertInstanceOf( WP_Term::class, $tag ); + $this->assertSame( self::$tag_id, $tag->term_id ); + $this->assertSame( 'Test Tag', $tag->name ); + $this->assertSame( 'test-tag', $tag->slug ); + } + + /** + * Tests that get_tag() accepts a raw database row object. + * + * @ticket 65819 + */ + public function test_accepts_raw_tag_object() { + $raw_object = (object) self::$tag->to_array(); + + $tag = get_tag( $raw_object ); + + $this->assertInstanceOf( WP_Term::class, $tag ); + $this->assertSame( self::$tag_id, $tag->term_id ); + $this->assertSame( 'Test Tag', $tag->name ); + $this->assertSame( 'test-tag', $tag->slug ); + } + + /** + * Tests that ARRAY_A output returns an associative array of tag fields. + * + * @ticket 65819 + */ + public function test_returns_associative_array() { + $tag = get_tag( self::$tag_id, ARRAY_A ); + + $this->assertIsArray( $tag ); + $this->assertSame( self::$tag_id, $tag['term_id'] ); + $this->assertSame( 'Test Tag', $tag['name'] ); + $this->assertSame( 'test-tag', $tag['slug'] ); + $this->assertSame( 'Tag description', $tag['description'] ); + $this->assertSame( 'post_tag', $tag['taxonomy'] ); + } + + /** + * Tests that ARRAY_N output returns a numeric array of tag field values. + * + * @ticket 65819 + */ + public function test_returns_numeric_array() { + $tag = get_tag( self::$tag_id, ARRAY_N ); + + $this->assertIsArray( $tag ); + $this->assertSame( array_values( self::$tag->to_array() ), $tag ); + } + + /** + * Tests that the filter parameter sanitizes the returned tag in the requested context. + * + * @ticket 65819 + */ + public function test_applies_filter_context() { + add_filter( + 'edit_post_tag_name', + static function ( $name ) { + return $name . ' (edited)'; + } + ); + + $tag = get_tag( self::$tag_id, OBJECT, 'edit' ); + + $this->assertInstanceOf( WP_Term::class, $tag ); + $this->assertSame( 'edit', $tag->filter ); + $this->assertSame( 'Test Tag (edited)', $tag->name ); + } + + /** + * Tests that empty tag values return an invalid_term WP_Error. + * + * @ticket 65819 + * + * @dataProvider data_empty_tag_values + * + * @param mixed $empty_value Empty tag input. + */ + public function test_returns_wp_error_for_empty_tag( $empty_value ) { + $result = get_tag( $empty_value ); + + $this->assertWPError( $result ); + $this->assertSame( 'invalid_term', $result->get_error_code() ); + } + + /** + * Data provider. + * + * @return array[] + */ + public static function data_empty_tag_values() { + return array( + 'empty string' => array( '' ), + 'zero int' => array( 0 ), + 'zero string' => array( '0' ), + 'null' => array( null ), + 'false' => array( false ), + ); + } + + /** + * Tests that a non-existent tag ID returns null. + * + * @ticket 65819 + */ + public function test_returns_null_for_non_existent_tag() { + $this->assertNull( get_tag( 99999999 ) ); + } + + /** + * Tests that a term ID belonging to another taxonomy returns null. + * + * @ticket 65819 + */ + public function test_returns_null_for_term_in_another_taxonomy() { + $category_id = self::factory()->category->create(); + + $this->assertNull( get_tag( $category_id ) ); + } +} From 80188ad264cce69b22fd4010468b82b86cdbefef Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:35:49 +0000 Subject: [PATCH 033/236] Tests: Add coverage for `walk_category_dropdown_tree()`. Covers the default dropdown walker, invalid-walker fallback, and a supplied custom walker. Developed in: https://github.com/WordPress/wordpress-develop/pull/14376 Props shailu25, mukesh27. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64468 602fd350-edb4-49c9-b593-d223f7449a82 --- .../category/walkCategoryDropdownTree.php | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 tests/phpunit/tests/category/walkCategoryDropdownTree.php diff --git a/tests/phpunit/tests/category/walkCategoryDropdownTree.php b/tests/phpunit/tests/category/walkCategoryDropdownTree.php new file mode 100644 index 0000000000000..ca13a9e9a8772 --- /dev/null +++ b/tests/phpunit/tests/category/walkCategoryDropdownTree.php @@ -0,0 +1,122 @@ +category->create_and_get( + array( + 'name' => 'Parent Category', + 'slug' => 'parent-category', + ) + ); + + self::$child = $factory->category->create_and_get( + array( + 'name' => 'Child Category', + 'slug' => 'child-category', + 'parent' => self::$parent->term_id, + ) + ); + } + + /** + * Tests that walk_category_dropdown_tree() uses Walker_CategoryDropdown by default + * when no custom walker is provided. + * + * @ticket 65819 + */ + public function test_uses_default_walker_category_dropdown() { + $elements = array( self::$parent, self::$child ); + $args = array( + 'selected' => 0, + 'show_count' => 0, + 'value_field' => 'term_id', + ); + + $default_walker = new Walker_CategoryDropdown(); + $expected = $default_walker->walk( $elements, 0, $args ); + + $this->assertStringContainsString( 'value="' . self::$child->term_id . '"', $expected ); + $this->assertSame( $expected, walk_category_dropdown_tree( $elements, 0, $args ) ); + } + + /** + * Tests that walk_category_dropdown_tree() falls back to Walker_CategoryDropdown + * when the 'walker' argument is not a Walker instance. + * + * @ticket 65819 + */ + public function test_falls_back_to_default_walker_when_walker_arg_is_invalid() { + $elements = array( self::$parent, self::$child ); + $args = array( + 'selected' => 0, + 'show_count' => 0, + 'value_field' => 'term_id', + 'walker' => new stdClass(), + ); + + $default_walker = new Walker_CategoryDropdown(); + $expected = $default_walker->walk( $elements, 0, $args ); + + $this->assertStringContainsString( 'value="' . self::$child->term_id . '"', $expected ); + $this->assertSame( $expected, walk_category_dropdown_tree( $elements, 0, $args ) ); + } + + /** + * Tests that walk_category_dropdown_tree() uses a custom Walker instance + * when passed in $args['walker']. + * + * @ticket 65819 + */ + public function test_uses_custom_walker_instance_when_provided() { + $custom_walker = new class() extends Walker { + public $tree_type = 'category'; + public $db_fields = array( + 'parent' => 'parent', + 'id' => 'term_id', + ); + + public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_object_id = 0 ) { + $output .= 'option:' . $data_object->slug . '|'; + } + }; + + $elements = array( self::$parent, self::$child ); + $args = array( + 'walker' => $custom_walker, + ); + + $this->assertSame( + 'option:parent-category|option:child-category|', + walk_category_dropdown_tree( $elements, 0, $args ) + ); + } +} From 6edd2f562f319c7728e36fe84c819832d929b9e1 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:36:47 +0000 Subject: [PATCH 034/236] Tests: Add coverage for `wp_get_code_editor_settings()`. Verify editor modes across MIME types and filenames, lint settings, HTMLHint permissions, argument overrides, and the `wp_code_editor_settings` filter. Developed in: https://github.com/WordPress/wordpress-develop/pull/14377 Props huzaifaalmesbah, mukesh27. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64469 602fd350-edb4-49c9-b593-d223f7449a82 --- .../tests/general/wpGetCodeEditorSettings.php | 393 ++++++++++++++++++ 1 file changed, 393 insertions(+) create mode 100644 tests/phpunit/tests/general/wpGetCodeEditorSettings.php diff --git a/tests/phpunit/tests/general/wpGetCodeEditorSettings.php b/tests/phpunit/tests/general/wpGetCodeEditorSettings.php new file mode 100644 index 0000000000000..a3cf0afea5e62 --- /dev/null +++ b/tests/phpunit/tests/general/wpGetCodeEditorSettings.php @@ -0,0 +1,393 @@ +allow_unfiltered_html( true ); + + $codemirror = wp_get_code_editor_settings( array( 'type' => $type ) )['codemirror']; + + foreach ( $expected as $key => $value ) { + $this->assertArrayHasKey( $key, $codemirror, "The {$key} setting should be set." ); + $this->assertSame( $value, $codemirror[ $key ], "The {$key} setting did not match." ); + } + + foreach ( array( 'lint', 'autoCloseBrackets', 'autoCloseTags', 'matchBrackets', 'matchTags', 'highlightFormatting' ) as $key ) { + if ( ! array_key_exists( $key, $expected ) ) { + $this->assertArrayNotHasKey( $key, $codemirror, "The {$key} setting should not be set." ); + } + } + + $this->assertSame( + empty( $expected['lint'] ) ? array() : array( 'CodeMirror-lint-markers' ), + $codemirror['gutters'], + 'The lint markers gutter should only be added when linting is enabled.' + ); + } + + /** + * Data provider. + * + * @return array[] + */ + public static function data_mime_types() { + $css = array( + 'lint' => false, + 'autoCloseBrackets' => true, + 'matchBrackets' => true, + ); + + $javascript = array( + 'mode' => 'javascript', + 'lint' => true, + 'autoCloseBrackets' => true, + 'matchBrackets' => true, + ); + + $markup = array( + 'autoCloseBrackets' => true, + 'autoCloseTags' => true, + 'matchTags' => array( 'bothTags' => true ), + ); + + return array( + 'CSS' => array( 'text/css', array( 'mode' => 'text/css' ) + $css ), + 'SCSS' => array( 'text/x-scss', array( 'mode' => 'text/x-scss' ) + $css ), + 'Less' => array( 'text/x-less', array( 'mode' => 'text/x-less' ) + $css ), + 'Sass' => array( 'text/x-sass', array( 'mode' => 'text/x-sass' ) + $css ), + 'diff' => array( 'text/x-diff', array( 'mode' => 'diff' ) ), + 'application/x-patch' => array( 'application/x-patch', array( 'mode' => 'diff' ) ), + 'text/x-patch' => array( 'text/x-patch', array( 'mode' => 'diff' ) ), + 'HTML' => array( + 'text/html', + array( + 'mode' => 'htmlmixed', + 'lint' => true, + 'autoCloseBrackets' => true, + 'autoCloseTags' => true, + 'matchTags' => array( 'bothTags' => true ), + ), + ), + 'GitHub Flavored Markdown' => array( + 'text/x-gfm', + array( + 'mode' => 'gfm', + 'highlightFormatting' => true, + ), + ), + 'Markdown' => array( + 'text/x-markdown', + array( + 'mode' => 'markdown', + 'highlightFormatting' => true, + ), + ), + 'application/javascript' => array( 'application/javascript', $javascript ), + 'text/javascript' => array( 'text/javascript', $javascript ), + 'JSON' => array( + 'application/json', + array( + 'mode' => array( + 'name' => 'javascript', + 'json' => true, + ), + 'lint' => true, + 'autoCloseBrackets' => true, + 'matchBrackets' => true, + ), + ), + 'JSON-LD' => array( + 'application/ld+json', + array( + 'mode' => array( + 'name' => 'javascript', + 'jsonld' => true, + ), + 'lint' => true, + 'autoCloseBrackets' => true, + 'matchBrackets' => true, + ), + ), + 'JSX' => array( + 'text/jsx', + array( + 'mode' => 'jsx', + 'autoCloseBrackets' => true, + 'matchBrackets' => true, + ), + ), + 'nginx' => array( 'text/nginx', array( 'mode' => 'nginx' ) ), + 'PHP' => array( + 'application/x-httpd-php', + array( + 'mode' => 'php', + 'matchBrackets' => true, + ) + $markup, + ), + 'SQL' => array( + 'text/x-sql', + array( + 'mode' => 'sql', + 'autoCloseBrackets' => true, + 'matchBrackets' => true, + ), + ), + 'MySQL' => array( + 'text/x-mysql', + array( + 'mode' => 'sql', + 'autoCloseBrackets' => true, + 'matchBrackets' => true, + ), + ), + 'XML' => array( 'text/xml', array( 'mode' => 'xml' ) + $markup ), + 'SVG' => array( 'application/svg+xml', array( 'mode' => 'xml' ) + $markup ), + 'YAML' => array( 'text/x-yaml', array( 'mode' => 'yaml' ) ), + 'other type' => array( 'text/x-python', array( 'mode' => 'text/x-python' ) ), + 'plain text' => array( 'text/plain', array( 'mode' => 'text/plain' ) ), + 'empty type' => array( '', array( 'mode' => '' ) ), + ); + } + + /** + * Tests the CodeMirror mode detected from the file extension. + * + * @ticket 65819 + * + * @dataProvider data_file_names + * + * @param string $file File name. + * @param string|array $mode Expected CodeMirror mode. + */ + public function test_codemirror_mode_for_file( $file, $mode ) { + $this->assertSame( $mode, wp_get_code_editor_settings( array( 'file' => $file ) )['codemirror']['mode'] ); + } + + /** + * Data provider. + * + * @return array[] + */ + public static function data_file_names() { + return array( + // Extensions known to wp_get_mime_types(). + 'CSS file' => array( 'style.css', 'text/css' ), + 'HTML file' => array( 'index.html', 'htmlmixed' ), + 'JavaScript file' => array( 'script.js', 'javascript' ), + 'text file' => array( 'readme.txt', 'text/plain' ), + 'CSV file' => array( 'data.csv', 'text/csv' ), + + // Extensions supplied by the fallback list. + 'nginx configuration' => array( 'nginx.conf', 'nginx' ), + 'diff file' => array( 'changes.diff', 'diff' ), + 'patch file' => array( 'changes.patch', 'diff' ), + 'HTTP message' => array( 'request.http', 'message/http' ), + 'JavaScript module' => array( 'module.mjs', 'javascript' ), + 'JSX file' => array( 'component.jsx', 'jsx' ), + 'Less file' => array( 'style.less', 'text/x-less' ), + 'Markdown file' => array( 'readme.md', 'gfm' ), + 'PHP file' => array( 'functions.php', 'php' ), + 'PHTML file' => array( 'template.phtml', 'php' ), + 'SCSS file' => array( 'style.scss', 'text/x-scss' ), + 'Sass file' => array( 'style.sass', 'text/x-sass' ), + 'shell script' => array( 'deploy.sh', 'text/x-sh' ), + 'Bash script' => array( 'deploy.bash', 'text/x-sh' ), + 'SQL file' => array( 'schema.sql', 'sql' ), + 'SVG file' => array( 'icon.svg', 'xml' ), + 'XML file' => array( 'feed.xml', 'xml' ), + 'YAML file' => array( 'config.yml', 'yaml' ), + 'YAML file, long form' => array( 'config.yaml', 'yaml' ), + 'unknown extension' => array( 'file.unknown', 'text/plain' ), + 'dot file' => array( '.htaccess', 'text/plain' ), + + // Other file names. + 'uppercase extension' => array( 'STYLE.CSS', 'text/css' ), + 'uppercase fallback extension' => array( 'README.MD', 'gfm' ), + 'path with directories' => array( 'theme/assets/style.scss', 'text/x-scss' ), + 'file without extension' => array( 'Makefile', '' ), + 'dot in directory only' => array( 'theme.v2/Makefile', '' ), + ); + } + + /** + * Tests that the type argument takes precedence over the file name. + * + * @ticket 65819 + */ + public function test_type_takes_precedence_over_file() { + $settings = wp_get_code_editor_settings( + array( + 'type' => 'text/css', + 'file' => 'functions.php', + ) + ); + + $this->assertSame( 'text/css', $settings['codemirror']['mode'] ); + } + + /** + * Tests that JavaScript is parsed as a module only for .mjs files. + * + * @ticket 65819 + * + * @dataProvider data_module_files + * + * @param array $args Arguments. + * @param bool $expected Whether the script should be parsed as a module. + */ + public function test_jshint_module_for_mjs_files( $args, $expected ) { + $this->assertSame( $expected, wp_get_code_editor_settings( $args )['jshint']['module'] ); + } + + /** + * Data provider. + * + * @return array[] + */ + public static function data_module_files() { + return array( + '.mjs file' => array( array( 'file' => 'module.mjs' ), true ), + '.js file' => array( array( 'file' => 'script.js' ), false ), + 'type only' => array( array( 'type' => 'text/javascript' ), false ), + 'no file' => array( array(), false ), + 'empty file' => array( array( 'file' => '' ), false ), + ); + } + + /** + * Tests that the allowed post HTML is passed to HTMLHint for users who cannot use unfiltered HTML. + * + * @ticket 65819 + * + * @dataProvider data_unfiltered_html + * + * @param bool $can_use_unfiltered_html Whether the user can use unfiltered HTML. + */ + public function test_htmlhint_kses_rules_for_html( $can_use_unfiltered_html ) { + $this->allow_unfiltered_html( $can_use_unfiltered_html ); + + $htmlhint = wp_get_code_editor_settings( array( 'type' => 'text/html' ) )['htmlhint']; + + if ( $can_use_unfiltered_html ) { + $this->assertArrayNotHasKey( 'kses', $htmlhint, 'No KSES rules should be passed.' ); + } else { + $this->assertArrayHasKey( 'kses', $htmlhint, 'The KSES rules should be passed.' ); + $this->assertArrayHasKey( 'a', $htmlhint['kses'], 'Links should be allowed.' ); + $this->assertArrayHasKey( 'href', $htmlhint['kses']['a'], 'The href attribute should be allowed on links.' ); + $this->assertArrayNotHasKey( 'script', $htmlhint['kses'], 'Scripts should not be allowed.' ); + } + } + + /** + * Data provider. + * + * @return array[] + */ + public static function data_unfiltered_html() { + return array( + 'user can use unfiltered HTML' => array( true ), + 'user cannot use unfiltered HTML' => array( false ), + ); + } + + /** + * Tests that the KSES rules are only passed for HTML. + * + * @ticket 65819 + */ + public function test_htmlhint_kses_rules_only_for_html() { + $this->allow_unfiltered_html( false ); + + $this->assertArrayNotHasKey( 'kses', wp_get_code_editor_settings( array( 'type' => 'text/css' ) )['htmlhint'] ); + } + + /** + * Tests that settings passed in the arguments are merged over the defaults. + * + * @ticket 65819 + */ + public function test_arguments_override_defaults() { + $settings = wp_get_code_editor_settings( + array( + 'type' => 'text/css', + 'codemirror' => array( + 'indentUnit' => 2, + 'mode' => 'custom-mode', + ), + 'csslint' => array( 'outline-none' => false ), + 'jshint' => array( 'esversion' => 6 ), + 'htmlhint' => array( 'alt-require' => false ), + 'unknown' => array( 'key' => 'value' ), + ) + ); + + $this->assertSame( 2, $settings['codemirror']['indentUnit'], 'The CodeMirror setting should be overridden.' ); + $this->assertSame( 'custom-mode', $settings['codemirror']['mode'], 'The detected mode should be overridden.' ); + $this->assertTrue( $settings['codemirror']['indentWithTabs'], 'Other CodeMirror settings should be kept.' ); + $this->assertFalse( $settings['csslint']['outline-none'], 'The CSSLint rule should be overridden.' ); + $this->assertTrue( $settings['csslint']['errors'], 'Other CSSLint rules should be kept.' ); + $this->assertSame( 6, $settings['jshint']['esversion'], 'The JSHint option should be overridden.' ); + $this->assertTrue( $settings['jshint']['curly'], 'Other JSHint options should be kept.' ); + $this->assertFalse( $settings['htmlhint']['alt-require'], 'The HTMLHint rule should be overridden.' ); + $this->assertTrue( $settings['htmlhint']['id-unique'], 'Other HTMLHint rules should be kept.' ); + $this->assertSame( array( 'codemirror', 'csslint', 'jshint', 'htmlhint' ), array_keys( $settings ), 'Unknown arguments should not be added to the settings.' ); + } + + /** + * Tests that the settings are filterable, and that the filter receives the settings and arguments. + * + * @ticket 65819 + */ + public function test_wp_code_editor_settings_filter() { + $args = array( 'type' => 'text/css' ); + + $filter = new MockAction(); + add_filter( 'wp_code_editor_settings', array( $filter, 'filter' ), 10, 2 ); + add_filter( 'wp_code_editor_settings', '__return_false', 20 ); + + $this->assertFalse( wp_get_code_editor_settings( $args ), 'The filtered value should be returned.' ); + + $filter_args = $filter->get_args(); + + $this->assertCount( 1, $filter_args, 'The filter should run once.' ); + $this->assertSame( 'text/css', $filter_args[0][0]['codemirror']['mode'], 'The filter should receive the settings.' ); + $this->assertSame( $args, $filter_args[0][1], 'The filter should receive the arguments.' ); + } + + /** + * Grants or denies the unfiltered_html capability to the current user. + * + * @param bool $allow Whether to grant the capability. + */ + private function allow_unfiltered_html( $allow ) { + add_filter( + 'map_meta_cap', + static function ( $caps, $cap ) use ( $allow ) { + if ( 'unfiltered_html' === $cap ) { + return $allow ? array( 'exist' ) : array( 'do_not_allow' ); + } + + return $caps; + }, + 10, + 2 + ); + } +} From fda8803b14e56b9ec7fc448ad57161e477724aae Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:38:17 +0000 Subject: [PATCH 035/236] Tests: Add coverage for `in_category()`. Checks matching categories and empty category inputs against a post. Developed in: https://github.com/WordPress/wordpress-develop/pull/14379 Props shailu25, mukesh27. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64470 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/category/inCategory.php | 87 +++++++++++++++++++++ tests/phpunit/tests/taxonomy.php | 17 ---- 2 files changed, 87 insertions(+), 17 deletions(-) create mode 100644 tests/phpunit/tests/category/inCategory.php diff --git a/tests/phpunit/tests/category/inCategory.php b/tests/phpunit/tests/category/inCategory.php new file mode 100644 index 0000000000000..c14628170569b --- /dev/null +++ b/tests/phpunit/tests/category/inCategory.php @@ -0,0 +1,87 @@ +category->create_and_get( + array( + 'name' => 'Assigned Category', + 'slug' => 'assigned-category', + ) + ); + + self::$post = $factory->post->create_and_get( + array( + 'post_category' => array( self::$category->term_id ), + ) + ); + } + + /** + * Tests that in_category() returns true when the post is in the specified category. + * + * @ticket 25706 + * @ticket 65819 + */ + public function test_returns_true_when_post_is_in_matching_category() { + $this->assertTrue( in_category( self::$category->term_id, self::$post ) ); + } + + /** + * Tests that in_category() returns false when the category parameter is empty, + * even if the post has categories assigned. + * + * @ticket 25706 + * @ticket 65819 + * + * @dataProvider data_empty_categories + * + * @param mixed $empty_category Empty category value. + */ + public function test_returns_false_when_category_is_empty( $empty_category ) { + $this->assertFalse( in_category( $empty_category, self::$post ) ); + } + + /** + * Data provider. + * + * @return array[] + */ + public static function data_empty_categories() { + return array( + 'empty string' => array( '' ), + 'zero int' => array( 0 ), + 'zero string' => array( '0' ), + 'false' => array( false ), + 'null' => array( null ), + 'empty array' => array( array() ), + ); + } +} diff --git a/tests/phpunit/tests/taxonomy.php b/tests/phpunit/tests/taxonomy.php index 6f112c36663ec..d7f7587d8b122 100644 --- a/tests/phpunit/tests/taxonomy.php +++ b/tests/phpunit/tests/taxonomy.php @@ -472,23 +472,6 @@ public function test_post_deletion_should_invalidate_get_objects_in_term_cache() $this->assertSame( array(), $after ); } - /** - * @ticket 25706 - */ - public function test_in_category() { - $post = self::factory()->post->create_and_get(); - - // in_category() returns false when first parameter is empty(). - $this->assertFalse( in_category( '', $post ) ); - $this->assertFalse( in_category( false, $post ) ); - $this->assertFalse( in_category( null, $post ) ); - - // Test expected behavior of in_category(). - $term = wp_insert_term( 'Test', 'category' ); - wp_set_object_terms( $post->ID, $term['term_id'], 'category' ); - $this->assertTrue( in_category( $term['term_id'], $post ) ); - } - public function test_insert_category_create() { $cat = array( 'cat_ID' => 0, From 78a186728a41f03f0a0f021257bc6fd9c16b508f Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:39:26 +0000 Subject: [PATCH 036/236] Tests: Add coverage for `get_the_tags()`. Checks post ID, post object, and global-post lookup, plus empty results and the tags filter. Developed in: https://github.com/WordPress/wordpress-develop/pull/14380 Props shailu25, mukesh27. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64471 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/category/getTheTags.php | 110 ++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 tests/phpunit/tests/category/getTheTags.php diff --git a/tests/phpunit/tests/category/getTheTags.php b/tests/phpunit/tests/category/getTheTags.php new file mode 100644 index 0000000000000..26a3766c287a1 --- /dev/null +++ b/tests/phpunit/tests/category/getTheTags.php @@ -0,0 +1,110 @@ +tag->create_and_get( + array( + 'name' => 'Test Tag', + 'slug' => 'test-tag', + ) + ); + + self::$post = $factory->post->create_and_get( + array( + 'tags_input' => array( self::$tag->slug ), + ) + ); + } + + /** + * Tests that get_the_tags() returns an array of WP_Term objects for a post ID or WP_Post object. + * + * @ticket 65819 + */ + public function test_returns_tags_for_post_id_and_post_object() { + $tags_by_id = get_the_tags( self::$post->ID ); + + $this->assertIsArray( $tags_by_id ); + $this->assertCount( 1, $tags_by_id ); + $this->assertInstanceOf( WP_Term::class, $tags_by_id[0] ); + $this->assertSame( self::$tag->term_id, $tags_by_id[0]->term_id ); + $this->assertSame( 'post_tag', $tags_by_id[0]->taxonomy ); + + $tags_by_object = get_the_tags( self::$post ); + + $this->assertIsArray( $tags_by_object ); + $this->assertCount( 1, $tags_by_object ); + $this->assertSame( self::$tag->term_id, $tags_by_object[0]->term_id ); + } + + /** + * Tests that get_the_tags() defaults to the global post when no post argument is passed. + * + * @ticket 65819 + */ + public function test_defaults_to_global_post_when_post_is_omitted() { + $GLOBALS['post'] = self::$post; + + $tags = get_the_tags(); + + $this->assertIsArray( $tags ); + $this->assertCount( 1, $tags ); + $this->assertSame( self::$tag->term_id, $tags[0]->term_id ); + } + + /** + * Tests that get_the_tags() returns false when a post has no tags or does not exist. + * + * @ticket 65819 + */ + public function test_returns_false_when_no_tags_or_invalid_post() { + $untagged_post_id = self::factory()->post->create(); + + $this->assertFalse( get_the_tags( $untagged_post_id ) ); + $this->assertFalse( get_the_tags( 99999999 ) ); + $this->assertFalse( get_the_tags( 0 ) ); + } + + /** + * Tests that get_the_tags() applies the 'get_the_tags' filter. + * + * @ticket 65819 + */ + public function test_applies_get_the_tags_filter() { + $filter = new MockAction(); + add_filter( 'get_the_tags', array( $filter, 'filter' ) ); + + $tags = get_the_tags( self::$post->ID ); + + $this->assertSame( 1, $filter->get_call_count() ); + $this->assertSame( array( $tags ), $filter->get_args()[0] ); + } +} From f414f48fec7e82a3a04d5f9d7d779656a714021e Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:40:46 +0000 Subject: [PATCH 037/236] Tests: Add coverage for `image_edit_apply_changes()`. Check rotation and flip combination, cancellation, operation order, crop scaling, filter arguments, and the GD image path in `image_edit_apply_changes()`. Developed in: https://github.com/WordPress/wordpress-develop/pull/14383 Props huzaifaalmesbah, rejaulalomkhan. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64472 602fd350-edb4-49c9-b593-d223f7449a82 --- .../tests/image/imageEditApplyChanges.php | 316 ++++++++++++++++++ 1 file changed, 316 insertions(+) create mode 100644 tests/phpunit/tests/image/imageEditApplyChanges.php diff --git a/tests/phpunit/tests/image/imageEditApplyChanges.php b/tests/phpunit/tests/image/imageEditApplyChanges.php new file mode 100644 index 0000000000000..dcb3d4e61521a --- /dev/null +++ b/tests/phpunit/tests/image/imageEditApplyChanges.php @@ -0,0 +1,316 @@ +createMock( WP_Image_Editor::class ); + + $editor->method( 'get_size' )->willReturn( + array( + 'width' => $width, + 'height' => $height, + ) + ); + + // Number of arguments to record for each method, leaving out optional arguments the function never passes. + $arg_counts = array( + 'rotate' => 1, + 'flip' => 2, + 'crop' => 4, + ); + + foreach ( $arg_counts as $method => $arg_count ) { + $editor->method( $method )->willReturnCallback( + function ( ...$args ) use ( $method, $arg_count ) { + $this->operations[] = array_merge( array( $method ), array_slice( $args, 0, $arg_count ) ); + + return true; + } + ); + } + + return $editor; + } + + /** + * Builds the change operations as they are decoded from the image editor history. + * + * @param array[] $changes Change operations as associative arrays. + * @return object[] Change operations as objects. + */ + private static function to_changes( array $changes ) { + return json_decode( wp_json_encode( $changes ) ); + } + + /** + * Tests that the image is returned unchanged when the changes are not an array. + * + * @ticket 65819 + * + * @dataProvider data_changes_that_are_not_an_array + * + * @param mixed $changes Changes. + */ + public function test_returns_image_unchanged_when_changes_are_not_an_array( $changes ) { + $editor = $this->get_recording_editor(); + + $filter = new MockAction(); + add_filter( 'wp_image_editor_before_change', array( $filter, 'filter' ) ); + + $this->assertSame( $editor, image_edit_apply_changes( $editor, $changes ), 'The editor should be returned.' ); + $this->assertSame( array(), $this->operations, 'No operation should be applied.' ); + $this->assertSame( 0, $filter->get_call_count(), 'The filter should not run.' ); + } + + /** + * Data provider. + * + * @return array[] + */ + public static function data_changes_that_are_not_an_array() { + return array( + 'null' => array( null ), + 'false' => array( false ), + 'empty string' => array( '' ), + 'string' => array( '[{"r":90}]' ), + 'object' => array( (object) array( 'r' => 90 ) ), + ); + } + + /** + * Tests the editor operations applied for a list of changes. + * + * @ticket 65819 + * + * @dataProvider data_changes + * + * @param array[] $changes Change operations. + * @param array[] $expected Expected editor calls, each as the method name followed by its arguments. + */ + public function test_applies_changes_to_editor( $changes, $expected ) { + $editor = $this->get_recording_editor(); + + $this->assertSame( $editor, image_edit_apply_changes( $editor, self::to_changes( $changes ) ), 'The editor should be returned.' ); + $this->assertSame( $expected, $this->operations ); + } + + /** + * Data provider. + * + * @return array[] + */ + public static function data_changes() { + return array( + 'no changes' => array( array(), array() ), + 'rotate' => array( + array( array( 'r' => 90 ) ), + array( array( 'rotate', 90 ) ), + ), + 'consecutive rotations are summed' => array( + array( array( 'r' => 90 ), array( 'r' => 90 ), array( 'r' => -45 ) ), + array( array( 'rotate', 135 ) ), + ), + 'rotations that cancel out' => array( + array( array( 'r' => 90 ), array( 'r' => -90 ) ), + array(), + ), + 'zero rotation' => array( + array( array( 'r' => 0 ) ), + array(), + ), + 'horizontal flip' => array( + array( array( 'f' => 1 ) ), + array( array( 'flip', true, false ) ), + ), + 'vertical flip' => array( + array( array( 'f' => 2 ) ), + array( array( 'flip', false, true ) ), + ), + 'consecutive flips are combined' => array( + array( array( 'f' => 1 ), array( 'f' => 2 ) ), + array( array( 'flip', true, true ) ), + ), + 'flips that cancel out' => array( + array( array( 'f' => 1 ), array( 'f' => 1 ) ), + array(), + ), + 'crop with an explicit scale' => array( + array( + array( + 'c' => array( + 'x' => 10, + 'y' => 20, + 'w' => 30, + 'h' => 40, + 'r' => 1.5, + ), + ), + ), + array( array( 'crop', 15, 30, 45, 60 ) ), + ), + 'crop scaled from the preview' => array( + array( + array( + 'c' => array( + 'x' => 10, + 'y' => 20, + 'w' => 30, + 'h' => 40, + ), + ), + ), + // The 1200x900 image is previewed at 600x450, so the selection is doubled. + array( array( 'crop', 20, 40, 60, 80 ) ), + ), + 'crops are not combined' => array( + array( + array( + 'c' => array( + 'x' => 1, + 'y' => 2, + 'w' => 3, + 'h' => 4, + 'r' => 1, + ), + ), + array( + 'c' => array( + 'x' => 5, + 'y' => 6, + 'w' => 7, + 'h' => 8, + 'r' => 1, + ), + ), + ), + array( array( 'crop', 1, 2, 3, 4 ), array( 'crop', 5, 6, 7, 8 ) ), + ), + 'different operations keep their order' => array( + array( array( 'r' => 90 ), array( 'f' => 1 ), array( 'r' => 90 ) ), + array( array( 'rotate', 90 ), array( 'flip', true, false ), array( 'rotate', 90 ) ), + ), + 'only consecutive operations are combined' => array( + array( array( 'f' => 1 ), array( 'r' => 90 ), array( 'r' => 180 ), array( 'f' => 2 ), array( 'f' => 2 ) ), + array( array( 'flip', true, false ), array( 'rotate', 270 ) ), + ), + ); + } + + /** + * Tests that the crop selection is not scaled for images that fit the preview. + * + * @ticket 65819 + */ + public function test_crop_selection_is_not_scaled_for_small_images() { + $editor = $this->get_recording_editor( 300, 200 ); + + $changes = self::to_changes( + array( + array( + 'c' => array( + 'x' => 10, + 'y' => 20, + 'w' => 30, + 'h' => 40, + ), + ), + ) + ); + + image_edit_apply_changes( $editor, $changes ); + + $this->assertSame( array( array( 'crop', 10, 20, 30, 40 ) ), $this->operations ); + } + + /** + * Tests that the filter receives the editor and the expanded, combined changes, and can replace the editor. + * + * @ticket 65819 + */ + public function test_wp_image_editor_before_change_filter() { + $editor = $this->get_recording_editor(); + $replacement = $this->get_recording_editor(); + + $filter = new MockAction(); + add_filter( 'wp_image_editor_before_change', array( $filter, 'filter' ), 10, 2 ); + add_filter( + 'wp_image_editor_before_change', + static function () use ( $replacement ) { + return $replacement; + }, + 20 + ); + + $result = image_edit_apply_changes( $editor, self::to_changes( array( array( 'r' => 90 ), array( 'r' => 90 ), array( 'f' => 2 ) ) ) ); + + $this->assertSame( $replacement, $result, 'The filtered editor should be returned.' ); + + $args = $filter->get_args(); + + $this->assertCount( 1, $args, 'The filter should run once.' ); + $this->assertSame( $editor, $args[0][0], 'The filter should receive the editor.' ); + $this->assertSame( + array( + array( + 'type' => 'rotate', + 'angle' => 180, + ), + array( + 'type' => 'flip', + 'axis' => 2, + ), + ), + json_decode( wp_json_encode( $args[0][1] ), true ), + 'The filter should receive the expanded and combined changes.' + ); + } + + /** + * Tests that a GD image is still accepted, with a deprecation notice, and has the changes applied. + * + * @ticket 65819 + * + * @requires function imagecreatetruecolor + * + * @expectedDeprecated image_edit_apply_changes + * @expectedDeprecated _rotate_image_resource + */ + public function test_applies_changes_to_gd_image() { + $image = imagecreatetruecolor( 40, 20 ); + + $result = image_edit_apply_changes( $image, self::to_changes( array( array( 'r' => 90 ) ) ) ); + + $this->assertTrue( is_gd_image( $result ), 'A GD image should be returned.' ); + $this->assertSame( 20, imagesx( $result ), 'The image should be rotated.' ); + $this->assertSame( 40, imagesy( $result ), 'The image should be rotated.' ); + } +} From 8c60f28a342908ab765036d079ab21e388a5835a Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:41:47 +0000 Subject: [PATCH 038/236] Tests: Add coverage for `get_the_term_list()`. Checks term-link formatting, empty and error results, and the taxonomy-specific links filter. Developed in: https://github.com/WordPress/wordpress-develop/pull/14387 Props shailu25, rejaulalomkhan. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64473 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/term/getTheTermList.php | 147 ++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 tests/phpunit/tests/term/getTheTermList.php diff --git a/tests/phpunit/tests/term/getTheTermList.php b/tests/phpunit/tests/term/getTheTermList.php new file mode 100644 index 0000000000000..c9c56648dcf9b --- /dev/null +++ b/tests/phpunit/tests/term/getTheTermList.php @@ -0,0 +1,147 @@ +tag->create_and_get( + array( + 'name' => 'Alpha', + 'slug' => 'alpha', + ) + ); + + self::$tag_2 = $factory->tag->create_and_get( + array( + 'name' => 'Beta', + 'slug' => 'beta', + ) + ); + + self::$post_id = $factory->post->create( + array( + 'tags_input' => array( self::$tag_1->slug, self::$tag_2->slug ), + ) + ); + } + + /** + * Tests that get_the_term_list() formats term links with default and custom before, separator, and after strings. + * + * @ticket 65819 + */ + public function test_returns_formatted_term_links() { + $link_1 = ''; + $link_2 = ''; + + $this->assertSame( + $link_1 . $link_2, + get_the_term_list( self::$post_id, 'post_tag' ) + ); + + $this->assertSame( + 'Tags: ' . $link_1 . ', ' . $link_2 . '.', + get_the_term_list( self::$post_id, 'post_tag', 'Tags: ', ', ', '.' ) + ); + } + + /** + * Tests that get_the_term_list() returns false when the post has no terms in the taxonomy or does not exist. + * + * @ticket 65819 + */ + public function test_returns_false_when_no_terms_or_invalid_post() { + $untagged_post_id = self::factory()->post->create(); + + $this->assertFalse( get_the_term_list( $untagged_post_id, 'post_tag' ) ); + $this->assertFalse( get_the_term_list( 99999999, 'post_tag' ) ); + } + + /** + * Tests that get_the_term_list() returns a WP_Error when the taxonomy is invalid. + * + * @ticket 65819 + */ + public function test_returns_wp_error_for_invalid_taxonomy() { + $result = get_the_term_list( self::$post_id, 'invalid_taxonomy' ); + + $this->assertWPError( $result ); + $this->assertSame( 'invalid_taxonomy', $result->get_error_code() ); + } + + /** + * Tests that get_the_term_list() returns a WP_Error when get_term_link() fails for a term. + * + * @ticket 65819 + */ + public function test_returns_wp_error_when_get_term_link_returns_wp_error() { + add_filter( + 'get_the_terms', + static function () { + return array( 99999999 ); + } + ); + + $result = get_the_term_list( self::$post_id, 'post_tag' ); + + $this->assertWPError( $result ); + } + + /** + * Tests that get_the_term_list() applies the 'term_links-{$taxonomy}' filter. + * + * @ticket 65819 + */ + public function test_applies_term_links_taxonomy_filter() { + $link_1 = ''; + $link_2 = ''; + + $filter = new MockAction(); + add_filter( 'term_links-post_tag', array( $filter, 'filter' ) ); + add_filter( + 'term_links-post_tag', + static function () { + return array( '' ); + }, + 20 + ); + + $result = get_the_term_list( self::$post_id, 'post_tag', '(', ', ', ')' ); + + $this->assertSame( '()', $result ); + $this->assertSame( 1, $filter->get_call_count() ); + $this->assertSame( array( array( $link_1, $link_2 ) ), $filter->get_args()[0] ); + } +} From 94cbab270a533b816334e597e064a982166f95b6 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:43:03 +0000 Subject: [PATCH 039/236] Tests: Add coverage for `the_terms()`. Checks echoed term-link formatting, error suppression, and the display filter with its arguments. Developed in: https://github.com/WordPress/wordpress-develop/pull/14388 Props shailu25, rejaulalomkhan. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64474 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/term/theTerms.php | 117 ++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 tests/phpunit/tests/term/theTerms.php diff --git a/tests/phpunit/tests/term/theTerms.php b/tests/phpunit/tests/term/theTerms.php new file mode 100644 index 0000000000000..d4274305a9bb5 --- /dev/null +++ b/tests/phpunit/tests/term/theTerms.php @@ -0,0 +1,117 @@ +tag->create_and_get( + array( + 'name' => 'Alpha', + 'slug' => 'alpha', + ) + ); + + self::$tag_2 = $factory->tag->create_and_get( + array( + 'name' => 'Beta', + 'slug' => 'beta', + ) + ); + + self::$post_id = $factory->post->create( + array( + 'tags_input' => array( self::$tag_1->slug, self::$tag_2->slug ), + ) + ); + } + + /** + * Tests that the_terms() outputs formatted term links with default and custom arguments. + * + * @ticket 65819 + */ + public function test_outputs_formatted_term_links() { + $link_1 = ''; + $link_2 = ''; + + $default_output = get_echo( 'the_terms', array( self::$post_id, 'post_tag' ) ); + $this->assertSame( $link_1 . ', ' . $link_2, $default_output ); + + $custom_output = get_echo( 'the_terms', array( self::$post_id, 'post_tag', 'Tags: ', ' | ', '.' ) ); + $this->assertSame( 'Tags: ' . $link_1 . ' | ' . $link_2 . '.', $custom_output ); + } + + /** + * Tests that the_terms() returns false and outputs nothing when get_the_term_list() returns a WP_Error. + * + * @ticket 65819 + */ + public function test_returns_false_and_outputs_nothing_on_wp_error() { + ob_start(); + $result = the_terms( self::$post_id, 'invalid_taxonomy' ); + $output = ob_get_clean(); + + $this->assertFalse( $result ); + $this->assertSame( '', $output ); + } + + /** + * Tests that the_terms() applies the 'the_terms' filter to the output. + * + * @ticket 65819 + */ + public function test_applies_the_terms_filter() { + $expected_list = get_the_term_list( self::$post_id, 'post_tag', '(', ' - ', ')' ); + + $filter = new MockAction(); + add_filter( 'the_terms', array( $filter, 'filter' ), 10, 5 ); + add_filter( + 'the_terms', + static function () { + return 'filtered terms output'; + }, + 20 + ); + + $output = get_echo( 'the_terms', array( self::$post_id, 'post_tag', '(', ' - ', ')' ) ); + + $this->assertSame( 'filtered terms output', $output ); + $this->assertSame( 1, $filter->get_call_count() ); + $this->assertSame( + array( $expected_list, 'post_tag', '(', ' - ', ')' ), + $filter->get_args()[0] + ); + } +} From b6100bde930e407dcaff398412c7408f94c6a021 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:44:11 +0000 Subject: [PATCH 040/236] Tests: Add coverage for `term_description()`. Checks descriptions by term ID and queried archive object, including missing terms and non-archive requests. Developed in: https://github.com/WordPress/wordpress-develop/pull/14390 Props shailu25. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64475 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/term/termDescription.php | 105 +++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 tests/phpunit/tests/term/termDescription.php diff --git a/tests/phpunit/tests/term/termDescription.php b/tests/phpunit/tests/term/termDescription.php new file mode 100644 index 0000000000000..62eccebc3396b --- /dev/null +++ b/tests/phpunit/tests/term/termDescription.php @@ -0,0 +1,105 @@ +category->create_and_get( + array( + 'name' => 'Described Category', + 'slug' => 'described-category', + 'description' => 'Category description text', + ) + ); + + self::$tag = $factory->tag->create_and_get( + array( + 'name' => 'Described Tag', + 'slug' => 'described-tag', + 'description' => 'Tag description text', + ) + ); + } + + /** + * Tests that term_description() returns the formatted description for a given term ID. + * + * @ticket 65819 + */ + public function test_returns_description_for_term_id() { + $this->assertSame( + "

Category description text

\n", + term_description( self::$category->term_id ) + ); + + $this->assertSame( + "

Tag description text

\n", + term_description( self::$tag->term_id ) + ); + } + + /** + * Tests that term_description() defaults to the queried object on category, tag, and custom taxonomy archives. + * + * @ticket 65819 + */ + public function test_defaults_to_queried_object_on_term_archives() { + $this->go_to( get_category_link( self::$category->term_id ) ); + $this->assertTrue( is_category() ); + $this->assertSame( "

Category description text

\n", term_description() ); + + $this->go_to( get_tag_link( self::$tag->term_id ) ); + $this->assertTrue( is_tag() ); + $this->assertSame( "

Tag description text

\n", term_description() ); + + register_taxonomy( 'wptests_tax', 'post' ); + $custom_term = self::factory()->term->create_and_get( + array( + 'taxonomy' => 'wptests_tax', + 'description' => 'Custom taxonomy description text', + ) + ); + + $this->go_to( get_term_link( $custom_term, 'wptests_tax' ) ); + $this->assertTrue( is_tax() ); + $this->assertSame( "

Custom taxonomy description text

\n", term_description() ); + } + + /** + * Tests that term_description() returns an empty string when the term does not exist + * or when no term is passed outside a term archive. + * + * @ticket 65819 + */ + public function test_returns_empty_string_for_invalid_term_or_non_term_archive() { + $this->assertSame( '', term_description( 99999999 ) ); + + $this->go_to( home_url( '/' ) ); + $this->assertSame( '', term_description() ); + } +} From 597a351a0a3bcca14b95a3d2762e4734f8f219ff Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:45:32 +0000 Subject: [PATCH 041/236] Tests: Add coverage for `get_the_tag_list()`. Checks tag-link formatting for the current or explicit post, empty results, and the tags filter arguments. Developed in: https://github.com/WordPress/wordpress-develop/pull/14394 Props shailu25. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64476 602fd350-edb4-49c9-b593-d223f7449a82 --- .../phpunit/tests/category/getTheTagList.php | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 tests/phpunit/tests/category/getTheTagList.php diff --git a/tests/phpunit/tests/category/getTheTagList.php b/tests/phpunit/tests/category/getTheTagList.php new file mode 100644 index 0000000000000..47e1df3a9f048 --- /dev/null +++ b/tests/phpunit/tests/category/getTheTagList.php @@ -0,0 +1,124 @@ +tag->create_and_get( + array( + 'name' => 'Alpha', + 'slug' => 'alpha', + ) + ); + + self::$tag_2 = $factory->tag->create_and_get( + array( + 'name' => 'Beta', + 'slug' => 'beta', + ) + ); + + self::$post = $factory->post->create_and_get( + array( + 'tags_input' => array( self::$tag_1->slug, self::$tag_2->slug ), + ) + ); + } + + /** + * Tests that get_the_tag_list() formats post tag links with before, separator, and after strings + * and defaults to the global post when no post ID is passed. + * + * @ticket 65819 + */ + public function test_returns_formatted_tag_links() { + $GLOBALS['post'] = self::$post; + + $link_1 = ''; + $link_2 = ''; + + $this->assertSame( + $link_1 . $link_2, + get_the_tag_list() + ); + + $this->assertSame( + 'Tags: ' . $link_1 . ', ' . $link_2 . '.', + get_the_tag_list( 'Tags: ', ', ', '.', self::$post->ID ) + ); + } + + /** + * Tests that get_the_tag_list() returns false when a post has no tags or does not exist. + * + * @ticket 65819 + */ + public function test_returns_false_when_no_tags_or_invalid_post() { + $untagged_post_id = self::factory()->post->create(); + + $this->assertFalse( get_the_tag_list( '', ', ', '', $untagged_post_id ) ); + $this->assertFalse( get_the_tag_list( '', ', ', '', 99999999 ) ); + } + + /** + * Tests that get_the_tag_list() applies the 'the_tags' filter with all arguments. + * + * @ticket 65819 + */ + public function test_applies_the_tags_filter() { + $link_1 = ''; + $link_2 = ''; + + $filter = new MockAction(); + add_filter( 'the_tags', array( $filter, 'filter' ), 10, 5 ); + add_filter( + 'the_tags', + static function () { + return 'filtered tag list'; + }, + 20 + ); + + $result = get_the_tag_list( '(', ' | ', ')', self::$post->ID ); + + $this->assertSame( 'filtered tag list', $result ); + $this->assertSame( 1, $filter->get_call_count() ); + $this->assertSame( + array( '(' . $link_1 . ' | ' . $link_2 . ')', '(', ' | ', ')', self::$post->ID ), + $filter->get_args()[0] + ); + } +} From 916b0ced5b6752e0fafa03b2949c29b880c998ed Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:46:35 +0000 Subject: [PATCH 042/236] Tests: Add coverage for `the_tags()`. Checks default and custom tag-list output and suppresses output when tag retrieval returns an error. Developed in: https://github.com/WordPress/wordpress-develop/pull/14401 Props shailu25. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64477 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/category/theTags.php | 98 ++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 tests/phpunit/tests/category/theTags.php diff --git a/tests/phpunit/tests/category/theTags.php b/tests/phpunit/tests/category/theTags.php new file mode 100644 index 0000000000000..8de6e3b206ec1 --- /dev/null +++ b/tests/phpunit/tests/category/theTags.php @@ -0,0 +1,98 @@ +tag->create_and_get( + array( + 'name' => 'Alpha', + 'slug' => 'alpha', + ) + ); + + self::$tag_2 = $factory->tag->create_and_get( + array( + 'name' => 'Beta', + 'slug' => 'beta', + ) + ); + + self::$post = $factory->post->create_and_get( + array( + 'tags_input' => array( self::$tag_1->slug, self::$tag_2->slug ), + ) + ); + } + + /** + * Tests that the_tags() outputs formatted tag links with default and custom before, separator, and after strings. + * + * @ticket 65819 + */ + public function test_outputs_formatted_tag_links() { + $GLOBALS['post'] = self::$post; + + $link_1 = ''; + $link_2 = ''; + + $default_output = get_echo( 'the_tags' ); + $this->assertSame( 'Tags: ' . $link_1 . ', ' . $link_2, $default_output ); + + $custom_output = get_echo( 'the_tags', array( 'Filed under: ', ' | ', '.' ) ); + $this->assertSame( 'Filed under: ' . $link_1 . ' | ' . $link_2 . '.', $custom_output ); + } + + /** + * Tests that the_tags() outputs nothing when get_the_tag_list() returns a WP_Error. + * + * @ticket 65819 + */ + public function test_outputs_nothing_when_get_the_tag_list_returns_wp_error() { + $GLOBALS['post'] = self::$post; + + add_filter( + 'the_tags', + static function () { + return new WP_Error( 'tag_error', 'Failed to retrieve tags.' ); + } + ); + + $output = get_echo( 'the_tags' ); + + $this->assertSame( '', $output ); + } +} From 1ce5e8f56fc4a64aad793f781ec39ecc0dce973a Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:50:52 +0000 Subject: [PATCH 043/236] Tests: Add coverage for `the_author_meta()`. Checks current and explicit author fields and the dynamic author-field filter arguments. Developed in: https://github.com/WordPress/wordpress-develop/pull/14402 Props shailu25. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64478 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/user/theAuthorMeta.php | 108 +++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 tests/phpunit/tests/user/theAuthorMeta.php diff --git a/tests/phpunit/tests/user/theAuthorMeta.php b/tests/phpunit/tests/user/theAuthorMeta.php new file mode 100644 index 0000000000000..61a0f8c214e2f --- /dev/null +++ b/tests/phpunit/tests/user/theAuthorMeta.php @@ -0,0 +1,108 @@ +user->create( + array( + 'role' => 'author', + 'user_login' => 'test_author', + 'display_name' => 'Test Author', + 'user_email' => 'test_author@example.org', + ) + ); + + self::$post_id = $factory->post->create( + array( + 'post_author' => self::$author_id, + 'post_status' => 'publish', + ) + ); + } + + /** + * Sets up the global post data before each test. + */ + public function set_up() { + parent::set_up(); + + setup_postdata( get_post( self::$post_id ) ); + } + + /** + * Tests that the_author_meta() outputs the requested field for the current post author + * or for an explicitly provided user ID. + * + * @ticket 65819 + */ + public function test_outputs_author_meta_for_current_author_and_explicit_user_id() { + $this->assertSame( + 'Test Author', + get_echo( 'the_author_meta', array( 'display_name' ) ) + ); + + $other_user_id = self::factory()->user->create( + array( + 'display_name' => 'Other User', + ) + ); + + $this->assertSame( + 'Other User', + get_echo( 'the_author_meta', array( 'display_name', $other_user_id ) ) + ); + } + + /** + * Tests that the_author_meta() applies the dynamic 'the_author_{$field}' filter. + * + * @ticket 65819 + */ + public function test_applies_the_author_field_filter() { + $filter = new MockAction(); + add_filter( 'the_author_user_email', array( $filter, 'filter' ), 10, 2 ); + add_filter( + 'the_author_user_email', + static function () { + return 'filtered@example.org'; + }, + 20 + ); + + $output = get_echo( 'the_author_meta', array( 'user_email', self::$author_id ) ); + + $this->assertSame( 'filtered@example.org', $output ); + $this->assertSame( 1, $filter->get_call_count() ); + $this->assertSame( + array( 'test_author@example.org', self::$author_id ), + $filter->get_args()[0] + ); + } +} From 935dab655da75dad4faad8ce8254807e971e2171 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:52:14 +0000 Subject: [PATCH 044/236] Tests: Add coverage for `is_multi_author()`. Checks published-author counts, excluded drafts and pages, cached values, and the result filter. Developed in: https://github.com/WordPress/wordpress-develop/pull/14403 Props shailu25. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64479 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/user/isMultiAuthor.php | 146 +++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 tests/phpunit/tests/user/isMultiAuthor.php diff --git a/tests/phpunit/tests/user/isMultiAuthor.php b/tests/phpunit/tests/user/isMultiAuthor.php new file mode 100644 index 0000000000000..3e6052b030efa --- /dev/null +++ b/tests/phpunit/tests/user/isMultiAuthor.php @@ -0,0 +1,146 @@ +user->create( array( 'role' => 'author' ) ); + self::$author_2 = $factory->user->create( array( 'role' => 'author' ) ); + } + + /** + * Clears the multi-author transient before each test. + */ + public function set_up() { + parent::set_up(); + delete_transient( 'is_multi_author' ); + } + + /** + * Tests that is_multi_author() returns false when zero or one author has published posts + * and caches 0 in the 'is_multi_author' transient. + * + * @ticket 65819 + */ + public function test_returns_false_with_zero_or_single_author() { + $this->assertFalse( is_multi_author() ); + $this->assertSame( 0, get_transient( 'is_multi_author' ) ); + + self::factory()->post->create( + array( + 'post_author' => self::$author_1, + 'post_status' => 'publish', + ) + ); + + $this->assertFalse( is_multi_author() ); + $this->assertSame( 0, get_transient( 'is_multi_author' ) ); + } + + /** + * Tests that is_multi_author() returns true when two distinct authors have published posts + * and caches 1 in the 'is_multi_author' transient. + * + * @ticket 65819 + */ + public function test_returns_true_when_multiple_authors_have_published_posts() { + self::factory()->post->create( + array( + 'post_author' => self::$author_1, + 'post_status' => 'publish', + ) + ); + self::factory()->post->create( + array( + 'post_author' => self::$author_2, + 'post_status' => 'publish', + ) + ); + + $this->assertTrue( is_multi_author() ); + $this->assertSame( 1, get_transient( 'is_multi_author' ) ); + } + + /** + * Tests that is_multi_author() ignores draft posts and non-post post types from a second author. + * + * @ticket 65819 + */ + public function test_ignores_drafts_and_other_post_types() { + self::factory()->post->create( + array( + 'post_author' => self::$author_1, + 'post_status' => 'publish', + ) + ); + self::factory()->post->create( + array( + 'post_author' => self::$author_2, + 'post_status' => 'draft', + ) + ); + self::factory()->post->create( + array( + 'post_author' => self::$author_2, + 'post_status' => 'publish', + 'post_type' => 'page', + ) + ); + + $this->assertFalse( is_multi_author() ); + } + + /** + * Tests that is_multi_author() uses the cached 'is_multi_author' transient when available. + * + * @ticket 65819 + */ + public function test_uses_cached_transient_value() { + set_transient( 'is_multi_author', 1 ); + $this->assertTrue( is_multi_author() ); + + set_transient( 'is_multi_author', 0 ); + $this->assertFalse( is_multi_author() ); + } + + /** + * Tests that is_multi_author() applies the 'is_multi_author' filter. + * + * @ticket 65819 + */ + public function test_applies_is_multi_author_filter() { + $filter = new MockAction(); + add_filter( 'is_multi_author', array( $filter, 'filter' ) ); + add_filter( 'is_multi_author', '__return_true', 20 ); + + $this->assertTrue( is_multi_author() ); + $this->assertSame( 1, $filter->get_call_count() ); + $this->assertSame( array( false ), $filter->get_args()[0] ); + } +} From 7b8b2f426a52a29098daea98b5982f9b88592b36 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:53:25 +0000 Subject: [PATCH 045/236] Tests: Add coverage for `the_author()`. Checks returned and echoed author names and both deprecated argument behaviors. Developed in: https://github.com/WordPress/wordpress-develop/pull/14404 Props shailu25. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64480 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/user/theAuthor.php | 101 +++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 tests/phpunit/tests/user/theAuthor.php diff --git a/tests/phpunit/tests/user/theAuthor.php b/tests/phpunit/tests/user/theAuthor.php new file mode 100644 index 0000000000000..a3e1e3738cb1b --- /dev/null +++ b/tests/phpunit/tests/user/theAuthor.php @@ -0,0 +1,101 @@ +user->create( + array( + 'role' => 'author', + 'user_login' => 'test_author', + 'display_name' => 'Test Author', + ) + ); + + self::$post_id = $factory->post->create( + array( + 'post_author' => self::$author_id, + 'post_status' => 'publish', + ) + ); + } + + /** + * Sets up the global post data before each test. + */ + public function set_up() { + parent::set_up(); + + setup_postdata( get_post( self::$post_id ) ); + } + + /** + * Tests that the_author() outputs and returns the current post author's display name. + * + * @ticket 65819 + */ + public function test_outputs_and_returns_author_display_name() { + ob_start(); + $returned = the_author(); + $output = ob_get_clean(); + + $this->assertSame( 'Test Author', $returned ); + $this->assertSame( 'Test Author', $output ); + } + + /** + * Tests that passing a non-empty first argument triggers a deprecated argument notice. + * + * @ticket 65819 + * + * @expectedDeprecated the_author + */ + public function test_triggers_deprecated_argument_for_first_parameter() { + $output = get_echo( 'the_author', array( 'deprecated_value' ) ); + + $this->assertSame( 'Test Author', $output ); + } + + /** + * Tests that passing false for the second argument triggers a deprecated argument notice + * and returns the display name without echoing it. + * + * @ticket 65819 + * + * @expectedDeprecated the_author + */ + public function test_returns_without_echoing_when_deprecated_echo_is_false() { + ob_start(); + $returned = the_author( '', false ); + $output = ob_get_clean(); + + $this->assertSame( 'Test Author', $returned ); + $this->assertSame( '', $output ); + } +} From 9c7eaada8ba951aa9f10c09d86e3cb59e35bf744 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:54:26 +0000 Subject: [PATCH 046/236] Tests: Add coverage for `the_author_link()`. Checks linked and unlinked author output and the optional title attribute. Developed in: https://github.com/WordPress/wordpress-develop/pull/14405 Props shailu25. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64481 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/user/theAuthorLink.php | 109 +++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 tests/phpunit/tests/user/theAuthorLink.php diff --git a/tests/phpunit/tests/user/theAuthorLink.php b/tests/phpunit/tests/user/theAuthorLink.php new file mode 100644 index 0000000000000..d5ddffb4165d4 --- /dev/null +++ b/tests/phpunit/tests/user/theAuthorLink.php @@ -0,0 +1,109 @@ +user->create( + array( + 'role' => 'author', + 'user_login' => 'test_author', + 'display_name' => 'Test Author', + 'user_url' => 'http://example.com', + ) + ); + + self::$post_id = $factory->post->create( + array( + 'post_author' => self::$author_id, + 'post_status' => 'publish', + ) + ); + } + + /** + * Sets up the global post data before each test. + */ + public function set_up() { + parent::set_up(); + + setup_postdata( get_post( self::$post_id ) ); + } + + /** + * Tests that the_author_link() outputs the author website link with a title attribute by default. + * + * @ticket 65819 + */ + public function test_outputs_author_link_with_title_attribute_by_default() { + $output = get_echo( 'the_author_link' ); + + $this->assertSame( get_the_author_link(), $output ); + $this->assertStringContainsString( 'http://example.com', $output ); + $this->assertStringContainsString( 'Test Author', $output ); + $this->assertStringContainsString( 'title="', $output ); + } + + /** + * Tests that the_author_link() omits the title attribute when $use_title_attr is false. + * + * @ticket 65819 + */ + public function test_omits_title_attribute_when_use_title_attr_is_false() { + $output = get_echo( 'the_author_link', array( false ) ); + + $this->assertSame( get_the_author_link( false ), $output ); + $this->assertStringContainsString( 'http://example.com', $output ); + $this->assertStringNotContainsString( 'title="', $output ); + } + + /** + * Tests that the_author_link() outputs the author display name when the author has no website URL. + * + * @ticket 65819 + */ + public function test_outputs_author_name_when_author_has_no_url() { + $author_without_url = self::factory()->user->create( + array( + 'display_name' => 'No URL Author', + 'user_url' => '', + ) + ); + + $post_id = self::factory()->post->create( + array( + 'post_author' => $author_without_url, + ) + ); + + setup_postdata( get_post( $post_id ) ); + + $this->assertSame( 'No URL Author', get_echo( 'the_author_link' ) ); + } +} From a1e45a05504c135cdb769cf0ee0369340da339bb Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sat, 17 Oct 2026 23:55:37 +0000 Subject: [PATCH 047/236] Tests: Add coverage for `get_author_posts_url()`. Checks query-string and pretty author URLs, explicit nicenames, and the author-link filter arguments. Developed in: https://github.com/WordPress/wordpress-develop/pull/14406 Props shailu25, rejaulalomkhan. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64482 602fd350-edb4-49c9-b593-d223f7449a82 --- .../phpunit/tests/user/getAuthorPostsUrl.php | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 tests/phpunit/tests/user/getAuthorPostsUrl.php diff --git a/tests/phpunit/tests/user/getAuthorPostsUrl.php b/tests/phpunit/tests/user/getAuthorPostsUrl.php new file mode 100644 index 0000000000000..50b3982fe649f --- /dev/null +++ b/tests/phpunit/tests/user/getAuthorPostsUrl.php @@ -0,0 +1,109 @@ +user->create( + array( + 'role' => 'author', + 'user_login' => 'test_author', + 'user_nicename' => 'test-author', + 'display_name' => 'Test Author', + ) + ); + + $user = get_userdata( self::$author_id ); + self::$author_nicename = $user->user_nicename; + } + + /** + * Tests that get_author_posts_url() returns a query-string URL when pretty permalinks are not used. + * + * @ticket 65819 + */ + public function test_returns_query_string_url_without_permalinks() { + $this->assertSame( + 'http://' . WP_TESTS_DOMAIN . '/?author=' . self::$author_id, + get_author_posts_url( self::$author_id ) + ); + } + + /** + * Tests that get_author_posts_url() returns a pretty permalink when an author permastruct is available, + * and looks up the author nicename when it is omitted. + * + * @ticket 65819 + */ + public function test_returns_pretty_permalink_and_looks_up_nicename() { + $this->set_permalink_structure( '/%postname%/' ); + + $this->assertSame( + 'http://' . WP_TESTS_DOMAIN . '/author/' . self::$author_nicename . '/', + get_author_posts_url( self::$author_id ) + ); + + $this->assertSame( + 'http://' . WP_TESTS_DOMAIN . '/author/custom-nicename/', + get_author_posts_url( self::$author_id, 'custom-nicename' ) + ); + + $this->set_permalink_structure( '' ); + } + + /** + * Tests that get_author_posts_url() applies the 'author_link' filter. + * + * @ticket 65819 + */ + public function test_applies_author_link_filter() { + $filter = new MockAction(); + add_filter( 'author_link', array( $filter, 'filter' ), 10, 3 ); + add_filter( + 'author_link', + static function () { + return 'https://example.org/filtered-author/'; + }, + 20 + ); + + $result = get_author_posts_url( self::$author_id, self::$author_nicename ); + + $this->assertSame( 'https://example.org/filtered-author/', $result ); + $this->assertSame( 1, $filter->get_call_count() ); + $this->assertSame( + array( + 'http://' . WP_TESTS_DOMAIN . '/?author=' . self::$author_id, + self::$author_id, + self::$author_nicename, + ), + $filter->get_args()[0] + ); + } +} From e4d8bdda9ae42175a5f93c446868dba8d67136a1 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sun, 18 Oct 2026 00:10:05 +0000 Subject: [PATCH 048/236] Tests: Isolate the navigation menu ID filter per test. Remove `_nav_menu_item_id_use_once` in `Tests_Menu_wpNavMenu::set_up()` after the parent setup. The test harness restores hooks after each test, so removing the filter only during class setup allows it to return and strip menu-item IDs from later output. Rely on the normal per-test teardown to restore the filter. Developed in: https://github.com/WordPress/wordpress-develop/pull/14358 Props mukesh27. See #65893. git-svn-id: https://develop.svn.wordpress.org/trunk@64483 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/menu/wp-nav-menu.php | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/tests/phpunit/tests/menu/wp-nav-menu.php b/tests/phpunit/tests/menu/wp-nav-menu.php index 72f5932ad0bbe..840dbd42983bf 100644 --- a/tests/phpunit/tests/menu/wp-nav-menu.php +++ b/tests/phpunit/tests/menu/wp-nav-menu.php @@ -65,30 +65,21 @@ public static function set_up_before_class() { 'menu-item-status' => 'publish', ) ); - - /* - * This filter is used to prevent reusing a menu item ID more that once. - * It caused the tests to fail after the first one since the IDs are missing - * from the HTML generated by `wp_nav_menu()`. - * - * To allow the tests to pass, we remove the filter before running them - * and add it back after they ran ({@see Tests_Menu_wpNavMenu::tear_down_after_class()}). - */ - remove_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once' ); } public static function tear_down_after_class() { wp_delete_nav_menu( self::$menu_id ); - /* - * This filter was removed to let the tests pass and needs to be added back - * ({@see Tests_Menu_wpNavMenu::set_up_before_class}). - */ - add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 ); - parent::tear_down_after_class(); } + public function set_up() { + parent::set_up(); + + // Allow fixture IDs to appear in each test; tear_down() restores the filter. + remove_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once' ); + } + /** * Tests that all menu items containing children have the CSS class `menu-item-has-children` * when displaying the menu without specifying a custom depth. From e1ed2ab493160d688f67fc25608a96148b7aff2f Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Sun, 18 Oct 2026 00:24:57 +0000 Subject: [PATCH 049/236] Tests: Reuse existing fixtures in REST user tests. Reuse the author and subscriber fixtures in read-only and rejected-request tests in `WP_Test_REST_Users_Controller`, avoiding 13 user creations per class run. Preserve the requests, assertions, and include-query ordering checks. Keep fresh users for successful updates, deletions, and identity-specific scenarios, and retain per-test post and page fixtures. Developed in: https://github.com/WordPress/wordpress-develop/pull/14339 Props abcd95. See #66074. git-svn-id: https://develop.svn.wordpress.org/trunk@64484 602fd350-edb4-49c9-b593-d223f7449a82 --- .../tests/rest-api/rest-users-controller.php | 40 ++++++------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/tests/phpunit/tests/rest-api/rest-users-controller.php b/tests/phpunit/tests/rest-api/rest-users-controller.php index f0b63fcff80a4..bd4dfe358719f 100644 --- a/tests/phpunit/tests/rest-api/rest-users-controller.php +++ b/tests/phpunit/tests/rest-api/rest-users-controller.php @@ -656,8 +656,8 @@ public function test_get_items_offset() { public function test_get_items_include_query() { wp_set_current_user( self::$user ); - $id1 = self::factory()->user->create(); - $id2 = self::factory()->user->create(); + $id1 = self::$author; + $id2 = self::$subscriber; $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); @@ -691,8 +691,8 @@ public function test_get_items_include_query() { public function test_get_items_exclude_query() { wp_set_current_user( self::$user ); - $id1 = self::factory()->user->create(); - $id2 = self::factory()->user->create(); + $id1 = self::$subscriber; + $id2 = self::$author; $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); $request->set_param( 'per_page', self::$per_page ); // There are >10 users at this point. @@ -1089,7 +1089,7 @@ public function test_get_items_who_unauthorized_query() { } public function test_get_item() { - $user_id = self::factory()->user->create(); + $user_id = self::$subscriber; wp_set_current_user( self::$user ); @@ -1242,11 +1242,7 @@ public function test_cannot_get_item_author_of_draft() { } public function test_get_item_published_author_post() { - $author_id = self::factory()->user->create( - array( - 'role' => 'author', - ) - ); + $author_id = self::$author; $post_id = self::factory()->post->create( array( @@ -1262,11 +1258,7 @@ public function test_get_item_published_author_post() { } public function test_get_item_published_author_pages() { - $author_id = self::factory()->user->create( - array( - 'role' => 'author', - ) - ); + $author_id = self::$author; wp_set_current_user( 0 ); @@ -1286,7 +1278,7 @@ public function test_get_item_published_author_pages() { } public function test_get_user_with_edit_context() { - $user_id = self::factory()->user->create(); + $user_id = self::$subscriber; $this->allow_user_to_manage_multisite(); @@ -1297,11 +1289,7 @@ public function test_get_user_with_edit_context() { } public function test_get_item_published_author_wrong_context() { - $author_id = self::factory()->user->create( - array( - 'role' => 'author', - ) - ); + $author_id = self::$author; $post_id = self::factory()->post->create( array( @@ -2183,11 +2171,7 @@ public function test_update_user_invalid_id() { * @ticket 40263 */ public function test_update_item_only_roles_as_editor() { - $user_id = self::factory()->user->create( - array( - 'role' => 'author', - ) - ); + $user_id = self::$author; wp_set_current_user( self::$editor ); @@ -2595,7 +2579,7 @@ public function test_delete_current_item_no_trash() { } public function test_delete_user_without_permission() { - $user_id = self::factory()->user->create(); + $user_id = self::$subscriber; $this->allow_user_to_manage_multisite(); @@ -3316,7 +3300,7 @@ public function test_get_items_only_fetches_ids_for_head_requests( $method ) { * @param string $path The path to test. */ public function test_head_request_with_specified_fields_returns_success_response( $path ) { - $user_id = self::factory()->user->create(); + $user_id = self::$subscriber; wp_set_current_user( self::$user ); $request = new WP_REST_Request( 'HEAD', sprintf( $path, $user_id ) ); From acf82f5ebd92b7a5a8e12350038e52ac6634fd0f Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Sun, 18 Oct 2026 02:56:08 +0000 Subject: [PATCH 050/236] Script Loader: Remove obsolete compression constants. Scripts and styles have not been compressed from PHP since WordPress 4.9.9, when `load-scripts.php` and `load-styles.php` stopped reading the `c` argument in r43580. Even so, the `COMPRESS_SCRIPTS`, `COMPRESS_CSS` and `ENFORCE_GZIP` constants were still documented and read, only to set that unused argument on the loader URLs. That code and documentation are removed. The `$compress_scripts` and `$compress_css` globals are kept for backward compatibility with code that reads them, but they now default to false since nothing is compressed, and a value already set by a plugin is still left alone. The compression test, which still runs in the admin, is to be removed separately. Developed in https://github.com/WordPress/wordpress-develop/pull/8409. Follow-up to r10442, r43580, r64320, r64321. Props sainathpoojary, westonruter, zodiac1978, dpknauss, azaozz. See #44815, #57548, #58302, #65980. Fixes #63017. git-svn-id: https://develop.svn.wordpress.org/trunk@64485 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/script-loader.php | 52 ++------- .../dependencies/scriptConcatSettings.php | 106 ++++++++++++++++++ tests/phpunit/tests/dependencies/scripts.php | 81 +++++++------ tests/phpunit/tests/dependencies/styles.php | 5 +- 4 files changed, 168 insertions(+), 76 deletions(-) create mode 100644 tests/phpunit/tests/dependencies/scriptConcatSettings.php diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index dfaaf73ede55a..629f537fb3b09 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -2,16 +2,11 @@ /** * WordPress scripts and styles default loader. * - * Several constants are used to manage the loading, concatenating and compression of scripts and CSS: - * define('SCRIPT_DEBUG', true); loads the development (non-minified) versions of all scripts and CSS, and disables compression and concatenation, - * define('CONCATENATE_SCRIPTS', true); enables concatenation of scripts and CSS in the admin and on the login screen (disabled by default), - * define('COMPRESS_SCRIPTS', false); disables compression of scripts, - * define('COMPRESS_CSS', false); disables compression of CSS, - * define('ENFORCE_GZIP', true); forces gzip for compression (default is deflate). + * These constants are used to manage the loading and concatenating of scripts and CSS: + * define('SCRIPT_DEBUG', true); loads the development (non-minified) versions of all scripts and CSS, and disables concatenation, + * define('CONCATENATE_SCRIPTS', true); enables concatenation of scripts and CSS in the admin and on the login screen (disabled by default). * - * The globals $concatenate_scripts, $compress_scripts and $compress_css can be set by plugins - * to temporarily override the above settings. Also a compression test is run once and the result is saved - * as option 'can_compress_scripts' (0/1). The test will run again if that option is deleted. + * The global $concatenate_scripts can be set by plugins to temporarily override the above settings. * * @package WordPress */ @@ -2238,15 +2233,9 @@ function print_footer_scripts() { * @ignore * * @global WP_Scripts $wp_scripts - * @global bool $compress_scripts */ function _print_scripts() { - global $wp_scripts, $compress_scripts; - - $zip = $compress_scripts ? 1 : 0; - if ( $zip && defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP ) { - $zip = 'gzip'; - } + global $wp_scripts; $concat = trim( $wp_scripts->concat, ', ' ); @@ -2262,7 +2251,7 @@ function _print_scripts() { $concatenated .= "&load%5Bchunk_{$key}%5D={$chunk}"; } - $src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}" . $concatenated . '&ver=' . $wp_scripts->default_version; + $src = $wp_scripts->base_url . '/wp-admin/load-scripts.php?' . ltrim( $concatenated, '&' ) . '&ver=' . $wp_scripts->default_version; wp_print_script_tag( array( 'src' => $src ) ); } @@ -2422,19 +2411,10 @@ function print_late_styles() { * * @ignore * @since 3.3.0 - * - * @global bool $compress_css */ function _print_styles() { - global $compress_css; - $wp_styles = wp_styles(); - $zip = $compress_css ? 1 : 0; - if ( $zip && defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP ) { - $zip = 'gzip'; - } - $concat = trim( $wp_styles->concat, ', ' ); if ( $concat ) { @@ -2449,7 +2429,7 @@ function _print_styles() { $concatenated .= "&load%5Bchunk_{$key}%5D={$chunk}"; } - $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}" . $concatenated . '&ver=' . $ver; + $href = $wp_styles->base_url . "/wp-admin/load-styles.php?dir={$dir}" . $concatenated . '&ver=' . $ver; echo "\n"; if ( ! empty( $wp_styles->print_code ) ) { @@ -2468,9 +2448,11 @@ function _print_styles() { } /** - * Determines the concatenation and compression settings for scripts and styles. + * Determines the concatenation settings for scripts and styles. * * @since 2.8.0 + * @since 7.2.0 The `$compress_scripts` and `$compress_css` globals default to false, as PHP compression + * of scripts and styles was removed in 4.9.9. * * @global bool $concatenate_scripts * @global bool $compress_scripts @@ -2479,26 +2461,16 @@ function _print_styles() { function script_concat_settings() { global $concatenate_scripts, $compress_scripts, $compress_css; - $compressed_output = ( ini_get( 'zlib.output_compression' ) || 'ob_gzhandler' === ini_get( 'output_handler' ) ); - - $can_compress_scripts = ! wp_installing() && get_site_option( 'can_compress_scripts' ); - if ( ! isset( $concatenate_scripts ) ) { $concatenate_scripts = ( is_admin() || did_action( 'login_init' ) ) && wp_should_concatenate_admin_scripts(); } if ( ! isset( $compress_scripts ) ) { - $compress_scripts = defined( 'COMPRESS_SCRIPTS' ) ? COMPRESS_SCRIPTS : true; - if ( $compress_scripts && ( ! $can_compress_scripts || $compressed_output ) ) { - $compress_scripts = false; - } + $compress_scripts = false; } if ( ! isset( $compress_css ) ) { - $compress_css = defined( 'COMPRESS_CSS' ) ? COMPRESS_CSS : true; - if ( $compress_css && ( ! $can_compress_scripts || $compressed_output ) ) { - $compress_css = false; - } + $compress_css = false; } } diff --git a/tests/phpunit/tests/dependencies/scriptConcatSettings.php b/tests/phpunit/tests/dependencies/scriptConcatSettings.php new file mode 100644 index 0000000000000..01b2ade589e3c --- /dev/null +++ b/tests/phpunit/tests/dependencies/scriptConcatSettings.php @@ -0,0 +1,106 @@ + + */ + private array $original_globals = array(); + + /** + * Backs up and unsets the globals, so that script_concat_settings() sets their defaults. + */ + public function set_up(): void { + parent::set_up(); + + foreach ( self::GLOBAL_NAMES as $name ) { + if ( array_key_exists( $name, $GLOBALS ) ) { + $this->original_globals[ $name ] = $GLOBALS[ $name ]; + } + unset( $GLOBALS[ $name ] ); + } + } + + /** + * Restores the globals. + */ + public function tear_down(): void { + foreach ( self::GLOBAL_NAMES as $name ) { + if ( array_key_exists( $name, $this->original_globals ) ) { + $GLOBALS[ $name ] = $this->original_globals[ $name ]; + } else { + unset( $GLOBALS[ $name ] ); + } + } + + parent::tear_down(); + } + + /** + * Tests that the compression globals default to false, as scripts and styles are not compressed from PHP. + * + * @ticket 63017 + */ + public function test_compression_globals_default_to_false(): void { + // The result of the compression test, which used to turn the compression globals on. + update_site_option( 'can_compress_scripts', 1 ); + + script_concat_settings(); + + $this->assertFalse( $GLOBALS['compress_scripts'], 'Expected the $compress_scripts global to default to false.' ); + $this->assertFalse( $GLOBALS['compress_css'], 'Expected the $compress_css global to default to false.' ); + } + + /** + * Tests that the obsolete `COMPRESS_SCRIPTS` and `COMPRESS_CSS` constants no longer set the compression globals. + * + * @ticket 63017 + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function test_compression_constants_are_ignored(): void { + define( 'COMPRESS_SCRIPTS', true ); + define( 'COMPRESS_CSS', true ); + update_site_option( 'can_compress_scripts', 1 ); + + script_concat_settings(); + + $this->assertFalse( $GLOBALS['compress_scripts'], 'Expected the COMPRESS_SCRIPTS constant to be ignored.' ); + $this->assertFalse( $GLOBALS['compress_css'], 'Expected the COMPRESS_CSS constant to be ignored.' ); + } + + /** + * Tests that values a plugin has already set for the compression globals are kept. + * + * @ticket 63017 + */ + public function test_compression_globals_already_set_are_kept(): void { + $GLOBALS['compress_scripts'] = true; + $GLOBALS['compress_css'] = true; + + script_concat_settings(); + + $this->assertTrue( $GLOBALS['compress_scripts'], 'Expected the $compress_scripts global to be kept.' ); + $this->assertTrue( $GLOBALS['compress_css'], 'Expected the $compress_css global to be kept.' ); + } +} diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php index f80fd7c9c8e2c..d85e353380051 100644 --- a/tests/phpunit/tests/dependencies/scripts.php +++ b/tests/phpunit/tests/dependencies/scripts.php @@ -35,11 +35,6 @@ class Tests_Dependencies_Scripts extends WP_UnitTestCase { */ protected $old_concatenate_scripts; - /** - * @var mixed - */ - protected $old_compress_scripts; - /** * @var WP_Styles */ @@ -59,7 +54,6 @@ public function set_up() { $this->old_wp_scripts = $GLOBALS['wp_scripts'] ?? null; $this->old_wp_styles = $GLOBALS['wp_styles'] ?? null; $this->old_concatenate_scripts = $GLOBALS['concatenate_scripts'] ?? null; - $this->old_compress_scripts = $GLOBALS['compress_scripts'] ?? null; remove_action( 'wp_default_scripts', 'wp_default_scripts' ); remove_action( 'wp_default_scripts', 'wp_default_packages' ); $GLOBALS['wp_scripts'] = new WP_Scripts(); @@ -83,7 +77,6 @@ public function tear_down() { $GLOBALS['wp_scripts'] = $this->old_wp_scripts; $GLOBALS['wp_styles'] = $this->old_wp_styles; $GLOBALS['concatenate_scripts'] = $this->old_concatenate_scripts; - $GLOBALS['compress_scripts'] = $this->old_compress_scripts; add_action( 'wp_default_scripts', 'wp_default_scripts' ); parent::tear_down(); } @@ -2177,6 +2170,10 @@ public function test_script_strategy_doing_it_wrong_via_enqueue() { * @covers WP_Scripts::do_item * @covers ::wp_enqueue_script * @covers ::wp_register_script + * + * @global WP_Scripts $wp_scripts + * @global bool $concatenate_scripts + * @global string $wp_version */ public function test_concatenate_with_defer_strategy() { global $wp_scripts, $concatenate_scripts, $wp_version; @@ -2194,7 +2191,7 @@ public function test_concatenate_with_defer_strategy() { wp_print_scripts(); $print_scripts = get_echo( '_print_scripts' ); - $expected = "\n"; + $expected = "\n"; $expected .= "\n"; $this->assertEqualHTML( $expected, $print_scripts, '', 'Scripts are being incorrectly concatenated when a main script is registered with a "defer" loading strategy. Deferred scripts should not be part of the script concat loading query.' ); @@ -2208,6 +2205,10 @@ public function test_concatenate_with_defer_strategy() { * @covers WP_Scripts::do_item * @covers ::wp_enqueue_script * @covers ::wp_register_script + * + * @global WP_Scripts $wp_scripts + * @global bool $concatenate_scripts + * @global string $wp_version */ public function test_concatenate_with_async_strategy() { global $wp_scripts, $concatenate_scripts, $wp_version; @@ -2225,7 +2226,7 @@ public function test_concatenate_with_async_strategy() { wp_print_scripts(); $print_scripts = get_echo( '_print_scripts' ); - $expected = "\n"; + $expected = "\n"; $expected .= "\n"; $this->assertEqualHTML( $expected, $print_scripts, '', 'Scripts are being incorrectly concatenated when a main script is registered with an "async" loading strategy. Async scripts should not be part of the script concat loading query.' ); @@ -2240,6 +2241,10 @@ public function test_concatenate_with_async_strategy() { * @covers WP_Scripts::do_item * @covers ::wp_enqueue_script * @covers ::wp_register_script + * + * @global WP_Scripts $wp_scripts + * @global bool $concatenate_scripts + * @global string $wp_version */ public function test_concatenate_with_blocking_script_before_and_after_script_with_defer_strategy() { global $wp_scripts, $concatenate_scripts, $wp_version; @@ -2260,7 +2265,7 @@ public function test_concatenate_with_blocking_script_before_and_after_script_wi wp_print_scripts(); $print_scripts = get_echo( '_print_scripts' ); - $expected = "\n"; + $expected = "\n"; $expected .= "\n"; $this->assertEqualHTML( $expected, $print_scripts, '', 'Scripts are being incorrectly concatenated when a main script is registered as deferred after other blocking scripts are registered. Deferred scripts should not be part of the script concat loader query string. ' ); @@ -2330,7 +2335,7 @@ public function test_script_concatenation() { wp_print_scripts(); $print_scripts = get_echo( '_print_scripts' ); - $expected = "\n"; + $expected = "\n"; $this->assertEqualHTML( $expected, $print_scripts ); } @@ -2751,6 +2756,9 @@ public function test_wp_add_inline_script_before_with_concat2() { /** * @ticket 14853 + * + * @global WP_Scripts $wp_scripts + * @global string $wp_version */ public function test_wp_add_inline_script_after_with_concat() { global $wp_scripts, $wp_version; @@ -2766,7 +2774,7 @@ public function test_wp_add_inline_script_after_with_concat() { wp_add_inline_script( 'two', 'console.log("after two");' ); wp_add_inline_script( 'three', 'console.log("after three");' ); - $expected = "\n"; + $expected = "\n"; $expected .= "\n"; $expected .= "\n"; $expected .= "\n"; @@ -2805,6 +2813,9 @@ public function test_wp_add_inline_script_after_and_before_with_concat_and_condi /** * @ticket 36392 + * + * @global WP_Scripts $wp_scripts + * @global string $wp_version */ public function test_wp_add_inline_script_after_with_concat_and_core_dependency() { global $wp_scripts, $wp_version; @@ -2814,7 +2825,7 @@ public function test_wp_add_inline_script_after_with_concat_and_core_dependency( $wp_scripts->base_url = ''; $wp_scripts->do_concat = true; - $expected = "\n"; + $expected = "\n"; $expected .= "\n"; $expected .= "\n"; @@ -2853,6 +2864,9 @@ public function test_wp_add_inline_script_after_with_concat_and_conditional_and_ /** * @ticket 36392 + * + * @global WP_Scripts $wp_scripts + * @global string $wp_version */ public function test_wp_add_inline_script_before_with_concat_and_core_dependency() { global $wp_scripts, $wp_version; @@ -2863,7 +2877,7 @@ public function test_wp_add_inline_script_before_with_concat_and_core_dependency $wp_scripts->base_url = ''; $wp_scripts->do_concat = true; - $expected = "\n"; + $expected = "\n"; $expected .= "\n"; $expected .= "\n"; @@ -2878,6 +2892,9 @@ public function test_wp_add_inline_script_before_with_concat_and_core_dependency /** * @ticket 36392 + * + * @global WP_Scripts $wp_scripts + * @global string $wp_version */ public function test_wp_add_inline_script_before_after_concat_with_core_dependency() { global $wp_scripts, $wp_version; @@ -2888,7 +2905,7 @@ public function test_wp_add_inline_script_before_after_concat_with_core_dependen $wp_scripts->base_url = ''; $wp_scripts->do_concat = true; - $expected = "\n"; + $expected = "\n"; $expected .= "\n"; @@ -2987,6 +3004,9 @@ public function test_wp_add_inline_script_after_for_core_scripts_with_concat_is_ /** * @ticket 36392 + * + * @global WP_Scripts $wp_scripts + * @global string $wp_version */ public function test_wp_add_inline_script_before_third_core_script_prints_two_concat_scripts() { global $wp_scripts, $wp_version; @@ -3000,7 +3020,7 @@ public function test_wp_add_inline_script_before_third_core_script_prints_two_co wp_add_inline_script( 'three', 'console.log("before three");', 'before' ); wp_enqueue_script( 'four', '/wp-includes/js/script4.js' ); - $expected = "\n"; + $expected = "\n"; $expected .= "\n"; $expected .= "\n"; $expected .= "\n"; @@ -3801,6 +3821,9 @@ public function data_wp_localize_script_data_formats() { * @ticket 55628 * * @covers ::wp_set_script_translations + * + * @global WP_Scripts $wp_scripts + * @global string $wp_version */ public function test_wp_external_wp_i18n_print_order() { global $wp_scripts, $wp_version; @@ -3824,7 +3847,7 @@ static function () { ); // The non-default script should end concatenation and maintain order. - $expected = "\n"; + $expected = "\n"; $expected .= "\n"; $expected .= "\n"; @@ -3855,13 +3878,11 @@ public function test_printing_tinymce_scripts() { * @dataProvider data_register_tinymce_scripts_unbundled * * @param bool $concatenate Value of the `$concatenate_scripts` global. - * @param bool $compress Value of the `$compress_scripts` global. */ - public function test_register_tinymce_scripts_unbundled( bool $concatenate, bool $compress ): void { - global $concatenate_scripts, $compress_scripts; + public function test_register_tinymce_scripts_unbundled( bool $concatenate ): void { + global $concatenate_scripts; $concatenate_scripts = $concatenate; - $compress_scripts = $compress; $wp_scripts = wp_scripts(); wp_register_tinymce_scripts( $wp_scripts ); @@ -3881,25 +3902,15 @@ public function test_register_tinymce_scripts_unbundled( bool $concatenate, bool /** * Data provider for test_register_tinymce_scripts_unbundled(). * - * @return array + * @return array */ public function data_register_tinymce_scripts_unbundled(): array { return array( - 'concatenated and compressed' => array( - 'concatenate' => true, - 'compress' => true, - ), - 'concatenated only' => array( + 'concatenated' => array( 'concatenate' => true, - 'compress' => false, - ), - 'compressed only' => array( - 'concatenate' => false, - 'compress' => true, ), - 'neither' => array( + 'not concatenated' => array( 'concatenate' => false, - 'compress' => false, ), ); } @@ -4436,7 +4447,7 @@ public function test_source_url_with_concat() { var one = {"key":"val"};var two = {"key":"val"}; //# sourceURL=js-inline-concat-one%2Ctwo - + HTML; diff --git a/tests/phpunit/tests/dependencies/styles.php b/tests/phpunit/tests/dependencies/styles.php index 6f394d8c78697..cd0768ecc5a54 100644 --- a/tests/phpunit/tests/dependencies/styles.php +++ b/tests/phpunit/tests/dependencies/styles.php @@ -911,6 +911,9 @@ public function test_source_url_encoding() { /** * @ticket 63887 + * + * @global WP_Styles $wp_styles + * @global string $wp_version */ public function test_source_url_with_concat() { global $wp_styles, $wp_version; @@ -930,7 +933,7 @@ public function test_source_url_with_concat() { $expected = << ' ); - $processor->next_tag(); - $style_tag_contents = "\n{$wp_styles->print_code}\n" - . sprintf( "/*# sourceURL=%s */\n", rawurlencode( $concat_source_url ) ); - $processor->set_modifiable_text( $style_tag_contents ); - echo "{$processor->get_updated_html()}\n"; - } - } - - if ( ! empty( $wp_styles->print_html ) ) { - echo $wp_styles->print_html; - } -} - -/** - * Determines the concatenation settings for scripts and styles. - * - * @since 2.8.0 - * @since 7.2.0 The `$compress_scripts` and `$compress_css` globals default to false, as PHP compression - * of scripts and styles was removed in 4.9.9. - * - * @global bool $concatenate_scripts - * @global bool $compress_scripts - * @global bool $compress_css - */ -function script_concat_settings() { - global $concatenate_scripts, $compress_scripts, $compress_css; - - if ( ! isset( $concatenate_scripts ) ) { - $concatenate_scripts = ( is_admin() || did_action( 'login_init' ) ) && wp_should_concatenate_admin_scripts(); - } - - if ( ! isset( $compress_scripts ) ) { - $compress_scripts = false; - } - - if ( ! isset( $compress_css ) ) { - $compress_css = false; - } -} - -/** - * Determines whether scripts and styles are concatenated on admin screens and the login screen. - * - * Concatenation is off unless the `CONCATENATE_SCRIPTS` constant turns it on, and `SCRIPT_DEBUG` - * turns it off regardless. Scripts and styles are never concatenated elsewhere. - * - * This is the default that script_concat_settings() gives the `$concatenate_scripts` global when - * the global has not already been set. It is also how wp_prefetch_admin_assets() predicts, from the - * login screen, what the admin screen the login leads to will do. - * - * This function and its filter are intended to be removed before 7.2-beta1. They exist only while - * concatenation is still an option, and once concatenation is retired, there is nothing left for - * them to decide. Do not rely on them; setting the `$concatenate_scripts` global remains the way - * to override concatenation on a request. - * - * @since 7.2.0 - * - * @return bool Whether scripts and styles are concatenated on admin screens and the login screen. - */ -function wp_should_concatenate_admin_scripts(): bool { - $concatenate = ( defined( 'CONCATENATE_SCRIPTS' ) ? (bool) CONCATENATE_SCRIPTS : false ) - && ! ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ); - - /** - * Filters whether scripts and styles are concatenated on admin screens and the login screen. - * - * Setting the `$concatenate_scripts` global directly still takes precedence over this filter on - * the request where it is set. - * - * An admin screen settles the global the first time scripts are registered, when the - * {@see 'wp_default_scripts'} action registers TinyMCE. That can be as early as while plugins - * load, before the theme's functions.php, whereas the login screen reads this filter only when - * it prints, to predict what the admin will do. So add a callback when a plugin loads, rather - * than from a theme or on a later hook, or the admin may not see it while the login screen does. - * - * @since 7.2.0 - * - * @param bool $concatenate Whether scripts and styles are concatenated. Default false, unless the - * `CONCATENATE_SCRIPTS` constant is true and `SCRIPT_DEBUG` is not. - */ - return (bool) apply_filters( 'wp_should_concatenate_admin_scripts', $concatenate ); -} - /** * Prints prefetch links for the assets of the screen the user is most likely to open next. * * Runs wherever the next screen can be predicted with confidence, and prefetches only what that * screen is certain to need. Two cases qualify today: * - * - The login screen, which is followed by an admin screen. With concatenation disabled that - * screen downloads each core script and stylesheet separately, which is what makes an uncached - * admin load slower than a concatenated one. Requesting the ones that block its first paint - * while the login form is on screen puts them in the HTTP cache during the time the user spends - * typing credentials, so the redirect that follows finds them already there. + * - The login screen, which is followed by an admin screen. That screen downloads each core script + * and stylesheet separately, which is what makes an uncached admin load slow. Requesting the + * ones that block its first paint while the login form is on screen puts them in the HTTP cache + * during the time the user spends typing credentials, so the redirect that follows finds them + * already there. * - The Dashboard and the post list tables, from which the editor is the usual next stop. Only the * editor's stylesheets are prefetched, not its scripts: the scripts run to well over a megabyte * compressed, which is far too much to spend on a screen the user may never open, whereas the @@ -2559,42 +2348,25 @@ function wp_should_concatenate_admin_scripts(): bool { * page, such as the password reset form, since those mostly lead to the admin as well. Nothing is * printed at all when `redirect_to` points outside this site's admin. * - * Nothing is printed when the next screen will concatenate its assets, since `load-scripts.php` - * and `load-styles.php` already collapse these handles into a handful of requests. - * * @since 7.2.0 * * @see wp_preload_resources() - * @see wp_should_concatenate_admin_scripts() * - * @global bool $concatenate_scripts Whether scripts and styles are concatenated. - * @global WP_Screen|null $current_screen The current admin screen, if any. + * @global WP_Screen|null $current_screen The current admin screen, if any. */ function wp_prefetch_admin_assets(): void { - global $concatenate_scripts, $current_screen; + global $current_screen; /* * The context is told apart by the request rather than by the hook this runs on, so it works * from whichever hook it is added to. The 'login_init' action is fired by wp-login.php however - * it is reached, which is also how script_concat_settings() recognizes it. The is_login() - * function would not do: it compares the login URL with the script handling the request, and a - * plugin serving the login screen at a URL of its own runs wp-login.php from another script, - * such as index.php. + * it is reached. The is_login() function would not do: it compares the login URL with the + * script handling the request, and a plugin serving the login screen at a URL of its own runs + * wp-login.php from another script, such as index.php. */ $on_login = (bool) did_action( 'login_init' ); - if ( $on_login ) { - /* - * Deliberately not the $concatenate_scripts global: script_concat_settings() often runs on a - * login request before 'login_init' fires — anything registering a script on 'init' is enough - * to trigger it — and at that point it evaluates is_admin() as false and settles the global on - * false whatever the constant says. What matters here is what the admin screen this login - * leads to will do, which is what wp_should_concatenate_admin_scripts() predicts. - */ - if ( wp_should_concatenate_admin_scripts() ) { - return; - } - } else { + if ( ! $on_login ) { /* * From the Dashboard and the post list tables, the editor is the usual next stop. Anywhere * else in the admin there is no destination worth guessing at. @@ -2606,16 +2378,6 @@ function wp_prefetch_admin_assets(): void { if ( ! $current_screen instanceof WP_Screen || ! in_array( $current_screen->base, array( 'dashboard', 'edit' ), true ) ) { return; } - - /* - * On an admin screen the global has settled by the time its head is printed, and the editor - * will be served the same way. - */ - script_concat_settings(); - - if ( $concatenate_scripts ) { - return; - } } $script_roots = array(); diff --git a/tests/phpstan/base.neon b/tests/phpstan/base.neon index e8f588962288e..a34c86a352739 100644 --- a/tests/phpstan/base.neon +++ b/tests/phpstan/base.neon @@ -212,7 +212,6 @@ parameters: - ../../src/wp-admin/includes/ms.php excludePaths: analyseAndScan: - - ../../src/wp-admin/includes/noop.php # Locally installed npm dependencies, such as in bundled themes, which may include PHP files. - */node_modules/* # Composer dependencies of themes and plugins, which are not part of core. @@ -224,9 +223,6 @@ parameters: - ../../src/wp-includes/deprecated.php - ../../src/wp-includes/ms-deprecated.php - ../../src/wp-includes/pluggable-deprecated.php - # Script and style concatenation which rely on a get_file() function in noop.php. - - ../../src/wp-admin/load-scripts.php - - ../../src/wp-admin/load-styles.php # These files are autogenerated by tools/gutenberg/copy.js. - ../../src/wp-includes/blocks # Generated output from the Gutenberg plugin's wp-build templates. diff --git a/tests/phpstan/baselines/variable.undefined.neon b/tests/phpstan/baselines/variable.undefined.neon index fed1a151deb71..f55f384b8ae66 100644 --- a/tests/phpstan/baselines/variable.undefined.neon +++ b/tests/phpstan/baselines/variable.undefined.neon @@ -783,11 +783,6 @@ parameters: identifier: variable.undefined count: 3 path: ../../../src/wp-includes/ms-settings.php - - - message: '#^Variable \$wp_version might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../../src/wp-includes/script-loader.php - message: '#^Variable \$wp_template_path might not be defined\.$#' identifier: variable.undefined diff --git a/tests/phpunit/tests/dependencies.php b/tests/phpunit/tests/dependencies.php index a9a9efa2d5256..68fc32d83639c 100644 --- a/tests/phpunit/tests/dependencies.php +++ b/tests/phpunit/tests/dependencies.php @@ -176,9 +176,12 @@ public function data_provider_get_etag() { * * @ticket 58433 * @ticket 61485 + * @ticket 57548 * * @covers WP_Dependencies::get_etag * + * @expectedDeprecated WP_Dependencies::get_etag + * * @dataProvider data_provider_get_etag * * @param array $load List of scripts to load. @@ -210,9 +213,12 @@ public function test_get_etag_scripts( $load, $hash_source_string, $expected ) { * * @ticket 58433 * @ticket 61485 + * @ticket 57548 * * @covers WP_Dependencies::get_etag * + * @expectedDeprecated WP_Dependencies::get_etag + * * @dataProvider data_provider_get_etag * * @param array $load List of styles to load. diff --git a/tests/phpunit/tests/dependencies/scriptConcatSettings.php b/tests/phpunit/tests/dependencies/scriptConcatSettings.php index 01b2ade589e3c..7aabd87ffb864 100644 --- a/tests/phpunit/tests/dependencies/scriptConcatSettings.php +++ b/tests/phpunit/tests/dependencies/scriptConcatSettings.php @@ -55,10 +55,27 @@ public function tear_down(): void { parent::tear_down(); } + /** + * Tests that the `$concatenate_scripts` global defaults to false, even on an admin screen. + * + * @ticket 57548 + * + * @expectedDeprecated script_concat_settings + */ + public function test_concatenate_scripts_global_defaults_to_false(): void { + set_current_screen( 'dashboard' ); + + script_concat_settings(); + + $this->assertFalse( $GLOBALS['concatenate_scripts'] ); + } + /** * Tests that the compression globals default to false, as scripts and styles are not compressed from PHP. * * @ticket 63017 + * + * @expectedDeprecated script_concat_settings */ public function test_compression_globals_default_to_false(): void { // The result of the compression test, which used to turn the compression globals on. @@ -75,6 +92,8 @@ public function test_compression_globals_default_to_false(): void { * * @ticket 63017 * + * @expectedDeprecated script_concat_settings + * * @runInSeparateProcess * @preserveGlobalState disabled */ @@ -93,6 +112,8 @@ public function test_compression_constants_are_ignored(): void { * Tests that values a plugin has already set for the compression globals are kept. * * @ticket 63017 + * + * @expectedDeprecated script_concat_settings */ public function test_compression_globals_already_set_are_kept(): void { $GLOBALS['compress_scripts'] = true; diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php index d85e353380051..3d51613d846c9 100644 --- a/tests/phpunit/tests/dependencies/scripts.php +++ b/tests/phpunit/tests/dependencies/scripts.php @@ -25,20 +25,9 @@ */ class Tests_Dependencies_Scripts extends WP_UnitTestCase { - /** - * @var WP_Scripts - */ - protected $old_wp_scripts; + protected ?WP_Scripts $old_wp_scripts = null; - /** - * @var bool - */ - protected $old_concatenate_scripts; - - /** - * @var WP_Styles - */ - protected $old_wp_styles; + protected ?WP_Styles $old_wp_styles = null; protected $wp_scripts_print_translations_output; @@ -51,9 +40,10 @@ class Tests_Dependencies_Scripts extends WP_UnitTestCase { public function set_up() { parent::set_up(); - $this->old_wp_scripts = $GLOBALS['wp_scripts'] ?? null; - $this->old_wp_styles = $GLOBALS['wp_styles'] ?? null; - $this->old_concatenate_scripts = $GLOBALS['concatenate_scripts'] ?? null; + $old_wp_scripts = $GLOBALS['wp_scripts'] ?? null; + $old_wp_styles = $GLOBALS['wp_styles'] ?? null; + $this->old_wp_scripts = $old_wp_scripts instanceof WP_Scripts ? $old_wp_scripts : null; + $this->old_wp_styles = $old_wp_styles instanceof WP_Styles ? $old_wp_styles : null; remove_action( 'wp_default_scripts', 'wp_default_scripts' ); remove_action( 'wp_default_scripts', 'wp_default_packages' ); $GLOBALS['wp_scripts'] = new WP_Scripts(); @@ -61,22 +51,21 @@ public function set_up() { $GLOBALS['wp_styles'] = new WP_Styles(); $this->wp_scripts_print_translations_output = << -( function( domain, translations ) { - var localeData = translations.locale_data[ domain ] || translations.locale_data.messages; - localeData[""].domain = domain; - wp.i18n.setLocaleData( localeData, domain ); -} )( "__DOMAIN__", __JSON_TRANSLATIONS__ ); -//# sourceURL=__HANDLE__-js-translations - -JS; + + JS; $this->wp_scripts_print_translations_output .= "\n"; } public function tear_down() { - $GLOBALS['wp_scripts'] = $this->old_wp_scripts; - $GLOBALS['wp_styles'] = $this->old_wp_styles; - $GLOBALS['concatenate_scripts'] = $this->old_concatenate_scripts; + $GLOBALS['wp_scripts'] = $this->old_wp_scripts; + $GLOBALS['wp_styles'] = $this->old_wp_styles; add_action( 'wp_default_scripts', 'wp_default_scripts' ); parent::tear_down(); } @@ -422,10 +411,10 @@ public function test_blocking_dependent_with_delayed_dependency( $strategy ) { wp_enqueue_script( 'dependent-script-a3', '/dependent-script-a3.js', array( 'main-script-a3' ), null ); $output = get_echo( 'wp_print_scripts' ); $expected = << - + + -JS; + JS; $this->assertEqualHTML( $expected, $output, '', 'Blocking dependents must force delayed dependencies to become blocking.' ); } @@ -672,32 +661,25 @@ public function data_provider_to_test_various_strategy_dependency_chains() { } }, 'expected_markup' => << -scriptEventLog.push( "blocking-not-async-without-dependency: before inline" ) -//# sourceURL=blocking-not-async-without-dependency-js-before - - - - - - -HTML - , - /* - * Note: The above comma must be on its own line in PHP<7.3 and not after the `HTML` identifier - * terminating the heredoc. Otherwise, a syntax error is raised with the line number being wildly wrong: - * - * PHP Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) - */ + + + + + + + HTML, ), 'async-with-async-dependencies' => array( 'set_up' => function () { @@ -713,35 +695,34 @@ public function data_provider_to_test_various_strategy_dependency_chains() { } }, 'expected_markup' => << -scriptEventLog.push( "async-no-dependency: before inline" ) -//# sourceURL=async-no-dependency-js-before - - - - - - - - - -HTML - , + + + + + + + + + + HTML, ), 'async-with-blocking-dependency' => array( 'set_up' => function () { @@ -755,26 +736,25 @@ public function data_provider_to_test_various_strategy_dependency_chains() { } }, 'expected_markup' => << -scriptEventLog.push( "async-with-blocking-dependent: before inline" ) -//# sourceURL=async-with-blocking-dependent-js-before - - - - - - -HTML - , + + + + + + + HTML, ), 'defer-with-async-dependency' => array( 'set_up' => function () { @@ -788,26 +768,25 @@ public function data_provider_to_test_various_strategy_dependency_chains() { } }, 'expected_markup' => << -scriptEventLog.push( "async-with-defer-dependent: before inline" ) -//# sourceURL=async-with-defer-dependent-js-before - - - - - - -HTML - , + + + + + + + HTML, ), 'blocking-bundle-of-none-with-inline-scripts-and-defer-dependent' => array( 'set_up' => function () { @@ -824,25 +803,24 @@ public function data_provider_to_test_various_strategy_dependency_chains() { $this->add_test_inline_script( $handle2, 'after' ); }, 'expected_markup' => << -scriptEventLog.push( "blocking-bundle-of-none: before inline" ) -//# sourceURL=blocking-bundle-of-none-js-before - - - - - -HTML - , + + + + + + HTML, ), 'blocking-bundle-of-two-with-defer-dependent' => array( 'set_up' => function () { @@ -862,35 +840,34 @@ public function data_provider_to_test_various_strategy_dependency_chains() { } }, 'expected_markup' => << -scriptEventLog.push( "blocking-bundle-member-one: before inline" ) -//# sourceURL=blocking-bundle-member-one-js-before - - - - - - - - - -HTML - , + + + + + + + + + + HTML, ), 'defer-bundle-of-none-with-inline-scripts-and-defer-dependents' => array( 'set_up' => function () { @@ -909,25 +886,24 @@ public function data_provider_to_test_various_strategy_dependency_chains() { $this->add_test_inline_script( $handle2, 'after' ); }, 'expected_markup' => << -scriptEventLog.push( "defer-bundle-of-none: before inline" ) -//# sourceURL=defer-bundle-of-none-js-before - - - - - -HTML - , + + + + + + HTML, ), 'defer-dependent-with-blocking-and-defer-dependencies' => array( 'set_up' => function () { @@ -944,35 +920,34 @@ public function data_provider_to_test_various_strategy_dependency_chains() { } }, 'expected_markup' => << -scriptEventLog.push( "blocking-dependency-with-defer-following-dependency: before inline" ) -//# sourceURL=blocking-dependency-with-defer-following-dependency-js-before - - - - - - - - - -HTML - , + + + + + + + + + + HTML, ), 'defer-dependent-with-defer-and-blocking-dependencies' => array( 'set_up' => function () { @@ -989,35 +964,34 @@ public function data_provider_to_test_various_strategy_dependency_chains() { } }, 'expected_markup' => << -scriptEventLog.push( "defer-dependency-with-blocking-following-dependency: before inline" ) -//# sourceURL=defer-dependency-with-blocking-following-dependency-js-before - - - - - - - - - -HTML - , + + + + + + + + + + HTML, ), 'async-with-defer-dependency' => array( 'set_up' => function () { @@ -1031,26 +1005,25 @@ public function data_provider_to_test_various_strategy_dependency_chains() { } }, 'expected_markup' => << -scriptEventLog.push( "defer-with-async-dependent: before inline" ) -//# sourceURL=defer-with-async-dependent-js-before - - - - - - -HTML - , + + + + + + + HTML, ), 'defer-with-before-inline-script' => array( 'set_up' => function () { @@ -1060,13 +1033,12 @@ public function data_provider_to_test_various_strategy_dependency_chains() { $this->add_test_inline_script( $handle, 'before' ); }, 'expected_markup' => << -scriptEventLog.push( "defer-with-before-inline: before inline" ) -//# sourceURL=defer-with-before-inline-js-before - - -HTML - , + + + HTML, ), 'defer-with-after-inline-script' => array( 'set_up' => function () { @@ -1076,13 +1048,12 @@ public function data_provider_to_test_various_strategy_dependency_chains() { $this->add_test_inline_script( $handle, 'after' ); }, 'expected_markup' => << - -HTML - , + + + HTML, ), 'jquery-deferred' => array( 'set_up' => function () { @@ -1095,11 +1066,10 @@ public function data_provider_to_test_various_strategy_dependency_chains() { wp_enqueue_script( 'theme-functions', 'https://example.com/theme-functions.js', array( 'jquery' ), null, array( 'strategy' => 'defer' ) ); }, 'expected_markup' => << - - -HTML - , + + + + HTML, ), 'nested-aliases' => array( 'set_up' => function () { @@ -1120,20 +1090,19 @@ public function data_provider_to_test_various_strategy_dependency_chains() { $this->add_test_inline_script( 'defer-dependent-of-nested-aliases', 'after' ); }, 'expected_markup' => << - - - - - -HTML - , + + + + + + + HTML, ), 'async-alias-members-with-defer-dependency' => array( @@ -1149,11 +1118,10 @@ public function data_provider_to_test_various_strategy_dependency_chains() { $this->enqueue_test_script( 'defer-dependent-of-async-aliases', 'defer', array( $alias_handle ) ); }, 'expected_markup' => << - - -HTML - , + + + + HTML, ), ); } @@ -1735,16 +1703,16 @@ public function test_fetchpriority_bumping_a_to_z() { $actual = get_echo( 'wp_print_scripts' ); $expected = <<<'HTML' - - - - - - - - - -HTML; + + + + + + + + + + HTML; $this->assertEqualHTML( $expected, $actual, '', "Snapshot:\n$actual" ); } @@ -2162,115 +2130,6 @@ public function test_script_strategy_doing_it_wrong_via_enqueue() { ); } - /** - * Tests that scripts registered with a deferred strategy are not included in the script concat loading query. - * - * @ticket 12009 - * - * @covers WP_Scripts::do_item - * @covers ::wp_enqueue_script - * @covers ::wp_register_script - * - * @global WP_Scripts $wp_scripts - * @global bool $concatenate_scripts - * @global string $wp_version - */ - public function test_concatenate_with_defer_strategy() { - global $wp_scripts, $concatenate_scripts, $wp_version; - - $concatenate_scripts = true; - - $wp_scripts->do_concat = true; - $wp_scripts->default_dirs = array( $this->default_scripts_dir ); - - wp_register_script( 'one-concat-dep', $this->default_scripts_dir . 'script.js' ); - wp_register_script( 'two-concat-dep', $this->default_scripts_dir . 'script.js' ); - wp_register_script( 'three-concat-dep', $this->default_scripts_dir . 'script.js' ); - wp_enqueue_script( 'main-defer-script', '/main-script.js', array( 'one-concat-dep', 'two-concat-dep', 'three-concat-dep' ), null, array( 'strategy' => 'defer' ) ); - - wp_print_scripts(); - $print_scripts = get_echo( '_print_scripts' ); - - $expected = "\n"; - $expected .= "\n"; - - $this->assertEqualHTML( $expected, $print_scripts, '', 'Scripts are being incorrectly concatenated when a main script is registered with a "defer" loading strategy. Deferred scripts should not be part of the script concat loading query.' ); - } - - /** - * Test script concatenation with `async` main script. - * - * @ticket 12009 - * - * @covers WP_Scripts::do_item - * @covers ::wp_enqueue_script - * @covers ::wp_register_script - * - * @global WP_Scripts $wp_scripts - * @global bool $concatenate_scripts - * @global string $wp_version - */ - public function test_concatenate_with_async_strategy() { - global $wp_scripts, $concatenate_scripts, $wp_version; - - $concatenate_scripts = true; - - $wp_scripts->do_concat = true; - $wp_scripts->default_dirs = array( $this->default_scripts_dir ); - - wp_enqueue_script( 'one-concat-dep-1', $this->default_scripts_dir . 'script.js' ); - wp_enqueue_script( 'two-concat-dep-1', $this->default_scripts_dir . 'script.js' ); - wp_enqueue_script( 'three-concat-dep-1', $this->default_scripts_dir . 'script.js' ); - wp_enqueue_script( 'main-async-script-1', '/main-script.js', array(), null, array( 'strategy' => 'async' ) ); - - wp_print_scripts(); - $print_scripts = get_echo( '_print_scripts' ); - - $expected = "\n"; - $expected .= "\n"; - - $this->assertEqualHTML( $expected, $print_scripts, '', 'Scripts are being incorrectly concatenated when a main script is registered with an "async" loading strategy. Async scripts should not be part of the script concat loading query.' ); - } - - /** - * Tests that script concatenation remains correct when a main script is registered as deferred after other blocking - * scripts are registered. - * - * @ticket 12009 - * - * @covers WP_Scripts::do_item - * @covers ::wp_enqueue_script - * @covers ::wp_register_script - * - * @global WP_Scripts $wp_scripts - * @global bool $concatenate_scripts - * @global string $wp_version - */ - public function test_concatenate_with_blocking_script_before_and_after_script_with_defer_strategy() { - global $wp_scripts, $concatenate_scripts, $wp_version; - - $concatenate_scripts = true; - - $wp_scripts->do_concat = true; - $wp_scripts->default_dirs = array( $this->default_scripts_dir ); - - wp_enqueue_script( 'one-concat-dep-2', $this->default_scripts_dir . 'script.js' ); - wp_enqueue_script( 'two-concat-dep-2', $this->default_scripts_dir . 'script.js' ); - wp_enqueue_script( 'three-concat-dep-2', $this->default_scripts_dir . 'script.js' ); - wp_enqueue_script( 'deferred-script-2', '/main-script.js', array(), null, array( 'strategy' => 'defer' ) ); - wp_enqueue_script( 'four-concat-dep-2', $this->default_scripts_dir . 'script.js' ); - wp_enqueue_script( 'five-concat-dep-2', $this->default_scripts_dir . 'script.js' ); - wp_enqueue_script( 'six-concat-dep-2', $this->default_scripts_dir . 'script.js' ); - - wp_print_scripts(); - $print_scripts = get_echo( '_print_scripts' ); - - $expected = "\n"; - $expected .= "\n"; - - $this->assertEqualHTML( $expected, $print_scripts, '', 'Scripts are being incorrectly concatenated when a main script is registered as deferred after other blocking scripts are registered. Deferred scripts should not be part of the script concat loader query string. ' ); - } - /** * Test the different protocol references in wp_enqueue_script * @@ -2317,27 +2176,104 @@ public function test_protocols() { } /** - * Test script concatenation. + * Tests that the deprecated `do_concat` property no longer holds back the markup of scripts. + * + * @ticket 57548 + * + * @covers WP_Scripts::do_item * * @global WP_Scripts $wp_scripts - * @global string $wp_version + * @global string $wp_version */ - public function test_script_concatenation() { + public function test_do_concat_is_ignored(): void { global $wp_scripts, $wp_version; - $wp_scripts->do_concat = true; - $wp_scripts->default_dirs = array( $this->default_scripts_dir ); + // The deprecated property is set as plugins may still do, to verify that it no longer has any effect. + $wp_scripts->do_concat = true; - wp_enqueue_script( 'one', $this->default_scripts_dir . 'script.js' ); - wp_enqueue_script( 'two', $this->default_scripts_dir . 'script.js' ); - wp_enqueue_script( 'three', $this->default_scripts_dir . 'script.js' ); + // A plain blocking script comes first, since anything with inline scripts stopped concatenation. + wp_enqueue_script( 'zero', '/wp-includes/js/zero.js' ); + wp_enqueue_script( 'one', '/wp-includes/js/one.js' ); + wp_localize_script( 'one', 'one', array( 'key' => 'val' ) ); + wp_add_inline_script( 'one', 'console.log("before one");', 'before' ); + wp_register_script( 'alias', false, array( 'one' ) ); + wp_add_inline_script( 'alias', 'console.log("after alias");' ); + wp_enqueue_script( 'two', '/plugins/two.js', array( 'alias' ), null, array( 'strategy' => 'defer' ) ); - wp_print_scripts(); - $print_scripts = get_echo( '_print_scripts' ); + $expected = << + + + + + - $expected = "\n"; + HTML; - $this->assertEqualHTML( $expected, $print_scripts ); + $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ), '', 'Expected each script to be printed right away.' ); + $this->assertSame( '', $wp_scripts->print_html, 'Expected nothing to be held in print_html.' ); + } + + /** + * Tests that WP_Scripts::in_default_dir() is deprecated but still works. + * + * @ticket 57548 + * + * @covers WP_Scripts::in_default_dir + * + * @expectedDeprecated WP_Scripts::in_default_dir + */ + public function test_in_default_dir_is_deprecated(): void { + $wp_scripts = wp_scripts(); + $wp_scripts->default_dirs = array( '/wp-includes/js/' ); + + $this->assertTrue( $wp_scripts->in_default_dir( '/wp-includes/js/file' ) ); + } + + /** + * Tests that extra data which is not a string is not printed. + * + * @ticket 57548 + * + * @covers WP_Scripts::print_extra_script + */ + public function test_print_extra_script_skips_non_string_data(): void { + wp_register_script( 'test-example', '/example.js', array(), null ); + wp_script_add_data( 'test-example', 'data', array( 'foo' => 'bar' ) ); + + $this->assertNull( wp_scripts()->print_extra_script( 'test-example', false ), 'Expected no extra script to be returned.' ); + $this->assertEqualHTML( "\n", get_echo( 'wp_print_scripts', array( 'test-example' ) ), '', 'Expected only the script tag to be printed.' ); + } + + /** + * Tests that the deprecated filters for printing scripts no longer keep them from being printed. + * + * @ticket 57548 + * + * @covers ::print_head_scripts + * @covers ::print_footer_scripts + * + * @expectedDeprecated print_head_scripts + * @expectedDeprecated print_footer_scripts + */ + public function test_print_scripts_filters_are_deprecated(): void { + add_filter( 'print_head_scripts', '__return_false' ); + add_filter( 'print_footer_scripts', '__return_false' ); + + wp_enqueue_script( 'head', '/head.js', array(), null ); + wp_enqueue_script( 'footer', '/footer.js', array(), null, array( 'in_footer' => true ) ); + + $this->assertEqualHTML( "\n", get_echo( 'print_head_scripts' ), '', 'Expected the head scripts to be printed.' ); + $this->assertEqualHTML( "\n", get_echo( 'print_footer_scripts' ), '', 'Expected the footer scripts to be printed.' ); } /** @@ -2586,12 +2522,12 @@ public function test_wp_add_inline_script_before() { wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ); $expected = << -console.log("before"); -//# sourceURL=test-example-js-before - + -HTML; + HTML; $expected .= "\n"; $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); @@ -2606,12 +2542,12 @@ public function test_wp_add_inline_script_after() { $expected = "\n"; $expected .= << -console.log("after"); -//# sourceURL=test-example-js-after - + -HTML; + HTML; $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); } @@ -2706,328 +2642,6 @@ public function test_wp_add_inline_script_localized_data_is_added_first() { $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); } - /** - * @ticket 14853 - */ - public function test_wp_add_inline_script_before_with_concat() { - global $wp_scripts, $wp_version; - - $wp_scripts->do_concat = true; - $wp_scripts->default_dirs = array( $this->default_scripts_dir ); - - wp_enqueue_script( 'one', $this->default_scripts_dir . 'one.js' ); - wp_enqueue_script( 'two', $this->default_scripts_dir . 'two.js' ); - wp_enqueue_script( 'three', $this->default_scripts_dir . 'three.js' ); - - wp_add_inline_script( 'one', 'console.log("before one");', 'before' ); - wp_add_inline_script( 'two', 'console.log("before two");', 'before' ); - - $expected = "\n"; - $expected .= "\n"; - $expected .= "\n"; - $expected .= "\n"; - $expected .= "\n"; - - $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); - } - - /** - * @ticket 14853 - */ - public function test_wp_add_inline_script_before_with_concat2() { - global $wp_scripts, $wp_version; - - $wp_scripts->do_concat = true; - $wp_scripts->default_dirs = array( $this->default_scripts_dir ); - - wp_enqueue_script( 'one', $this->default_scripts_dir . 'one.js' ); - wp_enqueue_script( 'two', $this->default_scripts_dir . 'two.js' ); - wp_enqueue_script( 'three', $this->default_scripts_dir . 'three.js' ); - - wp_add_inline_script( 'one', 'console.log("before one");', 'before' ); - - $expected = "\n"; - $expected .= "\n"; - $expected .= "\n"; - $expected .= "\n"; - - $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); - } - - /** - * @ticket 14853 - * - * @global WP_Scripts $wp_scripts - * @global string $wp_version - */ - public function test_wp_add_inline_script_after_with_concat() { - global $wp_scripts, $wp_version; - - $wp_scripts->do_concat = true; - $wp_scripts->default_dirs = array( $this->default_scripts_dir ); - - wp_enqueue_script( 'one', $this->default_scripts_dir . 'one.js' ); - wp_enqueue_script( 'two', $this->default_scripts_dir . 'two.js' ); - wp_enqueue_script( 'three', $this->default_scripts_dir . 'three.js' ); - wp_enqueue_script( 'four', $this->default_scripts_dir . 'four.js' ); - - wp_add_inline_script( 'two', 'console.log("after two");' ); - wp_add_inline_script( 'three', 'console.log("after three");' ); - - $expected = "\n"; - $expected .= "\n"; - $expected .= "\n"; - $expected .= "\n"; - $expected .= "\n"; - $expected .= "\n"; - - $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); - } - - /** - * @expectedDeprecated WP_Dependencies::add_data() - * - * @ticket 14853 - * @ticket 63821 - */ - public function test_wp_add_inline_script_after_and_before_with_concat_and_conditional() { - global $wp_scripts; - - $wp_scripts->do_concat = true; - $wp_scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); // Default dirs as in wp-includes/script-loader.php. - - // Conditional scripts should not output. - $expected_localized = ''; - $expected = ''; - - wp_enqueue_script( 'test-example', 'example.com', array(), null ); - wp_localize_script( 'test-example', 'testExample', array( 'foo' => 'bar' ) ); - wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ); - wp_add_inline_script( 'test-example', 'console.log("after");' ); - wp_script_add_data( 'test-example', 'conditional', 'gte IE 9' ); - - $this->assertSame( $expected_localized, get_echo( 'wp_print_scripts' ) ); - $this->assertEqualHTML( $expected, $wp_scripts->print_html ); - $this->assertTrue( $wp_scripts->do_concat ); - } - - /** - * @ticket 36392 - * - * @global WP_Scripts $wp_scripts - * @global string $wp_version - */ - public function test_wp_add_inline_script_after_with_concat_and_core_dependency() { - global $wp_scripts, $wp_version; - - wp_default_scripts( $wp_scripts ); - - $wp_scripts->base_url = ''; - $wp_scripts->do_concat = true; - - $expected = "\n"; - $expected .= "\n"; - $expected .= "\n"; - - wp_enqueue_script( 'test-example', 'http://example.com', array( 'jquery' ), null ); - wp_add_inline_script( 'test-example', 'console.log("after");' ); - - wp_print_scripts(); - $print_scripts = get_echo( '_print_scripts' ); - - $this->assertEqualHTML( $expected, $print_scripts ); - } - - /** - * @expectedDeprecated WP_Dependencies::add_data() - * - * @ticket 36392 - * @ticket 63821 - */ - public function test_wp_add_inline_script_after_with_concat_and_conditional_and_core_dependency() { - global $wp_scripts; - wp_default_scripts( $wp_scripts ); - - $wp_scripts->base_url = ''; - $wp_scripts->do_concat = true; - $expected = ''; - - wp_enqueue_script( 'test-example', 'http://example.com', array( 'jquery' ), null ); - wp_add_inline_script( 'test-example', 'console.log("after");' ); - wp_script_add_data( 'test-example', 'conditional', 'gte IE 9' ); - - wp_print_scripts(); - $print_scripts = get_echo( '_print_scripts' ); - - $this->assertEqualHTML( $expected, $print_scripts ); - } - - /** - * @ticket 36392 - * - * @global WP_Scripts $wp_scripts - * @global string $wp_version - */ - public function test_wp_add_inline_script_before_with_concat_and_core_dependency() { - global $wp_scripts, $wp_version; - - wp_default_scripts( $wp_scripts ); - wp_default_packages( $wp_scripts ); - - $wp_scripts->base_url = ''; - $wp_scripts->do_concat = true; - - $expected = "\n"; - $expected .= "\n"; - $expected .= "\n"; - - wp_enqueue_script( 'test-example', 'http://example.com', array( 'jquery' ), null ); - wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ); - - wp_print_scripts(); - $print_scripts = get_echo( '_print_scripts' ); - - $this->assertEqualHTML( $expected, $print_scripts ); - } - - /** - * @ticket 36392 - * - * @global WP_Scripts $wp_scripts - * @global string $wp_version - */ - public function test_wp_add_inline_script_before_after_concat_with_core_dependency() { - global $wp_scripts, $wp_version; - - wp_default_scripts( $wp_scripts ); - wp_default_packages( $wp_scripts ); - - $wp_scripts->base_url = ''; - $wp_scripts->do_concat = true; - - $expected = "\n"; - $expected .= "\n"; - $expected .= "\n"; - $expected .= "\n"; - $expected .= "\n"; - $expected .= "\n"; - $expected .= "\n"; - $expected .= "\n"; - wp_enqueue_script( 'test-example', 'http://example.com', array( 'jquery' ), null ); - wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ); - wp_enqueue_script( 'test-example2', 'http://example2.com', array( 'wp-a11y' ), null ); - wp_add_inline_script( 'test-example2', 'console.log("after");', 'after' ); - - // Effectively ignore the output until retrieving it later via `getActualOutput()`. - $this->expectOutputRegex( '`.`' ); - - wp_print_scripts(); - _print_scripts(); - $print_scripts = $this->getActualOutput(); - - /* - * We've replaced wp-a11y.js with @wordpress/a11y package (see #45066), - * and `wp-polyfill` is now a dependency of the packaged wp-a11y. - * The packaged scripts contain various version numbers, which are not exposed, - * so we will remove all version args from the output. - */ - $print_scripts = preg_replace( - '~js\?ver=([^"\']*)~', // Matches `js?ver=X.X.X` and everything to single or double quote. - 'js', // The replacement, `js` without the version arg. - $print_scripts // Printed scripts. - ); - - $this->assertEqualHTML( $expected, $print_scripts ); - } - - /** - * @ticket 36392 - */ - public function test_wp_add_inline_script_customize_dependency() { - global $wp_scripts; - - wp_default_scripts( $wp_scripts ); - wp_default_packages( $wp_scripts ); - - $wp_scripts->base_url = ''; - $wp_scripts->do_concat = true; - - $handle = 'customize-dependency'; - wp_enqueue_script( $handle, '/customize-dependency.js', array( 'customize-controls' ), null ); - wp_add_inline_script( $handle, 'tryCustomizeDependency()' ); - - // Effectively ignore the output until retrieving it later via `getActualOutput()`. - $this->expectOutputRegex( '`.`' ); - - wp_print_scripts(); - _print_scripts(); - $print_scripts = $this->getActualOutput(); - - $expected = ""; - $this->assertEqualHTMLScriptTagById( $expected, $print_scripts ); - - $expected = "'; - $this->assertEqualHTMLScriptTagById( $expected, $print_scripts ); - } - - /** - * @ticket 36392 - */ - public function test_wp_add_inline_script_after_for_core_scripts_with_concat_is_limited_and_falls_back_to_no_concat() { - global $wp_scripts, $wp_version; - - $wp_scripts->do_concat = true; - $wp_scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); // Default dirs as in wp-includes/script-loader.php. - - wp_enqueue_script( 'one', '/wp-includes/js/script.js' ); - wp_enqueue_script( 'two', '/wp-includes/js/script2.js', array( 'one' ) ); - wp_add_inline_script( 'one', 'console.log("after one");', 'after' ); - wp_enqueue_script( 'three', '/wp-includes/js/script3.js' ); - wp_enqueue_script( 'four', '/wp-includes/js/script4.js' ); - - $expected = "\n"; - $expected .= "\n"; - $expected .= "\n"; - $expected .= "\n"; - $expected .= "\n"; - - $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); - } - - /** - * @ticket 36392 - * - * @global WP_Scripts $wp_scripts - * @global string $wp_version - */ - public function test_wp_add_inline_script_before_third_core_script_prints_two_concat_scripts() { - global $wp_scripts, $wp_version; - - $wp_scripts->do_concat = true; - $wp_scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); // Default dirs as in wp-includes/script-loader.php. - - wp_enqueue_script( 'one', '/wp-includes/js/script.js' ); - wp_enqueue_script( 'two', '/wp-includes/js/script2.js', array( 'one' ) ); - wp_enqueue_script( 'three', '/wp-includes/js/script3.js' ); - wp_add_inline_script( 'three', 'console.log("before three");', 'before' ); - wp_enqueue_script( 'four', '/wp-includes/js/script4.js' ); - - $expected = "\n"; - $expected .= "\n"; - $expected .= "\n"; - $expected .= "\n"; - - $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); - } - /** * Data provider to test get_inline_script_data and get_inline_script_tag. * @@ -3817,43 +3431,6 @@ public function data_wp_localize_script_data_formats() { ); } - /** - * @ticket 55628 - * - * @covers ::wp_set_script_translations - * - * @global WP_Scripts $wp_scripts - * @global string $wp_version - */ - public function test_wp_external_wp_i18n_print_order() { - global $wp_scripts, $wp_version; - - $wp_scripts->do_concat = true; - $wp_scripts->default_dirs = array( '/default/' ); - - // wp-i18n script in a non-default directory. - wp_register_script( 'wp-i18n', '/plugins/wp-i18n.js', array(), null ); - // Script in default dir that's going to be concatenated. - wp_enqueue_script( 'jquery-core', '/default/jquery-core.js', array(), null ); - // Script in default dir that depends on wp-i18n. - wp_enqueue_script( 'common', '/default/common.js', array(), null ); - wp_set_script_translations( 'common' ); - - $print_scripts = get_echo( - static function () { - wp_print_scripts(); - _print_scripts(); - } - ); - - // The non-default script should end concatenation and maintain order. - $expected = "\n"; - $expected .= "\n"; - $expected .= "\n"; - - $this->assertEqualHTML( $expected, $print_scripts ); - } - /** * Ensure tinymce scripts aren't loading async. * @@ -3874,16 +3451,8 @@ public function test_printing_tinymce_scripts() { * @ticket 57548 * * @covers ::wp_register_tinymce_scripts - * - * @dataProvider data_register_tinymce_scripts_unbundled - * - * @param bool $concatenate Value of the `$concatenate_scripts` global. */ - public function test_register_tinymce_scripts_unbundled( bool $concatenate ): void { - global $concatenate_scripts; - - $concatenate_scripts = $concatenate; - + public function test_register_tinymce_scripts_unbundled(): void { $wp_scripts = wp_scripts(); wp_register_tinymce_scripts( $wp_scripts ); @@ -3899,22 +3468,6 @@ public function test_register_tinymce_scripts_unbundled( bool $concatenate ): vo $this->assertSame( array( 'wp-tinymce-root' ), $tinymce->deps ); } - /** - * Data provider for test_register_tinymce_scripts_unbundled(). - * - * @return array - */ - public function data_register_tinymce_scripts_unbundled(): array { - return array( - 'concatenated' => array( - 'concatenate' => true, - ), - 'not concatenated' => array( - 'concatenate' => false, - ), - ); - } - /** * Make sure scripts with a loading strategy that are printed * without being enqueued are handled properly. @@ -4400,58 +3953,23 @@ public function test_source_url_encoding() { wp_localize_script( $handle, 'test', array() ); $expected = << -var test = []; -//# sourceURL=%23%20test%2F%3C%2Fscript%3E%20%23-js-extra - - - - - -HTML; - - $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); - } - - /** - * @ticket 63887 - * - * @global WP_Scripts $wp_scripts - * @global bool $concatenate_scripts - * @global string $wp_version - */ - public function test_source_url_with_concat() { - global $wp_scripts, $concatenate_scripts, $wp_version; - - $concatenate_scripts = true; - - $wp_scripts->do_concat = true; - $wp_scripts->default_dirs = array( $this->default_scripts_dir ); - - wp_enqueue_script( 'one', $this->default_scripts_dir . '1.js' ); - wp_enqueue_script( 'two', $this->default_scripts_dir . '2.js' ); - wp_localize_script( 'one', 'one', array( 'key' => 'val' ) ); - wp_localize_script( 'two', 'two', array( 'key' => 'val' ) ); - - wp_print_scripts(); - $print_scripts = get_echo( '_print_scripts' ); - - $expected = << - var one = {"key":"val"};var two = {"key":"val"}; - //# sourceURL=js-inline-concat-one%2Ctwo + + + + - HTML; - $this->assertEqualHTML( $expected, $print_scripts ); + $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); } /** diff --git a/tests/phpunit/tests/dependencies/styles.php b/tests/phpunit/tests/dependencies/styles.php index cd0768ecc5a54..f7f66978d2775 100644 --- a/tests/phpunit/tests/dependencies/styles.php +++ b/tests/phpunit/tests/dependencies/styles.php @@ -9,23 +9,17 @@ * @covers ::wp_add_inline_style */ class Tests_Dependencies_Styles extends WP_UnitTestCase { - private $old_wp_styles; - private $old_wp_scripts; + private ?WP_Styles $old_wp_styles = null; + + private ?WP_Scripts $old_wp_scripts = null; public function set_up() { parent::set_up(); - if ( empty( $GLOBALS['wp_styles'] ) ) { - $GLOBALS['wp_styles'] = null; - } - - $this->old_wp_styles = $GLOBALS['wp_styles']; - - if ( empty( $GLOBALS['wp_scripts'] ) ) { - $GLOBALS['wp_scripts'] = null; - } - - $this->old_wp_styles = $GLOBALS['wp_scripts']; + $old_wp_styles = $GLOBALS['wp_styles'] ?? null; + $old_wp_scripts = $GLOBALS['wp_scripts'] ?? null; + $this->old_wp_styles = $old_wp_styles instanceof WP_Styles ? $old_wp_styles : null; + $this->old_wp_scripts = $old_wp_scripts instanceof WP_Scripts ? $old_wp_scripts : null; remove_action( 'wp_default_styles', 'wp_default_styles' ); remove_action( 'wp_print_styles', 'print_emoji_styles' ); @@ -198,16 +192,17 @@ public function test_inline_styles() { } /** - * Test if inline styles work with concatenation + * Tests that inline styles are printed right away when the deprecated `do_concat` property is set. * * @global WP_Styles $wp_styles * @ticket 24813 + * @ticket 57548 */ public function test_inline_styles_concat() { global $wp_styles; - $wp_styles->do_concat = true; - $wp_styles->default_dirs = array( '/wp-admin/', '/wp-includes/css/' ); // Default dirs as in wp-includes/script-loader.php. + // The deprecated property is set as plugins may still do, to verify that it no longer has any effect. + $wp_styles->do_concat = true; $style = ".thing {\n"; $style .= "\tbackground: red;\n"; @@ -216,13 +211,54 @@ public function test_inline_styles_concat() { $expected = "\n"; $expected .= "\n"; wp_enqueue_style( 'handle', 'http://example.com', array(), 1 ); wp_add_inline_style( 'handle', $style ); - wp_print_styles(); - $this->assertEqualHTML( $expected, $wp_styles->print_html ); + $this->assertEqualHTML( $expected, get_echo( 'wp_print_styles' ) ); + $this->assertSame( '', $wp_styles->print_html ); + } + + /** + * Tests that the deprecated filters for printing styles no longer keep them from being printed. + * + * @ticket 57548 + * + * @covers ::print_admin_styles + * @covers ::print_late_styles + * + * @expectedDeprecated print_admin_styles + * @expectedDeprecated print_late_styles + */ + public function test_print_styles_filters_are_deprecated(): void { + add_filter( 'print_admin_styles', '__return_false' ); + add_filter( 'print_late_styles', '__return_false' ); + + wp_enqueue_style( 'admin', '/admin.css', array(), null ); + + $this->assertEqualHTML( "\n", get_echo( 'print_admin_styles' ), '', 'Expected the admin styles to be printed.' ); + + wp_enqueue_style( 'late', '/late.css', array(), null ); + + $this->assertEqualHTML( "\n", get_echo( 'print_late_styles' ), '', 'Expected the late styles to be printed.' ); + } + + /** + * Tests that WP_Styles::in_default_dir() is deprecated but still works. + * + * @ticket 57548 + * + * @covers WP_Styles::in_default_dir + * + * @expectedDeprecated WP_Styles::in_default_dir + */ + public function test_in_default_dir_is_deprecated(): void { + $wp_styles = wp_styles(); + $wp_styles->default_dirs = array( '/wp-includes/css/' ); + + $this->assertTrue( $wp_styles->in_default_dir( '/wp-includes/css/file' ) ); } /** @@ -898,54 +934,17 @@ public function test_source_url_encoding() { wp_add_inline_style( $handle, 'custom-el { content: "ok"; }' ); $expected = << - + + -HTML; + HTML; $this->assertEqualHTML( $expected, get_echo( 'wp_print_styles' ) ); } - /** - * @ticket 63887 - * - * @global WP_Styles $wp_styles - * @global string $wp_version - */ - public function test_source_url_with_concat() { - global $wp_styles, $wp_version; - add_theme_support( 'html5', array( 'style' ) ); - - $wp_styles->do_concat = true; - $wp_styles->default_dirs = array( '/wp-admin/' ); - - wp_enqueue_style( 'one', '/wp-admin/1.css' ); - wp_enqueue_style( 'two', '/wp-admin/2.css' ); - wp_add_inline_style( 'one', 'h1 { background: blue; }' ); - wp_add_inline_style( 'two', 'h2 { color: green; }' ); - - wp_print_styles(); - $printed = get_echo( '_print_styles' ); - - $expected = << - - -HTML; - - $this->assertEqualHTML( $expected, $printed ); - } - /** * Tests that WP_Styles emits a _doing_it_wrong() notice for missing dependencies. * diff --git a/tests/phpunit/tests/dependencies/wpPrefetchAdminAssets.php b/tests/phpunit/tests/dependencies/wpPrefetchAdminAssets.php index 04acdf3b85a0e..f8927c8d3aa88 100644 --- a/tests/phpunit/tests/dependencies/wpPrefetchAdminAssets.php +++ b/tests/phpunit/tests/dependencies/wpPrefetchAdminAssets.php @@ -2,10 +2,6 @@ /** * Tests for {@see wp_prefetch_admin_assets()}. * - * Prefetching only happens when concatenation is off. Each test turns it off with the - * {@see 'wp_should_concatenate_admin_scripts'} filter, so that it does not depend on the - * `CONCATENATE_SCRIPTS` and `SCRIPT_DEBUG` constants, which cannot be changed once defined. - * * @package WordPress * @subpackage Script Loader * @@ -31,8 +27,7 @@ class Tests_Dependencies_WpPrefetchAdminAssets extends WP_UnitTestCase { private $original_script_name; /** - * Gives each test fresh script and style registries, since several tests modify them, and turns - * concatenation off. + * Gives each test fresh script and style registries, since several tests modify them. */ public function set_up(): void { parent::set_up(); @@ -43,8 +38,6 @@ public function set_up(): void { } $this->original_script_name = $_SERVER['SCRIPT_NAME'] ?? null; - - add_filter( 'wp_should_concatenate_admin_scripts', '__return_false' ); } /** @@ -69,65 +62,30 @@ public function tear_down(): void { } /** - * Tests that nothing is prefetched from the login screen when the admin concatenates its assets. - * - * @ticket 57548 - */ - public function test_login_prints_nothing_when_admin_concatenates(): void { - add_filter( 'wp_should_concatenate_admin_scripts', '__return_true' ); - - $this->assertSame( array(), $this->get_prefetched_on_login() ); - } - - /** - * Tests that the login screen predicts what the admin will do rather than reading the - * `$concatenate_scripts` global, which script_concat_settings() may have settled on false before - * 'login_init' fired. + * Tests that the `$concatenate_scripts` global no longer stops prefetching from the login screen, + * as nothing is concatenated. * * @ticket 57548 */ public function test_login_ignores_concatenate_scripts_global(): void { $GLOBALS['concatenate_scripts'] = true; - $this->assertNotSame( array(), $this->get_prefetched_on_login(), 'Expected prefetching when the admin will not concatenate.' ); - - $GLOBALS['concatenate_scripts'] = false; - add_filter( 'wp_should_concatenate_admin_scripts', '__return_true' ); - - $this->assertSame( array(), $this->get_prefetched_on_login(), 'Expected no prefetching when the admin will concatenate.' ); + $this->assertNotSame( array(), $this->get_prefetched_on_login() ); } /** - * Tests that an admin screen goes by the `$concatenate_scripts` global, which has settled by the - * time its head is printed, so a plugin setting the global is respected. + * Tests that the `$concatenate_scripts` global no longer stops prefetching from an admin screen, + * as nothing is concatenated. * * @ticket 57548 */ - public function test_admin_screen_uses_concatenate_scripts_global(): void { + public function test_admin_screen_ignores_concatenate_scripts_global(): void { wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); $GLOBALS['concatenate_scripts'] = true; - $this->assertSame( array(), $this->get_prefetched_on_admin_screen( 'dashboard' ), 'Expected no prefetching when the global says to concatenate.' ); - - $GLOBALS['concatenate_scripts'] = false; - add_filter( 'wp_should_concatenate_admin_scripts', '__return_true' ); - - $this->assertNotSame( array(), $this->get_prefetched_on_admin_screen( 'dashboard' ), 'Expected prefetching when the global says not to concatenate.' ); - } - - /** - * Tests that an admin screen settles the `$concatenate_scripts` global with script_concat_settings() - * when nothing has done so yet. - * - * @ticket 57548 - */ - public function test_admin_screen_settles_concatenate_scripts_global(): void { - wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); - add_filter( 'wp_should_concatenate_admin_scripts', '__return_true' ); - - $this->assertSame( array(), $this->get_prefetched_on_admin_screen( 'dashboard' ) ); - $this->assertTrue( $GLOBALS['concatenate_scripts'] ); + $this->assertSame( 0, did_action( 'login_init' ), 'Expected the request not to be one for the login screen.' ); + $this->assertNotSame( array(), $this->get_prefetched_on_admin_screen( 'dashboard' ) ); } /** diff --git a/tests/phpunit/tests/dependencies/wpShouldConcatenateAdminScripts.php b/tests/phpunit/tests/dependencies/wpShouldConcatenateAdminScripts.php deleted file mode 100644 index 8a577edf3228b..0000000000000 --- a/tests/phpunit/tests/dependencies/wpShouldConcatenateAdminScripts.php +++ /dev/null @@ -1,133 +0,0 @@ -original_concatenate_scripts = $GLOBALS['concatenate_scripts'] ?? null; - } - - /** - * Restores the `$concatenate_scripts` global. - */ - public function tear_down(): void { - if ( null === $this->original_concatenate_scripts ) { - unset( $GLOBALS['concatenate_scripts'] ); - } else { - $GLOBALS['concatenate_scripts'] = $this->original_concatenate_scripts; - } - - parent::tear_down(); - } - - /** - * Tests that `CONCATENATE_SCRIPTS` turns concatenation on, unless `SCRIPT_DEBUG` is on. - * - * @ticket 57548 - * - * @runInSeparateProcess - * @preserveGlobalState disabled - */ - public function test_constant_on(): void { - define( 'CONCATENATE_SCRIPTS', true ); - - $this->assertSame( ! SCRIPT_DEBUG, wp_should_concatenate_admin_scripts() ); - } - - /** - * Tests that `CONCATENATE_SCRIPTS` turns concatenation off. - * - * @ticket 57548 - * - * @runInSeparateProcess - * @preserveGlobalState disabled - */ - public function test_constant_off(): void { - define( 'CONCATENATE_SCRIPTS', false ); - - $this->assertFalse( wp_should_concatenate_admin_scripts() ); - } - - /** - * Tests the default when `CONCATENATE_SCRIPTS` is not defined, which is not to concatenate. - * - * @ticket 57548 - */ - public function test_default(): void { - if ( defined( 'CONCATENATE_SCRIPTS' ) ) { - $this->markTestSkipped( 'CONCATENATE_SCRIPTS is defined.' ); - } - - $this->assertFalse( wp_should_concatenate_admin_scripts() ); - } - - /** - * Tests that the filter overrides the constants. - * - * @ticket 57548 - */ - public function test_filter(): void { - $filter = new MockAction(); - add_filter( 'wp_should_concatenate_admin_scripts', array( $filter, 'filter' ) ); - - $this->assertSame( ! SCRIPT_DEBUG && defined( 'CONCATENATE_SCRIPTS' ) && CONCATENATE_SCRIPTS, wp_should_concatenate_admin_scripts() ); - $this->assertSame( 1, $filter->get_call_count() ); - - add_filter( 'wp_should_concatenate_admin_scripts', '__return_true', 20 ); - $this->assertTrue( wp_should_concatenate_admin_scripts() ); - - add_filter( 'wp_should_concatenate_admin_scripts', '__return_false', 30 ); - $this->assertFalse( wp_should_concatenate_admin_scripts() ); - } - - /** - * Tests that script_concat_settings() takes its default from the function on admin screens, and - * never concatenates elsewhere. - * - * @ticket 57548 - * - * @covers ::script_concat_settings - */ - public function test_script_concat_settings(): void { - add_filter( 'wp_should_concatenate_admin_scripts', '__return_true' ); - - unset( $GLOBALS['concatenate_scripts'] ); - script_concat_settings(); - $this->assertFalse( $GLOBALS['concatenate_scripts'], 'Expected no concatenation on the front end.' ); - - set_current_screen( 'dashboard' ); - unset( $GLOBALS['concatenate_scripts'] ); - script_concat_settings(); - $this->assertTrue( $GLOBALS['concatenate_scripts'], 'Expected concatenation on an admin screen.' ); - - add_filter( 'wp_should_concatenate_admin_scripts', '__return_false', 20 ); - unset( $GLOBALS['concatenate_scripts'] ); - script_concat_settings(); - $this->assertFalse( $GLOBALS['concatenate_scripts'], 'Expected the filter to turn concatenation off on an admin screen.' ); - } -} From 903878427c267fe5e72c863b20efed88f750ec2b Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 19 Oct 2026 23:40:48 +0000 Subject: [PATCH 151/236] Upgrade/Install: Explain when automatic updates cannot run. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When automatic updates can't run, the Plugins, Themes, and Updates screens still say “Automatic update scheduled in 6 hours”. The automatic updater skips the update entirely when the site is under version control or when writing files needs FTP credentials, so that scheduled update never happens. `wp_get_auto_update_message()` now runs the same two checks as `WP_Automatic_Updater::should_update()`, against the same directory, and says why the update won't run instead. Users who can view Site Health get a link to it, since Site Health already explains both cases. On the Updates screen, the core section drops the schedule and the “kept up to date” line in either case. The checks walk the filesystem, so the plugins and network themes list tables determine the message once per table instead of once per row. Developed in https://github.com/WordPress/wordpress-develop/pull/14506. Follow-up to r47835. Props kraftbj, eidolonnight, jgehrcke, nacin, johnbillion, chriscct7, SergeyBiryukov. Fixes #27814. git-svn-id: https://develop.svn.wordpress.org/trunk@64586 602fd350-edb4-49c9-b593-d223f7449a82 --- .../class-wp-ms-themes-list-table.php | 17 +- .../includes/class-wp-plugins-list-table.php | 17 +- src/wp-admin/includes/update.php | 51 ++++- src/wp-admin/themes.php | 2 +- .../update/wpGetAutoUpdateMessage.php | 179 ++++++++++++++++++ .../tests/admin/wpPluginsListTable.php | 73 +++++++ 6 files changed, 335 insertions(+), 4 deletions(-) create mode 100644 tests/phpunit/tests/admin/includes/update/wpGetAutoUpdateMessage.php diff --git a/src/wp-admin/includes/class-wp-ms-themes-list-table.php b/src/wp-admin/includes/class-wp-ms-themes-list-table.php index 0ecacb8f27fc5..be0039b5ea965 100644 --- a/src/wp-admin/includes/class-wp-ms-themes-list-table.php +++ b/src/wp-admin/includes/class-wp-ms-themes-list-table.php @@ -30,6 +30,17 @@ class WP_MS_Themes_List_Table extends WP_List_Table { */ protected $show_autoupdates = true; + /** + * The auto-update message shown for themes with an update available. + * + * Determined once per list table, as it is the same for every theme. + * + * @since 7.2.0 + * + * @var string|null Null until first needed. + */ + private $auto_update_message = null; + /** * Constructor. * @@ -867,10 +878,14 @@ public function column_autoupdates( $theme ) { } if ( isset( $available_updates->response[ $stylesheet ] ) ) { + if ( null === $this->auto_update_message ) { + $this->auto_update_message = wp_get_auto_update_message( 'theme' ); + } + $html[] = sprintf( '
%s
', $time_class, - wp_get_auto_update_message() + $this->auto_update_message ); } diff --git a/src/wp-admin/includes/class-wp-plugins-list-table.php b/src/wp-admin/includes/class-wp-plugins-list-table.php index c63a37992b6db..7778f21b4688b 100644 --- a/src/wp-admin/includes/class-wp-plugins-list-table.php +++ b/src/wp-admin/includes/class-wp-plugins-list-table.php @@ -24,6 +24,17 @@ class WP_Plugins_List_Table extends WP_List_Table { */ protected $show_autoupdates = true; + /** + * The auto-update message shown for plugins with an update available. + * + * Determined once per list table, as it is the same for every plugin. + * + * @since 7.2.0 + * + * @var string|null Null until first needed. + */ + private $auto_update_message = null; + /** * Constructor. * @@ -1434,10 +1445,14 @@ public function single_row( $item ) { } if ( ! empty( $plugin_data['update'] ) ) { + if ( null === $this->auto_update_message ) { + $this->auto_update_message = wp_get_auto_update_message( 'plugin' ); + } + $html[] = sprintf( '
%s
', $time_class, - wp_get_auto_update_message() + $this->auto_update_message ); } diff --git a/src/wp-admin/includes/update.php b/src/wp-admin/includes/update.php index b0e998264fe06..c3c15c8fe3f2c 100644 --- a/src/wp-admin/includes/update.php +++ b/src/wp-admin/includes/update.php @@ -1091,10 +1091,59 @@ function wp_is_auto_update_forced_for_item( $type, $update, $item ) { * Determines the appropriate auto-update message to be displayed. * * @since 5.5.0 + * @since 7.2.0 Added the `$type` parameter. A message is now returned when + * automatic updates cannot run because the filesystem requires + * credentials or the site appears to be under version control. * + * @param string $type Optional. The type of update the message is for: 'plugin' or 'theme'. + * Determines which directory is checked. Default empty, which checks ABSPATH. * @return string The update message to be shown. */ -function wp_get_auto_update_message() { +function wp_get_auto_update_message( $type = '' ) { + // Loads Automatic_Upgrader_Skin and WP_Automatic_Updater. + require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; + + if ( ! function_exists( 'request_filesystem_credentials' ) ) { + require_once ABSPATH . 'wp-admin/includes/file.php'; + } + + switch ( $type ) { + case 'plugin': + $context = WP_PLUGIN_DIR; + break; + case 'theme': + $context = get_theme_root(); + break; + default: + $context = ABSPATH; + } + + /* + * These mirror the checks in WP_Automatic_Updater::should_update(), which skips + * the update regardless of the schedule if either one fails. + */ + $skin = new Automatic_Upgrader_Skin(); + $updater = new WP_Automatic_Updater(); + + $message = ''; + if ( ! $skin->request_filesystem_credentials( false, $context ) ) { + $message = __( 'Automatic update will not run because WordPress needs FTP credentials to update files.' ); + } elseif ( $updater->is_vcs_checkout( $context ) ) { + $message = __( 'Automatic update will not run because this site appears to be under version control.' ); + } + + if ( $message ) { + if ( current_user_can( 'view_site_health_checks' ) ) { + $message .= ' ' . sprintf( + /* translators: %s: URL to the Site Health screen. */ + __( 'Learn more in Site Health.' ), + esc_url( admin_url( 'site-health.php' ) ) + ); + } + + return $message; + } + $next_update_time = wp_next_scheduled( 'wp_version_check' ); // Check if the event exists. diff --git a/src/wp-admin/themes.php b/src/wp-admin/themes.php index a0686c645766a..9e17386594a7d 100644 --- a/src/wp-admin/themes.php +++ b/src/wp-admin/themes.php @@ -811,7 +811,7 @@ function wp_theme_auto_update_setting_template() { <# } else { #> +
' . wp_get_auto_update_message( 'theme' ) . ' <# } #> ' . $notice . '
diff --git a/tests/phpunit/tests/admin/includes/update/wpGetAutoUpdateMessage.php b/tests/phpunit/tests/admin/includes/update/wpGetAutoUpdateMessage.php new file mode 100644 index 0000000000000..215c9c267fbd8 --- /dev/null +++ b/tests/phpunit/tests/admin/includes/update/wpGetAutoUpdateMessage.php @@ -0,0 +1,179 @@ +assertSame( 'Automatic update scheduled in 6 hours.', wp_get_auto_update_message( 'plugin' ) ); + } + + /** + * Tests that the schedule is replaced when the site is under version control. + * + * @ticket 27814 + * + * @dataProvider data_update_types + * + * @param string $type Type of update. + */ + public function test_should_return_version_control_message_when_under_version_control( $type ) { + add_filter( 'automatic_updates_is_vcs_checkout', '__return_true' ); + + $message = wp_get_auto_update_message( $type ); + + $this->assertStringStartsWith( 'Automatic update will not run because this site appears to be under version control.', $message ); + $this->assertStringNotContainsString( 'scheduled', $message ); + } + + /** + * Tests that the schedule is replaced when updating files requires FTP credentials. + * + * @ticket 27814 + * + * @dataProvider data_update_types + * + * @param string $type Type of update. + */ + public function test_should_return_credentials_message_when_credentials_are_required( $type ) { + remove_filter( 'request_filesystem_credentials', '__return_true' ); + add_filter( 'request_filesystem_credentials', '__return_false' ); + add_filter( 'automatic_updates_is_vcs_checkout', '__return_false' ); + + $message = wp_get_auto_update_message( $type ); + + $this->assertStringStartsWith( 'Automatic update will not run because WordPress needs FTP credentials to update files.', $message ); + $this->assertStringNotContainsString( 'scheduled', $message ); + } + + /** + * Tests that the credentials message takes precedence, matching the order + * of the checks in WP_Automatic_Updater::should_update(). + * + * @ticket 27814 + */ + public function test_should_return_credentials_message_when_both_checks_fail() { + remove_filter( 'request_filesystem_credentials', '__return_true' ); + add_filter( 'request_filesystem_credentials', '__return_false' ); + add_filter( 'automatic_updates_is_vcs_checkout', '__return_true' ); + + $this->assertStringStartsWith( 'Automatic update will not run because WordPress needs FTP credentials', wp_get_auto_update_message( 'plugin' ) ); + } + + /** + * Tests that the directory checked matches the one the automatic updater checks. + * + * @ticket 27814 + * + * @dataProvider data_update_types + * + * @param string $type Type of update. + */ + public function test_should_check_the_directory_for_the_type( $type ) { + $credentials_contexts = array(); + $vcs_contexts = array(); + + add_filter( + 'request_filesystem_credentials', + static function ( $credentials, $form_post, $method, $error, $context ) use ( &$credentials_contexts ) { + $credentials_contexts[] = $context; + return true; + }, + 20, + 5 + ); + + add_filter( + 'automatic_updates_is_vcs_checkout', + static function ( $checkout, $context ) use ( &$vcs_contexts ) { + $vcs_contexts[] = $context; + return false; + }, + 10, + 2 + ); + + wp_get_auto_update_message( $type ); + + $expected = array( + '' => ABSPATH, + 'plugin' => WP_PLUGIN_DIR, + 'theme' => get_theme_root(), + ); + + $this->assertSame( array( $expected[ $type ] ), $credentials_contexts, 'The wrong directory was checked for credentials.' ); + $this->assertSame( array( $expected[ $type ] ), $vcs_contexts, 'The wrong directory was checked for version control.' ); + } + + /** + * Data provider. + * + * @return array[] + */ + public static function data_update_types() { + return array( + 'no type' => array( '' ), + 'plugin' => array( 'plugin' ), + 'theme' => array( 'theme' ), + ); + } + + /** + * Tests that users who can view Site Health are linked to it. + * + * @ticket 27814 + */ + public function test_should_link_to_site_health_for_users_who_can_view_it() { + $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); + if ( is_multisite() ) { + grant_super_admin( $user_id ); + } + wp_set_current_user( $user_id ); + + add_filter( 'automatic_updates_is_vcs_checkout', '__return_true' ); + + $this->assertStringContainsString( 'href="' . admin_url( 'site-health.php' ) . '"', wp_get_auto_update_message( 'plugin' ) ); + } + + /** + * Tests that users who cannot view Site Health are not linked to it. + * + * @ticket 27814 + */ + public function test_should_not_link_to_site_health_for_users_who_cannot_view_it() { + wp_set_current_user( self::factory()->user->create( array( 'role' => 'editor' ) ) ); + + add_filter( 'automatic_updates_is_vcs_checkout', '__return_true' ); + + $this->assertStringNotContainsString( 'site-health.php', wp_get_auto_update_message( 'plugin' ) ); + } +} diff --git a/tests/phpunit/tests/admin/wpPluginsListTable.php b/tests/phpunit/tests/admin/wpPluginsListTable.php index 12af1d606f4e8..b6b8fd3d6002d 100644 --- a/tests/phpunit/tests/admin/wpPluginsListTable.php +++ b/tests/phpunit/tests/admin/wpPluginsListTable.php @@ -286,6 +286,79 @@ public function test_single_row_should_not_add_the_autoupdates_column_for_mustus $this->assertStringNotContainsString( 'column-auto-updates', $actual, 'The auto-updates column was output.' ); } + /** + * Tests that WP_Plugins_List_Table::single_row() determines the auto-update + * message once, rather than for each plugin with an update. + * + * The 'ms-excluded' group is added as the auto-updates column is only shown in the network admin. + * + * @ticket 27814 + * + * @group ms-excluded + * + * @covers WP_Plugins_List_Table::single_row + */ + public function test_single_row_should_determine_the_auto_update_message_once() { + add_filter( 'plugins_auto_update_enabled', '__return_true' ); + add_filter( 'request_filesystem_credentials', '__return_true' ); + + $vcs_checks = 0; + add_filter( + 'automatic_updates_is_vcs_checkout', + static function () use ( &$vcs_checks ) { + ++$vcs_checks; + return true; + } + ); + + wp_set_current_user( self::$admin_id ); + + $list_table_mock = $this->getMockBuilder( 'WP_Plugins_List_Table' ) + ->setMethods( array( 'get_column_info' ) ) + ->getMock(); + + $list_table_mock->method( 'get_column_info' )->willReturn( + array( + array( + 'name' => 'Plugin', + 'auto-updates' => 'Auto-updates', + ), + array(), + array(), + 'name', + ) + ); + + $output = ''; + foreach ( array( 'plugin-one', 'plugin-two' ) as $slug ) { + ob_start(); + $list_table_mock->single_row( + array( + "$slug/$slug.php", + array( + 'Name' => $slug, + 'slug' => $slug, + 'Description' => 'A plugin with an update available.', + 'Author' => 'A plugin author', + 'Version' => '1.0.0', + 'Author URI' => 'http://example.org', + 'Text Domain' => $slug, + 'update' => true, + 'update-supported' => true, + ), + ) + ); + $output .= ob_get_clean(); + } + + $this->assertSame( 1, $vcs_checks, 'Version control was not checked exactly once.' ); + $this->assertSame( + 2, + substr_count( $output, 'appears to be under version control' ), + 'The auto-update message was not output for both plugins.' + ); + } + /** * Data provider. * From 7cede9abac7294b0dd1ce7b61c16ad9c0374431c Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Tue, 20 Oct 2026 03:50:09 +0000 Subject: [PATCH 152/236] General: Bump the pinned hash for Gutenberg to 7b95ee96b (24.2.0). This updates the pinned commit hash of the Gutenberg repository from 954fe7f9e04631c41aec4552acd627a7203a2aad to 7b95ee96b54de2e35886971ccf7eb449c324c830 (version 24.2.0). A full list of changes included in this commit can be found on GitHub: https://github.com/WordPress/gutenberg/compare/954fe7f9e04631c41aec4552acd627a7203a2aad...7b95ee96b54de2e35886971ccf7eb449c324c830 - useServerSideRender: parse messages from caught errors (https://github.com/WordPress/gutenberg/pull/83365) - Docs: Fix published Vitest migration-guide links (https://github.com/WordPress/gutenberg/pull/83449) - Fix: Whitespace changes are not shown in the Resolve Block diff. (https://github.com/WordPress/gutenberg/pull/82397) - Editor: Use SearchableSelect for the post author field (https://github.com/WordPress/gutenberg/pull/83323) - Docs: Note that block attributes and global styles values are untrusted at render time (https://github.com/WordPress/gutenberg/pull/83473) - RichText: Remove dead exports and consolidate deprecations (https://github.com/WordPress/gutenberg/pull/83461) - Inserter: Manage roving tab index to skip re-rendering every item (https://github.com/WordPress/gutenberg/pull/83437) - SearchableSelectControl: Add to @wordpress/ui (https://github.com/WordPress/gutenberg/pull/80979) - Try: Bolder "B" icon (https://github.com/WordPress/gutenberg/pull/83321) - Ignore composer vendor files from top-level gitignore. (https://github.com/WordPress/gutenberg/pull/22283) - Tests: Add floating notes e2e coverage (https://github.com/WordPress/gutenberg/pull/83477) - Block Editor: Check the inserter's fallback containers unmemoized (https://github.com/WordPress/gutenberg/pull/83446) - Packages: Update Ariakit to 0.4.40 (https://github.com/WordPress/gutenberg/pull/83278) - Tests: Enforce per-call Vitest console expectations (https://github.com/WordPress/gutenberg/pull/83095) - Theme: Fix virtual modules, root styles, and seed validation (https://github.com/WordPress/gutenberg/pull/83355) - DataViews: Fix README to describe sort() as receiving field values, not items (https://github.com/WordPress/gutenberg/pull/83483) - Combobox: Label popup dialogs in stories (https://github.com/WordPress/gutenberg/pull/83476) - Block editor: Isolate mutable test fixtures (https://github.com/WordPress/gutenberg/pull/83098) - Blocks: Isolate registration state in tests (https://github.com/WordPress/gutenberg/pull/83099) - UI: Remove automatic Notice announcements (https://github.com/WordPress/gutenberg/pull/82737) - Text: Migrate Emotion styles to an SCSS Module (https://github.com/WordPress/gutenberg/pull/82573) - Block library: Isolate order-sensitive test interactions (https://github.com/WordPress/gutenberg/pull/83101) - Format Library: unify FormatEditProps to one type, move private types (https://github.com/WordPress/gutenberg/pull/83487) - UI: Announce selected chips in SearchableChipSelect (https://github.com/WordPress/gutenberg/pull/82863) - Card: Migrate from Emotion to SCSS modules (https://github.com/WordPress/gutenberg/pull/82577) - Components: Deprecate the private Menu API (https://github.com/WordPress/gutenberg/pull/82947) - CustomGradientPicker: Migrate control wrappers to an SCSS module (https://github.com/WordPress/gutenberg/pull/82576) - Components: Isolate order-sensitive UI tests (https://github.com/WordPress/gutenberg/pull/83103) - Tests: Isolate mutable configuration fixtures (https://github.com/WordPress/gutenberg/pull/83104) - Core data: Finish deferred selection updates in RTC test (https://github.com/WordPress/gutenberg/pull/83366) - Block editor: Wait for final keyboard link suggestions (https://github.com/WordPress/gutenberg/pull/83489) - Data: Assert and silence resolution error in useSuspenseSelect test (https://github.com/WordPress/gutenberg/pull/83491) - Tests: Isolate deprecation warning state (https://github.com/WordPress/gutenberg/pull/83107) - UI: Align selection popup checkmarks with the first label line (https://github.com/WordPress/gutenberg/pull/82942) - Tests: Resolve Browser Mode commands against the live iframe (https://github.com/WordPress/gutenberg/pull/83495) - Ensure position type is a string (https://github.com/WordPress/gutenberg/pull/83500) - MediaUpload: Fix console error when reopening Gallery media library (https://github.com/WordPress/gutenberg/pull/76749) - Refactor stylelint config detection in lint-style.js (https://github.com/WordPress/gutenberg/pull/79280) - Docs: Recommend UI Tabs for switching views (https://github.com/WordPress/gutenberg/pull/83516) - Popover: Close non-modal popovers on iframe interaction (https://github.com/WordPress/gutenberg/pull/83509) - Typography: List only the weights inside a variable font's range (https://github.com/WordPress/gutenberg/pull/83128) - Style book: Add link to example text. (https://github.com/WordPress/gutenberg/pull/83448) - Tests: Add Vitest Browser Mode failure artifacts (https://github.com/WordPress/gutenberg/pull/83093) - Theme: Make JavaScript token fallback transforms syntax-aware (https://github.com/WordPress/gutenberg/pull/83356) - Editor: Fix new posts being published with the `auto-draft` slug (https://github.com/WordPress/gutenberg/pull/83518) - Editor: Gather the View group of the Options menu into submenus (https://github.com/WordPress/gutenberg/pull/82976) - Tests: Fix PostCSS browser-externalized warnings in Vitest (https://github.com/WordPress/gutenberg/pull/83091) - Tests: Shuffle test cases in CI (https://github.com/WordPress/gutenberg/pull/83111) - Update Styles > Blocks description. (https://github.com/WordPress/gutenberg/pull/83515) - Columns: Remove the column count slider (https://github.com/WordPress/gutenberg/pull/83262) - BorderControl: Remove `%` from the border width units (https://github.com/WordPress/gutenberg/pull/83492) - Fields: Fix AuthorView for users who can't edit users (https://github.com/WordPress/gutenberg/pull/83498) - Update and add justify icons. (https://github.com/WordPress/gutenberg/pull/83519) - RichText: Refactor useMarkPersistent, fix StrictMode mount mark (https://github.com/WordPress/gutenberg/pull/83463) - Theme: Improve accessibility, API documentation, and compatibility checks (https://github.com/WordPress/gutenberg/pull/83358) - Theme: Preserve global token references in Lightning CSS (https://github.com/WordPress/gutenberg/pull/83359) - Tests: Migrate internal linting to Vitest and remove unused Jest dependencies (https://github.com/WordPress/gutenberg/pull/83502) - Improve specificity of lightbox button selector (https://github.com/WordPress/gutenberg/pull/70800) - TextControl: Use design system colors when disabled (https://github.com/WordPress/gutenberg/pull/83307) - Fix: Image lightbox: overlay becomes unusable (can't close) when it isn't a direct child of `` (https://github.com/WordPress/gutenberg/pull/83480) - Notes: Extract note selection sync into useNoteSelection hook (https://github.com/WordPress/gutenberg/pull/83528) - Block Parser: Document `\WP_Block_Parser::$stack` as a list (https://github.com/WordPress/gutenberg/pull/82695) - CollapsibleCard: Scope the header focus ring to its own trigger (https://github.com/WordPress/gutenberg/pull/81314) - Fix broken links in docs (https://github.com/WordPress/gutenberg/pull/83545) - Icons: Use assertEqualHTML() in icons registry tests (https://github.com/WordPress/gutenberg/pull/83544) - Editor: Merge adjacent revision inline diffs (https://github.com/WordPress/gutenberg/pull/80579) - Date: Ignore trailing format backslash instead of printing undefined (https://github.com/WordPress/gutenberg/pull/81528) - Block Supports: Add background-clip block support infrastructure (https://github.com/WordPress/gutenberg/pull/77141) - Block Editor: Fix translator comments for block count announcements (https://github.com/WordPress/gutenberg/pull/83555) - Paste: replace non-breaking spaces at the edges of text with regular spaces (https://github.com/WordPress/gutenberg/pull/83464) - Media Editor: Fix pan drag flooding undo history after wheel zoom (https://github.com/WordPress/gutenberg/pull/83558) - Rich text: fix iOS double tap selection, preventing focus capture under editable host (https://github.com/WordPress/gutenberg/pull/81042) - Block editor: migrate state-control badges to UI Badge (https://github.com/WordPress/gutenberg/pull/82608) - Gallery: Add Order By controls for static gallery, consolidate controls in settings sidebar (https://github.com/WordPress/gutenberg/pull/83438) - Media editor: show an error when saving attachment details fails (https://github.com/WordPress/gutenberg/pull/83560) - Position controls: Fix useSelect warning for selected state viewports (https://github.com/WordPress/gutenberg/pull/83570) - Inserter: Use design system focus ring for previews (https://github.com/WordPress/gutenberg/pull/83126) - Image: Fix lightbox using thumbnail aspect ratio instead of original image ratio (https://github.com/WordPress/gutenberg/pull/79058) - Docs: Clarify @wordpress/ui icon color requirements (https://github.com/WordPress/gutenberg/pull/83564) - docker compose -T if stdin is not a tty (https://github.com/WordPress/gutenberg/pull/78374) - Storybook: Add new contributing page. (https://github.com/WordPress/gutenberg/pull/83345) - Widget Primitives: Avoid Vite warnings for runtime widget modules (https://github.com/WordPress/gutenberg/pull/83602) - Build: Update Vite to 8.3.1 and simplify Storybook tooling (https://github.com/WordPress/gutenberg/pull/83569) - doc(wp-env) Change core branch from trunk to master in doc (https://github.com/WordPress/gutenberg/pull/83566) - wp-build: Remove the unused boot, private-apis, and route optional peer dependencies (https://github.com/WordPress/gutenberg/pull/83601) - CI: Check CHANGELOG presence for published tooling and config packages (https://github.com/WordPress/gutenberg/pull/83577) - Tests: Enforce Vitest assertion coverage (https://github.com/WordPress/gutenberg/pull/83572) - Icons: Update heading level icons for optical balance (https://github.com/WordPress/gutenberg/pull/83268) - ESLint: Add allowUseWithCaution option to use-recommended-components (https://github.com/WordPress/gutenberg/pull/83536) - Notes: Refactor floating board measurement (https://github.com/WordPress/gutenberg/pull/83485) - Inserter: Stop re-rendering the block list on block selection change (https://github.com/WordPress/gutenberg/pull/83284) - Paste: Give each pasted data-URI image unique filename to avoid upload collisions. (https://github.com/WordPress/gutenberg/pull/79480) - Changelog validator: ignore markdown & configs d46223 (https://github.com/WordPress/gutenberg/pull/83618) - Font Library: Use UI Menu for collection actions (https://github.com/WordPress/gutenberg/pull/82965) - Storybook: Show prop descriptions in Canvas controls (https://github.com/WordPress/gutenberg/pull/83581) - test: Link upstream warning fixes in config (https://github.com/WordPress/gutenberg/pull/83632) - Storybook: Use one block-editor store module (https://github.com/WordPress/gutenberg/pull/83636) - Tests: Use strict assertions synced from Core changeset 63934. (https://github.com/WordPress/gutenberg/pull/83619) - Math: Store cell alignment in the MathML and polyfill alignment and overlines in Chromium (https://github.com/WordPress/gutenberg/pull/83164) - Storybook: Reuse PostCSS browser resolver in smoke tests (https://github.com/WordPress/gutenberg/pull/83635) - Editor: Use UI Menu for template options (https://github.com/WordPress/gutenberg/pull/82964) - RTC: Add a EntitySyncManager interface in core-data (https://github.com/WordPress/gutenberg/pull/83410) - Term Count: Add margin support (https://github.com/WordPress/gutenberg/pull/83608) - Archives: Add minimum height support (https://github.com/WordPress/gutenberg/pull/83573) - Media Editor: Stop the crop pixel snap from recording undo history (https://github.com/WordPress/gutenberg/pull/83571) - Term Name: Add margin support (https://github.com/WordPress/gutenberg/pull/83606) - Post Author Biography: Add text indent support (https://github.com/WordPress/gutenberg/pull/83614) - Code: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83574) - Details: Add minimum width support (https://github.com/WordPress/gutenberg/pull/83576) - Post Content: Add minimum width support (https://github.com/WordPress/gutenberg/pull/83575) - Post Excerpt: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83578) - Post Title: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83600) - Footnotes: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83579) - Storybook: Place Notice announcements under Components (https://github.com/WordPress/gutenberg/pull/83617) - InputControl: Darken the field border on hover (https://github.com/WordPress/gutenberg/pull/83306) - npm: Switch from legacy-peer-deps to strict-peer-deps (https://github.com/WordPress/gutenberg/pull/81029) - Term Name: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83599) - Columns: Allow dropping a column at the outer edges (https://github.com/WordPress/gutenberg/pull/83274) - E2E: Pin the site title in the Interactivity API router specs and give the E2E Storybook build more heap. (https://github.com/WordPress/gutenberg/pull/83474) - Heading: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83580) - Login/out: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83583) - Verse: Add minimum width support (https://github.com/WordPress/gutenberg/pull/83609) - Video, Cover: Don't autoplay in the editor when reduced motion is preferred (https://github.com/WordPress/gutenberg/pull/83337) - Media & Text: Lower the specificity of the content padding (https://github.com/WordPress/gutenberg/pull/83563) - Pagination: Add padding, margin, and block gap support (https://github.com/WordPress/gutenberg/pull/83743) - Fix peer dependency conflicts left in the lockfile (https://github.com/WordPress/gutenberg/pull/83754) - Comments Pagination: Add padding, margin, and block gap support (https://github.com/WordPress/gutenberg/pull/83744) - Term Count: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83596) - Read More: Add border style support (https://github.com/WordPress/gutenberg/pull/83735) - Cover: Don't autoplay embedded background videos when reduced motion is preferred (https://github.com/WordPress/gutenberg/pull/83452) - No Results: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83584) - RichText: Rename utils.jsx to utils.js (https://github.com/WordPress/gutenberg/pull/83758) - Quote: Add minimum width support (https://github.com/WordPress/gutenberg/pull/83592) - Upgrade typescript-eslint to v8.70.1 (https://github.com/WordPress/gutenberg/pull/83760) - Tabs: Add minimum width support (https://github.com/WordPress/gutenberg/pull/83595) - Site Tagline: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83589) - Heading: Add text indent support (https://github.com/WordPress/gutenberg/pull/83615) - Site Title: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83593) - Home Link: Add padding and margin support (https://github.com/WordPress/gutenberg/pull/83607) - Preformatted: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83587) - Include E2E Storybook sources in docgen (https://github.com/WordPress/gutenberg/pull/83634) - Extensible Site Editor: Pass custom block categories to the blocks store (https://github.com/WordPress/gutenberg/pull/83762) - Packages: Declare missing peer dependencies and check them in CI (https://github.com/WordPress/gutenberg/pull/83765) - Post Terms: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83586) - Group, Cover: Track drop zone element in state (https://github.com/WordPress/gutenberg/pull/83756) - Global Styles: Add pseudo-state controls for Navigation Link (https://github.com/WordPress/gutenberg/pull/83451) - storybook: Register playground core blocks once (https://github.com/WordPress/gutenberg/pull/83637) - Document Outline: Show the design system focus ring instead of legacy box-shadow (https://github.com/WordPress/gutenberg/pull/83755) - storybook: Update BlockPopover fixture to API version 3 (https://github.com/WordPress/gutenberg/pull/83642) - Add typing to iAPI's getConfig() (https://github.com/WordPress/gutenberg/pull/71692) - Components: deprecate Badge (https://github.com/WordPress/gutenberg/pull/82379) - Block Editor: Fix style / nested attribute overwrite during multi-selection (https://github.com/WordPress/gutenberg/pull/80070) - Notes: Restrict menu actions for resolution notes and resolved threads (https://github.com/WordPress/gutenberg/pull/73243) - UI: Add change actions to form primitive stories (https://github.com/WordPress/gutenberg/pull/83591) - Icons: Support keyword-based search in the icons registry (https://github.com/WordPress/gutenberg/pull/82367) - Avatar: Explain that avatars use the Gravatar service (https://github.com/WordPress/gutenberg/pull/83567) - UI: Add item labels and descriptions to remaining popups (https://github.com/WordPress/gutenberg/pull/83493) - PaletteEdit: Stop changing the slug when renaming a preset (https://github.com/WordPress/gutenberg/pull/83750) - Storybook: Fix missing block styles in BlockCanvas playground stories (https://github.com/WordPress/gutenberg/pull/81070) - Tests: Enforce Vitest callback, promise, and title rules (https://github.com/WordPress/gutenberg/pull/83620) - ItemGroup: Use design system focus ring (https://github.com/WordPress/gutenberg/pull/83764) - Keep the legacy CheckboxControl visually consistent across viewports (https://github.com/WordPress/gutenberg/pull/83612) - Media editor: Use UI Menu for crop aspect ratio (https://github.com/WordPress/gutenberg/pull/82968) - Use strict assertions in override script tests (https://github.com/WordPress/gutenberg/pull/83782) - Home Link: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83582) - Tab Panels: Add minimum height support (https://github.com/WordPress/gutenberg/pull/83594) - Post Time to Read: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83598) - Term Description: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83597) - UI: Keep InputLayout chrome at md on small viewports (https://github.com/WordPress/gutenberg/pull/82764) - Math: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83585) - Tests: Bump undici in the AI development test lockfile (https://github.com/WordPress/gutenberg/pull/83799) - Bump brace-expansion in /test/ai-development (https://github.com/WordPress/gutenberg/pull/83807) - Bump js-yaml and promptfoo in /test/ai-development (https://github.com/WordPress/gutenberg/pull/83797) - Bump fast-uri from 3.1.7 to 3.1.8 (https://github.com/WordPress/gutenberg/pull/83829) - Update AI Development package versions after npm audit (https://github.com/WordPress/gutenberg/pull/83830) - Notes: Add show and hide options for floating notes (https://github.com/WordPress/gutenberg/pull/83768) - Add separators to item popup components (https://github.com/WordPress/gutenberg/pull/83776) - Components: Align RadioControl colors with UI Radio (https://github.com/WordPress/gutenberg/pull/83270) - E2E: Mock Openverse in image drag-and-drop inserter test (https://github.com/WordPress/gutenberg/pull/83842) - FormToggle: Match Switch colors across states (https://github.com/WordPress/gutenberg/pull/83773) - Bump `@react-spring/web` from 9.4.5 to 10.1.2 (https://github.com/WordPress/gutenberg/pull/83796) - ColorPalette: Show design system focus ring on custom color button (https://github.com/WordPress/gutenberg/pull/83841) - Docs: Remove CheckboxControl heading from InspectorControls example (https://github.com/WordPress/gutenberg/pull/83844) - Base Styles: Default the admin theme color to Blueberry (https://github.com/WordPress/gutenberg/pull/83749) - Menu: Guard against nesting Group and RadioGroup (https://github.com/WordPress/gutenberg/pull/83792) - Template Part: Fall back to rendering a template part from the theme file if the db version is unavailable (https://github.com/WordPress/gutenberg/pull/83809) - Tests: Reset deprecation history in shared Vitest setup (https://github.com/WordPress/gutenberg/pull/83849) - Menu: Disable triggers instead of roots in consumers (https://github.com/WordPress/gutenberg/pull/83791) - Playlist: Replace the waveform player patch with its no-autoinit entry (https://github.com/WordPress/gutenberg/pull/83132) - Update UI Spinner appearance and add a color prop (https://github.com/WordPress/gutenberg/pull/83775) - UI: Align component names with their semantics (https://github.com/WordPress/gutenberg/pull/83789) - Checkbox: Prevent rounded themes from making checkboxes circular (https://github.com/WordPress/gutenberg/pull/83526) - Storybook: Update manifest snapshot for Spinner color prop (https://github.com/WordPress/gutenberg/pull/83856) - Button: Only open the link popover on explicit user action (https://github.com/WordPress/gutenberg/pull/30166) - Gallery Lightbox: Prevent image click from closing the dialog when navigation is enabled (https://github.com/WordPress/gutenberg/pull/78898) - UI: Recommend Checkbox family components (https://github.com/WordPress/gutenberg/pull/83771) - RadioControl: Keep a 16px visual with a larger hit target (https://github.com/WordPress/gutenberg/pull/83840) - Table: replace deprecated word-break with overflow-wrap: anywhere (https://github.com/WordPress/gutenberg/pull/82480) - Tag Cloud: Update styles and add `!important` (https://github.com/WordPress/gutenberg/pull/70224) - Correctly document the `blockName` property as being nullable (https://github.com/WordPress/gutenberg/pull/70900) - Add inertValue helper and use it for setting inert attribute (https://github.com/WordPress/gutenberg/pull/83871) - Enable editableRoot for the list item block for multi-selection on mobile (https://github.com/WordPress/gutenberg/pull/82816) - Verify localized data retention in override script test (https://github.com/WordPress/gutenberg/pull/83845) - Tests: Bump ibm-cloud-sdk-core in the AI development test lockfile (https://github.com/WordPress/gutenberg/pull/83887) - UI: Recommend Notice component (https://github.com/WordPress/gutenberg/pull/82685) - Fix: MediaUpload `gallery` prop ignores `allowedTypes` (https://github.com/WordPress/gutenberg/pull/78257) - Media editor: Add a session boundary above the cropper (https://github.com/WordPress/gutenberg/pull/83550) - DataViews: Measure the container as the data view mounts to avoid a single column flash (https://github.com/WordPress/gutenberg/pull/83752) - Pullquote: Add minimum width support (https://github.com/WordPress/gutenberg/pull/83588) - Media editor: Remove initial state seeding from the session (https://github.com/WordPress/gutenberg/pull/83893) - UI: Add e2e Storybook popup item layout fixtures (https://github.com/WordPress/gutenberg/pull/83488) - Storybook: Give CI job a distinct name (https://github.com/WordPress/gutenberg/pull/83869) - Coding standards: Skip anonymous class methods in block library function name sniff (https://github.com/WordPress/gutenberg/pull/83900) - Pagination: Add border support (https://github.com/WordPress/gutenberg/pull/83745) - PR meta: Move the props list into the shared comment (https://github.com/WordPress/gutenberg/pull/82302) - Comments Pagination: Add border support (https://github.com/WordPress/gutenberg/pull/83746) - Scripts: Resolve default configs without hoisted dependencies (https://github.com/WordPress/gutenberg/pull/83902) - Image: Fix invalid CSS url() value in circle-mask style (https://github.com/WordPress/gutenberg/pull/82333) - Query Total: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83590) - Scripts: Treat files passed after --fix as file arguments (https://github.com/WordPress/gutenberg/pull/83521) - Editor: Remove icon for 'Export' more menu item (https://github.com/WordPress/gutenberg/pull/83901) - Dashboard Widgets: let a mounted widget declare actions at runtime (https://github.com/WordPress/gutenberg/pull/83877) - Framework: Switch from hoisted to isolated dependencies (https://github.com/WordPress/gutenberg/pull/83847) - Test: Run Vitest type graph validation in process (https://github.com/WordPress/gutenberg/pull/83851) - Remove use-memo-one usage (missing React 19 compat) (https://github.com/WordPress/gutenberg/pull/83952) - Fix Post Featured Image crash when isLink is enabled (https://github.com/WordPress/gutenberg/pull/81584) - Experiment: restyle classic wp-admin controls from design system tokens (https://github.com/WordPress/gutenberg/pull/82425) - Tests: Lint JavaScript Vitest mock imports (https://github.com/WordPress/gutenberg/pull/83783) - Build: Remove patch-package (https://github.com/WordPress/gutenberg/pull/83982) - Docs: Update deprecation testing guidance for shared reset (https://github.com/WordPress/gutenberg/pull/83989) - DataViews: list hideable fields alphabetically in the view config (https://github.com/WordPress/gutenberg/pull/83947) - Core Data: Rank link suggestions by type, and stop discarding merged results (https://github.com/WordPress/gutenberg/pull/83407) - Add new react-inert-value package with inertValue helper (https://github.com/WordPress/gutenberg/pull/83987) - Connectors: Keep a stored API key read-only when it can't be verified (https://github.com/WordPress/gutenberg/pull/83889) - Navigation: Search every entity type from the link UI (https://github.com/WordPress/gutenberg/pull/83408) - Tests: Cover translation setup in override script tests (https://github.com/WordPress/gutenberg/pull/83886) - Build: Update Vite to 8.3.2 and remove the PostCSS browser resolver (https://github.com/WordPress/gutenberg/pull/83992) - Update readme title to match block name (https://github.com/WordPress/gutenberg/pull/83999) - RTC: Fix undo breaking for non-synced entities (https://github.com/WordPress/gutenberg/pull/83888) - CI: Cover the AI development lockfile with Dependabot instead of npm audit (https://github.com/WordPress/gutenberg/pull/83997) - Latest Posts: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83905) - Avatar: Add shadow support (https://github.com/WordPress/gutenberg/pull/83929) - Tab List: Add shadow support (https://github.com/WordPress/gutenberg/pull/83922) - Buttons: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83894) - Social Icons: Add shadow support (https://github.com/WordPress/gutenberg/pull/83920) - Columns: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83895) - Gallery: Add shadow support (https://github.com/WordPress/gutenberg/pull/83919) - File: Add shadow support (https://github.com/WordPress/gutenberg/pull/83918) - Page List: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83908) - Build Tooling: Read npm v12 pack --json output (https://github.com/WordPress/gutenberg/pull/84011) - Accordion Heading: Add line height support (https://github.com/WordPress/gutenberg/pull/83958) - Paragraph: Add shadow support (https://github.com/WordPress/gutenberg/pull/83926) - Media & Text: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83906) - Tests: Patch basic-ftp in AI development dependencies (https://github.com/WordPress/gutenberg/pull/84000) - Env, E2E: Update dependencies that ran native install scripts (https://github.com/WordPress/gutenberg/pull/84012) - Tests: Update Vitest to 5.0.3 and Storybook to 10.6.1 (https://github.com/WordPress/gutenberg/pull/83996) - Search: Add padding support (https://github.com/WordPress/gutenberg/pull/83984) - Block editor: Honour background skip serialization in the editor (https://github.com/WordPress/gutenberg/pull/83943) - Framework: Declare React types in the workspaces that use them (https://github.com/WordPress/gutenberg/pull/84013) - Fit text: Size each block instance in a loop independently (https://github.com/WordPress/gutenberg/pull/83985) - FocalPointPicker: end a drag released over the editor canvas (https://github.com/WordPress/gutenberg/pull/83348) - Tests: Cover Menu scroll lock and LinkControl protocols in browsers (https://github.com/WordPress/gutenberg/pull/83991) - List: Add shadow support (https://github.com/WordPress/gutenberg/pull/83923) - UI: Add Progress with custom color support (https://github.com/WordPress/gutenberg/pull/83781) - ESLint: Allow non-module stylesheet imports in unit tests (https://github.com/WordPress/gutenberg/pull/84019) - Canvas loader: Use UI Progress and pass color via the indicator prop (https://github.com/WordPress/gutenberg/pull/83860) - Menu: Align group labels and separators with indented item labels. (https://github.com/WordPress/gutenberg/pull/83993) - react-inert-value: add missing types/react peer dep (https://github.com/WordPress/gutenberg/pull/84024) - Docs: Refine design system agent guidance (https://github.com/WordPress/gutenberg/pull/84007) - Navigation: List allowed blocks in the link UI search results + add transformSuggestions to Link Control (https://github.com/WordPress/gutenberg/pull/83652) - Sync: Remove exposed wp.sync package (https://github.com/WordPress/gutenberg/pull/81999) - Style: Update color to use CSS variable in edit-site (https://github.com/WordPress/gutenberg/pull/79002) - Popover: drop the will-change hint once the popover stops moving (https://github.com/WordPress/gutenberg/pull/77359) - MediaEdit: Show a checkerboard background behind image previews (https://github.com/WordPress/gutenberg/pull/83846) - Quote: Add button colour support (https://github.com/WordPress/gutenberg/pull/83983) - Media & Text: Add duotone support (https://github.com/WordPress/gutenberg/pull/83981) - Gallery: Add duotone support (https://github.com/WordPress/gutenberg/pull/83978) - Interactivity API Router: Add reactive navigation lifecycle and initiator API (https://github.com/WordPress/gutenberg/pull/83280) - Notes: Move floating notes into a canvas margin (https://github.com/WordPress/gutenberg/pull/83786) - Verse: Add text columns and indent support (https://github.com/WordPress/gutenberg/pull/83962) - Notes: Scroll floating notes with the canvas (https://github.com/WordPress/gutenberg/pull/83852) - Notes: Add Undo to deleted note snackbar (https://github.com/WordPress/gutenberg/pull/83988) - Framework: Move @typescript/native from the root to the workspaces that use it (https://github.com/WordPress/gutenberg/pull/84027) - Repair invalid peer dependencies in the lockfile (https://github.com/WordPress/gutenberg/pull/84062) - Term Template: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83914) - Fix check type declarations (https://github.com/WordPress/gutenberg/pull/84070) - Media: track the original attachment id for edited images (https://github.com/WordPress/gutenberg/pull/81803) - Post Comments Form: Add font family support (https://github.com/WordPress/gutenberg/pull/83967) - Media Utils: Add `MediaEdit` as a private API (https://github.com/WordPress/gutenberg/pull/84046) - Build Tools: Fix flaky ESM package types test timeout (https://github.com/WordPress/gutenberg/pull/84068) - Embed: Add padding support (https://github.com/WordPress/gutenberg/pull/83963) - Interactivity API: Add a data-wp-html directive (https://github.com/WordPress/gutenberg/pull/83092) - Typography and "block-default icon polish. (https://github.com/WordPress/gutenberg/pull/84073) - Release Tooling: Read the npm v12 JSON output shapes (https://github.com/WordPress/gutenberg/pull/84075) - Menu: Align submenu labels and highlight open parents (https://github.com/WordPress/gutenberg/pull/84031) - Props Bot: Skip bare reviews that duplicate their review comment runs (https://github.com/WordPress/gutenberg/pull/84076) - Dataviews: use inertValue in CompositeGrid (https://github.com/WordPress/gutenberg/pull/84072) - UI: Add Meter (https://github.com/WordPress/gutenberg/pull/83855) - Media & Text: Add shadow support (https://github.com/WordPress/gutenberg/pull/83976) - Media editor: restore original image in modal (https://github.com/WordPress/gutenberg/pull/81805) - List: Add background image, size, and gradient support (https://github.com/WordPress/gutenberg/pull/83935) - List Item: Add background image, size, and gradient support (https://github.com/WordPress/gutenberg/pull/83936) - Block Editor: Fix 'Manage allowed blocks' not shown when its the only 'Advanced' control (https://github.com/WordPress/gutenberg/pull/84067) - Design System: Clarify tooltip labeling and UI review guidance (https://github.com/WordPress/gutenberg/pull/83898) - Gallery: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83897) - File: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83896) - Media: Return 0 from the edit root lookup when there is no edit root (https://github.com/WordPress/gutenberg/pull/84096) - Read More: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83912) - UI: Recommend Radio family components (https://github.com/WordPress/gutenberg/pull/83872) - Latest Comments: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83904) - chore: Use v24 in .nvmrc (https://github.com/WordPress/gutenberg/pull/84061) - Embed: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83903) - Post Comments Form: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83910) - Post Featured Image: Add border style support (https://github.com/WordPress/gutenberg/pull/83956) - Buttons: Add shadow support (https://github.com/WordPress/gutenberg/pull/83916) - Poetry: Add fit text support (https://github.com/WordPress/gutenberg/pull/83980) - Video: Add duotone support (https://github.com/WordPress/gutenberg/pull/83979) - Notes: Keep anchor writes out of undo history (https://github.com/WordPress/gutenberg/pull/84079) - ProgressBar: Use WPDS color tokens (https://github.com/WordPress/gutenberg/pull/83779) - REST API: Add action-trash link to posts and comments (https://github.com/WordPress/gutenberg/pull/84045) - RSS: Add minimum width and height support (https://github.com/WordPress/gutenberg/pull/83913) - Notes: Reset paragraph top margin in floating notes (https://github.com/WordPress/gutenberg/pull/84101) - Global Styles: Fix popover position in Styles screen (https://github.com/WordPress/gutenberg/pull/84048) - Block Switcher: Show design system focus ring on pattern previews (https://github.com/WordPress/gutenberg/pull/83933) - MediaEdit: Use design system focus ring (https://github.com/WordPress/gutenberg/pull/83854) - Notes: Delete permanently when the trash is disabled (https://github.com/WordPress/gutenberg/pull/84102) - Release: Rewrite SVN publication scripts in Node.js (https://github.com/WordPress/gutenberg/pull/84034) - ContentEditableControl: Keep a disabled field focusable (https://github.com/WordPress/gutenberg/pull/84083) - States: Scope per-instance rules to the block's root element (https://github.com/WordPress/gutenberg/pull/83986) - List Item: Add shadow support (https://github.com/WordPress/gutenberg/pull/83925) - DataViews: Truncate filter chips instead of wrapping them (https://github.com/WordPress/gutenberg/pull/83879) - Experiments: Turn the React 19 experiment on by default (https://github.com/WordPress/gutenberg/pull/83784) - Notes: Extract NoteReply and lift AddNote gating (https://github.com/WordPress/gutenberg/pull/84106) - Interactivity API: Remove expired deprecated behaviors (https://github.com/WordPress/gutenberg/pull/84098) - Breadcrumbs: Fix typo in aria label translation context (https://github.com/WordPress/gutenberg/pull/84112) - ESLint: Allow generated test titles (https://github.com/WordPress/gutenberg/pull/83995) - Icons: Add keywords to icon manifest (https://github.com/WordPress/gutenberg/pull/83884) - Tooltip: Control the hover delay cancellation test clock (https://github.com/WordPress/gutenberg/pull/84113) - VS Code: Add managed workspace config (https://github.com/WordPress/gutenberg/pull/84025) - Breadcrumb: fix getMeasurementRender for React 19 (https://github.com/WordPress/gutenberg/pull/84069) - Notes: Fix flaky thread scroll e2e test (https://github.com/WordPress/gutenberg/pull/84118) - Detect the database client in the unit test debug step. (https://github.com/WordPress/gutenberg/pull/84089) - UI: Preserve Autocomplete item type inference (https://github.com/WordPress/gutenberg/pull/84095) - UI: Recommend Switch family components (https://github.com/WordPress/gutenberg/pull/84097) - Env: Add an option to choose the MariaDB version (https://github.com/WordPress/gutenberg/pull/83751) - UI: Preserve Combobox source item generics (https://github.com/WordPress/gutenberg/pull/84094) - Menu: Tighten spacing, use 16px prefix icons, and cap width at 320px (https://github.com/WordPress/gutenberg/pull/84028) - Notes: Preserve unsent note and reply drafts (https://github.com/WordPress/gutenberg/pull/84110) - Theme: Add integration test coverage for seed colors in artifacts (https://github.com/WordPress/gutenberg/pull/81161) - Progress: Migrate remaining ProgressBar usages and recommend UI Progress (https://github.com/WordPress/gutenberg/pull/84021) - Components: Fix polymorphism typings leaking `as` prop (https://github.com/WordPress/gutenberg/pull/82704) - Media & Text: Add background image, size, and gradient support (https://github.com/WordPress/gutenberg/pull/83927) - Experiments: Use a mock plugin slug that no WordPress build ships in the unrelated-plugin test (https://github.com/WordPress/gutenberg/pull/84133) - Button: Add background image, size, and gradient support (https://github.com/WordPress/gutenberg/pull/83950) - Tests: Isolate Ajv per test in wp-env schema tests to avoid order dependence (https://github.com/WordPress/gutenberg/pull/84139) - Storybook: Read icon keywords from the manifest (https://github.com/WordPress/gutenberg/pull/84127) - SandBox: Fix embed previews that require a referrer in Safari (https://github.com/WordPress/gutenberg/pull/84014) - Notes: Restore child notes trashed along with their parent note (https://github.com/WordPress/gutenberg/pull/84100) - Style states: fix exception when there's no selected block (https://github.com/WordPress/gutenberg/pull/84140) - Chore: Use v24.20 in `.nvmrc` config file. (https://github.com/WordPress/gutenberg/pull/84138) - Security: Opt in to the npm v12 supply-chain defaults (https://github.com/WordPress/gutenberg/pull/82689) - Docs: Describe isolated dependencies for agents and contributors (https://github.com/WordPress/gutenberg/pull/84141) - Upgrade code and types to React 19 (https://github.com/WordPress/gutenberg/pull/83941) - Latest Comments: Add border support (https://github.com/WordPress/gutenberg/pull/84148) - Add prettier, eslint and stylelint to the root package.json (https://github.com/WordPress/gutenberg/pull/84017) - FontSizePicker: Migrate Emotion styles to SCSS Modules (https://github.com/WordPress/gutenberg/pull/84126) - Fields API: Add the server-side registry and REST route (https://github.com/WordPress/gutenberg/pull/84078) - Block bindings: add support to `icon` attribute of `core/icon` (https://github.com/WordPress/gutenberg/pull/80730) - VisuallyHidden: Move hiding styles outside CSS cascade layers (https://github.com/WordPress/gutenberg/pull/84114) - Theme: Generate complete border token modes for Figma testing (https://github.com/WordPress/gutenberg/pull/84035) - Developer tools: Simplify editor setup and add Zed settings (https://github.com/WordPress/gutenberg/pull/84143) - Consolidate wp-admin container radiuses onto the design system scale (https://github.com/WordPress/gutenberg/pull/82427) - CustomGradientPicker: Extend control point targets to the bar height (https://github.com/WordPress/gutenberg/pull/84124) - Notes: Draw the canvas divider from body so it uses the theme text color (https://github.com/WordPress/gutenberg/pull/84158) - Icons: Experiment with proportional stroke scaling (https://github.com/WordPress/gutenberg/pull/84081) - Global Styles: Ignore theme.json values of unexpected types (https://github.com/WordPress/gutenberg/pull/84523) - React 19 codemod: apply defaultProps when rendering a memo component (https://github.com/WordPress/gutenberg/pull/84568) - React 19: add new incompatible plugins (https://github.com/WordPress/gutenberg/pull/84607) - Tests: Fix HTML comparison tests (https://github.com/WordPress/gutenberg/pull/84294) - Tests: Fix list item unsafe markup test on older WordPress versions (https://github.com/WordPress/gutenberg/pull/84302) - Experiments: don't invalidate saved option with a legacy key (https://github.com/WordPress/gutenberg/pull/84619) - Tests: Scope Classic block media checkbox locator (https://github.com/WordPress/gutenberg/pull/84524) Props mamaduka. See #66340 git-svn-id: https://develop.svn.wordpress.org/trunk@64587 602fd350-edb4-49c9-b593-d223f7449a82 --- package.json | 2 +- src/wp-admin/includes/update-core.php | 3 + .../assets/icon-library-manifest.php | 9 + .../assets/script-loader-packages.php | 68 +- .../assets/script-modules-packages.php | 44 +- .../blocks/accordion-heading/block.json | 1 + src/wp-includes/blocks/archives/block.json | 3 + src/wp-includes/blocks/avatar.php | 8 +- src/wp-includes/blocks/avatar/block.json | 4 + src/wp-includes/blocks/blocks-json.php | 282 +- src/wp-includes/blocks/breadcrumbs.php | 2 +- src/wp-includes/blocks/button.php | 47 + src/wp-includes/blocks/button/block.json | 6 + src/wp-includes/blocks/buttons/block.json | 7 +- src/wp-includes/blocks/code/block.json | 4 + src/wp-includes/blocks/columns/block.json | 4 + .../blocks/comments-pagination/block.json | 11 + src/wp-includes/blocks/cover.php | 59 +- src/wp-includes/blocks/cover/block.json | 3 +- src/wp-includes/blocks/details/block.json | 3 + src/wp-includes/blocks/embed/block.json | 7 +- src/wp-includes/blocks/file/block.json | 5 + src/wp-includes/blocks/footnotes/block.json | 4 + src/wp-includes/blocks/gallery/block.json | 13 + src/wp-includes/blocks/heading/block.json | 5 + src/wp-includes/blocks/home-link/block.json | 12 + src/wp-includes/blocks/icon.php | 2 +- src/wp-includes/blocks/image.php | 7 +- .../blocks/latest-comments/block.json | 10 + .../blocks/latest-posts/block.json | 4 + src/wp-includes/blocks/list-item/block.json | 9 +- src/wp-includes/blocks/list/block.json | 13 +- src/wp-includes/blocks/loginout/block.json | 4 + src/wp-includes/blocks/math/block.json | 4 + src/wp-includes/blocks/media-text/block.json | 18 + src/wp-includes/blocks/page-list/block.json | 4 + src/wp-includes/blocks/paragraph/block.json | 1 + .../blocks/post-author-biography/block.json | 1 + .../blocks/post-comments-form/block.json | 5 + .../blocks/post-content/block.json | 3 +- .../blocks/post-excerpt/block.json | 4 + .../blocks/post-featured-image/block.json | 1 + src/wp-includes/blocks/post-terms/block.json | 4 + .../blocks/post-time-to-read/block.json | 4 + src/wp-includes/blocks/post-title/block.json | 4 + .../blocks/preformatted/block.json | 4 + src/wp-includes/blocks/pullquote/block.json | 3 +- .../blocks/query-no-results/block.json | 4 + .../blocks/query-pagination/block.json | 17 + src/wp-includes/blocks/query-total/block.json | 4 + src/wp-includes/blocks/quote/block.json | 2 + src/wp-includes/blocks/read-more/block.json | 5 + src/wp-includes/blocks/rss/block.json | 4 + src/wp-includes/blocks/search/block.json | 3 +- .../blocks/site-tagline/block.json | 4 + src/wp-includes/blocks/site-title/block.json | 4 + .../blocks/social-links/block.json | 1 + src/wp-includes/blocks/tab-list/block.json | 4 + src/wp-includes/blocks/tab-panels/block.json | 3 + src/wp-includes/blocks/tabs/block.json | 3 + src/wp-includes/blocks/template-part.php | 19 +- src/wp-includes/blocks/term-count/block.json | 5 + .../blocks/term-description/block.json | 4 + src/wp-includes/blocks/term-name/block.json | 7 +- .../blocks/term-template/block.json | 4 + src/wp-includes/blocks/verse/block.json | 4 + src/wp-includes/blocks/video/block.json | 8 +- src/wp-includes/build/constants.php | 2 +- .../build/routes/connectors-home/content.js | 661 +- .../connectors-home/content.min.asset.php | 2 +- .../routes/connectors-home/content.min.js | 2 +- .../build/routes/font-list/content.js | 13542 +++++++++++++--- .../routes/font-list/content.min.asset.php | 2 +- .../build/routes/font-list/content.min.js | 14 +- .../images/icon-library/arrow-down-left.svg | 2 +- .../images/icon-library/arrow-down-right.svg | 2 +- .../images/icon-library/arrow-down.svg | 2 +- .../images/icon-library/arrow-left.svg | 2 +- .../images/icon-library/arrow-right.svg | 2 +- .../images/icon-library/arrow-up-left.svg | 2 +- .../images/icon-library/arrow-up-right.svg | 2 +- .../images/icon-library/arrow-up.svg | 2 +- .../images/icon-library/at-symbol.svg | 2 +- src/wp-includes/images/icon-library/audio.svg | 2 +- src/wp-includes/images/icon-library/bell.svg | 4 +- .../images/icon-library/block-default.svg | 3 +- .../images/icon-library/block-meta.svg | 2 +- .../images/icon-library/block-table.svg | 2 +- src/wp-includes/images/icon-library/brush.svg | 2 +- .../images/icon-library/calendar.svg | 4 +- .../images/icon-library/capture-photo.svg | 4 +- .../images/icon-library/capture-video.svg | 4 +- src/wp-includes/images/icon-library/cart.svg | 6 +- .../images/icon-library/category.svg | 8 +- .../images/icon-library/caution.svg | 2 +- .../images/icon-library/chart-bar.svg | 2 +- src/wp-includes/images/icon-library/check.svg | 2 +- .../icon-library/chevron-down-small.svg | 2 +- .../images/icon-library/chevron-down.svg | 2 +- .../icon-library/chevron-left-small.svg | 2 +- .../images/icon-library/chevron-left.svg | 2 +- .../icon-library/chevron-right-small.svg | 2 +- .../images/icon-library/chevron-right.svg | 2 +- .../images/icon-library/chevron-up-down.svg | 2 +- .../images/icon-library/chevron-up-small.svg | 2 +- .../images/icon-library/chevron-up.svg | 2 +- .../images/icon-library/comment.svg | 2 +- src/wp-includes/images/icon-library/cover.svg | 2 +- .../images/icon-library/create.svg | 2 +- .../images/icon-library/dashboard.svg | 2 +- .../images/icon-library/desktop.svg | 2 +- .../images/icon-library/download.svg | 2 +- .../images/icon-library/drawer-left.svg | 2 +- .../images/icon-library/drawer-right.svg | 2 +- .../images/icon-library/envelope.svg | 2 +- src/wp-includes/images/icon-library/error.svg | 2 +- .../images/icon-library/external.svg | 2 +- src/wp-includes/images/icon-library/file.svg | 2 +- .../images/icon-library/gallery.svg | 4 +- src/wp-includes/images/icon-library/group.svg | 4 +- .../images/icon-library/heading.svg | 2 +- src/wp-includes/images/icon-library/help.svg | 4 +- src/wp-includes/images/icon-library/home.svg | 2 +- src/wp-includes/images/icon-library/image.svg | 2 +- src/wp-includes/images/icon-library/info.svg | 2 +- src/wp-includes/images/icon-library/key.svg | 2 +- .../images/icon-library/language.svg | 4 +- src/wp-includes/images/icon-library/link.svg | 2 +- .../images/icon-library/map-marker.svg | 2 +- src/wp-includes/images/icon-library/media.svg | 12 +- src/wp-includes/images/icon-library/menu.svg | 2 +- .../images/icon-library/mobile.svg | 2 +- .../images/icon-library/more-horizontal.svg | 6 +- .../images/icon-library/more-vertical.svg | 6 +- src/wp-includes/images/icon-library/next.svg | 2 +- src/wp-includes/images/icon-library/page.svg | 2 +- .../images/icon-library/paragraph.svg | 4 +- .../images/icon-library/payment.svg | 4 +- .../images/icon-library/pencil.svg | 4 +- .../images/icon-library/people.svg | 2 +- src/wp-includes/images/icon-library/pin.svg | 2 +- .../images/icon-library/plugins.svg | 2 +- .../images/icon-library/plus-circle.svg | 4 +- src/wp-includes/images/icon-library/plus.svg | 2 +- .../images/icon-library/previous.svg | 2 +- .../images/icon-library/published.svg | 4 +- src/wp-includes/images/icon-library/quote.svg | 2 +- .../images/icon-library/receipt.svg | 2 +- src/wp-includes/images/icon-library/rss.svg | 4 +- .../images/icon-library/scheduled.svg | 4 +- .../images/icon-library/search.svg | 2 +- .../images/icon-library/settings.svg | 2 +- .../images/icon-library/shadow.svg | 2 +- src/wp-includes/images/icon-library/share.svg | 2 +- .../images/icon-library/shield.svg | 2 +- .../images/icon-library/shuffle.svg | 2 +- src/wp-includes/images/icon-library/sites.svg | 6 +- .../images/icon-library/star-empty.svg | 2 +- .../images/icon-library/star-filled.svg | 2 +- .../images/icon-library/star-half.svg | 2 +- src/wp-includes/images/icon-library/store.svg | 2 +- .../images/icon-library/styles.svg | 2 +- .../images/icon-library/symbol-filled.svg | 4 +- .../images/icon-library/symbol.svg | 4 +- src/wp-includes/images/icon-library/table.svg | 2 +- .../images/icon-library/tablet.svg | 2 +- src/wp-includes/images/icon-library/tag.svg | 2 +- src/wp-includes/images/icon-library/tip.svg | 2 +- src/wp-includes/images/icon-library/tool.svg | 2 +- .../images/icon-library/update.svg | 2 +- .../images/icon-library/upload.svg | 2 +- src/wp-includes/images/icon-library/verse.svg | 6 +- 172 files changed, 12087 insertions(+), 3239 deletions(-) diff --git a/package.json b/package.json index eb165bda5b0f0..2881c5f3715c1 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "url": "https://develop.svn.wordpress.org/trunk" }, "gutenberg": { - "sha": "954fe7f9e04631c41aec4552acd627a7203a2aad", + "sha": "7b95ee96b54de2e35886971ccf7eb449c324c830", "ghcrRepo": "WordPress/gutenberg/gutenberg-wp-develop-build" }, "engines": { diff --git a/src/wp-admin/includes/update-core.php b/src/wp-admin/includes/update-core.php index 7d625150110f1..4b91dca2b183a 100644 --- a/src/wp-admin/includes/update-core.php +++ b/src/wp-admin/includes/update-core.php @@ -1170,6 +1170,9 @@ * 'wp-includes/images/icon-library/update.svg', * 'wp-includes/images/icon-library/wordpress.svg', */ + // 7.2 + 'wp-includes/js/dist/sync.js', + 'wp-includes/js/dist/sync.min.js', ); /** diff --git a/src/wp-includes/assets/icon-library-manifest.php b/src/wp-includes/assets/icon-library-manifest.php index 6af5b7d421051..c4bbc83af2b5b 100644 --- a/src/wp-includes/assets/icon-library-manifest.php +++ b/src/wp-includes/assets/icon-library-manifest.php @@ -49,11 +49,13 @@ 'label' => _x( 'At Symbol (@)', 'icon label' ), 'filePath' => 'at-symbol.svg', 'collections' => array( 'core' ), + 'keywords' => array( _x( 'email', 'icon keyword' ) ), ), 'audio' => array( 'label' => _x( 'Audio', 'icon label' ), 'filePath' => 'audio.svg', 'collections' => array( 'core' ), + 'keywords' => array( _x( 'music', 'icon keyword' ), _x( 'note', 'icon keyword' ) ), ), 'bell' => array( 'label' => _x( 'Bell', 'icon label' ), @@ -109,6 +111,7 @@ 'label' => _x( 'Caution', 'icon label' ), 'filePath' => 'caution.svg', 'collections' => array( 'core' ), + 'keywords' => array( _x( 'alert', 'icon keyword' ), _x( 'exclamation', 'icon keyword' ), _x( 'warning', 'icon keyword' ) ), ), 'chart-bar' => array( 'label' => _x( 'Chart Bar', 'icon label' ), @@ -179,6 +182,7 @@ 'label' => _x( 'Create', 'icon label' ), 'filePath' => 'create.svg', 'collections' => array( 'core' ), + 'keywords' => array( _x( 'add', 'icon keyword' ), _x( 'new', 'icon keyword' ), _x( 'plus', 'icon keyword' ) ), ), 'dashboard' => array( 'label' => _x( 'Dashboard', 'icon label' ), @@ -209,11 +213,13 @@ 'label' => _x( 'Envelope', 'icon label' ), 'filePath' => 'envelope.svg', 'collections' => array( 'core' ), + 'keywords' => array( _x( 'email', 'icon keyword' ), _x( 'letter', 'icon keyword' ), _x( 'post', 'icon keyword' ) ), ), 'error' => array( 'label' => _x( 'Error', 'icon label' ), 'filePath' => 'error.svg', 'collections' => array( 'core' ), + 'keywords' => array( _x( 'alert', 'icon keyword' ), _x( 'caution', 'icon keyword' ), _x( 'exclamation', 'icon keyword' ), _x( 'warning', 'icon keyword' ) ), ), 'external' => array( 'label' => _x( 'External', 'icon label' ), @@ -224,6 +230,7 @@ 'label' => _x( 'File', 'icon label' ), 'filePath' => 'file.svg', 'collections' => array( 'core' ), + 'keywords' => array( _x( 'archive', 'icon keyword' ), _x( 'document', 'icon keyword' ), _x( 'folder', 'icon keyword' ) ), ), 'gallery' => array( 'label' => _x( 'Gallery', 'icon label' ), @@ -329,6 +336,7 @@ 'label' => _x( 'Pencil', 'icon label' ), 'filePath' => 'pencil.svg', 'collections' => array( 'core', 'core-admin' ), + 'keywords' => array( _x( 'edit', 'icon keyword' ) ), ), 'people' => array( 'label' => _x( 'People', 'icon label' ), @@ -429,6 +437,7 @@ 'label' => _x( 'Star Filled', 'icon label' ), 'filePath' => 'star-filled.svg', 'collections' => array( 'core' ), + 'keywords' => array( _x( 'favorite', 'icon keyword' ) ), ), 'star-half' => array( 'label' => _x( 'Star Half', 'icon label' ), diff --git a/src/wp-includes/assets/script-loader-packages.php b/src/wp-includes/assets/script-loader-packages.php index 130c022842931..d25684f47cc98 100644 --- a/src/wp-includes/assets/script-loader-packages.php +++ b/src/wp-includes/assets/script-loader-packages.php @@ -4,7 +4,7 @@ 'wp-dom-ready', 'wp-i18n' ), - 'version' => '31c6cec5a4ff7aff483d' + 'version' => '5faef02d497f248e93ee' ), 'annotations.js' => array( 'dependencies' => array( @@ -67,7 +67,7 @@ 'wp-url', 'wp-warning' ), - 'version' => '56da94f1b6ed56573e78' + 'version' => '6d6b3181a753252387e7' ), 'block-editor.js' => array( 'dependencies' => array( @@ -105,7 +105,7 @@ 'wp-url', 'wp-warning' ), - 'version' => '578ad9eb61ae8af0123d' + 'version' => '6e282539cf0a135ed4a5' ), 'block-library.js' => array( 'dependencies' => array( @@ -151,7 +151,7 @@ 'import' => 'dynamic' ) ), - 'version' => '0999d15ea60b2ca101bc' + 'version' => '9442f80186e1fd6c9d4b' ), 'block-serialization-default-parser.js' => array( 'dependencies' => array( @@ -184,7 +184,7 @@ 'wp-shortcode', 'wp-warning' ), - 'version' => 'c453468c6e4fc4dacf25' + 'version' => '3a5d55524352cd1635f7' ), 'commands.js' => array( 'dependencies' => array( @@ -201,7 +201,7 @@ 'wp-primitives', 'wp-private-apis' ), - 'version' => '4a4a518ce9c4838666fe' + 'version' => '0f782aaf1624cdb1148e' ), 'components.js' => array( 'dependencies' => array( @@ -226,11 +226,10 @@ 'wp-theme', 'wp-warning' ), - 'version' => 'fecbc7a454bacff1527c' + 'version' => 'b719ac135662ae191dd9' ), 'compose.js' => array( 'dependencies' => array( - 'react', 'react-jsx-runtime', 'wp-deprecated', 'wp-dom', @@ -241,7 +240,7 @@ 'wp-private-apis', 'wp-undo-manager' ), - 'version' => '18547cd8d2e6674f7b98' + 'version' => '502412777bc436c79a5e' ), 'core-commands.js' => array( 'dependencies' => array( @@ -258,7 +257,7 @@ 'wp-router', 'wp-url' ), - 'version' => '738a4beca871c27833f1' + 'version' => '8839a8b3ea5cc4eb698e' ), 'core-data.js' => array( 'dependencies' => array( @@ -271,6 +270,7 @@ 'wp-data', 'wp-deprecated', 'wp-element', + 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-notices', @@ -278,12 +278,11 @@ 'wp-private-apis', 'wp-rich-text', 'wp-style-engine', - 'wp-sync', 'wp-undo-manager', 'wp-url', 'wp-warning' ), - 'version' => 'a1d74a5d3b46ac893e05' + 'version' => '85a2af40c63fbc42dfd4' ), 'customize-widgets.js' => array( 'dependencies' => array( @@ -319,7 +318,7 @@ 'import' => 'static' ) ), - 'version' => 'dcab974f036fbee73086' + 'version' => 'b8cdb457de36ea41f05c' ), 'data.js' => array( 'dependencies' => array( @@ -347,7 +346,7 @@ 'moment', 'wp-deprecated' ), - 'version' => '8173fc0fc12b7bb7eaf0' + 'version' => 'af0f72250d99230696c5' ), 'deprecated.js' => array( 'dependencies' => array( @@ -410,7 +409,7 @@ 'import' => 'static' ) ), - 'version' => 'b4b1fb53ee012caa42fb' + 'version' => '2c15b75d60d41653fe34' ), 'edit-site.js' => array( 'dependencies' => array( @@ -459,7 +458,7 @@ 'import' => 'static' ) ), - 'version' => '1d1116c276ed95618737' + 'version' => '8690337206dfcb4ce13d' ), 'edit-widgets.js' => array( 'dependencies' => array( @@ -501,7 +500,7 @@ 'import' => 'static' ) ), - 'version' => 'b66dc643708560ba6922' + 'version' => '09222c649dc37fa9ac75' ), 'editor.js' => array( 'dependencies' => array( @@ -552,7 +551,7 @@ 'import' => 'static' ) ), - 'version' => '021570d5ceb676201638' + 'version' => 'a4fe21d0704817acc70d' ), 'element.js' => array( 'dependencies' => array( @@ -560,7 +559,7 @@ 'react-dom', 'wp-escape-html' ), - 'version' => '4822427ad9c627826631' + 'version' => '5a4b1aa0e42aad8ef7db' ), 'escape-html.js' => array( 'dependencies' => array( @@ -594,7 +593,7 @@ 'import' => 'dynamic' ) ), - 'version' => 'f9ce39fe8a3d8aaf2fd6' + 'version' => '8a12998b72d8407956ee' ), 'hooks.js' => array( 'dependencies' => array( @@ -627,7 +626,7 @@ 'wp-element', 'wp-keycodes' ), - 'version' => 'ba3985e44a8fdca9462f' + 'version' => '2871b9b36c2a9aef74c4' ), 'keycodes.js' => array( 'dependencies' => array( @@ -662,6 +661,7 @@ 'wp-date', 'wp-deprecated', 'wp-element', + 'wp-html-entities', 'wp-i18n', 'wp-keycodes', 'wp-notices', @@ -672,7 +672,7 @@ 'wp-url', 'wp-warning' ), - 'version' => '64a4692e40e4685caccd' + 'version' => '688e248d5d924b36f889' ), 'notices.js' => array( 'dependencies' => array( @@ -711,7 +711,7 @@ 'wp-url', 'wp-warning' ), - 'version' => 'bb86130c876014c4db11' + 'version' => '6738120a1e2a12899699' ), 'plugins.js' => array( 'dependencies' => array( @@ -723,7 +723,7 @@ 'wp-is-shallow-equal', 'wp-primitives' ), - 'version' => 'a03a674fba0130981f2d' + 'version' => '4c53884fe0283a7ee4c5' ), 'preferences.js' => array( 'dependencies' => array( @@ -739,7 +739,7 @@ 'wp-primitives', 'wp-private-apis' ), - 'version' => 'f0a611a312173e6b7648' + 'version' => '00228fed7f2d274a78ab' ), 'preferences-persistence.js' => array( 'dependencies' => array( @@ -764,7 +764,7 @@ 'dependencies' => array( ), - 'version' => 'df3615fd5cb379fb7ffe' + 'version' => 'c12220e72e4bcdfac6f3' ), 'react-i18n.js' => array( 'dependencies' => array( @@ -824,7 +824,7 @@ 'wp-i18n', 'wp-url' ), - 'version' => '83e806a0634df6b93530' + 'version' => '3ddc6eaa634c653fb483' ), 'shortcode.js' => array( 'dependencies' => array( @@ -836,15 +836,7 @@ 'dependencies' => array( ), - 'version' => '914befb08774033e6265' - ), - 'sync.js' => array( - 'dependencies' => array( - 'wp-api-fetch', - 'wp-hooks', - 'wp-private-apis' - ), - 'version' => '7179e38284ff7aba21e6' + 'version' => '7d2c0a2a9e5ae3f8e1c9' ), 'theme.js' => array( 'dependencies' => array( @@ -854,7 +846,7 @@ 'wp-element', 'wp-private-apis' ), - 'version' => '795a74a11c336f95159b' + 'version' => '21b0c3318f26c7b3d71e' ), 'token-list.js' => array( 'dependencies' => array( @@ -926,7 +918,7 @@ 'wp-notices', 'wp-primitives' ), - 'version' => 'f2802a2d8ac37b86bc43' + 'version' => '27c5c0b8c8fcd1753149' ), 'wordcount.js' => array( 'dependencies' => array( diff --git a/src/wp-includes/assets/script-modules-packages.php b/src/wp-includes/assets/script-modules-packages.php index b000cd3d852b6..1cfd4f0882c86 100644 --- a/src/wp-includes/assets/script-modules-packages.php +++ b/src/wp-includes/assets/script-modules-packages.php @@ -3,14 +3,14 @@ 'dependencies' => array( ), - 'version' => 'f62f48906198ea8abc60' + 'version' => '4df772cdd295831820e3' ), 'abilities/index.js' => array( 'dependencies' => array( 'wp-data', 'wp-i18n' ), - 'version' => 'e5fcd7e304ead0fc9779' + 'version' => '9448bb3053516a39086d' ), 'block-editor/utils/fit-text-frontend.js' => array( 'dependencies' => array( @@ -36,6 +36,22 @@ ), 'version' => '6d4bb8df9c7539843ad3' ), + 'block-library/cover/view.js' => array( + 'dependencies' => array( + + ), + 'module_dependencies' => array( + array( + 'id' => '@wordpress/a11y', + 'import' => 'static' + ), + array( + 'id' => '@wordpress/interactivity', + 'import' => 'static' + ) + ), + 'version' => '205c83d309206ac7b189' + ), 'block-library/file/view.js' => array( 'dependencies' => array( @@ -58,7 +74,7 @@ 'import' => 'static' ) ), - 'version' => '25ee935fd6c67371d0f3' + 'version' => '22bef14632c3f4b4622a' ), 'block-library/navigation/view.js' => array( 'dependencies' => array( @@ -82,7 +98,7 @@ 'import' => 'static' ) ), - 'version' => 'fde7e3309a48521aed56' + 'version' => 'dcead465d87ec21eea99' ), 'block-library/query/view.js' => array( 'dependencies' => array( @@ -162,7 +178,7 @@ 'import' => 'static' ) ), - 'version' => 'f6c3c0c637fe0ed2dbd2' + 'version' => 'a31ac98fff5501742501' ), 'connectors/index.js' => array( 'dependencies' => array( @@ -219,13 +235,13 @@ 'import' => 'static' ) ), - 'version' => '9e49b9edcfc16dc5203c' + 'version' => '4b2e3230d57e16afb0ad' ), 'interactivity/index.js' => array( 'dependencies' => array( ), - 'version' => 'b0929e0bd08daccaa778' + 'version' => '2c5ac406b0272485700e' ), 'interactivity-router/full-page.js' => array( 'dependencies' => array( @@ -253,13 +269,13 @@ 'import' => 'static' ) ), - 'version' => '711aa380e66c57009b7a' + 'version' => '3ee11de34faed693e7a5' ), 'latex-to-mathml/index.js' => array( 'dependencies' => array( ), - 'version' => '662cb0e7f68d2a21cd68' + 'version' => '4ec5f96f5cf884f76516' ), 'latex-to-mathml/loader.js' => array( 'dependencies' => array( @@ -287,7 +303,7 @@ 'wp-private-apis', 'wp-style-engine' ), - 'version' => 'e50dce77f58e6e3ffa9b' + 'version' => '7fa38becb312ea2acafb' ), 'route/index.js' => array( 'dependencies' => array( @@ -314,7 +330,7 @@ 'dependencies' => array( ), - 'version' => '4d3627c45251ceb4f9a2' + 'version' => 'fa777d9ac60940d2e501' ), 'vips/loader.js' => array( 'dependencies' => array( @@ -332,14 +348,14 @@ 'dependencies' => array( ), - 'version' => '7e33cd8c4128731126e8' + 'version' => '41206bd52b7ae59d873a' ), 'widget-primitives/index.js' => array( 'dependencies' => array( 'react-jsx-runtime', 'wp-element' ), - 'version' => '3047de39283129372300' + 'version' => '355066e7b5d458a5968d' ), 'workflow/index.js' => array( 'dependencies' => array( @@ -372,6 +388,6 @@ 'import' => 'dynamic' ) ), - 'version' => '02fa947b818b1e4c07fd' + 'version' => '870e8ddb51af5d567758' ) ); \ No newline at end of file diff --git a/src/wp-includes/blocks/accordion-heading/block.json b/src/wp-includes/blocks/accordion-heading/block.json index 8f51644120d41..1aa1756019374 100644 --- a/src/wp-includes/blocks/accordion-heading/block.json +++ b/src/wp-includes/blocks/accordion-heading/block.json @@ -45,6 +45,7 @@ "letterSpacing" ], "fontSize": true, + "lineHeight": true, "__experimentalFontFamily": true, "__experimentalFontWeight": true, "__experimentalFontStyle": true, diff --git a/src/wp-includes/blocks/archives/block.json b/src/wp-includes/blocks/archives/block.json index 7455b558c0d18..b0063dd06663b 100644 --- a/src/wp-includes/blocks/archives/block.json +++ b/src/wp-includes/blocks/archives/block.json @@ -42,6 +42,9 @@ "gradient": true } }, + "dimensions": { + "minHeight": true + }, "html": false, "spacing": { "margin": true, diff --git a/src/wp-includes/blocks/avatar.php b/src/wp-includes/blocks/avatar.php index 196d67a4d480c..c257175432685 100644 --- a/src/wp-includes/blocks/avatar.php +++ b/src/wp-includes/blocks/avatar.php @@ -19,6 +19,7 @@ function render_block_core_avatar( $attributes, $content, $block ) { $size = $attributes['size'] ?? 96; $wrapper_attributes = get_block_wrapper_attributes(); $border_attributes = get_block_core_avatar_border_attributes( $attributes ); + $shadow_styles = wp_style_engine_get_styles( array( 'shadow' => $attributes['style']['shadow'] ?? null ) ); // Class gets passed through `esc_attr` via `get_avatar`. $image_classes = ! empty( $border_attributes['class'] ) @@ -26,10 +27,11 @@ function render_block_core_avatar( $attributes, $content, $block ) { : 'wp-block-avatar__image'; // Unlike class, `get_avatar` doesn't filter the styles via `esc_attr`. - // The style engine does pass the border styles through + // The style engine does pass the border and shadow styles through // `safecss_filter_attr` however. - $image_styles = ! empty( $border_attributes['style'] ) - ? sprintf( ' style="%s"', esc_attr( $border_attributes['style'] ) ) + $image_css = ( $border_attributes['style'] ?? '' ) . ( $shadow_styles['css'] ?? '' ); + $image_styles = ! empty( $image_css ) + ? sprintf( ' style="%s"', esc_attr( $image_css ) ) : ''; if ( ! isset( $block->context['commentId'] ) ) { diff --git a/src/wp-includes/blocks/avatar/block.json b/src/wp-includes/blocks/avatar/block.json index 0cb92d81865c7..7d8b2ddee1f10 100644 --- a/src/wp-includes/blocks/avatar/block.json +++ b/src/wp-includes/blocks/avatar/block.json @@ -54,12 +54,16 @@ "filter": { "duotone": true }, + "shadow": { + "__experimentalSkipSerialization": true + }, "interactivity": { "clientNavigation": true } }, "selectors": { "border": ".wp-block-avatar img", + "shadow": ".wp-block-avatar img", "filter": { "duotone": ".wp-block-avatar img" } diff --git a/src/wp-includes/blocks/blocks-json.php b/src/wp-includes/blocks/blocks-json.php index 73e0bebb8fb78..e21c24ebf586c 100644 --- a/src/wp-includes/blocks/blocks-json.php +++ b/src/wp-includes/blocks/blocks-json.php @@ -152,6 +152,7 @@ 'letterSpacing' ), 'fontSize' => true, + 'lineHeight' => true, '__experimentalFontFamily' => true, '__experimentalFontWeight' => true, '__experimentalFontStyle' => true, @@ -414,6 +415,9 @@ 'gradient' => true ) ), + 'dimensions' => array( + 'minHeight' => true + ), 'html' => false, 'spacing' => array( 'margin' => true, @@ -591,12 +595,16 @@ 'filter' => array( 'duotone' => true ), + 'shadow' => array( + '__experimentalSkipSerialization' => true + ), 'interactivity' => array( 'clientNavigation' => true ) ), 'selectors' => array( 'border' => '.wp-block-avatar img', + 'shadow' => '.wp-block-avatar img', 'filter' => array( 'duotone' => '.wp-block-avatar img' ) @@ -808,6 +816,12 @@ 'splitting' => true, 'align' => false, 'alignWide' => false, + 'background' => array( + 'backgroundImage' => true, + 'backgroundSize' => true, + 'gradient' => true, + '__experimentalSkipSerialization' => true + ), 'color' => array( '__experimentalSkipSerialization' => true, 'gradients' => true, @@ -971,6 +985,10 @@ 'fontSize' => true ) ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), '__experimentalBorder' => array( 'color' => true, 'radius' => true, @@ -994,7 +1012,8 @@ 'clientNavigation' => true ), 'listView' => true, - 'contentRole' => true + 'contentRole' => true, + 'shadow' => true ), 'editorStyle' => 'wp-block-buttons-editor', 'style' => 'wp-block-buttons' @@ -1196,6 +1215,10 @@ 'gradient' => true ) ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'typography' => array( 'fontSize' => true, 'lineHeight' => true, @@ -1400,6 +1423,10 @@ 'gradient' => true ) ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'spacing' => array( 'blockGap' => array( '__experimentalDefault' => '2em', @@ -1995,6 +2022,11 @@ 'type' => 'flex' ) ), + 'spacing' => array( + 'padding' => true, + 'margin' => true, + 'blockGap' => true + ), 'typography' => array( 'fontSize' => true, 'lineHeight' => true, @@ -2008,6 +2040,12 @@ 'fontSize' => true ) ), + '__experimentalBorder' => array( + 'color' => true, + 'radius' => true, + 'style' => true, + 'width' => true + ), 'interactivity' => array( 'clientNavigation' => true ) @@ -2424,7 +2462,8 @@ 'allowJustification' => false ), 'interactivity' => array( - 'clientNavigation' => true + 'clientNavigation' => true, + 'interactive' => true ), 'filter' => array( 'duotone' => true @@ -2515,6 +2554,9 @@ 'padding' => false ) ), + 'dimensions' => array( + 'minWidth' => true + ), 'typography' => array( 'fontSize' => true, 'lineHeight' => true, @@ -2584,8 +2626,13 @@ 'supports' => array( 'anchor' => true, 'align' => true, + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'spacing' => array( - 'margin' => true + 'margin' => true, + 'padding' => true ), 'interactivity' => array( 'clientNavigation' => true @@ -2678,6 +2725,10 @@ 'margin' => true, 'padding' => true ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'color' => array( 'gradients' => true, 'link' => true, @@ -2699,6 +2750,7 @@ 'style' => true ) ), + 'shadow' => true, 'interactivity' => true ), 'editorStyle' => 'wp-block-file-editor', @@ -2764,6 +2816,10 @@ 'padding' => false ) ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'typography' => array( 'fontSize' => true, 'lineHeight' => true, @@ -3005,6 +3061,11 @@ 'background' => true, 'gradients' => true ), + 'shadow' => true, + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'layout' => array( 'allowSwitching' => false, 'allowInheriting' => false, @@ -3018,11 +3079,19 @@ 'type' => 'flex' ) ), + 'filter' => array( + 'duotone' => true + ), 'interactivity' => array( 'clientNavigation' => true ), 'listView' => true ), + 'selectors' => array( + 'filter' => array( + 'duotone' => '.wp-block-gallery :where(img)' + ) + ), 'editorStyle' => 'wp-block-gallery-editor', 'style' => 'wp-block-gallery' ), @@ -3208,6 +3277,10 @@ 'text' => true ) ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'shadow' => true, 'spacing' => array( 'margin' => true, @@ -3221,6 +3294,7 @@ 'fontSize' => true, 'lineHeight' => true, 'textAlign' => true, + 'textIndent' => true, '__experimentalFontFamily' => true, '__experimentalFontStyle' => true, '__experimentalFontWeight' => true, @@ -3299,6 +3373,10 @@ ) ), 'shadow' => true, + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), '__experimentalBorder' => array( 'color' => true, 'radius' => true, @@ -3311,6 +3389,14 @@ 'width' => false ) ), + 'spacing' => array( + 'margin' => true, + 'padding' => true, + '__experimentalDefaultControls' => array( + 'margin' => false, + 'padding' => false + ) + ), 'interactivity' => array( 'clientNavigation' => true ) @@ -3674,11 +3760,21 @@ 'link' => true ) ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'html' => false, 'spacing' => array( 'margin' => true, 'padding' => true ), + '__experimentalBorder' => array( + 'color' => true, + 'radius' => true, + 'style' => true, + 'width' => true + ), 'shadow' => true, 'typography' => array( 'fontSize' => true, @@ -3804,6 +3900,10 @@ 'link' => true ) ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'spacing' => array( 'margin' => true, 'padding' => true, @@ -3945,6 +4045,15 @@ 'fontSize' => true ) ), + 'background' => array( + 'backgroundImage' => true, + 'backgroundSize' => true, + 'gradient' => true, + '__experimentalDefaultControls' => array( + 'backgroundImage' => true, + 'gradient' => true + ) + ), 'color' => array( 'gradients' => true, 'link' => true, @@ -3961,6 +4070,7 @@ 'padding' => false ) ), + 'shadow' => true, '__unstablePasteTextInline' => true, '__experimentalOnMerge' => true, '__experimentalSlashInserter' => true, @@ -3970,7 +4080,8 @@ 'listView' => true ), 'selectors' => array( - 'border' => '.wp-block-list:not(.wp-block-list .wp-block-list)' + 'border' => '.wp-block-list:not(.wp-block-list .wp-block-list)', + 'shadow' => '.wp-block-list:not(.wp-block-list .wp-block-list)' ), 'editorStyle' => 'wp-block-list-editor', 'style' => 'wp-block-list' @@ -4005,6 +4116,11 @@ 'html' => false, 'className' => false, 'splitting' => true, + 'background' => array( + 'backgroundImage' => true, + 'backgroundSize' => true, + 'gradient' => true + ), '__experimentalBorder' => array( 'color' => true, 'radius' => true, @@ -4027,6 +4143,7 @@ 'padding' => false ) ), + 'shadow' => true, 'typography' => array( 'fontSize' => true, 'lineHeight' => true, @@ -4046,7 +4163,8 @@ ), 'selectors' => array( 'root' => '.wp-block-list > li', - 'border' => '.wp-block-list:not(.wp-block-list .wp-block-list) > li' + 'border' => '.wp-block-list:not(.wp-block-list .wp-block-list) > li', + 'shadow' => '.wp-block-list:not(.wp-block-list .wp-block-list) > li' ) ), 'loginout' => array( @@ -4093,6 +4211,10 @@ 'gradients' => true, 'link' => true ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'spacing' => array( 'margin' => true, 'padding' => true, @@ -4166,6 +4288,10 @@ 'text' => true ) ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'shadow' => true, 'spacing' => array( 'margin' => true, @@ -4310,6 +4436,11 @@ 'full' ), 'html' => false, + 'background' => array( + 'backgroundImage' => true, + 'backgroundSize' => true, + 'gradient' => true + ), '__experimentalBorder' => array( 'color' => true, 'radius' => true, @@ -4332,10 +4463,15 @@ 'text' => true ) ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'spacing' => array( 'margin' => true, 'padding' => true ), + 'shadow' => true, 'typography' => array( 'fontSize' => true, 'lineHeight' => true, @@ -4349,11 +4485,19 @@ 'fontSize' => true ) ), + 'filter' => array( + 'duotone' => true + ), 'interactivity' => array( 'clientNavigation' => true ), 'allowedBlocks' => true ), + 'selectors' => array( + 'filter' => array( + 'duotone' => '.wp-block-media-text > .wp-block-media-text__media img, .wp-block-media-text > .wp-block-media-text__media video' + ) + ), 'editorStyle' => 'wp-block-media-text-editor', 'style' => 'wp-block-media-text' ), @@ -4989,6 +5133,10 @@ ) ), 'shadow' => true, + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'contentRole' => true ), 'editorStyle' => 'wp-block-page-list-editor', @@ -5104,6 +5252,7 @@ 'style' => true, 'width' => true ), + 'shadow' => true, 'color' => array( 'gradients' => true, 'link' => true, @@ -5499,6 +5648,7 @@ 'lineHeight' => true, 'textAlign' => true, 'textColumns' => true, + 'textIndent' => true, '__experimentalFontFamily' => true, '__experimentalFontWeight' => true, '__experimentalFontStyle' => true, @@ -5698,6 +5848,10 @@ 'text' => true ) ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'spacing' => array( 'margin' => true, 'padding' => true @@ -5706,6 +5860,7 @@ 'fontSize' => true, 'lineHeight' => true, 'textAlign' => true, + '__experimentalFontFamily' => true, '__experimentalFontStyle' => true, '__experimentalFontWeight' => true, '__experimentalLetterSpacing' => true, @@ -5844,7 +5999,8 @@ ) ), 'dimensions' => array( - 'minHeight' => true + 'minHeight' => true, + 'minWidth' => true ), 'shadow' => true, 'spacing' => array( @@ -6031,6 +6187,10 @@ 'margin' => true, 'padding' => true ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'typography' => array( 'fontSize' => true, 'lineHeight' => true, @@ -6151,6 +6311,7 @@ '__experimentalBorder' => array( 'color' => true, 'radius' => true, + 'style' => true, 'width' => true, '__experimentalSkipSerialization' => true, '__experimentalDefaultControls' => array( @@ -6419,6 +6580,10 @@ 'link' => true ) ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'shadow' => true, 'spacing' => array( 'margin' => true, @@ -6496,6 +6661,10 @@ 'text' => true ) ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'html' => false, 'shadow' => true, 'spacing' => array( @@ -6600,6 +6769,10 @@ 'link' => true ) ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'shadow' => true, 'spacing' => array( 'margin' => true, @@ -6669,6 +6842,10 @@ 'text' => true ) ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'shadow' => true, 'spacing' => array( 'padding' => true, @@ -6754,7 +6931,8 @@ ) ), 'dimensions' => array( - 'minHeight' => true + 'minHeight' => true, + 'minWidth' => true ), 'shadow' => true, 'spacing' => array( @@ -6913,6 +7091,10 @@ 'heading' => true, 'button' => true ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'spacing' => array( 'padding' => true, 'margin' => true, @@ -6998,6 +7180,11 @@ 'link' => true ) ), + 'spacing' => array( + 'padding' => true, + 'margin' => true, + 'blockGap' => true + ), 'layout' => array( 'allowSwitching' => false, 'allowInheriting' => false, @@ -7018,6 +7205,18 @@ 'fontSize' => true ) ), + '__experimentalBorder' => array( + 'color' => true, + 'radius' => true, + 'style' => true, + 'width' => true, + '__experimentalDefaultControls' => array( + 'color' => false, + 'radius' => false, + 'style' => false, + 'width' => false + ) + ), 'interactivity' => array( 'clientNavigation' => true ) @@ -7316,6 +7515,10 @@ 'margin' => true, 'padding' => true ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'color' => array( 'gradients' => true, '__experimentalDefaultControls' => array( @@ -7418,6 +7621,7 @@ ), 'dimensions' => array( 'minHeight' => true, + 'minWidth' => true, '__experimentalDefaultControls' => array( 'minHeight' => false ) @@ -7441,6 +7645,7 @@ 'gradients' => true, 'heading' => true, 'link' => true, + 'button' => true, '__experimentalDefaultControls' => array( 'background' => true, 'text' => true @@ -7521,6 +7726,10 @@ 'textDecoration' => true ) ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'spacing' => array( 'margin' => array( 'top', @@ -7534,6 +7743,7 @@ '__experimentalBorder' => array( 'color' => true, 'radius' => true, + 'style' => true, 'width' => true, '__experimentalDefaultControls' => array( 'width' => true @@ -7621,6 +7831,10 @@ 'margin' => false ) ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'shadow' => true, 'background' => array( 'backgroundImage' => true, @@ -7734,7 +7948,8 @@ ) ), 'spacing' => array( - 'margin' => true + 'margin' => true, + 'padding' => true ), 'html' => false ), @@ -7976,6 +8191,10 @@ ) ), 'contentRole' => true, + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'spacing' => array( 'margin' => true, 'padding' => true, @@ -8074,6 +8293,10 @@ 'link' => true ) ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'spacing' => array( 'padding' => true, 'margin' => true, @@ -8274,6 +8497,7 @@ 'style' => true ) ), + 'shadow' => true, 'contentRole' => true, 'listView' => true ), @@ -8408,10 +8632,14 @@ 'padding' => true, 'blockGap' => true ) + ), + 'shadow' => array( + '__experimentalSkipSerialization' => true ) ), 'selectors' => array( 'border' => '.wp-block-tab-list button', + 'shadow' => '.wp-block-tab-list button', 'color' => array( 'background' => '.wp-block-tab-list button', 'text' => '.wp-block-tab-list button' @@ -8541,6 +8769,9 @@ 'spacing' => array( 'padding' => true ), + 'dimensions' => array( + 'minHeight' => true + ), 'typography' => array( 'fontSize' => true, 'lineHeight' => true, @@ -8854,6 +9085,9 @@ 'margin' => true, 'padding' => true ), + 'dimensions' => array( + 'minWidth' => true + ), 'shadow' => true, 'typography' => array( 'fontSize' => true, @@ -9042,8 +9276,13 @@ ), 'shadow' => true, 'spacing' => array( + 'margin' => true, 'padding' => true ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'typography' => array( 'fontSize' => true, 'lineHeight' => true, @@ -9109,6 +9348,10 @@ 'text' => true ) ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'spacing' => array( 'padding' => true, 'margin' => true @@ -9198,9 +9441,14 @@ 'link' => true ) ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'shadow' => true, 'spacing' => array( - 'padding' => true + 'padding' => true, + 'margin' => true ), 'typography' => array( 'fontSize' => true, @@ -9285,6 +9533,10 @@ 'fontSize' => true ) ), + 'dimensions' => array( + 'minHeight' => true, + 'minWidth' => true + ), 'spacing' => array( 'margin' => true, 'padding' => true, @@ -9456,6 +9708,7 @@ ), 'dimensions' => array( 'minHeight' => true, + 'minWidth' => true, '__experimentalDefaultControls' => array( 'minHeight' => false ) @@ -9465,12 +9718,15 @@ '__experimentalFontFamily' => true, 'lineHeight' => true, 'textAlign' => true, + 'textColumns' => true, + 'textIndent' => true, '__experimentalFontStyle' => true, '__experimentalFontWeight' => true, '__experimentalLetterSpacing' => true, '__experimentalTextTransform' => true, '__experimentalTextDecoration' => true, '__experimentalWritingMode' => true, + 'fitText' => true, '__experimentalDefaultControls' => array( 'fontSize' => true ) @@ -9594,6 +9850,9 @@ 'supports' => array( 'anchor' => true, 'align' => true, + 'filter' => array( + 'duotone' => true + ), 'spacing' => array( 'margin' => true, 'padding' => true, @@ -9610,7 +9869,10 @@ ) ), 'selectors' => array( - 'shadow' => '.wp-block-video video' + 'shadow' => '.wp-block-video video', + 'filter' => array( + 'duotone' => '.wp-block-video video' + ) ), 'editorStyle' => 'wp-block-video-editor', 'style' => 'wp-block-video' diff --git a/src/wp-includes/blocks/breadcrumbs.php b/src/wp-includes/blocks/breadcrumbs.php index 02c038dd057ea..b659afd8259b1 100644 --- a/src/wp-includes/blocks/breadcrumbs.php +++ b/src/wp-includes/blocks/breadcrumbs.php @@ -188,7 +188,7 @@ function render_block_core_breadcrumbs( $attributes, $content, $block ) { $wrapper_attributes = get_block_wrapper_attributes( array( 'style' => '--separator: "' . $separator . '";', - 'aria-label' => _x( 'Breadcrumbs', 'area label' ), + 'aria-label' => _x( 'Breadcrumbs', 'aria label' ), ) ); diff --git a/src/wp-includes/blocks/button.php b/src/wp-includes/blocks/button.php index 7b67ad158aed1..fd117e9436a57 100644 --- a/src/wp-includes/blocks/button.php +++ b/src/wp-includes/blocks/button.php @@ -60,6 +60,53 @@ function render_block_core_button( $attributes, $content ) { return ''; } + // Background skips serialization, so apply it to the link like color. + $background = $attributes['style']['background'] ?? null; + + if ( is_array( $background ) ) { + $background_styles = array( + 'backgroundImage' => $background['backgroundImage'] ?? null, + 'backgroundSize' => $background['backgroundSize'] ?? null, + 'backgroundPosition' => $background['backgroundPosition'] ?? null, + 'backgroundRepeat' => $background['backgroundRepeat'] ?? null, + 'backgroundAttachment' => $background['backgroundAttachment'] ?? null, + 'gradient' => $background['gradient'] ?? null, + ); + + // Mirror the background block support defaults. + if ( ! empty( $background_styles['backgroundImage'] ) ) { + $background_styles['backgroundSize'] = $background_styles['backgroundSize'] ?? 'cover'; + if ( 'contain' === $background_styles['backgroundSize'] && ! $background_styles['backgroundPosition'] ) { + $background_styles['backgroundPosition'] = '50% 50%'; + } + } + + $styles = wp_style_engine_get_styles( array( 'background' => $background_styles ) ); + + if ( ! empty( $styles['css'] ) ) { + $processor = new WP_HTML_Tag_Processor( $content ); + while ( $processor->next_tag() ) { + if ( $tag !== $processor->get_tag() ) { + continue; + } + + $existing_style = $processor->get_attribute( 'style' ); + if ( is_string( $existing_style ) && '' !== $existing_style ) { + $separator = str_ends_with( $existing_style, ';' ) ? '' : ';'; + $processor->set_attribute( 'style', $existing_style . $separator . $styles['css'] ); + } else { + $processor->set_attribute( 'style', $styles['css'] ); + } + + if ( ! empty( $background_styles['backgroundImage'] ) || ! empty( $background_styles['gradient'] ) ) { + $processor->add_class( 'has-background' ); + } + break; + } + $content = $processor->get_updated_html(); + } + } + $width = $attributes['style']['dimensions']['width'] ?? null; if ( is_string( $width ) && '' !== $width ) { diff --git a/src/wp-includes/blocks/button/block.json b/src/wp-includes/blocks/button/block.json index 2e23a64c8f559..29e3c1f22c50f 100644 --- a/src/wp-includes/blocks/button/block.json +++ b/src/wp-includes/blocks/button/block.json @@ -70,6 +70,12 @@ "splitting": true, "align": false, "alignWide": false, + "background": { + "backgroundImage": true, + "backgroundSize": true, + "gradient": true, + "__experimentalSkipSerialization": true + }, "color": { "__experimentalSkipSerialization": true, "gradients": true, diff --git a/src/wp-includes/blocks/buttons/block.json b/src/wp-includes/blocks/buttons/block.json index 4927a9644837b..03092ff3dc10a 100644 --- a/src/wp-includes/blocks/buttons/block.json +++ b/src/wp-includes/blocks/buttons/block.json @@ -50,6 +50,10 @@ "fontSize": true } }, + "dimensions": { + "minHeight": true, + "minWidth": true + }, "__experimentalBorder": { "color": true, "radius": true, @@ -73,7 +77,8 @@ "clientNavigation": true }, "listView": true, - "contentRole": true + "contentRole": true, + "shadow": true }, "editorStyle": "wp-block-buttons-editor", "style": "wp-block-buttons" diff --git a/src/wp-includes/blocks/code/block.json b/src/wp-includes/blocks/code/block.json index 028a64620cac3..4fad135a9706d 100644 --- a/src/wp-includes/blocks/code/block.json +++ b/src/wp-includes/blocks/code/block.json @@ -27,6 +27,10 @@ "gradient": true } }, + "dimensions": { + "minHeight": true, + "minWidth": true + }, "typography": { "fontSize": true, "lineHeight": true, diff --git a/src/wp-includes/blocks/columns/block.json b/src/wp-includes/blocks/columns/block.json index dcd1193ca093e..7f742a87931a1 100644 --- a/src/wp-includes/blocks/columns/block.json +++ b/src/wp-includes/blocks/columns/block.json @@ -43,6 +43,10 @@ "gradient": true } }, + "dimensions": { + "minHeight": true, + "minWidth": true + }, "spacing": { "blockGap": { "__experimentalDefault": "2em", diff --git a/src/wp-includes/blocks/comments-pagination/block.json b/src/wp-includes/blocks/comments-pagination/block.json index a2b7d9fe0b170..867a29736413d 100644 --- a/src/wp-includes/blocks/comments-pagination/block.json +++ b/src/wp-includes/blocks/comments-pagination/block.json @@ -50,6 +50,11 @@ "type": "flex" } }, + "spacing": { + "padding": true, + "margin": true, + "blockGap": true + }, "typography": { "fontSize": true, "lineHeight": true, @@ -63,6 +68,12 @@ "fontSize": true } }, + "__experimentalBorder": { + "color": true, + "radius": true, + "style": true, + "width": true + }, "interactivity": { "clientNavigation": true } diff --git a/src/wp-includes/blocks/cover.php b/src/wp-includes/blocks/cover.php index 8bd1c3f5cd38f..1241ece24c917 100644 --- a/src/wp-includes/blocks/cover.php +++ b/src/wp-includes/blocks/cover.php @@ -26,6 +26,10 @@ function render_block_core_cover( $attributes, $content ) { ) { $url = $attributes['url']; + // The view script decides whether the embed may autoplay, so it is only + // needed for embed backgrounds. + wp_enqueue_script_module( '@wordpress/block-library/cover/view' ); + // Use WordPress's native oEmbed processing (includes caching). $oembed_html = wp_oembed_get( $url ); @@ -50,7 +54,8 @@ function render_block_core_cover( $attributes, $content ) { } // Modify iframe src to add background video parameters based on provider. - $parsed_url = wp_parse_url( $iframe_src ); + $parsed_url = wp_parse_url( $iframe_src ); + $reduced_motion_src = null; if ( $parsed_url && isset( $parsed_url['host'] ) ) { // Parse existing query parameters. $query_params = array(); @@ -58,9 +63,12 @@ function render_block_core_cover( $attributes, $content ) { parse_str( $parsed_url['query'], $query_params ); } - // Add background video parameters based on provider. + // Add background video parameters based on provider. The + // autoplay parameters are kept separate so a source without + // them can also be built, which the view script swaps in for + // a visitor who has asked for reduced motion. + $autoplay_params = array(); if ( 'youtube' === $provider ) { - $query_params['autoplay'] = '1'; $query_params['mute'] = '1'; $query_params['loop'] = '1'; $query_params['controls'] = '0'; @@ -74,32 +82,53 @@ function render_block_core_cover( $attributes, $content ) { if ( $video_id ) { $query_params['playlist'] = $video_id; } + + $autoplay_params['autoplay'] = '1'; } elseif ( 'vimeo' === $provider ) { - $query_params['autoplay'] = '1'; $query_params['muted'] = '1'; $query_params['loop'] = '1'; - $query_params['background'] = '1'; $query_params['controls'] = '0'; $query_params['transparent'] = '0'; + + // Vimeo's background mode always autoplays, so it can only + // be used when autoplay is allowed. + $autoplay_params['autoplay'] = '1'; + $autoplay_params['background'] = '1'; } elseif ( 'videopress' === $provider || 'wordpress-tv' === $provider ) { - $query_params['autoplay'] = '1'; - $query_params['loop'] = '1'; - $query_params['muted'] = '1'; + $query_params['loop'] = '1'; + $query_params['muted'] = '1'; + + $autoplay_params['autoplay'] = '1'; } // Rebuild the URL with new parameters. - $iframe_src = $parsed_url['scheme'] . '://' . $parsed_url['host']; + $iframe_base = $parsed_url['scheme'] . '://' . $parsed_url['host']; if ( isset( $parsed_url['path'] ) ) { - $iframe_src .= $parsed_url['path']; - } - if ( ! empty( $query_params ) ) { - $iframe_src .= '?' . http_build_query( $query_params ); + $iframe_base .= $parsed_url['path']; } + + $reduced_motion_src = empty( $query_params ) + ? $iframe_base + : $iframe_base . '?' . http_build_query( $query_params ); + + $iframe_src = empty( $autoplay_params ) + ? $reduced_motion_src + : $iframe_base . '?' . http_build_query( array_merge( $query_params, $autoplay_params ) ); } - // Build the iframe HTML that will replace the figure. + // Build the iframe HTML that will replace the figure. The server + // renders the autoplaying source, and the view script swaps in the + // one without autoplay for a visitor who prefers reduced motion. $iframe_html = sprintf( - '
', + '
', + esc_attr( + wp_json_encode( + array( + 'src' => $iframe_src, + 'reducedMotionSrc' => $reduced_motion_src, + ) + ) + ), esc_url( $iframe_src ) ); diff --git a/src/wp-includes/blocks/cover/block.json b/src/wp-includes/blocks/cover/block.json index 1d95f80402e61..8f2f864555eb7 100644 --- a/src/wp-includes/blocks/cover/block.json +++ b/src/wp-includes/blocks/cover/block.json @@ -153,7 +153,8 @@ "allowJustification": false }, "interactivity": { - "clientNavigation": true + "clientNavigation": true, + "interactive": true }, "filter": { "duotone": true diff --git a/src/wp-includes/blocks/details/block.json b/src/wp-includes/blocks/details/block.json index f5a2a1a6c3edc..ef2ad1428c39c 100644 --- a/src/wp-includes/blocks/details/block.json +++ b/src/wp-includes/blocks/details/block.json @@ -67,6 +67,9 @@ "padding": false } }, + "dimensions": { + "minWidth": true + }, "typography": { "fontSize": true, "lineHeight": true, diff --git a/src/wp-includes/blocks/embed/block.json b/src/wp-includes/blocks/embed/block.json index d6f7c501d6507..41db597f29949 100644 --- a/src/wp-includes/blocks/embed/block.json +++ b/src/wp-includes/blocks/embed/block.json @@ -43,8 +43,13 @@ "supports": { "anchor": true, "align": true, + "dimensions": { + "minHeight": true, + "minWidth": true + }, "spacing": { - "margin": true + "margin": true, + "padding": true }, "interactivity": { "clientNavigation": true diff --git a/src/wp-includes/blocks/file/block.json b/src/wp-includes/blocks/file/block.json index 24eeba2b2c386..3d8da956428be 100644 --- a/src/wp-includes/blocks/file/block.json +++ b/src/wp-includes/blocks/file/block.json @@ -78,6 +78,10 @@ "margin": true, "padding": true }, + "dimensions": { + "minHeight": true, + "minWidth": true + }, "color": { "gradients": true, "link": true, @@ -99,6 +103,7 @@ "style": true } }, + "shadow": true, "interactivity": true }, "editorStyle": "wp-block-file-editor", diff --git a/src/wp-includes/blocks/footnotes/block.json b/src/wp-includes/blocks/footnotes/block.json index 393f7f702ab99..07fb9171aa243 100644 --- a/src/wp-includes/blocks/footnotes/block.json +++ b/src/wp-includes/blocks/footnotes/block.json @@ -53,6 +53,10 @@ "padding": false } }, + "dimensions": { + "minHeight": true, + "minWidth": true + }, "typography": { "fontSize": true, "lineHeight": true, diff --git a/src/wp-includes/blocks/gallery/block.json b/src/wp-includes/blocks/gallery/block.json index 44158bb0fd0ad..a18adb2573b8c 100644 --- a/src/wp-includes/blocks/gallery/block.json +++ b/src/wp-includes/blocks/gallery/block.json @@ -166,6 +166,11 @@ "background": true, "gradients": true }, + "shadow": true, + "dimensions": { + "minHeight": true, + "minWidth": true + }, "layout": { "allowSwitching": false, "allowInheriting": false, @@ -179,11 +184,19 @@ "type": "flex" } }, + "filter": { + "duotone": true + }, "interactivity": { "clientNavigation": true }, "listView": true }, + "selectors": { + "filter": { + "duotone": ".wp-block-gallery :where(img)" + } + }, "editorStyle": "wp-block-gallery-editor", "style": "wp-block-gallery" } diff --git a/src/wp-includes/blocks/heading/block.json b/src/wp-includes/blocks/heading/block.json index 4498f79781735..0f4a9476b19a9 100644 --- a/src/wp-includes/blocks/heading/block.json +++ b/src/wp-includes/blocks/heading/block.json @@ -53,6 +53,10 @@ "text": true } }, + "dimensions": { + "minHeight": true, + "minWidth": true + }, "shadow": true, "spacing": { "margin": true, @@ -66,6 +70,7 @@ "fontSize": true, "lineHeight": true, "textAlign": true, + "textIndent": true, "__experimentalFontFamily": true, "__experimentalFontStyle": true, "__experimentalFontWeight": true, diff --git a/src/wp-includes/blocks/home-link/block.json b/src/wp-includes/blocks/home-link/block.json index 036e967883164..733a3afdd8e0d 100644 --- a/src/wp-includes/blocks/home-link/block.json +++ b/src/wp-includes/blocks/home-link/block.json @@ -52,6 +52,10 @@ } }, "shadow": true, + "dimensions": { + "minHeight": true, + "minWidth": true + }, "__experimentalBorder": { "color": true, "radius": true, @@ -64,6 +68,14 @@ "width": false } }, + "spacing": { + "margin": true, + "padding": true, + "__experimentalDefaultControls": { + "margin": false, + "padding": false + } + }, "interactivity": { "clientNavigation": true } diff --git a/src/wp-includes/blocks/icon.php b/src/wp-includes/blocks/icon.php index 1b615c8a6dc96..e158333bc4da5 100644 --- a/src/wp-includes/blocks/icon.php +++ b/src/wp-includes/blocks/icon.php @@ -15,7 +15,7 @@ * @return string Returns the Icon. */ function render_block_core_icon( $attributes ) { - if ( empty( $attributes['icon'] ) ) { + if ( empty( $attributes['icon'] ) || ! is_string( $attributes['icon'] ) ) { return; } diff --git a/src/wp-includes/blocks/image.php b/src/wp-includes/blocks/image.php index aef905ef59a64..43f8e8c26c468 100644 --- a/src/wp-includes/blocks/image.php +++ b/src/wp-includes/blocks/image.php @@ -369,13 +369,12 @@ class="wp-lightbox-overlay zoom" data-wp-on--touchstart="actions.handleTouchStart" data-wp-on--touchmove="actions.handleTouchMove" data-wp-on--touchend="actions.handleTouchEnd" - data-wp-on--click="actions.hideLightbox" data-wp-on-window--resize="callbacks.setOverlayStyles" data-wp-on-window--scroll="actions.handleScroll" data-wp-bind--style="state.overlayStyles" tabindex="-1" > - @@ -383,7 +382,7 @@ class="wp-lightbox-overlay zoom" {$prev_button_icon} {$prev_button_text} -