diff --git a/src/wp-admin/admin-header.php b/src/wp-admin/admin-header.php index fc836c20a2c1d..53e3c06cfdf70 100644 --- a/src/wp-admin/admin-header.php +++ b/src/wp-admin/admin-header.php @@ -14,7 +14,7 @@ /** * In case admin-header.php is included in a function. * - * @global string $title + * @global string $title The title of the current screen. * @global string $hook_suffix * @global WP_Screen $current_screen WordPress current screen object. * @global WP_Locale $wp_locale WordPress date and time locale object. diff --git a/src/wp-admin/edit-form-advanced.php b/src/wp-admin/edit-form-advanced.php index ce68a4097ba26..91780372678d9 100644 --- a/src/wp-admin/edit-form-advanced.php +++ b/src/wp-admin/edit-form-advanced.php @@ -12,8 +12,8 @@ } /** - * @global string $post_type - * @global WP_Post_Type $post_type_object + * @global string $post_type Global post type. + * @global WP_Post_Type $post_type_object Global post type object. * @global WP_Post $post Global post object. */ global $post_type, $post_type_object, $post; diff --git a/src/wp-admin/edit-form-blocks.php b/src/wp-admin/edit-form-blocks.php index 93dea2eb917f4..dd66aeea90673 100644 --- a/src/wp-admin/edit-form-blocks.php +++ b/src/wp-admin/edit-form-blocks.php @@ -14,11 +14,11 @@ } /** - * @global string $post_type - * @global WP_Post_Type $post_type_object + * @global string $post_type Global post type. + * @global WP_Post_Type $post_type_object Global post type object. * @global WP_Post $post Global post object. - * @global string $title - * @global array $wp_meta_boxes + * @global string $title The title of the current screen. + * @global array $wp_meta_boxes Global meta box state. */ global $post_type, $post_type_object, $post, $title, $wp_meta_boxes; diff --git a/src/wp-admin/edit-tags.php b/src/wp-admin/edit-tags.php index 947db5ffc5f85..db2a13fe82f6f 100644 --- a/src/wp-admin/edit-tags.php +++ b/src/wp-admin/edit-tags.php @@ -32,9 +32,9 @@ } /** - * $post_type is set when the WP_Terms_List_Table instance is created + * $post_type is set when the WP_Terms_List_Table instance is created. * - * @global string $post_type + * @global string $post_type Global post type. */ global $post_type; diff --git a/src/wp-admin/edit.php b/src/wp-admin/edit.php index 6e4a05eabcc18..93bcef797f9ae 100644 --- a/src/wp-admin/edit.php +++ b/src/wp-admin/edit.php @@ -29,8 +29,8 @@ } /** - * @global string $post_type - * @global WP_Post_Type $post_type_object + * @global string $post_type Global post type. + * @global WP_Post_Type $post_type_object Global post type object. */ global $post_type, $post_type_object; diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index 985497641dc17..62feaffc6d077 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -192,7 +192,7 @@ function wp_ajax_wp_compression_test() { if ( is_multisite() ) { update_site_option( 'can_compress_scripts', 0 ); } else { - update_option( 'can_compress_scripts', 0, 'on' ); + update_option( 'can_compress_scripts', 0, true ); } wp_die( 0 ); } @@ -231,7 +231,7 @@ function wp_ajax_wp_compression_test() { if ( is_multisite() ) { update_site_option( 'can_compress_scripts', 0 ); } else { - update_option( 'can_compress_scripts', 0, 'on' ); + update_option( 'can_compress_scripts', 0, true ); } } elseif ( 'yes' === $_GET['test'] ) { check_ajax_referer( 'update_can_compress_scripts' ); @@ -239,7 +239,7 @@ function wp_ajax_wp_compression_test() { if ( is_multisite() ) { update_site_option( 'can_compress_scripts', 1 ); } else { - update_option( 'can_compress_scripts', 1, 'on' ); + update_option( 'can_compress_scripts', 1, true ); } } } diff --git a/src/wp-admin/includes/class-wp-posts-list-table.php b/src/wp-admin/includes/class-wp-posts-list-table.php index baf3ef6c6f347..826be9b67dc09 100644 --- a/src/wp-admin/includes/class-wp-posts-list-table.php +++ b/src/wp-admin/includes/class-wp-posts-list-table.php @@ -65,7 +65,7 @@ class WP_Posts_List_Table extends WP_List_Table { * * @see WP_List_Table::__construct() for more information on default arguments. * - * @global WP_Post_Type $post_type_object + * @global WP_Post_Type $post_type_object Global post type object. * @global wpdb $wpdb WordPress database abstraction object. * * @param array $args An associative array of arguments. diff --git a/src/wp-admin/includes/class-wp-screen.php b/src/wp-admin/includes/class-wp-screen.php index 67bceef060661..4bb5995e7f3d8 100644 --- a/src/wp-admin/includes/class-wp-screen.php +++ b/src/wp-admin/includes/class-wp-screen.php @@ -984,7 +984,7 @@ public function render_screen_meta() { } /** - * @global array $wp_meta_boxes + * @global array $wp_meta_boxes Global meta box state. * * @return bool */ @@ -1103,7 +1103,7 @@ public function render_screen_options( $options = array() ) { * * @since 4.4.0 * - * @global array $wp_meta_boxes + * @global array $wp_meta_boxes Global meta box state. */ public function render_meta_boxes_preferences() { global $wp_meta_boxes; diff --git a/src/wp-admin/includes/class-wp-terms-list-table.php b/src/wp-admin/includes/class-wp-terms-list-table.php index b3d9ec59e781b..c7f34631a9b42 100644 --- a/src/wp-admin/includes/class-wp-terms-list-table.php +++ b/src/wp-admin/includes/class-wp-terms-list-table.php @@ -27,8 +27,8 @@ class WP_Terms_List_Table extends WP_List_Table { * * @see WP_List_Table::__construct() for more information on default arguments. * - * @global string $post_type - * @global string $taxonomy + * @global string $post_type Global post type. + * @global string $taxonomy Global taxonomy. * @global string $action * @global object $tax * @@ -330,7 +330,8 @@ private function _rows( $taxonomy, $terms, &$children, $start, $per_page, &$coun } /** - * @global string $taxonomy + * @global string $taxonomy Global taxonomy. + * * @param WP_Term $tag Term object. * @param int $level */ diff --git a/src/wp-admin/includes/nav-menu.php b/src/wp-admin/includes/nav-menu.php index 8f18057c238f5..aa72117e68e9f 100644 --- a/src/wp-admin/includes/nav-menu.php +++ b/src/wp-admin/includes/nav-menu.php @@ -204,7 +204,7 @@ function wp_nav_menu_setup() { * * @since 3.0.0 * - * @global array $wp_meta_boxes + * @global array $wp_meta_boxes Global meta box state. */ function wp_initial_nav_menu_meta_boxes() { global $wp_meta_boxes; diff --git a/src/wp-admin/includes/plugin.php b/src/wp-admin/includes/plugin.php index f882b9b61ffc1..5b63855446a18 100644 --- a/src/wp-admin/includes/plugin.php +++ b/src/wp-admin/includes/plugin.php @@ -2030,7 +2030,7 @@ function get_admin_page_parent( $parent_page = '' ) { * * @since 1.5.0 * - * @global string $title + * @global string $title The title of the current screen. * @global array $menu * @global array $submenu * @global string $pagenow The filename of the current screen. diff --git a/src/wp-admin/includes/post.php b/src/wp-admin/includes/post.php index 0776b4234f41b..21020649c1a1d 100644 --- a/src/wp-admin/includes/post.php +++ b/src/wp-admin/includes/post.php @@ -2345,7 +2345,7 @@ function get_block_editor_server_block_settings() { * * @global WP_Post $post Global post object. * @global WP_Screen $current_screen WordPress current screen object. - * @global array $wp_meta_boxes + * @global array $wp_meta_boxes Global meta box state. */ function the_block_editor_meta_boxes() { global $post, $current_screen, $wp_meta_boxes; diff --git a/src/wp-admin/includes/screen.php b/src/wp-admin/includes/screen.php index bf5aefcca01ae..a3a41a655408a 100644 --- a/src/wp-admin/includes/screen.php +++ b/src/wp-admin/includes/screen.php @@ -89,7 +89,7 @@ function get_hidden_columns( $screen ) { * * @since 2.7.0 * - * @global array $wp_meta_boxes + * @global array $wp_meta_boxes Global meta box state. * * @param WP_Screen $screen */ diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php index 90b375e882a3f..f78acff4285e6 100644 --- a/src/wp-admin/includes/template.php +++ b/src/wp-admin/includes/template.php @@ -1050,7 +1050,7 @@ function wp_import_upload_form( $action ) { * @since 2.5.0 * @since 4.4.0 The `$screen` parameter now accepts an array of screen IDs. * - * @global array $wp_meta_boxes + * @global array $wp_meta_boxes Global meta box state. * * @param string $id Meta box ID (used in the 'id' attribute for the meta box). * @param string $title Title of the meta box. @@ -1287,7 +1287,7 @@ function _get_plugin_from_callback( $callback ) { * * @since 2.5.0 * - * @global array $wp_meta_boxes + * @global array $wp_meta_boxes Global meta box state. * * @param string|WP_Screen $screen The screen identifier. If you have used add_menu_page() or * add_submenu_page() to create a new screen (and hence screen_id) @@ -1472,7 +1472,7 @@ function do_meta_boxes( $screen, $context, $data_object ) { * @since 2.6.0 * @since 4.4.0 The `$screen` parameter now accepts an array of screen IDs. * - * @global array $wp_meta_boxes + * @global array $wp_meta_boxes Global meta box state. * * @param string $id Meta box ID (used in the 'id' attribute for the meta box). * @param string|array|WP_Screen $screen The screen or screens on which the meta box is shown (such as a diff --git a/src/wp-admin/post-new.php b/src/wp-admin/post-new.php index 521ef9ef7cd14..5bf9e7cb1fd59 100644 --- a/src/wp-admin/post-new.php +++ b/src/wp-admin/post-new.php @@ -10,9 +10,9 @@ require_once __DIR__ . '/admin.php'; /** - * @global string $post_type - * @global object $post_type_object - * @global WP_Post $post Global post object. + * @global string $post_type Global post type. + * @global WP_Post_Type $post_type_object Global post type object. + * @global WP_Post $post Global post object. */ global $post_type, $post_type_object, $post; diff --git a/src/wp-admin/post.php b/src/wp-admin/post.php index 1230dda23da77..1b8214c9ce563 100644 --- a/src/wp-admin/post.php +++ b/src/wp-admin/post.php @@ -28,9 +28,9 @@ $post_ID = $post_id; /** - * @global string $post_type - * @global object $post_type_object - * @global WP_Post $post Global post object. + * @global string $post_type Global post type. + * @global WP_Post_Type $post_type_object Global post type object. + * @global WP_Post $post Global post object. */ global $post_type, $post_type_object, $post; diff --git a/src/wp-includes/block-supports/block-style-variations.php b/src/wp-includes/block-supports/block-style-variations.php index a44ecdd396e18..8e84292ac0eb4 100644 --- a/src/wp-includes/block-supports/block-style-variations.php +++ b/src/wp-includes/block-supports/block-style-variations.php @@ -249,7 +249,7 @@ function wp_resolve_block_style_variations( $variations ) { * Block style variations read in via standalone theme.json partials * need to have their name set to the kebab case version of their title. */ - $variation_name = $have_named_variations ? $key : _wp_to_kebab_case( $variation['title'] ); + $variation_name = $have_named_variations ? $key : ( $variation['slug'] ?? _wp_to_kebab_case( $variation['title'] ) ); foreach ( $supported_blocks as $block_type ) { // Add block style variation data under current block type. @@ -441,7 +441,7 @@ function wp_register_block_style_variations_from_theme_json_data( $variations ) * Block style variations read in via standalone theme.json partials * need to have their name set to the kebab case version of their title. */ - $variation_name = $have_named_variations ? $key : _wp_to_kebab_case( $variation['title'] ); + $variation_name = $have_named_variations ? $key : ( $variation['slug'] ?? _wp_to_kebab_case( $variation['title'] ) ); $variation_label = $variation['title'] ?? $variation_name; foreach ( $supported_blocks as $block_type ) { diff --git a/src/wp-includes/class-wp-duotone.php b/src/wp-includes/class-wp-duotone.php index 0260cab4f3bd6..a22745d8950dd 100644 --- a/src/wp-includes/class-wp-duotone.php +++ b/src/wp-includes/class-wp-duotone.php @@ -215,7 +215,7 @@ private static function colord_parse_hue( $value, $unit = 'deg' ) { } /** - * Parses any valid Hex3, Hex4, Hex6 or Hex8 string and converts it to an RGBA object + * Parses any valid Hex3, Hex4, Hex6 or Hex8 string and converts it to an RGBA object. * * Direct port of colord's parseHex function. * @@ -286,7 +286,7 @@ private static function colord_clamp_rgba( $rgba ) { } /** - * Parses a valid RGB[A] CSS color function/string + * Parses a valid RGB[A] CSS color function/string. * * Direct port of colord's parseRgbaString function. * diff --git a/src/wp-includes/class-wp-theme-json.php b/src/wp-includes/class-wp-theme-json.php index 957434de7fba6..05f5e7b9e7629 100644 --- a/src/wp-includes/class-wp-theme-json.php +++ b/src/wp-includes/class-wp-theme-json.php @@ -358,6 +358,7 @@ class WP_Theme_JSON { 'description', 'patterns', 'settings', + 'slug', 'styles', 'templateParts', 'title', @@ -3244,7 +3245,7 @@ protected static function filter_slugs( $node, $slugs ) { * @since 6.3.2 Preserves global styles block variations when securing styles. * @since 6.6.0 Updated to allow variation element styles and $origin parameter. * - * @param array $theme_json Structure to sanitize. + * @param array $theme_json Structure to sanitize. * @param string $origin Optional. What source of data this object represents. * One of 'blocks', 'default', 'theme', or 'custom'. Default 'theme'. * @return array Sanitized structure. diff --git a/src/wp-includes/kses.php b/src/wp-includes/kses.php index 5a1ae2de84a4a..a9e8bbdd3ec5f 100644 --- a/src/wp-includes/kses.php +++ b/src/wp-includes/kses.php @@ -963,6 +963,7 @@ function wp_kses_version() { * It also matches stray `>` characters. * * @since 1.0.0 + * @since 6.6.0 Recognize additional forms of invalid HTML which convert into comments. * * @global array[]|string $pass_allowed_html An array of allowed HTML elements and attributes, * or a context name such as 'post'. @@ -981,7 +982,18 @@ function wp_kses_split( $content, $allowed_html, $allowed_protocols ) { $pass_allowed_html = $allowed_html; $pass_allowed_protocols = $allowed_protocols; - return preg_replace_callback( '%(|$))|(<[^>]*(>|$)|>)%', '_wp_kses_split_callback', $content ); + $token_pattern = <<|$)) # - Normative HTML comments. + | + ]*> # - Closing tags with invalid tag names. + ) + | + (<[^>]*(>|$)|>) # Tag-like spans of text. +~x +REGEX; + return preg_replace_callback( $token_pattern, '_wp_kses_split_callback', $content ); } /** @@ -1069,23 +1081,61 @@ function _wp_kses_split_callback( $matches ) { * @access private * @ignore * @since 1.0.0 + * @since 6.6.0 Recognize additional forms of invalid HTML which convert into comments. * * @param string $content Content to filter. * @param array[]|string $allowed_html An array of allowed HTML elements and attributes, * or a context name such as 'post'. See wp_kses_allowed_html() * for the list of accepted context names. * @param string[] $allowed_protocols Array of allowed URL protocols. + * * @return string Fixed HTML element */ function wp_kses_split2( $content, $allowed_html, $allowed_protocols ) { $content = wp_kses_stripslashes( $content ); - // It matched a ">" character. + /* + * The regex pattern used to split HTML into chunks attempts + * to split on HTML token boundaries. This function should + * thus receive chunks that _either_ start with meaningful + * syntax tokens, like a tag `
` or a comment ``. + * + * If the first character of the `$content` chunk _isn't_ one + * of these syntax elements, which always starts with `<`, then + * the match had to be for the final alternation of `>`. In such + * case, it's probably standing on its own and could be encoded + * with a character reference to remove ambiguity. + * + * In other words, if this chunk isn't from a match of a syntax + * token, it's just a plaintext greater-than (`>`) sign. + */ if ( ! str_starts_with( $content, '<' ) ) { return '>'; } - // Allow HTML comments. + /* + * When a closing tag appears with a name that isn't a valid tag name, + * it must be interpreted as an HTML comment. It extends until the + * first `>` character after the initial opening `]*>$~', $content ) ) { + $content = substr( $content, 2, -1 ); + $transformed = null; + + while ( $transformed !== $content ) { + $transformed = wp_kses( $content, $allowed_html, $allowed_protocols ); + $content = $transformed; + } + + return ""; + } + + /* + * Normative HTML comments should be handled separately as their + * parsing rules differ from those for tags and text nodes. + */ if ( str_starts_with( $content, '' ), '', $content ); diff --git a/src/wp-includes/option.php b/src/wp-includes/option.php index c454e1119d85d..4dee6ce1188e9 100644 --- a/src/wp-includes/option.php +++ b/src/wp-includes/option.php @@ -1514,10 +1514,10 @@ function set_transient( $transient, $value, $expiration = 0 ) { wp_prime_option_caches( array( $transient_option, $transient_timeout ) ); if ( false === get_option( $transient_option ) ) { - $autoload = 'on'; + $autoload = true; if ( $expiration ) { - $autoload = 'off'; - add_option( $transient_timeout, time() + $expiration, '', 'off' ); + $autoload = false; + add_option( $transient_timeout, time() + $expiration, '', false ); } $result = add_option( $transient_option, $value, '', $autoload ); } else { @@ -1530,8 +1530,8 @@ function set_transient( $transient, $value, $expiration = 0 ) { if ( $expiration ) { if ( false === get_option( $transient_timeout ) ) { delete_option( $transient_option ); - add_option( $transient_timeout, time() + $expiration, '', 'off' ); - $result = add_option( $transient_option, $value, '', 'off' ); + add_option( $transient_timeout, time() + $expiration, '', false ); + $result = add_option( $transient_option, $value, '', false ); $update = false; } else { update_option( $transient_timeout, time() + $expiration ); @@ -2119,7 +2119,7 @@ function add_network_option( $network_id, $option, $value ) { $notoptions_key = "$network_id:notoptions"; if ( ! is_multisite() ) { - $result = add_option( $option, $value, '', 'off' ); + $result = add_option( $option, $value, '', false ); } else { $cache_key = "$network_id:$option"; @@ -2365,7 +2365,7 @@ function update_network_option( $network_id, $option, $value ) { } if ( ! is_multisite() ) { - $result = update_option( $option, $value, 'off' ); + $result = update_option( $option, $value, false ); } else { $value = sanitize_option( $option, $value ); diff --git a/src/wp-includes/theme-i18n.json b/src/wp-includes/theme-i18n.json index 7ce52317ed65d..8bda329add4ce 100644 --- a/src/wp-includes/theme-i18n.json +++ b/src/wp-includes/theme-i18n.json @@ -80,6 +80,15 @@ } } }, + "styles": { + "blocks": { + "variations": { + "*": { + "title": "Style variation name" + } + } + } + }, "customTemplates": [ { "title": "Custom template name" diff --git a/tests/phpunit/data/themedir1/block-theme/styles/block-style-variation-with-slug.json b/tests/phpunit/data/themedir1/block-theme/styles/block-style-variation-with-slug.json new file mode 100644 index 0000000000000..d938a8a0db833 --- /dev/null +++ b/tests/phpunit/data/themedir1/block-theme/styles/block-style-variation-with-slug.json @@ -0,0 +1,12 @@ +{ + "version": 3, + "blockTypes": [ "core/group", "core/columns" ], + "slug": "WithSlug", + "title": "With Slug", + "styles": { + "color": { + "background": "aliceblue", + "text": "midnightblue" + } + } +} diff --git a/tests/phpunit/tests/block-supports/block-style-variations.php b/tests/phpunit/tests/block-supports/block-style-variations.php index 3adbaa407532e..6b50b87fa2abc 100644 --- a/tests/phpunit/tests/block-supports/block-style-variations.php +++ b/tests/phpunit/tests/block-supports/block-style-variations.php @@ -61,6 +61,7 @@ public function filter_set_theme_root() { * variation file within `/styles`, are added to the theme data. * * @ticket 61312 + * @ticket 61440 */ public function test_add_registered_block_styles_to_theme_data() { switch_theme( 'block-theme' ); @@ -98,6 +99,22 @@ public function test_add_registered_block_styles_to_theme_data() { ), ); + /* + * This style is to be deliberately overwritten by the theme.json partial + * See `tests/phpunit/data/themedir1/block-theme/styles/block-style-variation-with-slug.json`. + */ + register_block_style( + 'core/group', + array( + 'name' => 'WithSlug', + 'style_data' => array( + 'color' => array( + 'background' => 'whitesmoke', + 'text' => 'black', + ), + ), + ) + ); register_block_style( 'core/group', array( @@ -110,6 +127,13 @@ public function test_add_registered_block_styles_to_theme_data() { $group_styles = $theme_json['styles']['blocks']['core/group'] ?? array(); $expected = array( 'variations' => array( + // @ticket 61440 + 'WithSlug' => array( + 'color' => array( + 'background' => 'aliceblue', + 'text' => 'midnightblue', + ), + ), 'my-variation' => $variation_styles_data, /* @@ -133,7 +157,8 @@ public function test_add_registered_block_styles_to_theme_data() { ); unregister_block_style( 'core/group', 'my-variation' ); + unregister_block_style( 'core/group', 'WithSlug' ); - $this->assertSameSetsWithIndex( $group_styles, $expected ); + $this->assertSameSetsWithIndex( $expected, $group_styles ); } } diff --git a/tests/phpunit/tests/kses.php b/tests/phpunit/tests/kses.php index d0bacba8ee3a9..36bf2baf123d3 100644 --- a/tests/phpunit/tests/kses.php +++ b/tests/phpunit/tests/kses.php @@ -1931,6 +1931,35 @@ public function filter_wp_kses_object_added_in_html_filter( $tags, $context ) { return $tags; } + /** + * Ensures that `wp_kses()` preserves various kinds of HTML comments, both valid and invalid. + * + * @ticket 61009 + * + * @param string $html_comment HTML containing a comment; must not be a valid comment + * but must be syntax which a browser interprets as a comment. + * @param string $expected_output How `wp_kses()` ought to transform the comment. + */ + public function wp_kses_preserves_html_comments( $html_comment, $expected_output ) { + $this->assertSame( + $expected_output, + wp_kses( $html_comment, array() ), + 'Failed to properly preserve HTML comment.' + ); + } + + /** + * Data provider. + * + * @return array[]. + */ + public static function data_html_containing_various_kinds_of_html_comments() { + return array( + 'Normative HTML comment' => array( 'beforeafter', 'beforeafter' ), + 'Closing tag with invalid tag name' => array( 'beforeafter', 'beforeafter' ), + ); + } + /** * Test that attributes with a list of allowed values are filtered correctly. * diff --git a/tests/phpunit/tests/script-modules/wpScriptModules.php b/tests/phpunit/tests/script-modules/wpScriptModules.php index 21a98ac5ba518..0d4f2f61f4eb3 100644 --- a/tests/phpunit/tests/script-modules/wpScriptModules.php +++ b/tests/phpunit/tests/script-modules/wpScriptModules.php @@ -122,8 +122,8 @@ public function test_wp_dequeue_script_module() { $enqueued_script_modules = $this->get_enqueued_script_modules(); $this->assertCount( 1, $enqueued_script_modules ); - $this->assertFalse( isset( $enqueued_script_modules['foo'] ) ); - $this->assertTrue( isset( $enqueued_script_modules['bar'] ) ); + $this->assertArrayNotHasKey( 'foo', $enqueued_script_modules ); + $this->assertArrayHasKey( 'bar', $enqueued_script_modules ); } @@ -149,8 +149,8 @@ public function test_wp_deregister_script_module() { $enqueued_script_modules = $this->get_enqueued_script_modules(); $this->assertCount( 1, $enqueued_script_modules ); - $this->assertFalse( isset( $enqueued_script_modules['foo'] ) ); - $this->assertTrue( isset( $enqueued_script_modules['bar'] ) ); + $this->assertArrayNotHasKey( 'foo', $enqueued_script_modules ); + $this->assertArrayHasKey( 'bar', $enqueued_script_modules ); } /** @@ -168,7 +168,7 @@ public function test_wp_deregister_unexistent_script_module() { $enqueued_script_modules = $this->get_enqueued_script_modules(); $this->assertCount( 0, $enqueued_script_modules ); - $this->assertFalse( isset( $enqueued_script_modules['unexistent'] ) ); + $this->assertArrayNotHasKey( 'unexistent', $enqueued_script_modules ); } /** @@ -190,13 +190,13 @@ public function test_wp_deregister_already_deregistered_script_module() { $enqueued_script_modules = $this->get_enqueued_script_modules(); $this->assertCount( 0, $enqueued_script_modules ); - $this->assertFalse( isset( $enqueued_script_modules['foo'] ) ); + $this->assertArrayNotHasKey( 'foo', $enqueued_script_modules ); $this->script_modules->deregister( 'foo' ); // Dequeued. $enqueued_script_modules = $this->get_enqueued_script_modules(); $this->assertCount( 0, $enqueued_script_modules ); - $this->assertFalse( isset( $enqueued_script_modules['foo'] ) ); + $this->assertArrayNotHasKey( 'foo', $enqueued_script_modules ); } /** @@ -218,7 +218,7 @@ public function test_wp_enqueue_script_module_works_before_register() { $this->assertCount( 1, $enqueued_script_modules ); $this->assertStringStartsWith( '/foo.js', $enqueued_script_modules['foo'] ); - $this->assertFalse( isset( $enqueued_script_modules['bar'] ) ); + $this->assertArrayNotHasKey( 'bar', $enqueued_script_modules ); } /** @@ -242,8 +242,8 @@ public function test_wp_dequeue_script_module_works_before_register() { $enqueued_script_modules = $this->get_enqueued_script_modules(); $this->assertCount( 1, $enqueued_script_modules ); - $this->assertFalse( isset( $enqueued_script_modules['foo'] ) ); - $this->assertTrue( isset( $enqueued_script_modules['bar'] ) ); + $this->assertArrayNotHasKey( 'foo', $enqueued_script_modules ); + $this->assertArrayHasKey( 'bar', $enqueued_script_modules ); } /** @@ -266,7 +266,7 @@ public function test_wp_import_map_dependencies() { $this->assertCount( 1, $import_map ); $this->assertStringStartsWith( '/dep.js', $import_map['dep'] ); - $this->assertFalse( isset( $import_map['no-dep'] ) ); + $this->assertArrayNotHasKey( 'no-dep', $import_map ); } /** @@ -340,7 +340,7 @@ public function test_wp_import_map_recursive_dependencies() { $this->assertStringStartsWith( '/dynamic-dep.js', $import_map['dynamic-dep'] ); $this->assertStringStartsWith( '/nested-static-dep.js', $import_map['nested-static-dep'] ); $this->assertStringStartsWith( '/nested-dynamic-dep.js', $import_map['nested-dynamic-dep'] ); - $this->assertFalse( isset( $import_map['no-dep'] ) ); + $this->assertArrayNotHasKey( 'no-dep', $import_map ); } /** @@ -409,9 +409,9 @@ public function test_wp_enqueue_preloaded_static_dependencies() { $this->assertCount( 2, $preloaded_script_modules ); $this->assertStringStartsWith( '/static-dep.js', $preloaded_script_modules['static-dep'] ); $this->assertStringStartsWith( '/nested-static-dep.js', $preloaded_script_modules['nested-static-dep'] ); - $this->assertFalse( isset( $preloaded_script_modules['no-dep'] ) ); - $this->assertFalse( isset( $preloaded_script_modules['dynamic-dep'] ) ); - $this->assertFalse( isset( $preloaded_script_modules['nested-dynamic-dep'] ) ); + $this->assertArrayNotHasKey( 'dynamic-dep', $preloaded_script_modules ); + $this->assertArrayNotHasKey( 'nested-dynamic-dep', $preloaded_script_modules ); + $this->assertArrayNotHasKey( 'no-dep', $preloaded_script_modules ); } /** @@ -445,9 +445,9 @@ public function test_wp_dont_preload_static_dependencies_of_dynamic_dependencies $this->assertCount( 1, $preloaded_script_modules ); $this->assertStringStartsWith( '/static-dep.js', $preloaded_script_modules['static-dep'] ); - $this->assertFalse( isset( $preloaded_script_modules['dynamic-dep'] ) ); - $this->assertFalse( isset( $preloaded_script_modules['nested-static-dep'] ) ); - $this->assertFalse( isset( $preloaded_script_modules['no-dep'] ) ); + $this->assertArrayNotHasKey( 'dynamic-dep', $preloaded_script_modules ); + $this->assertArrayNotHasKey( 'nested-dynamic-dep', $preloaded_script_modules ); + $this->assertArrayNotHasKey( 'no-dep', $preloaded_script_modules ); } /** @@ -476,8 +476,8 @@ public function test_wp_preloaded_dependencies_filter_enqueued_script_modules() $preloaded_script_modules = $this->get_preloaded_script_modules(); $this->assertCount( 1, $preloaded_script_modules ); - $this->assertTrue( isset( $preloaded_script_modules['dep'] ) ); - $this->assertFalse( isset( $preloaded_script_modules['enqueued-dep'] ) ); + $this->assertArrayHasKey( 'dep', $preloaded_script_modules ); + $this->assertArrayNotHasKey( 'enqueued-dep', $preloaded_script_modules ); } /** @@ -507,8 +507,8 @@ public function test_wp_enqueued_script_modules_with_dependants_add_import_map() $import_map = $this->get_import_map(); $this->assertCount( 2, $import_map ); - $this->assertTrue( isset( $import_map['dep'] ) ); - $this->assertTrue( isset( $import_map['enqueued-dep'] ) ); + $this->assertArrayHasKey( 'dep', $import_map ); + $this->assertArrayHasKey( 'enqueued-dep', $import_map ); } /** @@ -531,7 +531,7 @@ public function test_get_src() { ); $result = $get_src->invoke( $this->script_modules, 'module_with_version' ); - $this->assertEquals( 'http://example.com/module.js?ver=1.0', $result ); + $this->assertSame( 'http://example.com/module.js?ver=1.0', $result ); $this->script_modules->register( 'module_without_version', @@ -541,7 +541,7 @@ public function test_get_src() { ); $result = $get_src->invoke( $this->script_modules, 'module_without_version' ); - $this->assertEquals( 'http://example.com/module.js', $result ); + $this->assertSame( 'http://example.com/module.js', $result ); $this->script_modules->register( 'module_with_wp_version', @@ -551,7 +551,7 @@ public function test_get_src() { ); $result = $get_src->invoke( $this->script_modules, 'module_with_wp_version' ); - $this->assertEquals( 'http://example.com/module.js?ver=' . get_bloginfo( 'version' ), $result ); + $this->assertSame( 'http://example.com/module.js?ver=' . get_bloginfo( 'version' ), $result ); $this->script_modules->register( 'module_with_existing_query_string', @@ -561,7 +561,7 @@ public function test_get_src() { ); $result = $get_src->invoke( $this->script_modules, 'module_with_existing_query_string' ); - $this->assertEquals( 'http://example.com/module.js?foo=bar&ver=1.0', $result ); + $this->assertSame( 'http://example.com/module.js?foo=bar&ver=1.0', $result ); // Filter the version to include the ID in the final URL, to test the filter, this should affect the tests below. add_filter( @@ -574,10 +574,10 @@ function ( $src, $id ) { ); $result = $get_src->invoke( $this->script_modules, 'module_without_version' ); - $this->assertEquals( 'http://example.com/module.js?script_module_id=module_without_version', $result ); + $this->assertSame( 'http://example.com/module.js?script_module_id=module_without_version', $result ); $result = $get_src->invoke( $this->script_modules, 'module_with_existing_query_string' ); - $this->assertEquals( 'http://example.com/module.js?foo=bar&ver=1.0&script_module_id=module_with_existing_query_string', $result ); + $this->assertSame( 'http://example.com/module.js?foo=bar&ver=1.0&script_module_id=module_with_existing_query_string', $result ); } /** @@ -606,13 +606,13 @@ public function test_version_is_propagated_correctly() { $this->script_modules->enqueue( 'foo' ); $enqueued_script_modules = $this->get_enqueued_script_modules(); - $this->assertEquals( '/foo.js?ver=1.0', $enqueued_script_modules['foo'] ); + $this->assertSame( '/foo.js?ver=1.0', $enqueued_script_modules['foo'] ); $import_map = $this->get_import_map(); - $this->assertEquals( '/dep.js?ver=2.0', $import_map['dep'] ); + $this->assertSame( '/dep.js?ver=2.0', $import_map['dep'] ); $preloaded_script_modules = $this->get_preloaded_script_modules(); - $this->assertEquals( '/dep.js?ver=2.0', $preloaded_script_modules['dep'] ); + $this->assertSame( '/dep.js?ver=2.0', $preloaded_script_modules['dep'] ); } /** @@ -630,7 +630,7 @@ public function test_wp_enqueue_script_module_doesnt_register_without_a_valid_sr $enqueued_script_modules = $this->get_enqueued_script_modules(); $this->assertCount( 0, $enqueued_script_modules ); - $this->assertFalse( isset( $enqueued_script_modules['foo'] ) ); + $this->assertArrayNotHasKey( 'foo', $enqueued_script_modules ); } /** @@ -666,7 +666,7 @@ public function test_wp_enqueue_script_module_registers_with_valid_src_the_secon $enqueued_script_modules = $this->get_enqueued_script_modules(); $this->assertCount( 0, $enqueued_script_modules ); - $this->assertFalse( isset( $enqueued_script_modules['foo'] ) ); + $this->assertArrayNotHasKey( 'foo', $enqueued_script_modules ); $this->script_modules->enqueue( 'foo', '/foo.js' ); // Valid src. @@ -695,7 +695,7 @@ public function test_wp_enqueue_script_module_registers_all_params() { $import_map = $this->get_import_map(); $this->assertCount( 1, $enqueued_script_modules ); - $this->assertEquals( '/foo.js?ver=1.0', $enqueued_script_modules['foo'] ); + $this->assertSame( '/foo.js?ver=1.0', $enqueued_script_modules['foo'] ); $this->assertCount( 1, $import_map ); $this->assertStringStartsWith( '/dep.js', $import_map['dep'] ); } @@ -708,7 +708,7 @@ public function test_wp_enqueue_script_module_registers_all_params() { public function test_wp_print_import_map_has_no_polyfill_when_no_modules_registered() { $import_map_polyfill = get_echo( array( $this->script_modules, 'print_import_map' ) ); - $this->assertEquals( '', $import_map_polyfill ); + $this->assertSame( '', $import_map_polyfill ); } /** @@ -730,6 +730,6 @@ public function test_wp_print_import_map_has_polyfill_when_modules_registered() $p->next_tag( array( 'tag' => 'SCRIPT' ) ); $id = $p->get_attribute( 'id' ); - $this->assertEquals( 'wp-load-polyfill-importmap', $id ); + $this->assertSame( 'wp-load-polyfill-importmap', $id ); } } diff --git a/tests/phpunit/tests/theme/wpThemeJsonResolver.php b/tests/phpunit/tests/theme/wpThemeJsonResolver.php index 581828ba6f29c..0cb102b7accf4 100644 --- a/tests/phpunit/tests/theme/wpThemeJsonResolver.php +++ b/tests/phpunit/tests/theme/wpThemeJsonResolver.php @@ -1160,6 +1160,19 @@ public function data_get_style_variations() { ), ), ), + // @ticket 61440 + array( + 'blockTypes' => array( 'core/group', 'core/columns' ), + 'version' => 3, + 'slug' => 'WithSlug', + 'title' => 'With Slug', + 'styles' => array( + 'color' => array( + 'background' => 'aliceblue', + 'text' => 'midnightblue', + ), + ), + ), ), ), );