Skip to content

Commit

Permalink
Merge branch 'develop' into fix/missing_wp_user_type
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiesshop committed Jul 2, 2024
2 parents 3c27322 + 1c29766 commit 175d8fe
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/integrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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+

Expand Down
30 changes: 20 additions & 10 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@
<ruleset name="WordPress Coding Standards for Plugins">
<description>Generally-applicable sniffs for WordPress plugins</description>

<rule ref="WordPress-Extra" />
<rule ref="WordPress-Docs" />
<rule ref="WordPress-VIP-Go" />
<rule ref="WordPress">
<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found" />
</rule>

<!-- Rules: WordPress Coding Standards - see
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
<!-- <rule ref="WordPress-Extra">--> <!-- Includes WordPress-Core -->
<!-- <exclude name="Universal.Arrays.DisallowShortArraySyntax.Found" />-->
<!-- </rule>-->
<!--<rule ref="WordPress-Docs"/>-->
<!-- For help in understanding this minimum_supported_wp_version:
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#setting-minimum-supported-wp-version-for-all-sniffs-in-one-go-wpcs-0140 -->
<config name="minimum_supported_wp_version" value="5.9"/>

<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
Expand All @@ -17,18 +23,22 @@
</rule>

<rule ref="PHPCompatibilityWP"/>
<config name="testVersion" value="7.2-"/>

<arg name="extensions" value="php"/>
<config name="testVersion" value="7.4-"/>

<!-- Show sniff codes in all reports -->
<arg value="s"/>
<!-- How to scan -->
<arg value="sp"/> <!-- Show sniff and progress -->
<arg value="n"/> <!-- No warnings -->
<arg name="colors"/> <!-- Show results with colors. Disable if working on Windows -->
<arg name="basepath" value="."/> <!-- Strip the file paths down to the relevant bit -->
<arg name="parallel" value="8"/> <!-- Enables parallel processing when available for faster results -->
<arg name="extensions" value="php"/> <!-- Limit to PHP files -->

<!-- Allow invoking just `phpcs` on command line without assuming STDIN for file input. -->
<file>.</file>

<exclude-pattern>*/dev-lib/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/dist/*</exclude-pattern>
</ruleset>
12 changes: 5 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -58,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"
Expand Down
25 changes: 25 additions & 0 deletions php/integrations/yoast.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

/**
Expand Down Expand Up @@ -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();

0 comments on commit 175d8fe

Please sign in to comment.