From df534bf3c575558ab3792d25a0e0a8311a2eee52 Mon Sep 17 00:00:00 2001 From: Ashley Hitchcock Date: Wed, 23 Nov 2022 19:52:37 +0000 Subject: [PATCH] Add Global Meta fields (#143) * Feat: add missing global meta data * chore: changelog and version number * update readme --- CHANGELOG.md | 12 ++++- README.md | 17 ++++++++ composer.lock | 94 ++++++++++++++++++++++------------------ readme.txt | 2 +- wp-graphql-yoast-seo.php | 63 ++++++++++++++++++++++++++- 5 files changed, 143 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24185ee..3c41137 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,21 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [4.20.0] - 2022-11-16 + +### Added + +- Added missing base meta fields: + - Homepage + - Author + - Separator + - 404 + ## [4.19.0] - 2022-10-21 ### Added -- Added "Other" Soical Profiles after Yoast change +- Added "Other" Social Profiles after Yoast change ## [4.18.0] - 2022-06-10 diff --git a/README.md b/README.md index dccfe6d..ea46166 100644 --- a/README.md +++ b/README.md @@ -253,6 +253,23 @@ query GetPostsWithIsPrimary { ```graphql query GetSeoConfig { seo { + meta { + author { + description + title + } + config { + separator + } + homepage { + description + title + } + notFound { + breadcrumb + title + } + } webmaster { googleVerify yandexVerify diff --git a/composer.lock b/composer.lock index df1e81e..73e9945 100644 --- a/composer.lock +++ b/composer.lock @@ -70,16 +70,16 @@ }, { "name": "phpcompatibility/phpcompatibility-paragonie", - "version": "1.3.1", + "version": "1.3.2", "source": { "type": "git", "url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git", - "reference": "ddabec839cc003651f2ce695c938686d1086cf43" + "reference": "bba5a9dfec7fcfbd679cfaf611d86b4d3759da26" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/ddabec839cc003651f2ce695c938686d1086cf43", - "reference": "ddabec839cc003651f2ce695c938686d1086cf43", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/bba5a9dfec7fcfbd679cfaf611d86b4d3759da26", + "reference": "bba5a9dfec7fcfbd679cfaf611d86b4d3759da26", "shasum": "" }, "require": { @@ -116,26 +116,27 @@ "paragonie", "phpcs", "polyfill", - "standards" + "standards", + "static analysis" ], "support": { "issues": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/issues", "source": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie" }, - "time": "2021-02-15T10:24:51+00:00" + "time": "2022-10-25T01:46:02+00:00" }, { "name": "phpcompatibility/phpcompatibility-wp", - "version": "2.1.1", + "version": "2.1.4", "source": { "type": "git", "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git", - "reference": "b7dc0cd7a8f767ccac5e7637550ea1c50a67b09e" + "reference": "b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/b7dc0cd7a8f767ccac5e7637550ea1c50a67b09e", - "reference": "b7dc0cd7a8f767ccac5e7637550ea1c50a67b09e", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5", + "reference": "b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5", "shasum": "" }, "require": { @@ -170,26 +171,27 @@ "compatibility", "phpcs", "standards", + "static analysis", "wordpress" ], "support": { "issues": "https://github.com/PHPCompatibility/PHPCompatibilityWP/issues", "source": "https://github.com/PHPCompatibility/PHPCompatibilityWP" }, - "time": "2021-02-15T12:58:46+00:00" + "time": "2022-10-24T09:00:36+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.6.0", + "version": "3.7.1", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625" + "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ffced0d2c8fa8e6cdc4d695a743271fab6c38625", - "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619", + "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619", "shasum": "" }, "require": { @@ -232,28 +234,28 @@ "source": "https://github.com/squizlabs/PHP_CodeSniffer", "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" }, - "time": "2021-04-09T00:54:41+00:00" + "time": "2022-06-18T07:21:10+00:00" } ], "packages-dev": [ { "name": "automattic/vipwpcs", - "version": "2.3.2", + "version": "2.3.3", "source": { "type": "git", "url": "https://github.com/Automattic/VIP-Coding-Standards.git", - "reference": "efacebef421334d54b99afa92fb8fa645336a8a7" + "reference": "6cd0a6a82bc0ac988dbf9d6a7c2e293dc8ac640b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Automattic/VIP-Coding-Standards/zipball/efacebef421334d54b99afa92fb8fa645336a8a7", - "reference": "efacebef421334d54b99afa92fb8fa645336a8a7", + "url": "https://api.github.com/repos/Automattic/VIP-Coding-Standards/zipball/6cd0a6a82bc0ac988dbf9d6a7c2e293dc8ac640b", + "reference": "6cd0a6a82bc0ac988dbf9d6a7c2e293dc8ac640b", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7", "php": ">=5.4", - "sirbrillig/phpcs-variable-analysis": "^2.8.3", + "sirbrillig/phpcs-variable-analysis": "^2.11.1", "squizlabs/php_codesniffer": "^3.5.5", "wp-coding-standards/wpcs": "^2.3" }, @@ -286,31 +288,31 @@ "source": "https://github.com/Automattic/VIP-Coding-Standards", "wiki": "https://github.com/Automattic/VIP-Coding-Standards/wiki" }, - "time": "2021-04-28T16:41:50+00:00" + "time": "2021-09-29T16:20:23+00:00" }, { "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v0.7.1", + "version": "v0.7.2", "source": { "type": "git", "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", - "reference": "fe390591e0241955f22eb9ba327d137e501c771c" + "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/fe390591e0241955f22eb9ba327d137e501c771c", - "reference": "fe390591e0241955f22eb9ba327d137e501c771c", + "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", + "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", "shasum": "" }, "require": { "composer-plugin-api": "^1.0 || ^2.0", "php": ">=5.3", - "squizlabs/php_codesniffer": "^2.0 || ^3.0 || ^4.0" + "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" }, "require-dev": { "composer/composer": "*", - "phpcompatibility/php-compatibility": "^9.0", - "sensiolabs/security-checker": "^4.1.0" + "php-parallel-lint/php-parallel-lint": "^1.3.1", + "phpcompatibility/php-compatibility": "^9.0" }, "type": "composer-plugin", "extra": { @@ -331,6 +333,10 @@ "email": "franck.nijhof@dealerdirect.com", "homepage": "http://www.frenck.nl", "role": "Developer / IT Manager" + }, + { + "name": "Contributors", + "homepage": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer/graphs/contributors" } ], "description": "PHP_CodeSniffer Standards Composer Installer Plugin", @@ -342,6 +348,7 @@ "codesniffer", "composer", "installer", + "phpcbf", "phpcs", "plugin", "qa", @@ -356,32 +363,33 @@ "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" }, - "time": "2020-12-07T18:04:37+00:00" + "time": "2022-02-04T12:51:07+00:00" }, { "name": "sirbrillig/phpcs-variable-analysis", - "version": "v2.11.2", + "version": "v2.11.9", "source": { "type": "git", "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git", - "reference": "3fad28475bfbdbf8aa5c440f8a8f89824983d85e" + "reference": "62730888d225d55a613854b6a76fb1f9f57d1618" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/3fad28475bfbdbf8aa5c440f8a8f89824983d85e", - "reference": "3fad28475bfbdbf8aa5c440f8a8f89824983d85e", + "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/62730888d225d55a613854b6a76fb1f9f57d1618", + "reference": "62730888d225d55a613854b6a76fb1f9f57d1618", "shasum": "" }, "require": { "php": ">=5.4.0", - "squizlabs/php_codesniffer": "^3.5" + "squizlabs/php_codesniffer": "^3.5.6" }, "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", - "limedeck/phpunit-detailed-printer": "^3.1 || ^4.0 || ^5.0", - "phpstan/phpstan": "^0.11.8", - "phpunit/phpunit": "^5.0 || ^6.5 || ^7.0 || ^8.0", - "sirbrillig/phpcs-import-detection": "^1.1" + "phpcsstandards/phpcsdevcs": "^1.1", + "phpstan/phpstan": "^1.7", + "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.5 || ^7.0 || ^8.0 || ^9.0", + "sirbrillig/phpcs-import-detection": "^1.1", + "vimeo/psalm": "^0.2 || ^0.3 || ^1.1 || ^4.24 || ^5.0@beta" }, "type": "phpcodesniffer-standard", "autoload": { @@ -404,12 +412,16 @@ } ], "description": "A PHPCS sniff to detect problems with variables.", + "keywords": [ + "phpcs", + "static analysis" + ], "support": { "issues": "https://github.com/sirbrillig/phpcs-variable-analysis/issues", "source": "https://github.com/sirbrillig/phpcs-variable-analysis", "wiki": "https://github.com/sirbrillig/phpcs-variable-analysis/wiki" }, - "time": "2021-07-06T23:45:17+00:00" + "time": "2022-10-05T23:31:46+00:00" }, { "name": "wp-coding-standards/wpcs", @@ -470,5 +482,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.1.0" + "plugin-api-version": "2.0.0" } diff --git a/readme.txt b/readme.txt index f8cc859..ef487bb 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: SEO, Yoast, WPGraphQL, GraphQL, Headless WordPress, Decoupled WordPress, J Requires at least: 5.0 Tested up to: 6 Requires PHP: 7.1 -Stable tag: 4.19.0 +Stable tag: 4.20.0 License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0.html diff --git a/wp-graphql-yoast-seo.php b/wp-graphql-yoast-seo.php index f35ca25..94ef4f9 100755 --- a/wp-graphql-yoast-seo.php +++ b/wp-graphql-yoast-seo.php @@ -8,7 +8,7 @@ * Author URI: https://www.ashleyhitchcock.com * Text Domain: wp-graphql-yoast-seo * Domain Path: /languages - * Version: 4.19.0 + * Version: 4.20.0 * * @package WP_Graphql_YOAST_SEO */ @@ -344,6 +344,43 @@ function wp_gql_seo_build_content_type_data($types, $all) ], ]); + register_graphql_object_type('SEOGlobalMetaHome', [ + 'description' => __('The Yoast SEO homepage data', 'wp-graphql-yoast-seo'), + 'fields' => [ + 'title' => ['type' => 'String'], + 'description' => ['type' => 'String'], + ], + ]); + register_graphql_object_type('SEOGlobalMetaAuthor', [ + 'description' => __('The Yoast SEO Author data', 'wp-graphql-yoast-seo'), + 'fields' => [ + 'title' => ['type' => 'String'], + 'description' => ['type' => 'String'], + ], + ]); + register_graphql_object_type('SEOGlobalMetaConfig', [ + 'description' => __('The Yoast SEO meta config data', 'wp-graphql-yoast-seo'), + 'fields' => [ + 'separator' => ['type' => 'String'], + ], + ]); + register_graphql_object_type('SEOGlobalMeta404', [ + 'description' => __('The Yoast SEO meta 404 data', 'wp-graphql-yoast-seo'), + 'fields' => [ + 'title' => ['type' => 'String'], + 'breadcrumb' => ['type' => 'String'], + ], + ]); + register_graphql_object_type('SEOGlobalMeta', [ + 'description' => __('The Yoast SEO meta data', 'wp-graphql-yoast-seo'), + 'fields' => [ + 'homepage' => ['type' => 'SEOGlobalMetaHome'], + 'author' => ['type' => 'SEOGlobalMetaAuthor'], + 'config' => ['type' => 'SEOGlobalMetaConfig'], + 'notFound' => ['type' => 'SEOGlobalMeta404'], + ], + ]); + register_graphql_object_type('SEOSchema', [ 'description' => __('The Yoast SEO schema data', 'wp-graphql-yoast-seo'), 'fields' => [ @@ -514,6 +551,7 @@ function wp_gql_seo_build_content_type_data($types, $all) register_graphql_object_type('SEOConfig', [ 'description' => __('The Yoast SEO site level configuration data', 'wp-graphql-yoast-seo'), 'fields' => [ + 'meta' => ['type' => 'SEOGlobalMeta'], 'schema' => ['type' => 'SEOSchema'], 'webmaster' => ['type' => 'SEOWebmaster'], 'social' => ['type' => 'SEOSocial'], @@ -592,7 +630,6 @@ function wp_gql_seo_build_content_type_data($types, $all) 'resolve' => function ($source, array $args, AppContext $context) use ($post_types) { $wpseo_options = WPSEO_Options::get_instance(); $all = $wpseo_options->get_all(); - $redirectsObj = class_exists('WPSEO_Redirect_Option') ? new WPSEO_Redirect_Option() : false; $redirects = $redirectsObj ? $redirectsObj->get_from_option() : []; @@ -610,8 +647,30 @@ function wp_gql_seo_build_content_type_data($types, $all) $contentTypes = wp_gql_seo_build_content_type_data($post_types, $all); + $homepage = [ + 'title' => wp_gql_seo_format_string(wp_gql_seo_replace_vars($all['title-home-wpseo'])), + 'description' => wp_gql_seo_format_string(wp_gql_seo_replace_vars($all['metadesc-home-wpseo'])), + ]; + $author = [ + 'title' => wp_gql_seo_format_string(wp_gql_seo_replace_vars($all['title-author-wpseo'])), + 'description' => wp_gql_seo_format_string(wp_gql_seo_replace_vars($all['metadesc-author-wpseo'])), + ]; + $config = [ + 'separator' => wp_gql_seo_format_string($all['separator']), + ]; + $notFound = [ + 'title' => wp_gql_seo_format_string(wp_gql_seo_replace_vars($all['title-404-wpseo'])), + 'breadcrumb' => wp_gql_seo_format_string(wp_gql_seo_replace_vars($all['breadcrumbs-404crumb'])), + ]; + return [ 'contentTypes' => $contentTypes, + 'meta' => [ + 'homepage' => $homepage, + 'author' => $author, + 'config' => $config, + 'notFound' => $notFound, + ], 'webmaster' => [ 'baiduVerify' => wp_gql_seo_format_string($all['baiduverify']), 'googleVerify' => wp_gql_seo_format_string($all['googleverify']),