From 9ae8c78c5edada63aa404593ef911c70399cd9b2 Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Mon, 29 Apr 2024 12:33:53 +0100 Subject: [PATCH 1/5] Composer: Update dev-dependencies --- composer.json | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index db73a114..57a05b22 100644 --- a/composer.json +++ b/composer.json @@ -26,16 +26,14 @@ "php": ">=7.4" }, "require-dev": { - "automattic/vipwpcs": "^2.2", - "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7", + "automattic/vipwpcs": "^3", "dms/phpunit-arraysubset-asserts": "^0.5.0", "php-parallel-lint/php-parallel-lint": "^1.0", "phpcompatibility/phpcompatibility-wp": "^2.1", "phpunit/phpunit": "^9", - "squizlabs/php_codesniffer": "^3.5", "wp-cli/extension-command": "^2.0", - "wp-cli/wp-cli-tests": "^3", - "wp-coding-standards/wpcs": "^2.3.0", + "wp-cli/wp-cli-tests": "^v4", + "wp-coding-standards/wpcs": "^3.1", "yoast/wp-test-utils": "^1.2" }, "autoload": { From 23a10e36b76fbb2097dcd100befbf922e3d2049e Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Mon, 29 Apr 2024 12:45:29 +0100 Subject: [PATCH 2/5] PHPCS: Consolidate config into config file The PHPCS in the composer.json was duplicating but obscuring some aspects of what was in the `phpcs.xml.dist` file. This change consolidates the Composer commands and the config file. --- .phpcs.xml.dist | 30 ++++++++++++++++++++---------- composer.json | 4 ++-- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist index af71a3db..4759537c 100644 --- a/.phpcs.xml.dist +++ b/.phpcs.xml.dist @@ -2,12 +2,18 @@ Generally-applicable sniffs for WordPress plugins - - - - - + + + + + + + + + @@ -17,12 +23,15 @@ - - - + - - + + + + + + + . @@ -30,5 +39,6 @@ */dev-lib/* */node_modules/* */vendor/* + */tests/* */dist/* diff --git a/composer.json b/composer.json index 57a05b22..b1ad7c22 100644 --- a/composer.json +++ b/composer.json @@ -56,10 +56,10 @@ "@php ./vendor/bin/phpunit --exclude=ms-excluded" ], "cs": [ - "@php ./vendor/bin/phpcs -p -s -v -n . --standard=\"WordPress-VIP-Go\" --extensions=php --ignore=\"/vendor/*,/node_modules/*,/tests/*\"" + "@php ./vendor/bin/phpcs" ], "cbf": [ - "@php ./vendor/bin/phpcbf -p -s -v -n . --standard=\"WordPress-VIP-Go\" --extensions=php --ignore=\"/vendor/*,/node_modules/*,/tests/*\"" + "@php ./vendor/bin/phpcbf" ], "lint": [ "@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git" From 662dab620675edda7628db17a24d57ad238f269d Mon Sep 17 00:00:00 2001 From: claudiulodro Date: Tue, 14 May 2024 10:14:45 -0700 Subject: [PATCH 3/5] Support for Yoast %%name%% variable --- php/integrations/yoast.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/php/integrations/yoast.php b/php/integrations/yoast.php index a580823a..938a9277 100644 --- a/php/integrations/yoast.php +++ b/php/integrations/yoast.php @@ -87,6 +87,7 @@ public static function register_hooks(): void { add_filter( 'wpseo_enhanced_slack_data', [__CLASS__, 'filter_slack_data'], 10, 2 ); add_filter( 'wpseo_robots_array', [ __CLASS__, 'allow_indexing_guest_author_archive' ], 10, 2 ); add_filter( 'wpseo_opengraph_url', [ __CLASS__, 'fix_guest_author_archive_url_presenter' ], 10, 2 ); + add_filter( 'wpseo_replacements', [ __CLASS__, 'filter_author_name_variable' ], 10, 2 ); } /** @@ -327,6 +328,30 @@ public static function fix_guest_author_archive_url_presenter( $url, $presenter return get_author_posts_url( $user->ID, $user->user_nicename ); } + + /** + * Uses guest authors in the '%%name%%' Yoast variable when needed. + * + * See https://yoast.com/features/meta-tag-variables/. + * + * @param array $replacements Key/val pair of variables and their transformed value. + * @param stdClass $args Info about current queried object. + * @return array Modified $replacements. + */ + public static function filter_author_name_variable( $replacements, $args ): array { + if ( isset( $replacements['%%name%%'], $args->ID ) ) { + $author_objects = get_coauthors( $args->ID ); + + // Fallback in case of error. + if ( empty( $author_objects ) ) { + return $replacements; + } + + $replacements['%%name%%'] = self::get_authors_display_names_output( $author_objects ); + } + + return $replacements; + } } Yoast::init(); From 03800e26b78045b9445f3ab072b38228b09cedec Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Tue, 21 May 2024 10:48:45 +0100 Subject: [PATCH 4/5] CI: Update deploy.yml Increase actions/checkout dependency version. --- .github/workflows/deploy.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b33bccb8..7cb7e7de 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,15 +2,15 @@ name: Deploy to WordPress.org on: release: types: [released] - # Allow manually triggering the workflow. + # Allow manual triggering of the workflow. workflow_dispatch: jobs: release: name: New release to WordPress.org - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Push to WordPress.org uses: 10up/action-wordpress-plugin-deploy@stable env: From 217267af5bf64b2638cb2c1b1fef8551ab78f364 Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Tue, 21 May 2024 17:43:52 +0100 Subject: [PATCH 5/5] CI: Update integrate.yml action versios --- .github/workflows/integrate.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integrate.yml b/.github/workflows/integrate.yml index e9d7c863..6a70dccd 100644 --- a/.github/workflows/integrate.yml +++ b/.github/workflows/integrate.yml @@ -34,7 +34,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up PHP ${{ matrix.php }} uses: shivammathur/setup-php@v2 @@ -45,7 +45,7 @@ jobs: coverage: ${{ matrix.coverage }} - name: Install Composer dependencies - uses: ramsey/composer-install@v2 + uses: ramsey/composer-install@v3 with: composer-options: --ignore-platform-req=php+