diff --git a/composer.json b/composer.json index 6892d57dd..bbc74de5c 100644 --- a/composer.json +++ b/composer.json @@ -80,7 +80,7 @@ "phpcompatibility/phpcompatibility-wp": "*", "phpunit/phpunit": "^9.5", "rmccue/requests": "^1.8.1", - "wp-coding-standards/wpcs": "2.*", + "wp-coding-standards/wpcs": "^3.4.1", "wp-phpunit/wp-phpunit": "~6.0", "wporg/wporg-parent-2021": "dev-build", "yoast/phpunit-polyfills": "^1.1" diff --git a/composer.lock b/composer.lock index a99b44681..71f5fa5a3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6cc3f076541e82842035264fae168138", + "content-hash": "53b746cf888dce9779e2e0cb2503240c", "packages": [ { "name": "adhocore/jwt", @@ -963,6 +963,181 @@ ], "time": "2025-05-12T16:38:37+00:00" }, + { + "name": "phpcsstandards/phpcsextra", + "version": "1.5.1", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHPCSExtra.git", + "reference": "39467533fdb742446d68c1d10ac33d625ee0311c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/39467533fdb742446d68c1d10ac33d625ee0311c", + "reference": "39467533fdb742446d68c1d10ac33d625ee0311c", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "phpcsstandards/phpcsutils": "^1.2.3", + "squizlabs/php_codesniffer": "^3.13.5 || ^4.0.1" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcsstandards/phpcsdevcs": "^1.2.0", + "phpcsstandards/phpcsdevtools": "^1.2.1", + "phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSExtra/graphs/contributors" + } + ], + "description": "A collection of sniffs and standards for use with PHP_CodeSniffer.", + "keywords": [ + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", + "phpcs", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/PHPCSExtra/issues", + "security": "https://github.com/PHPCSStandards/PHPCSExtra/security/policy", + "source": "https://github.com/PHPCSStandards/PHPCSExtra" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2026-07-27T11:13:17+00:00" + }, + { + "name": "phpcsstandards/phpcsutils", + "version": "1.2.3", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", + "reference": "5f35d9408c54d7b529501f3c688b6eae562aea1f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/5f35d9408c54d7b529501f3c688b6eae562aea1f", + "reference": "5f35d9408c54d7b529501f3c688b6eae562aea1f", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", + "php": ">=5.4", + "squizlabs/php_codesniffer": "^3.13.5 || ^4.0.1" + }, + "require-dev": { + "ext-filter": "*", + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcsstandards/phpcsdevcs": "^1.2.0", + "yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0 || ^3.0.0" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "autoload": { + "classmap": [ + "PHPCSUtils/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSUtils/graphs/contributors" + } + ], + "description": "A suite of utility functions for use with PHP_CodeSniffer", + "homepage": "https://phpcsutils.com/", + "keywords": [ + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", + "phpcs", + "phpcs3", + "phpcs4", + "standards", + "static analysis", + "tokens", + "utility" + ], + "support": { + "docs": "https://phpcsutils.com/", + "issues": "https://github.com/PHPCSStandards/PHPCSUtils/issues", + "security": "https://github.com/PHPCSStandards/PHPCSUtils/security/policy", + "source": "https://github.com/PHPCSStandards/PHPCSUtils" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2026-07-27T10:28:41+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "9.2.32", @@ -2418,16 +2593,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.13.2", + "version": "3.13.5", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "5b5e3821314f947dd040c70f7992a64eac89025c" + "reference": "0ca86845ce43291e8f5692c7356fccf3bcf02bf4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/5b5e3821314f947dd040c70f7992a64eac89025c", - "reference": "5b5e3821314f947dd040c70f7992a64eac89025c", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/0ca86845ce43291e8f5692c7356fccf3bcf02bf4", + "reference": "0ca86845ce43291e8f5692c7356fccf3bcf02bf4", "shasum": "" }, "require": { @@ -2444,11 +2619,6 @@ "bin/phpcs" ], "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } - }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" @@ -2498,7 +2668,7 @@ "type": "thanks_dev" } ], - "time": "2025-06-17T22:17:01+00:00" + "time": "2025-11-04T16:30:35+00:00" }, { "name": "theseer/tokenizer", @@ -2552,30 +2722,38 @@ }, { "name": "wp-coding-standards/wpcs", - "version": "2.3.0", + "version": "3.4.1", "source": { "type": "git", "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", - "reference": "7da1894633f168fe244afc6de00d141f27517b62" + "reference": "ec2ff942335f33683a5957a85d138753876a05cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/7da1894633f168fe244afc6de00d141f27517b62", - "reference": "7da1894633f168fe244afc6de00d141f27517b62", + "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/ec2ff942335f33683a5957a85d138753876a05cf", + "reference": "ec2ff942335f33683a5957a85d138753876a05cf", "shasum": "" }, "require": { - "php": ">=5.4", - "squizlabs/php_codesniffer": "^3.3.1" + "ext-filter": "*", + "ext-libxml": "*", + "ext-tokenizer": "*", + "ext-xmlreader": "*", + "php": ">=7.2", + "phpcsstandards/phpcsextra": "^1.5.1", + "phpcsstandards/phpcsutils": "^1.2.3", + "squizlabs/php_codesniffer": "^3.13.5" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || ^0.6", - "phpcompatibility/php-compatibility": "^9.0", - "phpcsstandards/phpcsdevtools": "^1.0", - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "php-parallel-lint/php-console-highlighter": "^1.0.0", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcompatibility/php-compatibility": "^10.0.0@dev", + "phpcsstandards/phpcsdevtools": "^1.2.0", + "phpunit/phpunit": "^8.0 || ^9.0" }, "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.6 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically." + "ext-iconv": "For improved results", + "ext-mbstring": "For improved results" }, "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", @@ -2592,6 +2770,7 @@ "keywords": [ "phpcs", "standards", + "static analysis", "wordpress" ], "support": { @@ -2599,7 +2778,13 @@ "source": "https://github.com/WordPress/WordPress-Coding-Standards", "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" }, - "time": "2020-05-13T23:57:56+00:00" + "funding": [ + { + "url": "https://opencollective.com/php_codesniffer", + "type": "custom" + } + ], + "time": "2026-07-27T11:53:23+00:00" }, { "name": "wp-phpunit/wp-phpunit", diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 56a8ad17d..9c82c7a49 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -93,7 +93,7 @@ - + @@ -151,4 +151,8 @@ + + + 0 + diff --git a/public_html/wp-content/plugins/pattern-creator/includes/mock-blocks.php b/public_html/wp-content/plugins/pattern-creator/includes/mock-blocks.php index 214d78a71..a8e91c957 100644 --- a/public_html/wp-content/plugins/pattern-creator/includes/mock-blocks.php +++ b/public_html/wp-content/plugins/pattern-creator/includes/mock-blocks.php @@ -109,31 +109,31 @@ function render_latest_comments( $block_content, $block, $block_instance ) { /* Note: This is not translated (for now) because the post content is also not translated. */ $comments = array( - [ + array( 'author' => 'Noah', 'post_title' => 'Jupiter', 'date' => strtotime( '5 days ago' ), 'content' => 'Since its orbital revolution occupies nearly twelve years, Jupiter comes back into opposition with the Sun every 399 days.', - ], - [ + ), + array( 'author' => 'Sabrina', 'post_title' => 'Jupiter', 'date' => strtotime( '1 week ago' ), 'content' => 'Most conspicuous upon this globe are the larger or smaller bands or markings (gray and white, sometimes tinted yellow, or of a maroon or chocolate hue) by which its surface is streaked, particularly in the vicinity of the equator.', - ], - [ + ), + array( 'author' => 'Yvonne', 'post_title' => 'The November Meteors', 'date' => strtotime( '2 weeks ago' ), 'content' => 'One or two unknown planets, some wandering comets, and swarms of meteors, doubtless traverse those unknown spaces, but all invisible to us.', - ], + ), ); $comments = array_slice( $comments, 0, min( 3, $attributes['commentsToShow'] ) ); foreach ( $comments as $comment ) { $list_items_markup .= '
  • '; if ( $attributes['displayAvatar'] ) { - $list_items_markup .= get_avatar( null, 48, '', '', [ 'class' => 'wp-block-latest-comments__comment-avatar' ] ); + $list_items_markup .= get_avatar( null, 48, '', '', array( 'class' => 'wp-block-latest-comments__comment-avatar' ) ); } $list_items_markup .= '
    '; diff --git a/public_html/wp-content/plugins/pattern-creator/includes/openverse-client.php b/public_html/wp-content/plugins/pattern-creator/includes/openverse-client.php index 66ede28b3..04757dddb 100644 --- a/public_html/wp-content/plugins/pattern-creator/includes/openverse-client.php +++ b/public_html/wp-content/plugins/pattern-creator/includes/openverse-client.php @@ -28,7 +28,7 @@ class Openverse_Client { /** * Openverse_Client constructor. */ - public function __construct( array $params = [] ) { + public function __construct( array $params = array() ) { $defaults = array( 'per_page' => 30, 'page' => 1, @@ -228,7 +228,7 @@ public function search() { trigger_error( $results->get_error_code() . ' ' . $results->get_error_message(), E_USER_WARNING ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped // Set a short timeout to avoid hammering the API during outages. - set_transient( $cache_key, [], 0.5 * MINUTE_IN_SECONDS ); + set_transient( $cache_key, array(), 0.5 * MINUTE_IN_SECONDS ); return new WP_Error( 'search-request-failed', diff --git a/public_html/wp-content/plugins/pattern-creator/pattern-creator.php b/public_html/wp-content/plugins/pattern-creator/pattern-creator.php index 2dfccac4e..21b59cf49 100644 --- a/public_html/wp-content/plugins/pattern-creator/pattern-creator.php +++ b/public_html/wp-content/plugins/pattern-creator/pattern-creator.php @@ -11,9 +11,10 @@ */ namespace WordPressdotorg\Pattern_Creator; -use const WordPressdotorg\Pattern_Directory\Pattern_Post_Type\POST_TYPE; -use function WordPressdotorg\MU_Plugins\Global_Header_Footer\{ is_rosetta_site, get_rosetta_name }; + use WP_Block_Editor_Context; +use function WordPressdotorg\MU_Plugins\Global_Header_Footer\{ is_rosetta_site, get_rosetta_name }; +use const WordPressdotorg\Pattern_Directory\Pattern_Post_Type\POST_TYPE; const AUTOSAVE_INTERVAL = 30; const IS_EDIT_VAR = 'edit-pattern'; @@ -84,13 +85,13 @@ function pattern_creator_init() { wp_deregister_style( 'wporg-parent-2021-style' ); wp_deregister_style( 'global-styles' ); - $dir = dirname( __FILE__ ); + $dir = __DIR__; $script_asset_path = "$dir/build/index.asset.php"; if ( ! file_exists( $script_asset_path ) ) { throw new \Error( 'You need to run `npm run start:creator` or `npm run build:creator` for the Pattern Creator.' ); } - $script_asset = require( $script_asset_path ); + $script_asset = require $script_asset_path; wp_enqueue_script( 'wp-pattern-creator', plugins_url( 'build/index.js', __FILE__ ), diff --git a/public_html/wp-content/plugins/pattern-creator/view/editor.php b/public_html/wp-content/plugins/pattern-creator/view/editor.php index a8fde1fc0..a4b561448 100644 --- a/public_html/wp-content/plugins/pattern-creator/view/editor.php +++ b/public_html/wp-content/plugins/pattern-creator/view/editor.php @@ -6,7 +6,7 @@ namespace WordPressdotorg\Pattern_Creator; use const WordPressdotorg\Pattern_Directory\Pattern_Post_Type\POST_TYPE; -add_filter( 'body_class', function( $classes ) { +add_filter( 'body_class', function ( $classes ) { $classes[] = 'admin-color-modern'; return $classes; } ); diff --git a/public_html/wp-content/plugins/pattern-directory/bin/check-spam.php b/public_html/wp-content/plugins/pattern-directory/bin/check-spam.php index 6b6883ba7..d37d6459d 100755 --- a/public_html/wp-content/plugins/pattern-directory/bin/check-spam.php +++ b/public_html/wp-content/plugins/pattern-directory/bin/check-spam.php @@ -103,10 +103,9 @@ ); } } - } else { - if ( $opts['verbose'] ) { + } elseif ( $opts['verbose'] ) { echo "{$pattern->ID}: Not spam.\n"; // phpcs:ignore - } + } } diff --git a/public_html/wp-content/plugins/pattern-directory/includes/admin-flags.php b/public_html/wp-content/plugins/pattern-directory/includes/admin-flags.php index 9e067d049..d34d2686c 100644 --- a/public_html/wp-content/plugins/pattern-directory/includes/admin-flags.php +++ b/public_html/wp-content/plugins/pattern-directory/includes/admin-flags.php @@ -303,10 +303,10 @@ function flag_list_table_views( $views ) { if ( $parent_id ) { $views = array_map( // Add a post_parent parameter to each view's URL. - function( $item ) use ( $parent_id ) { + function ( $item ) use ( $parent_id ) { return preg_replace_callback( '|href=[\'"]+([^\'"]+)[\'"]+|', - function( $matches ) use ( $parent_id ) { + function ( $matches ) use ( $parent_id ) { $old_url = wp_kses_decode_entities( $matches[1] ); $new_url = add_query_arg( array( 'post_parent' => $parent_id ), $old_url ); diff --git a/public_html/wp-content/plugins/pattern-directory/includes/admin-patterns.php b/public_html/wp-content/plugins/pattern-directory/includes/admin-patterns.php index 4cbe13f50..9091857e2 100644 --- a/public_html/wp-content/plugins/pattern-directory/includes/admin-patterns.php +++ b/public_html/wp-content/plugins/pattern-directory/includes/admin-patterns.php @@ -9,7 +9,7 @@ use const WordPressdotorg\Pattern_Directory\Pattern_Flag_Post_Type\POST_TYPE as FLAG; use const WordPressdotorg\Pattern_Directory\Pattern_Flag_Post_Type\TAX_TYPE as FLAG_REASON; use const WordPressdotorg\Pattern_Directory\Pattern_Flag_Post_Type\PENDING_STATUS; -use const WordPressdotorg\Pattern_Directory\Pattern_Post_Type\{ UNLISTED_STATUS, SPAM_STATUS }; +use const WordPressdotorg\Pattern_Directory\Pattern_Post_Type\{ UNLISTED_STATUS, SPAM_STATUS }; defined( 'WPINC' ) || die(); @@ -399,7 +399,7 @@ function display_post_states( $post_states, $post ) { if ( $post->post_status !== $post_status && - in_array( $post->post_status, [ UNLISTED_STATUS, SPAM_STATUS ] ) + in_array( $post->post_status, array( UNLISTED_STATUS, SPAM_STATUS ) ) ) { $post_states[ $post->post_status ] = get_post_status_object( $post->post_status )->label; } diff --git a/public_html/wp-content/plugins/pattern-directory/includes/admin-settings.php b/public_html/wp-content/plugins/pattern-directory/includes/admin-settings.php index 30a6b5f40..b43d5d649 100644 --- a/public_html/wp-content/plugins/pattern-directory/includes/admin-settings.php +++ b/public_html/wp-content/plugins/pattern-directory/includes/admin-settings.php @@ -50,7 +50,7 @@ function admin_init() { 'wporg-pattern-default_status', array( 'type' => 'string', - 'sanitize_callback' => function( $value ) { + 'sanitize_callback' => function ( $value ) { return in_array( $value, array( 'publish', 'pending' ) ) ? $value : 'publish'; }, 'default' => 'publish', @@ -73,7 +73,7 @@ function admin_init() { 'wporg-pattern-flag_threshold', array( 'type' => 'integer', - 'sanitize_callback' => function( $value ) { + 'sanitize_callback' => function ( $value ) { $value = absint( $value ); if ( $value < 1 || $value > 100 ) { diff --git a/public_html/wp-content/plugins/pattern-directory/includes/admin-stats.php b/public_html/wp-content/plugins/pattern-directory/includes/admin-stats.php index 3395ffc1e..475871f86 100644 --- a/public_html/wp-content/plugins/pattern-directory/includes/admin-stats.php +++ b/public_html/wp-content/plugins/pattern-directory/includes/admin-stats.php @@ -95,7 +95,7 @@ function get_snapshot_meta_data() { * @return array */ function get_export_form_inputs() { - $date_filter = function( $string ) { + $date_filter = function ( $string ) { $success = preg_match( '|([0-9]{4}\-[0-9]{2}\-[0-9]{2})|', $string, $match ); if ( $success ) { @@ -230,7 +230,7 @@ function handle_csv_export() { } $data = array_map( - function( $snapshot ) use ( $schema ) { + function ( $snapshot ) use ( $schema ) { $date = get_the_date( 'Y-m-d', $snapshot ); $row = array( $date ); diff --git a/public_html/wp-content/plugins/pattern-directory/includes/badges.php b/public_html/wp-content/plugins/pattern-directory/includes/badges.php index f27a8b7aa..14d297acc 100644 --- a/public_html/wp-content/plugins/pattern-directory/includes/badges.php +++ b/public_html/wp-content/plugins/pattern-directory/includes/badges.php @@ -1,4 +1,8 @@ post_author ); } elseif ( 'publish' === $old_status && 'publish' !== $new_status ) { // If the user has no published patterns, remove the badge. - $other_posts = get_posts( [ + $other_posts = get_posts( array( 'post_type' => PATTERN_POST_TYPE, 'post_status' => 'publish', 'author' => $post->post_author, 'exclude' => $post->ID, 'numberposts' => 1, 'fields' => 'ids', - ] ); + ) ); if ( ! $other_posts ) { remove_badge( 'pattern-author', $post->post_author ); diff --git a/public_html/wp-content/plugins/pattern-directory/includes/class-export-csv.php b/public_html/wp-content/plugins/pattern-directory/includes/class-export-csv.php index 09478cd1f..78a75937c 100644 --- a/public_html/wp-content/plugins/pattern-directory/includes/class-export-csv.php +++ b/public_html/wp-content/plugins/pattern-directory/includes/class-export-csv.php @@ -88,7 +88,7 @@ public function set_filename( $name_segments ) { $name_segments = (array) $name_segments; } - $name_segments = array_map( function( $segment ) { + $name_segments = array_map( function ( $segment ) { $segment = strtolower( $segment ); $segment = str_replace( '_', '-', $segment ); $segment = sanitize_file_name( $segment ); diff --git a/public_html/wp-content/plugins/pattern-directory/includes/class-rest-favorite-controller.php b/public_html/wp-content/plugins/pattern-directory/includes/class-rest-favorite-controller.php index 150716bc7..a5340247d 100644 --- a/public_html/wp-content/plugins/pattern-directory/includes/class-rest-favorite-controller.php +++ b/public_html/wp-content/plugins/pattern-directory/includes/class-rest-favorite-controller.php @@ -2,8 +2,8 @@ namespace WordPressdotorg\Pattern_Directory\Favorites_API; -use function WordPressdotorg\Pattern_Directory\Favorite\{add_favorite, get_favorite_count, get_favorites, remove_favorite}; use WP_Error, WP_REST_Server, WP_REST_Response; +use function WordPressdotorg\Pattern_Directory\Favorite\{add_favorite, get_favorite_count, get_favorites, remove_favorite}; add_action( 'rest_api_init', __NAMESPACE__ . '\init' ); @@ -23,7 +23,7 @@ function init() { $args = array( 'id' => array( - 'validate_callback' => function( $param, $request, $key ) { + 'validate_callback' => function ( $param, $request, $key ) { return is_numeric( $param ); }, ), diff --git a/public_html/wp-content/plugins/pattern-directory/includes/logging.php b/public_html/wp-content/plugins/pattern-directory/includes/logging.php index 6ea583e38..666685932 100644 --- a/public_html/wp-content/plugins/pattern-directory/includes/logging.php +++ b/public_html/wp-content/plugins/pattern-directory/includes/logging.php @@ -1,4 +1,7 @@ description ); }, $reasons diff --git a/public_html/wp-content/plugins/pattern-directory/includes/pattern-post-type.php b/public_html/wp-content/plugins/pattern-directory/includes/pattern-post-type.php index f47b79bf2..4f6a6e05b 100644 --- a/public_html/wp-content/plugins/pattern-directory/includes/pattern-post-type.php +++ b/public_html/wp-content/plugins/pattern-directory/includes/pattern-post-type.php @@ -197,7 +197,7 @@ function register_post_type_data() { 'type' => 'string', 'description' => 'A list of block types this pattern supports for transforms.', 'single' => false, - 'sanitize_callback' => function( $value, $key, $type ) { + 'sanitize_callback' => function ( $value, $key, $type ) { return preg_replace( '/[^a-z0-9-\/]/', '', $value ); }, 'auth_callback' => __NAMESPACE__ . '\can_edit_this_pattern', @@ -216,7 +216,7 @@ function register_post_type_data() { 'type' => 'string', 'description' => 'The language used when creating this pattern.', 'single' => true, - 'sanitize_callback' => function( $value ) { + 'sanitize_callback' => function ( $value ) { if ( ! in_array( $value, array_keys( get_locales() ), true ) ) { return 'en_US'; } @@ -291,10 +291,10 @@ function register_rest_fields() { POST_TYPE, 'category_slugs', array( - 'get_callback' => function() { + 'get_callback' => function () { $slugs = wp_list_pluck( wp_get_object_terms( get_the_ID(), 'wporg-pattern-category' ), 'slug' ); $slugs = array_map( 'sanitize_title', $slugs ); - $slugs = array_diff( $slugs, [ 'featured' ] ); + $slugs = array_diff( $slugs, array( 'featured' ) ); $slugs = array_values( $slugs ); return $slugs; @@ -314,7 +314,7 @@ function register_rest_fields() { POST_TYPE, 'keyword_slugs', array( - 'get_callback' => function() { + 'get_callback' => function () { $slugs = wp_list_pluck( wp_get_object_terms( get_the_ID(), 'wporg-pattern-keyword' ), 'slug' ); return array_map( 'sanitize_title', $slugs ); @@ -340,7 +340,7 @@ function register_rest_fields() { POST_TYPE, 'pattern_content', array( - 'get_callback' => function( $response_data ) { + 'get_callback' => function ( $response_data ) { $pattern = get_post( $response_data['id'] ); return decode_pattern_content( $pattern->post_content ); }, @@ -358,7 +358,7 @@ function register_rest_fields() { POST_TYPE, 'favorite_count', array( - 'get_callback' => function() { + 'get_callback' => function () { return get_favorite_count( get_the_ID() ); }, @@ -376,7 +376,7 @@ function register_rest_fields() { POST_TYPE, 'author_meta', array( - 'get_callback' => function( $post ) { + 'get_callback' => function ( $post ) { return array( 'name' => esc_html( get_the_author_meta( 'display_name', $post['author'] ) ), 'url' => esc_url( home_url( '/author/' . get_the_author_meta( 'user_nicename', $post['author'] ) ) ), @@ -420,7 +420,7 @@ function register_rest_fields() { POST_TYPE, 'unlisted_reason', array( - 'get_callback' => function() { + 'get_callback' => function () { $reasons = wp_get_object_terms( get_the_ID(), FLAG_REASON ); if ( count( $reasons ) > 0 ) { $reason = array_shift( $reasons ); @@ -560,7 +560,7 @@ function enqueue_editor_assets() { return; } - $dir = dirname( dirname( __FILE__ ) ); + $dir = dirname( __DIR__ ); $script_asset_path = "$dir/build/pattern-post-type.asset.php"; if ( ! file_exists( $script_asset_path ) ) { @@ -570,7 +570,7 @@ function enqueue_editor_assets() { $script_asset = require $script_asset_path; wp_enqueue_script( 'wporg-pattern-post-type', - plugins_url( 'build/pattern-post-type.js', dirname( __FILE__ ) ), + plugins_url( 'build/pattern-post-type.js', __DIR__ ), $script_asset['dependencies'], $script_asset['version'], true @@ -588,7 +588,7 @@ function enqueue_editor_assets() { wp_enqueue_style( 'wporg-pattern-post-type', - plugins_url( 'build/pattern-post-type.css', dirname( __FILE__ ) ), + plugins_url( 'build/pattern-post-type.css', __DIR__ ), array(), $script_asset['version'], ); @@ -665,7 +665,7 @@ function filter_patterns_collection_params( $query_params ) { $query_params['author_name'] = array( 'description' => __( 'Limit result set to patterns by a single author.', 'wporg-patterns' ), 'type' => 'string', - 'validate_callback' => function( $value ) { + 'validate_callback' => function ( $value ) { $user = get_user_by( 'slug', $value ); return (bool) $user; }, @@ -904,7 +904,7 @@ function setup_preview_theme() { if ( preg_match( '#/view/$#', $request_uri ) || preg_match( '#[?&]view=[1|true]#', $request_uri ) ) { add_filter( 'show_admin_bar', '__return_false', 2000 ); - add_filter( 'template', function() { + add_filter( 'template', function () { if ( 'local' === wp_get_environment_type() ) { return 'twentytwentythree'; } else { @@ -912,7 +912,7 @@ function setup_preview_theme() { } } ); - add_filter( 'stylesheet', function() { + add_filter( 'stylesheet', function () { if ( 'local' === wp_get_environment_type() ) { return 'twentytwentythree'; } else { @@ -920,7 +920,7 @@ function setup_preview_theme() { } } ); - add_filter( 'wp_enqueue_scripts', function() { + add_filter( 'wp_enqueue_scripts', function () { wp_deregister_style( 'wp4-styles' ); wp_deregister_style( 'wporg-global-header-footer' ); }, 201 ); @@ -992,7 +992,7 @@ function load_pattern_preview( $template ) { */ add_action( 'the_post', - function( $post ) { + function ( $post ) { $post->post_content = decode_pattern_content( $post->post_content ); } ); @@ -1009,7 +1009,7 @@ function( $post ) { */ function decode_pattern_content( $content ) { // Sometimes the initial `\` is missing, so look for both versions. - $content = str_replace( [ '\u0026amp;', 'u0026amp;' ], '&', $content ); + $content = str_replace( array( '\u0026amp;', 'u0026amp;' ), '&', $content ); // Remove `ref` from all content. $content = preg_replace( '/"ref":\d+,?/', '', $content ); return $content; diff --git a/public_html/wp-content/plugins/pattern-directory/includes/pattern-validation.php b/public_html/wp-content/plugins/pattern-directory/includes/pattern-validation.php index 2163759c3..72494d6e0 100644 --- a/public_html/wp-content/plugins/pattern-directory/includes/pattern-validation.php +++ b/public_html/wp-content/plugins/pattern-directory/includes/pattern-validation.php @@ -1,10 +1,10 @@ get_registered( $block['blockName'] ); return is_null( $block['blockName'] ) || is_null( $block_type ); } ); @@ -222,7 +222,7 @@ function validate_status( $prepared_post, $request ) { $current_status = get_post_status( $prepared_post->ID ); // Drafts or unlisted patterns are OK. - if ( in_array( $target_status, [ 'draft', 'auto-draft', UNLISTED_STATUS ] ) ) { + if ( in_array( $target_status, array( 'draft', 'auto-draft', UNLISTED_STATUS ) ) ) { return $prepared_post; } diff --git a/public_html/wp-content/plugins/pattern-directory/includes/search.php b/public_html/wp-content/plugins/pattern-directory/includes/search.php index 509eb2ad7..172088bde 100644 --- a/public_html/wp-content/plugins/pattern-directory/includes/search.php +++ b/public_html/wp-content/plugins/pattern-directory/includes/search.php @@ -62,7 +62,7 @@ function should_handle_query( $handle_query, $query ) { function modify_es_query_args( $es_query_args, $wp_query ) { $user_query = $wp_query->get( 's' ); $meta_query = $wp_query->get( 'meta_query' ); - $locales = [ 'en_US' ]; + $locales = array( 'en_US' ); if ( ! empty( $meta_query['orderby_locale']['value'] ) ) { $locales = array_unique( $meta_query['orderby_locale']['value'] ); @@ -70,40 +70,40 @@ function modify_es_query_args( $es_query_args, $wp_query ) { $parser = new Jetpack_WPES_Search_Query_Parser( $wp_query, array() ); - $must_query = [ - 'multi_match' => [ + $must_query = array( + 'multi_match' => array( 'query' => $user_query, - 'fields' => [ 'title_en', 'meta.wpop_description.value' ], + 'fields' => array( 'title_en', 'meta.wpop_description.value' ), 'boost' => 0.1, 'operator' => 'and', - ], - ]; + ), + ); - $should_query = [ - [ - 'multi_match' => [ + $should_query = array( + array( + 'multi_match' => array( 'query' => $user_query, - 'fields' => [ 'title_en' ], + 'fields' => array( 'title_en' ), 'boost' => 2, 'type' => 'phrase', - ], - ], + ), + ), - [ - 'multi_match' => [ + array( + 'multi_match' => array( // The `description_en` field in the ES index is actually `post_content`, but that's not // relevant in this context, since that's just sample content. The `wpop_description` // field is the actual description that should be searched. - 'fields' => [ 'meta.wpop_description.value' ], + 'fields' => array( 'meta.wpop_description.value' ), 'query' => $user_query, 'type' => 'phrase', - ], - ], - ]; + ), + ), + ); // Requests for a specific locale will still include `en_US` as a fallback. if ( count( $locales ) > 1 ) { - $primary_locale = array_reduce( $locales, function( $carry, $item ) { + $primary_locale = array_reduce( $locales, function ( $carry, $item ) { // This assumes there will only be 2 items in $locale. if ( 'en_US' !== $item ) { $carry = $item; @@ -113,31 +113,31 @@ function modify_es_query_args( $es_query_args, $wp_query ) { } ); // Boost the primary locale over the `en_US` fallback. - $should_query[] = [ - 'boosting' => [ - 'positive' => [ - 'term' => [ + $should_query[] = array( + 'boosting' => array( + 'positive' => array( + 'term' => array( 'meta.wpop_locale.value.raw' => $primary_locale, - ], - ], - 'negative' => [ - 'term' => [ + ), + ), + 'negative' => array( + 'term' => array( 'meta.wpop_locale.value.raw' => 'en_US', - ], - ], + ), + ), 'negative_boost' => 0.001, - ], - ]; + ), + ); } - $filter = [ - 'bool' => [ - 'must' => [ - [ 'term' => [ 'post_type' => 'wporg-pattern' ] ], - [ 'terms' => [ 'meta.wpop_locale.value.raw' => $locales ] ], - ], - ], - ]; + $filter = array( + 'bool' => array( + 'must' => array( + array( 'term' => array( 'post_type' => 'wporg-pattern' ) ), + array( 'terms' => array( 'meta.wpop_locale.value.raw' => $locales ) ), + ), + ), + ); $tax_query = $wp_query->get( 'tax_query' ); if ( $tax_query ) { @@ -149,9 +149,9 @@ function modify_es_query_args( $es_query_args, $wp_query ) { continue; } - $filter['bool']['must'][] = [ - 'terms' => [ "taxonomy.$taxonomy.term_id" => $term['terms'] ], - ]; + $filter['bool']['must'][] = array( + 'terms' => array( "taxonomy.$taxonomy.term_id" => $term['terms'] ), + ); } } @@ -162,13 +162,13 @@ function modify_es_query_args( $es_query_args, $wp_query ) { $es_query_args['query'] = $parser->build_query(); $es_query_args['filter'] = $parser->build_filter(); - $es_query_args['sort'] = [ - [ - '_score' => [ + $es_query_args['sort'] = array( + array( + '_score' => array( 'order' => 'desc', - ], - ], - ]; + ), + ), + ); return $es_query_args; } diff --git a/public_html/wp-content/plugins/pattern-directory/tests/phpunit/pattern-title-validation-test.php b/public_html/wp-content/plugins/pattern-directory/tests/phpunit/pattern-title-validation-test.php index 698bc44f7..505e2aa07 100644 --- a/public_html/wp-content/plugins/pattern-directory/tests/phpunit/pattern-title-validation-test.php +++ b/public_html/wp-content/plugins/pattern-directory/tests/phpunit/pattern-title-validation-test.php @@ -161,4 +161,3 @@ public function test_invalid_empty_existing_title() { $this->assertSame( 'rest_pattern_empty_title', $data['code'] ); } } - diff --git a/public_html/wp-content/plugins/pattern-translations/includes/cli-commands.php b/public_html/wp-content/plugins/pattern-translations/includes/cli-commands.php index c9a1a4049..5f3fcfb3c 100644 --- a/public_html/wp-content/plugins/pattern-translations/includes/cli-commands.php +++ b/public_html/wp-content/plugins/pattern-translations/includes/cli-commands.php @@ -21,7 +21,7 @@ public function json( $_, $args ) { $patterns = $this->get_patterns_or_exit( $args ); // Flatten parent to just being the slug. - array_walk( $patterns, function( $pattern ) { + array_walk( $patterns, function ( $pattern ) { $pattern->parent = $pattern->parent->name ?? $pattern->parent; } ); @@ -50,7 +50,7 @@ public function html( $_, $args ) { public function strings( $_, $args ) { $patterns = $this->get_patterns_or_exit( $args ); - $strings = []; + $strings = array(); foreach ( $patterns as $pattern ) { $parser = new PatternParser( $pattern ); @@ -103,7 +103,7 @@ private function get_patterns_or_exit( $args ) { $all_posts = isset( $args['all-posts'] ); $locale = $args['locale'] ?? false; - $query = []; + $query = array(); if ( false !== $post && ctype_digit( $post ) ) { $query['p'] = $post; @@ -139,5 +139,4 @@ private function get_patterns_or_exit( $args ) { return $patterns; } - } diff --git a/public_html/wp-content/plugins/pattern-translations/includes/cron.php b/public_html/wp-content/plugins/pattern-translations/includes/cron.php index f910c288d..5889285a4 100644 --- a/public_html/wp-content/plugins/pattern-translations/includes/cron.php +++ b/public_html/wp-content/plugins/pattern-translations/includes/cron.php @@ -17,7 +17,6 @@ function register_cron_tasks() { if ( ! wp_next_scheduled( 'pattern_import_translations_to_directory' ) ) { wp_schedule_event( time(), 'twicedaily', 'pattern_import_translations_to_directory' ); } - } add_action( 'admin_init', __NAMESPACE__ . '\register_cron_tasks' ); @@ -46,7 +45,7 @@ function pattern_import_to_glotpress() { */ function pattern_import_translations_to_directory( $pattern_ids = array() ) { if ( ! $pattern_ids ) { - $pattern_ids = Pattern::get_patterns( [ 'fields' => 'ids' ] ); + $pattern_ids = Pattern::get_patterns( array( 'fields' => 'ids' ) ); if ( wp_doing_cron() ) { // Chunk the patterns to avoid memory exhaustion. @@ -72,7 +71,7 @@ function pattern_import_translations_to_directory( $pattern_ids = array() ) { // Raise the memory limit for this process to at least 512M. add_filter( 'cron_memory_limit', - function() { + function () { return '512M'; } ); @@ -122,11 +121,11 @@ function() { function clear_memory_heavy_variables() { global $wpdb, $wp_object_cache; - $wpdb->queries = []; + $wpdb->queries = array(); if ( is_object( $wp_object_cache ) ) { - $wp_object_cache->cache = []; - $wp_object_cache->group_ops = []; - $wp_object_cache->memcache_debug = []; + $wp_object_cache->cache = array(); + $wp_object_cache->group_ops = array(); + $wp_object_cache->memcache_debug = array(); } } diff --git a/public_html/wp-content/plugins/pattern-translations/includes/i18n.php b/public_html/wp-content/plugins/pattern-translations/includes/i18n.php index bb5152e15..808eb8092 100644 --- a/public_html/wp-content/plugins/pattern-translations/includes/i18n.php +++ b/public_html/wp-content/plugins/pattern-translations/includes/i18n.php @@ -7,7 +7,7 @@ * @param array $patterns An array of Pattern objects to translate. * @return array The translated pattern objects. */ -function translate_patterns( array $patterns ) : array { +function translate_patterns( array $patterns ): array { return translate_patterns_to( $patterns, get_locale() ); } @@ -18,8 +18,8 @@ function translate_patterns( array $patterns ) : array { * @param string $locale The locale to translate into. * @return array The translated pattern objects. */ -function translate_patterns_to( array $patterns, string $locale ) : array { - return array_map( function( $pattern ) use ( $locale ) { +function translate_patterns_to( array $patterns, string $locale ): array { + return array_map( function ( $pattern ) use ( $locale ) { return $pattern->to_locale( $locale ) ?: $pattern; }, $patterns ); } diff --git a/public_html/wp-content/plugins/pattern-translations/includes/makepot.php b/public_html/wp-content/plugins/pattern-translations/includes/makepot.php index e5fc0efb0..ffb580439 100644 --- a/public_html/wp-content/plugins/pattern-translations/includes/makepot.php +++ b/public_html/wp-content/plugins/pattern-translations/includes/makepot.php @@ -9,11 +9,11 @@ public function __construct( array $patterns ) { $this->patterns = $patterns; } - public function makepot( $revision_time = null ) : string { + public function makepot( $revision_time = null ): string { return $this->makepo( $revision_time, $comment )->export(); } - public function makepo( $revision_time = null ) : \PO { + public function makepo( $revision_time = null ): \PO { require_once ABSPATH . '/wp-includes/pomo/po.php'; $po = new \PO(); @@ -31,8 +31,8 @@ public function makepo( $revision_time = null ) : \PO { return $po; } - public function entries() : array { - $entries = []; + public function entries(): array { + $entries = array(); foreach ( $this->patterns as $pattern ) { @@ -41,11 +41,11 @@ public function entries() : array { foreach ( $parser->to_strings() as $string ) { if ( ! isset( $entries[ $string ] ) ) { $entries[ $string ] = new \Translation_Entry( - [ + array( 'singular' => $string, 'extracted_comments' => "Found in the '{$pattern->title}' pattern.", - 'references' => [], - ] + 'references' => array(), + ) ); } @@ -77,9 +77,9 @@ public function import( $save = false ) { $po = $this->makepo(); if ( true === $save ) { - add_filter( 'gp_import_project_originals', [ $this, 'extend_imported_originals' ], 10, 3 ); + add_filter( 'gp_import_project_originals', array( $this, 'extend_imported_originals' ), 10, 3 ); list( $added, $existing, $fuzzied, $obsoleted, $error ) = \GP::$original->import_for_project( $project, $po ); - remove_filter( 'gp_import_project_originals', [ $this, 'extend_imported_originals' ], 10, 3 ); + remove_filter( 'gp_import_project_originals', array( $this, 'extend_imported_originals' ), 10, 3 ); $notice = sprintf( '%1$s new strings added, %2$s updated, %3$s fuzzied, and %4$s obsoleted.', @@ -121,7 +121,7 @@ public static function extend_imported_originals( $po, $project, $originals_by_k // Let's get all the references that we are importing. $import_references = array(); if ( ! empty( $po->entries ) ) { - $import_references = array_merge( ... array_column( $po->entries, 'references' ) ); + $import_references = array_merge( ...array_column( $po->entries, 'references' ) ); } foreach ( $originals_by_key as $entry_key => $original ) { @@ -145,13 +145,13 @@ public static function extend_imported_originals( $po, $project, $originals_by_k // otherwise, merge the original into the po as a new entry $po->add_entry( new \Translation_Entry( - [ + array( 'context' => $original->context, 'singular' => $original->singular, 'plural' => $original->plural, 'extracted_comments' => $original->comment, 'references' => $original_references, // Only include references not covered by our import - ] + ) ) ); } @@ -177,8 +177,8 @@ public function load_glotpress() { $GLOBALS['gp_table_prefix'] = GLOTPRESS_TABLE_PREFIX; // Load any GlotPress plugins as needed. - $plugins = get_option( 'active_plugins', [] ); - array_walk( $plugins, function( $plugin ) { + $plugins = get_option( 'active_plugins', array() ); + array_walk( $plugins, function ( $plugin ) { include_once trailingslashit( WP_PLUGIN_DIR ) . $plugin; } ); diff --git a/public_html/wp-content/plugins/pattern-translations/includes/parser.php b/public_html/wp-content/plugins/pattern-translations/includes/parser.php index 6e25b916f..0970408e0 100644 --- a/public_html/wp-content/plugins/pattern-translations/includes/parser.php +++ b/public_html/wp-content/plugins/pattern-translations/includes/parser.php @@ -14,13 +14,13 @@ class PatternParser { public $pattern; - public $parsers = []; + public $parsers = array(); public $fallback; public function __construct( Pattern $pattern ) { $this->pattern = $pattern; - $this->parsers = [ + $this->parsers = array( // Blocks that have custom parsers. 'core/paragraph' => new Parsers\Paragraph(), 'core/heading' => new Parsers\Heading(), @@ -38,12 +38,12 @@ public function __construct( Pattern $pattern ) { 'core/media-text' => new Parsers\BasicText(), 'core/separator' => new Parsers\BasicText(), 'core/social-link' => new Parsers\BasicText(), - ]; + ); $this->fallback = new Parsers\BasicText(); } - public function block_parser_to_strings( array $block ) : array { + public function block_parser_to_strings( array $block ): array { $parser = $this->parsers[ $block['blockName'] ] ?? $this->fallback; $strings = $parser->to_strings( $block ); @@ -55,7 +55,7 @@ public function block_parser_to_strings( array $block ) : array { return $strings; } - public function block_parser_replace_strings( array &$block, array $replacements ) : array { + public function block_parser_replace_strings( array &$block, array $replacements ): array { $parser = $this->parsers[ $block['blockName'] ] ?? $this->fallback; $block = $parser->replace_strings( $block, $replacements ); @@ -66,13 +66,13 @@ public function block_parser_replace_strings( array &$block, array $replacements return $block; } - public function to_strings() : array { + public function to_strings(): array { $blocks = parse_blocks( $this->pattern->html ); - $strings = []; + $strings = array(); if ( ! empty( $this->pattern->title ) ) { - $strings = [ $this->pattern->title ]; + $strings = array( $this->pattern->title ); } if ( ! empty( $this->pattern->description ) ) { @@ -91,7 +91,7 @@ public function to_strings() : array { return array_unique( $strings ); } - public function replace_strings_with_kses( array $replacements ) : Pattern { + public function replace_strings_with_kses( array $replacements ): Pattern { // Sanitize replacement strings before injecting them into blocks and block attributes. $sanitized_replacements = $replacements; foreach ( $sanitized_replacements as &$replacement ) { @@ -100,12 +100,12 @@ public function replace_strings_with_kses( array $replacements ) : Pattern { return $this->replace_strings( $sanitized_replacements ); } - public function replace_strings( array $replacements ) : Pattern { + public function replace_strings( array $replacements ): Pattern { $translated = clone $this->pattern; $translated->title = $replacements[ $translated->title ] ?? $translated->title; $translated->description = $replacements[ $translated->description ] ?? $translated->description; - $translated_keywords = []; + $translated_keywords = array(); foreach ( explode( ', ', $translated->keywords ) as $keyword ) { $translated_keywords[] = $replacements[ $keyword ] ?? $keyword; } @@ -142,13 +142,13 @@ public function decode_unicode_characters( string $string ): string { // in the placeholder attribute: // Reference: https://github.com/WordPress/WordPress/blob/HEAD/wp-includes/blocks.php#L367 - $excluded_characters = [ + $excluded_characters = array( '\\u002d\\u002d', // '--' '\\u003c', // '<' '\\u003e', // '>' '\\u0026', // '&' '\\u0022', // '"' - ]; + ); // Match any uninterrupted sequence of \u escaped unicode characters. $decoded_string = preg_replace_callback( diff --git a/public_html/wp-content/plugins/pattern-translations/includes/parsers/BasicText.php b/public_html/wp-content/plugins/pattern-translations/includes/parsers/BasicText.php index 43477bbf8..f3af34884 100644 --- a/public_html/wp-content/plugins/pattern-translations/includes/parsers/BasicText.php +++ b/public_html/wp-content/plugins/pattern-translations/includes/parsers/BasicText.php @@ -5,11 +5,11 @@ class BasicText implements BlockParser { use DomUtils; use TextNodesXPath; - public function to_strings( array $block ) : array { + public function to_strings( array $block ): array { $dom = $this->get_dom( $block['innerHTML'] ); $xpath = new \DOMXPath( $dom ); - $strings = []; + $strings = array(); foreach ( $xpath->query( $this->text_nodes_xpath_query() ) as $text ) { if ( trim( $text->nodeValue ) ) { @@ -20,7 +20,7 @@ public function to_strings( array $block ) : array { return $strings; } - public function replace_strings( array $block, array $replacements ) : array { + public function replace_strings( array $block, array $replacements ): array { $dom = $this->get_dom( $block['innerHTML'] ); $xpath = new \DOMXPath( $dom ); $xpath_query = $this->text_nodes_xpath_query(); @@ -54,5 +54,4 @@ public function replace_strings( array $block, array $replacements ) : array { return $block; } - } diff --git a/public_html/wp-content/plugins/pattern-translations/includes/parsers/BlockParser.php b/public_html/wp-content/plugins/pattern-translations/includes/parsers/BlockParser.php index b1edd6855..8fb5cd66f 100644 --- a/public_html/wp-content/plugins/pattern-translations/includes/parsers/BlockParser.php +++ b/public_html/wp-content/plugins/pattern-translations/includes/parsers/BlockParser.php @@ -15,31 +15,31 @@ // A block transform is specific to a certain block type and contains // the know-how of how to both extract and replace strings interface BlockParser { - public function to_strings( array $block ) : array; - public function replace_strings( array $block, array $replacements ) : array; + public function to_strings( array $block ): array; + public function replace_strings( array $block, array $replacements ): array; } // DomDocument::loadHTML with LIBXML_HTML_NOIMPLIED causes dom doc settings to format / strip whitespace from our html // Add/remove html tags to avoid the need for noimplied html trait DomUtils { // phpcs:disable WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid - private function addHtml( string $html ) : string { + private function addHtml( string $html ): string { return "$html"; } - private function removeHtml( string $html ) : string { + private function removeHtml( string $html ): string { return preg_replace( - [ + array( '/^\s*<\/head>/sm', // $dom->saveHTML() can have a trailing newline after the closing , match to the real end of the document. '/<\/body><\/html>\s*$/sm', - ], + ), '', $html ); } - private function get_dom( string $html ) : \DOMDocument { + private function get_dom( string $html ): \DOMDocument { $previous = libxml_use_internal_errors( true ); $dom = new \DomDocument(); $dom->loadHTML( $this->addHtml( $html ), LIBXML_HTML_NODEFDTD | LIBXML_COMPACT ); @@ -51,11 +51,11 @@ private function get_dom( string $html ) : \DOMDocument { } trait GetSetAttribute { - private function get_attribute( string $attribute_name, array $block ) : array { + private function get_attribute( string $attribute_name, array $block ): array { if ( isset( $block['attrs'][ $attribute_name ] ) && is_string( $block['attrs'][ $attribute_name ] ) ) { - return [ $block['attrs'][ $attribute_name ] ]; + return array( $block['attrs'][ $attribute_name ] ); } - return []; + return array(); } private function set_attribute( string $attribute_name, array &$block, array $replacements ) { @@ -68,12 +68,12 @@ private function set_attribute( string $attribute_name, array &$block, array $re } trait SwapTags { - private $safe_tags = [ + private $safe_tags = array( 'strong', 'em', - ]; + ); - private function encode_tags( string $raw_html ) : string { + private function encode_tags( string $raw_html ): string { foreach ( $this->safe_tags as $tag ) { $raw_html = preg_replace( '#(<' . $tag . '([^>]*)>)(.*)()#', @@ -84,7 +84,7 @@ private function encode_tags( string $raw_html ) : string { return $raw_html; } - private function decode_tags( string $encoded_html ) : string { + private function decode_tags( string $encoded_html ): string { foreach ( $this->safe_tags as $tag ) { $encoded_html = preg_replace( '#({' . $tag . '([^}]*)})(.*)({/' . $tag . '})#', @@ -97,11 +97,11 @@ private function decode_tags( string $encoded_html ) : string { } trait TextNodesXPath { - private $xpaths = [ + private $xpaths = array( '//text()', // Visible Text nodes. '//img/@alt', // Image alt="" text. '//*/@title', // title="" text. - ]; + ); protected function text_nodes_xpath_query() { return implode( ' | ', $this->xpaths ); diff --git a/public_html/wp-content/plugins/pattern-translations/includes/parsers/Button.php b/public_html/wp-content/plugins/pattern-translations/includes/parsers/Button.php index 65f52d50c..594528037 100644 --- a/public_html/wp-content/plugins/pattern-translations/includes/parsers/Button.php +++ b/public_html/wp-content/plugins/pattern-translations/includes/parsers/Button.php @@ -7,7 +7,7 @@ class Button implements BlockParser { use GetSetAttribute; use TextNodesXPath; - public function to_strings( array $block ) : array { + public function to_strings( array $block ): array { $strings = $this->get_attribute( 'placeholder', $block ); $encoded_html = $this->encode_tags( $block['innerHTML'] ); @@ -24,7 +24,7 @@ public function to_strings( array $block ) : array { return $strings; } - public function replace_strings( array $block, array $replacements ) : array { + public function replace_strings( array $block, array $replacements ): array { $this->set_attribute( 'placeholder', $block, $replacements ); $encoded_html = $this->encode_tags( $block['innerHTML'] ); @@ -47,7 +47,7 @@ public function replace_strings( array $block, array $replacements ) : array { $decoded_html = $this->decode_tags( $this->removeHtml( $dom->saveHTML() ) ); $block['innerHTML'] = $decoded_html; - $block['innerContent'] = [ $decoded_html ]; + $block['innerContent'] = array( $decoded_html ); return $block; } diff --git a/public_html/wp-content/plugins/pattern-translations/includes/parsers/Heading.php b/public_html/wp-content/plugins/pattern-translations/includes/parsers/Heading.php index a313b8a40..a4de74019 100644 --- a/public_html/wp-content/plugins/pattern-translations/includes/parsers/Heading.php +++ b/public_html/wp-content/plugins/pattern-translations/includes/parsers/Heading.php @@ -6,7 +6,7 @@ class Heading implements BlockParser { use GetSetAttribute; - public function to_strings( array $block ) : array { + public function to_strings( array $block ): array { $strings = $this->get_attribute( 'placeholder', $block ); if ( preg_match( '/]*>(.+)<\/h[1-6]>/is', $block['innerHTML'], $matches ) ) { @@ -19,7 +19,7 @@ public function to_strings( array $block ) : array { } // todo: this needs a fix to properly rebuild innerContent - see ParagraphParserTest - public function replace_strings( array $block, array $replacements ) : array { + public function replace_strings( array $block, array $replacements ): array { $this->set_attribute( 'placeholder', $block, $replacements ); $html = $block['innerHTML']; @@ -32,7 +32,7 @@ public function replace_strings( array $block, array $replacements ) : array { } $block['innerHTML'] = $html; - $block['innerContent'] = [ $html ]; + $block['innerContent'] = array( $html ); return $block; } diff --git a/public_html/wp-content/plugins/pattern-translations/includes/parsers/Noop.php b/public_html/wp-content/plugins/pattern-translations/includes/parsers/Noop.php index 752403ca2..73879e736 100644 --- a/public_html/wp-content/plugins/pattern-translations/includes/parsers/Noop.php +++ b/public_html/wp-content/plugins/pattern-translations/includes/parsers/Noop.php @@ -2,11 +2,11 @@ namespace WordPressdotorg\Pattern_Translations\Parsers; class Noop implements BlockParser { - public function to_strings( array $block ) : array { - return []; + public function to_strings( array $block ): array { + return array(); } - public function replace_strings( array $block, array $replacements ) : array { + public function replace_strings( array $block, array $replacements ): array { return $block; } } diff --git a/public_html/wp-content/plugins/pattern-translations/includes/parsers/Paragraph.php b/public_html/wp-content/plugins/pattern-translations/includes/parsers/Paragraph.php index 9d90cf519..f94d8e31c 100644 --- a/public_html/wp-content/plugins/pattern-translations/includes/parsers/Paragraph.php +++ b/public_html/wp-content/plugins/pattern-translations/includes/parsers/Paragraph.php @@ -4,10 +4,10 @@ class Paragraph implements BlockParser { use GetSetAttribute; - public function to_strings( array $block ) : array { + public function to_strings( array $block ): array { $strings = $this->get_attribute( 'placeholder', $block ); - $matches = []; + $matches = array(); if ( preg_match( '/]*>(.+)<\/p>/is', $block['innerHTML'], $matches ) ) { if ( ! empty( $matches[1] ) ) { @@ -19,7 +19,7 @@ public function to_strings( array $block ) : array { } // todo: this needs a fix to properly rebuild innerContent - see ParagraphParserTest - public function replace_strings( array $block, array $replacements ) : array { + public function replace_strings( array $block, array $replacements ): array { $this->set_attribute( 'placeholder', $block, $replacements ); $html = $block['innerHTML']; @@ -32,7 +32,7 @@ public function replace_strings( array $block, array $replacements ) : array { } $block['innerHTML'] = $html; - $block['innerContent'] = [ $html ]; + $block['innerContent'] = array( $html ); return $block; } diff --git a/public_html/wp-content/plugins/pattern-translations/includes/parsers/ShortcodeBlock.php b/public_html/wp-content/plugins/pattern-translations/includes/parsers/ShortcodeBlock.php index 18aaefcb0..6afcd5b50 100644 --- a/public_html/wp-content/plugins/pattern-translations/includes/parsers/ShortcodeBlock.php +++ b/public_html/wp-content/plugins/pattern-translations/includes/parsers/ShortcodeBlock.php @@ -10,14 +10,14 @@ class ShortcodeBlock implements BlockParser { use GetSetAttribute; - public $attribute_names = []; + public $attribute_names = array(); public function __construct( array $attribute_names ) { $this->attribute_names = $attribute_names; } - public function to_strings( array $block ) : array { - $strings = []; + public function to_strings( array $block ): array { + $strings = array(); foreach ( $this->attribute_names as $attribute_name ) { $strings = array_merge( $strings, $this->get_attribute( $attribute_name, $block ) ); } @@ -25,7 +25,7 @@ public function to_strings( array $block ) : array { return $strings; } - public function replace_strings( array $block, array $replacements ) : array { + public function replace_strings( array $block, array $replacements ): array { foreach ( $this->attribute_names as $attribute_name ) { $this->set_attribute( $attribute_name, $block, $replacements ); @@ -35,7 +35,7 @@ public function replace_strings( array $block, array $replacements ) : array { $block['innerContent'][ $i ] = preg_replace_callback( $shortcode_param_regex, - function( $matches ) use ( $replacements ) { + function ( $matches ) use ( $replacements ) { return $this->preg_replace_gutenberg_attributes_handler( $matches, $replacements ); }, $inner_content @@ -47,7 +47,7 @@ function( $matches ) use ( $replacements ) { $regex = '/\b(\w*?)="(.*?)(")/'; $block['innerHTML'] = preg_replace_callback( $regex, - function( $matches ) use ( $replacements ) { + function ( $matches ) use ( $replacements ) { return $this->preg_replace_gutenberg_attributes_handler( $matches, $replacements ); }, $block['innerHTML'] @@ -60,7 +60,7 @@ protected function snake_case( $camelCaseString ) { return ltrim( preg_replace_callback( '/([A-Z]+)/', - function( $matches ) { + function ( $matches ) { return '_' . strtolower( $matches[1] ); }, $camelCaseString ), diff --git a/public_html/wp-content/plugins/pattern-translations/includes/parsers/TextNode.php b/public_html/wp-content/plugins/pattern-translations/includes/parsers/TextNode.php index 1aec70829..f338e80d3 100644 --- a/public_html/wp-content/plugins/pattern-translations/includes/parsers/TextNode.php +++ b/public_html/wp-content/plugins/pattern-translations/includes/parsers/TextNode.php @@ -4,11 +4,11 @@ class TextNode implements BlockParser { use DomUtils; - public function to_strings( array $block ) : array { + public function to_strings( array $block ): array { $dom = $this->get_dom( serialize_block( $block ) ); $xpath = new \DOMXPath( $dom ); - $strings = []; + $strings = array(); foreach ( $xpath->query( '//text()' ) as $text ) { if ( trim( $text->nodeValue ) ) { @@ -19,7 +19,7 @@ public function to_strings( array $block ) : array { return $strings; } - public function replace_strings( array $block, array $replacements ) : array { + public function replace_strings( array $block, array $replacements ): array { $dom = $this->get_dom( serialize_block( $block ) ); $xpath = new \DOMXPath( $dom ); @@ -29,6 +29,6 @@ public function replace_strings( array $block, array $replacements ) : array { } } - return parse_blocks( $this->removeHtml( $dom->saveHTML() ) )[0] ?? []; + return parse_blocks( $this->removeHtml( $dom->saveHTML() ) )[0] ?? array(); } } diff --git a/public_html/wp-content/plugins/pattern-translations/includes/pattern.php b/public_html/wp-content/plugins/pattern-translations/includes/pattern.php index 148fce12f..58891d13f 100644 --- a/public_html/wp-content/plugins/pattern-translations/includes/pattern.php +++ b/public_html/wp-content/plugins/pattern-translations/includes/pattern.php @@ -1,7 +1,8 @@ to_strings() as $string ) { $translations[ $string ] = apply_filters( 'gettext', GlotPress_Translate_Bridge::translate( $string, GLOTPRESS_PROJECT ), 'wporg-pattern' ); @@ -68,17 +69,17 @@ public function to_locale( string $locale ) /* PHP8 : Pattern|bool */ { $translated->ID = 0; // Find the actual post ID of the translated pattern - $children = get_posts( [ + $children = get_posts( array( 'post_parent' => $parent->ID, 'post_type' => POST_TYPE, 'post_status' => 'any', - 'meta_query' => [ - [ + 'meta_query' => array( + array( 'key' => 'wpop_locale', 'value' => $locale, - ], - ], - ] ); + ), + ), + ) ); if ( $children ) { $post = array_shift( $children ); $translated->ID = $post->ID; @@ -94,7 +95,7 @@ public function to_locale( string $locale ) /* PHP8 : Pattern|bool */ { * @param \WP_Post $post The post object. * @return Pattern The Pattern object. */ - public static function from_post( \WP_Post $post ) : Pattern { + public static function from_post( \WP_Post $post ): Pattern { $pattern = new Pattern(); $pattern->ID = $post->ID; $pattern->title = $post->post_title; @@ -114,24 +115,24 @@ public static function from_post( \WP_Post $post ) : Pattern { * @param array $args The WP_Query args. * @return array An array of Pattern objects. */ - public static function get_patterns( array $args = [] ) : array { - $defaults = [ + public static function get_patterns( array $args = array() ): array { + $defaults = array( 'post_type' => POST_TYPE, // Note: This must be set for cli context, in isolated test context this is defaulted to 'publish' // Prevents unexpected patterns in translations 'post_status' => 'publish', 'posts_per_page' => -1, - 'orderby' => [ + 'orderby' => array( 'post_date' => 'DESC', - ], + ), // Only select en_US patterns. - 'meta_query' => [ - [ + 'meta_query' => array( + array( 'key' => 'wpop_locale', 'value' => 'en_US', - ], - ], - ]; + ), + ), + ); $options = wp_parse_args( $args, $defaults ); @@ -141,7 +142,7 @@ public static function get_patterns( array $args = [] ) : array { wp_reset_postdata(); if ( 'ids' !== $query->get( 'fields' ) ) { - $patterns = array_map( [ self::class, 'from_post' ], $patterns ); + $patterns = array_map( array( self::class, 'from_post' ), $patterns ); } return $patterns; diff --git a/public_html/wp-content/plugins/pattern-translations/pattern-translations.php b/public_html/wp-content/plugins/pattern-translations/pattern-translations.php index d01b1be88..28439fc32 100644 --- a/public_html/wp-content/plugins/pattern-translations/pattern-translations.php +++ b/public_html/wp-content/plugins/pattern-translations/pattern-translations.php @@ -11,11 +11,11 @@ const GLOTPRESS_PROJECT = 'patterns/core'; -const TRANSLATED_TAXONOMIES = [ +const TRANSLATED_TAXONOMIES = array( // Taxonomy => Translation Context, see pattern-directory/bin/i18n.php 'wporg-pattern-category' => 'Categories term name', 'wporg-pattern-flag-reason' => 'Flag Reasons term name', -]; +); require __DIR__ . '/includes/pattern.php'; require __DIR__ . '/includes/parser.php'; @@ -36,7 +36,7 @@ function create_or_update_translated_pattern( Pattern $pattern ) { $parent = get_post( $pattern->parent->ID ); } - $args = [ + $args = array( 'ID' => $pattern->ID, 'post_type' => POST_TYPE, 'post_title' => $pattern->title, @@ -46,7 +46,7 @@ function create_or_update_translated_pattern( Pattern $pattern ) { 'post_parent' => $pattern->parent->ID ?? 0, 'post_author' => $parent->post_author ?? 0, 'post_status' => $parent->post_status ?? 'pending', - 'meta_input' => [ + 'meta_input' => array( 'wpop_description' => $pattern->description, 'wpop_locale' => $pattern->locale, 'wpop_keywords' => $pattern->keywords, @@ -55,8 +55,8 @@ function create_or_update_translated_pattern( Pattern $pattern ) { 'wpop_contains_block_types' => $parent->wpop_contains_block_types, 'wpop_wp_version' => $parent->wpop_wp_version, 'wpop_is_translation' => true, - ], - ]; + ), + ); if ( ! $args['ID'] ) { unset( $args['ID'] ); @@ -66,8 +66,8 @@ function create_or_update_translated_pattern( Pattern $pattern ) { // Copy the terms from the parent if required. if ( $post_id && ! is_wp_error( $post_id ) && $pattern->parent ) { - foreach ( [ 'wporg-pattern-category', 'wporg-pattern-keyword' ] as $taxonomy ) { - $term_ids = wp_get_object_terms( $pattern->parent->ID, $taxonomy, [ 'fields' => 'ids' ] ); + foreach ( array( 'wporg-pattern-category', 'wporg-pattern-keyword' ) as $taxonomy ) { + $term_ids = wp_get_object_terms( $pattern->parent->ID, $taxonomy, array( 'fields' => 'ids' ) ); wp_set_object_terms( $post_id, $term_ids, $taxonomy ); } } diff --git a/public_html/wp-content/themes/wporg-pattern-directory-2024/functions.php b/public_html/wp-content/themes/wporg-pattern-directory-2024/functions.php index 3e1d2197f..a9d4f79cd 100644 --- a/public_html/wp-content/themes/wporg-pattern-directory-2024/functions.php +++ b/public_html/wp-content/themes/wporg-pattern-directory-2024/functions.php @@ -3,22 +3,22 @@ namespace WordPressdotorg\Theme\Pattern_Directory_2024; use function WordPressdotorg\Pattern_Directory\Favorite\{get_favorites, get_favorite_count}; +use function WordPressdotorg\Theme\Pattern_Directory_2024\Block_Config\get_applied_filter_list; use const WordPressdotorg\Pattern_Directory\Pattern_Post_Type\POST_TYPE; use const WordPressdotorg\Pattern_Directory\Pattern_Flag_Post_Type\POST_TYPE as FLAG_POST_TYPE; use const WordPressdotorg\Pattern_Directory\Pattern_Flag_Post_Type\PENDING_STATUS; -use function WordPressdotorg\Theme\Pattern_Directory_2024\Block_Config\get_applied_filter_list; // Block files -require_once( __DIR__ . '/src/blocks/copy-button/index.php' ); -require_once( __DIR__ . '/src/blocks/delete-button/index.php' ); -require_once( __DIR__ . '/src/blocks/pattern-preview/index.php' ); -require_once( __DIR__ . '/src/blocks/pattern-thumbnail/index.php' ); -require_once( __DIR__ . '/src/blocks/post-status/index.php' ); -require_once( __DIR__ . '/src/blocks/report-pattern/index.php' ); -require_once( __DIR__ . '/src/blocks/status-notice/index.php' ); +require_once __DIR__ . '/src/blocks/copy-button/index.php'; +require_once __DIR__ . '/src/blocks/delete-button/index.php'; +require_once __DIR__ . '/src/blocks/pattern-preview/index.php'; +require_once __DIR__ . '/src/blocks/pattern-thumbnail/index.php'; +require_once __DIR__ . '/src/blocks/post-status/index.php'; +require_once __DIR__ . '/src/blocks/report-pattern/index.php'; +require_once __DIR__ . '/src/blocks/status-notice/index.php'; -require_once( __DIR__ . '/inc/block-config.php' ); -require_once( __DIR__ . '/inc/shortcodes.php' ); +require_once __DIR__ . '/inc/block-config.php'; +require_once __DIR__ . '/inc/shortcodes.php'; /** * Actions and filters. @@ -37,7 +37,7 @@ add_action( 'init', - function() { + function () { // Don't swap author link with w.org profile link. remove_all_filters( 'author_link' ); @@ -175,13 +175,13 @@ function modify_patterns_query( $query ) { } if ( $curation ) { - $tax_query = isset( $query->tax_query->queries ) ? $query->tax_query->queries : []; + $tax_query = isset( $query->tax_query->queries ) ? $query->tax_query->queries : array(); if ( 'core' === $curation ) { // Patterns with the core keyword. $tax_query['core_keyword'] = array( 'taxonomy' => 'wporg-pattern-keyword', 'field' => 'slug', - 'terms' => [ 'core' ], + 'terms' => array( 'core' ), 'operator' => 'IN', ); } else if ( 'community' === $curation ) { @@ -189,7 +189,7 @@ function modify_patterns_query( $query ) { $tax_query['core_keyword'] = array( 'taxonomy' => 'wporg-pattern-keyword', 'field' => 'slug', - 'terms' => [ 'core' ], + 'terms' => array( 'core' ), 'operator' => 'NOT IN', ); } @@ -265,7 +265,7 @@ function modify_query_loop_block_query_vars( $query, $block, $page ) { $query['tax_query']['core_keyword'] = array( 'taxonomy' => 'wporg-pattern-keyword', 'field' => 'slug', - 'terms' => [ 'core' ], + 'terms' => array( 'core' ), 'operator' => 'NOT IN', ); } @@ -277,7 +277,7 @@ function modify_query_loop_block_query_vars( $query, $block, $page ) { } // Query Loops on My Patterns & Favorites pages - if ( is_page( [ 'my-patterns', 'favorites' ] ) ) { + if ( is_page( array( 'my-patterns', 'favorites' ) ) ) { // Get these values from the global wp_query, they're passed via the URL. if ( isset( $wp_query->query['pattern-categories'] ) ) { if ( ! isset( $query['tax_query'] ) || ! is_array( $query['tax_query'] ) ) { @@ -310,7 +310,7 @@ function modify_query_loop_block_query_vars( $query, $block, $page ) { $query['post_status'] = 'any'; $query['author'] = get_current_user_id(); } else { - $query['post__in'] = [ -1 ]; + $query['post__in'] = array( -1 ); } if ( isset( $wp_query->query['status'] ) ) { @@ -323,7 +323,7 @@ function modify_query_loop_block_query_vars( $query, $block, $page ) { if ( ! empty( $favorites ) ) { $query['post__in'] = get_favorites(); } else { - $query['post__in'] = [ -1 ]; + $query['post__in'] = array( -1 ); } } } @@ -360,7 +360,7 @@ function custom_query_loop_by_id( $query, $block ) { $current_post = get_post(); if ( 'more-by-author' === $block->context['query']['_id'] && $current_post && $current_post->post_author ) { $query['author'] = $current_post->post_author; - $query['post__not_in'] = [ $current_post->ID ]; + $query['post__not_in'] = array( $current_post->ID ); $query['post_type'] = 'wporg-pattern'; } @@ -456,7 +456,7 @@ function redirect_term_archives() { if ( count( $terms ) === 1 && ! $is_term_archive ) { $url = get_term_link( $terms[0] ); // Pass through search query, curation, sorting values. - $query_vars = [ 's', 'curation', 'order', 'orderby' ]; + $query_vars = array( 's', 'curation', 'order', 'orderby' ); foreach ( $query_vars as $query_var ) { if ( isset( $wp_query->query[ $query_var ] ) ) { $url = add_query_arg( $query_var, $wp_query->query[ $query_var ], $url ); @@ -471,37 +471,37 @@ function redirect_term_archives() { * Add meta tags for richer social media integrations. */ function add_social_meta_tags() { - $og_fields = []; + $og_fields = array(); $default_image = 'https://s.w.org/patterns/files/2024/04/patterns-ogimage.png'; $site_title = function_exists( '\WordPressdotorg\site_brand' ) ? \WordPressdotorg\site_brand() : 'WordPress.org'; if ( is_front_page() || is_home() ) { - $og_fields = [ + $og_fields = array( 'og:title' => __( 'Block Pattern Directory', 'wporg-patterns' ), 'og:description' => __( 'Add a beautifully designed, ready to go layout to any WordPress site with a simple copy/paste.', 'wporg-patterns' ), 'og:site_name' => $site_title, 'og:type' => 'website', 'og:url' => home_url(), 'og:image' => esc_url( $default_image ), - ]; + ); } else if ( is_tax() && get_queried_object() ) { - $og_fields = [ + $og_fields = array( 'og:title' => sprintf( __( 'Block Patterns: %s', 'wporg-patterns' ), esc_attr( single_term_title( '', false ) ) ), 'og:description' => __( 'Add a beautifully designed, ready to go layout to any WordPress site with a simple copy/paste.', 'wporg-patterns' ), 'og:site_name' => $site_title, 'og:type' => 'website', 'og:url' => esc_url( get_term_link( get_queried_object_id() ) ), 'og:image' => esc_url( $default_image ), - ]; + ); } else if ( is_singular( POST_TYPE ) ) { - $og_fields = [ + $og_fields = array( 'og:title' => the_title_attribute( array( 'echo' => false ) ), 'og:description' => strip_tags( get_post_meta( get_the_ID(), 'wpop_description', true ) ), 'og:site_name' => $site_title, 'og:type' => 'website', 'og:url' => esc_url( get_permalink() ), 'og:image' => esc_url( $default_image ), - ]; + ); printf( '' . "\n" ); printf( '' . "\n" ); printf( '' . "\n", esc_url( $default_image ) ); diff --git a/public_html/wp-content/themes/wporg-pattern-directory-2024/inc/block-config.php b/public_html/wp-content/themes/wporg-pattern-directory-2024/inc/block-config.php index 207a184e2..1f0419e00 100644 --- a/public_html/wp-content/themes/wporg-pattern-directory-2024/inc/block-config.php +++ b/public_html/wp-content/themes/wporg-pattern-directory-2024/inc/block-config.php @@ -35,8 +35,8 @@ function register_block_bindings() { 'wporg-pattern/edit-label', array( 'label' => __( 'Edit label', 'wporg-patterns' ), - 'uses_context' => [ 'postId' ], - 'get_value_callback' => function( $args, $block ) { + 'uses_context' => array( 'postId' ), + 'get_value_callback' => function ( $args, $block ) { $post_id = $block->context['postId']; /* translators: %s: Post title. Only visible to screen readers. */ return sprintf( @@ -51,8 +51,8 @@ function register_block_bindings() { 'wporg-pattern/edit-url', array( 'label' => __( 'Edit link', 'wporg-patterns' ), - 'uses_context' => [ 'postId' ], - 'get_value_callback' => function( $args, $block ) { + 'uses_context' => array( 'postId' ), + 'get_value_callback' => function ( $args, $block ) { $post_id = $block->context['postId']; return site_url( "pattern/$post_id/edit/" ); }, @@ -70,10 +70,10 @@ function register_block_bindings() { */ function get_applied_filter_list( $include_extras = true ) { global $wp_query; - $terms = []; - $taxes = [ + $terms = array(); + $taxes = array( 'pattern-categories' => 'wporg-pattern-category', - ]; + ); foreach ( $taxes as $query_var => $taxonomy ) { if ( ! isset( $wp_query->query[ $query_var ] ) ) { continue; @@ -178,7 +178,7 @@ function get_curation_options( $options ) { 'community' => _x( 'Community', 'filter option label', 'wporg-patterns' ), 'core' => _x( 'Curated', 'filter option label', 'wporg-patterns' ), ), - 'selected' => [ $current ], + 'selected' => array( $current ), ); } @@ -218,7 +218,7 @@ function get_sort_options( $options ) { ); // These pages don't support sorting by favorite count. - if ( ! is_page( [ 'my-patterns', 'favorites' ] ) ) { + if ( ! is_page( array( 'my-patterns', 'favorites' ) ) ) { $options = array_merge( array( 'favorite_count_desc' => __( 'Popular', 'wporg-patterns' ), @@ -233,7 +233,7 @@ function get_sort_options( $options ) { 'key' => 'orderby', 'action' => get_filter_action_url(), 'options' => $options, - 'selected' => [ $sort ], + 'selected' => array( $sort ), ); } @@ -250,7 +250,7 @@ function inject_other_filters( $key ) { global $wp_query; // Single-select query parameters. - $query_vars = [ 'pattern-categories', 'order', 'orderby', 'curation' ]; + $query_vars = array( 'pattern-categories', 'order', 'orderby', 'curation' ); foreach ( $query_vars as $query_var ) { if ( ! isset( $wp_query->query[ $query_var ] ) ) { continue; @@ -286,7 +286,7 @@ function get_favorite_settings( $settings, $post_id ) { return array( 'count' => get_favorite_count( $post_id ), 'is_favorite' => is_favorite( $post_id ), - 'add_callback' => function( $_post_id ) { + 'add_callback' => function ( $_post_id ) { $success = add_favorite( $_post_id ); if ( $success ) { return get_favorite_count( $_post_id ); @@ -298,7 +298,7 @@ function get_favorite_settings( $settings, $post_id ) { array( 'status' => 500 ) ); }, - 'delete_callback' => function( $_post_id ) { + 'delete_callback' => function ( $_post_id ) { $success = remove_favorite( $_post_id ); if ( $success ) { return get_favorite_count( $_post_id ); diff --git a/public_html/wp-content/themes/wporg-pattern-directory-2024/inc/shortcodes.php b/public_html/wp-content/themes/wporg-pattern-directory-2024/inc/shortcodes.php index a71c53cae..b9a430548 100644 --- a/public_html/wp-content/themes/wporg-pattern-directory-2024/inc/shortcodes.php +++ b/public_html/wp-content/themes/wporg-pattern-directory-2024/inc/shortcodes.php @@ -1,4 +1,8 @@ $current_post_id, 'message' => __( 'Are you sure you want to delete this pattern?', 'wporg-patterns' ), 'redirectUrl' => home_url( '/my-patterns/' ), -]; +); $encoded_state = wp_json_encode( $init_state ); ?> diff --git a/public_html/wp-content/themes/wporg-pattern-directory-2024/src/blocks/pattern-preview/controls/render.php b/public_html/wp-content/themes/wporg-pattern-directory-2024/src/blocks/pattern-preview/controls/render.php index 7b8f86b14..5a8b89d02 100644 --- a/public_html/wp-content/themes/wporg-pattern-directory-2024/src/blocks/pattern-preview/controls/render.php +++ b/public_html/wp-content/themes/wporg-pattern-directory-2024/src/blocks/pattern-preview/controls/render.php @@ -9,12 +9,12 @@ $view_url = get_pattern_preview_url( $block->context['postId'] ); // Initial state to pass to Interactivity API. -$init_state = [ +$init_state = array( 'url' => $view_url, 'previewWidth' => 1200, 'previewHeight' => 200, 'isControlled' => true, -]; +); $encoded_state = wp_json_encode( $init_state ); // Remove the nested context for child blocks, so that it uses this context. diff --git a/public_html/wp-content/themes/wporg-pattern-directory-2024/src/blocks/pattern-preview/frame/render.php b/public_html/wp-content/themes/wporg-pattern-directory-2024/src/blocks/pattern-preview/frame/render.php index b15cfed91..358c57112 100644 --- a/public_html/wp-content/themes/wporg-pattern-directory-2024/src/blocks/pattern-preview/frame/render.php +++ b/public_html/wp-content/themes/wporg-pattern-directory-2024/src/blocks/pattern-preview/frame/render.php @@ -14,12 +14,12 @@ } // Initial state to pass to Interactivity API. -$init_state = [ +$init_state = array( 'url' => $view_url, 'previewWidth' => $viewport_width, 'previewHeight' => 200, 'isControlled' => false, -]; +); $encoded_state = wp_json_encode( $init_state ); ?> diff --git a/public_html/wp-content/themes/wporg-pattern-directory-2024/src/blocks/pattern-thumbnail/render.php b/public_html/wp-content/themes/wporg-pattern-directory-2024/src/blocks/pattern-thumbnail/render.php index dd53fc7ba..414560702 100644 --- a/public_html/wp-content/themes/wporg-pattern-directory-2024/src/blocks/pattern-thumbnail/render.php +++ b/public_html/wp-content/themes/wporg-pattern-directory-2024/src/blocks/pattern-thumbnail/render.php @@ -32,14 +32,14 @@ ); // Initial state to pass to Interactivity API. -$init_state = [ +$init_state = array( 'base64Image' => '', 'src' => esc_url( $url ), 'alt' => the_title_attribute( array( 'echo' => false ) ), 'attempts' => 0, 'shouldRetry' => true, 'hasError' => false, -]; +); $encoded_state = wp_json_encode( $init_state ); $classname = ''; diff --git a/public_html/wp-content/themes/wporg-pattern-directory-2024/src/blocks/post-status/index.php b/public_html/wp-content/themes/wporg-pattern-directory-2024/src/blocks/post-status/index.php index f74af5f07..cf5ed8963 100644 --- a/public_html/wp-content/themes/wporg-pattern-directory-2024/src/blocks/post-status/index.php +++ b/public_html/wp-content/themes/wporg-pattern-directory-2024/src/blocks/post-status/index.php @@ -64,6 +64,6 @@ function render( $attributes, $content, $block ) { return ''; } - $wrapper_attributes = get_block_wrapper_attributes( [ 'class' => 'is-' . $type ] ); + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => 'is-' . $type ) ); return sprintf( '
    %2s
    ', $wrapper_attributes, $label ); } diff --git a/public_html/wp-content/themes/wporg-pattern-directory-2024/src/blocks/report-pattern/render.php b/public_html/wp-content/themes/wporg-pattern-directory-2024/src/blocks/report-pattern/render.php index 6d42d6343..ad77db827 100644 --- a/public_html/wp-content/themes/wporg-pattern-directory-2024/src/blocks/report-pattern/render.php +++ b/public_html/wp-content/themes/wporg-pattern-directory-2024/src/blocks/report-pattern/render.php @@ -29,11 +29,11 @@ return; } -$reasons = get_terms( [ +$reasons = get_terms( array( 'taxonomy' => FLAG_REASON, 'hide_empty' => false, 'orderby' => 'slug', -] ); +) ); ?>
    >