From 7c254c5510f6e5227e320ea3118f411504f1fe1a Mon Sep 17 00:00:00 2001
From: John Blackbourn
Date: Mon, 28 Aug 2023 21:51:44 +0000
Subject: [PATCH 001/105] Privacy: Improve docblocks for hooks and functions
related to personal data export and erasure.
See #58833
git-svn-id: https://develop.svn.wordpress.org/trunk@56482 602fd350-edb4-49c9-b593-d223f7449a82
---
src/wp-admin/includes/ajax-actions.php | 23 +++++++++++++++--------
src/wp-includes/comment.php | 24 ++++++++++++++++++------
src/wp-includes/media.php | 9 +++++++--
src/wp-includes/user.php | 7 ++++++-
4 files changed, 46 insertions(+), 17 deletions(-)
diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php
index 3c5dab31b500b..16b827d7bd5d0 100644
--- a/src/wp-admin/includes/ajax-actions.php
+++ b/src/wp-admin/includes/ajax-actions.php
@@ -4939,8 +4939,8 @@ function wp_ajax_wp_privacy_export_personal_data() {
* Array of personal data exporters.
*
* @type callable $callback Callable exporter function that accepts an
- * email address and a page and returns an array
- * of name => value pairs of personal data.
+ * email address and a page number and returns an
+ * array of name => value pairs of personal data.
* @type string $exporter_friendly_name Translated user facing friendly name for the
* exporter.
* }
@@ -5051,10 +5051,10 @@ function wp_ajax_wp_privacy_export_personal_data() {
*
* @since 4.9.6
*
- * @param array $response The personal data for the given exporter and page.
+ * @param array $response The personal data for the given exporter and page number.
* @param int $exporter_index The index of the exporter that provided this data.
* @param string $email_address The email address associated with this personal data.
- * @param int $page The page for this response.
+ * @param int $page The page number for this response.
* @param int $request_id The privacy request post ID associated with this request.
* @param bool $send_as_email Whether the final results of the export should be emailed to the user.
* @param string $exporter_key The key (slug) of the exporter that provided this data.
@@ -5128,8 +5128,8 @@ function wp_ajax_wp_privacy_erase_personal_data() {
* @type array ...$0 {
* Array of personal data exporters.
*
- * @type callable $callback Callable eraser that accepts an email address and
- * a page and returns an array with boolean values for
+ * @type callable $callback Callable eraser that accepts an email address and a page
+ * number, and returns an array with boolean values for
* whether items were removed or retained and any messages
* from the eraser, as well as if additional pages are
* available.
@@ -5281,10 +5281,17 @@ function wp_ajax_wp_privacy_erase_personal_data() {
*
* @since 4.9.6
*
- * @param array $response The personal data for the given exporter and page.
+ * @param array $response {
+ * The personal data for the given exporter and page number.
+ *
+ * @type bool $items_removed Whether items were actually removed or not.
+ * @type bool $items_retained Whether items were retained or not.
+ * @type string[] $messages An array of messages to add to the personal data export file.
+ * @type bool $done Whether the eraser is finished or not.
+ * }
* @param int $eraser_index The index of the eraser that provided this data.
* @param string $email_address The email address associated with this personal data.
- * @param int $page The page for this response.
+ * @param int $page The page number for this response.
* @param int $request_id The privacy request post ID associated with this request.
* @param string $eraser_key The key (slug) of the eraser that provided this data.
*/
diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php
index 604ede7c876a7..b538b2c5c12ef 100644
--- a/src/wp-includes/comment.php
+++ b/src/wp-includes/comment.php
@@ -3684,8 +3684,8 @@ function wp_handle_comment_submission( $comment_data ) {
*
* @since 4.9.6
*
- * @param array $exporters An array of personal data exporters.
- * @return array An array of personal data exporters.
+ * @param array[] $exporters An array of personal data exporters.
+ * @return array[] An array of personal data exporters.
*/
function wp_register_comment_personal_data_exporter( $exporters ) {
$exporters['wordpress-comments'] = array(
@@ -3702,8 +3702,13 @@ function wp_register_comment_personal_data_exporter( $exporters ) {
* @since 4.9.6
*
* @param string $email_address The comment author email address.
- * @param int $page Comment page.
- * @return array An array of personal data.
+ * @param int $page Comment page number.
+ * @return array {
+ * An array of personal data.
+ *
+ * @type array[] $data An array of personal data arrays.
+ * @type bool $done Whether the exporter is finished.
+ * }
*/
function wp_comments_personal_data_exporter( $email_address, $page = 1 ) {
// Limit us to 500 comments at a time to avoid timing out.
@@ -3814,8 +3819,15 @@ function wp_register_comment_personal_data_eraser( $erasers ) {
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param string $email_address The comment author email address.
- * @param int $page Comment page.
- * @return array
+ * @param int $page Comment page number.
+ * @return array {
+ * Data removal results.
+ *
+ * @type bool $items_removed Whether items were actually removed.
+ * @type bool $items_retained Whether items were retained.
+ * @type string[] $messages An array of messages to add to the personal data export file.
+ * @type bool $done Whether the eraser is finished.
+ * }
*/
function wp_comments_personal_data_eraser( $email_address, $page = 1 ) {
global $wpdb;
diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php
index aeedcc22a95ba..e037a0608bac8 100644
--- a/src/wp-includes/media.php
+++ b/src/wp-includes/media.php
@@ -5359,8 +5359,13 @@ function wp_register_media_personal_data_exporter( $exporters ) {
* @since 4.9.6
*
* @param string $email_address The attachment owner email address.
- * @param int $page Attachment page.
- * @return array An array of personal data.
+ * @param int $page Attachment page number.
+ * @return array {
+ * An array of personal data.
+ *
+ * @type array[] $data An array of personal data arrays.
+ * @type bool $done Whether the exporter is finished.
+ * }
*/
function wp_media_personal_data_exporter( $email_address, $page = 1 ) {
// Limit us to 50 attachments at a time to avoid timing out.
diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php
index 04e6aab999a1b..5f8fe3807154e 100644
--- a/src/wp-includes/user.php
+++ b/src/wp-includes/user.php
@@ -3807,7 +3807,12 @@ function wp_register_user_personal_data_exporter( $exporters ) {
* @since 5.4.0 Added 'Session Tokens' group to the export data.
*
* @param string $email_address The user's email address.
- * @return array An array of personal data.
+ * @return array {
+ * An array of personal data.
+ *
+ * @type array[] $data An array of personal data arrays.
+ * @type bool $done Whether the exporter is finished.
+ * }
*/
function wp_user_personal_data_exporter( $email_address ) {
$email_address = trim( $email_address );
From 61cd1a5210f907926c769bf7b3103d2d1b83a9de Mon Sep 17 00:00:00 2001
From: Sergey Biryukov
Date: Tue, 29 Aug 2023 13:44:54 +0000
Subject: [PATCH 002/105] External Libraries: Upgrade PHPMailer to version
6.8.1.
This is a minor maintenance release.
Note: WordPress core does not include PHPMailer's DSN class, as it is not particularly relevant for WP.
References:
* [https://github.com/PHPMailer/PHPMailer/releases/tag/v6.8.1 PHPMailer 6.8.1 release notes]
* [https://github.com/PHPMailer/PHPMailer/compare/v6.8.0...v6.8.1 Full list of changes in PHPMailer 6.8.1]
Follow-up to [50628], [50799], [51169], [51634], [51635], [52252], [52749], [52811], [53500], [53535], [53917], [54427], [54937], [55557].
Props jrf, Synchro.
Fixes #59238.
git-svn-id: https://develop.svn.wordpress.org/trunk@56484 602fd350-edb4-49c9-b593-d223f7449a82
---
src/wp-includes/PHPMailer/PHPMailer.php | 4 ++--
src/wp-includes/PHPMailer/SMTP.php | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/wp-includes/PHPMailer/PHPMailer.php b/src/wp-includes/PHPMailer/PHPMailer.php
index 79cf323307987..011fa92068e95 100644
--- a/src/wp-includes/PHPMailer/PHPMailer.php
+++ b/src/wp-includes/PHPMailer/PHPMailer.php
@@ -750,7 +750,7 @@ class PHPMailer
*
* @var string
*/
- const VERSION = '6.8.0';
+ const VERSION = '6.8.1';
/**
* Error severity: message only, continue processing.
@@ -795,7 +795,7 @@ class PHPMailer
* The maximum line length supported by mail().
*
* Background: mail() will sometimes corrupt messages
- * with headers headers longer than 65 chars, see #818.
+ * with headers longer than 65 chars, see #818.
*
* @var int
*/
diff --git a/src/wp-includes/PHPMailer/SMTP.php b/src/wp-includes/PHPMailer/SMTP.php
index fc4b781a5fdeb..2b63840304749 100644
--- a/src/wp-includes/PHPMailer/SMTP.php
+++ b/src/wp-includes/PHPMailer/SMTP.php
@@ -35,7 +35,7 @@ class SMTP
*
* @var string
*/
- const VERSION = '6.8.0';
+ const VERSION = '6.8.1';
/**
* SMTP line break constant.
@@ -704,7 +704,7 @@ public function close()
* Send an SMTP DATA command.
* Issues a data command and sends the msg_data to the server,
* finalizing the mail transaction. $msg_data is the message
- * that is to be send with the headers. Each header needs to be
+ * that is to be sent with the headers. Each header needs to be
* on a single line followed by a with the message headers
* and the message body being separated by an additional .
* Implements RFC 821: DATA .
@@ -732,7 +732,7 @@ public function data($msg_data)
$lines = explode("\n", str_replace(["\r\n", "\r"], "\n", $msg_data));
/* To distinguish between a complete RFC822 message and a plain message body, we check if the first field
- * of the first line (':' separated) does not contain a space then it _should_ be a header and we will
+ * of the first line (':' separated) does not contain a space then it _should_ be a header, and we will
* process all lines before a blank line as headers.
*/
From ec94944ae4b5af2c2dda675711b627d98a72a2b0 Mon Sep 17 00:00:00 2001
From: Pascal Birchler
Date: Tue, 29 Aug 2023 15:33:43 +0000
Subject: [PATCH 003/105] Media: Prevent warning if `[caption]` shortcode is
used without attributes.
Props maltfield, aslamdoctor.
Fixes #59206.
git-svn-id: https://develop.svn.wordpress.org/trunk@56488 602fd350-edb4-49c9-b593-d223f7449a82
---
src/wp-includes/media.php | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php
index e037a0608bac8..d365e0b1e1915 100644
--- a/src/wp-includes/media.php
+++ b/src/wp-includes/media.php
@@ -2361,6 +2361,10 @@ function _wp_post_thumbnail_context_filter_remove() {
* @return string HTML content to display the caption.
*/
function img_caption_shortcode( $attr, $content = '' ) {
+ if ( ! $attr ) {
+ $attr = array();
+ }
+
// New-style shortcode with the caption inside the shortcode with the link and image tags.
if ( ! isset( $attr['caption'] ) ) {
if ( preg_match( '#((?:]+>\s*)?]+>(?:\s*)?)(.*)#is', $content, $matches ) ) {
From ab5fd4d56a955c1b2c7800feb5f34218c6604a36 Mon Sep 17 00:00:00 2001
From: Pascal Birchler
Date: Tue, 29 Aug 2023 15:39:13 +0000
Subject: [PATCH 004/105] Site Health: fix check name used for REST API
permission checks.
Updates the calls to permission validation calls for the `directory-sizes` and `page-cache` routes to actually match the route names.
Follow-up to r54043 and r49154.
Props szepeviktor.
Fixes #59236
git-svn-id: https://develop.svn.wordpress.org/trunk@56489 602fd350-edb4-49c9-b593-d223f7449a82
---
.../endpoints/class-wp-rest-site-health-controller.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php
index 43e6676eff0ea..18d67dc2dd7a0 100644
--- a/src/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php
+++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php
@@ -153,7 +153,7 @@ public function register_routes() {
'methods' => 'GET',
'callback' => array( $this, 'get_directory_sizes' ),
'permission_callback' => function() {
- return $this->validate_request_permission( 'debug_enabled' ) && ! is_multisite();
+ return $this->validate_request_permission( 'directory_sizes' ) && ! is_multisite();
},
)
);
@@ -170,7 +170,7 @@ public function register_routes() {
'methods' => 'GET',
'callback' => array( $this, 'test_page_cache' ),
'permission_callback' => function () {
- return $this->validate_request_permission( 'view_site_health_checks' );
+ return $this->validate_request_permission( 'page_cache' );
},
),
)
From 3d2f4d5a88ab33e21f0ae97c277ddabb066c886b Mon Sep 17 00:00:00 2001
From: Joe McGill
Date: Tue, 29 Aug 2023 22:03:25 +0000
Subject: [PATCH 005/105] Posts, Post Types: Reinstate missing sort_column
options in get_pages().
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This fixes an issue introduced in [55569] that broke sort ordering by `post_modified_gmt` or `modified_gmt`.
Props david.binda, azaozz, spacedmonkey, flixos90, joemcgill.
Fixes #59226.
git-svn-id: https://develop.svn.wordpress.org/trunk@56490 602fd350-edb4-49c9-b593-d223f7449a82
---
src/wp-includes/post.php | 16 +++++++++++++-
tests/phpunit/tests/post/getPages.php | 31 +++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php
index 5367f51e06f06..0bd4fc7a9f1ce 100644
--- a/src/wp-includes/post.php
+++ b/src/wp-includes/post.php
@@ -6066,8 +6066,22 @@ function get_pages( $args = array() ) {
$query_args['post_parent'] = $parent;
}
+ /*
+ * Maintain backward compatibility for `sort_column` key.
+ * Additionally to `WP_Query`, it has been supporting the `post_modified_gmt` field, so this logic will translate
+ * it to `post_modified` which should result in the same order given the two dates in the fields match.
+ */
$orderby = wp_parse_list( $parsed_args['sort_column'] );
- $orderby = array_map( 'trim', $orderby );
+ $orderby = array_map(
+ static function( $orderby_field ) {
+ $orderby_field = trim( $orderby_field );
+ if ( 'post_modified_gmt' === $orderby_field || 'modified_gmt' === $orderby_field ) {
+ $orderby_field = str_replace( '_gmt', '', $orderby_field );
+ }
+ return $orderby_field;
+ },
+ $orderby
+ );
if ( $orderby ) {
$query_args['orderby'] = array_fill_keys( $orderby, $parsed_args['sort_order'] );
}
diff --git a/tests/phpunit/tests/post/getPages.php b/tests/phpunit/tests/post/getPages.php
index 92de3356fa5c6..e72ba3e2ed8b9 100644
--- a/tests/phpunit/tests/post/getPages.php
+++ b/tests/phpunit/tests/post/getPages.php
@@ -1181,4 +1181,35 @@ public function test_get_pages_order() {
'Check that ORDER is post date.'
);
}
+
+ /**
+ * Tests that the legacy `post_modified_gmt` orderby values are translated to the proper `WP_Query` values.
+ *
+ * @ticket 59226
+ */
+ public function test_get_pages_order_by_post_modified_gmt() {
+ global $wpdb;
+
+ get_pages(
+ array(
+ 'sort_column' => 'post_modified_gmt',
+ )
+ );
+ $this->assertStringContainsString(
+ "ORDER BY $wpdb->posts.post_modified ASC",
+ $wpdb->last_query,
+ 'Check that ORDER is post modified when using post_modified_gmt.'
+ );
+
+ get_pages(
+ array(
+ 'sort_column' => 'modified_gmt',
+ )
+ );
+ $this->assertStringContainsString(
+ "ORDER BY $wpdb->posts.post_modified ASC",
+ $wpdb->last_query,
+ 'Check that ORDER is post modified when using modified_gmt.'
+ );
+ }
}
From e278fe3fcf262d1792a347a460bc004200a2490f Mon Sep 17 00:00:00 2001
From: Joe McGill
Date: Tue, 29 Aug 2023 22:11:22 +0000
Subject: [PATCH 006/105] Posts, Post Types: Avoid redundant SQL query in
get_pages().
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This avoids an additional query by passing the query args directly to the `WP_Query::query()` method, rather than to the constructor and calling get_posts(), following [55569].
Props david.binda, azaozz, spacedmonkey, mukesh27, flixos90, SergeyBiryukov, joemcgill.
Fixes #59224.
git-svn-id: https://develop.svn.wordpress.org/trunk@56491 602fd350-edb4-49c9-b593-d223f7449a82
---
src/wp-includes/post.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php
index 0bd4fc7a9f1ce..f71a0a061d391 100644
--- a/src/wp-includes/post.php
+++ b/src/wp-includes/post.php
@@ -6105,8 +6105,8 @@ static function( $orderby_field ) {
*/
$query_args = apply_filters( 'get_pages_query_args', $query_args, $parsed_args );
- $query = new WP_Query( $query_args );
- $pages = $query->get_posts();
+ $pages = new WP_Query();
+ $pages = $pages->query( $query_args );
if ( $child_of || $hierarchical ) {
$pages = get_page_children( $child_of, $pages );
From c6088bb590ecf9d49dd03b81bc7175a7b9452ac1 Mon Sep 17 00:00:00 2001
From: Sergey Biryukov
Date: Wed, 30 Aug 2023 10:49:27 +0000
Subject: [PATCH 007/105] Tests: Correct uses of
`ReflectionProperty::setValue()` for static properties.
The single parameter signature, which was used for setting the value on a static property, is deprecated since PHP 8.3. A cross-version solution is to pass `null` as the first parameter.
This commit updates all the instances that use the deprecated signature in WordPress core.
Reference: [https://wiki.php.net/rfc/deprecate_functions_with_overloaded_signatures#reflectionpropertysetvalue PHP RFC: Deprecate functions with overloaded signatures: ReflectionProperty::setValue()].
Follow-up to [53152], [54493], [54799].
Props jrf, costdev, Tests: Correct uses of `ReflectionProperty::setValue()` for static properties.
The single parameter signature, which was used for setting the value on a static property, is deprecated since PHP 8.3. A cross-version solution is to pass `null` as the first parameter.
This commit updates all the instances that use the deprecated signature in WordPress core.
Reference: [https://wiki.php.net/rfc/deprecate_functions_with_overloaded_signatures#reflectionpropertysetvalue PHP RFC: Deprecate functions with overloaded signatures: ReflectionProperty::setValue()].
Follow-up to [53152], [54493], [54799].
Props jrf, costdev, sc0ttkclark.
See #59231.
git-svn-id: https://develop.svn.wordpress.org/trunk@56492 602fd350-edb4-49c9-b593-d223f7449a82
---
.../rest-api/wpRestBlockPatternCategoriesController.php | 4 ++--
.../tests/rest-api/wpRestBlockPatternsController.php | 4 ++--
tests/phpunit/tests/theme/wpThemeJsonResolver.php | 6 +++---
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/tests/phpunit/tests/rest-api/wpRestBlockPatternCategoriesController.php b/tests/phpunit/tests/rest-api/wpRestBlockPatternCategoriesController.php
index 77481112a0f87..63c2256b36ba3 100644
--- a/tests/phpunit/tests/rest-api/wpRestBlockPatternCategoriesController.php
+++ b/tests/phpunit/tests/rest-api/wpRestBlockPatternCategoriesController.php
@@ -65,7 +65,7 @@ public static function wpSetupBeforeClass( $factory ) {
self::$registry_instance_property = new ReflectionProperty( 'WP_Block_Pattern_Categories_Registry', 'instance' );
self::$registry_instance_property->setAccessible( true );
$test_registry = new WP_Block_Pattern_Categories_Registry();
- self::$registry_instance_property->setValue( $test_registry );
+ self::$registry_instance_property->setValue( null, $test_registry );
// Register some categories in the test registry.
$test_registry->register(
@@ -88,7 +88,7 @@ public static function wpTearDownAfterClass() {
self::delete_user( self::$admin_id );
// Restore the original registry instance.
- self::$registry_instance_property->setValue( self::$orig_registry );
+ self::$registry_instance_property->setValue( null, self::$orig_registry );
self::$registry_instance_property->setAccessible( false );
self::$registry_instance_property = null;
self::$orig_registry = null;
diff --git a/tests/phpunit/tests/rest-api/wpRestBlockPatternsController.php b/tests/phpunit/tests/rest-api/wpRestBlockPatternsController.php
index 5482e32cbede2..2dc3bb83a38ac 100644
--- a/tests/phpunit/tests/rest-api/wpRestBlockPatternsController.php
+++ b/tests/phpunit/tests/rest-api/wpRestBlockPatternsController.php
@@ -65,7 +65,7 @@ public static function wpSetUpBeforeClass( $factory ) {
self::$registry_instance_property = new ReflectionProperty( 'WP_Block_Patterns_Registry', 'instance' );
self::$registry_instance_property->setAccessible( true );
$test_registry = new WP_Block_Pattern_Categories_Registry();
- self::$registry_instance_property->setValue( $test_registry );
+ self::$registry_instance_property->setValue( null, $test_registry );
// Register some patterns in the test registry.
$test_registry->register(
@@ -106,7 +106,7 @@ public static function wpTearDownAfterClass() {
self::delete_user( self::$admin_id );
// Restore the original registry instance.
- self::$registry_instance_property->setValue( self::$orig_registry );
+ self::$registry_instance_property->setValue( null, self::$orig_registry );
self::$registry_instance_property->setAccessible( false );
self::$registry_instance_property = null;
self::$orig_registry = null;
diff --git a/tests/phpunit/tests/theme/wpThemeJsonResolver.php b/tests/phpunit/tests/theme/wpThemeJsonResolver.php
index 7e928aa0c7123..12c9f50f084f8 100644
--- a/tests/phpunit/tests/theme/wpThemeJsonResolver.php
+++ b/tests/phpunit/tests/theme/wpThemeJsonResolver.php
@@ -81,8 +81,8 @@ public static function set_up_before_class() {
}
public static function tear_down_after_class() {
- static::$property_blocks_cache->setValue( WP_Theme_JSON_Resolver::class, static::$property_blocks_cache_orig_value );
- static::$property_core->setValue( WP_Theme_JSON_Resolver::class, static::$property_core_orig_value );
+ static::$property_blocks_cache->setValue( null, static::$property_blocks_cache_orig_value );
+ static::$property_core->setValue( null, static::$property_core_orig_value );
parent::tear_down_after_class();
}
@@ -759,7 +759,7 @@ public function test_get_theme_data_does_not_parse_theme_json_if_not_present() {
// Force-unset $i18n_schema property to "unload" translation schema.
$property = new ReflectionProperty( $theme_json_resolver, 'i18n_schema' );
$property->setAccessible( true );
- $property->setValue( null );
+ $property->setValue( null, null );
// A completely empty theme.json data set still has the 'version' key when parsed.
$empty_theme_json = array( 'version' => WP_Theme_JSON::LATEST_SCHEMA );
From 973b4565ee4b7a9c08dfc8541e4951963f37f478 Mon Sep 17 00:00:00 2001
From: Bernie Reiter
Date: Wed, 30 Aug 2023 15:37:33 +0000
Subject: [PATCH 008/105] HTML API: Stop processing HTML when encountering
unsupported markup.
It was a design goal of the HTML Processor to abort processing its input document when encountering unsupported markup. Unfortunately there was no test for this and so-far, the HTML Processor has paused, but continued processing in these situations.
In this patch a new test ensures that the HTML Processor stops and refuses to move forward after encountering any unsupported markup. It also ensures that it doesn't report any current tag names since unsupported markup could imply that the read tag name is different than the parsed tag name.
Props dmsnell.
Fixes #59167.
git-svn-id: https://develop.svn.wordpress.org/trunk@56493 602fd350-edb4-49c9-b593-d223f7449a82
---
.../html-api/class-wp-html-processor.php | 9 +++++
.../tests/html-api/wpHtmlProcessor.php | 34 +++++++++++++++++++
2 files changed, 43 insertions(+)
diff --git a/src/wp-includes/html-api/class-wp-html-processor.php b/src/wp-includes/html-api/class-wp-html-processor.php
index 6e1723494c2e9..b5a20dbd82cdc 100644
--- a/src/wp-includes/html-api/class-wp-html-processor.php
+++ b/src/wp-includes/html-api/class-wp-html-processor.php
@@ -432,6 +432,11 @@ public function next_tag( $query = null ) {
* @return bool Whether a tag was matched.
*/
public function step( $node_to_process = self::PROCESS_NEXT_NODE ) {
+ // Refuse to proceed if there was a previous error.
+ if ( null !== $this->last_error ) {
+ return false;
+ }
+
if ( self::PROCESS_NEXT_NODE === $node_to_process ) {
$top_node = $this->state->stack_of_open_elements->current_node();
if ( $top_node && self::is_void( $top_node->node_name ) ) {
@@ -744,6 +749,10 @@ private function bookmark_tag() {
* @return string|null Name of currently matched tag in input HTML, or `null` if none found.
*/
public function get_tag() {
+ if ( null !== $this->last_error ) {
+ return null;
+ }
+
$tag_name = parent::get_tag();
switch ( $tag_name ) {
diff --git a/tests/phpunit/tests/html-api/wpHtmlProcessor.php b/tests/phpunit/tests/html-api/wpHtmlProcessor.php
index 6a666c19cf27c..d6b818dd44c34 100644
--- a/tests/phpunit/tests/html-api/wpHtmlProcessor.php
+++ b/tests/phpunit/tests/html-api/wpHtmlProcessor.php
@@ -42,6 +42,40 @@ public function test_warns_that_the_static_creator_methods_should_be_called_inst
);
}
+ /**
+ * Once stepping to the end of the document, WP_HTML_Processor::get_tag
+ * should no longer report a tag. It should report `null` because there
+ * is no tag matched or open.
+ *
+ * @ticket 59167
+ *
+ * @covers WP_HTML_Processor::get_tag
+ */
+ public function test_get_tag_is_null_once_document_is_finished() {
+ $p = WP_HTML_Processor::createFragment( '
Test
' );
+ $p->next_tag();
+ $this->assertSame( 'DIV', $p->get_tag() );
+
+ $this->assertFalse( $p->next_tag() );
+ $this->assertNull( $p->get_tag() );
+ }
+
+ /**
+ * Ensures that if the HTML Processor encounters inputs that it can't properly handle,
+ * that it stops processing the rest of the document. This prevents data corruption.
+ *
+ * @ticket 59167
+ *
+ * @covers WP_HTML_Processor::next_tag
+ */
+ public function test_stops_processing_after_unsupported_elements() {
+ $p = WP_HTML_Processor::createFragment( '
' );
+ $p->next_tag( 'P' );
+ $this->assertFalse( $p->next_tag(), 'Stepped into a tag after encountering X-NOT-SUPPORTED element when it should have aborted.' );
+ $this->assertNull( $p->get_tag(), "Should have aborted processing, but still reported tag {$p->get_tag()} after properly failing to step into tag." );
+ $this->assertFalse( $p->next_tag( 'P' ), 'Stepped into normal P element after X-NOT-SUPPORTED element when it should have aborted.' );
+ }
+
/**
* Ensures that the HTML Processor maintains its internal state through seek calls.
*
From bc92bb0cbae3969dc53056efaed3593c66e2600a Mon Sep 17 00:00:00 2001
From: Colin Stewart
Date: Wed, 30 Aug 2023 20:23:18 +0000
Subject: [PATCH 009/105] General: Replace two `esc_url_raw()` calls in core
with `sanitize_url()`.
This aims to improve performance by calling `sanitize_url()` directly, instead of the `esc_url_raw()` wrapper. As of WordPress 6.1, `sanitize_url()` is the recommended function for sanitizing a URL for database or redirect usage.
This replaces the two remaining instances of `esc_url_raw()` with `sanitize_url()` in WordPress core.
Follow-up to [53455], [53933], [54522].
Props rajinsharwar, SergeyBiryukov.
Fixes #59247.
git-svn-id: https://develop.svn.wordpress.org/trunk@56494 602fd350-edb4-49c9-b593-d223f7449a82
---
src/wp-includes/functions.php | 2 +-
src/wp-includes/update.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
index d2304f4d55c53..be03264455331 100644
--- a/src/wp-includes/functions.php
+++ b/src/wp-includes/functions.php
@@ -3613,7 +3613,7 @@ function wp_nonce_ays( $action ) {
if ( wp_get_referer() ) {
$wp_http_referer = remove_query_arg( 'updated', wp_get_referer() );
- $wp_http_referer = wp_validate_redirect( esc_url_raw( $wp_http_referer ) );
+ $wp_http_referer = wp_validate_redirect( sanitize_url( $wp_http_referer ) );
$html .= '
';
$html .= sprintf(
diff --git a/src/wp-includes/update.php b/src/wp-includes/update.php
index 7c4e31feefe99..c5349832ac2a4 100644
--- a/src/wp-includes/update.php
+++ b/src/wp-includes/update.php
@@ -754,7 +754,7 @@ function wp_update_themes( $extra_stats = array() ) {
continue;
}
- $hostname = wp_parse_url( esc_url_raw( $theme_data['UpdateURI'] ), PHP_URL_HOST );
+ $hostname = wp_parse_url( sanitize_url( $theme_data['UpdateURI'] ), PHP_URL_HOST );
/**
* Filters the update response for a given theme hostname.
From 98284ae792d95d4484c25b11d6f4fea4f6603cbc Mon Sep 17 00:00:00 2001
From: Jb Audras
Date: Wed, 30 Aug 2023 22:07:13 +0000
Subject: [PATCH 010/105] HTTP API: Update `WP_Http` class to avoid PHP
deprecation warnings.
This changeset prevents a PHP 8.3 deprecation shown when enabling debug and calling `get_class()` without arguments.
For more info about this deprecation, see https://wiki.php.net/rfc/deprecate_functions_with_overloaded_signatures#get_class_and_get_parent_class.
Props ipajen, rajinsharwar, SergeyBiryukov, jrf.
Fixes #58876.
git-svn-id: https://develop.svn.wordpress.org/trunk@56495 602fd350-edb4-49c9-b593-d223f7449a82
---
src/wp-includes/class-wp-http.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/wp-includes/class-wp-http.php b/src/wp-includes/class-wp-http.php
index e1d37878a140f..546ba96c1cdfb 100644
--- a/src/wp-includes/class-wp-http.php
+++ b/src/wp-includes/class-wp-http.php
@@ -326,11 +326,11 @@ public function request( $url, $args = array() ) {
);
// Ensure redirects follow browser behavior.
- $options['hooks']->register( 'requests.before_redirect', array( get_class(), 'browser_redirect_compatibility' ) );
+ $options['hooks']->register( 'requests.before_redirect', array( static::class, 'browser_redirect_compatibility' ) );
// Validate redirected URLs.
if ( function_exists( 'wp_kses_bad_protocol' ) && $parsed_args['reject_unsafe_urls'] ) {
- $options['hooks']->register( 'requests.before_redirect', array( get_class(), 'validate_redirects' ) );
+ $options['hooks']->register( 'requests.before_redirect', array( static::class, 'validate_redirects' ) );
}
if ( $parsed_args['stream'] ) {
From 39db9a677547c4cd1fa9f75b19223323ccfac7c7 Mon Sep 17 00:00:00 2001
From: Jb Audras
Date: Wed, 30 Aug 2023 22:09:20 +0000
Subject: [PATCH 011/105] Editor: Add relative time strings for the `wp-date`
inline script output.
This changeset updates `wp_default_packages_inline_scripts()` to add relative time strings to the `wp-date` inline script, so the JS version of `human_time_diff`
can output translated strings.
Props ramonopoly, oandregal, swissspidy, manzoorwanijk, adrianduffell, Presskopp.
Fixes #59219, #47373.
git-svn-id: https://develop.svn.wordpress.org/trunk@56496 602fd350-edb4-49c9-b593-d223f7449a82
---
src/wp-includes/script-loader.php | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php
index 3cbcb8996709b..85cb58f56bb13 100644
--- a/src/wp-includes/script-loader.php
+++ b/src/wp-includes/script-loader.php
@@ -329,6 +329,7 @@ function wp_default_packages_scripts( $scripts ) {
* Adds inline scripts required for the WordPress JavaScript packages.
*
* @since 5.0.0
+ * @since 6.4.0 Added relative time strings for the `wp-date` inline script output.
*
* @global WP_Locale $wp_locale WordPress date and time locale object.
* @global wpdb $wpdb WordPress database abstraction object.
@@ -430,6 +431,30 @@ function wp_default_packages_inline_scripts( $scripts ) {
'future' => __( '%s from now' ),
/* translators: %s: Duration. */
'past' => __( '%s ago' ),
+ /* translators: One second from or to a particular datetime, e.g., "a second ago" or "a second from now". */
+ 's' => __( 'a second' ),
+ /* translators: %s: Duration in seconds from or to a particular datetime, e.g., "4 seconds ago" or "4 seconds from now". */
+ 'ss' => __( '%d seconds' ),
+ /* translators: One minute from or to a particular datetime, e.g., "a minute ago" or "a minute from now". */
+ 'm' => __( 'a minute' ),
+ /* translators: %s: Duration in minutes from or to a particular datetime, e.g., "4 minutes ago" or "4 minutes from now". */
+ 'mm' => __( '%d minutes' ),
+ /* translators: %s: One hour from or to a particular datetime, e.g., "an hour ago" or "an hour from now". */
+ 'h' => __( 'an hour' ),
+ /* translators: %s: Duration in hours from or to a particular datetime, e.g., "4 hours ago" or "4 hours from now". */
+ 'hh' => __( '%d hours' ),
+ /* translators: %s: One day from or to a particular datetime, e.g., "a day ago" or "a day from now". */
+ 'd' => __( 'a day' ),
+ /* translators: %s: Duration in days from or to a particular datetime, e.g., "4 days ago" or "4 days from now". */
+ 'dd' => __( '%d days' ),
+ /* translators: %s: One month from or to a particular datetime, e.g., "a month ago" or "a month from now". */
+ 'M' => __( 'a month' ),
+ /* translators: %s: Duration in months from or to a particular datetime, e.g., "4 months ago" or "4 months from now". */
+ 'MM' => __( '%d months' ),
+ /* translators: %s: One year from or to a particular datetime, e.g., "a year ago" or "a year from now". */
+ 'y' => __( 'a year' ),
+ /* translators: %s: Duration in years from or to a particular datetime, e.g., "4 years ago" or "4 years from now". */
+ 'yy' => __( '%d years' ),
),
'startOfWeek' => (int) get_option( 'start_of_week', 0 ),
),
From a023fbce186748782d89c6180009fd4df569fda8 Mon Sep 17 00:00:00 2001
From: Jb Audras
Date: Wed, 30 Aug 2023 22:30:06 +0000
Subject: [PATCH 012/105] Upload: Add a MIME type exception for `.docx`
generated by Google Docs.
This changeset adds an exception to prevent permission issues on `.docx` generated by Google Docs. This is a temporary fix for an upstream bug on the `finfo_file()`
PHP function which returns a redundant MIME type for these documents.
Props winterstreet, jakariaistauk, mujuonly, mi5t4n, annashopina, audrasjb, azaozz, mikeschroder, oglekler.
Fixes #57898.
git-svn-id: https://develop.svn.wordpress.org/trunk@56497 602fd350-edb4-49c9-b593-d223f7449a82
---
src/wp-includes/functions.php | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
index be03264455331..dfe8af43350be 100644
--- a/src/wp-includes/functions.php
+++ b/src/wp-includes/functions.php
@@ -3150,6 +3150,11 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
$real_mime = finfo_file( $finfo, $file );
finfo_close( $finfo );
+ // finfo_file() returns redudant mime type for Google docs, see #57898.
+ if ( 'application/vnd.openxmlformats-officedocument.wordprocessingml.documentapplication/vnd.openxmlformats-officedocument.wordprocessingml.document' === $real_mime ) {
+ $real_mime = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
+ }
+
// fileinfo often misidentifies obscure files as one of these types.
$nonspecific_types = array(
'application/octet-stream',
From 9879434020b7acf9c10dad2593b9658737c11516 Mon Sep 17 00:00:00 2001
From: Sergey Biryukov
Date: Thu, 31 Aug 2023 10:15:42 +0000
Subject: [PATCH 013/105] Build/Test Tools: Enable running the tests on PHP
8.3.
PHP 8.3 is expected to be released at the end of November 2023.
Enabling the tests to run in CI on PHP 8.3 allows WordPress core to start getting ready.
Note: Xdebug-related tests will not be run on PHP 8.3 at this time as the Docker image for PHP 8.3 does not contain Xdebug yet. Once a stable release of Xdebug 3.3.0 is available, it can be added to the Docker image and the test step can then be enabled for PHP 8.3.
Follow-up to [53922], [56492], [56495].
Props jrf, costdev.
See #59231.
git-svn-id: https://develop.svn.wordpress.org/trunk@56498 602fd350-edb4-49c9-b593-d223f7449a82
---
.github/workflows/phpunit-tests-run.yml | 1 +
.github/workflows/phpunit-tests.yml | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/phpunit-tests-run.yml b/.github/workflows/phpunit-tests-run.yml
index 843a950481f19..af03911f4ac08 100644
--- a/.github/workflows/phpunit-tests-run.yml
+++ b/.github/workflows/phpunit-tests-run.yml
@@ -165,6 +165,7 @@ jobs:
# __fakegroup__ is excluded to force PHPUnit to ignore the settings in phpunit.xml.dist.
- name: Run (Xdebug) tests
+ if: ${{ inputs.php != '8.3' }}
run: LOCAL_PHP_XDEBUG=true node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit -v --group xdebug --exclude-group __fakegroup__
- name: Ensure version-controlled files are not modified or deleted
diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml
index 9c399d51ed791..7edf91608093c 100644
--- a/.github/workflows/phpunit-tests.yml
+++ b/.github/workflows/phpunit-tests.yml
@@ -45,7 +45,7 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
- php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' ]
+ php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
db-type: [ 'mysql' ]
db-version: [ '5.7', '8.0' ]
multisite: [ false, true ]
@@ -97,7 +97,7 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
- php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' ]
+ php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
db-type: [ 'mariadb' ]
db-version: [ '10.4', '10.6', '10.11', '11.0' ]
multisite: [ false, true ]
From 54a177910a80083930ee1284f648c1db5bf2e5c0 Mon Sep 17 00:00:00 2001
From: Jb Audras
Date: Thu, 31 Aug 2023 14:43:36 +0000
Subject: [PATCH 014/105] Coding Standards: Remove unused global variables in
various `/wp-admin/includes/` files.
Props upadalavipul.
Fixes #59254.
git-svn-id: https://develop.svn.wordpress.org/trunk@56499 602fd350-edb4-49c9-b593-d223f7449a82
---
src/wp-admin/includes/class-wp-privacy-policy-content.php | 4 ----
src/wp-admin/includes/ms.php | 4 ----
src/wp-admin/includes/upgrade.php | 3 +--
3 files changed, 1 insertion(+), 10 deletions(-)
diff --git a/src/wp-admin/includes/class-wp-privacy-policy-content.php b/src/wp-admin/includes/class-wp-privacy-policy-content.php
index 46b10e15f6b66..aa72b21aa7470 100644
--- a/src/wp-admin/includes/class-wp-privacy-policy-content.php
+++ b/src/wp-admin/includes/class-wp-privacy-policy-content.php
@@ -130,12 +130,8 @@ public static function text_change_check() {
* Outputs a warning when some privacy info has changed.
*
* @since 4.9.6
- *
- * @global WP_Post $post Global post object.
*/
public static function policy_text_changed_notice() {
- global $post;
-
$screen = get_current_screen()->id;
if ( 'privacy' !== $screen ) {
diff --git a/src/wp-admin/includes/ms.php b/src/wp-admin/includes/ms.php
index c769375b4b017..1e38133a3f3d8 100644
--- a/src/wp-admin/includes/ms.php
+++ b/src/wp-admin/includes/ms.php
@@ -58,14 +58,10 @@ function check_upload_size( $file ) {
* @since 3.0.0
* @since 5.1.0 Use wp_delete_site() internally to delete the site row from the database.
*
- * @global wpdb $wpdb WordPress database abstraction object.
- *
* @param int $blog_id Site ID.
* @param bool $drop True if site's database tables should be dropped. Default false.
*/
function wpmu_delete_blog( $blog_id, $drop = false ) {
- global $wpdb;
-
$blog_id = (int) $blog_id;
$switch = false;
diff --git a/src/wp-admin/includes/upgrade.php b/src/wp-admin/includes/upgrade.php
index 23653d1c2b46c..39455ad425c30 100644
--- a/src/wp-admin/includes/upgrade.php
+++ b/src/wp-admin/includes/upgrade.php
@@ -625,10 +625,9 @@ function wp_new_blog_notification( $blog_title, $blog_url, $user_id, $password )
*
* @global int $wp_current_db_version The old (current) database version.
* @global int $wp_db_version The new database version.
- * @global wpdb $wpdb WordPress database abstraction object.
*/
function wp_upgrade() {
- global $wp_current_db_version, $wp_db_version, $wpdb;
+ global $wp_current_db_version, $wp_db_version;
$wp_current_db_version = __get_option( 'db_version' );
From c29b095e762836e47df9080d670c2f6570d6cd12 Mon Sep 17 00:00:00 2001
From: Tonya Mork
Date: Thu, 31 Aug 2023 21:47:40 +0000
Subject: [PATCH 015/105] Introduce font-face styles generator and printer.
Introducing Font Face, a server-side `@font-face` styles generator and printer.
tl;dr:
* Introduces Font Face.
* Deprecates `_wp_theme_json_webfonts_handler()`.
**Introduce Font Face**
From an array of fonts (i.e. each font-family and its font variations to be processed), it:
1. Validates each `font-face` declaration, i.e. the CSS property and value pairing. If validation fails, processing stops with no font-face styles printed.
3. Generates the `@font-face` CSS for each font-family.
4. Prints the CSS within a ` and open a
+
+CSS;
+ $this->expectOutputString( $expected_output );
+
+ wp_print_font_faces( $fonts );
+ }
+
+ public function test_should_print_fonts_in_merged_data() {
+ switch_theme( static::FONTS_THEME );
+
+ $expected = $this->get_expected_fonts_for_fonts_block_theme( 'font_face_styles' );
+ $expected_output = $this->get_expected_styles_output( $expected );
+
+ $this->expectOutputString( $expected_output );
+ wp_print_font_faces();
+ }
+
+ private function get_expected_styles_output( $styles ) {
+ $style_element = "\n";
+ return sprintf( $style_element, $styles );
+ }
+}
diff --git a/tests/phpunit/tests/theme/themeDir.php b/tests/phpunit/tests/theme/themeDir.php
index ea721e5a4494c..73cf63539e58f 100644
--- a/tests/phpunit/tests/theme/themeDir.php
+++ b/tests/phpunit/tests/theme/themeDir.php
@@ -185,7 +185,7 @@ public function test_theme_list() {
'Block Theme [0.4.0]',
'Block Theme [1.0.0] in subdirectory',
'Block Theme Deprecated Path',
- 'Webfonts theme',
+ 'Block Theme with defined Typography Fonts',
'Empty `fontFace` in theme.json - no webfonts defined',
'A theme with the Update URI header',
);
From 13531cc3bdcdc912f4025089f14f6ac33469fc32 Mon Sep 17 00:00:00 2001
From: Tonya Mork
Date: Thu, 31 Aug 2023 22:16:05 +0000
Subject: [PATCH 016/105] Tests: Remove webfonts tests.
Removes the test file and `webfonts` directory for the stopgap code that was deprecated by [56500].
Follow-up to [56500], [53282].
Fixes #59165.
git-svn-id: https://develop.svn.wordpress.org/trunk@56501 602fd350-edb4-49c9-b593-d223f7449a82
---
.../webfonts/wpThemeJsonWebfontsHandler.php | 138 ------------------
1 file changed, 138 deletions(-)
delete mode 100644 tests/phpunit/tests/webfonts/wpThemeJsonWebfontsHandler.php
diff --git a/tests/phpunit/tests/webfonts/wpThemeJsonWebfontsHandler.php b/tests/phpunit/tests/webfonts/wpThemeJsonWebfontsHandler.php
deleted file mode 100644
index 7202417ddee93..0000000000000
--- a/tests/phpunit/tests/webfonts/wpThemeJsonWebfontsHandler.php
+++ /dev/null
@@ -1,138 +0,0 @@
-orig_wp_styles = $wp_styles;
- $wp_styles = null;
-
- $this->theme_root = realpath( DIR_TESTDATA . '/themedir1' );
- $this->orig_theme_dir = $GLOBALS['wp_theme_directories'];
-
- // /themes is necessary as theme.php functions assume /themes is the root if there is only one root.
- $GLOBALS['wp_theme_directories'] = array( WP_CONTENT_DIR . '/themes', $this->theme_root );
-
- $theme_root_callback = function () {
- return $this->theme_root;
- };
-
- add_filter( 'theme_root', $theme_root_callback );
- add_filter( 'stylesheet_root', $theme_root_callback );
- add_filter( 'template_root', $theme_root_callback );
-
- // Clear caches.
- wp_clean_themes_cache();
- unset( $GLOBALS['wp_themes'] );
- }
-
- public function tear_down() {
- global $wp_styles;
- $wp_styles = $this->orig_wp_styles;
-
- // Restore the original theme directory setup.
- $GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
- wp_clean_themes_cache();
- unset( $GLOBALS['wp_themes'] );
-
- parent::tear_down();
- }
-
- /**
- * @ticket 55567
- * @ticket 46370
- * @ticket 57430
- */
- public function test_font_face_generated_from_themejson() {
- $this->setup_theme_and_test( 'webfonts-theme' );
-
- $expected = <<
-@font-face{font-family:"Source Serif Pro";font-style:normal;font-weight:200 900;font-display:fallback;src:url('THEME_ROOT_URL/assets/fonts/SourceSerif4Variable-Roman.ttf.woff2') format('woff2');font-stretch:normal;}@font-face{font-family:"Source Serif Pro";font-style:italic;font-weight:200 900;font-display:fallback;src:url('THEME_ROOT_URL/assets/fonts/SourceSerif4Variable-Italic.ttf.woff2') format('woff2');font-stretch:normal;}
-
-EOF;
- $expected = str_replace( 'THEME_ROOT_URL', get_stylesheet_directory_uri(), $expected );
- $expected = str_replace( "\r\n", "\n", $expected );
-
- $this->assertStringContainsString(
- $expected,
- get_echo( 'wp_print_styles' )
- );
- }
-
- /**
- * @dataProvider data_font_face_not_generated
- *
- * @ticket 55567
- * @ticket 46370
- */
- public function test_font_face_not_generated( $theme_name ) {
- $this->setup_theme_and_test( $theme_name );
-
- $actual = get_echo( 'wp_print_styles' );
- $this->assertStringNotContainsString( "' === strtolower( $piece )
)
) {
- $nested_code_pre--;
+ --$nested_code_pre;
}
if ( $nested_code_pre
@@ -5354,7 +5354,7 @@ function wp_sprintf_l( $pattern, $args ) {
$i = count( $args );
while ( $i ) {
$arg = array_shift( $args );
- $i--;
+ --$i;
if ( 0 === $i ) {
$result .= $l['between_last_two'] . $arg;
} else {
diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
index 4a2a2b1779f2d..6963de3a3831d 100644
--- a/src/wp-includes/functions.php
+++ b/src/wp-includes/functions.php
@@ -2696,7 +2696,7 @@ function wp_unique_filename( $dir, $filename, $unique_filename_callback = null )
);
$number = $new_number;
- $i++;
+ ++$i;
}
}
}
@@ -2769,7 +2769,7 @@ function wp_unique_filename( $dir, $filename, $unique_filename_callback = null )
);
$number = $new_number;
- $i++;
+ ++$i;
}
}
}
@@ -7163,7 +7163,7 @@ function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pr
$trace = debug_backtrace( false );
$caller = array();
$check_class = ! is_null( $ignore_class );
- $skip_frames++; // Skip this function.
+ ++$skip_frames; // Skip this function.
if ( ! isset( $truncate_paths ) ) {
$truncate_paths = array(
@@ -7174,7 +7174,7 @@ function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pr
foreach ( $trace as $call ) {
if ( $skip_frames > 0 ) {
- $skip_frames--;
+ --$skip_frames;
} elseif ( isset( $call['class'] ) ) {
if ( $check_class && $ignore_class === $call['class'] ) {
continue; // Filter out calls.
diff --git a/src/wp-includes/html-api/class-wp-html-tag-processor.php b/src/wp-includes/html-api/class-wp-html-tag-processor.php
index 2e84b3d7193a0..541b5baf0bfbe 100644
--- a/src/wp-includes/html-api/class-wp-html-tag-processor.php
+++ b/src/wp-includes/html-api/class-wp-html-tag-processor.php
@@ -951,7 +951,7 @@ private function parse_next_tag() {
if ( '/' === $this->html[ $at + 1 ] ) {
$this->is_closing_tag = true;
- $at++;
+ ++$at;
} else {
$this->is_closing_tag = false;
}
@@ -1020,7 +1020,7 @@ private function parse_next_tag() {
*
* See https://html.spec.whatwg.org/#parse-error-incorrectly-closed-comment
*/
- $closer_at--; // Pre-increment inside condition below reduces risk of accidental infinite looping.
+ --$closer_at; // Pre-increment inside condition below reduces risk of accidental infinite looping.
while ( ++$closer_at < strlen( $html ) ) {
$closer_at = strpos( $html, '--', $closer_at );
if ( false === $closer_at ) {
@@ -1101,7 +1101,7 @@ private function parse_next_tag() {
* See https://html.spec.whatwg.org/#parse-error-missing-end-tag-name
*/
if ( '>' === $html[ $at + 1 ] ) {
- $at++;
+ ++$at;
continue;
}
diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php
index d365e0b1e1915..dd98b5e622b7d 100644
--- a/src/wp-includes/media.php
+++ b/src/wp-includes/media.php
@@ -2552,7 +2552,7 @@ function gallery_shortcode( $attr ) {
$post = get_post();
static $instance = 0;
- $instance++;
+ ++$instance;
if ( ! empty( $attr['ids'] ) ) {
// 'ids' is explicitly ordered, unless you specify otherwise.
@@ -2899,7 +2899,7 @@ function wp_playlist_shortcode( $attr ) {
$post = get_post();
static $instance = 0;
- $instance++;
+ ++$instance;
if ( ! empty( $attr['ids'] ) ) {
// 'ids' is explicitly ordered, unless you specify otherwise.
@@ -3213,7 +3213,7 @@ function wp_audio_shortcode( $attr, $content = '' ) {
$post_id = get_post() ? get_the_ID() : 0;
static $instance = 0;
- $instance++;
+ ++$instance;
/**
* Filters the default audio shortcode output.
@@ -3432,7 +3432,7 @@ function wp_video_shortcode( $attr, $content = '' ) {
$post_id = get_post() ? get_the_ID() : 0;
static $instance = 0;
- $instance++;
+ ++$instance;
/**
* Filters the default video shortcode output.
diff --git a/src/wp-includes/ms-site.php b/src/wp-includes/ms-site.php
index eaee99f5685c2..65e7d8d78d57d 100644
--- a/src/wp-includes/ms-site.php
+++ b/src/wp-includes/ms-site.php
@@ -877,7 +877,7 @@ function wp_uninitialize_site( $site_id ) {
}
@closedir( $dh );
}
- $index++;
+ ++$index;
}
$stack = array_reverse( $stack ); // Last added directories are deepest.
diff --git a/src/wp-includes/pomo/mo.php b/src/wp-includes/pomo/mo.php
index dec51cee31310..1bbc40ab65aa2 100644
--- a/src/wp-includes/pomo/mo.php
+++ b/src/wp-includes/pomo/mo.php
@@ -129,7 +129,7 @@ public function export_to_file_handle( $fh ) {
// Headers' msgid is an empty string.
fwrite( $fh, pack( 'VV', 0, $current_addr ) );
- $current_addr++;
+ ++$current_addr;
$originals_table = "\0";
$reader = new POMO_Reader();
diff --git a/src/wp-includes/pomo/plural-forms.php b/src/wp-includes/pomo/plural-forms.php
index b072bfadac002..ae9c306d989a8 100644
--- a/src/wp-includes/pomo/plural-forms.php
+++ b/src/wp-includes/pomo/plural-forms.php
@@ -110,19 +110,19 @@ protected function parse( $str ) {
// Ignore whitespace.
case ' ':
case "\t":
- $pos++;
+ ++$pos;
break;
// Variable (n).
case 'n':
$output[] = array( 'var' );
- $pos++;
+ ++$pos;
break;
// Parentheses.
case '(':
$stack[] = $next;
- $pos++;
+ ++$pos;
break;
case ')':
@@ -144,7 +144,7 @@ protected function parse( $str ) {
throw new Exception( 'Mismatched parentheses' );
}
- $pos++;
+ ++$pos;
break;
// Operators.
@@ -189,7 +189,7 @@ protected function parse( $str ) {
$o2 = $stack[ $s_pos ];
if ( '?' !== $o2 ) {
$output[] = array( 'op', array_pop( $stack ) );
- $s_pos--;
+ --$s_pos;
continue;
}
@@ -202,7 +202,7 @@ protected function parse( $str ) {
if ( ! $found ) {
throw new Exception( 'Missing starting "?" ternary operator' );
}
- $pos++;
+ ++$pos;
break;
// Default - number or invalid.
@@ -264,7 +264,7 @@ public function execute( $n ) {
$total = count( $this->tokens );
while ( $i < $total ) {
$next = $this->tokens[ $i ];
- $i++;
+ ++$i;
if ( 'var' === $next[0] ) {
$stack[] = $n;
continue;
diff --git a/src/wp-includes/pomo/po.php b/src/wp-includes/pomo/po.php
index 89d827c2550b9..7b9ec0b88bb2c 100644
--- a/src/wp-includes/pomo/po.php
+++ b/src/wp-includes/pomo/po.php
@@ -342,7 +342,7 @@ public function read_entry( $f, $lineno = 0 ) {
$context = '';
$msgstr_index = 0;
while ( true ) {
- $lineno++;
+ ++$lineno;
$line = PO::read_line( $f );
if ( ! $line ) {
if ( feof( $f ) ) {
@@ -365,7 +365,7 @@ public function read_entry( $f, $lineno = 0 ) {
// The comment is the start of a new entry.
if ( self::is_final( $context ) ) {
PO::read_line( $f, 'put-back' );
- $lineno--;
+ --$lineno;
break;
}
// Comments have to be at the beginning.
@@ -377,7 +377,7 @@ public function read_entry( $f, $lineno = 0 ) {
} elseif ( preg_match( '/^msgctxt\s+(".*")/', $line, $m ) ) {
if ( self::is_final( $context ) ) {
PO::read_line( $f, 'put-back' );
- $lineno--;
+ --$lineno;
break;
}
if ( $context && 'comment' !== $context ) {
@@ -388,7 +388,7 @@ public function read_entry( $f, $lineno = 0 ) {
} elseif ( preg_match( '/^msgid\s+(".*")/', $line, $m ) ) {
if ( self::is_final( $context ) ) {
PO::read_line( $f, 'put-back' );
- $lineno--;
+ --$lineno;
break;
}
if ( $context && 'msgctxt' !== $context && 'comment' !== $context ) {
diff --git a/src/wp-includes/pomo/translations.php b/src/wp-includes/pomo/translations.php
index d3a1d3cbd09a9..a5534a8ea9d02 100644
--- a/src/wp-includes/pomo/translations.php
+++ b/src/wp-includes/pomo/translations.php
@@ -261,7 +261,7 @@ public function parenthesize_plural_exression( $expression ) {
switch ( $char ) {
case '?':
$res .= ' ? (';
- $depth++;
+ ++$depth;
break;
case ':':
$res .= ') : (';
diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php
index 5d7aee24ee663..2a8d6b41f6844 100644
--- a/src/wp-includes/post.php
+++ b/src/wp-includes/post.php
@@ -5073,7 +5073,7 @@ function wp_unique_post_slug( $slug, $post_id, $post_status, $post_type, $post_p
do {
$alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_id ) );
- $suffix++;
+ ++$suffix;
} while ( $post_name_check );
$slug = $alt_post_name;
}
@@ -5110,7 +5110,7 @@ function wp_unique_post_slug( $slug, $post_id, $post_status, $post_type, $post_p
do {
$alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_id, $post_parent ) );
- $suffix++;
+ ++$suffix;
} while ( $post_name_check );
$slug = $alt_post_name;
}
@@ -5166,7 +5166,7 @@ function wp_unique_post_slug( $slug, $post_id, $post_status, $post_type, $post_p
do {
$alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_id ) );
- $suffix++;
+ ++$suffix;
} while ( $post_name_check );
$slug = $alt_post_name;
}
@@ -5758,7 +5758,7 @@ function get_page_by_path( $page_path, $output = OBJECT, $post_type = 'page' ) {
* ensuring each matches the post ancestry.
*/
while ( 0 != $p->post_parent && isset( $pages[ $p->post_parent ] ) ) {
- $count++;
+ ++$count;
$parent = $pages[ $p->post_parent ];
if ( ! isset( $revparts[ $count ] ) || $parent->post_name != $revparts[ $count ] ) {
break;
diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php
index 52a5705331798..3eb36552e618f 100644
--- a/src/wp-includes/taxonomy.php
+++ b/src/wp-includes/taxonomy.php
@@ -3090,7 +3090,7 @@ function wp_unique_term_slug( $slug, $term ) {
$num = 2;
do {
$alt_slug = $slug . "-$num";
- $num++;
+ ++$num;
$slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug ) );
} while ( $slug_check );
$slug = $alt_slug;
diff --git a/src/wp-includes/theme-templates.php b/src/wp-includes/theme-templates.php
index 114d7205d470c..2f233ca1d1946 100644
--- a/src/wp-includes/theme-templates.php
+++ b/src/wp-includes/theme-templates.php
@@ -90,7 +90,7 @@ function wp_filter_wp_template_unique_post_slug( $override_slug, $slug, $post_id
$alt_post_name = _truncate_post_slug( $override_slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
$query_args['post_name__in'] = array( $alt_post_name );
$query = new WP_Query( $query_args );
- $suffix++;
+ ++$suffix;
} while ( count( $query->posts ) > 0 );
$override_slug = $alt_post_name;
}
diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php
index 5f8fe3807154e..aaba3a7e7e095 100644
--- a/src/wp-includes/user.php
+++ b/src/wp-includes/user.php
@@ -1316,11 +1316,11 @@ function count_users( $strategy = 'time', $site_id = null ) {
continue;
}
if ( empty( $b_roles ) ) {
- $avail_roles['none']++;
+ ++$avail_roles['none'];
}
foreach ( $b_roles as $b_role => $val ) {
if ( isset( $avail_roles[ $b_role ] ) ) {
- $avail_roles[ $b_role ]++;
+ ++$avail_roles[ $b_role ];
} else {
$avail_roles[ $b_role ] = 1;
}
@@ -2177,7 +2177,7 @@ function wp_insert_user( $userdata ) {
$base_length = 49 - mb_strlen( $suffix );
$alt_user_nicename = mb_substr( $user_nicename, 0, $base_length ) . "-$suffix";
$user_nicename_check = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1", $alt_user_nicename, $user_login ) );
- $suffix++;
+ ++$suffix;
}
$user_nicename = $alt_user_nicename;
}
diff --git a/src/wp-includes/widgets/class-wp-widget-calendar.php b/src/wp-includes/widgets/class-wp-widget-calendar.php
index 6ab373fc42fe4..9103934173f8e 100644
--- a/src/wp-includes/widgets/class-wp-widget-calendar.php
+++ b/src/wp-includes/widgets/class-wp-widget-calendar.php
@@ -66,7 +66,7 @@ public function widget( $args, $instance ) {
echo '';
echo $args['after_widget'];
- self::$instance++;
+ ++self::$instance;
}
/**
diff --git a/src/wp-includes/widgets/class-wp-widget-media.php b/src/wp-includes/widgets/class-wp-widget-media.php
index ebca22ec66955..2352ae837b05a 100644
--- a/src/wp-includes/widgets/class-wp-widget-media.php
+++ b/src/wp-includes/widgets/class-wp-widget-media.php
@@ -373,7 +373,7 @@ public function display_media_state( $states, $post = null ) {
$use_count = 0;
foreach ( $this->get_settings() as $instance ) {
if ( isset( $instance['attachment_id'] ) && $instance['attachment_id'] === $post->ID ) {
- $use_count++;
+ ++$use_count;
}
}
diff --git a/tests/phpunit/includes/factory/class-wp-unittest-generator-sequence.php b/tests/phpunit/includes/factory/class-wp-unittest-generator-sequence.php
index 9391dd8bf7d9c..6412c15db7d8d 100644
--- a/tests/phpunit/includes/factory/class-wp-unittest-generator-sequence.php
+++ b/tests/phpunit/includes/factory/class-wp-unittest-generator-sequence.php
@@ -9,7 +9,7 @@ public function __construct( $template_string = '%s', $start = null ) {
if ( $start ) {
$this->next = $start;
} else {
- self::$incr++;
+ ++self::$incr;
$this->next = self::$incr;
}
$this->template_string = $template_string;
@@ -17,7 +17,7 @@ public function __construct( $template_string = '%s', $start = null ) {
public function next() {
$generated = sprintf( $this->template_string, $this->next );
- $this->next++;
+ ++$this->next;
return $generated;
}
diff --git a/tests/phpunit/includes/testcase-rest-post-type-controller.php b/tests/phpunit/includes/testcase-rest-post-type-controller.php
index 0fc03ef5ec621..cd8ccaefc7b14 100644
--- a/tests/phpunit/includes/testcase-rest-post-type-controller.php
+++ b/tests/phpunit/includes/testcase-rest-post-type-controller.php
@@ -193,7 +193,7 @@ protected function check_post_data( $post, $data, $context, $links ) {
foreach ( $taxonomies as $key => $taxonomy ) {
$this->assertSame( $taxonomy->name, $links['https://api.w.org/term'][ $num ]['attributes']['taxonomy'] );
$this->assertSame( add_query_arg( 'post', $data['id'], rest_url( 'wp/v2/' . $taxonomy->rest_base ) ), $links['https://api.w.org/term'][ $num ]['href'] );
- $num++;
+ ++$num;
}
}
}
diff --git a/tests/phpunit/includes/wp-profiler.php b/tests/phpunit/includes/wp-profiler.php
index 293f85645d779..5c4ea902d095c 100644
--- a/tests/phpunit/includes/wp-profiler.php
+++ b/tests/phpunit/includes/wp-profiler.php
@@ -72,7 +72,7 @@ public function stop() {
if ( isset( $this->profile[ $name ] ) ) {
$this->profile[ $name ]['time'] += $time;
- $this->profile[ $name ]['calls']++;
+ ++$this->profile[ $name ]['calls'];
$this->profile[ $name ]['cache_cold_hits'] += ( $wp_object_cache->cold_cache_hits - $item['cache_cold_hits'] );
$this->profile[ $name ]['cache_warm_hits'] += ( $wp_object_cache->warm_cache_hits - $item['cache_warm_hits'] );
$this->profile[ $name ]['cache_misses'] += ( $wp_object_cache->cache_misses - $item['cache_misses'] );
@@ -113,9 +113,9 @@ public function log_filter( $tag ) {
if ( $this->stack ) {
global $wp_actions;
if ( end( $wp_actions ) === $tag ) {
- $this->stack[ count( $this->stack ) - 1 ]['actions'][ $tag ]++;
+ ++$this->stack[ count( $this->stack ) - 1 ]['actions'][ $tag ];
} else {
- $this->stack[ count( $this->stack ) - 1 ]['filters'][ $tag ]++;
+ ++$this->stack[ count( $this->stack ) - 1 ]['filters'][ $tag ];
}
}
return $arg;
@@ -123,7 +123,7 @@ public function log_filter( $tag ) {
public function log_action( $tag ) {
if ( $this->stack ) {
- $this->stack[ count( $this->stack ) - 1 ]['actions'][ $tag ]++;
+ ++$this->stack[ count( $this->stack ) - 1 ]['actions'][ $tag ];
}
}
@@ -142,7 +142,7 @@ public function _query_summary( $queries, &$out ) {
$sql = preg_replace( '/(WHERE \w+ =) \d+/', '$1 x', $sql );
$sql = preg_replace( '/(WHERE \w+ =) \'\[-\w]+\'/', '$1 \'xxx\'', $sql );
- $out[ $sql ]++;
+ ++$out[ $sql ];
}
asort( $out );
return;
@@ -153,9 +153,9 @@ public function _query_count( $queries ) {
$out = array();
foreach ( $queries as $q ) {
if ( empty( $q[2] ) ) {
- $out['unknown']++;
+ ++$out['unknown'];
} else {
- $out[ $q[2] ]++;
+ ++$out[ $q[2] ];
}
}
return $out;
diff --git a/tests/phpunit/tests/blocks/wpBlockList.php b/tests/phpunit/tests/blocks/wpBlockList.php
index 2194bc5a98733..48b040e918f82 100644
--- a/tests/phpunit/tests/blocks/wpBlockList.php
+++ b/tests/phpunit/tests/blocks/wpBlockList.php
@@ -71,10 +71,10 @@ public function test_iterable() {
foreach ( $blocks as $block ) {
$this->assertSame( 'core/example', $block->name );
- $assertions++;
+ ++$assertions;
foreach ( $block->inner_blocks as $inner_block ) {
$this->assertSame( 'core/example', $inner_block->name );
- $assertions++;
+ ++$assertions;
}
}
@@ -83,9 +83,9 @@ public function test_iterable() {
$key = $blocks->key();
$block = $blocks->current();
$this->assertSame( 0, $key );
- $assertions++;
+ ++$assertions;
$this->assertSame( 'core/example', $block->name );
- $assertions++;
+ ++$assertions;
$blocks->next();
}
diff --git a/tests/phpunit/tests/comment/metaCache.php b/tests/phpunit/tests/comment/metaCache.php
index 5a6d716e914e8..828363e580544 100644
--- a/tests/phpunit/tests/comment/metaCache.php
+++ b/tests/phpunit/tests/comment/metaCache.php
@@ -243,7 +243,7 @@ public function test_comment_meta_should_be_lazy_loaded_in_comment_feed_queries(
// First comment will cause the cache to be primed.
$num_queries = get_num_queries();
$this->assertSame( 'bar', get_comment_meta( $comments[0], 'foo', 'bar' ) );
- $num_queries++;
+ ++$num_queries;
$this->assertSame( $num_queries, get_num_queries() );
// Second comment from the results should not cause more queries.
@@ -252,7 +252,7 @@ public function test_comment_meta_should_be_lazy_loaded_in_comment_feed_queries(
// A comment from outside the results will not be primed.
$this->assertSame( 'bar', get_comment_meta( $comments[4], 'foo', 'bar' ) );
- $num_queries++;
+ ++$num_queries;
$this->assertSame( $num_queries, get_num_queries() );
}
@@ -293,7 +293,7 @@ public function test_comment_meta_should_be_lazy_loaded_in_single_post_comment_f
// First comment will cause the cache to be primed.
$num_queries = get_num_queries();
$this->assertSame( 'bar', get_comment_meta( $comments[0], 'foo', 'bar' ) );
- $num_queries++;
+ ++$num_queries;
$this->assertSame( $num_queries, get_num_queries() );
// Second comment from the results should not cause more queries.
@@ -302,7 +302,7 @@ public function test_comment_meta_should_be_lazy_loaded_in_single_post_comment_f
// A comment from outside the results will not be primed.
$this->assertSame( 'bar', get_comment_meta( $comments[4], 'foo', 'bar' ) );
- $num_queries++;
+ ++$num_queries;
$this->assertSame( $num_queries, get_num_queries() );
}
diff --git a/tests/phpunit/tests/comment/query.php b/tests/phpunit/tests/comment/query.php
index 65f9af6253e13..50cd9107960ca 100644
--- a/tests/phpunit/tests/comment/query.php
+++ b/tests/phpunit/tests/comment/query.php
@@ -4769,7 +4769,7 @@ public function test_updated_comment_should_invalidate_query_cache() {
)
);
- $num_queries++;
+ ++$num_queries;
$this->assertSame( $num_queries, get_num_queries() );
$this->assertSameSets( array( $c ), $q->comments );
}
@@ -4805,7 +4805,7 @@ public function test_deleted_comment_should_invalidate_query_cache() {
)
);
- $num_queries++;
+ ++$num_queries;
$this->assertSame( $num_queries, get_num_queries() );
$this->assertSameSets( array(), $q->comments );
}
@@ -4841,7 +4841,7 @@ public function test_trashed_comment_should_invalidate_query_cache() {
)
);
- $num_queries++;
+ ++$num_queries;
$this->assertSame( $num_queries, get_num_queries() );
$this->assertSameSets( array(), $q->comments );
}
@@ -4879,7 +4879,7 @@ public function test_untrashed_comment_should_invalidate_query_cache() {
)
);
- $num_queries++;
+ ++$num_queries;
$this->assertSame( $num_queries, get_num_queries() );
$this->assertSameSets( array( $c ), $q->comments );
}
@@ -4915,7 +4915,7 @@ public function test_spammed_comment_should_invalidate_query_cache() {
)
);
- $num_queries++;
+ ++$num_queries;
$this->assertSame( $num_queries, get_num_queries() );
$this->assertSameSets( array(), $q->comments );
}
@@ -4953,7 +4953,7 @@ public function test_unspammed_comment_should_invalidate_query_cache() {
)
);
- $num_queries++;
+ ++$num_queries;
$this->assertSame( $num_queries, get_num_queries() );
$this->assertSameSets( array( $c ), $q->comments );
}
diff --git a/tests/phpunit/tests/date/theDate.php b/tests/phpunit/tests/date/theDate.php
index 2337ab61ec059..fffcb47ad5665 100644
--- a/tests/phpunit/tests/date/theDate.php
+++ b/tests/phpunit/tests/date/theDate.php
@@ -80,7 +80,7 @@ public function test_should_call_hooks() {
}
public function count_hook( $input ) {
- $this->hooks_called[ current_filter() ]++;
+ ++$this->hooks_called[ current_filter() ];
return $input;
}
diff --git a/tests/phpunit/tests/feed/atom.php b/tests/phpunit/tests/feed/atom.php
index 403f1152a46b2..dae234f51caf5 100644
--- a/tests/phpunit/tests/feed/atom.php
+++ b/tests/phpunit/tests/feed/atom.php
@@ -287,7 +287,7 @@ public function test_atom_enclosure_with_extended_url_length_type_parsing() {
$this->assertSame( $enclosures[ $i ]['expected']['href'], $link['attributes']['href'] );
$this->assertEquals( $enclosures[ $i ]['expected']['length'], $link['attributes']['length'] );
$this->assertSame( $enclosures[ $i ]['expected']['type'], $link['attributes']['type'] );
- $i++;
+ ++$i;
}
}
}
diff --git a/tests/phpunit/tests/import/base.php b/tests/phpunit/tests/import/base.php
index db83296c0afcb..d0fefb1a925ec 100644
--- a/tests/phpunit/tests/import/base.php
+++ b/tests/phpunit/tests/import/base.php
@@ -42,7 +42,7 @@ protected function _import_wp( $filename, $users = array(), $fetch_files = true
$new[ $i ] = $map;
}
- $i++;
+ ++$i;
}
$_POST = array(
diff --git a/tests/phpunit/tests/multisite/network.php b/tests/phpunit/tests/multisite/network.php
index db1f35b6d0466..c7fb78e54778f 100644
--- a/tests/phpunit/tests/multisite/network.php
+++ b/tests/phpunit/tests/multisite/network.php
@@ -267,7 +267,7 @@ public function test_is_plugin_active_for_network_false() {
}
public function helper_deactivate_hook() {
- $this->plugin_hook_count++;
+ ++$this->plugin_hook_count;
}
public function test_wp_schedule_update_network_counts() {
diff --git a/tests/phpunit/tests/multisite/site.php b/tests/phpunit/tests/multisite/site.php
index 4b201cd912108..aa04499105464 100644
--- a/tests/phpunit/tests/multisite/site.php
+++ b/tests/phpunit/tests/multisite/site.php
@@ -422,7 +422,7 @@ public function test_wpmu_update_blogs_date() {
public function test_get_blog_details_when_site_does_not_exist() {
// Create an unused site so that we can then assume an invalid site ID.
$blog_id = self::factory()->blog->create();
- $blog_id++;
+ ++$blog_id;
// Prime the cache for an invalid site.
get_blog_details( $blog_id );
diff --git a/tests/phpunit/tests/oembed/controller.php b/tests/phpunit/tests/oembed/controller.php
index 238b1faf1fa49..821eeac7e3ab5 100644
--- a/tests/phpunit/tests/oembed/controller.php
+++ b/tests/phpunit/tests/oembed/controller.php
@@ -171,7 +171,7 @@ public function filter_oembed_result( $data, $url, $args ) {
}
$this->assertIsString( $url );
$this->assertIsArray( $args );
- $this->oembed_result_filter_count++;
+ ++$this->oembed_result_filter_count;
return $data;
}
diff --git a/tests/phpunit/tests/pluggable/signatures.php b/tests/phpunit/tests/pluggable/signatures.php
index 84a828d348307..81fd079621916 100644
--- a/tests/phpunit/tests/pluggable/signatures.php
+++ b/tests/phpunit/tests/pluggable/signatures.php
@@ -44,7 +44,7 @@ public function test_pluggable_function_signatures_match( $function_name ) {
$this->assertSame( $name, $param_ref->getName(), $msg );
- $i++;
+ ++$i;
}
}
diff --git a/tests/phpunit/tests/pomo/pluralForms.php b/tests/phpunit/tests/pomo/pluralForms.php
index 0343302c689ef..439064f7c49de 100644
--- a/tests/phpunit/tests/pomo/pluralForms.php
+++ b/tests/phpunit/tests/pomo/pluralForms.php
@@ -21,7 +21,7 @@ protected static function parenthesize_plural_expression( $expression ) {
switch ( $char ) {
case '?':
$res .= ' ? (';
- $depth++;
+ ++$depth;
break;
case ':':
$res .= ') : (';
diff --git a/tests/phpunit/tests/post/getPageByPath.php b/tests/phpunit/tests/post/getPageByPath.php
index 5d26b88d2de19..8db0274249bed 100644
--- a/tests/phpunit/tests/post/getPageByPath.php
+++ b/tests/phpunit/tests/post/getPageByPath.php
@@ -343,7 +343,7 @@ public function test_cache_should_not_match_post_in_different_post_type_with_sam
$found = get_page_by_path( 'foo', OBJECT, 'wptests_pt' );
$this->assertSame( $p2, $found->ID );
- $num_queries++;
+ ++$num_queries;
$this->assertSame( $num_queries, get_num_queries() );
}
@@ -373,7 +373,7 @@ public function test_cache_should_be_invalidated_when_post_name_is_edited() {
$found = get_page_by_path( 'bar' );
$this->assertSame( $page, $found->ID );
- $num_queries++;
+ ++$num_queries;
$this->assertSame( $num_queries, get_num_queries() );
}
diff --git a/tests/phpunit/tests/post/revisions.php b/tests/phpunit/tests/post/revisions.php
index cc17ccd60d5df..8bdcb399b4a46 100644
--- a/tests/phpunit/tests/post/revisions.php
+++ b/tests/phpunit/tests/post/revisions.php
@@ -736,7 +736,7 @@ public function test_wp_get_post_revisions_url( $revisions ) {
)
);
- $latest_revision_id++;
+ ++$latest_revision_id;
}
}
@@ -784,7 +784,7 @@ public function test_wp_get_post_revisions_url_with_post_object( $revisions ) {
)
);
- $latest_revision_id++;
+ ++$latest_revision_id;
}
}
diff --git a/tests/phpunit/tests/rest-api/rest-attachments-controller.php b/tests/phpunit/tests/rest-api/rest-attachments-controller.php
index aca3c794f97fb..0e721258ed40a 100644
--- a/tests/phpunit/tests/rest-api/rest-attachments-controller.php
+++ b/tests/phpunit/tests/rest-api/rest-attachments-controller.php
@@ -1983,11 +1983,11 @@ public function test_create_item_with_meta_values() {
}
public function filter_rest_insert_attachment( $attachment ) {
- self::$rest_insert_attachment_count++;
+ ++self::$rest_insert_attachment_count;
}
public function filter_rest_after_insert_attachment( $attachment ) {
- self::$rest_after_insert_attachment_count++;
+ ++self::$rest_after_insert_attachment_count;
}
/**
diff --git a/tests/phpunit/tests/rest-api/rest-categories-controller.php b/tests/phpunit/tests/rest-api/rest-categories-controller.php
index a6ad0cf7005b0..a9019f227d723 100644
--- a/tests/phpunit/tests/rest-api/rest-categories-controller.php
+++ b/tests/phpunit/tests/rest-api/rest-categories-controller.php
@@ -631,8 +631,8 @@ public function test_get_terms_pagination_headers() {
// 3rd page.
self::factory()->category->create();
- $total_categories++;
- $total_pages++;
+ ++$total_categories;
+ ++$total_pages;
$request = new WP_REST_Request( 'GET', '/wp/v2/categories' );
$request->set_param( 'page', 3 );
$response = rest_get_server()->dispatch( $request );
diff --git a/tests/phpunit/tests/rest-api/rest-comments-controller.php b/tests/phpunit/tests/rest-api/rest-comments-controller.php
index 9b4444f559554..ab8f672c5de8a 100644
--- a/tests/phpunit/tests/rest-api/rest-comments-controller.php
+++ b/tests/phpunit/tests/rest-api/rest-comments-controller.php
@@ -828,8 +828,8 @@ public function test_get_comments_pagination_headers() {
'comment_post_ID' => self::$post_id,
)
);
- $total_comments++;
- $total_pages++;
+ ++$total_comments;
+ ++$total_pages;
$request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
$request->set_param( 'page', 3 );
$response = rest_get_server()->dispatch( $request );
diff --git a/tests/phpunit/tests/rest-api/rest-posts-controller.php b/tests/phpunit/tests/rest-api/rest-posts-controller.php
index 2722cfa7349bd..92d1262195456 100644
--- a/tests/phpunit/tests/rest-api/rest-posts-controller.php
+++ b/tests/phpunit/tests/rest-api/rest-posts-controller.php
@@ -1662,8 +1662,8 @@ public function test_get_items_pagination_headers() {
// 3rd page.
self::factory()->post->create();
- $total_posts++;
- $total_pages++;
+ ++$total_posts;
+ ++$total_pages;
$request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
$request->set_param( 'page', 3 );
$response = rest_get_server()->dispatch( $request );
@@ -2279,7 +2279,7 @@ public function test_prepare_item_limit_fields() {
public function test_prepare_item_filters_content_when_needed() {
$filter_count = 0;
$filter_content = static function() use ( &$filter_count ) {
- $filter_count++;
+ ++$filter_count;
return '
Filtered content.
';
};
add_filter( 'the_content', $filter_content );
@@ -2315,7 +2315,7 @@ public function test_prepare_item_filters_content_when_needed() {
public function test_prepare_item_skips_content_filter_if_not_needed() {
$filter_count = 0;
$filter_content = static function() use ( &$filter_count ) {
- $filter_count++;
+ ++$filter_count;
return '
Filtered content.
';
};
add_filter( 'the_content', $filter_content );
diff --git a/tests/phpunit/tests/rest-api/rest-sidebars-controller.php b/tests/phpunit/tests/rest-api/rest-sidebars-controller.php
index 8dab4f6ba97f7..0bddf12df92b9 100644
--- a/tests/phpunit/tests/rest-api/rest-sidebars-controller.php
+++ b/tests/phpunit/tests/rest-api/rest-sidebars-controller.php
@@ -1012,7 +1012,7 @@ protected function remove_links( $data ) {
if ( isset( $item['_links'] ) ) {
unset( $data[ $count ]['_links'] );
}
- $count++;
+ ++$count;
}
return $data;
diff --git a/tests/phpunit/tests/rest-api/rest-tags-controller.php b/tests/phpunit/tests/rest-api/rest-tags-controller.php
index d50bcedaaa3e3..6fb75eb93ec0e 100644
--- a/tests/phpunit/tests/rest-api/rest-tags-controller.php
+++ b/tests/phpunit/tests/rest-api/rest-tags-controller.php
@@ -415,7 +415,7 @@ public function test_get_terms_post_args_paging() {
$i = 0;
foreach ( $tags as $tag ) {
$this->assertSame( $tag['name'], "Tag {$i}" );
- $i++;
+ ++$i;
}
$request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
@@ -430,7 +430,7 @@ public function test_get_terms_post_args_paging() {
foreach ( $tags as $tag ) {
$this->assertSame( $tag['name'], "Tag {$i}" );
- $i++;
+ ++$i;
}
}
@@ -599,8 +599,8 @@ public function test_get_terms_pagination_headers() {
// 3rd page.
self::factory()->tag->create();
- $total_tags++;
- $total_pages++;
+ ++$total_tags;
+ ++$total_pages;
$request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
$request->set_param( 'page', 3 );
$response = rest_get_server()->dispatch( $request );
diff --git a/tests/phpunit/tests/rest-api/rest-users-controller.php b/tests/phpunit/tests/rest-api/rest-users-controller.php
index 72c1f7d6e250e..f4dbc2d57f379 100644
--- a/tests/phpunit/tests/rest-api/rest-users-controller.php
+++ b/tests/phpunit/tests/rest-api/rest-users-controller.php
@@ -339,8 +339,8 @@ public function test_get_items_pagination_headers() {
// 3rd page.
self::factory()->user->create();
- $total_users++;
- $total_pages++;
+ ++$total_users;
+ ++$total_pages;
$request = new WP_REST_Request( 'GET', '/wp/v2/users' );
$request->set_param( 'page', 3 );
$response = rest_get_server()->dispatch( $request );
diff --git a/tests/phpunit/tests/rest-api/rest-widgets-controller.php b/tests/phpunit/tests/rest-api/rest-widgets-controller.php
index 22516737c338d..69672a722627c 100644
--- a/tests/phpunit/tests/rest-api/rest-widgets-controller.php
+++ b/tests/phpunit/tests/rest-api/rest-widgets-controller.php
@@ -1551,7 +1551,7 @@ protected function remove_links( $data ) {
if ( is_array( $item ) && isset( $item['_links'] ) ) {
unset( $data[ $count ]['_links'] );
}
- $count++;
+ ++$count;
}
return $data;
diff --git a/tests/phpunit/tests/rest-api/wpRestMenuItemsController.php b/tests/phpunit/tests/rest-api/wpRestMenuItemsController.php
index 4687700cc798f..72dfab5f466e1 100644
--- a/tests/phpunit/tests/rest-api/wpRestMenuItemsController.php
+++ b/tests/phpunit/tests/rest-api/wpRestMenuItemsController.php
@@ -918,7 +918,7 @@ protected function check_menu_item_data( $post, $data, $context, $links ) {
foreach ( $taxonomies as $taxonomy ) {
$this->assertSame( $taxonomy->name, $links['https://api.w.org/term'][ $num ]['attributes']['taxonomy'] );
$this->assertSame( add_query_arg( 'post', $data['id'], rest_url( 'wp/v2/' . $taxonomy->rest_base ) ), $links['https://api.w.org/term'][ $num ]['href'] );
- $num++;
+ ++$num;
}
if ( 'post_type' === $data['type'] ) {
diff --git a/tests/phpunit/tests/term/cache.php b/tests/phpunit/tests/term/cache.php
index 8efd55da00d0c..ac418fbcfd5c0 100644
--- a/tests/phpunit/tests/term/cache.php
+++ b/tests/phpunit/tests/term/cache.php
@@ -73,12 +73,12 @@ public function test_hierachy_invalidation() {
case 2:
$parent = wp_insert_term( 'Child' . $i, $tax, array( 'parent' => $parent_id ) );
$parent_id = $parent['term_id'];
- $children++;
+ ++$children;
break;
case 3:
wp_insert_term( 'Grandchild' . $i, $tax, array( 'parent' => $parent_id ) );
$parent_id = 0;
- $children++;
+ ++$children;
break;
}
@@ -93,7 +93,7 @@ public function test_hierachy_invalidation() {
if ( 0 === ( $i % 3 ) ) {
$step = 1;
} else {
- $step++;
+ ++$step;
}
}
@@ -418,7 +418,7 @@ public function test_get_term_by_does_not_prime_term_meta_cache() {
$this->assertSame( $num_queries, get_num_queries() );
$term_meta = get_term_meta( $term_id, 'foo', true );
- $num_queries++;
+ ++$num_queries;
$this->assertSame( $term_meta, 'bar' );
$this->assertSame( $num_queries, get_num_queries() );
}
diff --git a/tests/phpunit/tests/term/getTerm.php b/tests/phpunit/tests/term/getTerm.php
index 36567a7830884..ed6acab691fc5 100644
--- a/tests/phpunit/tests/term/getTerm.php
+++ b/tests/phpunit/tests/term/getTerm.php
@@ -233,7 +233,7 @@ public function test_shared_term_in_cache_should_be_ignored_when_specifying_a_di
// Database should be hit again.
$found = get_term( $terms[1]['term_id'], 'wptests_tax_2' );
- $num_queries++;
+ ++$num_queries;
$this->assertSame( $num_queries, get_num_queries() );
$this->assertInstanceOf( 'WP_Term', $found );
diff --git a/tests/phpunit/tests/term/meta.php b/tests/phpunit/tests/term/meta.php
index d46f35ae1dbd7..248d1909179d3 100644
--- a/tests/phpunit/tests/term/meta.php
+++ b/tests/phpunit/tests/term/meta.php
@@ -139,7 +139,7 @@ public function test_term_meta_should_be_lazy_loaded_for_all_terms_in_wp_query_l
// First request will hit the database.
$num_queries = get_num_queries();
$this->assertSame( 'bar', get_term_meta( $terms[0], 'foo', true ) );
- $num_queries++;
+ ++$num_queries;
$this->assertSame( $num_queries, get_num_queries() );
// Second and third requests should be in cache.
@@ -148,7 +148,7 @@ public function test_term_meta_should_be_lazy_loaded_for_all_terms_in_wp_query_l
$this->assertSame( $num_queries, get_num_queries() );
// Querying a term not primed should result in a hit.
- $num_queries++;
+ ++$num_queries;
$this->assertSame( 'bar', get_term_meta( $orphan_term, 'foo', true ) );
$this->assertSame( $num_queries, get_num_queries() );
}
@@ -208,11 +208,11 @@ public function test_lazy_load_term_meta_false() {
// Requests will hit the database.
$num_queries = get_num_queries();
$this->assertSame( 'bar', get_term_meta( $terms[0], 'foo', true ) );
- $num_queries++;
+ ++$num_queries;
$this->assertSame( $num_queries, get_num_queries() );
$this->assertSame( 'bar', get_term_meta( $terms[1], 'foo', true ) );
- $num_queries++;
+ ++$num_queries;
$this->assertSame( $num_queries, get_num_queries() );
}
}
diff --git a/tests/phpunit/tests/theme/wpThemeJsonResolver.php b/tests/phpunit/tests/theme/wpThemeJsonResolver.php
index d75ff476b3e30..98f67fea5da4f 100644
--- a/tests/phpunit/tests/theme/wpThemeJsonResolver.php
+++ b/tests/phpunit/tests/theme/wpThemeJsonResolver.php
@@ -393,7 +393,7 @@ public function test_get_core_data( $should_fire_filter, $core_is_cached, $block
$expected_filter_count = did_filter( 'wp_theme_json_data_default' );
$actual = WP_Theme_JSON_Resolver::get_core_data();
if ( $should_fire_filter ) {
- $expected_filter_count++;
+ ++$expected_filter_count;
}
$this->assertSame( $expected_filter_count, did_filter( 'wp_theme_json_data_default' ), 'The filter "wp_theme_json_data_default" should fire the given number of times' );
diff --git a/tests/phpunit/tests/url.php b/tests/phpunit/tests/url.php
index 1561d3a03cccc..4768e25b7770a 100644
--- a/tests/phpunit/tests/url.php
+++ b/tests/phpunit/tests/url.php
@@ -339,7 +339,7 @@ public function test_set_url_scheme() {
$this->assertSame( $http_links[ $i ], set_url_scheme( $link, 'login' ) );
$this->assertSame( $http_links[ $i ], set_url_scheme( $link, 'rpc' ) );
- $i++;
+ ++$i;
}
force_ssl_admin( $forced_admin );
diff --git a/tests/phpunit/tests/widgets/wpWidgetText.php b/tests/phpunit/tests/widgets/wpWidgetText.php
index cccdcbe957c74..a1570da63a550 100644
--- a/tests/phpunit/tests/widgets/wpWidgetText.php
+++ b/tests/phpunit/tests/widgets/wpWidgetText.php
@@ -303,7 +303,7 @@ public function test_widget() {
*/
public function do_example_shortcode() {
$this->post_during_shortcode = get_post();
- $this->shortcode_render_count++;
+ ++$this->shortcode_render_count;
return $this->example_shortcode_content;
}
From 2a13d9321c48a3f55aebc5682e944812b969aee8 Mon Sep 17 00:00:00 2001
From: Colin Stewart
Date: Sun, 10 Sep 2023 07:31:47 +0000
Subject: [PATCH 061/105] Upgrade/Install: Fix broken `sprintf()` call when
deleting a backup.
In `WP_Upgrader::delete_temp_backup()`, a malformed `sprintf()` call did not pass the value, triggering a Warning in PHP 7 and a Fatal Error in PHP 8.
This fixes the malformed `sprintf()` call by correctly passing the value.
Follow-up to [55720].
Props akihiroharai, afragen.
Fixes #59320.
git-svn-id: https://develop.svn.wordpress.org/trunk@56550 602fd350-edb4-49c9-b593-d223f7449a82
---
src/wp-admin/includes/class-wp-upgrader.php | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/wp-admin/includes/class-wp-upgrader.php b/src/wp-admin/includes/class-wp-upgrader.php
index 69ba518328c1c..1fbfa99e4cf45 100644
--- a/src/wp-admin/includes/class-wp-upgrader.php
+++ b/src/wp-admin/includes/class-wp-upgrader.php
@@ -1207,8 +1207,7 @@ public function delete_temp_backup() {
if ( ! $wp_filesystem->delete( $temp_backup_dir, true ) ) {
$errors->add(
'temp_backup_delete_failed',
- sprintf( $this->strings['temp_backup_delete_failed'] ),
- $args['slug']
+ sprintf( $this->strings['temp_backup_delete_failed'], $args['slug'] )
);
continue;
}
From 858bd4b25f0ac021e64b2543cc990f9f9f1e5cb0 Mon Sep 17 00:00:00 2001
From: Sergey Biryukov
Date: Sun, 10 Sep 2023 09:02:49 +0000
Subject: [PATCH 062/105] Coding Standards: Correct spacing for spread
operators.
No space allowed between the operator and the variable it applies to.
Note: This is enforced by WPCS 3.0.0.
Follow-up to [46133].
Props jrf.
See #59161, #58831.
git-svn-id: https://develop.svn.wordpress.org/trunk@56551 602fd350-edb4-49c9-b593-d223f7449a82
---
src/wp-includes/class-wp-customize-panel.php | 2 +-
src/wp-includes/class-wp-customize-section.php | 2 +-
src/wp-includes/class-wp-customize-setting.php | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/wp-includes/class-wp-customize-panel.php b/src/wp-includes/class-wp-customize-panel.php
index f880afa8fe4a6..95b7aed468814 100644
--- a/src/wp-includes/class-wp-customize-panel.php
+++ b/src/wp-includes/class-wp-customize-panel.php
@@ -242,7 +242,7 @@ public function check_capabilities() {
return false;
}
- if ( $this->theme_supports && ! current_theme_supports( ... (array) $this->theme_supports ) ) {
+ if ( $this->theme_supports && ! current_theme_supports( ...(array) $this->theme_supports ) ) {
return false;
}
diff --git a/src/wp-includes/class-wp-customize-section.php b/src/wp-includes/class-wp-customize-section.php
index 65dbe00961dd5..4e58e7d43e64d 100644
--- a/src/wp-includes/class-wp-customize-section.php
+++ b/src/wp-includes/class-wp-customize-section.php
@@ -264,7 +264,7 @@ final public function check_capabilities() {
return false;
}
- if ( $this->theme_supports && ! current_theme_supports( ... (array) $this->theme_supports ) ) {
+ if ( $this->theme_supports && ! current_theme_supports( ...(array) $this->theme_supports ) ) {
return false;
}
diff --git a/src/wp-includes/class-wp-customize-setting.php b/src/wp-includes/class-wp-customize-setting.php
index 33b9436f859f6..99d0d2e51f199 100644
--- a/src/wp-includes/class-wp-customize-setting.php
+++ b/src/wp-includes/class-wp-customize-setting.php
@@ -836,7 +836,7 @@ final public function check_capabilities() {
return false;
}
- if ( $this->theme_supports && ! current_theme_supports( ... (array) $this->theme_supports ) ) {
+ if ( $this->theme_supports && ! current_theme_supports( ...(array) $this->theme_supports ) ) {
return false;
}
From aeba9d183d1b13616ac62e86e7ba310723ee6320 Mon Sep 17 00:00:00 2001
From: Sergey Biryukov
Date: Mon, 11 Sep 2023 04:51:09 +0000
Subject: [PATCH 063/105] Code Modernization: Use `dirname()` with the
`$levels` parameter.
PHP 7.0 introduced the `$levels` parameter to the `dirname()` function, which means nested calls to `dirname()` are no longer needed.
Note: This is enforced by WPCS 3.0.0.
Reference: [https://www.php.net/manual/en/function.dirname.php PHP Manual: dirname()].
Follow-up to [56141].
Props jrf.
See #59161, #58831.
git-svn-id: https://develop.svn.wordpress.org/trunk@56552 602fd350-edb4-49c9-b593-d223f7449a82
---
src/wp-admin/includes/theme.php | 2 +-
src/wp-admin/maint/repair.php | 2 +-
tests/phpunit/includes/bootstrap.php | 4 ++--
tests/phpunit/tests/filesystem/base.php | 2 +-
tests/phpunit/tests/pomo/pluralForms.php | 2 +-
5 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/wp-admin/includes/theme.php b/src/wp-admin/includes/theme.php
index d98cb5de33dd3..b0b3c6d768e79 100644
--- a/src/wp-admin/includes/theme.php
+++ b/src/wp-admin/includes/theme.php
@@ -156,7 +156,7 @@ function get_page_templates( $post = null, $post_type = 'page' ) {
* @return string
*/
function _get_template_edit_filename( $fullpath, $containingfolder ) {
- return str_replace( dirname( dirname( $containingfolder ) ), '', $fullpath );
+ return str_replace( dirname( $containingfolder, 2 ), '', $fullpath );
}
/**
diff --git a/src/wp-admin/maint/repair.php b/src/wp-admin/maint/repair.php
index 554e466d76f3e..1c0f6ffa985eb 100644
--- a/src/wp-admin/maint/repair.php
+++ b/src/wp-admin/maint/repair.php
@@ -7,7 +7,7 @@
*/
define( 'WP_REPAIRING', true );
-require_once dirname( dirname( __DIR__ ) ) . '/wp-load.php';
+require_once dirname( __DIR__, 2 ) . '/wp-load.php';
header( 'Content-Type: text/html; charset=utf-8' );
?>
diff --git a/tests/phpunit/includes/bootstrap.php b/tests/phpunit/includes/bootstrap.php
index 43ba0b0c493b5..15ec06b081440 100644
--- a/tests/phpunit/includes/bootstrap.php
+++ b/tests/phpunit/includes/bootstrap.php
@@ -10,7 +10,7 @@
if ( ! file_exists( $config_file_path . '/wp-tests-config.php' ) ) {
// Support the config file from the root of the develop repository.
if ( basename( $config_file_path ) === 'phpunit' && basename( dirname( $config_file_path ) ) === 'tests' ) {
- $config_file_path = dirname( dirname( $config_file_path ) );
+ $config_file_path = dirname( $config_file_path, 2 );
}
}
$config_file_path .= '/wp-tests-config.php';
@@ -79,7 +79,7 @@
*/
if ( ! class_exists( 'Yoast\PHPUnitPolyfills\Autoload' ) ) {
// Default location of the autoloader for WP core test runs.
- $phpunit_polyfills_autoloader = dirname( dirname( dirname( __DIR__ ) ) ) . '/vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
+ $phpunit_polyfills_autoloader = dirname( __DIR__, 3 ) . '/vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
$phpunit_polyfills_error = false;
// Allow for a custom installation location to be provided for plugin/theme integration tests.
diff --git a/tests/phpunit/tests/filesystem/base.php b/tests/phpunit/tests/filesystem/base.php
index 52ab59e3cdf6e..ceefeafa3e5c7 100644
--- a/tests/phpunit/tests/filesystem/base.php
+++ b/tests/phpunit/tests/filesystem/base.php
@@ -24,7 +24,7 @@ public function filter_fs_method( $method ) {
return 'MockFS';
}
public function filter_abstraction_file( $file ) {
- return dirname( dirname( __DIR__ ) ) . '/includes/mock-fs.php';
+ return dirname( __DIR__, 2 ) . '/includes/mock-fs.php';
}
public function test_is_MockFS_sane() {
diff --git a/tests/phpunit/tests/pomo/pluralForms.php b/tests/phpunit/tests/pomo/pluralForms.php
index 439064f7c49de..b676735c59bac 100644
--- a/tests/phpunit/tests/pomo/pluralForms.php
+++ b/tests/phpunit/tests/pomo/pluralForms.php
@@ -43,7 +43,7 @@ protected static function parenthesize_plural_expression( $expression ) {
* @group external-http
*/
public function test_regression( $lang, $nplurals, $expression ) {
- require_once dirname( dirname( __DIR__ ) ) . '/includes/plural-form-function.php';
+ require_once dirname( __DIR__, 2 ) . '/includes/plural-form-function.php';
$parenthesized = self::parenthesize_plural_expression( $expression );
$old_style = tests_make_plural_form_function( $nplurals, $parenthesized );
From 2453a6b57d9bfeb0a5a5d191044b42d24955995b Mon Sep 17 00:00:00 2001
From: Peter Wilson
Date: Mon, 11 Sep 2023 05:25:41 +0000
Subject: [PATCH 064/105] Cron: Cast `doing_cron` transient to a float.
Cast the `doing_cron` transient value to a float to prevent type errors if the transient is not set (in which case it returns `false`) or another unexpected type.
Props fzhantw, ankitmaru.
Fixes #58471.
git-svn-id: https://develop.svn.wordpress.org/trunk@56553 602fd350-edb4-49c9-b593-d223f7449a82
---
src/wp-includes/cron.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/wp-includes/cron.php b/src/wp-includes/cron.php
index c3a281a626dd5..4912d5f5035c8 100644
--- a/src/wp-includes/cron.php
+++ b/src/wp-includes/cron.php
@@ -863,7 +863,7 @@ function spawn_cron( $gmt_time = 0 ) {
* Multiple processes on multiple web servers can run this code concurrently,
* this lock attempts to make spawning as atomic as possible.
*/
- $lock = get_transient( 'doing_cron' );
+ $lock = (float) get_transient( 'doing_cron' );
if ( $lock > $gmt_time + 10 * MINUTE_IN_SECONDS ) {
$lock = 0;
From 46c1f6fcf4b823d6563638ff72d4a48b081f34e9 Mon Sep 17 00:00:00 2001
From: Colin Stewart
Date: Mon, 11 Sep 2023 10:31:22 +0000
Subject: [PATCH 065/105] External Libraries: Update the Requests library to
version 2.0.8.
This is a maintenance release with minor changes:
- Only force close cURL connection when needed (cURL < 7.22).
References:
- [https://github.com/WordPress/Requests/releases/tag/v2.0.8 Requests 2.0.8 release notes]
- [https://github.com/WordPress/Requests/compare/v2.0.6...v2.0.8 Full list of changes in Requests 2.0.8]
Follow-up to [54997], [55007], [55046], [55225], [55296], [55629].
Props jrf, mukesh27, spacedmonkey, costdev.
Fixes #59322.
git-svn-id: https://develop.svn.wordpress.org/trunk@56554 602fd350-edb4-49c9-b593-d223f7449a82
---
src/wp-includes/Requests/src/Requests.php | 2 +-
src/wp-includes/Requests/src/Transport/Curl.php | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/wp-includes/Requests/src/Requests.php b/src/wp-includes/Requests/src/Requests.php
index 287bacaaa575b..edf37f2214983 100644
--- a/src/wp-includes/Requests/src/Requests.php
+++ b/src/wp-includes/Requests/src/Requests.php
@@ -148,7 +148,7 @@ class Requests {
*
* @var string
*/
- const VERSION = '2.0.6';
+ const VERSION = '2.0.8';
/**
* Selected transport name
diff --git a/src/wp-includes/Requests/src/Transport/Curl.php b/src/wp-includes/Requests/src/Transport/Curl.php
index 7316987b5faed..29034b25d5358 100644
--- a/src/wp-includes/Requests/src/Transport/Curl.php
+++ b/src/wp-includes/Requests/src/Transport/Curl.php
@@ -25,6 +25,7 @@
final class Curl implements Transport {
const CURL_7_10_5 = 0x070A05;
const CURL_7_16_2 = 0x071002;
+ const CURL_7_22_0 = 0x071600;
/**
* Raw HTTP data
@@ -363,7 +364,7 @@ private function setup_handle($url, $headers, $data, $options) {
$options['hooks']->dispatch('curl.before_request', [&$this->handle]);
// Force closing the connection for old versions of cURL (<7.22).
- if (!isset($headers['Connection'])) {
+ if ($this->version < self::CURL_7_22_0 && !isset($headers['Connection'])) {
$headers['Connection'] = 'close';
}
From 827a560adef5e5f1d9fea1788b58aab9c4752a10 Mon Sep 17 00:00:00 2001
From: Jonny Harris
Date: Mon, 11 Sep 2023 11:35:59 +0000
Subject: [PATCH 066/105] Taxonomy: Cache term objects in WP_Term_Query if
query is filtered.
When utilizing the `terms_clauses` or `get_terms_fields` filters within `WP_Term_Query` and the selected fields are modified, the entire term object is now cached. This adjustment is necessary because filters can broaden the selected fields beyond just the term ID. Fields linked to the term object, such as the count or parent, may undergo modifications when queried. Caching the complete object ensures the accurate storage of these modified fields within the cache.
Props spacedmonkey, tnolte, peterwilsoncc.
Fixes #58116.
git-svn-id: https://develop.svn.wordpress.org/trunk@56555 602fd350-edb4-49c9-b593-d223f7449a82
---
src/wp-includes/class-wp-term-query.php | 6 +-
tests/phpunit/tests/term/query.php | 100 ++++++++++++++++++++++++
2 files changed, 105 insertions(+), 1 deletion(-)
diff --git a/src/wp-includes/class-wp-term-query.php b/src/wp-includes/class-wp-term-query.php
index d1cc69d96ca49..65b35289a9a21 100644
--- a/src/wp-includes/class-wp-term-query.php
+++ b/src/wp-includes/class-wp-term-query.php
@@ -738,6 +738,8 @@ public function get_terms() {
$order = isset( $clauses['order'] ) ? $clauses['order'] : '';
$limits = isset( $clauses['limits'] ) ? $clauses['limits'] : '';
+ $fields_is_filtered = implode( ', ', $selects ) !== $fields;
+
if ( $where ) {
$where = "WHERE $where";
}
@@ -782,7 +784,7 @@ public function get_terms() {
$cache = array_map( 'intval', $cache );
} elseif ( 'count' !== $_fields ) {
if ( ( 'all_with_object_id' === $_fields && ! empty( $args['object_ids'] ) )
- || ( 'all' === $_fields && $args['pad_counts'] )
+ || ( 'all' === $_fields && $args['pad_counts'] || $fields_is_filtered )
) {
$term_ids = wp_list_pluck( $cache, 'term_id' );
} else {
@@ -884,6 +886,8 @@ public function get_terms() {
$object->count = $term->count;
$term_cache[] = $object;
}
+ } elseif ( $fields_is_filtered ) {
+ $term_cache = $term_objects;
} else {
$term_cache = wp_list_pluck( $term_objects, 'term_id' );
}
diff --git a/tests/phpunit/tests/term/query.php b/tests/phpunit/tests/term/query.php
index 0e118a3c169a4..682e86a8dfced 100644
--- a/tests/phpunit/tests/term/query.php
+++ b/tests/phpunit/tests/term/query.php
@@ -698,6 +698,106 @@ public function test_query_should_return_zero_for_field_as_count_and_child_of_se
$this->assertSame( 0, $q->query( $args ) );
}
+ /**
+ * If fields have filtered, cached results should work.
+ *
+ * @ticket 58116
+ * @group cache
+ */
+ public function test_query_filter_fields() {
+ $post_id = self::factory()->post->create();
+ register_taxonomy( 'wptests_tax', 'post' );
+
+ $term_id = self::factory()->term->create(
+ array(
+ 'taxonomy' => 'wptests_tax',
+ )
+ );
+ wp_set_object_terms( $post_id, array( $term_id ), 'wptests_tax' );
+ $post_draft_id = self::factory()->post->create( array( 'post_type' => 'draft' ) );
+ wp_set_object_terms( $post_draft_id, array( $term_id ), 'wptests_tax' );
+
+ add_filter( 'terms_clauses', array( $this, 'filter_fields_terms_clauses' ), 10, 3 );
+
+ $args = array(
+ 'taxonomy' => 'wptests_tax',
+ 'hide_empty' => false,
+ 'post_type' => 'post',
+ 'post_status' => 'publish',
+ );
+
+ $q1 = new WP_Term_Query();
+ $terms1 = $q1->query( $args );
+ $q2 = new WP_Term_Query();
+ $terms2 = $q2->query( $args );
+ $this->assertSameSets( wp_list_pluck( $terms1, 'term_id' ), wp_list_pluck( $terms2, 'term_id' ), 'Term IDs are expected to match' );
+ $this->assertSameSets( wp_list_pluck( $terms1, 'count' ), wp_list_pluck( $terms2, 'count' ), 'Term counts are expected to match' );
+ }
+
+ /**
+ * Filter `terms_clauses` to change the field requested. The filter is from example code given in #58116.
+ */
+ public function filter_fields_terms_clauses( $clauses, $taxonomies, $args ) {
+ global $wpdb;
+
+ // Set to query specific posts types if set.
+ if ( ! empty( $args['post_type'] ) ) {
+ $clauses['fields'] = 'DISTINCT t.term_id, tt.term_taxonomy_id, tt.taxonomy, tt.description, tt.parent, COUNT(p.post_type) AS count';
+ $clauses['join'] .= ' LEFT JOIN ' . $wpdb->term_relationships . ' AS r ON r.term_taxonomy_id = tt.term_taxonomy_id LEFT JOIN ' . $wpdb->posts . ' AS p ON p.ID = r.object_id';
+ $clauses['where'] .= " AND (p.post_type = '" . $args['post_type'] . "' OR p.post_type IS NULL)";
+ $clauses['orderby'] = 'GROUP BY t.term_id ' . $clauses['orderby'];
+ }
+
+ // Set to query posts with specific status.
+ if ( ! empty( $args['post_status'] ) ) {
+ $clauses['where'] .= " AND (p.post_status = '" . $args['post_status'] . "')";
+ }
+ return $clauses;
+ }
+
+ /**
+ * If fields have filtered, cached results should work.
+ *
+ * @ticket 58116
+ * @group cache
+ */
+ public function test_query_filter_select_fields() {
+ $post_id = self::factory()->post->create();
+ register_taxonomy( 'wptests_tax', 'post' );
+
+ $term_id = self::factory()->term->create(
+ array(
+ 'taxonomy' => 'wptests_tax',
+ )
+ );
+ wp_set_object_terms( $post_id, array( $term_id ), 'wptests_tax' );
+ $post_draft_id = self::factory()->post->create( array( 'post_type' => 'draft' ) );
+ wp_set_object_terms( $post_draft_id, array( $term_id ), 'wptests_tax' );
+
+ add_filter( 'get_terms_fields', array( $this, 'filter_get_terms_fields' ) );
+
+ $args = array(
+ 'taxonomy' => 'wptests_tax',
+ 'hide_empty' => false,
+ 'post_type' => 'post',
+ 'post_status' => 'publish',
+ );
+
+ $q1 = new WP_Term_Query();
+ $terms1 = $q1->query( $args );
+ $q2 = new WP_Term_Query();
+ $terms2 = $q2->query( $args );
+ $this->assertSameSets( wp_list_pluck( $terms1, 'term_id' ), wp_list_pluck( $terms2, 'term_id' ), 'Term IDs are expected to match' );
+ $this->assertSameSets( wp_list_pluck( $terms1, 'parent' ), wp_list_pluck( $terms2, 'parent' ), 'Term parent are expected to match' );
+ }
+
+ /**
+ * Filter `get_terms_fields` to change the field requested.
+ */
+ public function filter_get_terms_fields( $select ) {
+ return array( 't.term_id', 'tt.parent' );
+ }
+
/**
* The terms property should be an empty array for fields not as count and parent set.
*
From cc775b9985b1dd9a0c8827df378b21e831b400a1 Mon Sep 17 00:00:00 2001
From: Weston Ruter
Date: Tue, 12 Sep 2023 00:04:15 +0000
Subject: [PATCH 067/105] Bundled Themes: Use `defer` loading strategy for
theme scripts.
* Add `defer` loading strategy for all frontend end-user theme scripts (excluding Customizer preview).
* Move scripts to the `head` which relate to the initial page viewport to ensure they start loading earlier and execute sooner while still not blocking rendering.
* Update Twenty Twenty's script loader (`TwentyTwenty_Script_Loader`) to support core's built-in script loading strategies (#12009), while also retaining backwards-compatibility for child themes that may set `async` and `defer` script data.
* Update the main script loading strategy in Twenty Twenty from `async` to `defer` for better performance on repeat page views, since when an `async` script is cached it will block rendering.
Props westonruter, flixos90, sabernhardt.
Fixes #59316.
git-svn-id: https://develop.svn.wordpress.org/trunk@56556 602fd350-edb4-49c9-b593-d223f7449a82
---
.../themes/twentyeleven/showcase.php | 11 +++++-
.../themes/twentyfifteen/functions.php | 11 +++++-
.../themes/twentyfourteen/functions.php | 22 ++++++++++-
.../themes/twentynineteen/functions.php | 22 ++++++++++-
.../themes/twentyseventeen/functions.php | 33 ++++++++++++++--
.../themes/twentysixteen/functions.php | 11 +++++-
.../themes/twentythirteen/functions.php | 11 +++++-
.../themes/twentytwelve/functions.php | 11 +++++-
.../class-twentytwenty-script-loader.php | 39 ++++++++++++++++---
.../themes/twentytwenty/functions.php | 18 +++++++--
.../themes/twentytwentyone/functions.php | 5 ++-
11 files changed, 173 insertions(+), 21 deletions(-)
diff --git a/src/wp-content/themes/twentyeleven/showcase.php b/src/wp-content/themes/twentyeleven/showcase.php
index 0821040f76d99..a46fed329cd69 100644
--- a/src/wp-content/themes/twentyeleven/showcase.php
+++ b/src/wp-content/themes/twentyeleven/showcase.php
@@ -16,7 +16,16 @@
*/
// Enqueue showcase script for the slider.
-wp_enqueue_script( 'twentyeleven-showcase', get_template_directory_uri() . '/js/showcase.js', array( 'jquery' ), '20211130' );
+wp_enqueue_script(
+ 'twentyeleven-showcase',
+ get_template_directory_uri() . '/js/showcase.js',
+ array( 'jquery' ),
+ '20211130',
+ array(
+ 'in_footer' => false, // Because involves header.
+ 'strategy' => 'defer',
+ )
+);
get_header(); ?>
diff --git a/src/wp-content/themes/twentyfifteen/functions.php b/src/wp-content/themes/twentyfifteen/functions.php
index 1132cff2dd58a..2b9cc816f80cf 100644
--- a/src/wp-content/themes/twentyfifteen/functions.php
+++ b/src/wp-content/themes/twentyfifteen/functions.php
@@ -454,7 +454,16 @@ function twentyfifteen_scripts() {
wp_enqueue_script( 'twentyfifteen-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20141210' );
}
- wp_enqueue_script( 'twentyfifteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20221101', array( 'in_footer' => true ) );
+ wp_enqueue_script(
+ 'twentyfifteen-script',
+ get_template_directory_uri() . '/js/functions.js',
+ array( 'jquery' ),
+ '20221101',
+ array(
+ 'in_footer' => false, // Because involves header.
+ 'strategy' => 'defer',
+ )
+ );
wp_localize_script(
'twentyfifteen-script',
'screenReaderText',
diff --git a/src/wp-content/themes/twentyfourteen/functions.php b/src/wp-content/themes/twentyfourteen/functions.php
index 6267c95f2ebab..d9688e0b87be5 100644
--- a/src/wp-content/themes/twentyfourteen/functions.php
+++ b/src/wp-content/themes/twentyfourteen/functions.php
@@ -367,7 +367,16 @@ function twentyfourteen_scripts() {
}
if ( is_front_page() && 'slider' === get_theme_mod( 'featured_content_layout' ) ) {
- wp_enqueue_script( 'twentyfourteen-slider', get_template_directory_uri() . '/js/slider.js', array( 'jquery' ), '20150120', array( 'in_footer' => true ) );
+ wp_enqueue_script(
+ 'twentyfourteen-slider',
+ get_template_directory_uri() . '/js/slider.js',
+ array( 'jquery' ),
+ '20150120',
+ array(
+ 'in_footer' => false, // Because involves header.
+ 'strategy' => 'defer',
+ )
+ );
wp_localize_script(
'twentyfourteen-slider',
'featuredSliderDefaults',
@@ -378,7 +387,16 @@ function twentyfourteen_scripts() {
);
}
- wp_enqueue_script( 'twentyfourteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20230526', array( 'in_footer' => true ) );
+ wp_enqueue_script(
+ 'twentyfourteen-script',
+ get_template_directory_uri() . '/js/functions.js',
+ array( 'jquery' ),
+ '20230526',
+ array(
+ 'in_footer' => false, // Because involves header.
+ 'strategy' => 'defer',
+ )
+ );
}
add_action( 'wp_enqueue_scripts', 'twentyfourteen_scripts' );
diff --git a/src/wp-content/themes/twentynineteen/functions.php b/src/wp-content/themes/twentynineteen/functions.php
index f53b3a2053f0b..33ce770581ba3 100644
--- a/src/wp-content/themes/twentynineteen/functions.php
+++ b/src/wp-content/themes/twentynineteen/functions.php
@@ -258,8 +258,26 @@ function twentynineteen_scripts() {
wp_style_add_data( 'twentynineteen-style', 'rtl', 'replace' );
if ( has_nav_menu( 'menu-1' ) ) {
- wp_enqueue_script( 'twentynineteen-priority-menu', get_theme_file_uri( '/js/priority-menu.js' ), array(), '20200129', array( 'in_footer' => true ) );
- wp_enqueue_script( 'twentynineteen-touch-navigation', get_theme_file_uri( '/js/touch-keyboard-navigation.js' ), array(), '20230621', array( 'in_footer' => true ) );
+ wp_enqueue_script(
+ 'twentynineteen-priority-menu',
+ get_theme_file_uri( '/js/priority-menu.js' ),
+ array(),
+ '20200129',
+ array(
+ 'in_footer' => false, // Because involves header.
+ 'strategy' => 'defer',
+ )
+ );
+ wp_enqueue_script(
+ 'twentynineteen-touch-navigation',
+ get_theme_file_uri( '/js/touch-keyboard-navigation.js' ),
+ array(),
+ '20230621',
+ array(
+ 'in_footer' => true,
+ 'strategy' => 'defer',
+ )
+ );
}
wp_enqueue_style( 'twentynineteen-print-style', get_template_directory_uri() . '/print.css', array(), wp_get_theme()->get( 'Version' ), 'print' );
diff --git a/src/wp-content/themes/twentyseventeen/functions.php b/src/wp-content/themes/twentyseventeen/functions.php
index 26a7a1a3c07e8..0afafbb8e8a13 100644
--- a/src/wp-content/themes/twentyseventeen/functions.php
+++ b/src/wp-content/themes/twentyseventeen/functions.php
@@ -479,14 +479,32 @@ function twentyseventeen_scripts() {
// Skip-link fix is no longer enqueued by default.
wp_register_script( 'twentyseventeen-skip-link-focus-fix', get_theme_file_uri( '/assets/js/skip-link-focus-fix.js' ), array(), '20161114', array( 'in_footer' => true ) );
- wp_enqueue_script( 'twentyseventeen-global', get_theme_file_uri( '/assets/js/global.js' ), array( 'jquery' ), '20211130', array( 'in_footer' => true ) );
+ wp_enqueue_script(
+ 'twentyseventeen-global',
+ get_theme_file_uri( '/assets/js/global.js' ),
+ array( 'jquery' ),
+ '20211130',
+ array(
+ 'in_footer' => false, // Because involves header.
+ 'strategy' => 'defer',
+ )
+ );
$twentyseventeen_l10n = array(
'quote' => twentyseventeen_get_svg( array( 'icon' => 'quote-right' ) ),
);
if ( has_nav_menu( 'top' ) ) {
- wp_enqueue_script( 'twentyseventeen-navigation', get_theme_file_uri( '/assets/js/navigation.js' ), array( 'jquery' ), '20210122', array( 'in_footer' => true ) );
+ wp_enqueue_script(
+ 'twentyseventeen-navigation',
+ get_theme_file_uri( '/assets/js/navigation.js' ),
+ array( 'jquery' ),
+ '20210122',
+ array(
+ 'in_footer' => false, // Because involves header.
+ 'strategy' => 'defer',
+ )
+ );
$twentyseventeen_l10n['expand'] = __( 'Expand child menu', 'twentyseventeen' );
$twentyseventeen_l10n['collapse'] = __( 'Collapse child menu', 'twentyseventeen' );
$twentyseventeen_l10n['icon'] = twentyseventeen_get_svg(
@@ -499,7 +517,16 @@ function twentyseventeen_scripts() {
wp_localize_script( 'twentyseventeen-global', 'twentyseventeenScreenReaderText', $twentyseventeen_l10n );
- wp_enqueue_script( 'jquery-scrollto', get_theme_file_uri( '/assets/js/jquery.scrollTo.js' ), array( 'jquery' ), '2.1.3', array( 'in_footer' => true ) );
+ wp_enqueue_script(
+ 'jquery-scrollto',
+ get_theme_file_uri( '/assets/js/jquery.scrollTo.js' ),
+ array( 'jquery' ),
+ '2.1.3',
+ array(
+ 'in_footer' => true,
+ 'strategy' => 'defer',
+ )
+ );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
diff --git a/src/wp-content/themes/twentysixteen/functions.php b/src/wp-content/themes/twentysixteen/functions.php
index 0c4c9237ee002..80b5cb525a6fe 100644
--- a/src/wp-content/themes/twentysixteen/functions.php
+++ b/src/wp-content/themes/twentysixteen/functions.php
@@ -423,7 +423,16 @@ function twentysixteen_scripts() {
wp_enqueue_script( 'twentysixteen-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20170530' );
}
- wp_enqueue_script( 'twentysixteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20230629', array( 'in_footer' => true ) );
+ wp_enqueue_script(
+ 'twentysixteen-script',
+ get_template_directory_uri() . '/js/functions.js',
+ array( 'jquery' ),
+ '20230629',
+ array(
+ 'in_footer' => false, // Because involves header.
+ 'strategy' => 'defer',
+ )
+ );
wp_localize_script(
'twentysixteen-script',
diff --git a/src/wp-content/themes/twentythirteen/functions.php b/src/wp-content/themes/twentythirteen/functions.php
index 5ccf92453622f..92651857044f2 100644
--- a/src/wp-content/themes/twentythirteen/functions.php
+++ b/src/wp-content/themes/twentythirteen/functions.php
@@ -321,7 +321,16 @@ function twentythirteen_scripts_styles() {
}
// Loads JavaScript file with functionality specific to Twenty Thirteen.
- wp_enqueue_script( 'twentythirteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20230526', array( 'in_footer' => true ) );
+ wp_enqueue_script(
+ 'twentythirteen-script',
+ get_template_directory_uri() . '/js/functions.js',
+ array( 'jquery' ),
+ '20230526',
+ array(
+ 'in_footer' => false, // Because involves header.
+ 'strategy' => 'defer',
+ )
+ );
// Add Source Sans Pro and Bitter fonts, used in the main stylesheet.
$font_version = ( 0 === strpos( (string) twentythirteen_fonts_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null;
diff --git a/src/wp-content/themes/twentytwelve/functions.php b/src/wp-content/themes/twentytwelve/functions.php
index 0d7c4825e23ca..6f8de15a89a4d 100644
--- a/src/wp-content/themes/twentytwelve/functions.php
+++ b/src/wp-content/themes/twentytwelve/functions.php
@@ -188,7 +188,16 @@ function twentytwelve_scripts_styles() {
}
// Adds JavaScript for handling the navigation menu hide-and-show behavior.
- wp_enqueue_script( 'twentytwelve-navigation', get_template_directory_uri() . '/js/navigation.js', array( 'jquery' ), '20141205', array( 'in_footer' => true ) );
+ wp_enqueue_script(
+ 'twentytwelve-navigation',
+ get_template_directory_uri() . '/js/navigation.js',
+ array( 'jquery' ),
+ '20141205',
+ array(
+ 'in_footer' => false, // Because involves header.
+ 'strategy' => 'defer',
+ )
+ );
$font_url = twentytwelve_get_font_url();
if ( ! empty( $font_url ) ) {
diff --git a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-script-loader.php b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-script-loader.php
index f57811614b15e..086d53ed2c287 100644
--- a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-script-loader.php
+++ b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-script-loader.php
@@ -19,10 +19,32 @@
*/
class TwentyTwenty_Script_Loader {
+ /**
+ * Migrates legacy async/defer script data which might be used by child themes.
+ *
+ * This method is used on the `print_scripts_array` filter.
+ *
+ * @since Twenty Twenty 2.0
+ *
+ * @param string[] $to_do An array of script dependency handles.
+ * @return string[] Unchanged array of script dependency handles.
+ */
+ public function migrate_legacy_strategy_script_data( $to_do ) {
+ foreach ( $to_do as $handle ) {
+ foreach ( array( 'async', 'defer' ) as $strategy ) {
+ if ( wp_scripts()->get_data( $handle, $strategy ) ) {
+ wp_script_add_data( $handle, 'strategy', $strategy );
+ }
+ }
+ }
+ return $to_do;
+ }
+
/**
* Adds async/defer attributes to enqueued / registered scripts.
*
- * If #12009 lands in WordPress, this function can no-op since it would be handled in core.
+ * Now that #12009 has landed in WordPress 6.3, this method is only used for older versions of WordPress.
+ * This method is used on the `script_loader_tag` filter.
*
* @since Twenty Twenty 1.0
*
@@ -33,10 +55,17 @@ class TwentyTwenty_Script_Loader {
* @return string Script HTML string.
*/
public function filter_script_loader_tag( $tag, $handle ) {
- foreach ( array( 'async', 'defer' ) as $attr ) {
- if ( ! wp_scripts()->get_data( $handle, $attr ) ) {
- continue;
- }
+ $strategies = array(
+ 'async' => (bool) wp_scripts()->get_data( $handle, 'async' ),
+ 'defer' => (bool) wp_scripts()->get_data( $handle, 'defer' ),
+ );
+ $strategy = wp_scripts()->get_data( $handle, 'strategy' );
+ if ( $strategy && isset( $strategies[ $strategy ] ) ) {
+ $strategies[ $strategy ] = true;
+ }
+
+ foreach ( array_keys( array_filter( $strategies ) ) as $attr ) {
+
// Prevent adding attribute when already added in #12009.
if ( ! preg_match( ":\s$attr(=|>|\s):", $tag ) ) {
$tag = preg_replace( ':(?=>):', " $attr", $tag, 1 );
diff --git a/src/wp-content/themes/twentytwenty/functions.php b/src/wp-content/themes/twentytwenty/functions.php
index fc2b0dddbfeca..1ca2e4318a53a 100644
--- a/src/wp-content/themes/twentytwenty/functions.php
+++ b/src/wp-content/themes/twentytwenty/functions.php
@@ -135,7 +135,11 @@ function twentytwenty_theme_support() {
* by the theme.
*/
$loader = new TwentyTwenty_Script_Loader();
- add_filter( 'script_loader_tag', array( $loader, 'filter_script_loader_tag' ), 10, 2 );
+ if ( version_compare( $GLOBALS['wp_version'], '6.3', '<' ) ) {
+ add_filter( 'script_loader_tag', array( $loader, 'filter_script_loader_tag' ), 10, 2 );
+ } else {
+ add_filter( 'print_scripts_array', array( $loader, 'migrate_legacy_strategy_script_data' ), 100 );
+ }
}
add_action( 'after_setup_theme', 'twentytwenty_theme_support' );
@@ -211,8 +215,16 @@ function twentytwenty_register_scripts() {
wp_enqueue_script( 'comment-reply' );
}
- wp_enqueue_script( 'twentytwenty-js', get_template_directory_uri() . '/assets/js/index.js', array(), $theme_version );
- wp_script_add_data( 'twentytwenty-js', 'async', true );
+ wp_enqueue_script(
+ 'twentytwenty-js',
+ get_template_directory_uri() . '/assets/js/index.js',
+ array(),
+ $theme_version,
+ array(
+ 'in_footer' => false, // Because involves header.
+ 'strategy' => 'defer',
+ )
+ );
}
add_action( 'wp_enqueue_scripts', 'twentytwenty_register_scripts' );
diff --git a/src/wp-content/themes/twentytwentyone/functions.php b/src/wp-content/themes/twentytwentyone/functions.php
index bdbaf9e336352..f163e394df734 100644
--- a/src/wp-content/themes/twentytwentyone/functions.php
+++ b/src/wp-content/themes/twentytwentyone/functions.php
@@ -449,7 +449,10 @@ function twenty_twenty_one_scripts() {
get_template_directory_uri() . '/assets/js/primary-navigation.js',
array( 'twenty-twenty-one-ie11-polyfills' ),
wp_get_theme()->get( 'Version' ),
- array( 'in_footer' => true )
+ array(
+ 'in_footer' => false, // Because involves header.
+ 'strategy' => 'defer',
+ )
);
}
From 44e71c8e703bb473924e0d2bd35999d3aa17e734 Mon Sep 17 00:00:00 2001
From: Bernie Reiter
Date: Tue, 12 Sep 2023 13:00:32 +0000
Subject: [PATCH 068/105] General: Add optional callback argument to
serialize_block(s).
Allow passing a function callback to serialize_block(s) that is invoked on each node in the tree of parsed blocks as it is traversed for serialization.
A function argument was chosen for passing the callback function as it reflects a pattern familiar from other algorithms that apply a given callback function while traversing a data structure -- most notably PHP's own `array_map()`.
Introducing a filter was considered as an alternative but ultimately dismissed. For a fairly low-level and general-purpose function such as `serialize_block()`, using a filter to pass the callback seemed risky, as it also requires ''removing'' that filter after usage in order to prevent the callback from being accidentally applied when `serialize_block()` is called in an entirely different context.
Introducing a separate function for applying a given operation during tree traversal (i.e. independently of serialization) was also considered but dismissed, as it would unnecessarily duplicate tree traversal.
Props dlh, gziolo.
Fixes #59327. See #59313.
git-svn-id: https://develop.svn.wordpress.org/trunk@56557 602fd350-edb4-49c9-b593-d223f7449a82
---
src/wp-includes/blocks.php | 24 ++++++++++++++++++------
tests/phpunit/tests/blocks/serialize.php | 24 ++++++++++++++++++++++++
2 files changed, 42 insertions(+), 6 deletions(-)
diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php
index 6fc72e358a5ef..590f3706f71f5 100644
--- a/src/wp-includes/blocks.php
+++ b/src/wp-includes/blocks.php
@@ -794,16 +794,22 @@ function get_comment_delimited_block_content( $block_name, $block_attributes, $b
* instead preserve the markup as parsed.
*
* @since 5.3.1
+ * @since 6.4.0 The `$callback` parameter was added.
*
- * @param array $block A representative array of a single parsed block object. See WP_Block_Parser_Block.
+ * @param array $block A representative array of a single parsed block object. See WP_Block_Parser_Block.
+ * @param callable|null $callback Optional. Callback to run on each block in the tree before serialization. Default null.
* @return string String of rendered HTML.
*/
-function serialize_block( $block ) {
+function serialize_block( $block, $callback = null ) {
+ if ( is_callable( $callback ) ) {
+ $block = call_user_func( $callback, $block );
+ }
+
$block_content = '';
$index = 0;
foreach ( $block['innerContent'] as $chunk ) {
- $block_content .= is_string( $chunk ) ? $chunk : serialize_block( $block['innerBlocks'][ $index++ ] );
+ $block_content .= is_string( $chunk ) ? $chunk : serialize_block( $block['innerBlocks'][ $index++ ], $callback );
}
if ( ! is_array( $block['attrs'] ) ) {
@@ -822,12 +828,18 @@ function serialize_block( $block ) {
* parsed blocks.
*
* @since 5.3.1
+ * @since 6.4.0 The `$callback` parameter was added.
*
- * @param array[] $blocks An array of representative arrays of parsed block objects. See serialize_block().
+ * @param array[] $blocks An array of representative arrays of parsed block objects. See serialize_block().
+ * @param callable|null $callback Optional. Callback to run on each block in the tree before serialization. Default null.
* @return string String of rendered HTML.
*/
-function serialize_blocks( $blocks ) {
- return implode( '', array_map( 'serialize_block', $blocks ) );
+function serialize_blocks( $blocks, $callback = null ) {
+ $result = '';
+ foreach ( $blocks as $block ) {
+ $result .= serialize_block( $block, $callback );
+ };
+ return $result;
}
/**
diff --git a/tests/phpunit/tests/blocks/serialize.php b/tests/phpunit/tests/blocks/serialize.php
index 4437c8ca852c3..3bfda3ed55a8f 100644
--- a/tests/phpunit/tests/blocks/serialize.php
+++ b/tests/phpunit/tests/blocks/serialize.php
@@ -54,4 +54,28 @@ public function test_serialized_block_name() {
$this->assertSame( 'example', strip_core_block_namespace( 'core/example' ) );
$this->assertSame( 'plugin/example', strip_core_block_namespace( 'plugin/example' ) );
}
+
+ /**
+ * @ticket 59327
+ *
+ * @covers ::serialize_blocks
+ */
+ public function test_callback_argument() {
+ $markup = "Example.\n\nExample.\n\n";
+ $blocks = parse_blocks( $markup );
+
+ $actual = serialize_blocks( $blocks, array( __CLASS__, 'add_attribute_to_inner_block' ) );
+
+ $this->assertSame(
+ "Example.\n\nExample.\n\n",
+ $actual
+ );
+ }
+
+ public static function add_attribute_to_inner_block( $block ) {
+ if ( 'core/inner' === $block['blockName'] ) {
+ $block['attrs']['myattr'] = 'myvalue';
+ }
+ return $block;
+ }
}
From 9c9329c44791336e247fec4d7c2dca31f505180f Mon Sep 17 00:00:00 2001
From: Bernie Reiter
Date: Tue, 12 Sep 2023 15:10:19 +0000
Subject: [PATCH 069/105] HTML API: Store current token reference in HTML
Processor state.
The `$current_token` reference has been stored in the HTML Processor itself, but I suggested to move it into the externalized state so that it can be stored and replaced.
In this patch the reference is moved to that state variable and it should become more possible to save and load state, to resume execution after pausing.
Props dmsnell.
Fixes #59268.
git-svn-id: https://develop.svn.wordpress.org/trunk@56558 602fd350-edb4-49c9-b593-d223f7449a82
---
.../class-wp-html-processor-state.php | 9 +++++
.../html-api/class-wp-html-processor.php | 35 ++++++++-----------
2 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/src/wp-includes/html-api/class-wp-html-processor-state.php b/src/wp-includes/html-api/class-wp-html-processor-state.php
index 3fe5192431bd3..9cf10c344107a 100644
--- a/src/wp-includes/html-api/class-wp-html-processor-state.php
+++ b/src/wp-includes/html-api/class-wp-html-processor-state.php
@@ -85,6 +85,15 @@ class WP_HTML_Processor_State {
*/
public $active_formatting_elements = null;
+ /**
+ * Refers to the currently-matched tag, if any.
+ *
+ * @since 6.4.0
+ *
+ * @var WP_HTML_Token|null
+ */
+ public $current_token = null;
+
/**
* Tree construction insertion mode.
*
diff --git a/src/wp-includes/html-api/class-wp-html-processor.php b/src/wp-includes/html-api/class-wp-html-processor.php
index b5a20dbd82cdc..64fd23924eada 100644
--- a/src/wp-includes/html-api/class-wp-html-processor.php
+++ b/src/wp-includes/html-api/class-wp-html-processor.php
@@ -164,15 +164,6 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
*/
private $bookmark_counter = 0;
- /**
- * Refers to the currently-matched tag, if any.
- *
- * @since 6.4.0
- *
- * @var WP_HTML_Token|null
- */
- private $current_token = null;
-
/**
* Stores an explanation for why something failed, if it did.
*
@@ -451,7 +442,7 @@ public function step( $node_to_process = self::PROCESS_NEXT_NODE ) {
return false;
}
- $this->current_token = new WP_HTML_Token(
+ $this->state->current_token = new WP_HTML_Token(
$this->bookmark_tag(),
$this->get_tag(),
$this->is_tag_closer(),
@@ -538,7 +529,7 @@ private function step_in_body() {
}
$this->reconstruct_active_formatting_elements();
- $this->insert_html_element( $this->current_token );
+ $this->insert_html_element( $this->state->current_token );
$this->state->frameset_ok = false;
return true;
@@ -558,7 +549,7 @@ private function step_in_body() {
$this->close_a_p_element();
}
- $this->insert_html_element( $this->current_token );
+ $this->insert_html_element( $this->state->current_token );
return true;
/*
@@ -590,7 +581,7 @@ private function step_in_body() {
*/
case '-P':
if ( ! $this->state->stack_of_open_elements->has_p_in_button_scope() ) {
- $this->insert_html_element( $this->current_token );
+ $this->insert_html_element( $this->state->current_token );
}
$this->close_a_p_element();
@@ -612,8 +603,8 @@ private function step_in_body() {
}
$this->reconstruct_active_formatting_elements();
- $this->insert_html_element( $this->current_token );
- $this->state->active_formatting_elements->push( $this->current_token );
+ $this->insert_html_element( $this->state->current_token );
+ $this->state->active_formatting_elements->push( $this->state->current_token );
return true;
/*
@@ -633,8 +624,8 @@ private function step_in_body() {
case '+TT':
case '+U':
$this->reconstruct_active_formatting_elements();
- $this->insert_html_element( $this->current_token );
- $this->state->active_formatting_elements->push( $this->current_token );
+ $this->insert_html_element( $this->state->current_token );
+ $this->state->active_formatting_elements->push( $this->state->current_token );
return true;
/*
@@ -662,7 +653,7 @@ private function step_in_body() {
*/
case '+IMG':
$this->reconstruct_active_formatting_elements();
- $this->insert_html_element( $this->current_token );
+ $this->insert_html_element( $this->state->current_token );
return true;
/*
@@ -670,7 +661,7 @@ private function step_in_body() {
*/
case '+SPAN':
$this->reconstruct_active_formatting_elements();
- $this->insert_html_element( $this->current_token );
+ $this->insert_html_element( $this->state->current_token );
return true;
/*
@@ -796,7 +787,9 @@ public function release_bookmark( $bookmark_name ) {
*/
public function seek( $bookmark_name ) {
$actual_bookmark_name = "_{$bookmark_name}";
- $processor_started_at = $this->current_token ? $this->bookmarks[ $this->current_token->bookmark_name ]->start : 0;
+ $processor_started_at = $this->state->current_token
+ ? $this->bookmarks[ $this->state->current_token->bookmark_name ]->start
+ : 0;
$bookmark_starts_at = $this->bookmarks[ $actual_bookmark_name ]->start;
$direction = $bookmark_starts_at > $processor_started_at ? 'forward' : 'backward';
@@ -804,7 +797,7 @@ public function seek( $bookmark_name ) {
case 'forward':
// When moving forwards, re-parse the document until reaching the same location as the original bookmark.
while ( $this->step() ) {
- if ( $bookmark_starts_at === $this->bookmarks[ $this->current_token->bookmark_name ]->start ) {
+ if ( $bookmark_starts_at === $this->bookmarks[ $this->state->current_token->bookmark_name ]->start ) {
return true;
}
}
From fd6c5606b1c572442f0eb15bafee0852cbbb7035 Mon Sep 17 00:00:00 2001
From: Sergey Biryukov
Date: Tue, 12 Sep 2023 15:21:02 +0000
Subject: [PATCH 070/105] Coding Standards: Include one space after `function`
keyword for closures.
Note: This is enforced by WPCS 3.0.0.
Reference: [https://github.com/WordPress/WordPress-Coding-Standards/pull/2328 WPCS: PR #2328 Core: properly check formatting of function declaration statements].
Props jrf.
See #59161, #58831.
git-svn-id: https://develop.svn.wordpress.org/trunk@56559 602fd350-edb4-49c9-b593-d223f7449a82
---
src/wp-admin/edit-form-blocks.php | 2 +-
.../includes/class-wp-community-events.php | 2 +-
.../class-wp-site-health-auto-updates.php | 2 +-
src/wp-admin/includes/file.php | 2 +-
src/wp-admin/includes/update-core.php | 2 +-
src/wp-admin/options-privacy.php | 2 +-
src/wp-admin/privacy-policy-guide.php | 2 +-
src/wp-admin/site-editor.php | 2 +-
src/wp-admin/upload.php | 2 +-
.../classes/class-twentytwenty-customize.php | 2 +-
.../class-twenty-twenty-one-customize.php | 2 +-
.../class-twenty-twenty-one-dark-mode.php | 8 ++---
src/wp-includes/block-supports/layout.php | 2 +-
src/wp-includes/blocks.php | 2 +-
src/wp-includes/blocks/index.php | 2 +-
.../class-wp-customize-widgets.php | 4 +--
src/wp-includes/class-wp-http.php | 2 +-
.../class-wp-navigation-fallback.php | 2 +-
src/wp-includes/class-wp-theme-json.php | 6 ++--
src/wp-includes/formatting.php | 6 ++--
src/wp-includes/functions.php | 2 +-
src/wp-includes/kses.php | 2 +-
src/wp-includes/post.php | 2 +-
.../endpoints/class-wp-rest-controller.php | 2 +-
.../class-wp-rest-plugins-controller.php | 4 +--
.../class-wp-rest-site-health-controller.php | 2 +-
.../class-wp-rest-widget-types-controller.php | 2 +-
.../class-wp-rest-widgets-controller.php | 2 +-
src/wp-includes/script-loader.php | 10 +++---
src/wp-includes/update.php | 2 +-
src/wp-includes/user.php | 2 +-
.../wp-content/mu-plugins/server-timing.php | 4 +--
tests/phpunit/tests/actions.php | 4 +--
tests/phpunit/tests/admin/includesFile.php | 2 +-
tests/phpunit/tests/admin/includesPost.php | 2 +-
tests/phpunit/tests/admin/includesSchema.php | 2 +-
.../tests/admin/wpAutomaticUpdater.php | 4 +--
.../tests/admin/wpCommentsListTable.php | 2 +-
tests/phpunit/tests/admin/wpSiteHealth.php | 2 +-
tests/phpunit/tests/ajax/wpAjaxAddTag.php | 2 +-
.../tests/ajax/wpAjaxAjaxTagSearch.php | 2 +-
tests/phpunit/tests/block-template.php | 2 +-
tests/phpunit/tests/blocks/context.php | 8 ++---
tests/phpunit/tests/blocks/editor.php | 2 +-
.../tests/blocks/getBlockTemplates.php | 2 +-
tests/phpunit/tests/blocks/register.php | 6 ++--
.../tests/blocks/renderCommentTemplate.php | 4 +--
tests/phpunit/tests/blocks/wpBlock.php | 16 ++++-----
tests/phpunit/tests/canonical.php | 2 +-
.../phpunit/tests/category/walkerCategory.php | 2 +-
tests/phpunit/tests/cron.php | 20 +++++------
tests/phpunit/tests/dependencies/scripts.php | 2 +-
tests/phpunit/tests/feed/rss2.php | 6 ++--
tests/phpunit/tests/file.php | 10 +++---
.../tests/formatting/wpTrimExcerpt.php | 2 +-
tests/phpunit/tests/functions.php | 4 +--
tests/phpunit/tests/functions/wpFilesize.php | 4 +--
.../phpunit/tests/general/feedLinksExtra.php | 4 +--
tests/phpunit/tests/http/http.php | 2 +-
tests/phpunit/tests/https-detection.php | 6 ++--
tests/phpunit/tests/https-migration.php | 4 +--
tests/phpunit/tests/image/editorImagick.php | 2 +-
tests/phpunit/tests/image/functions.php | 4 +--
.../phpunit/tests/image/intermediateSize.php | 2 +-
tests/phpunit/tests/l10n/determineLocale.php | 34 +++++++++----------
tests/phpunit/tests/link/editTermLink.php | 2 +-
tests/phpunit/tests/link/getEditTermLink.php | 2 +-
tests/phpunit/tests/media.php | 20 +++++------
.../media/wpGenerateAttachmentMetadata.php | 2 +-
.../tests/media/wpImageTagAddDecodingAttr.php | 4 +--
tests/phpunit/tests/menu/walker-nav-menu.php | 2 +-
.../option/wpSetOptionAutoloadValues.php | 2 +-
tests/phpunit/tests/post/getPages.php | 2 +-
tests/phpunit/tests/post/revisions.php | 2 +-
tests/phpunit/tests/post/thumbnails.php | 2 +-
tests/phpunit/tests/post/walkerPage.php | 2 +-
.../tests/post/wpGetAttachmentLink.php | 2 +-
tests/phpunit/tests/query.php | 4 +--
tests/phpunit/tests/query/conditionals.php | 4 +--
.../rest-application-passwords-controller.php | 2 +-
.../rest-block-directory-controller.php | 2 +-
.../rest-block-renderer-controller.php | 2 +-
.../rest-pattern-directory-controller.php | 4 +--
.../rest-api/rest-plugins-controller.php | 2 +-
.../tests/rest-api/rest-post-meta-fields.php | 2 +-
.../tests/rest-api/rest-posts-controller.php | 4 +--
tests/phpunit/tests/rest-api/rest-server.php | 10 +++---
.../rest-api/rest-widget-types-controller.php | 6 ++--
.../rest-api/wpRestUrlDetailsController.php | 8 ++---
tests/phpunit/tests/robots.php | 2 +-
tests/phpunit/tests/term/getTermLink.php | 2 +-
tests/phpunit/tests/theme/customHeader.php | 4 +--
.../tests/theme/wpThemeJsonResolver.php | 4 +--
tests/phpunit/tests/user/queryCache.php | 2 +-
tests/phpunit/tests/user/retrievePassword.php | 2 +-
tests/phpunit/tests/widgets.php | 2 +-
96 files changed, 188 insertions(+), 188 deletions(-)
diff --git a/src/wp-admin/edit-form-blocks.php b/src/wp-admin/edit-form-blocks.php
index 66a6bbfc25326..e200b29621924 100644
--- a/src/wp-admin/edit-form-blocks.php
+++ b/src/wp-admin/edit-form-blocks.php
@@ -31,7 +31,7 @@
// Default to is-fullscreen-mode to avoid jumps in the UI.
add_filter(
'admin_body_class',
- static function( $classes ) {
+ static function ( $classes ) {
return "$classes is-fullscreen-mode";
}
);
diff --git a/src/wp-admin/includes/class-wp-community-events.php b/src/wp-admin/includes/class-wp-community-events.php
index 09557c86a4782..008611af21c09 100644
--- a/src/wp-admin/includes/class-wp-community-events.php
+++ b/src/wp-admin/includes/class-wp-community-events.php
@@ -483,7 +483,7 @@ protected function trim_events( array $events ) {
$future_wordcamps = array_filter(
$future_events,
- static function( $wordcamp ) {
+ static function ( $wordcamp ) {
return 'wordcamp' === $wordcamp['type'];
}
);
diff --git a/src/wp-admin/includes/class-wp-site-health-auto-updates.php b/src/wp-admin/includes/class-wp-site-health-auto-updates.php
index d1655eb1d87d6..f8521ab2b0846 100644
--- a/src/wp-admin/includes/class-wp-site-health-auto-updates.php
+++ b/src/wp-admin/includes/class-wp-site-health-auto-updates.php
@@ -42,7 +42,7 @@ public function run_tests() {
$tests = array_filter( $tests );
$tests = array_map(
- static function( $test ) {
+ static function ( $test ) {
$test = (object) $test;
if ( empty( $test->severity ) ) {
diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php
index aa8e25c8ed5fa..6531736bd95b9 100644
--- a/src/wp-admin/includes/file.php
+++ b/src/wp-admin/includes/file.php
@@ -2726,7 +2726,7 @@ function wp_opcache_invalidate_directory( $dir ) {
* with sub-directories represented as nested arrays.
* @param string $path Absolute path to the directory.
*/
- $invalidate_directory = static function( $dirlist, $path ) use ( &$invalidate_directory ) {
+ $invalidate_directory = static function ( $dirlist, $path ) use ( &$invalidate_directory ) {
$path = trailingslashit( $path );
foreach ( $dirlist as $name => $details ) {
diff --git a/src/wp-admin/includes/update-core.php b/src/wp-admin/includes/update-core.php
index 6085b02c8fdc4..fdb522c889609 100644
--- a/src/wp-admin/includes/update-core.php
+++ b/src/wp-admin/includes/update-core.php
@@ -1805,7 +1805,7 @@ function _upgrade_422_find_genericons_files_in_folder( $directory ) {
$dirs = glob( $directory . '*', GLOB_ONLYDIR );
$dirs = array_filter(
$dirs,
- static function( $dir ) {
+ static function ( $dir ) {
/*
* Skip any node_modules directories.
*
diff --git a/src/wp-admin/options-privacy.php b/src/wp-admin/options-privacy.php
index 5c22d39d5df67..1afb8c0601388 100644
--- a/src/wp-admin/options-privacy.php
+++ b/src/wp-admin/options-privacy.php
@@ -23,7 +23,7 @@
add_filter(
'admin_body_class',
- static function( $body_class ) {
+ static function ( $body_class ) {
$body_class .= ' privacy-settings ';
return $body_class;
diff --git a/src/wp-admin/privacy-policy-guide.php b/src/wp-admin/privacy-policy-guide.php
index 7e92a4dea6a83..b8f303aa7f4e0 100644
--- a/src/wp-admin/privacy-policy-guide.php
+++ b/src/wp-admin/privacy-policy-guide.php
@@ -22,7 +22,7 @@
add_filter(
'admin_body_class',
- static function( $body_class ) {
+ static function ( $body_class ) {
$body_class .= ' privacy-settings ';
return $body_class;
diff --git a/src/wp-admin/site-editor.php b/src/wp-admin/site-editor.php
index b7cdfbe0dff63..2da7222d7c8ff 100644
--- a/src/wp-admin/site-editor.php
+++ b/src/wp-admin/site-editor.php
@@ -42,7 +42,7 @@
// Default to is-fullscreen-mode to avoid jumps in the UI.
add_filter(
'admin_body_class',
- static function( $classes ) {
+ static function ( $classes ) {
return "$classes is-fullscreen-mode";
}
);
diff --git a/src/wp-admin/upload.php b/src/wp-admin/upload.php
index 13b54c5840835..6d8c8462b7c19 100644
--- a/src/wp-admin/upload.php
+++ b/src/wp-admin/upload.php
@@ -144,7 +144,7 @@
// Remove the error parameter added by deprecation of wp-admin/media.php.
add_filter(
'removable_query_args',
- function() {
+ function () {
return array( 'error' );
},
10,
diff --git a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-customize.php b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-customize.php
index dedcb3788243b..8a560a8d49ab4 100644
--- a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-customize.php
+++ b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-customize.php
@@ -187,7 +187,7 @@ public static function register( $wp_customize ) {
'settings' => 'accent_hue',
'description' => __( 'Apply a custom color for links, buttons, featured images.', 'twentytwenty' ),
'mode' => 'hue',
- 'active_callback' => static function() use ( $wp_customize ) {
+ 'active_callback' => static function () use ( $wp_customize ) {
return ( 'custom' === $wp_customize->get_setting( 'accent_hue_active' )->value() );
},
)
diff --git a/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-customize.php b/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-customize.php
index d3af05ec42a79..903334089db4d 100644
--- a/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-customize.php
+++ b/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-customize.php
@@ -92,7 +92,7 @@ public function register( $wp_customize ) {
array(
'capability' => 'edit_theme_options',
'default' => 'excerpt',
- 'sanitize_callback' => static function( $value ) {
+ 'sanitize_callback' => static function ( $value ) {
return 'excerpt' === $value || 'full' === $value ? $value : 'excerpt';
},
)
diff --git a/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php b/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php
index 611ce3756f195..39b3fb726fc88 100644
--- a/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php
+++ b/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php
@@ -153,7 +153,7 @@ public function customizer_controls( $wp_customize ) {
array(
'section' => 'colors',
'priority' => 100,
- 'active_callback' => static function() {
+ 'active_callback' => static function () {
return 127 >= Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( get_theme_mod( 'background_color', 'D1E4DD' ) );
},
)
@@ -165,7 +165,7 @@ public function customizer_controls( $wp_customize ) {
array(
'capability' => 'edit_theme_options',
'default' => false,
- 'sanitize_callback' => static function( $value ) {
+ 'sanitize_callback' => static function ( $value ) {
return (bool) $value;
},
)
@@ -188,7 +188,7 @@ public function customizer_controls( $wp_customize ) {
'label' => esc_html__( 'Dark Mode support', 'twentytwentyone' ),
'priority' => 110,
'description' => $description,
- 'active_callback' => static function( $value ) {
+ 'active_callback' => static function ( $value ) {
return 127 < Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( get_theme_mod( 'background_color', 'D1E4DD' ) );
},
)
@@ -200,7 +200,7 @@ public function customizer_controls( $wp_customize ) {
array(
'selector' => '#dark-mode-toggler',
'container_inclusive' => true,
- 'render_callback' => function() {
+ 'render_callback' => function () {
$attrs = ( $this->switch_should_render() ) ? array() : array( 'style' => 'display:none;' );
$this->the_html( $attrs );
},
diff --git a/src/wp-includes/block-supports/layout.php b/src/wp-includes/block-supports/layout.php
index 519574238dee9..89713c772d206 100644
--- a/src/wp-includes/block-supports/layout.php
+++ b/src/wp-includes/block-supports/layout.php
@@ -789,7 +789,7 @@ function wp_restore_group_inner_container( $block_content, $block ) {
);
$updated_content = preg_replace_callback(
$replace_regex,
- static function( $matches ) {
+ static function ( $matches ) {
return $matches[1] . '