From bd6316803edaa6c0125027ab0dd7fcbe3b3fd299 Mon Sep 17 00:00:00 2001 From: Dovid Levine Date: Sun, 13 Feb 2022 15:47:14 +0000 Subject: [PATCH 01/13] chore: change project config --- composer.json | 81 +++++-- composer.lock | 599 ++++++++++++++++++++++++++++++++++++---------- phpcs.xml | 50 +++- phpstan.neon.dist | 17 ++ 4 files changed, 588 insertions(+), 159 deletions(-) create mode 100644 phpstan.neon.dist diff --git a/composer.json b/composer.json index 51e5116..435d2c6 100644 --- a/composer.json +++ b/composer.json @@ -1,24 +1,61 @@ { - "name": "ashhitch/wp-graphql-yoast-seo", - "description": "Query Yoast SEO data with wp-graphql", - "type": "wordpress-plugin", - "license": "GPL-3.0-or-later", - "authors": [ - { - "name": "Ash Hitchcock", - "email": "hello@ashleyhitchcock.co.uk" - } - ], - "suggest": { - "wp-graphql/wp-graphql": "Required to return data via GraphQl", - "yoast/wordpress-seo": "Required to provide SEO data to this plugin" - }, - "require-dev": { - "automattic/vipwpcs": "^2.2", - "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", - "squizlabs/php_codesniffer": "^3.5" - }, - "require": { - "phpcompatibility/phpcompatibility-wp": "^2.1" - } + "name": "ashhitch/wp-graphql-yoast-seo", + "description": "Query Yoast SEO data with wp-graphql", + "type": "wordpress-plugin", + "license": "GPL-3.0-or-later", + "authors": [ + { + "name": "Ash Hitchcock", + "email": "hello@ashleyhitchcock.co.uk" + } + ], + "suggest": { + "wp-graphql/wp-graphql": "Required to return data via GraphQl", + "yoast/wordpress-seo": "Required to provide SEO data to this plugin" + }, + "require": { + "php": ">=7.4" + }, + "require-dev": { + "automattic/vipwpcs": "^2.3", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7", + "phpcompatibility/phpcompatibility-wp": "^2.1", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.2", + "poolshark/wp-graphql-stubs": "^0.0.2", + "squizlabs/php_codesniffer": "^3.6", + "szepeviktor/phpstan-wordpress": "^1.0", + "wp-coding-standards/wpcs": "^2.3" + }, + "config": { + "optimize-autoloader": true, + "process-timeout": 0, + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true, + "phpstan/extension-installer": true + } + }, + "autoload": { + "files": [ + "access-functions.php" + ], + "psr-4": { + "WPGraphQL\\YoastSEO\\": "src/" + } + }, + "scripts": { + "lint": "vendor/bin/phpcs", + "phpcs-i": [ + "php ./vendor/bin/phpcs -i" + ], + "check-cs": [ + "php ./vendor/bin/phpcs src" + ], + "fix-cs": [ + "php ./vendor/bin/phpcbf src" + ], + "phpstan": [ + "phpstan analyze --ansi --memory-limit=1G" + ] + } } diff --git a/composer.lock b/composer.lock index df1e81e..8fc699f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,183 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "aa0bc8e95c40b5f41d3301f1985c9db5", - "packages": [ + "content-hash": "d19a6e595bf1527ed296045ebd29a882", + "packages": [], + "packages-dev": [ + { + "name": "automattic/vipwpcs", + "version": "2.3.3", + "source": { + "type": "git", + "url": "https://github.com/Automattic/VIP-Coding-Standards.git", + "reference": "6cd0a6a82bc0ac988dbf9d6a7c2e293dc8ac640b" + }, + "dist": { + "type": "zip", + "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.11.1", + "squizlabs/php_codesniffer": "^3.5.5", + "wp-coding-standards/wpcs": "^2.3" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^0.5", + "php-parallel-lint/php-parallel-lint": "^1.0", + "phpcompatibility/php-compatibility": "^9", + "phpcsstandards/phpcsdevtools": "^1.0", + "phpunit/phpunit": "^4 || ^5 || ^6 || ^7" + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Contributors", + "homepage": "https://github.com/Automattic/VIP-Coding-Standards/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress VIP minimum coding conventions", + "keywords": [ + "phpcs", + "standards", + "wordpress" + ], + "support": { + "issues": "https://github.com/Automattic/VIP-Coding-Standards/issues", + "source": "https://github.com/Automattic/VIP-Coding-Standards", + "wiki": "https://github.com/Automattic/VIP-Coding-Standards/wiki" + }, + "time": "2021-09-29T16:20:23+00:00" + }, + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v0.7.2", + "source": { + "type": "git", + "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", + "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db" + }, + "dist": { + "type": "zip", + "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.1.0 || ^4.0" + }, + "require-dev": { + "composer/composer": "*", + "php-parallel-lint/php-parallel-lint": "^1.3.1", + "phpcompatibility/php-compatibility": "^9.0" + }, + "type": "composer-plugin", + "extra": { + "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + }, + "autoload": { + "psr-4": { + "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Franck Nijhof", + "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", + "homepage": "http://www.dealerdirect.com", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcbf", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "support": { + "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", + "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" + }, + "time": "2022-02-04T12:51:07+00:00" + }, + { + "name": "php-stubs/wordpress-stubs", + "version": "v5.9.0", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/wordpress-stubs.git", + "reference": "0fa8dd9a1bd2a1b60e85afc6c798fca1f599cc1b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/0fa8dd9a1bd2a1b60e85afc6c798fca1f599cc1b", + "reference": "0fa8dd9a1bd2a1b60e85afc6c798fca1f599cc1b", + "shasum": "" + }, + "replace": { + "giacocorsiglia/wordpress-stubs": "*" + }, + "require-dev": { + "nikic/php-parser": "< 4.12.0", + "php": "~7.3 || ~8.0", + "php-stubs/generator": "^0.8.0", + "phpdocumentor/reflection-docblock": "^5.3", + "phpstan/phpstan": "^1.2" + }, + "suggest": { + "paragonie/sodium_compat": "Pure PHP implementation of libsodium", + "symfony/polyfill-php73": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "WordPress function and class declaration stubs for static analysis.", + "homepage": "https://github.com/php-stubs/wordpress-stubs", + "keywords": [ + "PHPStan", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/php-stubs/wordpress-stubs/issues", + "source": "https://github.com/php-stubs/wordpress-stubs/tree/v5.9.0" + }, + "time": "2022-01-26T00:27:45+00:00" + }, { "name": "phpcompatibility/php-compatibility", "version": "9.3.5", @@ -126,16 +301,16 @@ }, { "name": "phpcompatibility/phpcompatibility-wp", - "version": "2.1.1", + "version": "2.1.3", "source": { "type": "git", "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git", - "reference": "b7dc0cd7a8f767ccac5e7637550ea1c50a67b09e" + "reference": "d55de55f88697b9cdb94bccf04f14eb3b11cf308" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/b7dc0cd7a8f767ccac5e7637550ea1c50a67b09e", - "reference": "b7dc0cd7a8f767ccac5e7637550ea1c50a67b09e", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/d55de55f88697b9cdb94bccf04f14eb3b11cf308", + "reference": "d55de55f88697b9cdb94bccf04f14eb3b11cf308", "shasum": "" }, "require": { @@ -176,187 +351,151 @@ "issues": "https://github.com/PHPCompatibility/PHPCompatibilityWP/issues", "source": "https://github.com/PHPCompatibility/PHPCompatibilityWP" }, - "time": "2021-02-15T12:58:46+00:00" + "time": "2021-12-30T16:37:40+00:00" }, { - "name": "squizlabs/php_codesniffer", - "version": "3.6.0", + "name": "phpstan/extension-installer", + "version": "1.1.0", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625" + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ffced0d2c8fa8e6cdc4d695a743271fab6c38625", - "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/66c7adc9dfa38b6b5838a9fb728b68a7d8348051", + "reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051", "shasum": "" }, "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.4.0" + "composer-plugin-api": "^1.1 || ^2.0", + "php": "^7.1 || ^8.0", + "phpstan/phpstan": ">=0.11.6" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "composer/composer": "^1.8", + "phing/phing": "^2.16.3", + "php-parallel-lint/php-parallel-lint": "^1.2.0", + "phpstan/phpstan-strict-rules": "^0.11 || ^0.12" }, - "bin": [ - "bin/phpcs", - "bin/phpcbf" - ], - "type": "library", + "type": "composer-plugin", "extra": { - "branch-alias": { - "dev-master": "3.x-dev" + "class": "PHPStan\\ExtensionInstaller\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPStan\\ExtensionInstaller\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Greg Sherwood", - "role": "lead" - } - ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", - "keywords": [ - "phpcs", - "standards" + "MIT" ], + "description": "Composer plugin for automatic installation of PHPStan extensions", "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + "issues": "https://github.com/phpstan/extension-installer/issues", + "source": "https://github.com/phpstan/extension-installer/tree/1.1.0" }, - "time": "2021-04-09T00:54:41+00:00" - } - ], - "packages-dev": [ + "time": "2020-12-13T13:06:13+00:00" + }, { - "name": "automattic/vipwpcs", - "version": "2.3.2", + "name": "phpstan/phpstan", + "version": "1.4.6", "source": { "type": "git", - "url": "https://github.com/Automattic/VIP-Coding-Standards.git", - "reference": "efacebef421334d54b99afa92fb8fa645336a8a7" + "url": "https://github.com/phpstan/phpstan.git", + "reference": "8a7761f1c520e0dad6e04d862fdc697445457cfe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Automattic/VIP-Coding-Standards/zipball/efacebef421334d54b99afa92fb8fa645336a8a7", - "reference": "efacebef421334d54b99afa92fb8fa645336a8a7", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/8a7761f1c520e0dad6e04d862fdc697445457cfe", + "reference": "8a7761f1c520e0dad6e04d862fdc697445457cfe", "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", - "squizlabs/php_codesniffer": "^3.5.5", - "wp-coding-standards/wpcs": "^2.3" + "php": "^7.1|^8.0" }, - "require-dev": { - "php-parallel-lint/php-console-highlighter": "^0.5", - "php-parallel-lint/php-parallel-lint": "^1.0", - "phpcompatibility/php-compatibility": "^9", - "phpcsstandards/phpcsdevtools": "^1.0", - "phpunit/phpunit": "^4 || ^5 || ^6 || ^7" + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ] }, - "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "authors": [ + "description": "PHPStan - PHP Static Analysis Tool", + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/1.4.6" + }, + "funding": [ { - "name": "Contributors", - "homepage": "https://github.com/Automattic/VIP-Coding-Standards/graphs/contributors" + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpstan", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" } ], - "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress VIP minimum coding conventions", - "keywords": [ - "phpcs", - "standards", - "wordpress" - ], - "support": { - "issues": "https://github.com/Automattic/VIP-Coding-Standards/issues", - "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": "2022-02-06T12:56:13+00:00" }, { - "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v0.7.1", + "name": "poolshark/wp-graphql-stubs", + "version": "v0.0.2", "source": { "type": "git", - "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", - "reference": "fe390591e0241955f22eb9ba327d137e501c771c" + "url": "https://github.com/Poolshark/wp-graphql-stubs.git", + "reference": "66ba54188d04788849abd07bfc9fff511839cdb3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/fe390591e0241955f22eb9ba327d137e501c771c", - "reference": "fe390591e0241955f22eb9ba327d137e501c771c", + "url": "https://api.github.com/repos/Poolshark/wp-graphql-stubs/zipball/66ba54188d04788849abd07bfc9fff511839cdb3", + "reference": "66ba54188d04788849abd07bfc9fff511839cdb3", "shasum": "" }, - "require": { - "composer-plugin-api": "^1.0 || ^2.0", - "php": ">=5.3", - "squizlabs/php_codesniffer": "^2.0 || ^3.0 || ^4.0" - }, "require-dev": { - "composer/composer": "*", - "phpcompatibility/php-compatibility": "^9.0", - "sensiolabs/security-checker": "^4.1.0" - }, - "type": "composer-plugin", - "extra": { - "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" - }, - "autoload": { - "psr-4": { - "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" - } + "php": "^7.4" }, + "type": "library", "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { - "name": "Franck Nijhof", - "email": "franck.nijhof@dealerdirect.com", - "homepage": "http://www.frenck.nl", - "role": "Developer / IT Manager" + "name": "Flo Ragossnig", + "email": "florian@webleaders.at" } ], - "description": "PHP_CodeSniffer Standards Composer Installer Plugin", - "homepage": "http://www.dealerdirect.com", - "keywords": [ - "PHPCodeSniffer", - "PHP_CodeSniffer", - "code quality", - "codesniffer", - "composer", - "installer", - "phpcs", - "plugin", - "qa", - "quality", - "standard", - "standards", - "style guide", - "stylecheck", - "tests" - ], + "description": "WP GraphQL Stubs for VS Code and others.", "support": { - "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", - "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" + "issues": "https://github.com/Poolshark/wp-graphql-stubs/issues", + "source": "https://github.com/Poolshark/wp-graphql-stubs/tree/v0.0.2" }, - "time": "2020-12-07T18:04:37+00:00" + "time": "2021-03-20T07:43:55+00:00" }, { "name": "sirbrillig/phpcs-variable-analysis", @@ -411,6 +550,206 @@ }, "time": "2021-07-06T23:45:17+00:00" }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.6.2", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5e4e71592f69da17871dba6e80dd51bce74a351a", + "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", + "source": "https://github.com/squizlabs/PHP_CodeSniffer", + "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + }, + "time": "2021-12-12T21:44:58+00:00" + }, + { + "name": "symfony/polyfill-php73", + "version": "v1.24.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/cc5db0e22b3cb4111010e48785a97f670b350ca5", + "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php73/tree/v1.24.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-06-05T21:20:04+00:00" + }, + { + "name": "szepeviktor/phpstan-wordpress", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/szepeviktor/phpstan-wordpress.git", + "reference": "d44b5abcaa529698e138b2d21bc2a7cf9834039c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/d44b5abcaa529698e138b2d21bc2a7cf9834039c", + "reference": "d44b5abcaa529698e138b2d21bc2a7cf9834039c", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0", + "php-stubs/wordpress-stubs": "^4.7 || ^5.0", + "phpstan/phpstan": "^1.0", + "symfony/polyfill-php73": "^1.12.0" + }, + "require-dev": { + "composer/composer": "^1.10.23", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7", + "php-parallel-lint/php-parallel-lint": "^1.1", + "phpstan/phpstan-strict-rules": "^1.0", + "phpunit/phpunit": "^7 || ^9", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^0.6" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, + "autoload": { + "psr-4": { + "SzepeViktor\\PHPStan\\WordPress\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "WordPress extensions for PHPStan", + "keywords": [ + "PHPStan", + "code analyse", + "code analysis", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/szepeviktor/phpstan-wordpress/issues", + "source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v1.0.2" + }, + "funding": [ + { + "url": "https://www.paypal.me/szepeviktor", + "type": "custom" + } + ], + "time": "2021-11-19T12:47:11+00:00" + }, { "name": "wp-coding-standards/wpcs", "version": "2.3.0", @@ -468,7 +807,9 @@ "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, - "platform": [], + "platform": { + "php": ">=7.4" + }, "platform-dev": [], - "plugin-api-version": "2.1.0" + "plugin-api-version": "2.2.0" } diff --git a/phpcs.xml b/phpcs.xml index 2c18f8c..f4367f1 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,29 +1,63 @@ - + Coding standards for the WPGraphQL Yoast SEO plugin - + . */.git/* */vendor/* */wp-content/* - + + + - + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + - \ No newline at end of file + + + + + + + diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..698aac3 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,17 @@ +parameters: + level: 8 + inferPrivatePropertyTypeFromConstructor: true + checkMissingIterableValueType: false + featureToggles: + disableRuntimeReflectionProvider: true + bootstrapFiles: + - phpstan/constants.php + - wp-graphql-yoast-seo.php + paths: + - wp-graphql-yoast.php + - src/ + scanDirectories: + - ../wp-graphql/ + - ../wordpress-seo/ + ignoreErrors: + - '#^Function apply_filters(_ref_array)? invoked with ([1-9]|1[0-2]) parameters, 2 required\.$#' From b87b8c40967235f8784eaa146130babaa84c81c4 Mon Sep 17 00:00:00 2001 From: Dovid Levine Date: Sun, 13 Feb 2022 15:47:41 +0000 Subject: [PATCH 02/13] chore: implement PHP Interfaces --- src/Interfaces/Field.php | 24 ++++++++++++++++++++++++ src/Interfaces/Registerable.php | 23 +++++++++++++++++++++++ src/Interfaces/Type.php | 20 ++++++++++++++++++++ src/Interfaces/TypeWithFields.php | 20 ++++++++++++++++++++ 4 files changed, 87 insertions(+) create mode 100644 src/Interfaces/Field.php create mode 100644 src/Interfaces/Registerable.php create mode 100644 src/Interfaces/Type.php create mode 100644 src/Interfaces/TypeWithFields.php diff --git a/src/Interfaces/Field.php b/src/Interfaces/Field.php new file mode 100644 index 0000000..0aa5bd3 --- /dev/null +++ b/src/Interfaces/Field.php @@ -0,0 +1,24 @@ + Date: Sat, 19 Feb 2022 14:55:26 +0000 Subject: [PATCH 03/13] chore: base plugin refactor --- access-functions.php | 85 + phpcs.xml | 2 +- phpstan.neon.dist | 5 +- .../PostTypeToTermNodeConnectionEdge.php | 81 + src/CoreSchemaFilters.php | 82 + src/Interfaces/Hookable.php | 21 + .../{Registerable.php => Registrable.php} | 0 src/Seo.php | 100 ++ src/Type/Enum/SEOCardTypeEnum.php | 59 + src/Type/WPInterface/ContentNodeWithSEO.php | 232 +++ src/Type/WPInterface/SEOBaseFields.php | 82 + src/Type/WPInterface/TermNodeWithSEO.php | 198 +++ src/Type/WPObject/Config/Breadcrumbs.php | 64 + .../Config/ContentType/ContentType.php | 62 + src/Type/WPObject/Config/ContentTypes.php | 70 + src/Type/WPObject/Config/OpenGraph.php | 58 + .../WPObject/Config/OpenGraph/FrontPage.php | 61 + src/Type/WPObject/Config/Redirect.php | 62 + src/Type/WPObject/Config/Schema.php | 66 + src/Type/WPObject/Config/Social.php | 64 + src/Type/WPObject/Config/Social/Facebook.php | 58 + src/Type/WPObject/Config/Social/Instagram.php | 57 + src/Type/WPObject/Config/Social/LinkedIn.php | 57 + src/Type/WPObject/Config/Social/MySpace.php | 57 + src/Type/WPObject/Config/Social/Pinterest.php | 58 + src/Type/WPObject/Config/Social/Twitter.php | 59 + src/Type/WPObject/Config/Social/Wikipedia.php | 57 + src/Type/WPObject/Config/Social/Youtube.php | 57 + src/Type/WPObject/Config/Webmaster.php | 59 + src/Type/WPObject/ContentType/Archive.php | 62 + src/Type/WPObject/PageInfo/Schema.php | 56 + src/Type/WPObject/PostType/Schema.php | 58 + src/Type/WPObject/PostTypeSEO.php | 61 + src/Type/WPObject/SEOConfig.php | 351 +++++ src/Type/WPObject/SEOPostTypeBreadcrumbs.php | 58 + src/Type/WPObject/SEOPostTypePageInfo.php | 87 + src/Type/WPObject/SEOUser.php | 207 +++ src/Type/WPObject/Taxonomy/Schema.php | 56 + src/Type/WPObject/TaxonomySEO.php | 59 + src/Type/WPObject/User/Schema.php | 58 + src/Type/WPObject/User/Social.php | 65 + src/TypeRegistry.php | 156 ++ wp-graphql-yoast-seo.php | 1393 ++--------------- 43 files changed, 3398 insertions(+), 1302 deletions(-) create mode 100644 access-functions.php create mode 100644 src/Connection/PostTypeToTermNodeConnectionEdge.php create mode 100644 src/CoreSchemaFilters.php create mode 100644 src/Interfaces/Hookable.php rename src/Interfaces/{Registerable.php => Registrable.php} (100%) create mode 100644 src/Seo.php create mode 100644 src/Type/Enum/SEOCardTypeEnum.php create mode 100644 src/Type/WPInterface/ContentNodeWithSEO.php create mode 100644 src/Type/WPInterface/SEOBaseFields.php create mode 100644 src/Type/WPInterface/TermNodeWithSEO.php create mode 100644 src/Type/WPObject/Config/Breadcrumbs.php create mode 100644 src/Type/WPObject/Config/ContentType/ContentType.php create mode 100644 src/Type/WPObject/Config/ContentTypes.php create mode 100644 src/Type/WPObject/Config/OpenGraph.php create mode 100644 src/Type/WPObject/Config/OpenGraph/FrontPage.php create mode 100644 src/Type/WPObject/Config/Redirect.php create mode 100644 src/Type/WPObject/Config/Schema.php create mode 100644 src/Type/WPObject/Config/Social.php create mode 100644 src/Type/WPObject/Config/Social/Facebook.php create mode 100644 src/Type/WPObject/Config/Social/Instagram.php create mode 100644 src/Type/WPObject/Config/Social/LinkedIn.php create mode 100644 src/Type/WPObject/Config/Social/MySpace.php create mode 100644 src/Type/WPObject/Config/Social/Pinterest.php create mode 100644 src/Type/WPObject/Config/Social/Twitter.php create mode 100644 src/Type/WPObject/Config/Social/Wikipedia.php create mode 100644 src/Type/WPObject/Config/Social/Youtube.php create mode 100644 src/Type/WPObject/Config/Webmaster.php create mode 100644 src/Type/WPObject/ContentType/Archive.php create mode 100644 src/Type/WPObject/PageInfo/Schema.php create mode 100644 src/Type/WPObject/PostType/Schema.php create mode 100644 src/Type/WPObject/PostTypeSEO.php create mode 100644 src/Type/WPObject/SEOConfig.php create mode 100644 src/Type/WPObject/SEOPostTypeBreadcrumbs.php create mode 100644 src/Type/WPObject/SEOPostTypePageInfo.php create mode 100644 src/Type/WPObject/SEOUser.php create mode 100644 src/Type/WPObject/Taxonomy/Schema.php create mode 100644 src/Type/WPObject/TaxonomySEO.php create mode 100644 src/Type/WPObject/User/Schema.php create mode 100644 src/Type/WPObject/User/Social.php create mode 100644 src/TypeRegistry.php diff --git a/access-functions.php b/access-functions.php new file mode 100644 index 0000000..5acf7fa --- /dev/null +++ b/access-functions.php @@ -0,0 +1,85 @@ + - + diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 698aac3..aa48a81 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -5,10 +5,11 @@ parameters: featureToggles: disableRuntimeReflectionProvider: true bootstrapFiles: - - phpstan/constants.php + - access-functions.php - wp-graphql-yoast-seo.php paths: - - wp-graphql-yoast.php + - access-functions.php + - wp-graphql-yoast-seo.php - src/ scanDirectories: - ../wp-graphql/ diff --git a/src/Connection/PostTypeToTermNodeConnectionEdge.php b/src/Connection/PostTypeToTermNodeConnectionEdge.php new file mode 100644 index 0000000..d6bf00b --- /dev/null +++ b/src/Connection/PostTypeToTermNodeConnectionEdge.php @@ -0,0 +1,81 @@ +graphql_single_name ) ) { + continue; + } + + $post_name_key = wp_gql_seo_get_field_key( $post_type_object->graphql_single_name ); + + $taxonomies = get_object_taxonomies( $post_type, 'objects' ); + + foreach ( $taxonomies as $tax ) { + // Skip if not a hierarchical taxonomy registered to GraphQL. + if ( ! isset( $tax->hierarchical ) && ! isset( $tax->graphql_single_name ) ) { + continue; + } + + $name = sprintf( + '%sTo%sConnectionEdge', + ucfirst( $post_name_key ), + ucfirst( $tax->graphql_single_name ) + ); + + register_graphql_field( + $name, + 'isPrimary', + [ + 'type' => 'Boolean', + // translators: Taxonomy name. + 'description' => sprintf( __( 'The Yoast SEO primary %s.', 'wp-graphql-yoast-seo' ), $tax->labels->name ), + 'resolve' => static function( $item, array $args, AppContext $context ) use ( $tax ) { + $post_id = $item['source']->ID; + $term_id = $item['node']->term_id; + + $wpseo_primary_term = new WPSEO_Primary_Term( $tax->name, $post_id ); + $primary_tax_id = $wpseo_primary_term->get_primary_term(); + + return $primary_tax_id === $term_id; + }, + ] + ); + } + } + } + +} diff --git a/src/CoreSchemaFilters.php b/src/CoreSchemaFilters.php new file mode 100644 index 0000000..d404531 --- /dev/null +++ b/src/CoreSchemaFilters.php @@ -0,0 +1,82 @@ +includes(); + self::$instance->setup(); + } + + /** + * Fire off init action + * + * @param Seo $instance The instance of the Seo class + */ + do_action( 'graphql_seo_init', self::$instance ); + + /** + * Return the Seo Instance + */ + return self::$instance; + } + /** + * Throw error on object clone. + * The whole idea of the singleton design pattern is that there is a single object + * therefore, we don't want the object to be cloned. + * + * @since @todo + * @access public + * @return void + */ + public function __clone() { + // Cloning instances of the class is forbidden. + _doing_it_wrong( __FUNCTION__, esc_html__( 'WPGraphQL/YoastSEO/Seo class should not be cloned.', 'wp-graphql-yoast-seo' ), '@todo' ); + } + + /** + * Disable unserializing of the class. + * + * @since @todo + * @access protected + * @return void + */ + public function __wakeup() : void { + // De-serializing instances of the class is forbidden. + _doing_it_wrong( __FUNCTION__, esc_html__( 'De-serializing instances of the WPGraphQL/YoastSEO/Seo class is not allowed', 'wp-graphql-yoast-seo' ), '@todo' ); + } + + /** + * Include required files. + * Uses composer's autoload + * + * @access private + * @since @todo + */ + private function includes() : void { + /** + * Autoload Required Classes + */ + if ( defined( 'WPGRAPHQL_SEO_AUTOLOAD' ) && false !== WPGRAPHQL_SEO_AUTOLOAD && defined( 'WPGRAPHQL_SEO_PLUGIN_DIR' ) ) { + require_once WPGRAPHQL_SEO_PLUGIN_DIR . 'vendor/autoload.php'; + } + } + + /** + * Sets up the schema. + */ + private function setup() : void { + CoreSchemaFilters::register_hooks(); + add_action( get_graphql_register_action(), [ TypeRegistry::class, 'init' ] ); + } + } +endif; diff --git a/src/Type/Enum/SEOCardTypeEnum.php b/src/Type/Enum/SEOCardTypeEnum.php new file mode 100644 index 0000000..9e2f713 --- /dev/null +++ b/src/Type/Enum/SEOCardTypeEnum.php @@ -0,0 +1,59 @@ + static::get_description(), + 'values' => static::get_values(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'Types of cards', 'wp-graphql-yoast-seo' ); + } + + /** + * Gets the Enum type values. + */ + public static function get_values() : array { + return [ + 'summary_large_image' => [ + 'value' => 'summary_large_image', + ], + 'summary' => [ + 'value' => 'summary', + ], + ]; + } +} diff --git a/src/Type/WPInterface/ContentNodeWithSEO.php b/src/Type/WPInterface/ContentNodeWithSEO.php new file mode 100644 index 0000000..887c82f --- /dev/null +++ b/src/Type/WPInterface/ContentNodeWithSEO.php @@ -0,0 +1,232 @@ + self::get_description(), + 'fields' => self::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'A node that can have Yoast SEO data assigned to it.', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + return [ + 'seo' => [ + 'type' => PostTypeSEO::$type, + 'resolve' => static function( $post, array $args, AppContext $context ) { + // Base array. + $seo = []; + + $map = [ + '@id' => 'id', + '@type' => 'type', + '@graph' => 'graph', + '@context' => 'context', + ]; + + $schemaArray = YoastSEO()->meta->for_post( $post->ID ) + ->schema; + + // https://developer.yoast.com/blog/yoast-seo-14-0-using-yoast-seo-surfaces/ + $robots = YoastSEO()->meta->for_post( $post->ID ) + ->robots; + + // Get data + $seo = [ + 'title' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID )->title + ), + 'metaDesc' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->description + ), + 'focuskw' => wp_gql_seo_format_string( + get_post_meta( + $post->ID, + '_yoast_wpseo_focuskw', + true + ) + ), + 'metaKeywords' => wp_gql_seo_format_string( + get_post_meta( + $post->ID, + '_yoast_wpseo_metakeywords', + true + ) + ), + 'metaRobotsNoindex' => $robots['index'], + 'metaRobotsNofollow' => $robots['follow'], + 'opengraphTitle' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->open_graph_title + ), + 'opengraphUrl' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->open_graph_url + ), + 'opengraphSiteName' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->open_graph_site_name + ), + 'opengraphType' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->open_graph_type + ), + 'opengraphAuthor' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->open_graph_article_author + ), + 'opengraphPublisher' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->open_graph_article_publisher + ), + 'opengraphPublishedTime' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->open_graph_article_published_time + ), + 'opengraphModifiedTime' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->open_graph_article_modified_time + ), + 'opengraphDescription' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->open_graph_description + ), + 'opengraphImage' => function () use ( + $post, + $context + ) { + $id = wp_gql_seo_get_og_image( + YoastSEO()->meta->for_post( $post->ID ) + ->open_graph_images + ); + + return $context + ->get_loader( 'post' ) + ->load_deferred( absint( $id ) ); + }, + 'twitterCardType' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->twitter_card + ), + 'twitterTitle' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->twitter_title + ), + 'twitterDescription' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->twitter_description + ), + 'twitterImage' => function () use ( + $post, + $context + ) { + $id = wpcom_vip_attachment_url_to_postid( + YoastSEO()->meta->for_post( $post->ID ) + ->twitter_image + ); + + return $context + ->get_loader( 'post' ) + ->load_deferred( absint( $id ) ); + }, + 'canonical' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->canonical + ), + 'readingTime' => floatval( + YoastSEO()->meta->for_post( $post->ID ) + ->estimated_reading_time_minutes + ), + 'breadcrumbs' => YoastSEO()->meta->for_post( + $post->ID + )->breadcrumbs, + 'cornerstone' => boolval( + YoastSEO()->meta->for_post( $post->ID ) + ->indexable->is_cornerstone + ), + 'fullHead' => is_string( + YoastSEO() + ->meta->for_post( $post->ID ) + ->get_head() + ) + ? YoastSEO() + ->meta->for_post( $post->ID ) + ->get_head() + : YoastSEO() + ->meta->for_post( $post->ID ) + ->get_head()->html, + 'schema' => [ + 'pageType' => is_array( + YoastSEO()->meta->for_post( $post->ID ) + ->schema_page_type + ) + ? YoastSEO()->meta->for_post( $post->ID ) + ->schema_page_type + : [], + 'articleType' => is_array( + YoastSEO()->meta->for_post( $post->ID ) + ->schema_article_type + ) + ? YoastSEO()->meta->for_post( $post->ID ) + ->schema_article_type + : [], + 'raw' => json_encode( + $schemaArray, + JSON_UNESCAPED_SLASHES + ), + ], + ]; + + return ! empty( $seo ) ? $seo : null; + }, + ], + ]; + } +} diff --git a/src/Type/WPInterface/SEOBaseFields.php b/src/Type/WPInterface/SEOBaseFields.php new file mode 100644 index 0000000..dda2700 --- /dev/null +++ b/src/Type/WPInterface/SEOBaseFields.php @@ -0,0 +1,82 @@ + self::get_description(), + 'fields' => self::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'Base SEO Fields.', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + return [ + 'title' => [ 'type' => 'String' ], + 'metaDesc' => [ 'type' => 'String' ], + 'focuskw' => [ 'type' => 'String' ], + 'metaKeywords' => [ 'type' => 'String' ], + 'metaRobotsNoindex' => [ 'type' => 'String' ], + 'metaRobotsNofollow' => [ 'type' => 'String' ], + 'opengraphTitle' => [ 'type' => 'String' ], + 'opengraphUrl' => [ 'type' => 'String' ], + 'opengraphSiteName' => [ 'type' => 'String' ], + 'opengraphType' => [ 'type' => 'String' ], + 'opengraphAuthor' => [ 'type' => 'String' ], + 'opengraphPublisher' => [ 'type' => 'String' ], + 'opengraphPublishedTime' => [ 'type' => 'String' ], + 'opengraphModifiedTime' => [ 'type' => 'String' ], + 'opengraphDescription' => [ 'type' => 'String' ], + 'opengraphImage' => [ 'type' => 'MediaItem' ], + 'twitterTitle' => [ 'type' => 'String' ], + 'twitterDescription' => [ 'type' => 'String' ], + 'twitterImage' => [ 'type' => 'MediaItem' ], + 'canonical' => [ 'type' => 'String' ], + 'breadcrumbs' => [ 'type' => [ 'list_of' => SEOPostTypeBreadcrumbs::$type ] ], + 'cornerstone' => [ 'type' => 'Boolean' ], + 'fullHead' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPInterface/TermNodeWithSEO.php b/src/Type/WPInterface/TermNodeWithSEO.php new file mode 100644 index 0000000..c1bf548 --- /dev/null +++ b/src/Type/WPInterface/TermNodeWithSEO.php @@ -0,0 +1,198 @@ + self::get_description(), + 'fields' => self::get_fields(), + ] + ); + + // self::register_field(); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'A term node that can have Yoast SEO data assigned to it.', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + return [ + 'seo' => [ + 'type' => TaxonomySEO::$type, + 'resolve' => static function( $term, array $args, AppContext $context ) { + $term_obj = get_term( $term->term_id ); + + $meta = WPSEO_Taxonomy_Meta::get_term_meta( + (int) $term_obj->term_id, + $term_obj->taxonomy + ); + $robots = YoastSEO()->meta->for_term( $term->term_id )->robots; + + $schemaArray = YoastSEO()->meta->for_term( $term->term_id ) + ->schema; + + // Get data + $seo = [ + 'title' => wp_gql_seo_format_string( + html_entity_decode( + wp_strip_all_tags( + YoastSEO()->meta->for_term( $term->term_id ) + ->title + ) + ) + ), + 'metaDesc' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->description + ), + 'focuskw' => isset( $meta['wpseo_focuskw'] ) + ? wp_gql_seo_format_string( $meta['wpseo_focuskw'] ) + : $meta['wpseo_focuskw'], + 'metaKeywords' => isset( $meta['wpseo_metakeywords'] ) + ? wp_gql_seo_format_string( + $meta['wpseo_metakeywords'] + ) + : null, + 'metaRobotsNoindex' => $robots['index'], + 'metaRobotsNofollow' => $robots['follow'], + 'opengraphTitle' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->open_graph_title + ), + 'opengraphUrl' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->open_graph_url + ), + 'opengraphSiteName' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->open_graph_site_name + ), + 'opengraphType' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->open_graph_type + ), + 'opengraphAuthor' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->open_graph_article_author + ), + 'opengraphPublisher' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->open_graph_article_publisher + ), + 'opengraphPublishedTime' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->open_graph_article_published_time + ), + 'opengraphModifiedTime' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->open_graph_article_modified_time + ), + 'opengraphDescription' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->open_graph_description + ), + 'opengraphImage' => $context + ->get_loader( 'post' ) + ->load_deferred( + absint( $meta['wpseo_opengraph-image-id'] ) + ), + 'twitterCardType' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->twitter_card + ), + 'twitterTitle' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->twitter_title + ), + 'twitterDescription' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->twitter_description + ), + 'twitterImage' => $context + ->get_loader( 'post' ) + ->load_deferred( + absint( $meta['wpseo_twitter-image-id'] ) + ), + 'canonical' => isset( + YoastSEO()->meta->for_term( $term->term_id )->canonical + ) + ? wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->canonical + ) + : null, + 'breadcrumbs' => YoastSEO()->meta->for_term( + $term->term_id + )->breadcrumbs, + 'cornerstone' => boolval( + YoastSEO()->meta->for_term( $term->term_id ) + ->is_cornerstone + ), + 'fullHead' => is_string( + YoastSEO() + ->meta->for_term( $term->term_id ) + ->get_head() + ) + ? YoastSEO() + ->meta->for_term( $term->term_id ) + ->get_head() + : YoastSEO() + ->meta->for_term( $term->term_id ) + ->get_head()->html, + 'schema' => [ + 'raw' => json_encode( + $schemaArray, + JSON_UNESCAPED_SLASHES + ), + ], + ]; + wp_reset_query(); + + return ! empty( $seo ) ? $seo : null; + }, + ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Breadcrumbs.php b/src/Type/WPObject/Config/Breadcrumbs.php new file mode 100644 index 0000000..d080716 --- /dev/null +++ b/src/Type/WPObject/Config/Breadcrumbs.php @@ -0,0 +1,64 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Yoast SEO breadcrumb config', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'enabled' => [ 'type' => 'Boolean' ], + 'boldLast' => [ 'type' => 'Boolean' ], + 'showBlogPage' => [ 'type' => 'Boolean' ], + 'notFoundText' => [ 'type' => 'String' ], + 'archivePrefix' => [ 'type' => 'String' ], + 'homeText' => [ 'type' => 'String' ], + 'prefix' => [ 'type' => 'String' ], + 'searchPrefix' => [ 'type' => 'String' ], + 'separator' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/Config/ContentType/ContentType.php b/src/Type/WPObject/Config/ContentType/ContentType.php new file mode 100644 index 0000000..f325770 --- /dev/null +++ b/src/Type/WPObject/Config/ContentType/ContentType.php @@ -0,0 +1,62 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Yoast SEO search appearance content types fields', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'title' => [ 'type' => 'String' ], + 'metaDesc' => [ 'type' => 'String' ], + 'metaRobotsNoindex' => [ 'type' => 'Boolean' ], + 'schemaType' => [ 'type' => 'String' ], + 'schema' => [ 'type' => 'SEOPageInfoSchema' ], + 'archive' => [ 'type' => Archive::$type ], + ]; + } +} diff --git a/src/Type/WPObject/Config/ContentTypes.php b/src/Type/WPObject/Config/ContentTypes.php new file mode 100644 index 0000000..f7f466e --- /dev/null +++ b/src/Type/WPObject/Config/ContentTypes.php @@ -0,0 +1,70 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Yoast SEO search appearance content types', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + $post_types = WPGraphQL::get_allowed_post_types(); + + return self::build_content_types( $post_types ); + } + + private static function build_content_types( $types ) : array { + $carry = []; + + foreach ( $types as $type ) { + $post_type_object = get_post_type_object( $type ); + if ( $post_type_object->graphql_single_name ) { + $carry[ wp_gql_seo_get_field_key( $post_type_object->graphql_single_name ) ] = [ 'type' => ContentType::$type ]; + } + } + + return $carry; + } +} diff --git a/src/Type/WPObject/Config/OpenGraph.php b/src/Type/WPObject/Config/OpenGraph.php new file mode 100644 index 0000000..98853db --- /dev/null +++ b/src/Type/WPObject/Config/OpenGraph.php @@ -0,0 +1,58 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Open Graph data', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'defaultImage' => [ 'type' => 'MediaItem' ], + 'frontPage' => [ 'type' => FrontPage::$type ], + ]; + } +} diff --git a/src/Type/WPObject/Config/OpenGraph/FrontPage.php b/src/Type/WPObject/Config/OpenGraph/FrontPage.php new file mode 100644 index 0000000..fffecd1 --- /dev/null +++ b/src/Type/WPObject/Config/OpenGraph/FrontPage.php @@ -0,0 +1,61 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Open Graph Front page data', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'title' => [ 'type' => 'String' ], + 'description' => [ 'type' => 'String' ], + 'image' => [ 'type' => 'MediaItem' ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Redirect.php b/src/Type/WPObject/Config/Redirect.php new file mode 100644 index 0000000..a8d46ca --- /dev/null +++ b/src/Type/WPObject/Config/Redirect.php @@ -0,0 +1,62 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Yoast redirect data (Yoast Premium only)', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'origin' => [ 'type' => 'String' ], + 'target' => [ 'type' => 'String' ], + 'type' => [ 'type' => 'Int' ], + 'format' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Schema.php b/src/Type/WPObject/Config/Schema.php new file mode 100644 index 0000000..841f658 --- /dev/null +++ b/src/Type/WPObject/Config/Schema.php @@ -0,0 +1,66 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Yoast SEO schema data', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'companyName' => [ 'type' => 'String' ], + 'personName' => [ 'type' => 'String' ], + 'companyOrPerson' => [ 'type' => 'String' ], + 'companyLogo' => [ 'type' => 'MediaItem' ], + 'personLogo' => [ 'type' => 'MediaItem' ], + 'logo' => [ 'type' => 'MediaItem' ], + 'siteName' => [ 'type' => 'String' ], + 'wordpressSiteName' => [ 'type' => 'String' ], + 'siteUrl' => [ 'type' => 'String' ], + 'homeUrl' => [ 'type' => 'String' ], + 'inLanguage' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Social.php b/src/Type/WPObject/Config/Social.php new file mode 100644 index 0000000..2facfbd --- /dev/null +++ b/src/Type/WPObject/Config/Social.php @@ -0,0 +1,64 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Yoast SEO Social media links', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'facebook' => [ 'type' => SEOSocial\Facebook::$type ], + 'twitter' => [ 'type' => SEOSocial\Twitter::$type ], + 'instagram' => [ 'type' => SEOSocial\Instagram::$type ], + 'linkedIn' => [ 'type' => SEOSocial\LinkedIn::$type ], + 'mySpace' => [ 'type' => SEOSocial\MySpace::$type ], + 'pinterest' => [ 'type' => SEOSocial\Pinterest::$type ], + 'youTube' => [ 'type' => SEOSocial\Youtube::$type ], + 'wikipedia' => [ 'type' => SEOSocial\Wikipedia::$type ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Social/Facebook.php b/src/Type/WPObject/Config/Social/Facebook.php new file mode 100644 index 0000000..7298a9c --- /dev/null +++ b/src/Type/WPObject/Config/Social/Facebook.php @@ -0,0 +1,58 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + // @todo update description + return __( 'The Yoast SEO webmaster fields', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'url' => [ 'type' => 'String' ], + 'defaultImage' => [ 'type' => 'MediaItem' ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Social/Instagram.php b/src/Type/WPObject/Config/Social/Instagram.php new file mode 100644 index 0000000..c940fd3 --- /dev/null +++ b/src/Type/WPObject/Config/Social/Instagram.php @@ -0,0 +1,57 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + // @todo update description + return __( 'The Yoast SEO webmaster fields', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'url' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Social/LinkedIn.php b/src/Type/WPObject/Config/Social/LinkedIn.php new file mode 100644 index 0000000..2ce9277 --- /dev/null +++ b/src/Type/WPObject/Config/Social/LinkedIn.php @@ -0,0 +1,57 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + // @todo update description + return __( 'The Yoast SEO webmaster fields', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'url' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Social/MySpace.php b/src/Type/WPObject/Config/Social/MySpace.php new file mode 100644 index 0000000..7c039b8 --- /dev/null +++ b/src/Type/WPObject/Config/Social/MySpace.php @@ -0,0 +1,57 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + // @todo update description + return __( 'The Yoast SEO webmaster fields', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'url' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Social/Pinterest.php b/src/Type/WPObject/Config/Social/Pinterest.php new file mode 100644 index 0000000..9f8ace8 --- /dev/null +++ b/src/Type/WPObject/Config/Social/Pinterest.php @@ -0,0 +1,58 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + // @todo update description + return __( 'The Yoast SEO webmaster fields', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'url' => [ 'type' => 'String' ], + 'metaTag' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Social/Twitter.php b/src/Type/WPObject/Config/Social/Twitter.php new file mode 100644 index 0000000..9d1e271 --- /dev/null +++ b/src/Type/WPObject/Config/Social/Twitter.php @@ -0,0 +1,59 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + // @todo update description + return __( 'The Yoast SEO webmaster fields', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'username' => [ 'type' => 'String' ], + 'cardType' => [ 'type' => SEOCardTypeEnum::$type ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Social/Wikipedia.php b/src/Type/WPObject/Config/Social/Wikipedia.php new file mode 100644 index 0000000..b03c8a6 --- /dev/null +++ b/src/Type/WPObject/Config/Social/Wikipedia.php @@ -0,0 +1,57 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + // @todo update description + return __( 'The Yoast SEO webmaster fields', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'url' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Social/Youtube.php b/src/Type/WPObject/Config/Social/Youtube.php new file mode 100644 index 0000000..5aa1799 --- /dev/null +++ b/src/Type/WPObject/Config/Social/Youtube.php @@ -0,0 +1,57 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + // @todo update description + return __( 'The Yoast SEO webmaster fields', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'url' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Webmaster.php b/src/Type/WPObject/Config/Webmaster.php new file mode 100644 index 0000000..c8550ba --- /dev/null +++ b/src/Type/WPObject/Config/Webmaster.php @@ -0,0 +1,59 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Yoast SEO webmaster fields', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'baiduVerify' => [ 'type' => 'String' ], + 'googleVerify' => [ 'type' => 'String' ], + 'msVerify' => [ 'type' => 'String' ], + 'yandexVerify' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/ContentType/Archive.php b/src/Type/WPObject/ContentType/Archive.php new file mode 100644 index 0000000..fa85fd4 --- /dev/null +++ b/src/Type/WPObject/ContentType/Archive.php @@ -0,0 +1,62 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Yoast SEO search appearance content types fields.', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'hasArchive' => [ 'type' => 'Boolean' ], + 'title' => [ 'type' => 'String' ], + 'archiveLink' => [ 'type' => 'String' ], + 'metaDesc' => [ 'type' => 'String' ], + 'metaRobotsNoindex' => [ 'type' => 'Boolean' ], + 'breadcrumbTitle' => [ 'type' => 'String' ], + 'fullHead' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/PageInfo/Schema.php b/src/Type/WPObject/PageInfo/Schema.php new file mode 100644 index 0000000..599cb18 --- /dev/null +++ b/src/Type/WPObject/PageInfo/Schema.php @@ -0,0 +1,56 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Schema for post type.', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'raw' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/PostType/Schema.php b/src/Type/WPObject/PostType/Schema.php new file mode 100644 index 0000000..883119d --- /dev/null +++ b/src/Type/WPObject/PostType/Schema.php @@ -0,0 +1,58 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Schema types', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'pageType' => [ 'type' => [ 'list_of' => 'String' ] ], + 'articleType' => [ 'type' => [ 'list_of' => 'String' ] ], + 'raw' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/PostTypeSEO.php b/src/Type/WPObject/PostTypeSEO.php new file mode 100644 index 0000000..649c1a3 --- /dev/null +++ b/src/Type/WPObject/PostTypeSEO.php @@ -0,0 +1,61 @@ + static::get_description(), + 'interfaces' => [ SEOBaseFields::$type ], + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Yoast SEO data for the type.', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'readingTime' => [ 'type' => 'Float' ], + 'schema' => [ 'type' => Schema::$type ], + ]; + } +} diff --git a/src/Type/WPObject/SEOConfig.php b/src/Type/WPObject/SEOConfig.php new file mode 100644 index 0000000..18bebed --- /dev/null +++ b/src/Type/WPObject/SEOConfig.php @@ -0,0 +1,351 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + + self::register_field(); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Yoast SEO site level configuration data.', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'schema' => [ 'type' => Config\Schema::$type ], + 'webmaster' => [ 'type' => Config\Webmaster::$type ], + 'social' => [ 'type' => Config\Social::$type ], + 'breadcrumbs' => [ 'type' => Config\Breadcrumbs::$type ], + 'redirects' => [ + 'type' => [ 'list_of' => Config\Redirect::$type ], + ], + 'openGraph' => [ 'type' => Config\OpenGraph::$type ], + 'contentTypes' => [ 'type' => Config\ContentTypes::$type ], + ]; + } + + /** + * {@inheritDoc} + */ + public static function register_field() : void { + $post_types = \WPGraphQL::get_allowed_post_types(); + + register_graphql_field( + 'RootQuery', + static::$fieldname, + [ + 'type' => static::$type, + 'description' => __( 'Returns seo site data.', 'wp-graphql-yoast-seo' ), + 'resolve' => static function ( $source, array $args, AppContext $context ) use ( $post_types ) { + $wpseo_options = WPSEO_Options::get_instance(); + $all = $wpseo_options->get_all(); + + $redirects_obj = class_exists( 'WPSEO_Redirect_Option' ) ? new WPSEO_Redirect_Option() : false; + $redirects = $redirects_obj ? $redirects_obj->get_from_option() : []; + + $user_id = $all['company_or_person_user_id']; + $user = get_userdata( $user_id ); + + $mappedRedirects = function ( $value ) { + return [ + 'origin' => $value['origin'], + 'target' => $value['url'], + 'type' => $value['type'], + 'format' => $value['format'], + ]; + }; + + $contentTypes = self::build_content_type_data( $post_types, $all ); + + return [ + 'contentTypes' => $contentTypes, + 'webmaster' => [ + 'baiduVerify' => wp_gql_seo_format_string( + $all['baiduverify'] + ), + 'googleVerify' => wp_gql_seo_format_string( + $all['googleverify'] + ), + 'msVerify' => wp_gql_seo_format_string( $all['msverify'] ), + 'yandexVerify' => wp_gql_seo_format_string( + $all['yandexverify'] + ), + ], + 'social' => [ + 'facebook' => [ + 'url' => wp_gql_seo_format_string( $all['facebook_site'] ), + 'defaultImage' => $context + ->get_loader( 'post' ) + ->load_deferred( $all['og_default_image_id'] ), + ], + 'twitter' => [ + 'username' => wp_gql_seo_format_string( + $all['twitter_site'] + ), + 'cardType' => wp_gql_seo_format_string( + $all['twitter_card_type'] + ), + ], + 'instagram' => [ + 'url' => wp_gql_seo_format_string( $all['instagram_url'] ), + ], + 'linkedIn' => [ + 'url' => wp_gql_seo_format_string( $all['linkedin_url'] ), + ], + 'mySpace' => [ + 'url' => wp_gql_seo_format_string( $all['myspace_url'] ), + ], + 'pinterest' => [ + 'url' => wp_gql_seo_format_string( $all['pinterest_url'] ), + 'metaTag' => wp_gql_seo_format_string( + $all['pinterestverify'] + ), + ], + 'youTube' => [ + 'url' => wp_gql_seo_format_string( $all['youtube_url'] ), + ], + 'wikipedia' => [ + 'url' => wp_gql_seo_format_string( $all['wikipedia_url'] ), + ], + ], + 'breadcrumbs' => [ + 'enabled' => wp_gql_seo_format_string( + $all['breadcrumbs-enable'] + ), + 'boldLast' => wp_gql_seo_format_string( + $all['breadcrumbs-boldlast'] + ), + 'showBlogPage' => wp_gql_seo_format_string( + $all['breadcrumbs-display-blog-page'] + ), + 'archivePrefix' => wp_gql_seo_format_string( + $all['breadcrumbs-archiveprefix'] + ), + 'prefix' => wp_gql_seo_format_string( + $all['breadcrumbs-prefix'] + ), + 'notFoundText' => wp_gql_seo_format_string( + $all['breadcrumbs-404crumb'] + ), + 'homeText' => wp_gql_seo_format_string( + $all['breadcrumbs-home'] + ), + 'searchPrefix' => wp_gql_seo_format_string( + $all['breadcrumbs-searchprefix'] + ), + 'separator' => wp_gql_seo_format_string( + $all['breadcrumbs-sep'] + ), + ], + 'schema' => [ + 'companyName' => wp_gql_seo_format_string( + $all['company_name'] + ), + 'personName' => wp_gql_seo_format_string( + $user->user_nicename + ), + 'companyLogo' => $context + ->get_loader( 'post' ) + ->load_deferred( absint( $all['company_logo_id'] ) ), + 'personLogo' => $context + ->get_loader( 'post' ) + ->load_deferred( absint( $all['person_logo_id'] ) ), + 'logo' => $context + ->get_loader( 'post' ) + ->load_deferred( + $all['company_or_person'] === 'company' + ? absint( $all['company_logo_id'] ) + : absint( $all['person_logo_id'] ) + ), + 'companyOrPerson' => wp_gql_seo_format_string( + $all['company_or_person'] + ), + 'siteName' => wp_gql_seo_format_string( + YoastSEO()->helpers->site->get_site_name() + ), + 'wordpressSiteName' => wp_gql_seo_format_string( + get_bloginfo( 'name' ) + ), + 'siteUrl' => wp_gql_seo_format_string( + apply_filters( 'wp_gql_seo_site_url', get_site_url() ) + ), + 'homeUrl' => wp_gql_seo_format_string( + apply_filters( 'wp_gql_seo_home_url', get_home_url() ) + ), + 'inLanguage' => wp_gql_seo_format_string( + get_bloginfo( 'language' ) + ), + ], + 'redirects' => array_map( $mappedRedirects, $redirects ), + 'openGraph' => [ + 'defaultImage' => $context + ->get_loader( 'post' ) + ->load_deferred( absint( $all['og_default_image_id'] ) ), + 'frontPage' => [ + 'title' => wp_gql_seo_format_string( + $all['og_frontpage_title'] + ), + 'description' => wp_gql_seo_format_string( + $all['og_frontpage_desc'] + ), + 'image' => $context + ->get_loader( 'post' ) + ->load_deferred( + absint( $all['og_frontpage_image_id'] ) + ), + ], + ], + ]; + }, + ] + ); + } + + private static function build_content_type_data( $types, $all ) : array { + $carry = []; + foreach ( $types as $type ) { + $post_type_object = get_post_type_object( $type ); + + if ( $post_type_object->graphql_single_name ) { + $tag = wp_gql_seo_get_field_key( + $post_type_object->graphql_single_name + ); + + $schemaArray = YoastSEO()->meta->for_post_type_archive( $type ) + ->schema; + + $carry[ $tag ] = [ + 'title' => ! empty( $all[ 'title-' . $type ] ) + ? $all[ 'title-' . $type ] + : null, + 'metaDesc' => ! empty( $all[ 'metadesc-' . $type ] ) + ? $all[ 'metadesc-' . $type ] + : null, + 'metaRobotsNoindex' => ! empty( $all[ 'noindex-' . $type ] ) + ? boolval( $all[ 'noindex-' . $type ] ) + : false, + 'schemaType' => ! empty( $all[ 'schema-page-type-' . $type ] ) + ? $all[ 'schema-page-type-' . $type ] + : null, + + 'schema' => [ + 'raw' => ! empty( $schemaArray ) + ? json_encode( $schemaArray, JSON_UNESCAPED_SLASHES ) + : null, + ], + 'archive' => + $tag == 'post' // Posts are stored like this + ? [ + 'hasArchive' => true, + 'archiveLink' => get_post_type_archive_link( $type ), + 'title' => $all['title-archive-wpseo'] ?? null, + 'metaDesc' => $all['metadesc-archive-wpseo'] ?? null, + 'metaRobotsNoindex' => $all['noindex-archive-wpseo'] ?? null, + 'breadcrumbTitle' => $all['bctitle-archive-wpseo'] ?? null, + 'metaRobotsNoindex' => boolval( + $all['noindex-archive-wpseo'] + ), + 'fullHead' => is_string( + YoastSEO() + ->meta->for_post_type_archive( $type ) + ->get_head() + ) + ? YoastSEO() + ->meta->for_post_type_archive( $type ) + ->get_head() + : YoastSEO() + ->meta->for_post_type_archive( $type ) + ->get_head()->html, + ] + : [ + 'hasArchive' => boolval( + $post_type_object->has_archive + ), + 'archiveLink' => get_post_type_archive_link( $type ), + 'title' => ! empty( $all[ 'title-ptarchive-' . $type ] ) + ? $all[ 'title-ptarchive-' . $type ] + : null, + 'metaDesc' => ! empty( + $all[ 'metadesc-ptarchive-' . $type ] + ) + ? $all[ 'metadesc-ptarchive-' . $type ] + : null, + 'metaRobotsNoindex' => ! empty( + $all[ 'noindex-ptarchive-' . $type ] + ) + ? boolval( $all[ 'noindex-ptarchive-' . $type ] ) + : false, + 'breadcrumbTitle' => ! empty( + $all[ 'bctitle-ptarchive-' . $type ] + ) + ? $all[ 'bctitle-ptarchive-' . $type ] + : null, + 'fullHead' => is_string( + YoastSEO() + ->meta->for_post_type_archive( $type ) + ->get_head() + ) + ? YoastSEO() + ->meta->for_post_type_archive( $type ) + ->get_head() + : YoastSEO() + ->meta->for_post_type_archive( $type ) + ->get_head()->html, + ], + ]; + } + } + return $carry; + } +} diff --git a/src/Type/WPObject/SEOPostTypeBreadcrumbs.php b/src/Type/WPObject/SEOPostTypeBreadcrumbs.php new file mode 100644 index 0000000..7a7c5a5 --- /dev/null +++ b/src/Type/WPObject/SEOPostTypeBreadcrumbs.php @@ -0,0 +1,58 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + // @todo update description. + return __( 'The Schema types for Taxonomy', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'url' => [ 'type' => 'String' ], + 'text' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/SEOPostTypePageInfo.php b/src/Type/WPObject/SEOPostTypePageInfo.php new file mode 100644 index 0000000..10ce46d --- /dev/null +++ b/src/Type/WPObject/SEOPostTypePageInfo.php @@ -0,0 +1,87 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + + self::register_field(); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The page info SEO details', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'schema' => [ 'type' => PageInfo\Schema::$type ], + ]; + } + /** + * {@inheritDoc} + */ + public static function register_field() : void { + // @todo this shouldn't be on every `pageInfo`. + register_graphql_field( + 'WPPageInfo', + 'seo', + [ + 'type' => self::$type, + 'description' => __( 'Raw schema for archive', 'wp-graphql-yoast-seo' ), + 'resolve' => static function( $item, array $args, AppContext $context ) { + $schemaArray = YoastSEO()->meta->for_post_type_archive()->schema; + + return [ + 'schema' => [ + 'raw' => json_encode( + $schemaArray, + JSON_UNESCAPED_SLASHES + ), + ], + ]; + }, + ] + ); + } +} diff --git a/src/Type/WPObject/SEOUser.php b/src/Type/WPObject/SEOUser.php new file mode 100644 index 0000000..8009c39 --- /dev/null +++ b/src/Type/WPObject/SEOUser.php @@ -0,0 +1,207 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + + self::register_field(); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + // @todo add description. + return __( 'The Yoast SEO site level configuration data.', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'title' => [ 'type' => 'String' ], + 'metaDesc' => [ 'type' => 'String' ], + 'metaRobotsNoindex' => [ 'type' => 'String' ], + 'metaRobotsNofollow' => [ 'type' => 'String' ], + 'canonical' => [ 'type' => 'String' ], + 'opengraphTitle' => [ 'type' => 'String' ], + 'opengraphDescription' => [ 'type' => 'String' ], + 'opengraphImage' => [ 'type' => 'MediaItem' ], + 'twitterImage' => [ 'type' => 'MediaItem' ], + 'twitterTitle' => [ 'type' => 'String' ], + 'twitterDescription' => [ 'type' => 'String' ], + 'language' => [ 'type' => 'String' ], + 'region' => [ 'type' => 'String' ], + 'breadcrumbTitle' => [ 'type' => 'String' ], + 'fullHead' => [ 'type' => 'String' ], + 'social' => [ 'type' => User\Social::$type ], + 'schema' => [ 'type' => User\Schema::$type ], + ]; + } + /** + * {@inheritDoc} + */ + public static function register_field() : void { + register_graphql_field( + 'User', + static::$fieldname, + [ + 'type' => static::$type, + 'description' => __( 'The Yoast SEO data of a user', 'wp-graphql-yoast-seo' ), + 'resolve' => static function ( $user, array $args, AppContext $context ) { + $robots = YoastSEO()->meta->for_author( $user->userId )->robots; + + $schemaArray = YoastSEO()->meta->for_author( $user->userId )->schema; + $userSeo = [ + 'title' => wp_gql_seo_format_string( + YoastSEO()->meta->for_author( $user->userId )->title + ), + 'metaDesc' => wp_gql_seo_format_string( + YoastSEO()->meta->for_author( $user->userId )->description + ), + 'metaRobotsNoindex' => $robots['index'], + 'metaRobotsNofollow' => $robots['follow'], + 'canonical' => YoastSEO()->meta->for_author( $user->userId ) + ->canonical, + 'opengraphTitle' => YoastSEO()->meta->for_author( $user->userId ) + ->open_graph_title, + 'opengraphDescription' => YoastSEO()->meta->for_author( + $user->userId + )->open_graph_description, + 'opengraphImage' => $context + ->get_loader( 'post' ) + ->load_deferred( + absint( + YoastSEO()->meta->for_author( $user->userId ) + ->open_graph_image_id + ) + ), + 'twitterImage' => $context + ->get_loader( 'post' ) + ->load_deferred( + absint( + YoastSEO()->meta->for_author( $user->userId ) + ->twitter_image_id + ) + ), + 'twitterTitle' => YoastSEO()->meta->for_author( $user->userId ) + ->twitter_title, + 'twitterDescription' => YoastSEO()->meta->for_author( + $user->userId + )->twitter_description, + 'language' => YoastSEO()->meta->for_author( $user->userId ) + ->language, + 'region' => YoastSEO()->meta->for_author( $user->userId )->region, + 'breadcrumbTitle' => YoastSEO()->meta->for_author( $user->userId ) + ->breadcrumb_title, + 'fullHead' => is_string( + YoastSEO() + ->meta->for_author( $user->userId ) + ->get_head() + ) + ? YoastSEO() + ->meta->for_author( $user->userId ) + ->get_head() + : YoastSEO() + ->meta->for_author( $user->userId ) + ->get_head()->html, + 'social' => [ + 'facebook' => wp_gql_seo_format_string( + get_the_author_meta( 'facebook', $user->userId ) + ), + 'twitter' => wp_gql_seo_format_string( + get_the_author_meta( 'twitter', $user->userId ) + ), + 'instagram' => wp_gql_seo_format_string( + get_the_author_meta( 'instagram', $user->userId ) + ), + 'linkedIn' => wp_gql_seo_format_string( + get_the_author_meta( 'linkedin', $user->userId ) + ), + 'mySpace' => wp_gql_seo_format_string( + get_the_author_meta( 'myspace', $user->userId ) + ), + 'pinterest' => wp_gql_seo_format_string( + get_the_author_meta( 'pinterest', $user->userId ) + ), + 'youTube' => wp_gql_seo_format_string( + get_the_author_meta( 'youtube', $user->userId ) + ), + 'soundCloud' => wp_gql_seo_format_string( + get_the_author_meta( 'soundcloud', $user->userId ) + ), + 'wikipedia' => wp_gql_seo_format_string( + get_the_author_meta( 'wikipedia', $user->userId ) + ), + ], + + 'schema' => [ + 'raw' => json_encode( $schemaArray, JSON_UNESCAPED_SLASHES ), + 'pageType' => is_array( + YoastSEO()->meta->for_author( $user->userId ) + ->schema_page_type + ) + ? YoastSEO()->meta->for_author( $user->userId ) + ->schema_page_type + : [], + 'articleType' => is_array( + YoastSEO()->meta->for_author( $user->userId ) + ->schema_article_type + ) + ? YoastSEO()->meta->for_author( $user->userId ) + ->schema_article_type + : [], + ], + ]; + + return ! empty( $userSeo ) ? $userSeo : []; + }, + ] + ); + } +} diff --git a/src/Type/WPObject/Taxonomy/Schema.php b/src/Type/WPObject/Taxonomy/Schema.php new file mode 100644 index 0000000..f9f410f --- /dev/null +++ b/src/Type/WPObject/Taxonomy/Schema.php @@ -0,0 +1,56 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Schema types for Taxonomy', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'raw' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/TaxonomySEO.php b/src/Type/WPObject/TaxonomySEO.php new file mode 100644 index 0000000..2b10292 --- /dev/null +++ b/src/Type/WPObject/TaxonomySEO.php @@ -0,0 +1,59 @@ + static::get_description(), + 'interfaces' => [ SEOBaseFields::$type ], + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Schema types', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'schema' => [ 'type' => Schema::$type ], + ]; + } +} diff --git a/src/Type/WPObject/User/Schema.php b/src/Type/WPObject/User/Schema.php new file mode 100644 index 0000000..f3029ae --- /dev/null +++ b/src/Type/WPObject/User/Schema.php @@ -0,0 +1,58 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Schema types for User', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'raw' => [ 'type' => 'String' ], + 'pageType' => [ 'type' => [ 'list_of' => 'String' ] ], + 'articleType' => [ 'type' => [ 'list_of' => 'String' ] ], + ]; + } +} diff --git a/src/Type/WPObject/User/Social.php b/src/Type/WPObject/User/Social.php new file mode 100644 index 0000000..d756b4d --- /dev/null +++ b/src/Type/WPObject/User/Social.php @@ -0,0 +1,65 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + // @todo add description + return __( 'The Social types for User', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'facebook' => [ 'type' => 'String' ], + 'twitter' => [ 'type' => 'String' ], + 'instagram' => [ 'type' => 'String' ], + 'linkedIn' => [ 'type' => 'String' ], + 'mySpace' => [ 'type' => 'String' ], + 'pinterest' => [ 'type' => 'String' ], + 'youTube' => [ 'type' => 'String' ], + 'soundCloud' => [ 'type' => 'String' ], + 'wikipedia' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/TypeRegistry.php b/src/TypeRegistry.php new file mode 100644 index 0000000..cb7f146 --- /dev/null +++ b/src/TypeRegistry.php @@ -0,0 +1,156 @@ + class_exists('WPGraphQL'), - 'Yoast SEO' => function_exists('YoastSEO'), - ]; - - $missing_dependencies = array_keys( - array_diff($core_dependencies, array_filter($core_dependencies)) - ); - $display_admin_notice = static function () use ($missing_dependencies) { - ?> -
-

-

-
    - -
  • - -
-
- graphql_single_name) { - $carry[ - wp_gql_seo_get_field_key($post_type_object->graphql_single_name) - ] = ['type' => 'SEOContentType']; - } - } - return $carry; - } - - function wp_gql_seo_build_content_type_data($types, $all) - { - $carry = []; - foreach ($types as $type) { - $post_type_object = get_post_type_object($type); - - if ($post_type_object->graphql_single_name) { - $tag = wp_gql_seo_get_field_key( - $post_type_object->graphql_single_name - ); - - $schemaArray = YoastSEO()->meta->for_post_type_archive($type) - ->schema; - - $carry[$tag] = [ - 'title' => !empty($all['title-' . $type]) - ? $all['title-' . $type] - : null, - 'metaDesc' => !empty($all['metadesc-' . $type]) - ? $all['metadesc-' . $type] - : null, - 'metaRobotsNoindex' => !empty($all['noindex-' . $type]) - ? boolval($all['noindex-' . $type]) - : false, - 'schemaType' => !empty($all['schema-page-type-' . $type]) - ? $all['schema-page-type-' . $type] - : null, - - 'schema' => [ - 'raw' => !empty($schemaArray) - ? json_encode($schemaArray, JSON_UNESCAPED_SLASHES) - : null, - ], - 'archive' => - $tag == 'post' //Posts are stored like this - ? [ - 'hasArchive' => true, - 'archiveLink' => get_post_type_archive_link($type), - 'title' => $all['title-archive-wpseo'], - '' => $all['metadesc-archive-wpseo'], - '' => $all['noindex-archive-wpseo'], - 'breadcrumbTitle' => $all['bctitle-archive-wpseo'], - 'metaRobotsNoindex' => boolval( - $all['noindex-archive-wpseo'] - ), - 'fullHead' => is_string( - YoastSEO() - ->meta->for_post_type_archive($type) - ->get_head() - ) - ? YoastSEO() - ->meta->for_post_type_archive($type) - ->get_head() - : YoastSEO() - ->meta->for_post_type_archive($type) - ->get_head()->html, - ] - : [ - 'hasArchive' => boolval( - $post_type_object->has_archive - ), - 'archiveLink' => get_post_type_archive_link($type), - 'title' => !empty($all['title-ptarchive-' . $type]) - ? $all['title-ptarchive-' . $type] - : null, - 'metaDesc' => !empty( - $all['metadesc-ptarchive-' . $type] - ) - ? $all['metadesc-ptarchive-' . $type] - : null, - 'metaRobotsNoindex' => !empty( - $all['noindex-ptarchive-' . $type] - ) - ? boolval($all['noindex-ptarchive-' . $type]) - : false, - 'breadcrumbTitle' => !empty( - $all['bctitle-ptarchive-' . $type] - ) - ? $all['bctitle-ptarchive-' . $type] - : null, - 'fullHead' => is_string( - YoastSEO() - ->meta->for_post_type_archive($type) - ->get_head() - ) - ? YoastSEO() - ->meta->for_post_type_archive($type) - ->get_head() - : YoastSEO() - ->meta->for_post_type_archive($type) - ->get_head()->html, - ], - ]; - } - } - return $carry; - } - - add_action('graphql_register_types', function () { - $post_types = \WPGraphQL::get_allowed_post_types(); - $taxonomies = \WPGraphQL::get_allowed_taxonomies(); - - // If WooCommerce installed then add these post types and taxonomies - if (class_exists('\WooCommerce')) { - array_push($post_types, 'product'); - array_push($taxonomies, 'productCategory'); - } - - register_graphql_enum_type('SEOCardType', [ - 'description' => __('Types of cards', 'wp-graphql-yoast-seo'), - 'values' => [ - 'summary_large_image' => [ - 'value' => 'summary_large_image', - ], - 'summary' => [ - 'value' => 'summary', - ], - ], - ]); - - register_graphql_object_type('SEOPostTypeSchema', [ - 'description' => __('The Schema types', 'wp-graphql-yoast-seo'), - 'fields' => [ - 'pageType' => ['type' => ['list_of' => 'String']], - 'articleType' => ['type' => ['list_of' => 'String']], - 'raw' => ['type' => 'String'], - ], - ]); - register_graphql_object_type('SEOTaxonomySchema', [ - 'description' => __( - 'The Schema types for Taxonomy', - 'wp-graphql-yoast-seo' - ), - 'fields' => [ - 'raw' => ['type' => 'String'], - ], - ]); - - $baseSEOFields = [ - 'title' => ['type' => 'String'], - 'metaDesc' => ['type' => 'String'], - 'focuskw' => ['type' => 'String'], - 'metaKeywords' => ['type' => 'String'], - 'metaRobotsNoindex' => ['type' => 'String'], - 'metaRobotsNofollow' => ['type' => 'String'], - 'opengraphTitle' => ['type' => 'String'], - 'opengraphUrl' => ['type' => 'String'], - 'opengraphSiteName' => ['type' => 'String'], - 'opengraphType' => ['type' => 'String'], - 'opengraphAuthor' => ['type' => 'String'], - 'opengraphPublisher' => ['type' => 'String'], - 'opengraphPublishedTime' => ['type' => 'String'], - 'opengraphModifiedTime' => ['type' => 'String'], - 'opengraphDescription' => ['type' => 'String'], - 'opengraphImage' => ['type' => 'MediaItem'], - 'twitterTitle' => ['type' => 'String'], - 'twitterDescription' => ['type' => 'String'], - 'twitterImage' => ['type' => 'MediaItem'], - 'canonical' => ['type' => 'String'], - 'breadcrumbs' => ['type' => ['list_of' => 'SEOPostTypeBreadcrumbs']], - 'cornerstone' => ['type' => 'Boolean'], - 'fullHead' => ['type' => 'String'], - ]; - - register_graphql_object_type('TaxonomySEO', [ - 'fields' => array_merge($baseSEOFields, [ - 'schema' => ['type' => 'SEOTaxonomySchema'], - ]), - ]); - - register_graphql_object_type('PostTypeSEO', [ - 'fields' => array_merge($baseSEOFields, [ - 'readingTime' => ['type' => 'Float'], - 'schema' => ['type' => 'SEOPostTypeSchema'], - ]), - ]); - - register_graphql_object_type('SEOPostTypeBreadcrumbs', [ - 'fields' => [ - 'url' => ['type' => 'String'], - 'text' => ['type' => 'String'], - ], - ]); - - register_graphql_object_type('SEOSchema', [ - 'description' => __('The Yoast SEO schema data', 'wp-graphql-yoast-seo'), - 'fields' => [ - 'companyName' => ['type' => 'String'], - 'personName' => ['type' => 'String'], - 'companyOrPerson' => ['type' => 'String'], - 'companyLogo' => ['type' => 'MediaItem'], - 'personLogo' => ['type' => 'MediaItem'], - 'logo' => ['type' => 'MediaItem'], - 'siteName' => ['type' => 'String'], - 'wordpressSiteName' => ['type' => 'String'], - 'siteUrl' => ['type' => 'String'], - 'homeUrl' => ['type' => 'String'], - 'inLanguage' => ['type' => 'String'], - ], - ]); - - register_graphql_object_type('SEOWebmaster', [ - 'description' => __( - 'The Yoast SEO webmaster fields', - 'wp-graphql-yoast-seo' - ), - 'fields' => [ - 'baiduVerify' => ['type' => 'String'], - 'googleVerify' => ['type' => 'String'], - 'msVerify' => ['type' => 'String'], - 'yandexVerify' => ['type' => 'String'], - ], - ]); - - register_graphql_object_type('SEOBreadcrumbs', [ - 'description' => __( - 'The Yoast SEO breadcrumb config', - 'wp-graphql-yoast-seo' - ), - 'fields' => [ - 'enabled' => ['type' => 'Boolean'], - 'boldLast' => ['type' => 'Boolean'], - 'showBlogPage' => ['type' => 'Boolean'], - 'notFoundText' => ['type' => 'String'], - 'archivePrefix' => ['type' => 'String'], - 'homeText' => ['type' => 'String'], - 'prefix' => ['type' => 'String'], - 'searchPrefix' => ['type' => 'String'], - 'separator' => ['type' => 'String'], - ], - ]); - - register_graphql_object_type('SEOSocialFacebook', [ - 'fields' => [ - 'url' => ['type' => 'String'], - 'defaultImage' => ['type' => 'MediaItem'], - ], - ]); - - register_graphql_object_type('SEOSocialTwitter', [ - 'fields' => [ - 'username' => ['type' => 'String'], - 'cardType' => ['type' => 'SEOCardType'], - ], - ]); - - register_graphql_object_type('SEOSocialInstagram', [ - 'fields' => [ - 'url' => ['type' => 'String'], - ], - ]); - register_graphql_object_type('SEOSocialLinkedIn', [ - 'fields' => [ - 'url' => ['type' => 'String'], - ], - ]); - register_graphql_object_type('SEOSocialMySpace', [ - 'fields' => [ - 'url' => ['type' => 'String'], - ], - ]); - - register_graphql_object_type('SEOSocialPinterest', [ - 'fields' => [ - 'url' => ['type' => 'String'], - 'metaTag' => ['type' => 'String'], - ], - ]); - - register_graphql_object_type('SEOSocialYoutube', [ - 'fields' => [ - 'url' => ['type' => 'String'], - ], - ]); - register_graphql_object_type('SEOSocialWikipedia', [ - 'fields' => [ - 'url' => ['type' => 'String'], - ], - ]); - - register_graphql_object_type('SEOSocial', [ - 'description' => __( - 'The Yoast SEO Social media links', - 'wp-graphql-yoast-seo' - ), - 'fields' => [ - 'facebook' => ['type' => 'SEOSocialFacebook'], - 'twitter' => ['type' => 'SEOSocialTwitter'], - 'instagram' => ['type' => 'SEOSocialInstagram'], - 'linkedIn' => ['type' => 'SEOSocialLinkedIn'], - 'mySpace' => ['type' => 'SEOSocialMySpace'], - 'pinterest' => ['type' => 'SEOSocialPinterest'], - 'youTube' => ['type' => 'SEOSocialYoutube'], - 'wikipedia' => ['type' => 'SEOSocialWikipedia'], - ], - ]); - - register_graphql_object_type('SEORedirect', [ - 'description' => __( - 'The Yoast redirect data (Yoast Premium only)', - 'wp-graphql-yoast-seo' - ), - 'fields' => [ - 'origin' => ['type' => 'String'], - 'target' => ['type' => 'String'], - 'type' => ['type' => 'Int'], - 'format' => ['type' => 'String'], - ], - ]); - - register_graphql_object_type('SEOOpenGraphFrontPage', [ - 'description' => __( - 'The Open Graph Front page data', - 'wp-graphql-yoast-seo' - ), - 'fields' => [ - 'title' => ['type' => 'String'], - 'description' => ['type' => 'String'], - 'image' => ['type' => 'MediaItem'], - ], - ]); - - register_graphql_object_type('SEOOpenGraph', [ - 'description' => __('The Open Graph data', 'wp-graphql-yoast-seo'), - 'fields' => [ - 'defaultImage' => ['type' => 'MediaItem'], - 'frontPage' => ['type' => 'SEOOpenGraphFrontPage'], - ], - ]); - - register_graphql_object_type('SEOContentTypeArchive', [ - 'description' => __( - 'he Yoast SEO search appearance content types fields', - 'wp-graphql-yoast-seo' - ), - 'fields' => [ - 'hasArchive' => ['type' => 'Boolean'], - 'title' => ['type' => 'String'], - 'archiveLink' => ['type' => 'String'], - 'metaDesc' => ['type' => 'String'], - 'metaRobotsNoindex' => ['type' => 'Boolean'], - 'breadcrumbTitle' => ['type' => 'String'], - 'fullHead' => ['type' => 'String'], - ], - ]); - register_graphql_object_type('SEOContentType', [ - 'description' => __( - 'he Yoast SEO search appearance content types fields', - 'wp-graphql-yoast-seo' - ), - 'fields' => [ - 'title' => ['type' => 'String'], - 'metaDesc' => ['type' => 'String'], - 'metaRobotsNoindex' => ['type' => 'Boolean'], - 'schemaType' => ['type' => 'String'], - 'schema' => ['type' => 'SEOPageInfoSchema'], - 'archive' => ['type' => 'SEOContentTypeArchive'], - ], - ]); - - $allTypes = wp_gql_seo_build_content_types($post_types); - - register_graphql_object_type('SEOContentTypes', [ - 'description' => __( - 'The Yoast SEO search appearance content types', - 'wp-graphql-yoast-seo' - ), - 'fields' => $allTypes, - ]); - - register_graphql_object_type('SEOConfig', [ - 'description' => __( - 'The Yoast SEO site level configuration data', - 'wp-graphql-yoast-seo' - ), - 'fields' => [ - 'schema' => ['type' => 'SEOSchema'], - 'webmaster' => ['type' => 'SEOWebmaster'], - 'social' => ['type' => 'SEOSocial'], - 'breadcrumbs' => ['type' => 'SEOBreadcrumbs'], - 'redirects' => [ - 'type' => [ - 'list_of' => 'SEORedirect', - ], - ], - 'openGraph' => ['type' => 'SEOOpenGraph'], - 'contentTypes' => ['type' => 'SEOContentTypes'], - ], - ]); - - register_graphql_object_type('SEOUserSocial', [ - 'fields' => [ - 'facebook' => ['type' => 'String'], - 'twitter' => ['type' => 'String'], - 'instagram' => ['type' => 'String'], - 'linkedIn' => ['type' => 'String'], - 'mySpace' => ['type' => 'String'], - 'pinterest' => ['type' => 'String'], - 'youTube' => ['type' => 'String'], - 'soundCloud' => ['type' => 'String'], - 'wikipedia' => ['type' => 'String'], - ], - ]); - - register_graphql_object_type('SEOUserSchema', [ - 'description' => __('The Schema types for User', 'wp-graphql-yoast-seo'), - 'fields' => [ - 'raw' => ['type' => 'String'], - 'pageType' => ['type' => ['list_of' => 'String']], - 'articleType' => ['type' => ['list_of' => 'String']], - ], - ]); - - register_graphql_object_type('SEOUser', [ - 'fields' => [ - 'title' => ['type' => 'String'], - 'metaDesc' => ['type' => 'String'], - 'metaRobotsNoindex' => ['type' => 'String'], - 'metaRobotsNofollow' => ['type' => 'String'], - 'canonical' => ['type' => 'String'], - 'opengraphTitle' => ['type' => 'String'], - 'opengraphDescription' => ['type' => 'String'], - 'opengraphImage' => ['type' => 'MediaItem'], - 'twitterImage' => ['type' => 'MediaItem'], - 'twitterTitle' => ['type' => 'String'], - 'twitterDescription' => ['type' => 'String'], - 'language' => ['type' => 'String'], - 'region' => ['type' => 'String'], - 'breadcrumbTitle' => ['type' => 'String'], - 'fullHead' => ['type' => 'String'], - 'social' => ['type' => 'SEOUserSocial'], - 'schema' => ['type' => 'SEOUserSchema'], - ], - ]); - - register_graphql_object_type('SEOPageInfoSchema', [ - 'description' => __('The Schema for post type', 'wp-graphql-yoast-seo'), - 'fields' => [ - 'raw' => ['type' => 'String'], - ], - ]); - register_graphql_object_type('SEOPostTypePageInfo', [ - 'description' => __('The page info SEO details', 'wp-graphql-yoast-seo'), - 'fields' => [ - 'schema' => ['type' => 'SEOPageInfoSchema'], - ], - ]); - - register_graphql_field('RootQuery', 'seo', [ - 'type' => 'SEOConfig', - 'description' => __('Returns seo site data', 'wp-graphql-yoast-seo'), - '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() : []; - - $userID = $all['company_or_person_user_id']; - $user = get_userdata($userID); - - $mappedRedirects = function ($value) { - return [ - 'origin' => $value['origin'], - 'target' => $value['url'], - 'type' => $value['type'], - 'format' => $value['format'], - ]; - }; - - $contentTypes = wp_gql_seo_build_content_type_data( - $post_types, - $all - ); - - return [ - 'contentTypes' => $contentTypes, - 'webmaster' => [ - 'baiduVerify' => wp_gql_seo_format_string( - $all['baiduverify'] - ), - 'googleVerify' => wp_gql_seo_format_string( - $all['googleverify'] - ), - 'msVerify' => wp_gql_seo_format_string($all['msverify']), - 'yandexVerify' => wp_gql_seo_format_string( - $all['yandexverify'] - ), - ], - 'social' => [ - 'facebook' => [ - 'url' => wp_gql_seo_format_string($all['facebook_site']), - 'defaultImage' => $context - ->get_loader('post') - ->load_deferred($all['og_default_image_id']), - ], - 'twitter' => [ - 'username' => wp_gql_seo_format_string( - $all['twitter_site'] - ), - 'cardType' => wp_gql_seo_format_string( - $all['twitter_card_type'] - ), - ], - 'instagram' => [ - 'url' => wp_gql_seo_format_string($all['instagram_url']), - ], - 'linkedIn' => [ - 'url' => wp_gql_seo_format_string($all['linkedin_url']), - ], - 'mySpace' => [ - 'url' => wp_gql_seo_format_string($all['myspace_url']), - ], - 'pinterest' => [ - 'url' => wp_gql_seo_format_string($all['pinterest_url']), - 'metaTag' => wp_gql_seo_format_string( - $all['pinterestverify'] - ), - ], - 'youTube' => [ - 'url' => wp_gql_seo_format_string($all['youtube_url']), - ], - 'wikipedia' => [ - 'url' => wp_gql_seo_format_string($all['wikipedia_url']), - ], - ], - 'breadcrumbs' => [ - 'enabled' => wp_gql_seo_format_string( - $all['breadcrumbs-enable'] - ), - 'boldLast' => wp_gql_seo_format_string( - $all['breadcrumbs-boldlast'] - ), - 'showBlogPage' => wp_gql_seo_format_string( - $all['breadcrumbs-display-blog-page'] - ), - 'archivePrefix' => wp_gql_seo_format_string( - $all['breadcrumbs-archiveprefix'] - ), - 'prefix' => wp_gql_seo_format_string( - $all['breadcrumbs-prefix'] - ), - 'notFoundText' => wp_gql_seo_format_string( - $all['breadcrumbs-404crumb'] - ), - 'homeText' => wp_gql_seo_format_string( - $all['breadcrumbs-home'] - ), - 'searchPrefix' => wp_gql_seo_format_string( - $all['breadcrumbs-searchprefix'] - ), - 'separator' => wp_gql_seo_format_string( - $all['breadcrumbs-sep'] - ), - ], - 'schema' => [ - 'companyName' => wp_gql_seo_format_string( - $all['company_name'] - ), - 'personName' => wp_gql_seo_format_string( - $user->user_nicename - ), - 'companyLogo' => $context - ->get_loader('post') - ->load_deferred(absint($all['company_logo_id'])), - 'personLogo' => $context - ->get_loader('post') - ->load_deferred(absint($all['person_logo_id'])), - 'logo' => $context - ->get_loader('post') - ->load_deferred( - $all['company_or_person'] === 'company' - ? absint($all['company_logo_id']) - : absint($all['person_logo_id']) - ), - 'companyOrPerson' => wp_gql_seo_format_string( - $all['company_or_person'] - ), - 'siteName' => wp_gql_seo_format_string( - YoastSEO()->helpers->site->get_site_name() - ), - 'wordpressSiteName' => wp_gql_seo_format_string( - get_bloginfo('name') - ), - 'siteUrl' => wp_gql_seo_format_string( - apply_filters('wp_gql_seo_site_url', get_site_url()) - ), - 'homeUrl' => wp_gql_seo_format_string( - apply_filters('wp_gql_seo_home_url', get_home_url()) - ), - 'inLanguage' => wp_gql_seo_format_string( - get_bloginfo('language') - ), - ], - 'redirects' => array_map($mappedRedirects, $redirects), - 'openGraph' => [ - 'defaultImage' => $context - ->get_loader('post') - ->load_deferred(absint($all['og_default_image_id'])), - 'frontPage' => [ - 'title' => wp_gql_seo_format_string( - $all['og_frontpage_title'] - ), - 'description' => wp_gql_seo_format_string( - $all['og_frontpage_desc'] - ), - 'image' => $context - ->get_loader('post') - ->load_deferred( - absint($all['og_frontpage_image_id']) - ), - ], - ], - ]; - }, - ]); - - // Post Type SEO Data - if (!empty($post_types) && is_array($post_types)) { - foreach ($post_types as $post_type) { - $post_type_object = get_post_type_object($post_type); - - if (isset($post_type_object->graphql_single_name)): - register_graphql_field( - $post_type_object->graphql_single_name, - 'seo', - [ - 'type' => 'PostTypeSEO', - 'description' => __( - 'The Yoast SEO data of the ' . - $post_type_object->graphql_single_name, - 'wp-graphql-yoast-seo' - ), - 'resolve' => function ( - $post, - array $args, - AppContext $context - ) { - // Base array - $seo = []; - - $map = [ - '@id' => 'id', - '@type' => 'type', - '@graph' => 'graph', - '@context' => 'context', - ]; - - $schemaArray = YoastSEO()->meta->for_post($post->ID) - ->schema; - - // https://developer.yoast.com/blog/yoast-seo-14-0-using-yoast-seo-surfaces/ - $robots = YoastSEO()->meta->for_post($post->ID) - ->robots; - - // Get data - $seo = [ - 'title' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID)->title - ), - 'metaDesc' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->description - ), - 'focuskw' => wp_gql_seo_format_string( - get_post_meta( - $post->ID, - '_yoast_wpseo_focuskw', - true - ) - ), - 'metaKeywords' => wp_gql_seo_format_string( - get_post_meta( - $post->ID, - '_yoast_wpseo_metakeywords', - true - ) - ), - 'metaRobotsNoindex' => $robots['index'], - 'metaRobotsNofollow' => $robots['follow'], - 'opengraphTitle' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->open_graph_title - ), - 'opengraphUrl' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->open_graph_url - ), - 'opengraphSiteName' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->open_graph_site_name - ), - 'opengraphType' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->open_graph_type - ), - 'opengraphAuthor' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->open_graph_article_author - ), - 'opengraphPublisher' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->open_graph_article_publisher - ), - 'opengraphPublishedTime' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->open_graph_article_published_time - ), - 'opengraphModifiedTime' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->open_graph_article_modified_time - ), - 'opengraphDescription' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->open_graph_description - ), - 'opengraphImage' => function () use ( - $post, - $context - ) { - $id = wp_gql_seo_get_og_image( - YoastSEO()->meta->for_post($post->ID) - ->open_graph_images - ); - - return $context - ->get_loader('post') - ->load_deferred(absint($id)); - }, - 'twitterCardType' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->twitter_card - ), - 'twitterTitle' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->twitter_title - ), - 'twitterDescription' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->twitter_description - ), - 'twitterImage' => function () use ( - $post, - $context - ) { - $id = wpcom_vip_attachment_url_to_postid( - YoastSEO()->meta->for_post($post->ID) - ->twitter_image - ); - - return $context - ->get_loader('post') - ->load_deferred(absint($id)); - }, - 'canonical' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->canonical - ), - 'readingTime' => floatval( - YoastSEO()->meta->for_post($post->ID) - ->estimated_reading_time_minutes - ), - 'breadcrumbs' => YoastSEO()->meta->for_post( - $post->ID - )->breadcrumbs, - 'cornerstone' => boolval( - YoastSEO()->meta->for_post($post->ID) - ->indexable->is_cornerstone - ), - 'fullHead' => is_string( - YoastSEO() - ->meta->for_post($post->ID) - ->get_head() - ) - ? YoastSEO() - ->meta->for_post($post->ID) - ->get_head() - : YoastSEO() - ->meta->for_post($post->ID) - ->get_head()->html, - 'schema' => [ - 'pageType' => is_array( - YoastSEO()->meta->for_post($post->ID) - ->schema_page_type - ) - ? YoastSEO()->meta->for_post($post->ID) - ->schema_page_type - : [], - 'articleType' => is_array( - YoastSEO()->meta->for_post($post->ID) - ->schema_article_type - ) - ? YoastSEO()->meta->for_post($post->ID) - ->schema_article_type - : [], - 'raw' => json_encode( - $schemaArray, - JSON_UNESCAPED_SLASHES - ), - ], - ]; - - return !empty($seo) ? $seo : null; - }, - ] - ); - - // register field on edge for arch - - $name = - 'WP' . - ucfirst($post_type_object->graphql_single_name) . - 'Info'; - - register_graphql_field($name, 'seo', [ - 'type' => 'SEOPostTypePageInfo', - 'description' => __( - 'Raw schema for ' . - $post_type_object->graphql_single_name, - 'wp-graphql-yoast-seo' - ), - 'resolve' => function ( - $item, - array $args, - AppContext $context - ) use ($post_type) { - $schemaArray = YoastSEO()->meta->for_post_type_archive( - $post_type - )->schema; - - return [ - 'schema' => [ - 'raw' => json_encode( - $schemaArray, - JSON_UNESCAPED_SLASHES - ), - ], - ]; - }, - ]); - - // Loop each taxonomy to register on the edge if a category is the primary one. - $taxonomiesPostObj = get_object_taxonomies( - $post_type, - 'objects' - ); - - $postNameKey = wp_gql_seo_get_field_key( - $post_type_object->graphql_single_name - ); - - foreach ($taxonomiesPostObj as $tax) { - if ( - isset($tax->hierarchical) && - isset($tax->graphql_single_name) - ) { - $name = - ucfirst($postNameKey) . - 'To' . - ucfirst($tax->graphql_single_name) . - 'ConnectionEdge'; - - register_graphql_field($name, 'isPrimary', [ - 'type' => 'Boolean', - 'description' => __( - 'The Yoast SEO Primary ' . $tax->name, - 'wp-graphql-yoast-seo' - ), - 'resolve' => function ( - $item, - array $args, - AppContext $context - ) use ($tax) { - $postId = $item['source']->ID; - - $wpseo_primary_term = new WPSEO_Primary_Term( - $tax->name, - $postId - ); - $primaryTaxId = $wpseo_primary_term->get_primary_term(); - $termId = $item['node']->term_id; - - return $primaryTaxId === $termId; - }, - ]); - } - } - endif; - } - } - // User SEO Data - register_graphql_field('User', 'seo', [ - 'type' => 'SEOUser', - 'description' => __( - 'The Yoast SEO data of a user', - 'wp-graphql-yoast-seo' - ), - 'resolve' => function ($user, array $args, AppContext $context) { - $robots = YoastSEO()->meta->for_author($user->userId)->robots; - - $schemaArray = YoastSEO()->meta->for_author($user->userId)->schema; - - $userSeo = [ - 'title' => wp_gql_seo_format_string( - YoastSEO()->meta->for_author($user->userId)->title - ), - 'metaDesc' => wp_gql_seo_format_string( - YoastSEO()->meta->for_author($user->userId)->description - ), - 'metaRobotsNoindex' => $robots['index'], - 'metaRobotsNofollow' => $robots['follow'], - 'canonical' => YoastSEO()->meta->for_author($user->userId) - ->canonical, - 'opengraphTitle' => YoastSEO()->meta->for_author($user->userId) - ->open_graph_title, - 'opengraphDescription' => YoastSEO()->meta->for_author( - $user->userId - )->open_graph_description, - 'opengraphImage' => $context - ->get_loader('post') - ->load_deferred( - absint( - YoastSEO()->meta->for_author($user->userId) - ->open_graph_image_id - ) - ), - 'twitterImage' => $context - ->get_loader('post') - ->load_deferred( - absint( - YoastSEO()->meta->for_author($user->userId) - ->twitter_image_id - ) - ), - 'twitterTitle' => YoastSEO()->meta->for_author($user->userId) - ->twitter_title, - 'twitterDescription' => YoastSEO()->meta->for_author( - $user->userId - )->twitter_description, - 'language' => YoastSEO()->meta->for_author($user->userId) - ->language, - 'region' => YoastSEO()->meta->for_author($user->userId)->region, - 'breadcrumbTitle' => YoastSEO()->meta->for_author($user->userId) - ->breadcrumb_title, - 'fullHead' => is_string( - YoastSEO() - ->meta->for_author($user->userId) - ->get_head() - ) - ? YoastSEO() - ->meta->for_author($user->userId) - ->get_head() - : YoastSEO() - ->meta->for_author($user->userId) - ->get_head()->html, - 'social' => [ - 'facebook' => wp_gql_seo_format_string( - get_the_author_meta('facebook', $user->userId) - ), - 'twitter' => wp_gql_seo_format_string( - get_the_author_meta('twitter', $user->userId) - ), - 'instagram' => wp_gql_seo_format_string( - get_the_author_meta('instagram', $user->userId) - ), - 'linkedIn' => wp_gql_seo_format_string( - get_the_author_meta('linkedin', $user->userId) - ), - 'mySpace' => wp_gql_seo_format_string( - get_the_author_meta('myspace', $user->userId) - ), - 'pinterest' => wp_gql_seo_format_string( - get_the_author_meta('pinterest', $user->userId) - ), - 'youTube' => wp_gql_seo_format_string( - get_the_author_meta('youtube', $user->userId) - ), - 'soundCloud' => wp_gql_seo_format_string( - get_the_author_meta('soundcloud', $user->userId) - ), - 'wikipedia' => wp_gql_seo_format_string( - get_the_author_meta('wikipedia', $user->userId) - ), - ], - - 'schema' => [ - 'raw' => json_encode($schemaArray, JSON_UNESCAPED_SLASHES), - 'pageType' => is_array( - YoastSEO()->meta->for_author($user->userId) - ->schema_page_type - ) - ? YoastSEO()->meta->for_author($user->userId) - ->schema_page_type - : [], - 'articleType' => is_array( - YoastSEO()->meta->for_author($user->userId) - ->schema_article_type - ) - ? YoastSEO()->meta->for_author($user->userId) - ->schema_article_type - : [], - ], - ]; - - return !empty($userSeo) ? $userSeo : []; - }, - ]); - - // Taxonomy SEO Data - if (!empty($taxonomies) && is_array($taxonomies)) { - foreach ($taxonomies as $tax) { - $taxonomy = get_taxonomy($tax); - - if (empty($taxonomy) || !isset($taxonomy->graphql_single_name)) { - return; - } - - register_graphql_field($taxonomy->graphql_single_name, 'seo', [ - 'type' => 'TaxonomySEO', - 'description' => __( - 'The Yoast SEO data of the ' . - $taxonomy->label . - ' taxonomy.', - 'wp-graphql-yoast-seo' - ), - 'resolve' => function ($term, array $args, AppContext $context) { - $term_obj = get_term($term->term_id); +/** + * Define plugin constants. + */ +function wp_gql_seo_constants() : void { + // Plugin version. + if ( ! defined( 'WPGRAPHQL_SEO_VERSION' ) ) { + define( 'WPGRAPHQL_SEO_VERSION', '0.0.1' ); + } + + // Plugin Folder Path. + if ( ! defined( 'WPGRAPHQL_SEO_PLUGIN_DIR' ) ) { + define( 'WPGRAPHQL_SEO_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); + } + + // Plugin Folder URL. + if ( ! defined( 'WPGRAPHQL_SEO_PLUGIN_URL' ) ) { + define( 'WPGRAPHQL_SEO_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); + } + + // Plugin Root File. + if ( ! defined( 'WPGRAPHQL_SEO_PLUGIN_FILE' ) ) { + define( 'WPGRAPHQL_SEO_PLUGIN_FILE', __FILE__ ); + } + + // Whether to autoload the files or not. + if ( ! defined( 'WPGRAPHQL_SEO_AUTOLOAD' ) ) { + define( 'WPGRAPHQL_SEO_AUTOLOAD', true ); + } +} - $meta = WPSEO_Taxonomy_Meta::get_term_meta( - (int) $term_obj->term_id, - $term_obj->taxonomy - ); - $robots = YoastSEO()->meta->for_term($term->term_id)->robots; +/** + * Checks if all the the required plugins are installed and activated. + */ +function wp_gql_seo_dependencies_not_ready() : array { + $deps = []; + if ( ! class_exists( 'WPGraphQL' ) ) { + $deps[] = 'WPGraphQL'; + } - $schemaArray = YoastSEO()->meta->for_term($term->term_id) - ->schema; + if ( ! function_exists( 'YoastSEO' ) ) { + $deps[] = 'Yoast SEO'; + } - // Get data - $seo = [ - 'title' => wp_gql_seo_format_string( - html_entity_decode( - wp_strip_all_tags( - YoastSEO()->meta->for_term($term->term_id) - ->title - ) - ) - ), - 'metaDesc' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->description - ), - 'focuskw' => isset($meta['wpseo_focuskw']) - ? wp_gql_seo_format_string($meta['wpseo_focuskw']) - : $meta['wpseo_focuskw'], - 'metaKeywords' => isset($meta['wpseo_metakeywords']) - ? wp_gql_seo_format_string( - $meta['wpseo_metakeywords'] - ) - : null, - 'metaRobotsNoindex' => $robots['index'], - 'metaRobotsNofollow' => $robots['follow'], - 'opengraphTitle' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->open_graph_title - ), - 'opengraphUrl' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->open_graph_url - ), - 'opengraphSiteName' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->open_graph_site_name - ), - 'opengraphType' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->open_graph_type - ), - 'opengraphAuthor' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->open_graph_article_author - ), - 'opengraphPublisher' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->open_graph_article_publisher - ), - 'opengraphPublishedTime' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->open_graph_article_published_time - ), - 'opengraphModifiedTime' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->open_graph_article_modified_time - ), - 'opengraphDescription' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->open_graph_description - ), - 'opengraphImage' => $context - ->get_loader('post') - ->load_deferred( - absint($meta['wpseo_opengraph-image-id']) - ), - 'twitterCardType' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->twitter_card - ), - 'twitterTitle' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->twitter_title - ), - 'twitterDescription' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->twitter_description - ), - 'twitterImage' => $context - ->get_loader('post') - ->load_deferred( - absint($meta['wpseo_twitter-image-id']) - ), - 'canonical' => isset( - YoastSEO()->meta->for_term($term->term_id)->canonical - ) - ? wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->canonical - ) - : null, - 'breadcrumbs' => YoastSEO()->meta->for_term( - $term->term_id - )->breadcrumbs, - 'cornerstone' => boolval( - YoastSEO()->meta->for_term($term->term_id) - ->is_cornerstone - ), - 'fullHead' => is_string( - YoastSEO() - ->meta->for_term($term->term_id) - ->get_head() - ) - ? YoastSEO() - ->meta->for_term($term->term_id) - ->get_head() - : YoastSEO() - ->meta->for_term($term->term_id) - ->get_head()->html, - 'schema' => [ - 'raw' => json_encode( - $schemaArray, - JSON_UNESCAPED_SLASHES - ), - ], - ]; - wp_reset_query(); + return $deps; +} - return !empty($seo) ? $seo : null; - }, - ]); - } - } - }); -}); +/** + * Initializes WPGraphQL SEO + * + * @return \WPGraphQL\YoastSEO\Seo|false + */ +function wp_gql_seo_init() { + wp_gql_seo_constants(); + + $not_ready = wp_gql_seo_dependencies_not_ready(); + + if ( empty( $not_ready ) && defined( 'WPGRAPHQL_SEO_PLUGIN_DIR' ) ) { + require_once WPGRAPHQL_SEO_PLUGIN_DIR . 'src/Seo.php'; + return \WPGraphQL\YoastSEO\Seo::instance(); + } + + foreach ( $not_ready as $dep ) { + $display_admin_notice = static function() use( $dep ) { + ?> +
=5.3", - "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" - }, - "conflict": { - "squizlabs/php_codesniffer": "2.6.2" + "php": ">=5.5" }, "require-dev": { - "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" + "symfony/phpunit-bridge": "^4.4 || ^5.1" }, - "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", - "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.5-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] }, - "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", "license": [ - "LGPL-3.0-or-later" + "MIT" ], "authors": [ { - "name": "Wim Godden", - "homepage": "https://github.com/wimg", - "role": "lead" + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" }, { - "name": "Juliette Reinders Folmer", - "homepage": "https://github.com/jrfnl", - "role": "lead" + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" }, { - "name": "Contributors", - "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" } ], - "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", - "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", + "description": "Guzzle promises library", "keywords": [ - "compatibility", - "phpcs", - "standards" + "promise" ], "support": { - "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", - "source": "https://github.com/PHPCompatibility/PHPCompatibility" + "issues": "https://github.com/guzzle/promises/issues", + "source": "https://github.com/guzzle/promises/tree/1.5.1" }, - "time": "2019-12-27T09:44:58+00:00" + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", + "type": "tidelift" + } + ], + "time": "2021-10-22T20:56:57+00:00" }, { - "name": "phpcompatibility/phpcompatibility-paragonie", - "version": "1.3.1", + "name": "guzzlehttp/psr7", + "version": "2.1.0", "source": { "type": "git", - "url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git", - "reference": "ddabec839cc003651f2ce695c938686d1086cf43" + "url": "https://github.com/guzzle/psr7.git", + "reference": "089edd38f5b8abba6cb01567c2a8aaa47cec4c72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/ddabec839cc003651f2ce695c938686d1086cf43", - "reference": "ddabec839cc003651f2ce695c938686d1086cf43", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/089edd38f5b8abba6cb01567c2a8aaa47cec4c72", + "reference": "089edd38f5b8abba6cb01567c2a8aaa47cec4c72", "shasum": "" }, "require": { - "phpcompatibility/php-compatibility": "^9.0" + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0", + "ralouphie/getallheaders": "^3.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7", - "paragonie/random_compat": "dev-master", - "paragonie/sodium_compat": "dev-master" + "bamarni/composer-bin-plugin": "^1.4.1", + "http-interop/http-factory-tests": "^0.9", + "phpunit/phpunit": "^8.5.8 || ^9.3.10" }, "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", - "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } }, - "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", "license": [ - "LGPL-3.0-or-later" + "MIT" ], "authors": [ { - "name": "Wim Godden", - "role": "lead" + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" }, { - "name": "Juliette Reinders Folmer", - "role": "lead" + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" } ], - "description": "A set of rulesets for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by the Paragonie polyfill libraries.", - "homepage": "http://phpcompatibility.com/", + "description": "PSR-7 message implementation that also provides common utility methods", "keywords": [ - "compatibility", - "paragonie", - "phpcs", - "polyfill", - "standards" + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" ], "support": { - "issues": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/issues", - "source": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie" + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/2.1.0" }, - "time": "2021-02-15T10:24:51+00:00" + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", + "type": "tidelift" + } + ], + "time": "2021-10-06T17:43:30+00:00" }, { - "name": "phpcompatibility/phpcompatibility-wp", - "version": "2.1.3", + "name": "j4mie/idiorm", + "version": "v1.5.7", "source": { "type": "git", - "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git", - "reference": "d55de55f88697b9cdb94bccf04f14eb3b11cf308" + "url": "https://github.com/j4mie/idiorm.git", + "reference": "d23f97053ef5d0b988a02c6a71eb5c6118b2f5b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/d55de55f88697b9cdb94bccf04f14eb3b11cf308", - "reference": "d55de55f88697b9cdb94bccf04f14eb3b11cf308", + "url": "https://api.github.com/repos/j4mie/idiorm/zipball/d23f97053ef5d0b988a02c6a71eb5c6118b2f5b4", + "reference": "d23f97053ef5d0b988a02c6a71eb5c6118b2f5b4", "shasum": "" }, "require": { - "phpcompatibility/php-compatibility": "^9.0", - "phpcompatibility/phpcompatibility-paragonie": "^1.0" + "php": ">=5.2.0" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7" + "ext-pdo_sqlite": "*", + "phpunit/phpunit": "^4.8" }, - "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", - "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + "type": "library", + "autoload": { + "classmap": [ + "idiorm.php" + ] }, - "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", "license": [ - "LGPL-3.0-or-later" + "BSD-2-Clause", + "BSD-3-Clause", + "BSD-4-Clause" ], "authors": [ { - "name": "Wim Godden", - "role": "lead" + "name": "Jamie Matthews", + "email": "jamie.matthews@gmail.com", + "homepage": "http://j4mie.org", + "role": "Developer" }, { - "name": "Juliette Reinders Folmer", - "role": "lead" + "name": "Simon Holywell", + "email": "treffynnon@php.net", + "homepage": "http://simonholywell.com", + "role": "Maintainer" + }, + { + "name": "Durham Hale", + "email": "me@durhamhale.com", + "homepage": "http://durhamhale.com", + "role": "Maintainer" } ], - "description": "A ruleset for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by WordPress.", - "homepage": "http://phpcompatibility.com/", + "description": "A lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5", + "homepage": "http://j4mie.github.com/idiormandparis", "keywords": [ - "compatibility", - "phpcs", - "standards", - "wordpress" + "idiorm", + "orm", + "query builder" ], "support": { - "issues": "https://github.com/PHPCompatibility/PHPCompatibilityWP/issues", - "source": "https://github.com/PHPCompatibility/PHPCompatibilityWP" + "issues": "https://github.com/j4mie/idiorm/issues", + "source": "https://github.com/j4mie/idiorm" }, - "time": "2021-12-30T16:37:40+00:00" + "time": "2020-04-29T00:37:09+00:00" }, { - "name": "phpstan/extension-installer", - "version": "1.1.0", + "name": "league/oauth2-client", + "version": "2.6.1", "source": { "type": "git", - "url": "https://github.com/phpstan/extension-installer.git", - "reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051" + "url": "https://github.com/thephpleague/oauth2-client.git", + "reference": "2334c249907190c132364f5dae0287ab8666aa19" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/66c7adc9dfa38b6b5838a9fb728b68a7d8348051", - "reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051", + "url": "https://api.github.com/repos/thephpleague/oauth2-client/zipball/2334c249907190c132364f5dae0287ab8666aa19", + "reference": "2334c249907190c132364f5dae0287ab8666aa19", "shasum": "" }, "require": { - "composer-plugin-api": "^1.1 || ^2.0", - "php": "^7.1 || ^8.0", - "phpstan/phpstan": ">=0.11.6" + "guzzlehttp/guzzle": "^6.0 || ^7.0", + "paragonie/random_compat": "^1 || ^2 || ^9.99", + "php": "^5.6 || ^7.0 || ^8.0" }, "require-dev": { - "composer/composer": "^1.8", - "phing/phing": "^2.16.3", - "php-parallel-lint/php-parallel-lint": "^1.2.0", - "phpstan/phpstan-strict-rules": "^0.11 || ^0.12" + "mockery/mockery": "^1.3.5", + "php-parallel-lint/php-parallel-lint": "^1.3.1", + "phpunit/phpunit": "^5.7 || ^6.0 || ^9.5", + "squizlabs/php_codesniffer": "^2.3 || ^3.0" }, - "type": "composer-plugin", + "type": "library", "extra": { - "class": "PHPStan\\ExtensionInstaller\\Plugin" + "branch-alias": { + "dev-2.x": "2.0.x-dev" + } }, "autoload": { "psr-4": { - "PHPStan\\ExtensionInstaller\\": "src/" + "League\\OAuth2\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alex Bilbie", + "email": "hello@alexbilbie.com", + "homepage": "http://www.alexbilbie.com", + "role": "Developer" + }, + { + "name": "Woody Gilk", + "homepage": "https://github.com/shadowhand", + "role": "Contributor" + } + ], + "description": "OAuth 2.0 Client Library", + "keywords": [ + "Authentication", + "SSO", + "authorization", + "identity", + "idp", + "oauth", + "oauth2", + "single sign on" + ], + "support": { + "issues": "https://github.com/thephpleague/oauth2-client/issues", + "source": "https://github.com/thephpleague/oauth2-client/tree/2.6.1" + }, + "time": "2021-12-22T16:42:49+00:00" + }, + { + "name": "paragonie/random_compat", + "version": "v9.99.100", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a", + "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a", + "shasum": "" + }, + "require": { + "php": ">= 7" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*", + "vimeo/psalm": "^1" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "polyfill", + "pseudorandom", + "random" + ], + "support": { + "email": "info@paragonie.com", + "issues": "https://github.com/paragonie/random_compat/issues", + "source": "https://github.com/paragonie/random_compat" + }, + "time": "2020-10-15T08:29:30+00:00" + }, + { + "name": "php-stubs/wordpress-seo-stubs", + "version": "v17.2", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/wordpress-seo-stubs.git", + "reference": "f4b272159d3091f07596e63f14525f8da0919caf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/wordpress-seo-stubs/zipball/f4b272159d3091f07596e63f14525f8da0919caf", + "reference": "f4b272159d3091f07596e63f14525f8da0919caf", + "shasum": "" + }, + "require": { + "j4mie/idiorm": "^1.5", + "league/oauth2-client": "^2.4", + "php-stubs/wordpress-stubs": "^5.3.0", + "psr/log": "^1.0", + "symfony/config": "^3.4", + "symfony/dependency-injection": "^3.4" + }, + "require-dev": { + "giacocorsiglia/stubs-generator": "^0.5.0", + "php": "~7.1" + }, + "suggest": { + "symfony/polyfill-php73": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Yoas SEO function and class declaration stubs for static analysis.", + "homepage": "https://github.com/php-stubs/wordpress-seo-stubs", + "keywords": [ + "PHPStan", + "seo", + "static analysis", + "wordpress", + "yoast" + ], + "support": { + "issues": "https://github.com/php-stubs/wordpress-seo-stubs/issues", + "source": "https://github.com/php-stubs/wordpress-seo-stubs/tree/v17.2" + }, + "time": "2021-09-22T12:05:07+00:00" + }, + { + "name": "php-stubs/wordpress-stubs", + "version": "v5.9.0", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/wordpress-stubs.git", + "reference": "0fa8dd9a1bd2a1b60e85afc6c798fca1f599cc1b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/0fa8dd9a1bd2a1b60e85afc6c798fca1f599cc1b", + "reference": "0fa8dd9a1bd2a1b60e85afc6c798fca1f599cc1b", + "shasum": "" + }, + "replace": { + "giacocorsiglia/wordpress-stubs": "*" + }, + "require-dev": { + "nikic/php-parser": "< 4.12.0", + "php": "~7.3 || ~8.0", + "php-stubs/generator": "^0.8.0", + "phpdocumentor/reflection-docblock": "^5.3", + "phpstan/phpstan": "^1.2" + }, + "suggest": { + "paragonie/sodium_compat": "Pure PHP implementation of libsodium", + "symfony/polyfill-php73": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "WordPress function and class declaration stubs for static analysis.", + "homepage": "https://github.com/php-stubs/wordpress-stubs", + "keywords": [ + "PHPStan", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/php-stubs/wordpress-stubs/issues", + "source": "https://github.com/php-stubs/wordpress-stubs/tree/v5.9.0" + }, + "time": "2022-01-26T00:27:45+00:00" + }, + { + "name": "phpcompatibility/php-compatibility", + "version": "9.3.5", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" + }, + "conflict": { + "squizlabs/php_codesniffer": "2.6.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "homepage": "https://github.com/wimg", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" + } + ], + "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", + "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", + "keywords": [ + "compatibility", + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibility" + }, + "time": "2019-12-27T09:44:58+00:00" + }, + { + "name": "phpcompatibility/phpcompatibility-paragonie", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git", + "reference": "ddabec839cc003651f2ce695c938686d1086cf43" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/ddabec839cc003651f2ce695c938686d1086cf43", + "reference": "ddabec839cc003651f2ce695c938686d1086cf43", + "shasum": "" + }, + "require": { + "phpcompatibility/php-compatibility": "^9.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7", + "paragonie/random_compat": "dev-master", + "paragonie/sodium_compat": "dev-master" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "lead" + } + ], + "description": "A set of rulesets for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by the Paragonie polyfill libraries.", + "homepage": "http://phpcompatibility.com/", + "keywords": [ + "compatibility", + "paragonie", + "phpcs", + "polyfill", + "standards" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie" + }, + "time": "2021-02-15T10:24:51+00:00" + }, + { + "name": "phpcompatibility/phpcompatibility-wp", + "version": "2.1.3", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git", + "reference": "d55de55f88697b9cdb94bccf04f14eb3b11cf308" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/d55de55f88697b9cdb94bccf04f14eb3b11cf308", + "reference": "d55de55f88697b9cdb94bccf04f14eb3b11cf308", + "shasum": "" + }, + "require": { + "phpcompatibility/php-compatibility": "^9.0", + "phpcompatibility/phpcompatibility-paragonie": "^1.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "lead" + } + ], + "description": "A ruleset for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by WordPress.", + "homepage": "http://phpcompatibility.com/", + "keywords": [ + "compatibility", + "phpcs", + "standards", + "wordpress" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibilityWP/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibilityWP" + }, + "time": "2021-12-30T16:37:40+00:00" + }, + { + "name": "phpstan/extension-installer", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/66c7adc9dfa38b6b5838a9fb728b68a7d8348051", + "reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.1 || ^2.0", + "php": "^7.1 || ^8.0", + "phpstan/phpstan": ">=0.11.6" + }, + "require-dev": { + "composer/composer": "^1.8", + "phing/phing": "^2.16.3", + "php-parallel-lint/php-parallel-lint": "^1.2.0", + "phpstan/phpstan-strict-rules": "^0.11 || ^0.12" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPStan\\ExtensionInstaller\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPStan\\ExtensionInstaller\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Composer plugin for automatic installation of PHPStan extensions", + "support": { + "issues": "https://github.com/phpstan/extension-installer/issues", + "source": "https://github.com/phpstan/extension-installer/tree/1.1.0" + }, + "time": "2020-12-13T13:06:13+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "1.4.6", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "8a7761f1c520e0dad6e04d862fdc697445457cfe" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/8a7761f1c520e0dad6e04d862fdc697445457cfe", + "reference": "8a7761f1c520e0dad6e04d862fdc697445457cfe", + "shasum": "" + }, + "require": { + "php": "^7.1|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/1.4.6" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpstan", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2022-02-06T12:56:13+00:00" + }, + { + "name": "poolshark/wp-graphql-stubs", + "version": "v0.0.2", + "source": { + "type": "git", + "url": "https://github.com/Poolshark/wp-graphql-stubs.git", + "reference": "66ba54188d04788849abd07bfc9fff511839cdb3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Poolshark/wp-graphql-stubs/zipball/66ba54188d04788849abd07bfc9fff511839cdb3", + "reference": "66ba54188d04788849abd07bfc9fff511839cdb3", + "shasum": "" + }, + "require-dev": { + "php": "^7.4" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Flo Ragossnig", + "email": "florian@webleaders.at" + } + ], + "description": "WP GraphQL Stubs for VS Code and others.", + "support": { + "issues": "https://github.com/Poolshark/wp-graphql-stubs/issues", + "source": "https://github.com/Poolshark/wp-graphql-stubs/tree/v0.0.2" + }, + "time": "2021-03-20T07:43:55+00:00" + }, + { + "name": "psr/container", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/1.1.2" + }, + "time": "2021-11-05T16:50:12+00:00" + }, + { + "name": "psr/http-client", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", + "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "support": { + "source": "https://github.com/php-fig/http-client/tree/master" + }, + "time": "2020-06-29T06:28:15+00:00" + }, + { + "name": "psr/http-factory", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be", + "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be", + "shasum": "" + }, + "require": { + "php": ">=7.0.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory/tree/master" + }, + "time": "2019-04-30T12:38:16+00:00" + }, + { + "name": "psr/http-message", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/master" + }, + "time": "2016-08-06T14:39:51+00:00" + }, + { + "name": "psr/log", + "version": "1.1.4", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/1.1.4" + }, + "time": "2021-05-03T11:20:27+00:00" + }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, + "time": "2019-03-08T08:55:37+00:00" + }, + { + "name": "sirbrillig/phpcs-variable-analysis", + "version": "v2.11.2", + "source": { + "type": "git", + "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git", + "reference": "3fad28475bfbdbf8aa5c440f8a8f89824983d85e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/3fad28475bfbdbf8aa5c440f8a8f89824983d85e", + "reference": "3fad28475bfbdbf8aa5c440f8a8f89824983d85e", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "squizlabs/php_codesniffer": "^3.5" + }, + "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" + }, + "type": "phpcodesniffer-standard", + "autoload": { + "psr-4": { + "VariableAnalysis\\": "VariableAnalysis/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Sam Graham", + "email": "php-codesniffer-variableanalysis@illusori.co.uk" + }, + { + "name": "Payton Swick", + "email": "payton@foolord.com" + } + ], + "description": "A PHPCS sniff to detect problems with variables.", + "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" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.6.2", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5e4e71592f69da17871dba6e80dd51bce74a351a", + "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", + "source": "https://github.com/squizlabs/PHP_CodeSniffer", + "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + }, + "time": "2021-12-12T21:44:58+00:00" + }, + { + "name": "symfony/config", + "version": "v3.4.47", + "source": { + "type": "git", + "url": "https://github.com/symfony/config.git", + "reference": "bc6b3fd3930d4b53a60b42fe2ed6fc466b75f03f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/config/zipball/bc6b3fd3930d4b53a60b42fe2ed6fc466b75f03f", + "reference": "bc6b3fd3930d4b53a60b42fe2ed6fc466b75f03f", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/filesystem": "~2.8|~3.0|~4.0", + "symfony/polyfill-ctype": "~1.8" + }, + "conflict": { + "symfony/dependency-injection": "<3.3", + "symfony/finder": "<3.3" + }, + "require-dev": { + "symfony/dependency-injection": "~3.3|~4.0", + "symfony/event-dispatcher": "~3.3|~4.0", + "symfony/finder": "~3.3|~4.0", + "symfony/yaml": "~3.0|~4.0" + }, + "suggest": { + "symfony/yaml": "To use the yaml reference dumper" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Config\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Config Component", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/config/tree/v3.4.47" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-10-24T10:57:07+00:00" + }, + { + "name": "symfony/dependency-injection", + "version": "v3.4.47", + "source": { + "type": "git", + "url": "https://github.com/symfony/dependency-injection.git", + "reference": "51d2a2708c6ceadad84393f8581df1dcf9e5e84b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/51d2a2708c6ceadad84393f8581df1dcf9e5e84b", + "reference": "51d2a2708c6ceadad84393f8581df1dcf9e5e84b", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "psr/container": "^1.0" + }, + "conflict": { + "symfony/config": "<3.3.7", + "symfony/finder": "<3.3", + "symfony/proxy-manager-bridge": "<3.4", + "symfony/yaml": "<3.4" + }, + "provide": { + "psr/container-implementation": "1.0" + }, + "require-dev": { + "symfony/config": "~3.3|~4.0", + "symfony/expression-language": "~2.8|~3.0|~4.0", + "symfony/yaml": "~3.4|~4.0" + }, + "suggest": { + "symfony/config": "", + "symfony/expression-language": "For using expressions in service container configuration", + "symfony/finder": "For using double-star glob patterns or when GLOB_BRACE portability is required", + "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", + "symfony/yaml": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\DependencyInjection\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony DependencyInjection Component", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/dependency-injection/tree/v3.4.47" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" ], - "description": "Composer plugin for automatic installation of PHPStan extensions", - "support": { - "issues": "https://github.com/phpstan/extension-installer/issues", - "source": "https://github.com/phpstan/extension-installer/tree/1.1.0" - }, - "time": "2020-12-13T13:06:13+00:00" + "time": "2020-10-24T10:57:07+00:00" }, { - "name": "phpstan/phpstan", - "version": "1.4.6", + "name": "symfony/deprecation-contracts", + "version": "v3.0.0", "source": { "type": "git", - "url": "https://github.com/phpstan/phpstan.git", - "reference": "8a7761f1c520e0dad6e04d862fdc697445457cfe" + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "c726b64c1ccfe2896cb7df2e1331c357ad1c8ced" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/8a7761f1c520e0dad6e04d862fdc697445457cfe", - "reference": "8a7761f1c520e0dad6e04d862fdc697445457cfe", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/c726b64c1ccfe2896cb7df2e1331c357ad1c8ced", + "reference": "c726b64c1ccfe2896cb7df2e1331c357ad1c8ced", "shasum": "" }, "require": { - "php": "^7.1|^8.0" + "php": ">=8.0.2" }, - "conflict": { - "phpstan/phpstan-shim": "*" - }, - "bin": [ - "phpstan", - "phpstan.phar" - ], "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-main": "3.0-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" } }, "autoload": { "files": [ - "bootstrap.php" + "function.php" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "description": "PHPStan - PHP Static Analysis Tool", + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", "support": { - "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.4.6" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.0.0" }, "funding": [ { - "url": "https://github.com/ondrejmirtes", - "type": "github" + "url": "https://symfony.com/sponsor", + "type": "custom" }, { - "url": "https://github.com/phpstan", + "url": "https://github.com/fabpot", "type": "github" }, { - "url": "https://www.patreon.com/phpstan", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2022-02-06T12:56:13+00:00" + "time": "2021-11-01T23:48:49+00:00" }, { - "name": "poolshark/wp-graphql-stubs", - "version": "v0.0.2", + "name": "symfony/filesystem", + "version": "v4.4.37", "source": { "type": "git", - "url": "https://github.com/Poolshark/wp-graphql-stubs.git", - "reference": "66ba54188d04788849abd07bfc9fff511839cdb3" + "url": "https://github.com/symfony/filesystem.git", + "reference": "c59f37705c3e513ae55b2735f128f4ce363c82ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Poolshark/wp-graphql-stubs/zipball/66ba54188d04788849abd07bfc9fff511839cdb3", - "reference": "66ba54188d04788849abd07bfc9fff511839cdb3", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/c59f37705c3e513ae55b2735f128f4ce363c82ec", + "reference": "c59f37705c3e513ae55b2735f128f4ce363c82ec", "shasum": "" }, - "require-dev": { - "php": "^7.4" + "require": { + "php": ">=7.1.3", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-php80": "^1.16" }, "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { - "name": "Flo Ragossnig", - "email": "florian@webleaders.at" + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "WP GraphQL Stubs for VS Code and others.", + "description": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", "support": { - "issues": "https://github.com/Poolshark/wp-graphql-stubs/issues", - "source": "https://github.com/Poolshark/wp-graphql-stubs/tree/v0.0.2" + "source": "https://github.com/symfony/filesystem/tree/v4.4.37" }, - "time": "2021-03-20T07:43:55+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-01-02T09:41:36+00:00" }, { - "name": "sirbrillig/phpcs-variable-analysis", - "version": "v2.11.2", + "name": "symfony/polyfill-ctype", + "version": "v1.24.0", "source": { "type": "git", - "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git", - "reference": "3fad28475bfbdbf8aa5c440f8a8f89824983d85e" + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "30885182c981ab175d4d034db0f6f469898070ab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/3fad28475bfbdbf8aa5c440f8a8f89824983d85e", - "reference": "3fad28475bfbdbf8aa5c440f8a8f89824983d85e", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/30885182c981ab175d4d034db0f6f469898070ab", + "reference": "30885182c981ab175d4d034db0f6f469898070ab", "shasum": "" }, "require": { - "php": ">=5.4.0", - "squizlabs/php_codesniffer": "^3.5" + "php": ">=7.1" }, - "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" + "provide": { + "ext-ctype": "*" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } }, - "type": "phpcodesniffer-standard", "autoload": { "psr-4": { - "VariableAnalysis\\": "VariableAnalysis/" - } + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-2-Clause" + "MIT" ], "authors": [ { - "name": "Sam Graham", - "email": "php-codesniffer-variableanalysis@illusori.co.uk" + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" }, { - "name": "Payton Swick", - "email": "payton@foolord.com" + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "A PHPCS sniff to detect problems with variables.", + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], "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" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.24.0" }, - "time": "2021-07-06T23:45:17+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-10-20T20:35:02+00:00" }, { - "name": "squizlabs/php_codesniffer", - "version": "3.6.2", + "name": "symfony/polyfill-php73", + "version": "v1.24.0", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a" + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5e4e71592f69da17871dba6e80dd51bce74a351a", - "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/cc5db0e22b3cb4111010e48785a97f670b350ca5", + "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5", "shasum": "" }, "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "php": ">=7.1" }, - "bin": [ - "bin/phpcs", - "bin/phpcbf" - ], "type": "library", "extra": { "branch-alias": { - "dev-master": "3.x-dev" + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Greg Sherwood", - "role": "lead" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", "keywords": [ - "phpcs", - "standards" + "compatibility", + "polyfill", + "portable", + "shim" ], "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.24.0" }, - "time": "2021-12-12T21:44:58+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-06-05T21:20:04+00:00" }, { - "name": "symfony/polyfill-php73", + "name": "symfony/polyfill-php80", "version": "v1.24.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5" + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/cc5db0e22b3cb4111010e48785a97f670b350ca5", - "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/57b712b08eddb97c762a8caa32c84e037892d2e9", + "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9", "shasum": "" }, "require": { @@ -638,7 +1949,7 @@ "bootstrap.php" ], "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" + "Symfony\\Polyfill\\Php80\\": "" }, "classmap": [ "Resources/stubs" @@ -649,6 +1960,10 @@ "MIT" ], "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, { "name": "Nicolas Grekas", "email": "p@tchwork.com" @@ -658,7 +1973,7 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", "homepage": "https://symfony.com", "keywords": [ "compatibility", @@ -667,7 +1982,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.24.0" }, "funding": [ { @@ -683,7 +1998,7 @@ "type": "tidelift" } ], - "time": "2021-06-05T21:20:04+00:00" + "time": "2021-09-13T13:58:33+00:00" }, { "name": "szepeviktor/phpstan-wordpress", diff --git a/index.php b/index.php index e71af0e..b02073d 100644 --- a/index.php +++ b/index.php @@ -1 +1 @@ - + + @@ -33,10 +35,10 @@ - + - + diff --git a/phpstan.neon.dist b/phpstan.neon.dist index aa48a81..efa3cdb 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -4,6 +4,10 @@ parameters: checkMissingIterableValueType: false featureToggles: disableRuntimeReflectionProvider: true + stubFiles: + # Simulate added properties + - phpstan/class-wp-post-type.stub + - phpstan/class-wp-taxonomy.stub bootstrapFiles: - access-functions.php - wp-graphql-yoast-seo.php @@ -14,5 +18,3 @@ parameters: scanDirectories: - ../wp-graphql/ - ../wordpress-seo/ - ignoreErrors: - - '#^Function apply_filters(_ref_array)? invoked with ([1-9]|1[0-2]) parameters, 2 required\.$#' diff --git a/phpstan/class-wp-post-type.stub b/phpstan/class-wp-post-type.stub new file mode 100644 index 0000000..33a7209 --- /dev/null +++ b/phpstan/class-wp-post-type.stub @@ -0,0 +1,9 @@ +hierarchical ) && ! isset( $tax->graphql_single_name ) ) { + if ( empty( $tax->hierarchical ) && ! isset( $tax->graphql_single_name ) ) { continue; } @@ -63,7 +62,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { 'type' => 'Boolean', // translators: Taxonomy name. 'description' => sprintf( __( 'The Yoast SEO primary %s.', 'wp-graphql-yoast-seo' ), $tax->labels->name ), - 'resolve' => static function( $item, array $args, AppContext $context ) use ( $tax ) { + 'resolve' => static function( $item ) use ( $tax ) { $post_id = $item['source']->ID; $term_id = $item['node']->term_id; diff --git a/src/CoreSchemaFilters.php b/src/CoreSchemaFilters.php index d404531..559fcb6 100644 --- a/src/CoreSchemaFilters.php +++ b/src/CoreSchemaFilters.php @@ -8,7 +8,6 @@ namespace WPGraphQL\YoastSEO; -use WPGraphQL; use WPGraphQL\YoastSEO\Interfaces\Hookable; use WPGraphQL\YoastSEO\Type\WPInterface\ContentNodeWithSEO; use WPGraphQL\YoastSEO\Type\WPInterface\TermNodeWithSEO; @@ -22,7 +21,6 @@ class CoreSchemaFilters implements Hookable { */ public static function register_hooks(): void { add_filter( 'graphql_wp_object_type_config', [ __CLASS__, 'set_object_type_config' ] ); - add_filter( 'graphql_wp_connection_type_config', [ __CLASS__, 'set_connection_type_config' ] ); } /** @@ -55,28 +53,6 @@ public static function set_object_type_config( array $config ) : array { ); } - return $config; - } - - public static function set_connection_type_config( array $config ) : array { - global $wp_post_types, $wp_taxonomies; - $post_types = WPGraphQL::get_allowed_post_types(); - $taxonomies = WPGraphQL::get_allowed_taxonomies(); - // If WooCommerce installed then add these post types and taxonomies - if ( class_exists( '\WooCommerce' ) ) { - array_push( $post_types, 'product' ); - array_push( $taxonomies, 'productCategory' ); - } - if ( ! in_array( $config['fromType'], $post_types, true ) || ! in_array( $config['toType'], $taxonomies, true ) ) { - error_log( 'BAD:' . $config['fromType'] . ' to ' . $config['toType'] ); - return $config; - } - - error_log( 'GOOD:' . $config['fromType'] . ' to ' . $config['toType'] ); - - - - return $config; } } diff --git a/src/Type/WPInterface/ContentNodeWithSEO.php b/src/Type/WPInterface/ContentNodeWithSEO.php index 887c82f..7e31209 100644 --- a/src/Type/WPInterface/ContentNodeWithSEO.php +++ b/src/Type/WPInterface/ContentNodeWithSEO.php @@ -13,8 +13,7 @@ use WPGraphQL\YoastSEO\Interfaces\Registrable; use WPGraphQL\YoastSEO\Interfaces\Type; use WPGraphQL\YoastSEO\Type\WPObject\PostTypeSEO; -use WPGraphQL\YoastSEO\Type\WPObject\SEOBaseFields; -use WPGraphQL\YoastSEO\Type\WPObject\SEOPostTypeBreadcrumbs; +use function YoastSEO; /** * Class - ContentNodeWithSEO @@ -60,9 +59,6 @@ public static function get_fields() : array { 'seo' => [ 'type' => PostTypeSEO::$type, 'resolve' => static function( $post, array $args, AppContext $context ) { - // Base array. - $seo = []; - $map = [ '@id' => 'id', '@type' => 'type', @@ -70,161 +66,57 @@ public static function get_fields() : array { '@context' => 'context', ]; - $schemaArray = YoastSEO()->meta->for_post( $post->ID ) - ->schema; + $yoast_meta = YoastSEO()->meta->for_post( $post->ID ); + + + $schema_array = isset( $yoast_meta->schema ) ? $yoast_meta->schema : []; - // https://developer.yoast.com/blog/yoast-seo-14-0-using-yoast-seo-surfaces/ - $robots = YoastSEO()->meta->for_post( $post->ID ) - ->robots; + // @see https://developer.yoast.com/blog/yoast-seo-14-0-using-yoast-seo-surfaces/ + $robots = isset( $yoast_meta->robots ) ? $yoast_meta->robots : []; - // Get data + // Get data. $seo = [ - 'title' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID )->title - ), - 'metaDesc' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->description - ), - 'focuskw' => wp_gql_seo_format_string( - get_post_meta( - $post->ID, - '_yoast_wpseo_focuskw', - true - ) - ), - 'metaKeywords' => wp_gql_seo_format_string( - get_post_meta( - $post->ID, - '_yoast_wpseo_metakeywords', - true - ) - ), - 'metaRobotsNoindex' => $robots['index'], - 'metaRobotsNofollow' => $robots['follow'], - 'opengraphTitle' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->open_graph_title - ), - 'opengraphUrl' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->open_graph_url - ), - 'opengraphSiteName' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->open_graph_site_name - ), - 'opengraphType' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->open_graph_type - ), - 'opengraphAuthor' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->open_graph_article_author - ), - 'opengraphPublisher' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->open_graph_article_publisher - ), - 'opengraphPublishedTime' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->open_graph_article_published_time - ), - 'opengraphModifiedTime' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->open_graph_article_modified_time - ), - 'opengraphDescription' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->open_graph_description - ), - 'opengraphImage' => function () use ( - $post, - $context - ) { - $id = wp_gql_seo_get_og_image( - YoastSEO()->meta->for_post( $post->ID ) - ->open_graph_images - ); + 'title' => isset( $yoast_meta->title ) ? wp_gql_seo_format_string( $yoast_meta->title ) : null, + 'metaDesc' => isset( $yoast_meta->description ) ? wp_gql_seo_format_string( $yoast_meta->description ) : null, + 'focuskw' => wp_gql_seo_format_string( get_post_meta( $post->ID, '_yoast_wpseo_focuskw', true ) ) ?: null, + 'metaKeywords' => wp_gql_seo_format_string( get_post_meta( $post->ID, '_yoast_wpseo_metakeywords', true ) ) ?: null, + 'metaRobotsNoindex' => $robots['index'] ?? null, + 'metaRobotsNofollow' => $robots['follow'] ?? null, + 'opengraphTitle' => isset( $yoast_meta->open_graph_title ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_title ) : null, + 'opengraphUrl' => isset( $yoast_meta->open_graph_url ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_url ) : null, + 'opengraphSiteName' => isset( $yoast_meta->open_graph_site_name ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_site_name ) : null, + 'opengraphType' => isset( $yoast_meta->open_graph_type ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_type ) : null, + 'opengraphAuthor' => isset( $yoast_meta->open_graph_article_author ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_article_author ) : null, + 'opengraphPublisher' => isset( $yoast_meta->open_graph_article_publisher ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_article_publisher ) : null, + 'opengraphPublishedTime' => isset( $yoast_meta->open_graph_article_published_time ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_article_published_time ) : null, + 'opengraphModifiedTime' => isset( $yoast_meta->open_graph_article_modified_time ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_article_modified_time ) : null, + 'opengraphDescription' => isset( $yoast_meta->open_graph_description ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_description ) : null, + 'opengraphImage' => static function () use ( $context, $yoast_meta ) { + $id = ! empty( $yoast_meta->open_graph_images ) ? wp_gql_seo_get_og_image( $yoast_meta->open_graph_images ) : null; - return $context - ->get_loader( 'post' ) - ->load_deferred( absint( $id ) ); + return null !== $id ? $context->get_loader( 'post' )->load_deferred( absint( $id ) ) : null; }, - 'twitterCardType' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->twitter_card - ), - 'twitterTitle' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->twitter_title - ), - 'twitterDescription' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->twitter_description - ), - 'twitterImage' => function () use ( - $post, - $context - ) { - $id = wpcom_vip_attachment_url_to_postid( - YoastSEO()->meta->for_post( $post->ID ) - ->twitter_image - ); + 'twitterCardType' => isset( $yoast_meta->twitter_card ) ? wp_gql_seo_format_string( $yoast_meta->twitter_card ) : null, + 'twitterTitle' => isset( $yoast_meta->twitter_title ) ? wp_gql_seo_format_string( $yoast_meta->twitter_title ) : null, + 'twitterDescription' => isset( $yoast_meta->twitter_description ) ? wp_gql_seo_format_string( $yoast_meta->twitter_description ) : null, + 'twitterImage' => static function () use ( $context, $yoast_meta ) { + $id = isset( $yoast_meta->twitter_image ) ? wpcom_vip_attachment_url_to_postid( $yoast_meta->twitter_image ) : null; - return $context - ->get_loader( 'post' ) - ->load_deferred( absint( $id ) ); + return null !== $id ? $context->get_loader( 'post' )->load_deferred( absint( $id ) ) : null; }, - 'canonical' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->canonical - ), - 'readingTime' => floatval( - YoastSEO()->meta->for_post( $post->ID ) - ->estimated_reading_time_minutes - ), - 'breadcrumbs' => YoastSEO()->meta->for_post( - $post->ID - )->breadcrumbs, - 'cornerstone' => boolval( - YoastSEO()->meta->for_post( $post->ID ) - ->indexable->is_cornerstone - ), - 'fullHead' => is_string( - YoastSEO() - ->meta->for_post( $post->ID ) - ->get_head() - ) - ? YoastSEO() - ->meta->for_post( $post->ID ) - ->get_head() - : YoastSEO() - ->meta->for_post( $post->ID ) - ->get_head()->html, + 'canonical' => isset( $yoast_meta->canonical ) ? wp_gql_seo_format_string( $yoast_meta->canonical ) : null, + 'readingTime' => isset( $yoast_meta->estimated_reading_time_minutes ) ? floatval( $yoast_meta->estimated_reading_time_minutes ) : null, + 'breadcrumbs' => isset( $yoast_meta->breadcrumbs ) ? $yoast_meta->breadcrumbs : null, + 'cornerstone' => isset( $yoast_meta->indexable ) && isset( $yoast_meta->indexable->is_cornerstone ) ? boolval( $yoast_meta->indexable->is_cornerstone ) : null, + 'fullHead' => is_string( $yoast_meta->get_head() ) ? $yoast_meta->get_head() : $yoast_meta->get_head()->html, 'schema' => [ - 'pageType' => is_array( - YoastSEO()->meta->for_post( $post->ID ) - ->schema_page_type - ) - ? YoastSEO()->meta->for_post( $post->ID ) - ->schema_page_type - : [], - 'articleType' => is_array( - YoastSEO()->meta->for_post( $post->ID ) - ->schema_article_type - ) - ? YoastSEO()->meta->for_post( $post->ID ) - ->schema_article_type - : [], - 'raw' => json_encode( - $schemaArray, - JSON_UNESCAPED_SLASHES - ), + 'pageType' => isset( $yoast_meta->indexable ) && isset( $yoast_meta->indexable->schema_page_type ) ? $yoast_meta->schema_page_type : [], + 'articleType' => isset( $yoast_meta->indexable ) && isset( $yoast_meta->indexable->schema_article_type ) ? $yoast_meta->schema_article_type : [], + 'raw' => json_encode( $schema_array, JSON_UNESCAPED_SLASHES ), ], ]; - return ! empty( $seo ) ? $seo : null; + return $seo; }, ], ]; diff --git a/src/Type/WPInterface/TermNodeWithSEO.php b/src/Type/WPInterface/TermNodeWithSEO.php index c1bf548..e636bcd 100644 --- a/src/Type/WPInterface/TermNodeWithSEO.php +++ b/src/Type/WPInterface/TermNodeWithSEO.php @@ -8,6 +8,7 @@ namespace WPGraphQL\YoastSEO\Type\WPInterface; +use WP_Term; use WPGraphQL\AppContext; use WPGraphQL\YoastSEO\Interfaces\TypeWithFields; use WPGraphQL\Registry\TypeRegistry; @@ -43,8 +44,6 @@ public static function register( TypeRegistry $type_registry = null ) : void { 'fields' => self::get_fields(), ] ); - - // self::register_field(); } /** @@ -63,134 +62,55 @@ public static function get_fields() : array { 'type' => TaxonomySEO::$type, 'resolve' => static function( $term, array $args, AppContext $context ) { $term_obj = get_term( $term->term_id ); + // Bail early if no term exists. + if ( ! $term_obj instanceof WP_Term ) { + return null; + } - $meta = WPSEO_Taxonomy_Meta::get_term_meta( + $meta = WPSEO_Taxonomy_Meta::get_term_meta( (int) $term_obj->term_id, $term_obj->taxonomy ); - $robots = YoastSEO()->meta->for_term( $term->term_id )->robots; - $schemaArray = YoastSEO()->meta->for_term( $term->term_id ) - ->schema; + $yoast_meta = YoastSEO()->meta->for_term( $term->term_id ); + + $robots = isset( $yoast_meta->robots ) ? $yoast_meta->robots : []; + + $schema_array = isset( $yoast_meta->schema ) ? $yoast_meta->schema : []; - // Get data + // Get data. $seo = [ - 'title' => wp_gql_seo_format_string( - html_entity_decode( - wp_strip_all_tags( - YoastSEO()->meta->for_term( $term->term_id ) - ->title - ) - ) - ), - 'metaDesc' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->description - ), - 'focuskw' => isset( $meta['wpseo_focuskw'] ) - ? wp_gql_seo_format_string( $meta['wpseo_focuskw'] ) - : $meta['wpseo_focuskw'], - 'metaKeywords' => isset( $meta['wpseo_metakeywords'] ) - ? wp_gql_seo_format_string( - $meta['wpseo_metakeywords'] - ) - : null, - 'metaRobotsNoindex' => $robots['index'], - 'metaRobotsNofollow' => $robots['follow'], - 'opengraphTitle' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->open_graph_title - ), - 'opengraphUrl' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->open_graph_url - ), - 'opengraphSiteName' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->open_graph_site_name - ), - 'opengraphType' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->open_graph_type - ), - 'opengraphAuthor' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->open_graph_article_author - ), - 'opengraphPublisher' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->open_graph_article_publisher - ), - 'opengraphPublishedTime' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->open_graph_article_published_time - ), - 'opengraphModifiedTime' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->open_graph_article_modified_time - ), - 'opengraphDescription' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->open_graph_description - ), - 'opengraphImage' => $context - ->get_loader( 'post' ) - ->load_deferred( - absint( $meta['wpseo_opengraph-image-id'] ) - ), - 'twitterCardType' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->twitter_card - ), - 'twitterTitle' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->twitter_title - ), - 'twitterDescription' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->twitter_description - ), - 'twitterImage' => $context - ->get_loader( 'post' ) - ->load_deferred( - absint( $meta['wpseo_twitter-image-id'] ) - ), - 'canonical' => isset( - YoastSEO()->meta->for_term( $term->term_id )->canonical - ) - ? wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->canonical - ) - : null, - 'breadcrumbs' => YoastSEO()->meta->for_term( - $term->term_id - )->breadcrumbs, - 'cornerstone' => boolval( - YoastSEO()->meta->for_term( $term->term_id ) - ->is_cornerstone - ), - 'fullHead' => is_string( - YoastSEO() - ->meta->for_term( $term->term_id ) - ->get_head() - ) - ? YoastSEO() - ->meta->for_term( $term->term_id ) - ->get_head() - : YoastSEO() - ->meta->for_term( $term->term_id ) - ->get_head()->html, + 'title' => isset( $yoast_meta->title ) ? wp_gql_seo_format_string( wp_strip_all_tags( $yoast_meta->title ) ) : null, + 'metaDesc' => isset( $yoast_meta->description ) ? wp_gql_seo_format_string( $yoast_meta->description ) : null, + 'focuskw' => isset( $meta['wpseo_focuskw'] ) ? wp_gql_seo_format_string( $meta['wpseo_focuskw'] ) : null, + 'metaKeywords' => isset( $meta['wpseo_metakeywords'] ) ? wp_gql_seo_format_string( $meta['wpseo_metakeywords'] ) : null, + 'metaRobotsNoindex' => $robots['index'] ?? null, + 'metaRobotsNofollow' => $robots['follow'] ?? null, + 'opengraphTitle' => isset( $yoast_meta->open_graph_title ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_title ) : null, + 'opengraphUrl' => isset( $yoast_meta->open_graph_url ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_url ) : null, + 'opengraphSiteName' => isset( $yoast_meta->open_graph_site_name ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_site_name ) : null, + 'opengraphType' => isset( $yoast_meta->open_graph_type ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_type ) : null, + 'opengraphAuthor' => isset( $yoast_meta->open_graph_article_author ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_article_author ) : null, + 'opengraphPublisher' => isset( $yoast_meta->open_graph_article_publisher ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_article_publisher ) : null, + 'opengraphPublishedTime' => isset( $yoast_meta->open_graph_article_published_time ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_article_published_time ) : null, + 'opengraphModifiedTime' => isset( $yoast_meta->open_graph_article_modified_time ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_article_modified_time ) : null, + 'opengraphDescription' => isset( $yoast_meta->open_graph_description ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_description ) : null, + 'opengraphImage' => isset( $meta['wpseo_opengraph-image-id'] ) ? $context->get_loader( 'post' )->load_deferred( absint( $meta['wpseo_opengraph-image-id'] ) ) : null, + 'twitterCardType' => isset( $yoast_meta->twitter_card ) ? wp_gql_seo_format_string( $yoast_meta->twitter_card ) : null, + 'twitterTitle' => isset( $yoast_meta->twitter_title ) ? wp_gql_seo_format_string( $yoast_meta->twitter_title ) : null, + 'twitterDescription' => isset( $yoast_meta->twitter_description ) ? wp_gql_seo_format_string( $yoast_meta->twitter_description ) : null, + 'twitterImage' => isset( $meta['wpseo_twitter-image-id'] ) ? $context->get_loader( 'post' )->load_deferred( absint( $meta['wpseo_twitter-image-id'] ) ) : null, + 'canonical' => isset( $yoast_meta->canonical ) ? wp_gql_seo_format_string( $yoast_meta->canonical ) : null, + 'breadcrumbs' => isset( $yoast_meta->breadcrumbs ) ? $yoast_meta->breadcrumbs : null, + 'cornerstone' => ! empty( $yoast_meta->is_cornerstone ), + 'fullHead' => is_string( $yoast_meta->get_head() ) ? $yoast_meta->get_head() : $yoast_meta->get_head()->html, 'schema' => [ - 'raw' => json_encode( - $schemaArray, - JSON_UNESCAPED_SLASHES - ), + 'raw' => json_encode( $schema_array, JSON_UNESCAPED_SLASHES ), ], ]; wp_reset_query(); - return ! empty( $seo ) ? $seo : null; + return $seo; }, ], ]; diff --git a/src/Type/WPObject/Config/ContentTypes.php b/src/Type/WPObject/Config/ContentTypes.php index f7f466e..4ec485c 100644 --- a/src/Type/WPObject/Config/ContentTypes.php +++ b/src/Type/WPObject/Config/ContentTypes.php @@ -8,6 +8,7 @@ namespace WPGraphQL\YoastSEO\Type\WPObject\Config; +use WP_Post_Type; use WPGraphQL; use WPGraphQL\Registry\TypeRegistry; use WPGraphQL\YoastSEO\Interfaces\Registrable; @@ -52,15 +53,25 @@ public static function get_description() : string { public static function get_fields() : array { $post_types = WPGraphQL::get_allowed_post_types(); + // If WooCommerce installed then add these post types. + if ( class_exists( '\WooCommerce' ) ) { + $post_types[] = 'product'; + } + return self::build_content_types( $post_types ); } - private static function build_content_types( $types ) : array { + /** + * Builds a ContentType field configuration for each post type. + * + * @param string[] $types . + */ + private static function build_content_types( array $types ) : array { $carry = []; foreach ( $types as $type ) { $post_type_object = get_post_type_object( $type ); - if ( $post_type_object->graphql_single_name ) { + if ( $post_type_object instanceof WP_Post_Type && $post_type_object->graphql_single_name ) { $carry[ wp_gql_seo_get_field_key( $post_type_object->graphql_single_name ) ] = [ 'type' => ContentType::$type ]; } } diff --git a/src/Type/WPObject/Config/Social/Facebook.php b/src/Type/WPObject/Config/Social/Facebook.php index 7298a9c..93a4e41 100644 --- a/src/Type/WPObject/Config/Social/Facebook.php +++ b/src/Type/WPObject/Config/Social/Facebook.php @@ -31,6 +31,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / register_graphql_object_type( static::$type, [ + // phpcs:ignore // 'description' => static::get_description(), 'fields' => static::get_fields(), ] diff --git a/src/Type/WPObject/Config/Social/Instagram.php b/src/Type/WPObject/Config/Social/Instagram.php index c940fd3..c8c9b14 100644 --- a/src/Type/WPObject/Config/Social/Instagram.php +++ b/src/Type/WPObject/Config/Social/Instagram.php @@ -31,6 +31,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / register_graphql_object_type( static::$type, [ + // phpcs:ignore // 'description' => static::get_description(), 'fields' => static::get_fields(), ] diff --git a/src/Type/WPObject/Config/Social/LinkedIn.php b/src/Type/WPObject/Config/Social/LinkedIn.php index 2ce9277..52083c8 100644 --- a/src/Type/WPObject/Config/Social/LinkedIn.php +++ b/src/Type/WPObject/Config/Social/LinkedIn.php @@ -31,6 +31,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / register_graphql_object_type( static::$type, [ + // phpcs:ignore // 'description' => static::get_description(), 'fields' => static::get_fields(), ] diff --git a/src/Type/WPObject/Config/Social/MySpace.php b/src/Type/WPObject/Config/Social/MySpace.php index 7c039b8..3797eec 100644 --- a/src/Type/WPObject/Config/Social/MySpace.php +++ b/src/Type/WPObject/Config/Social/MySpace.php @@ -31,6 +31,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / register_graphql_object_type( static::$type, [ + // phpcs:ignore // 'description' => static::get_description(), 'fields' => static::get_fields(), ] diff --git a/src/Type/WPObject/Config/Social/Pinterest.php b/src/Type/WPObject/Config/Social/Pinterest.php index 9f8ace8..b9e13ef 100644 --- a/src/Type/WPObject/Config/Social/Pinterest.php +++ b/src/Type/WPObject/Config/Social/Pinterest.php @@ -31,6 +31,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / register_graphql_object_type( static::$type, [ + // phpcs:ignore // 'description' => static::get_description(), 'fields' => static::get_fields(), ] diff --git a/src/Type/WPObject/Config/Social/Twitter.php b/src/Type/WPObject/Config/Social/Twitter.php index 9d1e271..f2f2647 100644 --- a/src/Type/WPObject/Config/Social/Twitter.php +++ b/src/Type/WPObject/Config/Social/Twitter.php @@ -32,6 +32,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / register_graphql_object_type( static::$type, [ + // phpcs:ignore // 'description' => static::get_description(), 'fields' => static::get_fields(), ] @@ -43,7 +44,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / */ public static function get_description() : string { // @todo update description - return __( 'The Yoast SEO webmaster fields', 'wp-graphql-yoast-seo' ); + return __( 'placeholder description', 'wp-graphql-yoast-seo' ); } /** diff --git a/src/Type/WPObject/Config/Social/Wikipedia.php b/src/Type/WPObject/Config/Social/Wikipedia.php index b03c8a6..7aa212d 100644 --- a/src/Type/WPObject/Config/Social/Wikipedia.php +++ b/src/Type/WPObject/Config/Social/Wikipedia.php @@ -31,6 +31,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / register_graphql_object_type( static::$type, [ + // phpcs:ignore // 'description' => static::get_description(), 'fields' => static::get_fields(), ] diff --git a/src/Type/WPObject/Config/Social/Youtube.php b/src/Type/WPObject/Config/Social/Youtube.php index 5aa1799..935aa62 100644 --- a/src/Type/WPObject/Config/Social/Youtube.php +++ b/src/Type/WPObject/Config/Social/Youtube.php @@ -31,6 +31,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / register_graphql_object_type( static::$type, [ + // phpcs:ignore // 'description' => static::get_description(), 'fields' => static::get_fields(), ] diff --git a/src/Type/WPObject/SEOConfig.php b/src/Type/WPObject/SEOConfig.php index 18bebed..12c6636 100644 --- a/src/Type/WPObject/SEOConfig.php +++ b/src/Type/WPObject/SEOConfig.php @@ -8,6 +8,7 @@ namespace WPGraphQL\YoastSEO\Type\WPObject; +use WP_Post_Type; use WPGraphQL\AppContext; use WPGraphQL\Registry\TypeRegistry; use WPGraphQL\YoastSEO\Interfaces\Field; @@ -88,16 +89,15 @@ public static function register_field() : void { 'type' => static::$type, 'description' => __( 'Returns seo site data.', 'wp-graphql-yoast-seo' ), 'resolve' => static function ( $source, array $args, AppContext $context ) use ( $post_types ) { - $wpseo_options = WPSEO_Options::get_instance(); - $all = $wpseo_options->get_all(); + $wpseo_options = WPSEO_Options::get_all(); - $redirects_obj = class_exists( 'WPSEO_Redirect_Option' ) ? new WPSEO_Redirect_Option() : false; + $redirects_obj = class_exists( 'WPSEO_Redirect_Option' ) ? new \WPSEO_Redirect_Option() : false; $redirects = $redirects_obj ? $redirects_obj->get_from_option() : []; - $user_id = $all['company_or_person_user_id']; + $user_id = $wpseo_options['company_or_person_user_id']; $user = get_userdata( $user_id ); - $mappedRedirects = function ( $value ) { + $mapped_redirects = function ( $value ) { return [ 'origin' => $value['origin'], 'target' => $value['url'], @@ -106,111 +106,67 @@ public static function register_field() : void { ]; }; - $contentTypes = self::build_content_type_data( $post_types, $all ); + $contentTypes = self::build_content_type_data( $post_types, $wpseo_options ); return [ 'contentTypes' => $contentTypes, 'webmaster' => [ - 'baiduVerify' => wp_gql_seo_format_string( - $all['baiduverify'] - ), - 'googleVerify' => wp_gql_seo_format_string( - $all['googleverify'] - ), - 'msVerify' => wp_gql_seo_format_string( $all['msverify'] ), - 'yandexVerify' => wp_gql_seo_format_string( - $all['yandexverify'] - ), + 'baiduVerify' => isset( $wpseo_options['baiduverify'] ) ? wp_gql_seo_format_string( $wpseo_options['baiduverify'] ) : null, + 'googleVerify' => isset( $wpseo_options['googleverify'] ) ? wp_gql_seo_format_string( $wpseo_options['googleverify'] ) : null, + 'msVerify' => isset( $wpseo_options['msverify'] ) ? wp_gql_seo_format_string( $wpseo_options['msverify'] ) : null, + 'yandexVerify' => isset( $wpseo_options['yandexverify'] ) ? wp_gql_seo_format_string( $wpseo_options['yandexverify'] ) : null, ], 'social' => [ 'facebook' => [ - 'url' => wp_gql_seo_format_string( $all['facebook_site'] ), - 'defaultImage' => $context - ->get_loader( 'post' ) - ->load_deferred( $all['og_default_image_id'] ), + 'url' => isset( $wpseo_options['facebook_site'] ) ? wp_gql_seo_format_string( $wpseo_options['facebook_site'] ) : null, + 'defaultImage' => isset( $wpseo_options['og_default_image_id'] ) ? $context->get_loader( 'post' )->load_deferred( $wpseo_options['og_default_image_id'] ) : null, ], 'twitter' => [ - 'username' => wp_gql_seo_format_string( - $all['twitter_site'] - ), - 'cardType' => wp_gql_seo_format_string( - $all['twitter_card_type'] - ), + 'username' => isset( $wpseo_options['twitter_site'] ) ? wp_gql_seo_format_string( $wpseo_options['twitter_site'] ) : null, + 'cardType' => isset( $wpseo_options['twitter_card_type'] ) ? wp_gql_seo_format_string( $wpseo_options['twitter_card_type'] ) : null, ], 'instagram' => [ - 'url' => wp_gql_seo_format_string( $all['instagram_url'] ), + 'url' => isset( $wpseo_options['instagram_url'] ) ? wp_gql_seo_format_string( $wpseo_options['instagram_url'] ) : null, ], 'linkedIn' => [ - 'url' => wp_gql_seo_format_string( $all['linkedin_url'] ), + 'url' => isset( $wpseo_options['linkedin_url'] ) ? wp_gql_seo_format_string( $wpseo_options['linkedin_url'] ) : null, ], 'mySpace' => [ - 'url' => wp_gql_seo_format_string( $all['myspace_url'] ), + 'url' => isset( $wpseo_options['myspace_url'] ) ? wp_gql_seo_format_string( $wpseo_options['myspace_url'] ) : null, ], 'pinterest' => [ - 'url' => wp_gql_seo_format_string( $all['pinterest_url'] ), - 'metaTag' => wp_gql_seo_format_string( - $all['pinterestverify'] - ), + 'url' => isset( $wpseo_options['pinterest_url'] ) ? wp_gql_seo_format_string( $wpseo_options['pinterest_url'] ) : null, + 'metaTag' => isset( $wpseo_options['pinterestverify'] ) ? wp_gql_seo_format_string( $wpseo_options['pinterestverify'] ) : null, ], 'youTube' => [ - 'url' => wp_gql_seo_format_string( $all['youtube_url'] ), + 'url' => isset( $wpseo_options['youtube_url'] ) ? wp_gql_seo_format_string( $wpseo_options['youtube_url'] ) : null, ], 'wikipedia' => [ - 'url' => wp_gql_seo_format_string( $all['wikipedia_url'] ), + 'url' => isset( $wpseo_options['wikipedia_url'] ) ? wp_gql_seo_format_string( $wpseo_options['wikipedia_url'] ) : null, ], ], 'breadcrumbs' => [ - 'enabled' => wp_gql_seo_format_string( - $all['breadcrumbs-enable'] - ), - 'boldLast' => wp_gql_seo_format_string( - $all['breadcrumbs-boldlast'] - ), - 'showBlogPage' => wp_gql_seo_format_string( - $all['breadcrumbs-display-blog-page'] - ), - 'archivePrefix' => wp_gql_seo_format_string( - $all['breadcrumbs-archiveprefix'] - ), - 'prefix' => wp_gql_seo_format_string( - $all['breadcrumbs-prefix'] - ), - 'notFoundText' => wp_gql_seo_format_string( - $all['breadcrumbs-404crumb'] - ), - 'homeText' => wp_gql_seo_format_string( - $all['breadcrumbs-home'] - ), - 'searchPrefix' => wp_gql_seo_format_string( - $all['breadcrumbs-searchprefix'] - ), - 'separator' => wp_gql_seo_format_string( - $all['breadcrumbs-sep'] - ), + 'enabled' => isset( $wpseo_options['breadcrumbs-enable'] ) ? wp_gql_seo_format_string( $wpseo_options['breadcrumbs-enable'] ) : null, + 'boldLast' => isset( $wpseo_options['breadcrumbs-boldlast'] ) ? wp_gql_seo_format_string( $wpseo_options['breadcrumbs-boldlast'] ) : null, + 'showBlogPage' => isset( $wpseo_options['breadcrumbs-display-blog-page'] ) ? wp_gql_seo_format_string( $wpseo_options['breadcrumbs-display-blog-page'] ) : null, + 'archivePrefix' => isset( $wpseo_options['breadcrumbs-archiveprefix'] ) ? wp_gql_seo_format_string( $wpseo_options['breadcrumbs-archiveprefix'] ) : null, + 'prefix' => isset( $wpseo_options['breadcrumbs-prefix'] ) ? wp_gql_seo_format_string( $wpseo_options['breadcrumbs-prefix'] ) : null, + 'notFoundText' => isset( $wpseo_options['breadcrumbs-404crumb'] ) ? wp_gql_seo_format_string( $wpseo_options['breadcrumbs-404crumb'] ) : null, + 'homeText' => isset( $wpseo_options['breadcrumbs-home'] ) ? wp_gql_seo_format_string( $wpseo_options['breadcrumbs-home'] ) : null, + 'searchPrefix' => isset( $wpseo_options['breadcrumbs-searchprefix'] ) ? wp_gql_seo_format_string( $wpseo_options['breadcrumbs-searchprefix'] ) : null, + 'separator' => isset( $wpseo_options['breadcrumbs-sep'] ) ? wp_gql_seo_format_string( $wpseo_options['breadcrumbs-sep'] ) : null, ], 'schema' => [ - 'companyName' => wp_gql_seo_format_string( - $all['company_name'] - ), - 'personName' => wp_gql_seo_format_string( - $user->user_nicename - ), - 'companyLogo' => $context - ->get_loader( 'post' ) - ->load_deferred( absint( $all['company_logo_id'] ) ), - 'personLogo' => $context - ->get_loader( 'post' ) - ->load_deferred( absint( $all['person_logo_id'] ) ), - 'logo' => $context - ->get_loader( 'post' ) - ->load_deferred( - $all['company_or_person'] === 'company' - ? absint( $all['company_logo_id'] ) - : absint( $all['person_logo_id'] ) - ), - 'companyOrPerson' => wp_gql_seo_format_string( - $all['company_or_person'] - ), + 'companyName' => isset( $wpseo_options['company_name'] ) ? wp_gql_seo_format_string( $wpseo_options['company_name'] ) : null, + 'personName' => $user instanceof WP_User ? wp_gql_seo_format_string( $user->user_nicename ) : null, + 'companyLogo' => isset( $wpseo_options['company_logo_id'] ) ? $context->get_loader( 'post' )->load_deferred( absint( $wpseo_options['company_logo_id'] ) ) : null, + 'personLogo' => isset( $wpseo_options['person_logo_id'] ) ? $context->get_loader( 'post' )->load_deferred( absint( $wpseo_options['person_logo_id'] ) ) : null, + 'logo' => $context->get_loader( 'post' )->load_deferred( + 'company' === $wpseo_options['company_or_person'] + ? absint( $wpseo_options['company_logo_id'] ) + : absint( $wpseo_options['person_logo_id'] ) + ), + 'companyOrPerson' => isset( $wpseo_options['company_or_person'] ) ? wp_gql_seo_format_string( $wpseo_options['company_or_person'] ) : null, 'siteName' => wp_gql_seo_format_string( YoastSEO()->helpers->site->get_site_name() ), @@ -227,23 +183,13 @@ public static function register_field() : void { get_bloginfo( 'language' ) ), ], - 'redirects' => array_map( $mappedRedirects, $redirects ), + 'redirects' => array_map( $mapped_redirects, $redirects ), 'openGraph' => [ - 'defaultImage' => $context - ->get_loader( 'post' ) - ->load_deferred( absint( $all['og_default_image_id'] ) ), + 'defaultImage' => isset( $wpseo_options['og_default_image_id'] ) ? $context->get_loader( 'post' )->load_deferred( absint( $wpseo_options['og_default_image_id'] ) ) : null, 'frontPage' => [ - 'title' => wp_gql_seo_format_string( - $all['og_frontpage_title'] - ), - 'description' => wp_gql_seo_format_string( - $all['og_frontpage_desc'] - ), - 'image' => $context - ->get_loader( 'post' ) - ->load_deferred( - absint( $all['og_frontpage_image_id'] ) - ), + 'title' => isset( $wpseo_options['og_frontpage_title'] ) ? wp_gql_seo_format_string( $wpseo_options['og_frontpage_title'] ) : null, + 'description' => isset( $wpseo_options['og_frontpage_desc'] ) ? wp_gql_seo_format_string( $wpseo_options['og_frontpage_desc'] ) : null, + 'image' => isset( $wpseo_options['og_frontpage_image_id'] ) ? $context->get_loader( 'post' )->load_deferred( absint( $wpseo_options['og_frontpage_image_id'] ) ) : null, ], ], ]; @@ -252,98 +198,55 @@ public static function register_field() : void { ); } - private static function build_content_type_data( $types, $all ) : array { + /** + * Builds the resolver data for all SEOContentTypes + * + * @param string[] $types The post types. + * @param array $wpseo_options An array of all WPSEO options. + */ + private static function build_content_type_data( $types, $wpseo_options ) : array { $carry = []; foreach ( $types as $type ) { $post_type_object = get_post_type_object( $type ); - if ( $post_type_object->graphql_single_name ) { + if ( $post_type_object instanceof WP_Post_Type && $post_type_object->graphql_single_name ) { $tag = wp_gql_seo_get_field_key( $post_type_object->graphql_single_name ); - $schemaArray = YoastSEO()->meta->for_post_type_archive( $type ) - ->schema; + $yoast_meta = YoastSEO()->meta->for_post_type_archive( $type ); + $schema_array = false !== $yoast_meta ? $yoast_meta->schema : null; $carry[ $tag ] = [ - 'title' => ! empty( $all[ 'title-' . $type ] ) - ? $all[ 'title-' . $type ] - : null, - 'metaDesc' => ! empty( $all[ 'metadesc-' . $type ] ) - ? $all[ 'metadesc-' . $type ] - : null, - 'metaRobotsNoindex' => ! empty( $all[ 'noindex-' . $type ] ) - ? boolval( $all[ 'noindex-' . $type ] ) - : false, - 'schemaType' => ! empty( $all[ 'schema-page-type-' . $type ] ) - ? $all[ 'schema-page-type-' . $type ] - : null, - + 'title' => ! empty( $wpseo_options[ 'title-' . $type ] ) ? $wpseo_options[ 'title-' . $type ] : null, + 'metaDesc' => ! empty( $wpseo_options[ 'metadesc-' . $type ] ) ? $wpseo_options[ 'metadesc-' . $type ] : null, + 'metaRobotsNoindex' => ! empty( $wpseo_options[ 'noindex-' . $type ] ), + 'schemaType' => ! empty( $wpseo_options[ 'schema-page-type-' . $type ] ) ? $wpseo_options[ 'schema-page-type-' . $type ] : null, 'schema' => [ - 'raw' => ! empty( $schemaArray ) - ? json_encode( $schemaArray, JSON_UNESCAPED_SLASHES ) - : null, + 'raw' => ! empty( $schema_array ) ? json_encode( $schema_array, JSON_UNESCAPED_SLASHES ) : null, ], - 'archive' => - $tag == 'post' // Posts are stored like this - ? [ - 'hasArchive' => true, - 'archiveLink' => get_post_type_archive_link( $type ), - 'title' => $all['title-archive-wpseo'] ?? null, - 'metaDesc' => $all['metadesc-archive-wpseo'] ?? null, - 'metaRobotsNoindex' => $all['noindex-archive-wpseo'] ?? null, - 'breadcrumbTitle' => $all['bctitle-archive-wpseo'] ?? null, - 'metaRobotsNoindex' => boolval( - $all['noindex-archive-wpseo'] - ), - 'fullHead' => is_string( - YoastSEO() - ->meta->for_post_type_archive( $type ) - ->get_head() - ) - ? YoastSEO() - ->meta->for_post_type_archive( $type ) - ->get_head() - : YoastSEO() - ->meta->for_post_type_archive( $type ) - ->get_head()->html, - ] - : [ - 'hasArchive' => boolval( - $post_type_object->has_archive - ), - 'archiveLink' => get_post_type_archive_link( $type ), - 'title' => ! empty( $all[ 'title-ptarchive-' . $type ] ) - ? $all[ 'title-ptarchive-' . $type ] - : null, - 'metaDesc' => ! empty( - $all[ 'metadesc-ptarchive-' . $type ] - ) - ? $all[ 'metadesc-ptarchive-' . $type ] - : null, - 'metaRobotsNoindex' => ! empty( - $all[ 'noindex-ptarchive-' . $type ] - ) - ? boolval( $all[ 'noindex-ptarchive-' . $type ] ) - : false, - 'breadcrumbTitle' => ! empty( - $all[ 'bctitle-ptarchive-' . $type ] - ) - ? $all[ 'bctitle-ptarchive-' . $type ] - : null, - 'fullHead' => is_string( - YoastSEO() - ->meta->for_post_type_archive( $type ) - ->get_head() - ) - ? YoastSEO() - ->meta->for_post_type_archive( $type ) - ->get_head() - : YoastSEO() - ->meta->for_post_type_archive( $type ) - ->get_head()->html, - ], + // These are shared by all post types. + 'archive' => [ + 'archiveLink' => get_post_type_archive_link( $type ), + 'fullHead' => is_string( $yoast_meta->get_head() ) ? $yoast_meta->get_head() : $yoast_meta->get_head()->html, + ], + ]; + + // Set archive values and merge with existing. + $archive_values = 'post' === $tag ? [ + 'hasArchive' => true, + 'title' => $wpseo_options['title-archive-wpseo'] ?? null, + 'metaDesc' => $wpseo_options['metadesc-archive-wpseo'] ?? null, + 'metaRobotsNoindex' => $wpseo_options['noindex-archive-wpseo'] ?? null, + 'breadcrumbTitle' => $wpseo_options['bctitle-archive-wpseo'] ?? null, + ] : [ + 'hasArchive' => boolval( $post_type_object->has_archive ), + 'title' => ! empty( $wpseo_options[ 'title-ptarchive-' . $type ] ) ? $wpseo_options[ 'title-ptarchive-' . $type ] : null, + 'metaDesc' => ! empty( $wpseo_options[ 'metadesc-ptarchive-' . $type ] ) ? $wpseo_options[ 'metadesc-ptarchive-' . $type ] : null, + 'metaRobotsNoindex' => ! empty( $wpseo_options[ 'noindex-ptarchive-' . $type ] ) ? boolval( $wpseo_options[ 'noindex-ptarchive-' . $type ] ) : false, + 'breadcrumbTitle' => ! empty( $wpseo_options[ 'bctitle-ptarchive-' . $type ] ) ? $wpseo_options[ 'bctitle-ptarchive-' . $type ] : null, ]; + $carry[ $tag ]['archive'] = array_merge( $carry[ $tag ]['archive'], $archive_values ); } } return $carry; diff --git a/src/Type/WPObject/SEOPostTypeBreadcrumbs.php b/src/Type/WPObject/SEOPostTypeBreadcrumbs.php index 7a7c5a5..1e3c46b 100644 --- a/src/Type/WPObject/SEOPostTypeBreadcrumbs.php +++ b/src/Type/WPObject/SEOPostTypeBreadcrumbs.php @@ -31,6 +31,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / register_graphql_object_type( static::$type, [ + // phpcs:ignore // 'description' => static::get_description(), 'fields' => static::get_fields(), ] @@ -42,7 +43,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / */ public static function get_description() : string { // @todo update description. - return __( 'The Schema types for Taxonomy', 'wp-graphql-yoast-seo' ); + return __( 'placeholder description', 'wp-graphql-yoast-seo' ); } /** diff --git a/src/Type/WPObject/SEOPostTypePageInfo.php b/src/Type/WPObject/SEOPostTypePageInfo.php index 10ce46d..41521db 100644 --- a/src/Type/WPObject/SEOPostTypePageInfo.php +++ b/src/Type/WPObject/SEOPostTypePageInfo.php @@ -8,14 +8,13 @@ namespace WPGraphQL\YoastSEO\Type\WPObject; -use WPGraphQL\AppContext; use WPGraphQL\Registry\TypeRegistry; use WPGraphQL\YoastSEO\Interfaces\Field; use WPGraphQL\YoastSEO\Type\WPObject\PageInfo; use WPGraphQL\YoastSEO\Interfaces\Registrable; use WPGraphQL\YoastSEO\Interfaces\Type; use WPGraphQL\YoastSEO\Interfaces\TypeWithFields; - +use YoastSEO; /** * Class - SEOPostTypePageInfo */ @@ -69,15 +68,13 @@ public static function register_field() : void { [ 'type' => self::$type, 'description' => __( 'Raw schema for archive', 'wp-graphql-yoast-seo' ), - 'resolve' => static function( $item, array $args, AppContext $context ) { - $schemaArray = YoastSEO()->meta->for_post_type_archive()->schema; + 'resolve' => static function() { + $yoast_meta = YoastSEO()->meta->for_post_type_archive(); + $schema_array = false !== $yoast_meta ? $yoast_meta->schema : []; return [ 'schema' => [ - 'raw' => json_encode( - $schemaArray, - JSON_UNESCAPED_SLASHES - ), + 'raw' => json_encode( $schema_array, JSON_UNESCAPED_SLASHES ), ], ]; }, diff --git a/src/Type/WPObject/SEOUser.php b/src/Type/WPObject/SEOUser.php index 8009c39..155f1ac 100644 --- a/src/Type/WPObject/SEOUser.php +++ b/src/Type/WPObject/SEOUser.php @@ -8,8 +8,9 @@ namespace WPGraphQL\YoastSEO\Type\WPObject; -use YoastSEO; +use function YoastSEO; use WPGraphQL\AppContext; +use WPGraphQL\Model\User as ModelUser; use WPGraphQL\Registry\TypeRegistry; use WPGraphQL\YoastSEO\Interfaces\Field; use WPGraphQL\YoastSEO\Interfaces\Registrable; @@ -42,6 +43,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / register_graphql_object_type( static::$type, [ + // phpcs:ignore // 'description' => static::get_description(), 'fields' => static::get_fields(), ] @@ -93,63 +95,27 @@ public static function register_field() : void { [ 'type' => static::$type, 'description' => __( 'The Yoast SEO data of a user', 'wp-graphql-yoast-seo' ), - 'resolve' => static function ( $user, array $args, AppContext $context ) { - $robots = YoastSEO()->meta->for_author( $user->userId )->robots; + 'resolve' => static function ( ModelUser $user, array $args, AppContext $context ) { + $yoast_meta = YoastSEO()->meta->for_author( $user->userId ); + $robots = isset( $yoast_meta->robots ) ? $yoast_meta->robots : []; - $schemaArray = YoastSEO()->meta->for_author( $user->userId )->schema; - $userSeo = [ - 'title' => wp_gql_seo_format_string( - YoastSEO()->meta->for_author( $user->userId )->title - ), - 'metaDesc' => wp_gql_seo_format_string( - YoastSEO()->meta->for_author( $user->userId )->description - ), - 'metaRobotsNoindex' => $robots['index'], - 'metaRobotsNofollow' => $robots['follow'], - 'canonical' => YoastSEO()->meta->for_author( $user->userId ) - ->canonical, - 'opengraphTitle' => YoastSEO()->meta->for_author( $user->userId ) - ->open_graph_title, - 'opengraphDescription' => YoastSEO()->meta->for_author( - $user->userId - )->open_graph_description, - 'opengraphImage' => $context - ->get_loader( 'post' ) - ->load_deferred( - absint( - YoastSEO()->meta->for_author( $user->userId ) - ->open_graph_image_id - ) - ), - 'twitterImage' => $context - ->get_loader( 'post' ) - ->load_deferred( - absint( - YoastSEO()->meta->for_author( $user->userId ) - ->twitter_image_id - ) - ), - 'twitterTitle' => YoastSEO()->meta->for_author( $user->userId ) - ->twitter_title, - 'twitterDescription' => YoastSEO()->meta->for_author( - $user->userId - )->twitter_description, - 'language' => YoastSEO()->meta->for_author( $user->userId ) - ->language, - 'region' => YoastSEO()->meta->for_author( $user->userId )->region, - 'breadcrumbTitle' => YoastSEO()->meta->for_author( $user->userId ) - ->breadcrumb_title, - 'fullHead' => is_string( - YoastSEO() - ->meta->for_author( $user->userId ) - ->get_head() - ) - ? YoastSEO() - ->meta->for_author( $user->userId ) - ->get_head() - : YoastSEO() - ->meta->for_author( $user->userId ) - ->get_head()->html, + $schema_array = isset( $yoast_meta->schema ) ? $yoast_meta->schema : []; + + $userSeo = [ + 'title' => wp_gql_seo_format_string( $yoast_meta->title ), + 'metaDesc' => wp_gql_seo_format_string( $yoast_meta->description ), + 'metaRobotsNoindex' => $robots['index'] ?? null, + 'metaRobotsNofollow' => $robots['follow'] ?? null, + 'canonical' => isset( $yoast_meta->canonical ) ? $yoast_meta->canonical : null, + 'opengraphTitle' => isset( $yoast_meta->open_graph_title ) ? $yoast_meta->open_graph_title : null, + 'opengraphDescription' => isset( $yoast_meta->open_graph_description ) ? $yoast_meta->open_graph_description : null, + 'opengraphImage' => isset( $yoast_meta->open_graph_image_id ) ? $context->get_loader( 'post' )->load_deferred( absint( $yoast_meta->open_graph_image_id ) ) : null, + 'twitterImage' => isset( $yoast_meta->twitter_image_id ) ? $context->get_loader( 'post' )->load_deferred( absint( $yoast_meta->twitter_image_id ) ) : null, + 'twitterDescription' => isset( $yoast_meta->twitter_description ) ? $yoast_meta->twitter_description : null, + 'language' => isset( $yoast_meta->language ) ? $yoast_meta->language : null, + 'region' => isset( $yoast_meta->region ) ? $yoast_meta->region : null, + 'breadcrumbTitle' => isset( $yoast_meta->breadcrumb_title ) ? $yoast_meta->breadcrumb_title : null, + 'fullHead' => is_string( $yoast_meta->get_head() ) ? $yoast_meta->get_head() : $yoast_meta->get_head()->html, 'social' => [ 'facebook' => wp_gql_seo_format_string( get_the_author_meta( 'facebook', $user->userId ) @@ -179,27 +145,14 @@ public static function register_field() : void { get_the_author_meta( 'wikipedia', $user->userId ) ), ], - 'schema' => [ - 'raw' => json_encode( $schemaArray, JSON_UNESCAPED_SLASHES ), - 'pageType' => is_array( - YoastSEO()->meta->for_author( $user->userId ) - ->schema_page_type - ) - ? YoastSEO()->meta->for_author( $user->userId ) - ->schema_page_type - : [], - 'articleType' => is_array( - YoastSEO()->meta->for_author( $user->userId ) - ->schema_article_type - ) - ? YoastSEO()->meta->for_author( $user->userId ) - ->schema_article_type - : [], + 'raw' => json_encode( $schema_array, JSON_UNESCAPED_SLASHES ), + 'pageType' => isset( $yoast_meta->schema_page_type ) ? $yoast_meta->schema_page_type : [], + 'articleType' => isset( $yoast_meta->indexable ) && isset( $yoast_meta->indexable->schema_article_type ) ? $yoast_meta->indexable->schema_article_type : [], ], ]; - return ! empty( $userSeo ) ? $userSeo : []; + return $userSeo; }, ] ); diff --git a/src/Type/WPObject/User/Social.php b/src/Type/WPObject/User/Social.php index d756b4d..83b9cd8 100644 --- a/src/Type/WPObject/User/Social.php +++ b/src/Type/WPObject/User/Social.php @@ -31,6 +31,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / register_graphql_object_type( static::$type, [ + // phpcs:ignore // 'description' => static::get_description(), 'fields' => static::get_fields(), ] diff --git a/vendor/autoload.php b/vendor/autoload.php new file mode 100644 index 0000000..4417350 --- /dev/null +++ b/vendor/autoload.php @@ -0,0 +1,7 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see https://www.php-fig.org/psr/psr-0/ + * @see https://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + /** @var ?string */ + private $vendorDir; + + // PSR-4 + /** + * @var array[] + * @psalm-var array> + */ + private $prefixLengthsPsr4 = array(); + /** + * @var array[] + * @psalm-var array> + */ + private $prefixDirsPsr4 = array(); + /** + * @var array[] + * @psalm-var array + */ + private $fallbackDirsPsr4 = array(); + + // PSR-0 + /** + * @var array[] + * @psalm-var array> + */ + private $prefixesPsr0 = array(); + /** + * @var array[] + * @psalm-var array + */ + private $fallbackDirsPsr0 = array(); + + /** @var bool */ + private $useIncludePath = false; + + /** + * @var string[] + * @psalm-var array + */ + private $classMap = array(); + + /** @var bool */ + private $classMapAuthoritative = false; + + /** + * @var bool[] + * @psalm-var array + */ + private $missingClasses = array(); + + /** @var ?string */ + private $apcuPrefix; + + /** + * @var self[] + */ + private static $registeredLoaders = array(); + + /** + * @param ?string $vendorDir + */ + public function __construct($vendorDir = null) + { + $this->vendorDir = $vendorDir; + } + + /** + * @return string[] + */ + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); + } + + return array(); + } + + /** + * @return array[] + * @psalm-return array> + */ + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + /** + * @return array[] + * @psalm-return array + */ + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + /** + * @return array[] + * @psalm-return array + */ + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + /** + * @return string[] Array of classname => path + * @psalm-return array + */ + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param string[] $classMap Class to filename map + * @psalm-param array $classMap + * + * @return void + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param string[]|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + * + * @return void + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param string[]|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param string[]|string $paths The PSR-0 base directories + * + * @return void + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param string[]|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + * + * @return void + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + * + * @return void + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + * + * @return void + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + * + * @return void + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + + if (null === $this->vendorDir) { + return; + } + + if ($prepend) { + self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; + } else { + unset(self::$registeredLoaders[$this->vendorDir]); + self::$registeredLoaders[$this->vendorDir] = $this; + } + } + + /** + * Unregisters this instance as an autoloader. + * + * @return void + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + + if (null !== $this->vendorDir) { + unset(self::$registeredLoaders[$this->vendorDir]); + } + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return true|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + + return null; + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + /** + * Returns the currently registered loaders indexed by their corresponding vendor directories. + * + * @return self[] + */ + public static function getRegisteredLoaders() + { + return self::$registeredLoaders; + } + + /** + * @param string $class + * @param string $ext + * @return string|false + */ + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath . '\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . $pathEnd)) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + * @private + */ +function includeFile($file) +{ + include $file; +} diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php new file mode 100644 index 0000000..d50e0c9 --- /dev/null +++ b/vendor/composer/InstalledVersions.php @@ -0,0 +1,350 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer; + +use Composer\Autoload\ClassLoader; +use Composer\Semver\VersionParser; + +/** + * This class is copied in every Composer installed project and available to all + * + * See also https://getcomposer.org/doc/07-runtime.md#installed-versions + * + * To require its presence, you can require `composer-runtime-api ^2.0` + */ +class InstalledVersions +{ + /** + * @var mixed[]|null + * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array}|array{}|null + */ + private static $installed; + + /** + * @var bool|null + */ + private static $canGetVendors; + + /** + * @var array[] + * @psalm-var array}> + */ + private static $installedByVendor = array(); + + /** + * Returns a list of all package names which are present, either by being installed, replaced or provided + * + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackages() + { + $packages = array(); + foreach (self::getInstalled() as $installed) { + $packages[] = array_keys($installed['versions']); + } + + if (1 === \count($packages)) { + return $packages[0]; + } + + return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); + } + + /** + * Returns a list of all package names with a specific type e.g. 'library' + * + * @param string $type + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackagesByType($type) + { + $packagesByType = array(); + + foreach (self::getInstalled() as $installed) { + foreach ($installed['versions'] as $name => $package) { + if (isset($package['type']) && $package['type'] === $type) { + $packagesByType[] = $name; + } + } + } + + return $packagesByType; + } + + /** + * Checks whether the given package is installed + * + * This also returns true if the package name is provided or replaced by another package + * + * @param string $packageName + * @param bool $includeDevRequirements + * @return bool + */ + public static function isInstalled($packageName, $includeDevRequirements = true) + { + foreach (self::getInstalled() as $installed) { + if (isset($installed['versions'][$packageName])) { + return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); + } + } + + return false; + } + + /** + * Checks whether the given package satisfies a version constraint + * + * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: + * + * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') + * + * @param VersionParser $parser Install composer/semver to have access to this class and functionality + * @param string $packageName + * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package + * @return bool + */ + public static function satisfies(VersionParser $parser, $packageName, $constraint) + { + $constraint = $parser->parseConstraints($constraint); + $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); + + return $provided->matches($constraint); + } + + /** + * Returns a version constraint representing all the range(s) which are installed for a given package + * + * It is easier to use this via isInstalled() with the $constraint argument if you need to check + * whether a given version of a package is installed, and not just whether it exists + * + * @param string $packageName + * @return string Version constraint usable with composer/semver + */ + public static function getVersionRanges($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + $ranges = array(); + if (isset($installed['versions'][$packageName]['pretty_version'])) { + $ranges[] = $installed['versions'][$packageName]['pretty_version']; + } + if (array_key_exists('aliases', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); + } + if (array_key_exists('replaced', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); + } + if (array_key_exists('provided', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); + } + + return implode(' || ', $ranges); + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['version'])) { + return null; + } + + return $installed['versions'][$packageName]['version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getPrettyVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['pretty_version'])) { + return null; + } + + return $installed['versions'][$packageName]['pretty_version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference + */ + public static function getReference($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['reference'])) { + return null; + } + + return $installed['versions'][$packageName]['reference']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. + */ + public static function getInstallPath($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @return array + * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string} + */ + public static function getRootPackage() + { + $installed = self::getInstalled(); + + return $installed[0]['root']; + } + + /** + * Returns the raw installed.php data for custom implementations + * + * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. + * @return array[] + * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array} + */ + public static function getRawData() + { + @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = include __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + + return self::$installed; + } + + /** + * Returns the raw data of all installed.php which are currently loaded for custom implementations + * + * @return array[] + * @psalm-return list}> + */ + public static function getAllRawData() + { + return self::getInstalled(); + } + + /** + * Lets you reload the static array from another file + * + * This is only useful for complex integrations in which a project needs to use + * this class but then also needs to execute another project's autoloader in process, + * and wants to ensure both projects have access to their version of installed.php. + * + * A typical case would be PHPUnit, where it would need to make sure it reads all + * the data it needs from this class, then call reload() with + * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure + * the project in which it runs can then also use this class safely, without + * interference between PHPUnit's dependencies and the project's dependencies. + * + * @param array[] $data A vendor/composer/installed.php data set + * @return void + * + * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array} $data + */ + public static function reload($data) + { + self::$installed = $data; + self::$installedByVendor = array(); + } + + /** + * @return array[] + * @psalm-return list}> + */ + private static function getInstalled() + { + if (null === self::$canGetVendors) { + self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); + } + + $installed = array(); + + if (self::$canGetVendors) { + foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { + if (isset(self::$installedByVendor[$vendorDir])) { + $installed[] = self::$installedByVendor[$vendorDir]; + } elseif (is_file($vendorDir.'/composer/installed.php')) { + $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; + if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { + self::$installed = $installed[count($installed) - 1]; + } + } + } + } + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = require __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + $installed[] = self::$installed; + + return $installed; + } +} diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE new file mode 100644 index 0000000..f27399a --- /dev/null +++ b/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php new file mode 100644 index 0000000..743381b --- /dev/null +++ b/vendor/composer/autoload_classmap.php @@ -0,0 +1,52 @@ + $vendorDir . '/composer/InstalledVersions.php', + 'WPGraphQL\\YoastSEO\\Connection\\PostTypeToTermNodeConnectionEdge' => $baseDir . '/src/Connection/PostTypeToTermNodeConnectionEdge.php', + 'WPGraphQL\\YoastSEO\\CoreSchemaFilters' => $baseDir . '/src/CoreSchemaFilters.php', + 'WPGraphQL\\YoastSEO\\Interfaces\\Field' => $baseDir . '/src/Interfaces/Field.php', + 'WPGraphQL\\YoastSEO\\Interfaces\\Hookable' => $baseDir . '/src/Interfaces/Hookable.php', + 'WPGraphQL\\YoastSEO\\Interfaces\\Registrable' => $baseDir . '/src/Interfaces/Registrable.php', + 'WPGraphQL\\YoastSEO\\Interfaces\\Type' => $baseDir . '/src/Interfaces/Type.php', + 'WPGraphQL\\YoastSEO\\Interfaces\\TypeWithFields' => $baseDir . '/src/Interfaces/TypeWithFields.php', + 'WPGraphQL\\YoastSEO\\Seo' => $baseDir . '/src/Seo.php', + 'WPGraphQL\\YoastSEO\\TypeRegistry' => $baseDir . '/src/TypeRegistry.php', + 'WPGraphQL\\YoastSEO\\Type\\Enum\\SEOCardTypeEnum' => $baseDir . '/src/Type/Enum/SEOCardTypeEnum.php', + 'WPGraphQL\\YoastSEO\\Type\\WPInterface\\ContentNodeWithSEO' => $baseDir . '/src/Type/WPInterface/ContentNodeWithSEO.php', + 'WPGraphQL\\YoastSEO\\Type\\WPInterface\\SEOBaseFields' => $baseDir . '/src/Type/WPInterface/SEOBaseFields.php', + 'WPGraphQL\\YoastSEO\\Type\\WPInterface\\TermNodeWithSEO' => $baseDir . '/src/Type/WPInterface/TermNodeWithSEO.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Breadcrumbs' => $baseDir . '/src/Type/WPObject/Config/Breadcrumbs.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\ContentType\\ContentType' => $baseDir . '/src/Type/WPObject/Config/ContentType/ContentType.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\ContentTypes' => $baseDir . '/src/Type/WPObject/Config/ContentTypes.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\OpenGraph' => $baseDir . '/src/Type/WPObject/Config/OpenGraph.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\OpenGraph\\FrontPage' => $baseDir . '/src/Type/WPObject/Config/OpenGraph/FrontPage.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Redirect' => $baseDir . '/src/Type/WPObject/Config/Redirect.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Schema' => $baseDir . '/src/Type/WPObject/Config/Schema.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social' => $baseDir . '/src/Type/WPObject/Config/Social.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Facebook' => $baseDir . '/src/Type/WPObject/Config/Social/Facebook.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Instagram' => $baseDir . '/src/Type/WPObject/Config/Social/Instagram.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\LinkedIn' => $baseDir . '/src/Type/WPObject/Config/Social/LinkedIn.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\MySpace' => $baseDir . '/src/Type/WPObject/Config/Social/MySpace.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Pinterest' => $baseDir . '/src/Type/WPObject/Config/Social/Pinterest.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Twitter' => $baseDir . '/src/Type/WPObject/Config/Social/Twitter.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Wikipedia' => $baseDir . '/src/Type/WPObject/Config/Social/Wikipedia.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Youtube' => $baseDir . '/src/Type/WPObject/Config/Social/Youtube.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Webmaster' => $baseDir . '/src/Type/WPObject/Config/Webmaster.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\ContentType\\Archive' => $baseDir . '/src/Type/WPObject/ContentType/Archive.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\PageInfo\\Schema' => $baseDir . '/src/Type/WPObject/PageInfo/Schema.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\PostTypeSEO' => $baseDir . '/src/Type/WPObject/PostTypeSEO.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\PostType\\Schema' => $baseDir . '/src/Type/WPObject/PostType/Schema.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\SEOConfig' => $baseDir . '/src/Type/WPObject/SEOConfig.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\SEOPostTypeBreadcrumbs' => $baseDir . '/src/Type/WPObject/SEOPostTypeBreadcrumbs.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\SEOPostTypePageInfo' => $baseDir . '/src/Type/WPObject/SEOPostTypePageInfo.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\SEOUser' => $baseDir . '/src/Type/WPObject/SEOUser.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\TaxonomySEO' => $baseDir . '/src/Type/WPObject/TaxonomySEO.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Taxonomy\\Schema' => $baseDir . '/src/Type/WPObject/Taxonomy/Schema.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\User\\Schema' => $baseDir . '/src/Type/WPObject/User/Schema.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\User\\Social' => $baseDir . '/src/Type/WPObject/User/Social.php', +); diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php new file mode 100644 index 0000000..67791f0 --- /dev/null +++ b/vendor/composer/autoload_files.php @@ -0,0 +1,10 @@ + $baseDir . '/access-functions.php', +); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php new file mode 100644 index 0000000..b7fc012 --- /dev/null +++ b/vendor/composer/autoload_namespaces.php @@ -0,0 +1,9 @@ + array($baseDir . '/src'), +); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php new file mode 100644 index 0000000..4ad717c --- /dev/null +++ b/vendor/composer/autoload_real.php @@ -0,0 +1,80 @@ += 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); + if ($useStaticLoader) { + require __DIR__ . '/autoload_static.php'; + + call_user_func(\Composer\Autoload\ComposerStaticInitccec7e4645ca6ddf694d702594caaacb::getInitializer($loader)); + } else { + $map = require __DIR__ . '/autoload_namespaces.php'; + foreach ($map as $namespace => $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + } + + $loader->register(true); + + if ($useStaticLoader) { + $includeFiles = Composer\Autoload\ComposerStaticInitccec7e4645ca6ddf694d702594caaacb::$files; + } else { + $includeFiles = require __DIR__ . '/autoload_files.php'; + } + foreach ($includeFiles as $fileIdentifier => $file) { + composerRequireccec7e4645ca6ddf694d702594caaacb($fileIdentifier, $file); + } + + return $loader; + } +} + +/** + * @param string $fileIdentifier + * @param string $file + * @return void + */ +function composerRequireccec7e4645ca6ddf694d702594caaacb($fileIdentifier, $file) +{ + if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { + $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; + + require $file; + } +} diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php new file mode 100644 index 0000000..6c1e3af --- /dev/null +++ b/vendor/composer/autoload_static.php @@ -0,0 +1,82 @@ + __DIR__ . '/../..' . '/access-functions.php', + ); + + public static $prefixLengthsPsr4 = array ( + 'W' => + array ( + 'WPGraphQL\\YoastSEO\\' => 19, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'WPGraphQL\\YoastSEO\\' => + array ( + 0 => __DIR__ . '/../..' . '/src', + ), + ); + + public static $classMap = array ( + 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', + 'WPGraphQL\\YoastSEO\\Connection\\PostTypeToTermNodeConnectionEdge' => __DIR__ . '/../..' . '/src/Connection/PostTypeToTermNodeConnectionEdge.php', + 'WPGraphQL\\YoastSEO\\CoreSchemaFilters' => __DIR__ . '/../..' . '/src/CoreSchemaFilters.php', + 'WPGraphQL\\YoastSEO\\Interfaces\\Field' => __DIR__ . '/../..' . '/src/Interfaces/Field.php', + 'WPGraphQL\\YoastSEO\\Interfaces\\Hookable' => __DIR__ . '/../..' . '/src/Interfaces/Hookable.php', + 'WPGraphQL\\YoastSEO\\Interfaces\\Registrable' => __DIR__ . '/../..' . '/src/Interfaces/Registrable.php', + 'WPGraphQL\\YoastSEO\\Interfaces\\Type' => __DIR__ . '/../..' . '/src/Interfaces/Type.php', + 'WPGraphQL\\YoastSEO\\Interfaces\\TypeWithFields' => __DIR__ . '/../..' . '/src/Interfaces/TypeWithFields.php', + 'WPGraphQL\\YoastSEO\\Seo' => __DIR__ . '/../..' . '/src/Seo.php', + 'WPGraphQL\\YoastSEO\\TypeRegistry' => __DIR__ . '/../..' . '/src/TypeRegistry.php', + 'WPGraphQL\\YoastSEO\\Type\\Enum\\SEOCardTypeEnum' => __DIR__ . '/../..' . '/src/Type/Enum/SEOCardTypeEnum.php', + 'WPGraphQL\\YoastSEO\\Type\\WPInterface\\ContentNodeWithSEO' => __DIR__ . '/../..' . '/src/Type/WPInterface/ContentNodeWithSEO.php', + 'WPGraphQL\\YoastSEO\\Type\\WPInterface\\SEOBaseFields' => __DIR__ . '/../..' . '/src/Type/WPInterface/SEOBaseFields.php', + 'WPGraphQL\\YoastSEO\\Type\\WPInterface\\TermNodeWithSEO' => __DIR__ . '/../..' . '/src/Type/WPInterface/TermNodeWithSEO.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Breadcrumbs' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Breadcrumbs.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\ContentType\\ContentType' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/ContentType/ContentType.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\ContentTypes' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/ContentTypes.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\OpenGraph' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/OpenGraph.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\OpenGraph\\FrontPage' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/OpenGraph/FrontPage.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Redirect' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Redirect.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Schema' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Schema.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Social.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Facebook' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Social/Facebook.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Instagram' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Social/Instagram.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\LinkedIn' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Social/LinkedIn.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\MySpace' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Social/MySpace.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Pinterest' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Social/Pinterest.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Twitter' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Social/Twitter.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Wikipedia' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Social/Wikipedia.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Youtube' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Social/Youtube.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Webmaster' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Webmaster.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\ContentType\\Archive' => __DIR__ . '/../..' . '/src/Type/WPObject/ContentType/Archive.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\PageInfo\\Schema' => __DIR__ . '/../..' . '/src/Type/WPObject/PageInfo/Schema.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\PostTypeSEO' => __DIR__ . '/../..' . '/src/Type/WPObject/PostTypeSEO.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\PostType\\Schema' => __DIR__ . '/../..' . '/src/Type/WPObject/PostType/Schema.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\SEOConfig' => __DIR__ . '/../..' . '/src/Type/WPObject/SEOConfig.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\SEOPostTypeBreadcrumbs' => __DIR__ . '/../..' . '/src/Type/WPObject/SEOPostTypeBreadcrumbs.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\SEOPostTypePageInfo' => __DIR__ . '/../..' . '/src/Type/WPObject/SEOPostTypePageInfo.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\SEOUser' => __DIR__ . '/../..' . '/src/Type/WPObject/SEOUser.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\TaxonomySEO' => __DIR__ . '/../..' . '/src/Type/WPObject/TaxonomySEO.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Taxonomy\\Schema' => __DIR__ . '/../..' . '/src/Type/WPObject/Taxonomy/Schema.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\User\\Schema' => __DIR__ . '/../..' . '/src/Type/WPObject/User/Schema.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\User\\Social' => __DIR__ . '/../..' . '/src/Type/WPObject/User/Social.php', + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticInitccec7e4645ca6ddf694d702594caaacb::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitccec7e4645ca6ddf694d702594caaacb::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitccec7e4645ca6ddf694d702594caaacb::$classMap; + + }, null, ClassLoader::class); + } +} diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php new file mode 100644 index 0000000..919e62a --- /dev/null +++ b/vendor/composer/installed.php @@ -0,0 +1,350 @@ + array( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'type' => 'wordpress-plugin', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'reference' => '5665c34f310076666caa5763e8fdd9385fa66b81', + 'name' => 'ashhitch/wp-graphql-yoast-seo', + 'dev' => true, + ), + 'versions' => array( + 'ashhitch/wp-graphql-yoast-seo' => array( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'type' => 'wordpress-plugin', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'reference' => '5665c34f310076666caa5763e8fdd9385fa66b81', + 'dev_requirement' => false, + ), + 'automattic/vipwpcs' => array( + 'pretty_version' => '2.3.3', + 'version' => '2.3.3.0', + 'type' => 'phpcodesniffer-standard', + 'install_path' => __DIR__ . '/../automattic/vipwpcs', + 'aliases' => array(), + 'reference' => '6cd0a6a82bc0ac988dbf9d6a7c2e293dc8ac640b', + 'dev_requirement' => true, + ), + 'dealerdirect/phpcodesniffer-composer-installer' => array( + 'pretty_version' => 'v0.7.2', + 'version' => '0.7.2.0', + 'type' => 'composer-plugin', + 'install_path' => __DIR__ . '/../dealerdirect/phpcodesniffer-composer-installer', + 'aliases' => array(), + 'reference' => '1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db', + 'dev_requirement' => true, + ), + 'giacocorsiglia/wordpress-stubs' => array( + 'dev_requirement' => true, + 'replaced' => array( + 0 => '*', + ), + ), + 'guzzlehttp/guzzle' => array( + 'pretty_version' => '7.4.1', + 'version' => '7.4.1.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../guzzlehttp/guzzle', + 'aliases' => array(), + 'reference' => 'ee0a041b1760e6a53d2a39c8c34115adc2af2c79', + 'dev_requirement' => true, + ), + 'guzzlehttp/promises' => array( + 'pretty_version' => '1.5.1', + 'version' => '1.5.1.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../guzzlehttp/promises', + 'aliases' => array(), + 'reference' => 'fe752aedc9fd8fcca3fe7ad05d419d32998a06da', + 'dev_requirement' => true, + ), + 'guzzlehttp/psr7' => array( + 'pretty_version' => '2.1.0', + 'version' => '2.1.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../guzzlehttp/psr7', + 'aliases' => array(), + 'reference' => '089edd38f5b8abba6cb01567c2a8aaa47cec4c72', + 'dev_requirement' => true, + ), + 'j4mie/idiorm' => array( + 'pretty_version' => 'v1.5.7', + 'version' => '1.5.7.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../j4mie/idiorm', + 'aliases' => array(), + 'reference' => 'd23f97053ef5d0b988a02c6a71eb5c6118b2f5b4', + 'dev_requirement' => true, + ), + 'league/oauth2-client' => array( + 'pretty_version' => '2.6.1', + 'version' => '2.6.1.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../league/oauth2-client', + 'aliases' => array(), + 'reference' => '2334c249907190c132364f5dae0287ab8666aa19', + 'dev_requirement' => true, + ), + 'paragonie/random_compat' => array( + 'pretty_version' => 'v9.99.100', + 'version' => '9.99.100.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../paragonie/random_compat', + 'aliases' => array(), + 'reference' => '996434e5492cb4c3edcb9168db6fbb1359ef965a', + 'dev_requirement' => true, + ), + 'php-stubs/wordpress-seo-stubs' => array( + 'pretty_version' => 'v17.2', + 'version' => '17.2.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../php-stubs/wordpress-seo-stubs', + 'aliases' => array(), + 'reference' => 'f4b272159d3091f07596e63f14525f8da0919caf', + 'dev_requirement' => true, + ), + 'php-stubs/wordpress-stubs' => array( + 'pretty_version' => 'v5.9.0', + 'version' => '5.9.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../php-stubs/wordpress-stubs', + 'aliases' => array(), + 'reference' => '0fa8dd9a1bd2a1b60e85afc6c798fca1f599cc1b', + 'dev_requirement' => true, + ), + 'phpcompatibility/php-compatibility' => array( + 'pretty_version' => '9.3.5', + 'version' => '9.3.5.0', + 'type' => 'phpcodesniffer-standard', + 'install_path' => __DIR__ . '/../phpcompatibility/php-compatibility', + 'aliases' => array(), + 'reference' => '9fb324479acf6f39452e0655d2429cc0d3914243', + 'dev_requirement' => true, + ), + 'phpcompatibility/phpcompatibility-paragonie' => array( + 'pretty_version' => '1.3.1', + 'version' => '1.3.1.0', + 'type' => 'phpcodesniffer-standard', + 'install_path' => __DIR__ . '/../phpcompatibility/phpcompatibility-paragonie', + 'aliases' => array(), + 'reference' => 'ddabec839cc003651f2ce695c938686d1086cf43', + 'dev_requirement' => true, + ), + 'phpcompatibility/phpcompatibility-wp' => array( + 'pretty_version' => '2.1.3', + 'version' => '2.1.3.0', + 'type' => 'phpcodesniffer-standard', + 'install_path' => __DIR__ . '/../phpcompatibility/phpcompatibility-wp', + 'aliases' => array(), + 'reference' => 'd55de55f88697b9cdb94bccf04f14eb3b11cf308', + 'dev_requirement' => true, + ), + 'phpstan/extension-installer' => array( + 'pretty_version' => '1.1.0', + 'version' => '1.1.0.0', + 'type' => 'composer-plugin', + 'install_path' => __DIR__ . '/../phpstan/extension-installer', + 'aliases' => array(), + 'reference' => '66c7adc9dfa38b6b5838a9fb728b68a7d8348051', + 'dev_requirement' => true, + ), + 'phpstan/phpstan' => array( + 'pretty_version' => '1.4.6', + 'version' => '1.4.6.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../phpstan/phpstan', + 'aliases' => array(), + 'reference' => '8a7761f1c520e0dad6e04d862fdc697445457cfe', + 'dev_requirement' => true, + ), + 'poolshark/wp-graphql-stubs' => array( + 'pretty_version' => 'v0.0.2', + 'version' => '0.0.2.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../poolshark/wp-graphql-stubs', + 'aliases' => array(), + 'reference' => '66ba54188d04788849abd07bfc9fff511839cdb3', + 'dev_requirement' => true, + ), + 'psr/container' => array( + 'pretty_version' => '1.1.2', + 'version' => '1.1.2.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/container', + 'aliases' => array(), + 'reference' => '513e0666f7216c7459170d56df27dfcefe1689ea', + 'dev_requirement' => true, + ), + 'psr/container-implementation' => array( + 'dev_requirement' => true, + 'provided' => array( + 0 => '1.0', + ), + ), + 'psr/http-client' => array( + 'pretty_version' => '1.0.1', + 'version' => '1.0.1.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/http-client', + 'aliases' => array(), + 'reference' => '2dfb5f6c5eff0e91e20e913f8c5452ed95b86621', + 'dev_requirement' => true, + ), + 'psr/http-client-implementation' => array( + 'dev_requirement' => true, + 'provided' => array( + 0 => '1.0', + ), + ), + 'psr/http-factory' => array( + 'pretty_version' => '1.0.1', + 'version' => '1.0.1.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/http-factory', + 'aliases' => array(), + 'reference' => '12ac7fcd07e5b077433f5f2bee95b3a771bf61be', + 'dev_requirement' => true, + ), + 'psr/http-factory-implementation' => array( + 'dev_requirement' => true, + 'provided' => array( + 0 => '1.0', + ), + ), + 'psr/http-message' => array( + 'pretty_version' => '1.0.1', + 'version' => '1.0.1.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/http-message', + 'aliases' => array(), + 'reference' => 'f6561bf28d520154e4b0ec72be95418abe6d9363', + 'dev_requirement' => true, + ), + 'psr/http-message-implementation' => array( + 'dev_requirement' => true, + 'provided' => array( + 0 => '1.0', + ), + ), + 'psr/log' => array( + 'pretty_version' => '1.1.4', + 'version' => '1.1.4.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/log', + 'aliases' => array(), + 'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11', + 'dev_requirement' => true, + ), + 'ralouphie/getallheaders' => array( + 'pretty_version' => '3.0.3', + 'version' => '3.0.3.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../ralouphie/getallheaders', + 'aliases' => array(), + 'reference' => '120b605dfeb996808c31b6477290a714d356e822', + 'dev_requirement' => true, + ), + 'sirbrillig/phpcs-variable-analysis' => array( + 'pretty_version' => 'v2.11.2', + 'version' => '2.11.2.0', + 'type' => 'phpcodesniffer-standard', + 'install_path' => __DIR__ . '/../sirbrillig/phpcs-variable-analysis', + 'aliases' => array(), + 'reference' => '3fad28475bfbdbf8aa5c440f8a8f89824983d85e', + 'dev_requirement' => true, + ), + 'squizlabs/php_codesniffer' => array( + 'pretty_version' => '3.6.2', + 'version' => '3.6.2.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../squizlabs/php_codesniffer', + 'aliases' => array(), + 'reference' => '5e4e71592f69da17871dba6e80dd51bce74a351a', + 'dev_requirement' => true, + ), + 'symfony/config' => array( + 'pretty_version' => 'v3.4.47', + 'version' => '3.4.47.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/config', + 'aliases' => array(), + 'reference' => 'bc6b3fd3930d4b53a60b42fe2ed6fc466b75f03f', + 'dev_requirement' => true, + ), + 'symfony/dependency-injection' => array( + 'pretty_version' => 'v3.4.47', + 'version' => '3.4.47.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/dependency-injection', + 'aliases' => array(), + 'reference' => '51d2a2708c6ceadad84393f8581df1dcf9e5e84b', + 'dev_requirement' => true, + ), + 'symfony/deprecation-contracts' => array( + 'pretty_version' => 'v3.0.0', + 'version' => '3.0.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/deprecation-contracts', + 'aliases' => array(), + 'reference' => 'c726b64c1ccfe2896cb7df2e1331c357ad1c8ced', + 'dev_requirement' => true, + ), + 'symfony/filesystem' => array( + 'pretty_version' => 'v4.4.37', + 'version' => '4.4.37.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/filesystem', + 'aliases' => array(), + 'reference' => 'c59f37705c3e513ae55b2735f128f4ce363c82ec', + 'dev_requirement' => true, + ), + 'symfony/polyfill-ctype' => array( + 'pretty_version' => 'v1.24.0', + 'version' => '1.24.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-ctype', + 'aliases' => array(), + 'reference' => '30885182c981ab175d4d034db0f6f469898070ab', + 'dev_requirement' => true, + ), + 'symfony/polyfill-php73' => array( + 'pretty_version' => 'v1.24.0', + 'version' => '1.24.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-php73', + 'aliases' => array(), + 'reference' => 'cc5db0e22b3cb4111010e48785a97f670b350ca5', + 'dev_requirement' => true, + ), + 'symfony/polyfill-php80' => array( + 'pretty_version' => 'v1.24.0', + 'version' => '1.24.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-php80', + 'aliases' => array(), + 'reference' => '57b712b08eddb97c762a8caa32c84e037892d2e9', + 'dev_requirement' => true, + ), + 'szepeviktor/phpstan-wordpress' => array( + 'pretty_version' => 'v1.0.2', + 'version' => '1.0.2.0', + 'type' => 'phpstan-extension', + 'install_path' => __DIR__ . '/../szepeviktor/phpstan-wordpress', + 'aliases' => array(), + 'reference' => 'd44b5abcaa529698e138b2d21bc2a7cf9834039c', + 'dev_requirement' => true, + ), + 'wp-coding-standards/wpcs' => array( + 'pretty_version' => '2.3.0', + 'version' => '2.3.0.0', + 'type' => 'phpcodesniffer-standard', + 'install_path' => __DIR__ . '/../wp-coding-standards/wpcs', + 'aliases' => array(), + 'reference' => '7da1894633f168fe244afc6de00d141f27517b62', + 'dev_requirement' => true, + ), + ), +); diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php new file mode 100644 index 0000000..580fa96 --- /dev/null +++ b/vendor/composer/platform_check.php @@ -0,0 +1,26 @@ += 70400)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 7.4.0". You are running ' . PHP_VERSION . '.'; +} + +if ($issues) { + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); + } elseif (!headers_sent()) { + echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; + } + } + trigger_error( + 'Composer detected issues in your platform: ' . implode(' ', $issues), + E_USER_ERROR + ); +} diff --git a/wp-graphql-yoast-seo.php b/wp-graphql-yoast-seo.php index 71d0cd9..5e07396 100755 --- a/wp-graphql-yoast-seo.php +++ b/wp-graphql-yoast-seo.php @@ -86,7 +86,7 @@ function wp_gql_seo_init() { } foreach ( $not_ready as $dep ) { - $display_admin_notice = static function() use( $dep ) { + $display_admin_notice = static function() use ( $dep ) { ?>
=7.4" + }, + "require-dev": { + "automattic/vipwpcs": "^2.3", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7", + "phpcompatibility/phpcompatibility-wp": "^2.1", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.2", + "poolshark/wp-graphql-stubs": "^0.0.2", + "squizlabs/php_codesniffer": "^3.6", + "szepeviktor/phpstan-wordpress": "^1.0", + "wp-coding-standards/wpcs": "^2.3" + }, + "config": { + "optimize-autoloader": true, + "process-timeout": 0, + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true, + "phpstan/extension-installer": true + } + }, + "autoload": { + "files": [ + "access-functions.php" + ], + "psr-4": { + "WPGraphQL\\YoastSEO\\": "src/" + } + }, + "scripts": { + "lint": "vendor/bin/phpcs", + "phpcs-i": [ + "php ./vendor/bin/phpcs -i" + ], + "check-cs": [ + "php ./vendor/bin/phpcs src" + ], + "fix-cs": [ + "php ./vendor/bin/phpcbf src" + ], + "phpstan": [ + "phpstan analyze --ansi --memory-limit=1G" + ] + } } diff --git a/composer.lock b/composer.lock index df1e81e..8fc699f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,183 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "aa0bc8e95c40b5f41d3301f1985c9db5", - "packages": [ + "content-hash": "d19a6e595bf1527ed296045ebd29a882", + "packages": [], + "packages-dev": [ + { + "name": "automattic/vipwpcs", + "version": "2.3.3", + "source": { + "type": "git", + "url": "https://github.com/Automattic/VIP-Coding-Standards.git", + "reference": "6cd0a6a82bc0ac988dbf9d6a7c2e293dc8ac640b" + }, + "dist": { + "type": "zip", + "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.11.1", + "squizlabs/php_codesniffer": "^3.5.5", + "wp-coding-standards/wpcs": "^2.3" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^0.5", + "php-parallel-lint/php-parallel-lint": "^1.0", + "phpcompatibility/php-compatibility": "^9", + "phpcsstandards/phpcsdevtools": "^1.0", + "phpunit/phpunit": "^4 || ^5 || ^6 || ^7" + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Contributors", + "homepage": "https://github.com/Automattic/VIP-Coding-Standards/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress VIP minimum coding conventions", + "keywords": [ + "phpcs", + "standards", + "wordpress" + ], + "support": { + "issues": "https://github.com/Automattic/VIP-Coding-Standards/issues", + "source": "https://github.com/Automattic/VIP-Coding-Standards", + "wiki": "https://github.com/Automattic/VIP-Coding-Standards/wiki" + }, + "time": "2021-09-29T16:20:23+00:00" + }, + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v0.7.2", + "source": { + "type": "git", + "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", + "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db" + }, + "dist": { + "type": "zip", + "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.1.0 || ^4.0" + }, + "require-dev": { + "composer/composer": "*", + "php-parallel-lint/php-parallel-lint": "^1.3.1", + "phpcompatibility/php-compatibility": "^9.0" + }, + "type": "composer-plugin", + "extra": { + "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + }, + "autoload": { + "psr-4": { + "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Franck Nijhof", + "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", + "homepage": "http://www.dealerdirect.com", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcbf", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "support": { + "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", + "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" + }, + "time": "2022-02-04T12:51:07+00:00" + }, + { + "name": "php-stubs/wordpress-stubs", + "version": "v5.9.0", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/wordpress-stubs.git", + "reference": "0fa8dd9a1bd2a1b60e85afc6c798fca1f599cc1b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/0fa8dd9a1bd2a1b60e85afc6c798fca1f599cc1b", + "reference": "0fa8dd9a1bd2a1b60e85afc6c798fca1f599cc1b", + "shasum": "" + }, + "replace": { + "giacocorsiglia/wordpress-stubs": "*" + }, + "require-dev": { + "nikic/php-parser": "< 4.12.0", + "php": "~7.3 || ~8.0", + "php-stubs/generator": "^0.8.0", + "phpdocumentor/reflection-docblock": "^5.3", + "phpstan/phpstan": "^1.2" + }, + "suggest": { + "paragonie/sodium_compat": "Pure PHP implementation of libsodium", + "symfony/polyfill-php73": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "WordPress function and class declaration stubs for static analysis.", + "homepage": "https://github.com/php-stubs/wordpress-stubs", + "keywords": [ + "PHPStan", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/php-stubs/wordpress-stubs/issues", + "source": "https://github.com/php-stubs/wordpress-stubs/tree/v5.9.0" + }, + "time": "2022-01-26T00:27:45+00:00" + }, { "name": "phpcompatibility/php-compatibility", "version": "9.3.5", @@ -126,16 +301,16 @@ }, { "name": "phpcompatibility/phpcompatibility-wp", - "version": "2.1.1", + "version": "2.1.3", "source": { "type": "git", "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git", - "reference": "b7dc0cd7a8f767ccac5e7637550ea1c50a67b09e" + "reference": "d55de55f88697b9cdb94bccf04f14eb3b11cf308" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/b7dc0cd7a8f767ccac5e7637550ea1c50a67b09e", - "reference": "b7dc0cd7a8f767ccac5e7637550ea1c50a67b09e", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/d55de55f88697b9cdb94bccf04f14eb3b11cf308", + "reference": "d55de55f88697b9cdb94bccf04f14eb3b11cf308", "shasum": "" }, "require": { @@ -176,187 +351,151 @@ "issues": "https://github.com/PHPCompatibility/PHPCompatibilityWP/issues", "source": "https://github.com/PHPCompatibility/PHPCompatibilityWP" }, - "time": "2021-02-15T12:58:46+00:00" + "time": "2021-12-30T16:37:40+00:00" }, { - "name": "squizlabs/php_codesniffer", - "version": "3.6.0", + "name": "phpstan/extension-installer", + "version": "1.1.0", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625" + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ffced0d2c8fa8e6cdc4d695a743271fab6c38625", - "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/66c7adc9dfa38b6b5838a9fb728b68a7d8348051", + "reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051", "shasum": "" }, "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.4.0" + "composer-plugin-api": "^1.1 || ^2.0", + "php": "^7.1 || ^8.0", + "phpstan/phpstan": ">=0.11.6" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "composer/composer": "^1.8", + "phing/phing": "^2.16.3", + "php-parallel-lint/php-parallel-lint": "^1.2.0", + "phpstan/phpstan-strict-rules": "^0.11 || ^0.12" }, - "bin": [ - "bin/phpcs", - "bin/phpcbf" - ], - "type": "library", + "type": "composer-plugin", "extra": { - "branch-alias": { - "dev-master": "3.x-dev" + "class": "PHPStan\\ExtensionInstaller\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPStan\\ExtensionInstaller\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Greg Sherwood", - "role": "lead" - } - ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", - "keywords": [ - "phpcs", - "standards" + "MIT" ], + "description": "Composer plugin for automatic installation of PHPStan extensions", "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + "issues": "https://github.com/phpstan/extension-installer/issues", + "source": "https://github.com/phpstan/extension-installer/tree/1.1.0" }, - "time": "2021-04-09T00:54:41+00:00" - } - ], - "packages-dev": [ + "time": "2020-12-13T13:06:13+00:00" + }, { - "name": "automattic/vipwpcs", - "version": "2.3.2", + "name": "phpstan/phpstan", + "version": "1.4.6", "source": { "type": "git", - "url": "https://github.com/Automattic/VIP-Coding-Standards.git", - "reference": "efacebef421334d54b99afa92fb8fa645336a8a7" + "url": "https://github.com/phpstan/phpstan.git", + "reference": "8a7761f1c520e0dad6e04d862fdc697445457cfe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Automattic/VIP-Coding-Standards/zipball/efacebef421334d54b99afa92fb8fa645336a8a7", - "reference": "efacebef421334d54b99afa92fb8fa645336a8a7", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/8a7761f1c520e0dad6e04d862fdc697445457cfe", + "reference": "8a7761f1c520e0dad6e04d862fdc697445457cfe", "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", - "squizlabs/php_codesniffer": "^3.5.5", - "wp-coding-standards/wpcs": "^2.3" + "php": "^7.1|^8.0" }, - "require-dev": { - "php-parallel-lint/php-console-highlighter": "^0.5", - "php-parallel-lint/php-parallel-lint": "^1.0", - "phpcompatibility/php-compatibility": "^9", - "phpcsstandards/phpcsdevtools": "^1.0", - "phpunit/phpunit": "^4 || ^5 || ^6 || ^7" + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ] }, - "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "authors": [ + "description": "PHPStan - PHP Static Analysis Tool", + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/1.4.6" + }, + "funding": [ { - "name": "Contributors", - "homepage": "https://github.com/Automattic/VIP-Coding-Standards/graphs/contributors" + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpstan", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" } ], - "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress VIP minimum coding conventions", - "keywords": [ - "phpcs", - "standards", - "wordpress" - ], - "support": { - "issues": "https://github.com/Automattic/VIP-Coding-Standards/issues", - "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": "2022-02-06T12:56:13+00:00" }, { - "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v0.7.1", + "name": "poolshark/wp-graphql-stubs", + "version": "v0.0.2", "source": { "type": "git", - "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", - "reference": "fe390591e0241955f22eb9ba327d137e501c771c" + "url": "https://github.com/Poolshark/wp-graphql-stubs.git", + "reference": "66ba54188d04788849abd07bfc9fff511839cdb3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/fe390591e0241955f22eb9ba327d137e501c771c", - "reference": "fe390591e0241955f22eb9ba327d137e501c771c", + "url": "https://api.github.com/repos/Poolshark/wp-graphql-stubs/zipball/66ba54188d04788849abd07bfc9fff511839cdb3", + "reference": "66ba54188d04788849abd07bfc9fff511839cdb3", "shasum": "" }, - "require": { - "composer-plugin-api": "^1.0 || ^2.0", - "php": ">=5.3", - "squizlabs/php_codesniffer": "^2.0 || ^3.0 || ^4.0" - }, "require-dev": { - "composer/composer": "*", - "phpcompatibility/php-compatibility": "^9.0", - "sensiolabs/security-checker": "^4.1.0" - }, - "type": "composer-plugin", - "extra": { - "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" - }, - "autoload": { - "psr-4": { - "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" - } + "php": "^7.4" }, + "type": "library", "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { - "name": "Franck Nijhof", - "email": "franck.nijhof@dealerdirect.com", - "homepage": "http://www.frenck.nl", - "role": "Developer / IT Manager" + "name": "Flo Ragossnig", + "email": "florian@webleaders.at" } ], - "description": "PHP_CodeSniffer Standards Composer Installer Plugin", - "homepage": "http://www.dealerdirect.com", - "keywords": [ - "PHPCodeSniffer", - "PHP_CodeSniffer", - "code quality", - "codesniffer", - "composer", - "installer", - "phpcs", - "plugin", - "qa", - "quality", - "standard", - "standards", - "style guide", - "stylecheck", - "tests" - ], + "description": "WP GraphQL Stubs for VS Code and others.", "support": { - "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", - "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" + "issues": "https://github.com/Poolshark/wp-graphql-stubs/issues", + "source": "https://github.com/Poolshark/wp-graphql-stubs/tree/v0.0.2" }, - "time": "2020-12-07T18:04:37+00:00" + "time": "2021-03-20T07:43:55+00:00" }, { "name": "sirbrillig/phpcs-variable-analysis", @@ -411,6 +550,206 @@ }, "time": "2021-07-06T23:45:17+00:00" }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.6.2", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5e4e71592f69da17871dba6e80dd51bce74a351a", + "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", + "source": "https://github.com/squizlabs/PHP_CodeSniffer", + "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + }, + "time": "2021-12-12T21:44:58+00:00" + }, + { + "name": "symfony/polyfill-php73", + "version": "v1.24.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/cc5db0e22b3cb4111010e48785a97f670b350ca5", + "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php73/tree/v1.24.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-06-05T21:20:04+00:00" + }, + { + "name": "szepeviktor/phpstan-wordpress", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/szepeviktor/phpstan-wordpress.git", + "reference": "d44b5abcaa529698e138b2d21bc2a7cf9834039c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/d44b5abcaa529698e138b2d21bc2a7cf9834039c", + "reference": "d44b5abcaa529698e138b2d21bc2a7cf9834039c", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0", + "php-stubs/wordpress-stubs": "^4.7 || ^5.0", + "phpstan/phpstan": "^1.0", + "symfony/polyfill-php73": "^1.12.0" + }, + "require-dev": { + "composer/composer": "^1.10.23", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7", + "php-parallel-lint/php-parallel-lint": "^1.1", + "phpstan/phpstan-strict-rules": "^1.0", + "phpunit/phpunit": "^7 || ^9", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^0.6" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, + "autoload": { + "psr-4": { + "SzepeViktor\\PHPStan\\WordPress\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "WordPress extensions for PHPStan", + "keywords": [ + "PHPStan", + "code analyse", + "code analysis", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/szepeviktor/phpstan-wordpress/issues", + "source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v1.0.2" + }, + "funding": [ + { + "url": "https://www.paypal.me/szepeviktor", + "type": "custom" + } + ], + "time": "2021-11-19T12:47:11+00:00" + }, { "name": "wp-coding-standards/wpcs", "version": "2.3.0", @@ -468,7 +807,9 @@ "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, - "platform": [], + "platform": { + "php": ">=7.4" + }, "platform-dev": [], - "plugin-api-version": "2.1.0" + "plugin-api-version": "2.2.0" } diff --git a/phpcs.xml b/phpcs.xml index 2c18f8c..f4367f1 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,29 +1,63 @@ - + Coding standards for the WPGraphQL Yoast SEO plugin - + . */.git/* */vendor/* */wp-content/* - + + + - + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + - \ No newline at end of file + + + + + + + diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..698aac3 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,17 @@ +parameters: + level: 8 + inferPrivatePropertyTypeFromConstructor: true + checkMissingIterableValueType: false + featureToggles: + disableRuntimeReflectionProvider: true + bootstrapFiles: + - phpstan/constants.php + - wp-graphql-yoast-seo.php + paths: + - wp-graphql-yoast.php + - src/ + scanDirectories: + - ../wp-graphql/ + - ../wordpress-seo/ + ignoreErrors: + - '#^Function apply_filters(_ref_array)? invoked with ([1-9]|1[0-2]) parameters, 2 required\.$#' From b4ce91dc896198736408d40115833087a8684e4d Mon Sep 17 00:00:00 2001 From: Dovid Levine Date: Sun, 13 Feb 2022 15:47:41 +0000 Subject: [PATCH 06/13] chore: implement PHP Interfaces --- src/Interfaces/Field.php | 24 ++++++++++++++++++++++++ src/Interfaces/Registerable.php | 23 +++++++++++++++++++++++ src/Interfaces/Type.php | 20 ++++++++++++++++++++ src/Interfaces/TypeWithFields.php | 20 ++++++++++++++++++++ 4 files changed, 87 insertions(+) create mode 100644 src/Interfaces/Field.php create mode 100644 src/Interfaces/Registerable.php create mode 100644 src/Interfaces/Type.php create mode 100644 src/Interfaces/TypeWithFields.php diff --git a/src/Interfaces/Field.php b/src/Interfaces/Field.php new file mode 100644 index 0000000..0aa5bd3 --- /dev/null +++ b/src/Interfaces/Field.php @@ -0,0 +1,24 @@ + Date: Sat, 19 Feb 2022 14:55:26 +0000 Subject: [PATCH 07/13] chore: base plugin refactor --- access-functions.php | 85 + phpcs.xml | 2 +- phpstan.neon.dist | 5 +- .../PostTypeToTermNodeConnectionEdge.php | 81 + src/CoreSchemaFilters.php | 82 + src/Interfaces/Hookable.php | 21 + .../{Registerable.php => Registrable.php} | 0 src/Seo.php | 100 ++ src/Type/Enum/SEOCardTypeEnum.php | 59 + src/Type/WPInterface/ContentNodeWithSEO.php | 232 +++ src/Type/WPInterface/SEOBaseFields.php | 82 + src/Type/WPInterface/TermNodeWithSEO.php | 198 +++ src/Type/WPObject/Config/Breadcrumbs.php | 64 + .../Config/ContentType/ContentType.php | 62 + src/Type/WPObject/Config/ContentTypes.php | 70 + src/Type/WPObject/Config/OpenGraph.php | 58 + .../WPObject/Config/OpenGraph/FrontPage.php | 61 + src/Type/WPObject/Config/Redirect.php | 62 + src/Type/WPObject/Config/Schema.php | 66 + src/Type/WPObject/Config/Social.php | 64 + src/Type/WPObject/Config/Social/Facebook.php | 58 + src/Type/WPObject/Config/Social/Instagram.php | 57 + src/Type/WPObject/Config/Social/LinkedIn.php | 57 + src/Type/WPObject/Config/Social/MySpace.php | 57 + src/Type/WPObject/Config/Social/Pinterest.php | 58 + src/Type/WPObject/Config/Social/Twitter.php | 59 + src/Type/WPObject/Config/Social/Wikipedia.php | 57 + src/Type/WPObject/Config/Social/Youtube.php | 57 + src/Type/WPObject/Config/Webmaster.php | 59 + src/Type/WPObject/ContentType/Archive.php | 62 + src/Type/WPObject/PageInfo/Schema.php | 56 + src/Type/WPObject/PostType/Schema.php | 58 + src/Type/WPObject/PostTypeSEO.php | 61 + src/Type/WPObject/SEOConfig.php | 351 ++++ src/Type/WPObject/SEOPostTypeBreadcrumbs.php | 58 + src/Type/WPObject/SEOPostTypePageInfo.php | 87 + src/Type/WPObject/SEOUser.php | 207 +++ src/Type/WPObject/Taxonomy/Schema.php | 56 + src/Type/WPObject/TaxonomySEO.php | 59 + src/Type/WPObject/User/Schema.php | 58 + src/Type/WPObject/User/Social.php | 65 + src/TypeRegistry.php | 156 ++ wp-graphql-yoast-seo.php | 1405 ++--------------- 43 files changed, 3397 insertions(+), 1315 deletions(-) create mode 100644 access-functions.php create mode 100644 src/Connection/PostTypeToTermNodeConnectionEdge.php create mode 100644 src/CoreSchemaFilters.php create mode 100644 src/Interfaces/Hookable.php rename src/Interfaces/{Registerable.php => Registrable.php} (100%) create mode 100644 src/Seo.php create mode 100644 src/Type/Enum/SEOCardTypeEnum.php create mode 100644 src/Type/WPInterface/ContentNodeWithSEO.php create mode 100644 src/Type/WPInterface/SEOBaseFields.php create mode 100644 src/Type/WPInterface/TermNodeWithSEO.php create mode 100644 src/Type/WPObject/Config/Breadcrumbs.php create mode 100644 src/Type/WPObject/Config/ContentType/ContentType.php create mode 100644 src/Type/WPObject/Config/ContentTypes.php create mode 100644 src/Type/WPObject/Config/OpenGraph.php create mode 100644 src/Type/WPObject/Config/OpenGraph/FrontPage.php create mode 100644 src/Type/WPObject/Config/Redirect.php create mode 100644 src/Type/WPObject/Config/Schema.php create mode 100644 src/Type/WPObject/Config/Social.php create mode 100644 src/Type/WPObject/Config/Social/Facebook.php create mode 100644 src/Type/WPObject/Config/Social/Instagram.php create mode 100644 src/Type/WPObject/Config/Social/LinkedIn.php create mode 100644 src/Type/WPObject/Config/Social/MySpace.php create mode 100644 src/Type/WPObject/Config/Social/Pinterest.php create mode 100644 src/Type/WPObject/Config/Social/Twitter.php create mode 100644 src/Type/WPObject/Config/Social/Wikipedia.php create mode 100644 src/Type/WPObject/Config/Social/Youtube.php create mode 100644 src/Type/WPObject/Config/Webmaster.php create mode 100644 src/Type/WPObject/ContentType/Archive.php create mode 100644 src/Type/WPObject/PageInfo/Schema.php create mode 100644 src/Type/WPObject/PostType/Schema.php create mode 100644 src/Type/WPObject/PostTypeSEO.php create mode 100644 src/Type/WPObject/SEOConfig.php create mode 100644 src/Type/WPObject/SEOPostTypeBreadcrumbs.php create mode 100644 src/Type/WPObject/SEOPostTypePageInfo.php create mode 100644 src/Type/WPObject/SEOUser.php create mode 100644 src/Type/WPObject/Taxonomy/Schema.php create mode 100644 src/Type/WPObject/TaxonomySEO.php create mode 100644 src/Type/WPObject/User/Schema.php create mode 100644 src/Type/WPObject/User/Social.php create mode 100644 src/TypeRegistry.php diff --git a/access-functions.php b/access-functions.php new file mode 100644 index 0000000..5acf7fa --- /dev/null +++ b/access-functions.php @@ -0,0 +1,85 @@ + - + diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 698aac3..aa48a81 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -5,10 +5,11 @@ parameters: featureToggles: disableRuntimeReflectionProvider: true bootstrapFiles: - - phpstan/constants.php + - access-functions.php - wp-graphql-yoast-seo.php paths: - - wp-graphql-yoast.php + - access-functions.php + - wp-graphql-yoast-seo.php - src/ scanDirectories: - ../wp-graphql/ diff --git a/src/Connection/PostTypeToTermNodeConnectionEdge.php b/src/Connection/PostTypeToTermNodeConnectionEdge.php new file mode 100644 index 0000000..d6bf00b --- /dev/null +++ b/src/Connection/PostTypeToTermNodeConnectionEdge.php @@ -0,0 +1,81 @@ +graphql_single_name ) ) { + continue; + } + + $post_name_key = wp_gql_seo_get_field_key( $post_type_object->graphql_single_name ); + + $taxonomies = get_object_taxonomies( $post_type, 'objects' ); + + foreach ( $taxonomies as $tax ) { + // Skip if not a hierarchical taxonomy registered to GraphQL. + if ( ! isset( $tax->hierarchical ) && ! isset( $tax->graphql_single_name ) ) { + continue; + } + + $name = sprintf( + '%sTo%sConnectionEdge', + ucfirst( $post_name_key ), + ucfirst( $tax->graphql_single_name ) + ); + + register_graphql_field( + $name, + 'isPrimary', + [ + 'type' => 'Boolean', + // translators: Taxonomy name. + 'description' => sprintf( __( 'The Yoast SEO primary %s.', 'wp-graphql-yoast-seo' ), $tax->labels->name ), + 'resolve' => static function( $item, array $args, AppContext $context ) use ( $tax ) { + $post_id = $item['source']->ID; + $term_id = $item['node']->term_id; + + $wpseo_primary_term = new WPSEO_Primary_Term( $tax->name, $post_id ); + $primary_tax_id = $wpseo_primary_term->get_primary_term(); + + return $primary_tax_id === $term_id; + }, + ] + ); + } + } + } + +} diff --git a/src/CoreSchemaFilters.php b/src/CoreSchemaFilters.php new file mode 100644 index 0000000..d404531 --- /dev/null +++ b/src/CoreSchemaFilters.php @@ -0,0 +1,82 @@ +includes(); + self::$instance->setup(); + } + + /** + * Fire off init action + * + * @param Seo $instance The instance of the Seo class + */ + do_action( 'graphql_seo_init', self::$instance ); + + /** + * Return the Seo Instance + */ + return self::$instance; + } + /** + * Throw error on object clone. + * The whole idea of the singleton design pattern is that there is a single object + * therefore, we don't want the object to be cloned. + * + * @since @todo + * @access public + * @return void + */ + public function __clone() { + // Cloning instances of the class is forbidden. + _doing_it_wrong( __FUNCTION__, esc_html__( 'WPGraphQL/YoastSEO/Seo class should not be cloned.', 'wp-graphql-yoast-seo' ), '@todo' ); + } + + /** + * Disable unserializing of the class. + * + * @since @todo + * @access protected + * @return void + */ + public function __wakeup() : void { + // De-serializing instances of the class is forbidden. + _doing_it_wrong( __FUNCTION__, esc_html__( 'De-serializing instances of the WPGraphQL/YoastSEO/Seo class is not allowed', 'wp-graphql-yoast-seo' ), '@todo' ); + } + + /** + * Include required files. + * Uses composer's autoload + * + * @access private + * @since @todo + */ + private function includes() : void { + /** + * Autoload Required Classes + */ + if ( defined( 'WPGRAPHQL_SEO_AUTOLOAD' ) && false !== WPGRAPHQL_SEO_AUTOLOAD && defined( 'WPGRAPHQL_SEO_PLUGIN_DIR' ) ) { + require_once WPGRAPHQL_SEO_PLUGIN_DIR . 'vendor/autoload.php'; + } + } + + /** + * Sets up the schema. + */ + private function setup() : void { + CoreSchemaFilters::register_hooks(); + add_action( get_graphql_register_action(), [ TypeRegistry::class, 'init' ] ); + } + } +endif; diff --git a/src/Type/Enum/SEOCardTypeEnum.php b/src/Type/Enum/SEOCardTypeEnum.php new file mode 100644 index 0000000..9e2f713 --- /dev/null +++ b/src/Type/Enum/SEOCardTypeEnum.php @@ -0,0 +1,59 @@ + static::get_description(), + 'values' => static::get_values(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'Types of cards', 'wp-graphql-yoast-seo' ); + } + + /** + * Gets the Enum type values. + */ + public static function get_values() : array { + return [ + 'summary_large_image' => [ + 'value' => 'summary_large_image', + ], + 'summary' => [ + 'value' => 'summary', + ], + ]; + } +} diff --git a/src/Type/WPInterface/ContentNodeWithSEO.php b/src/Type/WPInterface/ContentNodeWithSEO.php new file mode 100644 index 0000000..887c82f --- /dev/null +++ b/src/Type/WPInterface/ContentNodeWithSEO.php @@ -0,0 +1,232 @@ + self::get_description(), + 'fields' => self::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'A node that can have Yoast SEO data assigned to it.', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + return [ + 'seo' => [ + 'type' => PostTypeSEO::$type, + 'resolve' => static function( $post, array $args, AppContext $context ) { + // Base array. + $seo = []; + + $map = [ + '@id' => 'id', + '@type' => 'type', + '@graph' => 'graph', + '@context' => 'context', + ]; + + $schemaArray = YoastSEO()->meta->for_post( $post->ID ) + ->schema; + + // https://developer.yoast.com/blog/yoast-seo-14-0-using-yoast-seo-surfaces/ + $robots = YoastSEO()->meta->for_post( $post->ID ) + ->robots; + + // Get data + $seo = [ + 'title' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID )->title + ), + 'metaDesc' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->description + ), + 'focuskw' => wp_gql_seo_format_string( + get_post_meta( + $post->ID, + '_yoast_wpseo_focuskw', + true + ) + ), + 'metaKeywords' => wp_gql_seo_format_string( + get_post_meta( + $post->ID, + '_yoast_wpseo_metakeywords', + true + ) + ), + 'metaRobotsNoindex' => $robots['index'], + 'metaRobotsNofollow' => $robots['follow'], + 'opengraphTitle' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->open_graph_title + ), + 'opengraphUrl' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->open_graph_url + ), + 'opengraphSiteName' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->open_graph_site_name + ), + 'opengraphType' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->open_graph_type + ), + 'opengraphAuthor' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->open_graph_article_author + ), + 'opengraphPublisher' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->open_graph_article_publisher + ), + 'opengraphPublishedTime' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->open_graph_article_published_time + ), + 'opengraphModifiedTime' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->open_graph_article_modified_time + ), + 'opengraphDescription' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->open_graph_description + ), + 'opengraphImage' => function () use ( + $post, + $context + ) { + $id = wp_gql_seo_get_og_image( + YoastSEO()->meta->for_post( $post->ID ) + ->open_graph_images + ); + + return $context + ->get_loader( 'post' ) + ->load_deferred( absint( $id ) ); + }, + 'twitterCardType' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->twitter_card + ), + 'twitterTitle' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->twitter_title + ), + 'twitterDescription' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->twitter_description + ), + 'twitterImage' => function () use ( + $post, + $context + ) { + $id = wpcom_vip_attachment_url_to_postid( + YoastSEO()->meta->for_post( $post->ID ) + ->twitter_image + ); + + return $context + ->get_loader( 'post' ) + ->load_deferred( absint( $id ) ); + }, + 'canonical' => wp_gql_seo_format_string( + YoastSEO()->meta->for_post( $post->ID ) + ->canonical + ), + 'readingTime' => floatval( + YoastSEO()->meta->for_post( $post->ID ) + ->estimated_reading_time_minutes + ), + 'breadcrumbs' => YoastSEO()->meta->for_post( + $post->ID + )->breadcrumbs, + 'cornerstone' => boolval( + YoastSEO()->meta->for_post( $post->ID ) + ->indexable->is_cornerstone + ), + 'fullHead' => is_string( + YoastSEO() + ->meta->for_post( $post->ID ) + ->get_head() + ) + ? YoastSEO() + ->meta->for_post( $post->ID ) + ->get_head() + : YoastSEO() + ->meta->for_post( $post->ID ) + ->get_head()->html, + 'schema' => [ + 'pageType' => is_array( + YoastSEO()->meta->for_post( $post->ID ) + ->schema_page_type + ) + ? YoastSEO()->meta->for_post( $post->ID ) + ->schema_page_type + : [], + 'articleType' => is_array( + YoastSEO()->meta->for_post( $post->ID ) + ->schema_article_type + ) + ? YoastSEO()->meta->for_post( $post->ID ) + ->schema_article_type + : [], + 'raw' => json_encode( + $schemaArray, + JSON_UNESCAPED_SLASHES + ), + ], + ]; + + return ! empty( $seo ) ? $seo : null; + }, + ], + ]; + } +} diff --git a/src/Type/WPInterface/SEOBaseFields.php b/src/Type/WPInterface/SEOBaseFields.php new file mode 100644 index 0000000..dda2700 --- /dev/null +++ b/src/Type/WPInterface/SEOBaseFields.php @@ -0,0 +1,82 @@ + self::get_description(), + 'fields' => self::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'Base SEO Fields.', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + return [ + 'title' => [ 'type' => 'String' ], + 'metaDesc' => [ 'type' => 'String' ], + 'focuskw' => [ 'type' => 'String' ], + 'metaKeywords' => [ 'type' => 'String' ], + 'metaRobotsNoindex' => [ 'type' => 'String' ], + 'metaRobotsNofollow' => [ 'type' => 'String' ], + 'opengraphTitle' => [ 'type' => 'String' ], + 'opengraphUrl' => [ 'type' => 'String' ], + 'opengraphSiteName' => [ 'type' => 'String' ], + 'opengraphType' => [ 'type' => 'String' ], + 'opengraphAuthor' => [ 'type' => 'String' ], + 'opengraphPublisher' => [ 'type' => 'String' ], + 'opengraphPublishedTime' => [ 'type' => 'String' ], + 'opengraphModifiedTime' => [ 'type' => 'String' ], + 'opengraphDescription' => [ 'type' => 'String' ], + 'opengraphImage' => [ 'type' => 'MediaItem' ], + 'twitterTitle' => [ 'type' => 'String' ], + 'twitterDescription' => [ 'type' => 'String' ], + 'twitterImage' => [ 'type' => 'MediaItem' ], + 'canonical' => [ 'type' => 'String' ], + 'breadcrumbs' => [ 'type' => [ 'list_of' => SEOPostTypeBreadcrumbs::$type ] ], + 'cornerstone' => [ 'type' => 'Boolean' ], + 'fullHead' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPInterface/TermNodeWithSEO.php b/src/Type/WPInterface/TermNodeWithSEO.php new file mode 100644 index 0000000..c1bf548 --- /dev/null +++ b/src/Type/WPInterface/TermNodeWithSEO.php @@ -0,0 +1,198 @@ + self::get_description(), + 'fields' => self::get_fields(), + ] + ); + + // self::register_field(); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'A term node that can have Yoast SEO data assigned to it.', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + return [ + 'seo' => [ + 'type' => TaxonomySEO::$type, + 'resolve' => static function( $term, array $args, AppContext $context ) { + $term_obj = get_term( $term->term_id ); + + $meta = WPSEO_Taxonomy_Meta::get_term_meta( + (int) $term_obj->term_id, + $term_obj->taxonomy + ); + $robots = YoastSEO()->meta->for_term( $term->term_id )->robots; + + $schemaArray = YoastSEO()->meta->for_term( $term->term_id ) + ->schema; + + // Get data + $seo = [ + 'title' => wp_gql_seo_format_string( + html_entity_decode( + wp_strip_all_tags( + YoastSEO()->meta->for_term( $term->term_id ) + ->title + ) + ) + ), + 'metaDesc' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->description + ), + 'focuskw' => isset( $meta['wpseo_focuskw'] ) + ? wp_gql_seo_format_string( $meta['wpseo_focuskw'] ) + : $meta['wpseo_focuskw'], + 'metaKeywords' => isset( $meta['wpseo_metakeywords'] ) + ? wp_gql_seo_format_string( + $meta['wpseo_metakeywords'] + ) + : null, + 'metaRobotsNoindex' => $robots['index'], + 'metaRobotsNofollow' => $robots['follow'], + 'opengraphTitle' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->open_graph_title + ), + 'opengraphUrl' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->open_graph_url + ), + 'opengraphSiteName' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->open_graph_site_name + ), + 'opengraphType' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->open_graph_type + ), + 'opengraphAuthor' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->open_graph_article_author + ), + 'opengraphPublisher' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->open_graph_article_publisher + ), + 'opengraphPublishedTime' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->open_graph_article_published_time + ), + 'opengraphModifiedTime' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->open_graph_article_modified_time + ), + 'opengraphDescription' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->open_graph_description + ), + 'opengraphImage' => $context + ->get_loader( 'post' ) + ->load_deferred( + absint( $meta['wpseo_opengraph-image-id'] ) + ), + 'twitterCardType' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->twitter_card + ), + 'twitterTitle' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->twitter_title + ), + 'twitterDescription' => wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->twitter_description + ), + 'twitterImage' => $context + ->get_loader( 'post' ) + ->load_deferred( + absint( $meta['wpseo_twitter-image-id'] ) + ), + 'canonical' => isset( + YoastSEO()->meta->for_term( $term->term_id )->canonical + ) + ? wp_gql_seo_format_string( + YoastSEO()->meta->for_term( $term->term_id ) + ->canonical + ) + : null, + 'breadcrumbs' => YoastSEO()->meta->for_term( + $term->term_id + )->breadcrumbs, + 'cornerstone' => boolval( + YoastSEO()->meta->for_term( $term->term_id ) + ->is_cornerstone + ), + 'fullHead' => is_string( + YoastSEO() + ->meta->for_term( $term->term_id ) + ->get_head() + ) + ? YoastSEO() + ->meta->for_term( $term->term_id ) + ->get_head() + : YoastSEO() + ->meta->for_term( $term->term_id ) + ->get_head()->html, + 'schema' => [ + 'raw' => json_encode( + $schemaArray, + JSON_UNESCAPED_SLASHES + ), + ], + ]; + wp_reset_query(); + + return ! empty( $seo ) ? $seo : null; + }, + ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Breadcrumbs.php b/src/Type/WPObject/Config/Breadcrumbs.php new file mode 100644 index 0000000..d080716 --- /dev/null +++ b/src/Type/WPObject/Config/Breadcrumbs.php @@ -0,0 +1,64 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Yoast SEO breadcrumb config', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'enabled' => [ 'type' => 'Boolean' ], + 'boldLast' => [ 'type' => 'Boolean' ], + 'showBlogPage' => [ 'type' => 'Boolean' ], + 'notFoundText' => [ 'type' => 'String' ], + 'archivePrefix' => [ 'type' => 'String' ], + 'homeText' => [ 'type' => 'String' ], + 'prefix' => [ 'type' => 'String' ], + 'searchPrefix' => [ 'type' => 'String' ], + 'separator' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/Config/ContentType/ContentType.php b/src/Type/WPObject/Config/ContentType/ContentType.php new file mode 100644 index 0000000..f325770 --- /dev/null +++ b/src/Type/WPObject/Config/ContentType/ContentType.php @@ -0,0 +1,62 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Yoast SEO search appearance content types fields', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'title' => [ 'type' => 'String' ], + 'metaDesc' => [ 'type' => 'String' ], + 'metaRobotsNoindex' => [ 'type' => 'Boolean' ], + 'schemaType' => [ 'type' => 'String' ], + 'schema' => [ 'type' => 'SEOPageInfoSchema' ], + 'archive' => [ 'type' => Archive::$type ], + ]; + } +} diff --git a/src/Type/WPObject/Config/ContentTypes.php b/src/Type/WPObject/Config/ContentTypes.php new file mode 100644 index 0000000..f7f466e --- /dev/null +++ b/src/Type/WPObject/Config/ContentTypes.php @@ -0,0 +1,70 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Yoast SEO search appearance content types', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + $post_types = WPGraphQL::get_allowed_post_types(); + + return self::build_content_types( $post_types ); + } + + private static function build_content_types( $types ) : array { + $carry = []; + + foreach ( $types as $type ) { + $post_type_object = get_post_type_object( $type ); + if ( $post_type_object->graphql_single_name ) { + $carry[ wp_gql_seo_get_field_key( $post_type_object->graphql_single_name ) ] = [ 'type' => ContentType::$type ]; + } + } + + return $carry; + } +} diff --git a/src/Type/WPObject/Config/OpenGraph.php b/src/Type/WPObject/Config/OpenGraph.php new file mode 100644 index 0000000..98853db --- /dev/null +++ b/src/Type/WPObject/Config/OpenGraph.php @@ -0,0 +1,58 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Open Graph data', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'defaultImage' => [ 'type' => 'MediaItem' ], + 'frontPage' => [ 'type' => FrontPage::$type ], + ]; + } +} diff --git a/src/Type/WPObject/Config/OpenGraph/FrontPage.php b/src/Type/WPObject/Config/OpenGraph/FrontPage.php new file mode 100644 index 0000000..fffecd1 --- /dev/null +++ b/src/Type/WPObject/Config/OpenGraph/FrontPage.php @@ -0,0 +1,61 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Open Graph Front page data', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'title' => [ 'type' => 'String' ], + 'description' => [ 'type' => 'String' ], + 'image' => [ 'type' => 'MediaItem' ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Redirect.php b/src/Type/WPObject/Config/Redirect.php new file mode 100644 index 0000000..a8d46ca --- /dev/null +++ b/src/Type/WPObject/Config/Redirect.php @@ -0,0 +1,62 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Yoast redirect data (Yoast Premium only)', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'origin' => [ 'type' => 'String' ], + 'target' => [ 'type' => 'String' ], + 'type' => [ 'type' => 'Int' ], + 'format' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Schema.php b/src/Type/WPObject/Config/Schema.php new file mode 100644 index 0000000..841f658 --- /dev/null +++ b/src/Type/WPObject/Config/Schema.php @@ -0,0 +1,66 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Yoast SEO schema data', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'companyName' => [ 'type' => 'String' ], + 'personName' => [ 'type' => 'String' ], + 'companyOrPerson' => [ 'type' => 'String' ], + 'companyLogo' => [ 'type' => 'MediaItem' ], + 'personLogo' => [ 'type' => 'MediaItem' ], + 'logo' => [ 'type' => 'MediaItem' ], + 'siteName' => [ 'type' => 'String' ], + 'wordpressSiteName' => [ 'type' => 'String' ], + 'siteUrl' => [ 'type' => 'String' ], + 'homeUrl' => [ 'type' => 'String' ], + 'inLanguage' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Social.php b/src/Type/WPObject/Config/Social.php new file mode 100644 index 0000000..2facfbd --- /dev/null +++ b/src/Type/WPObject/Config/Social.php @@ -0,0 +1,64 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Yoast SEO Social media links', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'facebook' => [ 'type' => SEOSocial\Facebook::$type ], + 'twitter' => [ 'type' => SEOSocial\Twitter::$type ], + 'instagram' => [ 'type' => SEOSocial\Instagram::$type ], + 'linkedIn' => [ 'type' => SEOSocial\LinkedIn::$type ], + 'mySpace' => [ 'type' => SEOSocial\MySpace::$type ], + 'pinterest' => [ 'type' => SEOSocial\Pinterest::$type ], + 'youTube' => [ 'type' => SEOSocial\Youtube::$type ], + 'wikipedia' => [ 'type' => SEOSocial\Wikipedia::$type ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Social/Facebook.php b/src/Type/WPObject/Config/Social/Facebook.php new file mode 100644 index 0000000..7298a9c --- /dev/null +++ b/src/Type/WPObject/Config/Social/Facebook.php @@ -0,0 +1,58 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + // @todo update description + return __( 'The Yoast SEO webmaster fields', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'url' => [ 'type' => 'String' ], + 'defaultImage' => [ 'type' => 'MediaItem' ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Social/Instagram.php b/src/Type/WPObject/Config/Social/Instagram.php new file mode 100644 index 0000000..c940fd3 --- /dev/null +++ b/src/Type/WPObject/Config/Social/Instagram.php @@ -0,0 +1,57 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + // @todo update description + return __( 'The Yoast SEO webmaster fields', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'url' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Social/LinkedIn.php b/src/Type/WPObject/Config/Social/LinkedIn.php new file mode 100644 index 0000000..2ce9277 --- /dev/null +++ b/src/Type/WPObject/Config/Social/LinkedIn.php @@ -0,0 +1,57 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + // @todo update description + return __( 'The Yoast SEO webmaster fields', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'url' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Social/MySpace.php b/src/Type/WPObject/Config/Social/MySpace.php new file mode 100644 index 0000000..7c039b8 --- /dev/null +++ b/src/Type/WPObject/Config/Social/MySpace.php @@ -0,0 +1,57 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + // @todo update description + return __( 'The Yoast SEO webmaster fields', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'url' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Social/Pinterest.php b/src/Type/WPObject/Config/Social/Pinterest.php new file mode 100644 index 0000000..9f8ace8 --- /dev/null +++ b/src/Type/WPObject/Config/Social/Pinterest.php @@ -0,0 +1,58 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + // @todo update description + return __( 'The Yoast SEO webmaster fields', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'url' => [ 'type' => 'String' ], + 'metaTag' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Social/Twitter.php b/src/Type/WPObject/Config/Social/Twitter.php new file mode 100644 index 0000000..9d1e271 --- /dev/null +++ b/src/Type/WPObject/Config/Social/Twitter.php @@ -0,0 +1,59 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + // @todo update description + return __( 'The Yoast SEO webmaster fields', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'username' => [ 'type' => 'String' ], + 'cardType' => [ 'type' => SEOCardTypeEnum::$type ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Social/Wikipedia.php b/src/Type/WPObject/Config/Social/Wikipedia.php new file mode 100644 index 0000000..b03c8a6 --- /dev/null +++ b/src/Type/WPObject/Config/Social/Wikipedia.php @@ -0,0 +1,57 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + // @todo update description + return __( 'The Yoast SEO webmaster fields', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'url' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Social/Youtube.php b/src/Type/WPObject/Config/Social/Youtube.php new file mode 100644 index 0000000..5aa1799 --- /dev/null +++ b/src/Type/WPObject/Config/Social/Youtube.php @@ -0,0 +1,57 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + // @todo update description + return __( 'The Yoast SEO webmaster fields', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'url' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/Config/Webmaster.php b/src/Type/WPObject/Config/Webmaster.php new file mode 100644 index 0000000..c8550ba --- /dev/null +++ b/src/Type/WPObject/Config/Webmaster.php @@ -0,0 +1,59 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Yoast SEO webmaster fields', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'baiduVerify' => [ 'type' => 'String' ], + 'googleVerify' => [ 'type' => 'String' ], + 'msVerify' => [ 'type' => 'String' ], + 'yandexVerify' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/ContentType/Archive.php b/src/Type/WPObject/ContentType/Archive.php new file mode 100644 index 0000000..fa85fd4 --- /dev/null +++ b/src/Type/WPObject/ContentType/Archive.php @@ -0,0 +1,62 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Yoast SEO search appearance content types fields.', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'hasArchive' => [ 'type' => 'Boolean' ], + 'title' => [ 'type' => 'String' ], + 'archiveLink' => [ 'type' => 'String' ], + 'metaDesc' => [ 'type' => 'String' ], + 'metaRobotsNoindex' => [ 'type' => 'Boolean' ], + 'breadcrumbTitle' => [ 'type' => 'String' ], + 'fullHead' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/PageInfo/Schema.php b/src/Type/WPObject/PageInfo/Schema.php new file mode 100644 index 0000000..599cb18 --- /dev/null +++ b/src/Type/WPObject/PageInfo/Schema.php @@ -0,0 +1,56 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Schema for post type.', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'raw' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/PostType/Schema.php b/src/Type/WPObject/PostType/Schema.php new file mode 100644 index 0000000..883119d --- /dev/null +++ b/src/Type/WPObject/PostType/Schema.php @@ -0,0 +1,58 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Schema types', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'pageType' => [ 'type' => [ 'list_of' => 'String' ] ], + 'articleType' => [ 'type' => [ 'list_of' => 'String' ] ], + 'raw' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/PostTypeSEO.php b/src/Type/WPObject/PostTypeSEO.php new file mode 100644 index 0000000..649c1a3 --- /dev/null +++ b/src/Type/WPObject/PostTypeSEO.php @@ -0,0 +1,61 @@ + static::get_description(), + 'interfaces' => [ SEOBaseFields::$type ], + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Yoast SEO data for the type.', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'readingTime' => [ 'type' => 'Float' ], + 'schema' => [ 'type' => Schema::$type ], + ]; + } +} diff --git a/src/Type/WPObject/SEOConfig.php b/src/Type/WPObject/SEOConfig.php new file mode 100644 index 0000000..18bebed --- /dev/null +++ b/src/Type/WPObject/SEOConfig.php @@ -0,0 +1,351 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + + self::register_field(); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Yoast SEO site level configuration data.', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'schema' => [ 'type' => Config\Schema::$type ], + 'webmaster' => [ 'type' => Config\Webmaster::$type ], + 'social' => [ 'type' => Config\Social::$type ], + 'breadcrumbs' => [ 'type' => Config\Breadcrumbs::$type ], + 'redirects' => [ + 'type' => [ 'list_of' => Config\Redirect::$type ], + ], + 'openGraph' => [ 'type' => Config\OpenGraph::$type ], + 'contentTypes' => [ 'type' => Config\ContentTypes::$type ], + ]; + } + + /** + * {@inheritDoc} + */ + public static function register_field() : void { + $post_types = \WPGraphQL::get_allowed_post_types(); + + register_graphql_field( + 'RootQuery', + static::$fieldname, + [ + 'type' => static::$type, + 'description' => __( 'Returns seo site data.', 'wp-graphql-yoast-seo' ), + 'resolve' => static function ( $source, array $args, AppContext $context ) use ( $post_types ) { + $wpseo_options = WPSEO_Options::get_instance(); + $all = $wpseo_options->get_all(); + + $redirects_obj = class_exists( 'WPSEO_Redirect_Option' ) ? new WPSEO_Redirect_Option() : false; + $redirects = $redirects_obj ? $redirects_obj->get_from_option() : []; + + $user_id = $all['company_or_person_user_id']; + $user = get_userdata( $user_id ); + + $mappedRedirects = function ( $value ) { + return [ + 'origin' => $value['origin'], + 'target' => $value['url'], + 'type' => $value['type'], + 'format' => $value['format'], + ]; + }; + + $contentTypes = self::build_content_type_data( $post_types, $all ); + + return [ + 'contentTypes' => $contentTypes, + 'webmaster' => [ + 'baiduVerify' => wp_gql_seo_format_string( + $all['baiduverify'] + ), + 'googleVerify' => wp_gql_seo_format_string( + $all['googleverify'] + ), + 'msVerify' => wp_gql_seo_format_string( $all['msverify'] ), + 'yandexVerify' => wp_gql_seo_format_string( + $all['yandexverify'] + ), + ], + 'social' => [ + 'facebook' => [ + 'url' => wp_gql_seo_format_string( $all['facebook_site'] ), + 'defaultImage' => $context + ->get_loader( 'post' ) + ->load_deferred( $all['og_default_image_id'] ), + ], + 'twitter' => [ + 'username' => wp_gql_seo_format_string( + $all['twitter_site'] + ), + 'cardType' => wp_gql_seo_format_string( + $all['twitter_card_type'] + ), + ], + 'instagram' => [ + 'url' => wp_gql_seo_format_string( $all['instagram_url'] ), + ], + 'linkedIn' => [ + 'url' => wp_gql_seo_format_string( $all['linkedin_url'] ), + ], + 'mySpace' => [ + 'url' => wp_gql_seo_format_string( $all['myspace_url'] ), + ], + 'pinterest' => [ + 'url' => wp_gql_seo_format_string( $all['pinterest_url'] ), + 'metaTag' => wp_gql_seo_format_string( + $all['pinterestverify'] + ), + ], + 'youTube' => [ + 'url' => wp_gql_seo_format_string( $all['youtube_url'] ), + ], + 'wikipedia' => [ + 'url' => wp_gql_seo_format_string( $all['wikipedia_url'] ), + ], + ], + 'breadcrumbs' => [ + 'enabled' => wp_gql_seo_format_string( + $all['breadcrumbs-enable'] + ), + 'boldLast' => wp_gql_seo_format_string( + $all['breadcrumbs-boldlast'] + ), + 'showBlogPage' => wp_gql_seo_format_string( + $all['breadcrumbs-display-blog-page'] + ), + 'archivePrefix' => wp_gql_seo_format_string( + $all['breadcrumbs-archiveprefix'] + ), + 'prefix' => wp_gql_seo_format_string( + $all['breadcrumbs-prefix'] + ), + 'notFoundText' => wp_gql_seo_format_string( + $all['breadcrumbs-404crumb'] + ), + 'homeText' => wp_gql_seo_format_string( + $all['breadcrumbs-home'] + ), + 'searchPrefix' => wp_gql_seo_format_string( + $all['breadcrumbs-searchprefix'] + ), + 'separator' => wp_gql_seo_format_string( + $all['breadcrumbs-sep'] + ), + ], + 'schema' => [ + 'companyName' => wp_gql_seo_format_string( + $all['company_name'] + ), + 'personName' => wp_gql_seo_format_string( + $user->user_nicename + ), + 'companyLogo' => $context + ->get_loader( 'post' ) + ->load_deferred( absint( $all['company_logo_id'] ) ), + 'personLogo' => $context + ->get_loader( 'post' ) + ->load_deferred( absint( $all['person_logo_id'] ) ), + 'logo' => $context + ->get_loader( 'post' ) + ->load_deferred( + $all['company_or_person'] === 'company' + ? absint( $all['company_logo_id'] ) + : absint( $all['person_logo_id'] ) + ), + 'companyOrPerson' => wp_gql_seo_format_string( + $all['company_or_person'] + ), + 'siteName' => wp_gql_seo_format_string( + YoastSEO()->helpers->site->get_site_name() + ), + 'wordpressSiteName' => wp_gql_seo_format_string( + get_bloginfo( 'name' ) + ), + 'siteUrl' => wp_gql_seo_format_string( + apply_filters( 'wp_gql_seo_site_url', get_site_url() ) + ), + 'homeUrl' => wp_gql_seo_format_string( + apply_filters( 'wp_gql_seo_home_url', get_home_url() ) + ), + 'inLanguage' => wp_gql_seo_format_string( + get_bloginfo( 'language' ) + ), + ], + 'redirects' => array_map( $mappedRedirects, $redirects ), + 'openGraph' => [ + 'defaultImage' => $context + ->get_loader( 'post' ) + ->load_deferred( absint( $all['og_default_image_id'] ) ), + 'frontPage' => [ + 'title' => wp_gql_seo_format_string( + $all['og_frontpage_title'] + ), + 'description' => wp_gql_seo_format_string( + $all['og_frontpage_desc'] + ), + 'image' => $context + ->get_loader( 'post' ) + ->load_deferred( + absint( $all['og_frontpage_image_id'] ) + ), + ], + ], + ]; + }, + ] + ); + } + + private static function build_content_type_data( $types, $all ) : array { + $carry = []; + foreach ( $types as $type ) { + $post_type_object = get_post_type_object( $type ); + + if ( $post_type_object->graphql_single_name ) { + $tag = wp_gql_seo_get_field_key( + $post_type_object->graphql_single_name + ); + + $schemaArray = YoastSEO()->meta->for_post_type_archive( $type ) + ->schema; + + $carry[ $tag ] = [ + 'title' => ! empty( $all[ 'title-' . $type ] ) + ? $all[ 'title-' . $type ] + : null, + 'metaDesc' => ! empty( $all[ 'metadesc-' . $type ] ) + ? $all[ 'metadesc-' . $type ] + : null, + 'metaRobotsNoindex' => ! empty( $all[ 'noindex-' . $type ] ) + ? boolval( $all[ 'noindex-' . $type ] ) + : false, + 'schemaType' => ! empty( $all[ 'schema-page-type-' . $type ] ) + ? $all[ 'schema-page-type-' . $type ] + : null, + + 'schema' => [ + 'raw' => ! empty( $schemaArray ) + ? json_encode( $schemaArray, JSON_UNESCAPED_SLASHES ) + : null, + ], + 'archive' => + $tag == 'post' // Posts are stored like this + ? [ + 'hasArchive' => true, + 'archiveLink' => get_post_type_archive_link( $type ), + 'title' => $all['title-archive-wpseo'] ?? null, + 'metaDesc' => $all['metadesc-archive-wpseo'] ?? null, + 'metaRobotsNoindex' => $all['noindex-archive-wpseo'] ?? null, + 'breadcrumbTitle' => $all['bctitle-archive-wpseo'] ?? null, + 'metaRobotsNoindex' => boolval( + $all['noindex-archive-wpseo'] + ), + 'fullHead' => is_string( + YoastSEO() + ->meta->for_post_type_archive( $type ) + ->get_head() + ) + ? YoastSEO() + ->meta->for_post_type_archive( $type ) + ->get_head() + : YoastSEO() + ->meta->for_post_type_archive( $type ) + ->get_head()->html, + ] + : [ + 'hasArchive' => boolval( + $post_type_object->has_archive + ), + 'archiveLink' => get_post_type_archive_link( $type ), + 'title' => ! empty( $all[ 'title-ptarchive-' . $type ] ) + ? $all[ 'title-ptarchive-' . $type ] + : null, + 'metaDesc' => ! empty( + $all[ 'metadesc-ptarchive-' . $type ] + ) + ? $all[ 'metadesc-ptarchive-' . $type ] + : null, + 'metaRobotsNoindex' => ! empty( + $all[ 'noindex-ptarchive-' . $type ] + ) + ? boolval( $all[ 'noindex-ptarchive-' . $type ] ) + : false, + 'breadcrumbTitle' => ! empty( + $all[ 'bctitle-ptarchive-' . $type ] + ) + ? $all[ 'bctitle-ptarchive-' . $type ] + : null, + 'fullHead' => is_string( + YoastSEO() + ->meta->for_post_type_archive( $type ) + ->get_head() + ) + ? YoastSEO() + ->meta->for_post_type_archive( $type ) + ->get_head() + : YoastSEO() + ->meta->for_post_type_archive( $type ) + ->get_head()->html, + ], + ]; + } + } + return $carry; + } +} diff --git a/src/Type/WPObject/SEOPostTypeBreadcrumbs.php b/src/Type/WPObject/SEOPostTypeBreadcrumbs.php new file mode 100644 index 0000000..7a7c5a5 --- /dev/null +++ b/src/Type/WPObject/SEOPostTypeBreadcrumbs.php @@ -0,0 +1,58 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + // @todo update description. + return __( 'The Schema types for Taxonomy', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'url' => [ 'type' => 'String' ], + 'text' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/SEOPostTypePageInfo.php b/src/Type/WPObject/SEOPostTypePageInfo.php new file mode 100644 index 0000000..10ce46d --- /dev/null +++ b/src/Type/WPObject/SEOPostTypePageInfo.php @@ -0,0 +1,87 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + + self::register_field(); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The page info SEO details', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'schema' => [ 'type' => PageInfo\Schema::$type ], + ]; + } + /** + * {@inheritDoc} + */ + public static function register_field() : void { + // @todo this shouldn't be on every `pageInfo`. + register_graphql_field( + 'WPPageInfo', + 'seo', + [ + 'type' => self::$type, + 'description' => __( 'Raw schema for archive', 'wp-graphql-yoast-seo' ), + 'resolve' => static function( $item, array $args, AppContext $context ) { + $schemaArray = YoastSEO()->meta->for_post_type_archive()->schema; + + return [ + 'schema' => [ + 'raw' => json_encode( + $schemaArray, + JSON_UNESCAPED_SLASHES + ), + ], + ]; + }, + ] + ); + } +} diff --git a/src/Type/WPObject/SEOUser.php b/src/Type/WPObject/SEOUser.php new file mode 100644 index 0000000..8009c39 --- /dev/null +++ b/src/Type/WPObject/SEOUser.php @@ -0,0 +1,207 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + + self::register_field(); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + // @todo add description. + return __( 'The Yoast SEO site level configuration data.', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'title' => [ 'type' => 'String' ], + 'metaDesc' => [ 'type' => 'String' ], + 'metaRobotsNoindex' => [ 'type' => 'String' ], + 'metaRobotsNofollow' => [ 'type' => 'String' ], + 'canonical' => [ 'type' => 'String' ], + 'opengraphTitle' => [ 'type' => 'String' ], + 'opengraphDescription' => [ 'type' => 'String' ], + 'opengraphImage' => [ 'type' => 'MediaItem' ], + 'twitterImage' => [ 'type' => 'MediaItem' ], + 'twitterTitle' => [ 'type' => 'String' ], + 'twitterDescription' => [ 'type' => 'String' ], + 'language' => [ 'type' => 'String' ], + 'region' => [ 'type' => 'String' ], + 'breadcrumbTitle' => [ 'type' => 'String' ], + 'fullHead' => [ 'type' => 'String' ], + 'social' => [ 'type' => User\Social::$type ], + 'schema' => [ 'type' => User\Schema::$type ], + ]; + } + /** + * {@inheritDoc} + */ + public static function register_field() : void { + register_graphql_field( + 'User', + static::$fieldname, + [ + 'type' => static::$type, + 'description' => __( 'The Yoast SEO data of a user', 'wp-graphql-yoast-seo' ), + 'resolve' => static function ( $user, array $args, AppContext $context ) { + $robots = YoastSEO()->meta->for_author( $user->userId )->robots; + + $schemaArray = YoastSEO()->meta->for_author( $user->userId )->schema; + $userSeo = [ + 'title' => wp_gql_seo_format_string( + YoastSEO()->meta->for_author( $user->userId )->title + ), + 'metaDesc' => wp_gql_seo_format_string( + YoastSEO()->meta->for_author( $user->userId )->description + ), + 'metaRobotsNoindex' => $robots['index'], + 'metaRobotsNofollow' => $robots['follow'], + 'canonical' => YoastSEO()->meta->for_author( $user->userId ) + ->canonical, + 'opengraphTitle' => YoastSEO()->meta->for_author( $user->userId ) + ->open_graph_title, + 'opengraphDescription' => YoastSEO()->meta->for_author( + $user->userId + )->open_graph_description, + 'opengraphImage' => $context + ->get_loader( 'post' ) + ->load_deferred( + absint( + YoastSEO()->meta->for_author( $user->userId ) + ->open_graph_image_id + ) + ), + 'twitterImage' => $context + ->get_loader( 'post' ) + ->load_deferred( + absint( + YoastSEO()->meta->for_author( $user->userId ) + ->twitter_image_id + ) + ), + 'twitterTitle' => YoastSEO()->meta->for_author( $user->userId ) + ->twitter_title, + 'twitterDescription' => YoastSEO()->meta->for_author( + $user->userId + )->twitter_description, + 'language' => YoastSEO()->meta->for_author( $user->userId ) + ->language, + 'region' => YoastSEO()->meta->for_author( $user->userId )->region, + 'breadcrumbTitle' => YoastSEO()->meta->for_author( $user->userId ) + ->breadcrumb_title, + 'fullHead' => is_string( + YoastSEO() + ->meta->for_author( $user->userId ) + ->get_head() + ) + ? YoastSEO() + ->meta->for_author( $user->userId ) + ->get_head() + : YoastSEO() + ->meta->for_author( $user->userId ) + ->get_head()->html, + 'social' => [ + 'facebook' => wp_gql_seo_format_string( + get_the_author_meta( 'facebook', $user->userId ) + ), + 'twitter' => wp_gql_seo_format_string( + get_the_author_meta( 'twitter', $user->userId ) + ), + 'instagram' => wp_gql_seo_format_string( + get_the_author_meta( 'instagram', $user->userId ) + ), + 'linkedIn' => wp_gql_seo_format_string( + get_the_author_meta( 'linkedin', $user->userId ) + ), + 'mySpace' => wp_gql_seo_format_string( + get_the_author_meta( 'myspace', $user->userId ) + ), + 'pinterest' => wp_gql_seo_format_string( + get_the_author_meta( 'pinterest', $user->userId ) + ), + 'youTube' => wp_gql_seo_format_string( + get_the_author_meta( 'youtube', $user->userId ) + ), + 'soundCloud' => wp_gql_seo_format_string( + get_the_author_meta( 'soundcloud', $user->userId ) + ), + 'wikipedia' => wp_gql_seo_format_string( + get_the_author_meta( 'wikipedia', $user->userId ) + ), + ], + + 'schema' => [ + 'raw' => json_encode( $schemaArray, JSON_UNESCAPED_SLASHES ), + 'pageType' => is_array( + YoastSEO()->meta->for_author( $user->userId ) + ->schema_page_type + ) + ? YoastSEO()->meta->for_author( $user->userId ) + ->schema_page_type + : [], + 'articleType' => is_array( + YoastSEO()->meta->for_author( $user->userId ) + ->schema_article_type + ) + ? YoastSEO()->meta->for_author( $user->userId ) + ->schema_article_type + : [], + ], + ]; + + return ! empty( $userSeo ) ? $userSeo : []; + }, + ] + ); + } +} diff --git a/src/Type/WPObject/Taxonomy/Schema.php b/src/Type/WPObject/Taxonomy/Schema.php new file mode 100644 index 0000000..f9f410f --- /dev/null +++ b/src/Type/WPObject/Taxonomy/Schema.php @@ -0,0 +1,56 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Schema types for Taxonomy', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'raw' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/Type/WPObject/TaxonomySEO.php b/src/Type/WPObject/TaxonomySEO.php new file mode 100644 index 0000000..2b10292 --- /dev/null +++ b/src/Type/WPObject/TaxonomySEO.php @@ -0,0 +1,59 @@ + static::get_description(), + 'interfaces' => [ SEOBaseFields::$type ], + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Schema types', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'schema' => [ 'type' => Schema::$type ], + ]; + } +} diff --git a/src/Type/WPObject/User/Schema.php b/src/Type/WPObject/User/Schema.php new file mode 100644 index 0000000..f3029ae --- /dev/null +++ b/src/Type/WPObject/User/Schema.php @@ -0,0 +1,58 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'The Schema types for User', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'raw' => [ 'type' => 'String' ], + 'pageType' => [ 'type' => [ 'list_of' => 'String' ] ], + 'articleType' => [ 'type' => [ 'list_of' => 'String' ] ], + ]; + } +} diff --git a/src/Type/WPObject/User/Social.php b/src/Type/WPObject/User/Social.php new file mode 100644 index 0000000..d756b4d --- /dev/null +++ b/src/Type/WPObject/User/Social.php @@ -0,0 +1,65 @@ + static::get_description(), + 'fields' => static::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + // @todo add description + return __( 'The Social types for User', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + // @todo add descriptions. + return [ + 'facebook' => [ 'type' => 'String' ], + 'twitter' => [ 'type' => 'String' ], + 'instagram' => [ 'type' => 'String' ], + 'linkedIn' => [ 'type' => 'String' ], + 'mySpace' => [ 'type' => 'String' ], + 'pinterest' => [ 'type' => 'String' ], + 'youTube' => [ 'type' => 'String' ], + 'soundCloud' => [ 'type' => 'String' ], + 'wikipedia' => [ 'type' => 'String' ], + ]; + } +} diff --git a/src/TypeRegistry.php b/src/TypeRegistry.php new file mode 100644 index 0000000..cb7f146 --- /dev/null +++ b/src/TypeRegistry.php @@ -0,0 +1,156 @@ + class_exists('WPGraphQL'), - 'Yoast SEO' => function_exists('YoastSEO'), - ]; - - $missing_dependencies = array_keys( - array_diff($core_dependencies, array_filter($core_dependencies)) - ); - $display_admin_notice = static function () use ($missing_dependencies) { - ?> -
-

-

-
    - -
  • - -
-
- graphql_single_name) { - $carry[ - wp_gql_seo_get_field_key($post_type_object->graphql_single_name) - ] = ['type' => 'SEOContentType']; - } - } - return $carry; - } - - function wp_gql_seo_build_content_type_data($types, $all) - { - $carry = []; - foreach ($types as $type) { - $post_type_object = get_post_type_object($type); - - if ($post_type_object->graphql_single_name) { - $tag = wp_gql_seo_get_field_key( - $post_type_object->graphql_single_name - ); - - $schemaArray = YoastSEO()->meta->for_post_type_archive($type) - ->schema; - - $carry[$tag] = [ - 'title' => !empty($all['title-' . $type]) - ? $all['title-' . $type] - : null, - 'metaDesc' => !empty($all['metadesc-' . $type]) - ? $all['metadesc-' . $type] - : null, - 'metaRobotsNoindex' => !empty($all['noindex-' . $type]) - ? boolval($all['noindex-' . $type]) - : false, - 'schemaType' => !empty($all['schema-page-type-' . $type]) - ? $all['schema-page-type-' . $type] - : null, - - 'schema' => [ - 'raw' => !empty($schemaArray) - ? json_encode($schemaArray, JSON_UNESCAPED_SLASHES) - : null, - ], - 'archive' => - $tag == 'post' //Posts are stored like this - ? [ - 'hasArchive' => true, - 'archiveLink' => get_post_type_archive_link($type), - 'title' => !empty($all['title-archive-wpseo']) - ? $all['title-archive-wpseo'] - : null, - 'metaDesc' => !empty($all['metadesc-archive-wpseo']) - ? $all['metadesc-archive-wpseo'] - : null, - 'metaRobotsNoindex' => !empty( - $all['noindex-archive-wpseo'] - ) - ? $all['noindex-archive-wpseo'] - : null, - 'breadcrumbTitle' => !empty( - $all['bctitle-archive-wpseo'] - ) - ? $all['bctitle-archive-wpseo'] - : null, - 'metaRobotsNoindex' => boolval( - $all['noindex-archive-wpseo'] - ), - 'fullHead' => is_string( - YoastSEO() - ->meta->for_post_type_archive($type) - ->get_head() - ) - ? YoastSEO() - ->meta->for_post_type_archive($type) - ->get_head() - : YoastSEO() - ->meta->for_post_type_archive($type) - ->get_head()->html, - ] - : [ - 'hasArchive' => boolval( - $post_type_object->has_archive - ), - 'archiveLink' => get_post_type_archive_link($type), - 'title' => !empty($all['title-ptarchive-' . $type]) - ? $all['title-ptarchive-' . $type] - : null, - 'metaDesc' => !empty( - $all['metadesc-ptarchive-' . $type] - ) - ? $all['metadesc-ptarchive-' . $type] - : null, - 'metaRobotsNoindex' => !empty( - $all['noindex-ptarchive-' . $type] - ) - ? boolval($all['noindex-ptarchive-' . $type]) - : false, - 'breadcrumbTitle' => !empty( - $all['bctitle-ptarchive-' . $type] - ) - ? $all['bctitle-ptarchive-' . $type] - : null, - 'fullHead' => is_string( - YoastSEO() - ->meta->for_post_type_archive($type) - ->get_head() - ) - ? YoastSEO() - ->meta->for_post_type_archive($type) - ->get_head() - : YoastSEO() - ->meta->for_post_type_archive($type) - ->get_head()->html, - ], - ]; - } - } - return $carry; - } - - add_action('graphql_register_types', function () { - $post_types = \WPGraphQL::get_allowed_post_types(); - $taxonomies = \WPGraphQL::get_allowed_taxonomies(); - - // If WooCommerce installed then add these post types and taxonomies - if (class_exists('\WooCommerce')) { - array_push($post_types, 'product'); - array_push($taxonomies, 'productCategory'); - } - - register_graphql_enum_type('SEOCardType', [ - 'description' => __('Types of cards', 'wp-graphql-yoast-seo'), - 'values' => [ - 'summary_large_image' => [ - 'value' => 'summary_large_image', - ], - 'summary' => [ - 'value' => 'summary', - ], - ], - ]); - - register_graphql_object_type('SEOPostTypeSchema', [ - 'description' => __('The Schema types', 'wp-graphql-yoast-seo'), - 'fields' => [ - 'pageType' => ['type' => ['list_of' => 'String']], - 'articleType' => ['type' => ['list_of' => 'String']], - 'raw' => ['type' => 'String'], - ], - ]); - register_graphql_object_type('SEOTaxonomySchema', [ - 'description' => __( - 'The Schema types for Taxonomy', - 'wp-graphql-yoast-seo' - ), - 'fields' => [ - 'raw' => ['type' => 'String'], - ], - ]); - - $baseSEOFields = [ - 'title' => ['type' => 'String'], - 'metaDesc' => ['type' => 'String'], - 'focuskw' => ['type' => 'String'], - 'metaKeywords' => ['type' => 'String'], - 'metaRobotsNoindex' => ['type' => 'String'], - 'metaRobotsNofollow' => ['type' => 'String'], - 'opengraphTitle' => ['type' => 'String'], - 'opengraphUrl' => ['type' => 'String'], - 'opengraphSiteName' => ['type' => 'String'], - 'opengraphType' => ['type' => 'String'], - 'opengraphAuthor' => ['type' => 'String'], - 'opengraphPublisher' => ['type' => 'String'], - 'opengraphPublishedTime' => ['type' => 'String'], - 'opengraphModifiedTime' => ['type' => 'String'], - 'opengraphDescription' => ['type' => 'String'], - 'opengraphImage' => ['type' => 'MediaItem'], - 'twitterTitle' => ['type' => 'String'], - 'twitterDescription' => ['type' => 'String'], - 'twitterImage' => ['type' => 'MediaItem'], - 'canonical' => ['type' => 'String'], - 'breadcrumbs' => ['type' => ['list_of' => 'SEOPostTypeBreadcrumbs']], - 'cornerstone' => ['type' => 'Boolean'], - 'fullHead' => ['type' => 'String'], - ]; - - register_graphql_object_type('TaxonomySEO', [ - 'fields' => array_merge($baseSEOFields, [ - 'schema' => ['type' => 'SEOTaxonomySchema'], - ]), - ]); - - register_graphql_object_type('PostTypeSEO', [ - 'fields' => array_merge($baseSEOFields, [ - 'readingTime' => ['type' => 'Float'], - 'schema' => ['type' => 'SEOPostTypeSchema'], - ]), - ]); - - register_graphql_object_type('SEOPostTypeBreadcrumbs', [ - 'fields' => [ - 'url' => ['type' => 'String'], - 'text' => ['type' => 'String'], - ], - ]); - - register_graphql_object_type('SEOSchema', [ - 'description' => __('The Yoast SEO schema data', 'wp-graphql-yoast-seo'), - 'fields' => [ - 'companyName' => ['type' => 'String'], - 'personName' => ['type' => 'String'], - 'companyOrPerson' => ['type' => 'String'], - 'companyLogo' => ['type' => 'MediaItem'], - 'personLogo' => ['type' => 'MediaItem'], - 'logo' => ['type' => 'MediaItem'], - 'siteName' => ['type' => 'String'], - 'wordpressSiteName' => ['type' => 'String'], - 'siteUrl' => ['type' => 'String'], - 'homeUrl' => ['type' => 'String'], - 'inLanguage' => ['type' => 'String'], - ], - ]); - - register_graphql_object_type('SEOWebmaster', [ - 'description' => __( - 'The Yoast SEO webmaster fields', - 'wp-graphql-yoast-seo' - ), - 'fields' => [ - 'baiduVerify' => ['type' => 'String'], - 'googleVerify' => ['type' => 'String'], - 'msVerify' => ['type' => 'String'], - 'yandexVerify' => ['type' => 'String'], - ], - ]); - - register_graphql_object_type('SEOBreadcrumbs', [ - 'description' => __( - 'The Yoast SEO breadcrumb config', - 'wp-graphql-yoast-seo' - ), - 'fields' => [ - 'enabled' => ['type' => 'Boolean'], - 'boldLast' => ['type' => 'Boolean'], - 'showBlogPage' => ['type' => 'Boolean'], - 'notFoundText' => ['type' => 'String'], - 'archivePrefix' => ['type' => 'String'], - 'homeText' => ['type' => 'String'], - 'prefix' => ['type' => 'String'], - 'searchPrefix' => ['type' => 'String'], - 'separator' => ['type' => 'String'], - ], - ]); - - register_graphql_object_type('SEOSocialFacebook', [ - 'fields' => [ - 'url' => ['type' => 'String'], - 'defaultImage' => ['type' => 'MediaItem'], - ], - ]); - - register_graphql_object_type('SEOSocialTwitter', [ - 'fields' => [ - 'username' => ['type' => 'String'], - 'cardType' => ['type' => 'SEOCardType'], - ], - ]); - - register_graphql_object_type('SEOSocialInstagram', [ - 'fields' => [ - 'url' => ['type' => 'String'], - ], - ]); - register_graphql_object_type('SEOSocialLinkedIn', [ - 'fields' => [ - 'url' => ['type' => 'String'], - ], - ]); - register_graphql_object_type('SEOSocialMySpace', [ - 'fields' => [ - 'url' => ['type' => 'String'], - ], - ]); - - register_graphql_object_type('SEOSocialPinterest', [ - 'fields' => [ - 'url' => ['type' => 'String'], - 'metaTag' => ['type' => 'String'], - ], - ]); - - register_graphql_object_type('SEOSocialYoutube', [ - 'fields' => [ - 'url' => ['type' => 'String'], - ], - ]); - register_graphql_object_type('SEOSocialWikipedia', [ - 'fields' => [ - 'url' => ['type' => 'String'], - ], - ]); - - register_graphql_object_type('SEOSocial', [ - 'description' => __( - 'The Yoast SEO Social media links', - 'wp-graphql-yoast-seo' - ), - 'fields' => [ - 'facebook' => ['type' => 'SEOSocialFacebook'], - 'twitter' => ['type' => 'SEOSocialTwitter'], - 'instagram' => ['type' => 'SEOSocialInstagram'], - 'linkedIn' => ['type' => 'SEOSocialLinkedIn'], - 'mySpace' => ['type' => 'SEOSocialMySpace'], - 'pinterest' => ['type' => 'SEOSocialPinterest'], - 'youTube' => ['type' => 'SEOSocialYoutube'], - 'wikipedia' => ['type' => 'SEOSocialWikipedia'], - ], - ]); - - register_graphql_object_type('SEORedirect', [ - 'description' => __( - 'The Yoast redirect data (Yoast Premium only)', - 'wp-graphql-yoast-seo' - ), - 'fields' => [ - 'origin' => ['type' => 'String'], - 'target' => ['type' => 'String'], - 'type' => ['type' => 'Int'], - 'format' => ['type' => 'String'], - ], - ]); - - register_graphql_object_type('SEOOpenGraphFrontPage', [ - 'description' => __( - 'The Open Graph Front page data', - 'wp-graphql-yoast-seo' - ), - 'fields' => [ - 'title' => ['type' => 'String'], - 'description' => ['type' => 'String'], - 'image' => ['type' => 'MediaItem'], - ], - ]); - - register_graphql_object_type('SEOOpenGraph', [ - 'description' => __('The Open Graph data', 'wp-graphql-yoast-seo'), - 'fields' => [ - 'defaultImage' => ['type' => 'MediaItem'], - 'frontPage' => ['type' => 'SEOOpenGraphFrontPage'], - ], - ]); - - register_graphql_object_type('SEOContentTypeArchive', [ - 'description' => __( - 'he Yoast SEO search appearance content types fields', - 'wp-graphql-yoast-seo' - ), - 'fields' => [ - 'hasArchive' => ['type' => 'Boolean'], - 'title' => ['type' => 'String'], - 'archiveLink' => ['type' => 'String'], - 'metaDesc' => ['type' => 'String'], - 'metaRobotsNoindex' => ['type' => 'Boolean'], - 'breadcrumbTitle' => ['type' => 'String'], - 'fullHead' => ['type' => 'String'], - ], - ]); - register_graphql_object_type('SEOContentType', [ - 'description' => __( - 'he Yoast SEO search appearance content types fields', - 'wp-graphql-yoast-seo' - ), - 'fields' => [ - 'title' => ['type' => 'String'], - 'metaDesc' => ['type' => 'String'], - 'metaRobotsNoindex' => ['type' => 'Boolean'], - 'schemaType' => ['type' => 'String'], - 'schema' => ['type' => 'SEOPageInfoSchema'], - 'archive' => ['type' => 'SEOContentTypeArchive'], - ], - ]); - - $allTypes = wp_gql_seo_build_content_types($post_types); - - register_graphql_object_type('SEOContentTypes', [ - 'description' => __( - 'The Yoast SEO search appearance content types', - 'wp-graphql-yoast-seo' - ), - 'fields' => $allTypes, - ]); - - register_graphql_object_type('SEOConfig', [ - 'description' => __( - 'The Yoast SEO site level configuration data', - 'wp-graphql-yoast-seo' - ), - 'fields' => [ - 'schema' => ['type' => 'SEOSchema'], - 'webmaster' => ['type' => 'SEOWebmaster'], - 'social' => ['type' => 'SEOSocial'], - 'breadcrumbs' => ['type' => 'SEOBreadcrumbs'], - 'redirects' => [ - 'type' => [ - 'list_of' => 'SEORedirect', - ], - ], - 'openGraph' => ['type' => 'SEOOpenGraph'], - 'contentTypes' => ['type' => 'SEOContentTypes'], - ], - ]); - - register_graphql_object_type('SEOUserSocial', [ - 'fields' => [ - 'facebook' => ['type' => 'String'], - 'twitter' => ['type' => 'String'], - 'instagram' => ['type' => 'String'], - 'linkedIn' => ['type' => 'String'], - 'mySpace' => ['type' => 'String'], - 'pinterest' => ['type' => 'String'], - 'youTube' => ['type' => 'String'], - 'soundCloud' => ['type' => 'String'], - 'wikipedia' => ['type' => 'String'], - ], - ]); - - register_graphql_object_type('SEOUserSchema', [ - 'description' => __('The Schema types for User', 'wp-graphql-yoast-seo'), - 'fields' => [ - 'raw' => ['type' => 'String'], - 'pageType' => ['type' => ['list_of' => 'String']], - 'articleType' => ['type' => ['list_of' => 'String']], - ], - ]); - - register_graphql_object_type('SEOUser', [ - 'fields' => [ - 'title' => ['type' => 'String'], - 'metaDesc' => ['type' => 'String'], - 'metaRobotsNoindex' => ['type' => 'String'], - 'metaRobotsNofollow' => ['type' => 'String'], - 'canonical' => ['type' => 'String'], - 'opengraphTitle' => ['type' => 'String'], - 'opengraphDescription' => ['type' => 'String'], - 'opengraphImage' => ['type' => 'MediaItem'], - 'twitterImage' => ['type' => 'MediaItem'], - 'twitterTitle' => ['type' => 'String'], - 'twitterDescription' => ['type' => 'String'], - 'language' => ['type' => 'String'], - 'region' => ['type' => 'String'], - 'breadcrumbTitle' => ['type' => 'String'], - 'fullHead' => ['type' => 'String'], - 'social' => ['type' => 'SEOUserSocial'], - 'schema' => ['type' => 'SEOUserSchema'], - ], - ]); - - register_graphql_object_type('SEOPageInfoSchema', [ - 'description' => __('The Schema for post type', 'wp-graphql-yoast-seo'), - 'fields' => [ - 'raw' => ['type' => 'String'], - ], - ]); - register_graphql_object_type('SEOPostTypePageInfo', [ - 'description' => __('The page info SEO details', 'wp-graphql-yoast-seo'), - 'fields' => [ - 'schema' => ['type' => 'SEOPageInfoSchema'], - ], - ]); - - register_graphql_field('RootQuery', 'seo', [ - 'type' => 'SEOConfig', - 'description' => __('Returns seo site data', 'wp-graphql-yoast-seo'), - '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() : []; - - $userID = !empty($all['company_or_person_user_id']) - ? $all['company_or_person_user_id'] - : null; - $user = !empty($userID) ? get_userdata($userID) : null; - - $mappedRedirects = function ($value) { - return [ - 'origin' => $value['origin'], - 'target' => $value['url'], - 'type' => $value['type'], - 'format' => $value['format'], - ]; - }; - - $contentTypes = wp_gql_seo_build_content_type_data( - $post_types, - $all - ); - - return [ - 'contentTypes' => $contentTypes, - 'webmaster' => [ - 'baiduVerify' => wp_gql_seo_format_string( - $all['baiduverify'] - ), - 'googleVerify' => wp_gql_seo_format_string( - $all['googleverify'] - ), - 'msVerify' => wp_gql_seo_format_string($all['msverify']), - 'yandexVerify' => wp_gql_seo_format_string( - $all['yandexverify'] - ), - ], - 'social' => [ - 'facebook' => [ - 'url' => wp_gql_seo_format_string($all['facebook_site']), - 'defaultImage' => $context - ->get_loader('post') - ->load_deferred($all['og_default_image_id']), - ], - 'twitter' => [ - 'username' => wp_gql_seo_format_string( - $all['twitter_site'] - ), - 'cardType' => wp_gql_seo_format_string( - $all['twitter_card_type'] - ), - ], - 'instagram' => [ - 'url' => wp_gql_seo_format_string($all['instagram_url']), - ], - 'linkedIn' => [ - 'url' => wp_gql_seo_format_string($all['linkedin_url']), - ], - 'mySpace' => [ - 'url' => wp_gql_seo_format_string($all['myspace_url']), - ], - 'pinterest' => [ - 'url' => wp_gql_seo_format_string($all['pinterest_url']), - 'metaTag' => wp_gql_seo_format_string( - $all['pinterestverify'] - ), - ], - 'youTube' => [ - 'url' => wp_gql_seo_format_string($all['youtube_url']), - ], - 'wikipedia' => [ - 'url' => wp_gql_seo_format_string($all['wikipedia_url']), - ], - ], - 'breadcrumbs' => [ - 'enabled' => wp_gql_seo_format_string( - $all['breadcrumbs-enable'] - ), - 'boldLast' => wp_gql_seo_format_string( - $all['breadcrumbs-boldlast'] - ), - 'showBlogPage' => wp_gql_seo_format_string( - $all['breadcrumbs-display-blog-page'] - ), - 'archivePrefix' => wp_gql_seo_format_string( - $all['breadcrumbs-archiveprefix'] - ), - 'prefix' => wp_gql_seo_format_string( - $all['breadcrumbs-prefix'] - ), - 'notFoundText' => wp_gql_seo_format_string( - $all['breadcrumbs-404crumb'] - ), - 'homeText' => wp_gql_seo_format_string( - $all['breadcrumbs-home'] - ), - 'searchPrefix' => wp_gql_seo_format_string( - $all['breadcrumbs-searchprefix'] - ), - 'separator' => wp_gql_seo_format_string( - $all['breadcrumbs-sep'] - ), - ], - 'schema' => [ - 'companyName' => wp_gql_seo_format_string( - $all['company_name'] - ), - 'personName' => wp_gql_seo_format_string( - $user->user_nicename - ), - 'companyLogo' => $context - ->get_loader('post') - ->load_deferred(absint($all['company_logo_id'])), - 'personLogo' => $context - ->get_loader('post') - ->load_deferred(absint($all['person_logo_id'])), - 'logo' => $context - ->get_loader('post') - ->load_deferred( - $all['company_or_person'] === 'company' - ? absint($all['company_logo_id']) - : absint($all['person_logo_id']) - ), - 'companyOrPerson' => wp_gql_seo_format_string( - $all['company_or_person'] - ), - 'siteName' => wp_gql_seo_format_string( - YoastSEO()->helpers->site->get_site_name() - ), - 'wordpressSiteName' => wp_gql_seo_format_string( - get_bloginfo('name') - ), - 'siteUrl' => wp_gql_seo_format_string( - apply_filters('wp_gql_seo_site_url', get_site_url()) - ), - 'homeUrl' => wp_gql_seo_format_string( - apply_filters('wp_gql_seo_home_url', get_home_url()) - ), - 'inLanguage' => wp_gql_seo_format_string( - get_bloginfo('language') - ), - ], - 'redirects' => array_map($mappedRedirects, $redirects), - 'openGraph' => [ - 'defaultImage' => $context - ->get_loader('post') - ->load_deferred(absint($all['og_default_image_id'])), - 'frontPage' => [ - 'title' => wp_gql_seo_format_string( - $all['og_frontpage_title'] - ), - 'description' => wp_gql_seo_format_string( - $all['og_frontpage_desc'] - ), - 'image' => $context - ->get_loader('post') - ->load_deferred( - absint($all['og_frontpage_image_id']) - ), - ], - ], - ]; - }, - ]); - - // Post Type SEO Data - if (!empty($post_types) && is_array($post_types)) { - foreach ($post_types as $post_type) { - $post_type_object = get_post_type_object($post_type); - - if (isset($post_type_object->graphql_single_name)): - register_graphql_field( - $post_type_object->graphql_single_name, - 'seo', - [ - 'type' => 'PostTypeSEO', - 'description' => __( - 'The Yoast SEO data of the ' . - $post_type_object->graphql_single_name, - 'wp-graphql-yoast-seo' - ), - 'resolve' => function ( - $post, - array $args, - AppContext $context - ) { - // Base array - $seo = []; - - $map = [ - '@id' => 'id', - '@type' => 'type', - '@graph' => 'graph', - '@context' => 'context', - ]; - - $schemaArray = YoastSEO()->meta->for_post($post->ID) - ->schema; - - // https://developer.yoast.com/blog/yoast-seo-14-0-using-yoast-seo-surfaces/ - $robots = YoastSEO()->meta->for_post($post->ID) - ->robots; - - // Get data - $seo = [ - 'title' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID)->title - ), - 'metaDesc' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->description - ), - 'focuskw' => wp_gql_seo_format_string( - get_post_meta( - $post->ID, - '_yoast_wpseo_focuskw', - true - ) - ), - 'metaKeywords' => wp_gql_seo_format_string( - get_post_meta( - $post->ID, - '_yoast_wpseo_metakeywords', - true - ) - ), - 'metaRobotsNoindex' => $robots['index'], - 'metaRobotsNofollow' => $robots['follow'], - 'opengraphTitle' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->open_graph_title - ), - 'opengraphUrl' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->open_graph_url - ), - 'opengraphSiteName' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->open_graph_site_name - ), - 'opengraphType' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->open_graph_type - ), - 'opengraphAuthor' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->open_graph_article_author - ), - 'opengraphPublisher' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->open_graph_article_publisher - ), - 'opengraphPublishedTime' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->open_graph_article_published_time - ), - 'opengraphModifiedTime' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->open_graph_article_modified_time - ), - 'opengraphDescription' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->open_graph_description - ), - 'opengraphImage' => function () use ( - $post, - $context - ) { - $id = wp_gql_seo_get_og_image( - YoastSEO()->meta->for_post($post->ID) - ->open_graph_images - ); - - return $context - ->get_loader('post') - ->load_deferred(absint($id)); - }, - 'twitterCardType' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->twitter_card - ), - 'twitterTitle' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->twitter_title - ), - 'twitterDescription' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->twitter_description - ), - 'twitterImage' => function () use ( - $post, - $context - ) { - $id = wpcom_vip_attachment_url_to_postid( - YoastSEO()->meta->for_post($post->ID) - ->twitter_image - ); - - return $context - ->get_loader('post') - ->load_deferred(absint($id)); - }, - 'canonical' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post($post->ID) - ->canonical - ), - 'readingTime' => floatval( - YoastSEO()->meta->for_post($post->ID) - ->estimated_reading_time_minutes - ), - 'breadcrumbs' => YoastSEO()->meta->for_post( - $post->ID - )->breadcrumbs, - 'cornerstone' => boolval( - YoastSEO()->meta->for_post($post->ID) - ->indexable->is_cornerstone - ), - 'fullHead' => is_string( - YoastSEO() - ->meta->for_post($post->ID) - ->get_head() - ) - ? YoastSEO() - ->meta->for_post($post->ID) - ->get_head() - : YoastSEO() - ->meta->for_post($post->ID) - ->get_head()->html, - 'schema' => [ - 'pageType' => is_array( - YoastSEO()->meta->for_post($post->ID) - ->schema_page_type - ) - ? YoastSEO()->meta->for_post($post->ID) - ->schema_page_type - : [], - 'articleType' => is_array( - YoastSEO()->meta->for_post($post->ID) - ->schema_article_type - ) - ? YoastSEO()->meta->for_post($post->ID) - ->schema_article_type - : [], - 'raw' => json_encode( - $schemaArray, - JSON_UNESCAPED_SLASHES - ), - ], - ]; - - return !empty($seo) ? $seo : null; - }, - ] - ); - - // register field on edge for arch - - $name = - 'WP' . - ucfirst($post_type_object->graphql_single_name) . - 'Info'; - - register_graphql_field($name, 'seo', [ - 'type' => 'SEOPostTypePageInfo', - 'description' => __( - 'Raw schema for ' . - $post_type_object->graphql_single_name, - 'wp-graphql-yoast-seo' - ), - 'resolve' => function ( - $item, - array $args, - AppContext $context - ) use ($post_type) { - $schemaArray = YoastSEO()->meta->for_post_type_archive( - $post_type - )->schema; - - return [ - 'schema' => [ - 'raw' => json_encode( - $schemaArray, - JSON_UNESCAPED_SLASHES - ), - ], - ]; - }, - ]); - - // Loop each taxonomy to register on the edge if a category is the primary one. - $taxonomiesPostObj = get_object_taxonomies( - $post_type, - 'objects' - ); - - $postNameKey = wp_gql_seo_get_field_key( - $post_type_object->graphql_single_name - ); - - foreach ($taxonomiesPostObj as $tax) { - if ( - isset($tax->hierarchical) && - isset($tax->graphql_single_name) - ) { - $name = - ucfirst($postNameKey) . - 'To' . - ucfirst($tax->graphql_single_name) . - 'ConnectionEdge'; - - register_graphql_field($name, 'isPrimary', [ - 'type' => 'Boolean', - 'description' => __( - 'The Yoast SEO Primary ' . $tax->name, - 'wp-graphql-yoast-seo' - ), - 'resolve' => function ( - $item, - array $args, - AppContext $context - ) use ($tax) { - $postId = $item['source']->ID; - - $wpseo_primary_term = new WPSEO_Primary_Term( - $tax->name, - $postId - ); - $primaryTaxId = $wpseo_primary_term->get_primary_term(); - $termId = $item['node']->term_id; - - return $primaryTaxId === $termId; - }, - ]); - } - } - endif; - } - } - // User SEO Data - register_graphql_field('User', 'seo', [ - 'type' => 'SEOUser', - 'description' => __( - 'The Yoast SEO data of a user', - 'wp-graphql-yoast-seo' - ), - 'resolve' => function ($user, array $args, AppContext $context) { - $robots = YoastSEO()->meta->for_author($user->userId)->robots; - - $schemaArray = YoastSEO()->meta->for_author($user->userId)->schema; - - $userSeo = [ - 'title' => wp_gql_seo_format_string( - YoastSEO()->meta->for_author($user->userId)->title - ), - 'metaDesc' => wp_gql_seo_format_string( - YoastSEO()->meta->for_author($user->userId)->description - ), - 'metaRobotsNoindex' => $robots['index'], - 'metaRobotsNofollow' => $robots['follow'], - 'canonical' => YoastSEO()->meta->for_author($user->userId) - ->canonical, - 'opengraphTitle' => YoastSEO()->meta->for_author($user->userId) - ->open_graph_title, - 'opengraphDescription' => YoastSEO()->meta->for_author( - $user->userId - )->open_graph_description, - 'opengraphImage' => $context - ->get_loader('post') - ->load_deferred( - absint( - YoastSEO()->meta->for_author($user->userId) - ->open_graph_image_id - ) - ), - 'twitterImage' => $context - ->get_loader('post') - ->load_deferred( - absint( - YoastSEO()->meta->for_author($user->userId) - ->twitter_image_id - ) - ), - 'twitterTitle' => YoastSEO()->meta->for_author($user->userId) - ->twitter_title, - 'twitterDescription' => YoastSEO()->meta->for_author( - $user->userId - )->twitter_description, - 'language' => YoastSEO()->meta->for_author($user->userId) - ->language, - 'region' => YoastSEO()->meta->for_author($user->userId)->region, - 'breadcrumbTitle' => YoastSEO()->meta->for_author($user->userId) - ->breadcrumb_title, - 'fullHead' => is_string( - YoastSEO() - ->meta->for_author($user->userId) - ->get_head() - ) - ? YoastSEO() - ->meta->for_author($user->userId) - ->get_head() - : YoastSEO() - ->meta->for_author($user->userId) - ->get_head()->html, - 'social' => [ - 'facebook' => wp_gql_seo_format_string( - get_the_author_meta('facebook', $user->userId) - ), - 'twitter' => wp_gql_seo_format_string( - get_the_author_meta('twitter', $user->userId) - ), - 'instagram' => wp_gql_seo_format_string( - get_the_author_meta('instagram', $user->userId) - ), - 'linkedIn' => wp_gql_seo_format_string( - get_the_author_meta('linkedin', $user->userId) - ), - 'mySpace' => wp_gql_seo_format_string( - get_the_author_meta('myspace', $user->userId) - ), - 'pinterest' => wp_gql_seo_format_string( - get_the_author_meta('pinterest', $user->userId) - ), - 'youTube' => wp_gql_seo_format_string( - get_the_author_meta('youtube', $user->userId) - ), - 'soundCloud' => wp_gql_seo_format_string( - get_the_author_meta('soundcloud', $user->userId) - ), - 'wikipedia' => wp_gql_seo_format_string( - get_the_author_meta('wikipedia', $user->userId) - ), - ], - - 'schema' => [ - 'raw' => json_encode($schemaArray, JSON_UNESCAPED_SLASHES), - 'pageType' => is_array( - YoastSEO()->meta->for_author($user->userId) - ->schema_page_type - ) - ? YoastSEO()->meta->for_author($user->userId) - ->schema_page_type - : [], - 'articleType' => is_array( - YoastSEO()->meta->for_author($user->userId) - ->schema_article_type - ) - ? YoastSEO()->meta->for_author($user->userId) - ->schema_article_type - : [], - ], - ]; - - return !empty($userSeo) ? $userSeo : []; - }, - ]); - - // Taxonomy SEO Data - if (!empty($taxonomies) && is_array($taxonomies)) { - foreach ($taxonomies as $tax) { - $taxonomy = get_taxonomy($tax); - - if (empty($taxonomy) || !isset($taxonomy->graphql_single_name)) { - return; - } - - register_graphql_field($taxonomy->graphql_single_name, 'seo', [ - 'type' => 'TaxonomySEO', - 'description' => __( - 'The Yoast SEO data of the ' . - $taxonomy->label . - ' taxonomy.', - 'wp-graphql-yoast-seo' - ), - 'resolve' => function ($term, array $args, AppContext $context) { - $term_obj = get_term($term->term_id); +/** + * Define plugin constants. + */ +function wp_gql_seo_constants() : void { + // Plugin version. + if ( ! defined( 'WPGRAPHQL_SEO_VERSION' ) ) { + define( 'WPGRAPHQL_SEO_VERSION', '0.0.1' ); + } + + // Plugin Folder Path. + if ( ! defined( 'WPGRAPHQL_SEO_PLUGIN_DIR' ) ) { + define( 'WPGRAPHQL_SEO_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); + } + + // Plugin Folder URL. + if ( ! defined( 'WPGRAPHQL_SEO_PLUGIN_URL' ) ) { + define( 'WPGRAPHQL_SEO_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); + } + + // Plugin Root File. + if ( ! defined( 'WPGRAPHQL_SEO_PLUGIN_FILE' ) ) { + define( 'WPGRAPHQL_SEO_PLUGIN_FILE', __FILE__ ); + } + + // Whether to autoload the files or not. + if ( ! defined( 'WPGRAPHQL_SEO_AUTOLOAD' ) ) { + define( 'WPGRAPHQL_SEO_AUTOLOAD', true ); + } +} - $meta = WPSEO_Taxonomy_Meta::get_term_meta( - (int) $term_obj->term_id, - $term_obj->taxonomy - ); - $robots = YoastSEO()->meta->for_term($term->term_id)->robots; +/** + * Checks if all the the required plugins are installed and activated. + */ +function wp_gql_seo_dependencies_not_ready() : array { + $deps = []; + if ( ! class_exists( 'WPGraphQL' ) ) { + $deps[] = 'WPGraphQL'; + } - $schemaArray = YoastSEO()->meta->for_term($term->term_id) - ->schema; + if ( ! function_exists( 'YoastSEO' ) ) { + $deps[] = 'Yoast SEO'; + } - // Get data - $seo = [ - 'title' => wp_gql_seo_format_string( - html_entity_decode( - wp_strip_all_tags( - YoastSEO()->meta->for_term($term->term_id) - ->title - ) - ) - ), - 'metaDesc' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->description - ), - 'focuskw' => isset($meta['wpseo_focuskw']) - ? wp_gql_seo_format_string($meta['wpseo_focuskw']) - : $meta['wpseo_focuskw'], - 'metaKeywords' => isset($meta['wpseo_metakeywords']) - ? wp_gql_seo_format_string( - $meta['wpseo_metakeywords'] - ) - : null, - 'metaRobotsNoindex' => $robots['index'], - 'metaRobotsNofollow' => $robots['follow'], - 'opengraphTitle' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->open_graph_title - ), - 'opengraphUrl' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->open_graph_url - ), - 'opengraphSiteName' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->open_graph_site_name - ), - 'opengraphType' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->open_graph_type - ), - 'opengraphAuthor' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->open_graph_article_author - ), - 'opengraphPublisher' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->open_graph_article_publisher - ), - 'opengraphPublishedTime' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->open_graph_article_published_time - ), - 'opengraphModifiedTime' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->open_graph_article_modified_time - ), - 'opengraphDescription' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->open_graph_description - ), - 'opengraphImage' => $context - ->get_loader('post') - ->load_deferred( - absint($meta['wpseo_opengraph-image-id']) - ), - 'twitterCardType' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->twitter_card - ), - 'twitterTitle' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->twitter_title - ), - 'twitterDescription' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->twitter_description - ), - 'twitterImage' => $context - ->get_loader('post') - ->load_deferred( - absint($meta['wpseo_twitter-image-id']) - ), - 'canonical' => isset( - YoastSEO()->meta->for_term($term->term_id)->canonical - ) - ? wp_gql_seo_format_string( - YoastSEO()->meta->for_term($term->term_id) - ->canonical - ) - : null, - 'breadcrumbs' => YoastSEO()->meta->for_term( - $term->term_id - )->breadcrumbs, - 'cornerstone' => boolval( - YoastSEO()->meta->for_term($term->term_id) - ->is_cornerstone - ), - 'fullHead' => is_string( - YoastSEO() - ->meta->for_term($term->term_id) - ->get_head() - ) - ? YoastSEO() - ->meta->for_term($term->term_id) - ->get_head() - : YoastSEO() - ->meta->for_term($term->term_id) - ->get_head()->html, - 'schema' => [ - 'raw' => json_encode( - $schemaArray, - JSON_UNESCAPED_SLASHES - ), - ], - ]; - wp_reset_query(); + return $deps; +} - return !empty($seo) ? $seo : null; - }, - ]); - } - } - }); -}); +/** + * Initializes WPGraphQL SEO + * + * @return \WPGraphQL\YoastSEO\Seo|false + */ +function wp_gql_seo_init() { + wp_gql_seo_constants(); + + $not_ready = wp_gql_seo_dependencies_not_ready(); + + if ( empty( $not_ready ) && defined( 'WPGRAPHQL_SEO_PLUGIN_DIR' ) ) { + require_once WPGRAPHQL_SEO_PLUGIN_DIR . 'src/Seo.php'; + return \WPGraphQL\YoastSEO\Seo::instance(); + } + + foreach ( $not_ready as $dep ) { + $display_admin_notice = static function() use ( $dep ) { + ?> +
=5.3", - "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" - }, - "conflict": { - "squizlabs/php_codesniffer": "2.6.2" + "php": ">=5.5" }, "require-dev": { - "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" + "symfony/phpunit-bridge": "^4.4 || ^5.1" }, - "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", - "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.5-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] }, - "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", "license": [ - "LGPL-3.0-or-later" + "MIT" ], "authors": [ { - "name": "Wim Godden", - "homepage": "https://github.com/wimg", - "role": "lead" + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" }, { - "name": "Juliette Reinders Folmer", - "homepage": "https://github.com/jrfnl", - "role": "lead" + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" }, { - "name": "Contributors", - "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" } ], - "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", - "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", + "description": "Guzzle promises library", "keywords": [ - "compatibility", - "phpcs", - "standards" + "promise" ], "support": { - "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", - "source": "https://github.com/PHPCompatibility/PHPCompatibility" + "issues": "https://github.com/guzzle/promises/issues", + "source": "https://github.com/guzzle/promises/tree/1.5.1" }, - "time": "2019-12-27T09:44:58+00:00" + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", + "type": "tidelift" + } + ], + "time": "2021-10-22T20:56:57+00:00" }, { - "name": "phpcompatibility/phpcompatibility-paragonie", - "version": "1.3.1", + "name": "guzzlehttp/psr7", + "version": "2.1.0", "source": { "type": "git", - "url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git", - "reference": "ddabec839cc003651f2ce695c938686d1086cf43" + "url": "https://github.com/guzzle/psr7.git", + "reference": "089edd38f5b8abba6cb01567c2a8aaa47cec4c72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/ddabec839cc003651f2ce695c938686d1086cf43", - "reference": "ddabec839cc003651f2ce695c938686d1086cf43", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/089edd38f5b8abba6cb01567c2a8aaa47cec4c72", + "reference": "089edd38f5b8abba6cb01567c2a8aaa47cec4c72", "shasum": "" }, "require": { - "phpcompatibility/php-compatibility": "^9.0" + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0", + "ralouphie/getallheaders": "^3.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7", - "paragonie/random_compat": "dev-master", - "paragonie/sodium_compat": "dev-master" + "bamarni/composer-bin-plugin": "^1.4.1", + "http-interop/http-factory-tests": "^0.9", + "phpunit/phpunit": "^8.5.8 || ^9.3.10" }, "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", - "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } }, - "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", "license": [ - "LGPL-3.0-or-later" + "MIT" ], "authors": [ { - "name": "Wim Godden", - "role": "lead" + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" }, { - "name": "Juliette Reinders Folmer", - "role": "lead" + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" } ], - "description": "A set of rulesets for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by the Paragonie polyfill libraries.", - "homepage": "http://phpcompatibility.com/", + "description": "PSR-7 message implementation that also provides common utility methods", "keywords": [ - "compatibility", - "paragonie", - "phpcs", - "polyfill", - "standards" + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" ], "support": { - "issues": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/issues", - "source": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie" + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/2.1.0" }, - "time": "2021-02-15T10:24:51+00:00" + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", + "type": "tidelift" + } + ], + "time": "2021-10-06T17:43:30+00:00" }, { - "name": "phpcompatibility/phpcompatibility-wp", - "version": "2.1.3", + "name": "j4mie/idiorm", + "version": "v1.5.7", "source": { "type": "git", - "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git", - "reference": "d55de55f88697b9cdb94bccf04f14eb3b11cf308" + "url": "https://github.com/j4mie/idiorm.git", + "reference": "d23f97053ef5d0b988a02c6a71eb5c6118b2f5b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/d55de55f88697b9cdb94bccf04f14eb3b11cf308", - "reference": "d55de55f88697b9cdb94bccf04f14eb3b11cf308", + "url": "https://api.github.com/repos/j4mie/idiorm/zipball/d23f97053ef5d0b988a02c6a71eb5c6118b2f5b4", + "reference": "d23f97053ef5d0b988a02c6a71eb5c6118b2f5b4", "shasum": "" }, "require": { - "phpcompatibility/php-compatibility": "^9.0", - "phpcompatibility/phpcompatibility-paragonie": "^1.0" + "php": ">=5.2.0" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7" + "ext-pdo_sqlite": "*", + "phpunit/phpunit": "^4.8" }, - "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", - "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + "type": "library", + "autoload": { + "classmap": [ + "idiorm.php" + ] }, - "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", "license": [ - "LGPL-3.0-or-later" + "BSD-2-Clause", + "BSD-3-Clause", + "BSD-4-Clause" ], "authors": [ { - "name": "Wim Godden", - "role": "lead" + "name": "Jamie Matthews", + "email": "jamie.matthews@gmail.com", + "homepage": "http://j4mie.org", + "role": "Developer" }, { - "name": "Juliette Reinders Folmer", - "role": "lead" + "name": "Simon Holywell", + "email": "treffynnon@php.net", + "homepage": "http://simonholywell.com", + "role": "Maintainer" + }, + { + "name": "Durham Hale", + "email": "me@durhamhale.com", + "homepage": "http://durhamhale.com", + "role": "Maintainer" } ], - "description": "A ruleset for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by WordPress.", - "homepage": "http://phpcompatibility.com/", + "description": "A lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5", + "homepage": "http://j4mie.github.com/idiormandparis", "keywords": [ - "compatibility", - "phpcs", - "standards", - "wordpress" + "idiorm", + "orm", + "query builder" ], "support": { - "issues": "https://github.com/PHPCompatibility/PHPCompatibilityWP/issues", - "source": "https://github.com/PHPCompatibility/PHPCompatibilityWP" + "issues": "https://github.com/j4mie/idiorm/issues", + "source": "https://github.com/j4mie/idiorm" }, - "time": "2021-12-30T16:37:40+00:00" + "time": "2020-04-29T00:37:09+00:00" }, { - "name": "phpstan/extension-installer", - "version": "1.1.0", + "name": "league/oauth2-client", + "version": "2.6.1", "source": { "type": "git", - "url": "https://github.com/phpstan/extension-installer.git", - "reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051" + "url": "https://github.com/thephpleague/oauth2-client.git", + "reference": "2334c249907190c132364f5dae0287ab8666aa19" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/66c7adc9dfa38b6b5838a9fb728b68a7d8348051", - "reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051", + "url": "https://api.github.com/repos/thephpleague/oauth2-client/zipball/2334c249907190c132364f5dae0287ab8666aa19", + "reference": "2334c249907190c132364f5dae0287ab8666aa19", "shasum": "" }, "require": { - "composer-plugin-api": "^1.1 || ^2.0", - "php": "^7.1 || ^8.0", - "phpstan/phpstan": ">=0.11.6" + "guzzlehttp/guzzle": "^6.0 || ^7.0", + "paragonie/random_compat": "^1 || ^2 || ^9.99", + "php": "^5.6 || ^7.0 || ^8.0" }, "require-dev": { - "composer/composer": "^1.8", - "phing/phing": "^2.16.3", - "php-parallel-lint/php-parallel-lint": "^1.2.0", - "phpstan/phpstan-strict-rules": "^0.11 || ^0.12" + "mockery/mockery": "^1.3.5", + "php-parallel-lint/php-parallel-lint": "^1.3.1", + "phpunit/phpunit": "^5.7 || ^6.0 || ^9.5", + "squizlabs/php_codesniffer": "^2.3 || ^3.0" }, - "type": "composer-plugin", + "type": "library", "extra": { - "class": "PHPStan\\ExtensionInstaller\\Plugin" + "branch-alias": { + "dev-2.x": "2.0.x-dev" + } }, "autoload": { "psr-4": { - "PHPStan\\ExtensionInstaller\\": "src/" + "League\\OAuth2\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alex Bilbie", + "email": "hello@alexbilbie.com", + "homepage": "http://www.alexbilbie.com", + "role": "Developer" + }, + { + "name": "Woody Gilk", + "homepage": "https://github.com/shadowhand", + "role": "Contributor" + } + ], + "description": "OAuth 2.0 Client Library", + "keywords": [ + "Authentication", + "SSO", + "authorization", + "identity", + "idp", + "oauth", + "oauth2", + "single sign on" + ], + "support": { + "issues": "https://github.com/thephpleague/oauth2-client/issues", + "source": "https://github.com/thephpleague/oauth2-client/tree/2.6.1" + }, + "time": "2021-12-22T16:42:49+00:00" + }, + { + "name": "paragonie/random_compat", + "version": "v9.99.100", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a", + "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a", + "shasum": "" + }, + "require": { + "php": ">= 7" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*", + "vimeo/psalm": "^1" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "polyfill", + "pseudorandom", + "random" + ], + "support": { + "email": "info@paragonie.com", + "issues": "https://github.com/paragonie/random_compat/issues", + "source": "https://github.com/paragonie/random_compat" + }, + "time": "2020-10-15T08:29:30+00:00" + }, + { + "name": "php-stubs/wordpress-seo-stubs", + "version": "v17.2", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/wordpress-seo-stubs.git", + "reference": "f4b272159d3091f07596e63f14525f8da0919caf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/wordpress-seo-stubs/zipball/f4b272159d3091f07596e63f14525f8da0919caf", + "reference": "f4b272159d3091f07596e63f14525f8da0919caf", + "shasum": "" + }, + "require": { + "j4mie/idiorm": "^1.5", + "league/oauth2-client": "^2.4", + "php-stubs/wordpress-stubs": "^5.3.0", + "psr/log": "^1.0", + "symfony/config": "^3.4", + "symfony/dependency-injection": "^3.4" + }, + "require-dev": { + "giacocorsiglia/stubs-generator": "^0.5.0", + "php": "~7.1" + }, + "suggest": { + "symfony/polyfill-php73": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Yoas SEO function and class declaration stubs for static analysis.", + "homepage": "https://github.com/php-stubs/wordpress-seo-stubs", + "keywords": [ + "PHPStan", + "seo", + "static analysis", + "wordpress", + "yoast" + ], + "support": { + "issues": "https://github.com/php-stubs/wordpress-seo-stubs/issues", + "source": "https://github.com/php-stubs/wordpress-seo-stubs/tree/v17.2" + }, + "time": "2021-09-22T12:05:07+00:00" + }, + { + "name": "php-stubs/wordpress-stubs", + "version": "v5.9.0", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/wordpress-stubs.git", + "reference": "0fa8dd9a1bd2a1b60e85afc6c798fca1f599cc1b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/0fa8dd9a1bd2a1b60e85afc6c798fca1f599cc1b", + "reference": "0fa8dd9a1bd2a1b60e85afc6c798fca1f599cc1b", + "shasum": "" + }, + "replace": { + "giacocorsiglia/wordpress-stubs": "*" + }, + "require-dev": { + "nikic/php-parser": "< 4.12.0", + "php": "~7.3 || ~8.0", + "php-stubs/generator": "^0.8.0", + "phpdocumentor/reflection-docblock": "^5.3", + "phpstan/phpstan": "^1.2" + }, + "suggest": { + "paragonie/sodium_compat": "Pure PHP implementation of libsodium", + "symfony/polyfill-php73": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "WordPress function and class declaration stubs for static analysis.", + "homepage": "https://github.com/php-stubs/wordpress-stubs", + "keywords": [ + "PHPStan", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/php-stubs/wordpress-stubs/issues", + "source": "https://github.com/php-stubs/wordpress-stubs/tree/v5.9.0" + }, + "time": "2022-01-26T00:27:45+00:00" + }, + { + "name": "phpcompatibility/php-compatibility", + "version": "9.3.5", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" + }, + "conflict": { + "squizlabs/php_codesniffer": "2.6.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "homepage": "https://github.com/wimg", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" + } + ], + "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", + "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", + "keywords": [ + "compatibility", + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibility" + }, + "time": "2019-12-27T09:44:58+00:00" + }, + { + "name": "phpcompatibility/phpcompatibility-paragonie", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git", + "reference": "ddabec839cc003651f2ce695c938686d1086cf43" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/ddabec839cc003651f2ce695c938686d1086cf43", + "reference": "ddabec839cc003651f2ce695c938686d1086cf43", + "shasum": "" + }, + "require": { + "phpcompatibility/php-compatibility": "^9.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7", + "paragonie/random_compat": "dev-master", + "paragonie/sodium_compat": "dev-master" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "lead" + } + ], + "description": "A set of rulesets for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by the Paragonie polyfill libraries.", + "homepage": "http://phpcompatibility.com/", + "keywords": [ + "compatibility", + "paragonie", + "phpcs", + "polyfill", + "standards" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie" + }, + "time": "2021-02-15T10:24:51+00:00" + }, + { + "name": "phpcompatibility/phpcompatibility-wp", + "version": "2.1.3", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git", + "reference": "d55de55f88697b9cdb94bccf04f14eb3b11cf308" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/d55de55f88697b9cdb94bccf04f14eb3b11cf308", + "reference": "d55de55f88697b9cdb94bccf04f14eb3b11cf308", + "shasum": "" + }, + "require": { + "phpcompatibility/php-compatibility": "^9.0", + "phpcompatibility/phpcompatibility-paragonie": "^1.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "lead" + } + ], + "description": "A ruleset for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by WordPress.", + "homepage": "http://phpcompatibility.com/", + "keywords": [ + "compatibility", + "phpcs", + "standards", + "wordpress" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibilityWP/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibilityWP" + }, + "time": "2021-12-30T16:37:40+00:00" + }, + { + "name": "phpstan/extension-installer", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/66c7adc9dfa38b6b5838a9fb728b68a7d8348051", + "reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.1 || ^2.0", + "php": "^7.1 || ^8.0", + "phpstan/phpstan": ">=0.11.6" + }, + "require-dev": { + "composer/composer": "^1.8", + "phing/phing": "^2.16.3", + "php-parallel-lint/php-parallel-lint": "^1.2.0", + "phpstan/phpstan-strict-rules": "^0.11 || ^0.12" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPStan\\ExtensionInstaller\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPStan\\ExtensionInstaller\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Composer plugin for automatic installation of PHPStan extensions", + "support": { + "issues": "https://github.com/phpstan/extension-installer/issues", + "source": "https://github.com/phpstan/extension-installer/tree/1.1.0" + }, + "time": "2020-12-13T13:06:13+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "1.4.6", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "8a7761f1c520e0dad6e04d862fdc697445457cfe" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/8a7761f1c520e0dad6e04d862fdc697445457cfe", + "reference": "8a7761f1c520e0dad6e04d862fdc697445457cfe", + "shasum": "" + }, + "require": { + "php": "^7.1|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/1.4.6" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpstan", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2022-02-06T12:56:13+00:00" + }, + { + "name": "poolshark/wp-graphql-stubs", + "version": "v0.0.2", + "source": { + "type": "git", + "url": "https://github.com/Poolshark/wp-graphql-stubs.git", + "reference": "66ba54188d04788849abd07bfc9fff511839cdb3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Poolshark/wp-graphql-stubs/zipball/66ba54188d04788849abd07bfc9fff511839cdb3", + "reference": "66ba54188d04788849abd07bfc9fff511839cdb3", + "shasum": "" + }, + "require-dev": { + "php": "^7.4" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Flo Ragossnig", + "email": "florian@webleaders.at" + } + ], + "description": "WP GraphQL Stubs for VS Code and others.", + "support": { + "issues": "https://github.com/Poolshark/wp-graphql-stubs/issues", + "source": "https://github.com/Poolshark/wp-graphql-stubs/tree/v0.0.2" + }, + "time": "2021-03-20T07:43:55+00:00" + }, + { + "name": "psr/container", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/1.1.2" + }, + "time": "2021-11-05T16:50:12+00:00" + }, + { + "name": "psr/http-client", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", + "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "support": { + "source": "https://github.com/php-fig/http-client/tree/master" + }, + "time": "2020-06-29T06:28:15+00:00" + }, + { + "name": "psr/http-factory", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be", + "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be", + "shasum": "" + }, + "require": { + "php": ">=7.0.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory/tree/master" + }, + "time": "2019-04-30T12:38:16+00:00" + }, + { + "name": "psr/http-message", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/master" + }, + "time": "2016-08-06T14:39:51+00:00" + }, + { + "name": "psr/log", + "version": "1.1.4", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/1.1.4" + }, + "time": "2021-05-03T11:20:27+00:00" + }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, + "time": "2019-03-08T08:55:37+00:00" + }, + { + "name": "sirbrillig/phpcs-variable-analysis", + "version": "v2.11.2", + "source": { + "type": "git", + "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git", + "reference": "3fad28475bfbdbf8aa5c440f8a8f89824983d85e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/3fad28475bfbdbf8aa5c440f8a8f89824983d85e", + "reference": "3fad28475bfbdbf8aa5c440f8a8f89824983d85e", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "squizlabs/php_codesniffer": "^3.5" + }, + "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" + }, + "type": "phpcodesniffer-standard", + "autoload": { + "psr-4": { + "VariableAnalysis\\": "VariableAnalysis/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Sam Graham", + "email": "php-codesniffer-variableanalysis@illusori.co.uk" + }, + { + "name": "Payton Swick", + "email": "payton@foolord.com" + } + ], + "description": "A PHPCS sniff to detect problems with variables.", + "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" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.6.2", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5e4e71592f69da17871dba6e80dd51bce74a351a", + "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", + "source": "https://github.com/squizlabs/PHP_CodeSniffer", + "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + }, + "time": "2021-12-12T21:44:58+00:00" + }, + { + "name": "symfony/config", + "version": "v3.4.47", + "source": { + "type": "git", + "url": "https://github.com/symfony/config.git", + "reference": "bc6b3fd3930d4b53a60b42fe2ed6fc466b75f03f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/config/zipball/bc6b3fd3930d4b53a60b42fe2ed6fc466b75f03f", + "reference": "bc6b3fd3930d4b53a60b42fe2ed6fc466b75f03f", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/filesystem": "~2.8|~3.0|~4.0", + "symfony/polyfill-ctype": "~1.8" + }, + "conflict": { + "symfony/dependency-injection": "<3.3", + "symfony/finder": "<3.3" + }, + "require-dev": { + "symfony/dependency-injection": "~3.3|~4.0", + "symfony/event-dispatcher": "~3.3|~4.0", + "symfony/finder": "~3.3|~4.0", + "symfony/yaml": "~3.0|~4.0" + }, + "suggest": { + "symfony/yaml": "To use the yaml reference dumper" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Config\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Config Component", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/config/tree/v3.4.47" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-10-24T10:57:07+00:00" + }, + { + "name": "symfony/dependency-injection", + "version": "v3.4.47", + "source": { + "type": "git", + "url": "https://github.com/symfony/dependency-injection.git", + "reference": "51d2a2708c6ceadad84393f8581df1dcf9e5e84b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/51d2a2708c6ceadad84393f8581df1dcf9e5e84b", + "reference": "51d2a2708c6ceadad84393f8581df1dcf9e5e84b", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "psr/container": "^1.0" + }, + "conflict": { + "symfony/config": "<3.3.7", + "symfony/finder": "<3.3", + "symfony/proxy-manager-bridge": "<3.4", + "symfony/yaml": "<3.4" + }, + "provide": { + "psr/container-implementation": "1.0" + }, + "require-dev": { + "symfony/config": "~3.3|~4.0", + "symfony/expression-language": "~2.8|~3.0|~4.0", + "symfony/yaml": "~3.4|~4.0" + }, + "suggest": { + "symfony/config": "", + "symfony/expression-language": "For using expressions in service container configuration", + "symfony/finder": "For using double-star glob patterns or when GLOB_BRACE portability is required", + "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", + "symfony/yaml": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\DependencyInjection\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony DependencyInjection Component", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/dependency-injection/tree/v3.4.47" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" ], - "description": "Composer plugin for automatic installation of PHPStan extensions", - "support": { - "issues": "https://github.com/phpstan/extension-installer/issues", - "source": "https://github.com/phpstan/extension-installer/tree/1.1.0" - }, - "time": "2020-12-13T13:06:13+00:00" + "time": "2020-10-24T10:57:07+00:00" }, { - "name": "phpstan/phpstan", - "version": "1.4.6", + "name": "symfony/deprecation-contracts", + "version": "v3.0.0", "source": { "type": "git", - "url": "https://github.com/phpstan/phpstan.git", - "reference": "8a7761f1c520e0dad6e04d862fdc697445457cfe" + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "c726b64c1ccfe2896cb7df2e1331c357ad1c8ced" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/8a7761f1c520e0dad6e04d862fdc697445457cfe", - "reference": "8a7761f1c520e0dad6e04d862fdc697445457cfe", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/c726b64c1ccfe2896cb7df2e1331c357ad1c8ced", + "reference": "c726b64c1ccfe2896cb7df2e1331c357ad1c8ced", "shasum": "" }, "require": { - "php": "^7.1|^8.0" + "php": ">=8.0.2" }, - "conflict": { - "phpstan/phpstan-shim": "*" - }, - "bin": [ - "phpstan", - "phpstan.phar" - ], "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-main": "3.0-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" } }, "autoload": { "files": [ - "bootstrap.php" + "function.php" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "description": "PHPStan - PHP Static Analysis Tool", + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", "support": { - "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.4.6" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.0.0" }, "funding": [ { - "url": "https://github.com/ondrejmirtes", - "type": "github" + "url": "https://symfony.com/sponsor", + "type": "custom" }, { - "url": "https://github.com/phpstan", + "url": "https://github.com/fabpot", "type": "github" }, { - "url": "https://www.patreon.com/phpstan", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2022-02-06T12:56:13+00:00" + "time": "2021-11-01T23:48:49+00:00" }, { - "name": "poolshark/wp-graphql-stubs", - "version": "v0.0.2", + "name": "symfony/filesystem", + "version": "v4.4.37", "source": { "type": "git", - "url": "https://github.com/Poolshark/wp-graphql-stubs.git", - "reference": "66ba54188d04788849abd07bfc9fff511839cdb3" + "url": "https://github.com/symfony/filesystem.git", + "reference": "c59f37705c3e513ae55b2735f128f4ce363c82ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Poolshark/wp-graphql-stubs/zipball/66ba54188d04788849abd07bfc9fff511839cdb3", - "reference": "66ba54188d04788849abd07bfc9fff511839cdb3", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/c59f37705c3e513ae55b2735f128f4ce363c82ec", + "reference": "c59f37705c3e513ae55b2735f128f4ce363c82ec", "shasum": "" }, - "require-dev": { - "php": "^7.4" + "require": { + "php": ">=7.1.3", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-php80": "^1.16" }, "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { - "name": "Flo Ragossnig", - "email": "florian@webleaders.at" + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "WP GraphQL Stubs for VS Code and others.", + "description": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", "support": { - "issues": "https://github.com/Poolshark/wp-graphql-stubs/issues", - "source": "https://github.com/Poolshark/wp-graphql-stubs/tree/v0.0.2" + "source": "https://github.com/symfony/filesystem/tree/v4.4.37" }, - "time": "2021-03-20T07:43:55+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-01-02T09:41:36+00:00" }, { - "name": "sirbrillig/phpcs-variable-analysis", - "version": "v2.11.2", + "name": "symfony/polyfill-ctype", + "version": "v1.24.0", "source": { "type": "git", - "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git", - "reference": "3fad28475bfbdbf8aa5c440f8a8f89824983d85e" + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "30885182c981ab175d4d034db0f6f469898070ab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/3fad28475bfbdbf8aa5c440f8a8f89824983d85e", - "reference": "3fad28475bfbdbf8aa5c440f8a8f89824983d85e", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/30885182c981ab175d4d034db0f6f469898070ab", + "reference": "30885182c981ab175d4d034db0f6f469898070ab", "shasum": "" }, "require": { - "php": ">=5.4.0", - "squizlabs/php_codesniffer": "^3.5" + "php": ">=7.1" }, - "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" + "provide": { + "ext-ctype": "*" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } }, - "type": "phpcodesniffer-standard", "autoload": { "psr-4": { - "VariableAnalysis\\": "VariableAnalysis/" - } + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-2-Clause" + "MIT" ], "authors": [ { - "name": "Sam Graham", - "email": "php-codesniffer-variableanalysis@illusori.co.uk" + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" }, { - "name": "Payton Swick", - "email": "payton@foolord.com" + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "A PHPCS sniff to detect problems with variables.", + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], "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" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.24.0" }, - "time": "2021-07-06T23:45:17+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-10-20T20:35:02+00:00" }, { - "name": "squizlabs/php_codesniffer", - "version": "3.6.2", + "name": "symfony/polyfill-php73", + "version": "v1.24.0", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a" + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5e4e71592f69da17871dba6e80dd51bce74a351a", - "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/cc5db0e22b3cb4111010e48785a97f670b350ca5", + "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5", "shasum": "" }, "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "php": ">=7.1" }, - "bin": [ - "bin/phpcs", - "bin/phpcbf" - ], "type": "library", "extra": { "branch-alias": { - "dev-master": "3.x-dev" + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Greg Sherwood", - "role": "lead" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", "keywords": [ - "phpcs", - "standards" + "compatibility", + "polyfill", + "portable", + "shim" ], "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.24.0" }, - "time": "2021-12-12T21:44:58+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-06-05T21:20:04+00:00" }, { - "name": "symfony/polyfill-php73", + "name": "symfony/polyfill-php80", "version": "v1.24.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5" + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/cc5db0e22b3cb4111010e48785a97f670b350ca5", - "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/57b712b08eddb97c762a8caa32c84e037892d2e9", + "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9", "shasum": "" }, "require": { @@ -638,7 +1949,7 @@ "bootstrap.php" ], "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" + "Symfony\\Polyfill\\Php80\\": "" }, "classmap": [ "Resources/stubs" @@ -649,6 +1960,10 @@ "MIT" ], "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, { "name": "Nicolas Grekas", "email": "p@tchwork.com" @@ -658,7 +1973,7 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", "homepage": "https://symfony.com", "keywords": [ "compatibility", @@ -667,7 +1982,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.24.0" }, "funding": [ { @@ -683,7 +1998,7 @@ "type": "tidelift" } ], - "time": "2021-06-05T21:20:04+00:00" + "time": "2021-09-13T13:58:33+00:00" }, { "name": "szepeviktor/phpstan-wordpress", diff --git a/index.php b/index.php index e71af0e..b02073d 100644 --- a/index.php +++ b/index.php @@ -1 +1 @@ - + + @@ -33,10 +35,10 @@ - + - + diff --git a/phpstan.neon.dist b/phpstan.neon.dist index aa48a81..efa3cdb 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -4,6 +4,10 @@ parameters: checkMissingIterableValueType: false featureToggles: disableRuntimeReflectionProvider: true + stubFiles: + # Simulate added properties + - phpstan/class-wp-post-type.stub + - phpstan/class-wp-taxonomy.stub bootstrapFiles: - access-functions.php - wp-graphql-yoast-seo.php @@ -14,5 +18,3 @@ parameters: scanDirectories: - ../wp-graphql/ - ../wordpress-seo/ - ignoreErrors: - - '#^Function apply_filters(_ref_array)? invoked with ([1-9]|1[0-2]) parameters, 2 required\.$#' diff --git a/phpstan/class-wp-post-type.stub b/phpstan/class-wp-post-type.stub new file mode 100644 index 0000000..33a7209 --- /dev/null +++ b/phpstan/class-wp-post-type.stub @@ -0,0 +1,9 @@ +hierarchical ) && ! isset( $tax->graphql_single_name ) ) { + if ( empty( $tax->hierarchical ) && ! isset( $tax->graphql_single_name ) ) { continue; } @@ -63,7 +62,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { 'type' => 'Boolean', // translators: Taxonomy name. 'description' => sprintf( __( 'The Yoast SEO primary %s.', 'wp-graphql-yoast-seo' ), $tax->labels->name ), - 'resolve' => static function( $item, array $args, AppContext $context ) use ( $tax ) { + 'resolve' => static function( $item ) use ( $tax ) { $post_id = $item['source']->ID; $term_id = $item['node']->term_id; diff --git a/src/CoreSchemaFilters.php b/src/CoreSchemaFilters.php index d404531..559fcb6 100644 --- a/src/CoreSchemaFilters.php +++ b/src/CoreSchemaFilters.php @@ -8,7 +8,6 @@ namespace WPGraphQL\YoastSEO; -use WPGraphQL; use WPGraphQL\YoastSEO\Interfaces\Hookable; use WPGraphQL\YoastSEO\Type\WPInterface\ContentNodeWithSEO; use WPGraphQL\YoastSEO\Type\WPInterface\TermNodeWithSEO; @@ -22,7 +21,6 @@ class CoreSchemaFilters implements Hookable { */ public static function register_hooks(): void { add_filter( 'graphql_wp_object_type_config', [ __CLASS__, 'set_object_type_config' ] ); - add_filter( 'graphql_wp_connection_type_config', [ __CLASS__, 'set_connection_type_config' ] ); } /** @@ -55,28 +53,6 @@ public static function set_object_type_config( array $config ) : array { ); } - return $config; - } - - public static function set_connection_type_config( array $config ) : array { - global $wp_post_types, $wp_taxonomies; - $post_types = WPGraphQL::get_allowed_post_types(); - $taxonomies = WPGraphQL::get_allowed_taxonomies(); - // If WooCommerce installed then add these post types and taxonomies - if ( class_exists( '\WooCommerce' ) ) { - array_push( $post_types, 'product' ); - array_push( $taxonomies, 'productCategory' ); - } - if ( ! in_array( $config['fromType'], $post_types, true ) || ! in_array( $config['toType'], $taxonomies, true ) ) { - error_log( 'BAD:' . $config['fromType'] . ' to ' . $config['toType'] ); - return $config; - } - - error_log( 'GOOD:' . $config['fromType'] . ' to ' . $config['toType'] ); - - - - return $config; } } diff --git a/src/Type/WPInterface/ContentNodeWithSEO.php b/src/Type/WPInterface/ContentNodeWithSEO.php index 887c82f..7e31209 100644 --- a/src/Type/WPInterface/ContentNodeWithSEO.php +++ b/src/Type/WPInterface/ContentNodeWithSEO.php @@ -13,8 +13,7 @@ use WPGraphQL\YoastSEO\Interfaces\Registrable; use WPGraphQL\YoastSEO\Interfaces\Type; use WPGraphQL\YoastSEO\Type\WPObject\PostTypeSEO; -use WPGraphQL\YoastSEO\Type\WPObject\SEOBaseFields; -use WPGraphQL\YoastSEO\Type\WPObject\SEOPostTypeBreadcrumbs; +use function YoastSEO; /** * Class - ContentNodeWithSEO @@ -60,9 +59,6 @@ public static function get_fields() : array { 'seo' => [ 'type' => PostTypeSEO::$type, 'resolve' => static function( $post, array $args, AppContext $context ) { - // Base array. - $seo = []; - $map = [ '@id' => 'id', '@type' => 'type', @@ -70,161 +66,57 @@ public static function get_fields() : array { '@context' => 'context', ]; - $schemaArray = YoastSEO()->meta->for_post( $post->ID ) - ->schema; + $yoast_meta = YoastSEO()->meta->for_post( $post->ID ); + + + $schema_array = isset( $yoast_meta->schema ) ? $yoast_meta->schema : []; - // https://developer.yoast.com/blog/yoast-seo-14-0-using-yoast-seo-surfaces/ - $robots = YoastSEO()->meta->for_post( $post->ID ) - ->robots; + // @see https://developer.yoast.com/blog/yoast-seo-14-0-using-yoast-seo-surfaces/ + $robots = isset( $yoast_meta->robots ) ? $yoast_meta->robots : []; - // Get data + // Get data. $seo = [ - 'title' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID )->title - ), - 'metaDesc' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->description - ), - 'focuskw' => wp_gql_seo_format_string( - get_post_meta( - $post->ID, - '_yoast_wpseo_focuskw', - true - ) - ), - 'metaKeywords' => wp_gql_seo_format_string( - get_post_meta( - $post->ID, - '_yoast_wpseo_metakeywords', - true - ) - ), - 'metaRobotsNoindex' => $robots['index'], - 'metaRobotsNofollow' => $robots['follow'], - 'opengraphTitle' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->open_graph_title - ), - 'opengraphUrl' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->open_graph_url - ), - 'opengraphSiteName' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->open_graph_site_name - ), - 'opengraphType' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->open_graph_type - ), - 'opengraphAuthor' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->open_graph_article_author - ), - 'opengraphPublisher' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->open_graph_article_publisher - ), - 'opengraphPublishedTime' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->open_graph_article_published_time - ), - 'opengraphModifiedTime' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->open_graph_article_modified_time - ), - 'opengraphDescription' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->open_graph_description - ), - 'opengraphImage' => function () use ( - $post, - $context - ) { - $id = wp_gql_seo_get_og_image( - YoastSEO()->meta->for_post( $post->ID ) - ->open_graph_images - ); + 'title' => isset( $yoast_meta->title ) ? wp_gql_seo_format_string( $yoast_meta->title ) : null, + 'metaDesc' => isset( $yoast_meta->description ) ? wp_gql_seo_format_string( $yoast_meta->description ) : null, + 'focuskw' => wp_gql_seo_format_string( get_post_meta( $post->ID, '_yoast_wpseo_focuskw', true ) ) ?: null, + 'metaKeywords' => wp_gql_seo_format_string( get_post_meta( $post->ID, '_yoast_wpseo_metakeywords', true ) ) ?: null, + 'metaRobotsNoindex' => $robots['index'] ?? null, + 'metaRobotsNofollow' => $robots['follow'] ?? null, + 'opengraphTitle' => isset( $yoast_meta->open_graph_title ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_title ) : null, + 'opengraphUrl' => isset( $yoast_meta->open_graph_url ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_url ) : null, + 'opengraphSiteName' => isset( $yoast_meta->open_graph_site_name ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_site_name ) : null, + 'opengraphType' => isset( $yoast_meta->open_graph_type ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_type ) : null, + 'opengraphAuthor' => isset( $yoast_meta->open_graph_article_author ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_article_author ) : null, + 'opengraphPublisher' => isset( $yoast_meta->open_graph_article_publisher ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_article_publisher ) : null, + 'opengraphPublishedTime' => isset( $yoast_meta->open_graph_article_published_time ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_article_published_time ) : null, + 'opengraphModifiedTime' => isset( $yoast_meta->open_graph_article_modified_time ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_article_modified_time ) : null, + 'opengraphDescription' => isset( $yoast_meta->open_graph_description ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_description ) : null, + 'opengraphImage' => static function () use ( $context, $yoast_meta ) { + $id = ! empty( $yoast_meta->open_graph_images ) ? wp_gql_seo_get_og_image( $yoast_meta->open_graph_images ) : null; - return $context - ->get_loader( 'post' ) - ->load_deferred( absint( $id ) ); + return null !== $id ? $context->get_loader( 'post' )->load_deferred( absint( $id ) ) : null; }, - 'twitterCardType' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->twitter_card - ), - 'twitterTitle' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->twitter_title - ), - 'twitterDescription' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->twitter_description - ), - 'twitterImage' => function () use ( - $post, - $context - ) { - $id = wpcom_vip_attachment_url_to_postid( - YoastSEO()->meta->for_post( $post->ID ) - ->twitter_image - ); + 'twitterCardType' => isset( $yoast_meta->twitter_card ) ? wp_gql_seo_format_string( $yoast_meta->twitter_card ) : null, + 'twitterTitle' => isset( $yoast_meta->twitter_title ) ? wp_gql_seo_format_string( $yoast_meta->twitter_title ) : null, + 'twitterDescription' => isset( $yoast_meta->twitter_description ) ? wp_gql_seo_format_string( $yoast_meta->twitter_description ) : null, + 'twitterImage' => static function () use ( $context, $yoast_meta ) { + $id = isset( $yoast_meta->twitter_image ) ? wpcom_vip_attachment_url_to_postid( $yoast_meta->twitter_image ) : null; - return $context - ->get_loader( 'post' ) - ->load_deferred( absint( $id ) ); + return null !== $id ? $context->get_loader( 'post' )->load_deferred( absint( $id ) ) : null; }, - 'canonical' => wp_gql_seo_format_string( - YoastSEO()->meta->for_post( $post->ID ) - ->canonical - ), - 'readingTime' => floatval( - YoastSEO()->meta->for_post( $post->ID ) - ->estimated_reading_time_minutes - ), - 'breadcrumbs' => YoastSEO()->meta->for_post( - $post->ID - )->breadcrumbs, - 'cornerstone' => boolval( - YoastSEO()->meta->for_post( $post->ID ) - ->indexable->is_cornerstone - ), - 'fullHead' => is_string( - YoastSEO() - ->meta->for_post( $post->ID ) - ->get_head() - ) - ? YoastSEO() - ->meta->for_post( $post->ID ) - ->get_head() - : YoastSEO() - ->meta->for_post( $post->ID ) - ->get_head()->html, + 'canonical' => isset( $yoast_meta->canonical ) ? wp_gql_seo_format_string( $yoast_meta->canonical ) : null, + 'readingTime' => isset( $yoast_meta->estimated_reading_time_minutes ) ? floatval( $yoast_meta->estimated_reading_time_minutes ) : null, + 'breadcrumbs' => isset( $yoast_meta->breadcrumbs ) ? $yoast_meta->breadcrumbs : null, + 'cornerstone' => isset( $yoast_meta->indexable ) && isset( $yoast_meta->indexable->is_cornerstone ) ? boolval( $yoast_meta->indexable->is_cornerstone ) : null, + 'fullHead' => is_string( $yoast_meta->get_head() ) ? $yoast_meta->get_head() : $yoast_meta->get_head()->html, 'schema' => [ - 'pageType' => is_array( - YoastSEO()->meta->for_post( $post->ID ) - ->schema_page_type - ) - ? YoastSEO()->meta->for_post( $post->ID ) - ->schema_page_type - : [], - 'articleType' => is_array( - YoastSEO()->meta->for_post( $post->ID ) - ->schema_article_type - ) - ? YoastSEO()->meta->for_post( $post->ID ) - ->schema_article_type - : [], - 'raw' => json_encode( - $schemaArray, - JSON_UNESCAPED_SLASHES - ), + 'pageType' => isset( $yoast_meta->indexable ) && isset( $yoast_meta->indexable->schema_page_type ) ? $yoast_meta->schema_page_type : [], + 'articleType' => isset( $yoast_meta->indexable ) && isset( $yoast_meta->indexable->schema_article_type ) ? $yoast_meta->schema_article_type : [], + 'raw' => json_encode( $schema_array, JSON_UNESCAPED_SLASHES ), ], ]; - return ! empty( $seo ) ? $seo : null; + return $seo; }, ], ]; diff --git a/src/Type/WPInterface/TermNodeWithSEO.php b/src/Type/WPInterface/TermNodeWithSEO.php index c1bf548..e636bcd 100644 --- a/src/Type/WPInterface/TermNodeWithSEO.php +++ b/src/Type/WPInterface/TermNodeWithSEO.php @@ -8,6 +8,7 @@ namespace WPGraphQL\YoastSEO\Type\WPInterface; +use WP_Term; use WPGraphQL\AppContext; use WPGraphQL\YoastSEO\Interfaces\TypeWithFields; use WPGraphQL\Registry\TypeRegistry; @@ -43,8 +44,6 @@ public static function register( TypeRegistry $type_registry = null ) : void { 'fields' => self::get_fields(), ] ); - - // self::register_field(); } /** @@ -63,134 +62,55 @@ public static function get_fields() : array { 'type' => TaxonomySEO::$type, 'resolve' => static function( $term, array $args, AppContext $context ) { $term_obj = get_term( $term->term_id ); + // Bail early if no term exists. + if ( ! $term_obj instanceof WP_Term ) { + return null; + } - $meta = WPSEO_Taxonomy_Meta::get_term_meta( + $meta = WPSEO_Taxonomy_Meta::get_term_meta( (int) $term_obj->term_id, $term_obj->taxonomy ); - $robots = YoastSEO()->meta->for_term( $term->term_id )->robots; - $schemaArray = YoastSEO()->meta->for_term( $term->term_id ) - ->schema; + $yoast_meta = YoastSEO()->meta->for_term( $term->term_id ); + + $robots = isset( $yoast_meta->robots ) ? $yoast_meta->robots : []; + + $schema_array = isset( $yoast_meta->schema ) ? $yoast_meta->schema : []; - // Get data + // Get data. $seo = [ - 'title' => wp_gql_seo_format_string( - html_entity_decode( - wp_strip_all_tags( - YoastSEO()->meta->for_term( $term->term_id ) - ->title - ) - ) - ), - 'metaDesc' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->description - ), - 'focuskw' => isset( $meta['wpseo_focuskw'] ) - ? wp_gql_seo_format_string( $meta['wpseo_focuskw'] ) - : $meta['wpseo_focuskw'], - 'metaKeywords' => isset( $meta['wpseo_metakeywords'] ) - ? wp_gql_seo_format_string( - $meta['wpseo_metakeywords'] - ) - : null, - 'metaRobotsNoindex' => $robots['index'], - 'metaRobotsNofollow' => $robots['follow'], - 'opengraphTitle' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->open_graph_title - ), - 'opengraphUrl' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->open_graph_url - ), - 'opengraphSiteName' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->open_graph_site_name - ), - 'opengraphType' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->open_graph_type - ), - 'opengraphAuthor' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->open_graph_article_author - ), - 'opengraphPublisher' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->open_graph_article_publisher - ), - 'opengraphPublishedTime' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->open_graph_article_published_time - ), - 'opengraphModifiedTime' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->open_graph_article_modified_time - ), - 'opengraphDescription' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->open_graph_description - ), - 'opengraphImage' => $context - ->get_loader( 'post' ) - ->load_deferred( - absint( $meta['wpseo_opengraph-image-id'] ) - ), - 'twitterCardType' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->twitter_card - ), - 'twitterTitle' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->twitter_title - ), - 'twitterDescription' => wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->twitter_description - ), - 'twitterImage' => $context - ->get_loader( 'post' ) - ->load_deferred( - absint( $meta['wpseo_twitter-image-id'] ) - ), - 'canonical' => isset( - YoastSEO()->meta->for_term( $term->term_id )->canonical - ) - ? wp_gql_seo_format_string( - YoastSEO()->meta->for_term( $term->term_id ) - ->canonical - ) - : null, - 'breadcrumbs' => YoastSEO()->meta->for_term( - $term->term_id - )->breadcrumbs, - 'cornerstone' => boolval( - YoastSEO()->meta->for_term( $term->term_id ) - ->is_cornerstone - ), - 'fullHead' => is_string( - YoastSEO() - ->meta->for_term( $term->term_id ) - ->get_head() - ) - ? YoastSEO() - ->meta->for_term( $term->term_id ) - ->get_head() - : YoastSEO() - ->meta->for_term( $term->term_id ) - ->get_head()->html, + 'title' => isset( $yoast_meta->title ) ? wp_gql_seo_format_string( wp_strip_all_tags( $yoast_meta->title ) ) : null, + 'metaDesc' => isset( $yoast_meta->description ) ? wp_gql_seo_format_string( $yoast_meta->description ) : null, + 'focuskw' => isset( $meta['wpseo_focuskw'] ) ? wp_gql_seo_format_string( $meta['wpseo_focuskw'] ) : null, + 'metaKeywords' => isset( $meta['wpseo_metakeywords'] ) ? wp_gql_seo_format_string( $meta['wpseo_metakeywords'] ) : null, + 'metaRobotsNoindex' => $robots['index'] ?? null, + 'metaRobotsNofollow' => $robots['follow'] ?? null, + 'opengraphTitle' => isset( $yoast_meta->open_graph_title ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_title ) : null, + 'opengraphUrl' => isset( $yoast_meta->open_graph_url ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_url ) : null, + 'opengraphSiteName' => isset( $yoast_meta->open_graph_site_name ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_site_name ) : null, + 'opengraphType' => isset( $yoast_meta->open_graph_type ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_type ) : null, + 'opengraphAuthor' => isset( $yoast_meta->open_graph_article_author ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_article_author ) : null, + 'opengraphPublisher' => isset( $yoast_meta->open_graph_article_publisher ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_article_publisher ) : null, + 'opengraphPublishedTime' => isset( $yoast_meta->open_graph_article_published_time ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_article_published_time ) : null, + 'opengraphModifiedTime' => isset( $yoast_meta->open_graph_article_modified_time ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_article_modified_time ) : null, + 'opengraphDescription' => isset( $yoast_meta->open_graph_description ) ? wp_gql_seo_format_string( $yoast_meta->open_graph_description ) : null, + 'opengraphImage' => isset( $meta['wpseo_opengraph-image-id'] ) ? $context->get_loader( 'post' )->load_deferred( absint( $meta['wpseo_opengraph-image-id'] ) ) : null, + 'twitterCardType' => isset( $yoast_meta->twitter_card ) ? wp_gql_seo_format_string( $yoast_meta->twitter_card ) : null, + 'twitterTitle' => isset( $yoast_meta->twitter_title ) ? wp_gql_seo_format_string( $yoast_meta->twitter_title ) : null, + 'twitterDescription' => isset( $yoast_meta->twitter_description ) ? wp_gql_seo_format_string( $yoast_meta->twitter_description ) : null, + 'twitterImage' => isset( $meta['wpseo_twitter-image-id'] ) ? $context->get_loader( 'post' )->load_deferred( absint( $meta['wpseo_twitter-image-id'] ) ) : null, + 'canonical' => isset( $yoast_meta->canonical ) ? wp_gql_seo_format_string( $yoast_meta->canonical ) : null, + 'breadcrumbs' => isset( $yoast_meta->breadcrumbs ) ? $yoast_meta->breadcrumbs : null, + 'cornerstone' => ! empty( $yoast_meta->is_cornerstone ), + 'fullHead' => is_string( $yoast_meta->get_head() ) ? $yoast_meta->get_head() : $yoast_meta->get_head()->html, 'schema' => [ - 'raw' => json_encode( - $schemaArray, - JSON_UNESCAPED_SLASHES - ), + 'raw' => json_encode( $schema_array, JSON_UNESCAPED_SLASHES ), ], ]; wp_reset_query(); - return ! empty( $seo ) ? $seo : null; + return $seo; }, ], ]; diff --git a/src/Type/WPObject/Config/ContentTypes.php b/src/Type/WPObject/Config/ContentTypes.php index f7f466e..4ec485c 100644 --- a/src/Type/WPObject/Config/ContentTypes.php +++ b/src/Type/WPObject/Config/ContentTypes.php @@ -8,6 +8,7 @@ namespace WPGraphQL\YoastSEO\Type\WPObject\Config; +use WP_Post_Type; use WPGraphQL; use WPGraphQL\Registry\TypeRegistry; use WPGraphQL\YoastSEO\Interfaces\Registrable; @@ -52,15 +53,25 @@ public static function get_description() : string { public static function get_fields() : array { $post_types = WPGraphQL::get_allowed_post_types(); + // If WooCommerce installed then add these post types. + if ( class_exists( '\WooCommerce' ) ) { + $post_types[] = 'product'; + } + return self::build_content_types( $post_types ); } - private static function build_content_types( $types ) : array { + /** + * Builds a ContentType field configuration for each post type. + * + * @param string[] $types . + */ + private static function build_content_types( array $types ) : array { $carry = []; foreach ( $types as $type ) { $post_type_object = get_post_type_object( $type ); - if ( $post_type_object->graphql_single_name ) { + if ( $post_type_object instanceof WP_Post_Type && $post_type_object->graphql_single_name ) { $carry[ wp_gql_seo_get_field_key( $post_type_object->graphql_single_name ) ] = [ 'type' => ContentType::$type ]; } } diff --git a/src/Type/WPObject/Config/Social/Facebook.php b/src/Type/WPObject/Config/Social/Facebook.php index 7298a9c..93a4e41 100644 --- a/src/Type/WPObject/Config/Social/Facebook.php +++ b/src/Type/WPObject/Config/Social/Facebook.php @@ -31,6 +31,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / register_graphql_object_type( static::$type, [ + // phpcs:ignore // 'description' => static::get_description(), 'fields' => static::get_fields(), ] diff --git a/src/Type/WPObject/Config/Social/Instagram.php b/src/Type/WPObject/Config/Social/Instagram.php index c940fd3..c8c9b14 100644 --- a/src/Type/WPObject/Config/Social/Instagram.php +++ b/src/Type/WPObject/Config/Social/Instagram.php @@ -31,6 +31,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / register_graphql_object_type( static::$type, [ + // phpcs:ignore // 'description' => static::get_description(), 'fields' => static::get_fields(), ] diff --git a/src/Type/WPObject/Config/Social/LinkedIn.php b/src/Type/WPObject/Config/Social/LinkedIn.php index 2ce9277..52083c8 100644 --- a/src/Type/WPObject/Config/Social/LinkedIn.php +++ b/src/Type/WPObject/Config/Social/LinkedIn.php @@ -31,6 +31,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / register_graphql_object_type( static::$type, [ + // phpcs:ignore // 'description' => static::get_description(), 'fields' => static::get_fields(), ] diff --git a/src/Type/WPObject/Config/Social/MySpace.php b/src/Type/WPObject/Config/Social/MySpace.php index 7c039b8..3797eec 100644 --- a/src/Type/WPObject/Config/Social/MySpace.php +++ b/src/Type/WPObject/Config/Social/MySpace.php @@ -31,6 +31,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / register_graphql_object_type( static::$type, [ + // phpcs:ignore // 'description' => static::get_description(), 'fields' => static::get_fields(), ] diff --git a/src/Type/WPObject/Config/Social/Pinterest.php b/src/Type/WPObject/Config/Social/Pinterest.php index 9f8ace8..b9e13ef 100644 --- a/src/Type/WPObject/Config/Social/Pinterest.php +++ b/src/Type/WPObject/Config/Social/Pinterest.php @@ -31,6 +31,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / register_graphql_object_type( static::$type, [ + // phpcs:ignore // 'description' => static::get_description(), 'fields' => static::get_fields(), ] diff --git a/src/Type/WPObject/Config/Social/Twitter.php b/src/Type/WPObject/Config/Social/Twitter.php index 9d1e271..f2f2647 100644 --- a/src/Type/WPObject/Config/Social/Twitter.php +++ b/src/Type/WPObject/Config/Social/Twitter.php @@ -32,6 +32,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / register_graphql_object_type( static::$type, [ + // phpcs:ignore // 'description' => static::get_description(), 'fields' => static::get_fields(), ] @@ -43,7 +44,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / */ public static function get_description() : string { // @todo update description - return __( 'The Yoast SEO webmaster fields', 'wp-graphql-yoast-seo' ); + return __( 'placeholder description', 'wp-graphql-yoast-seo' ); } /** diff --git a/src/Type/WPObject/Config/Social/Wikipedia.php b/src/Type/WPObject/Config/Social/Wikipedia.php index b03c8a6..7aa212d 100644 --- a/src/Type/WPObject/Config/Social/Wikipedia.php +++ b/src/Type/WPObject/Config/Social/Wikipedia.php @@ -31,6 +31,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / register_graphql_object_type( static::$type, [ + // phpcs:ignore // 'description' => static::get_description(), 'fields' => static::get_fields(), ] diff --git a/src/Type/WPObject/Config/Social/Youtube.php b/src/Type/WPObject/Config/Social/Youtube.php index 5aa1799..935aa62 100644 --- a/src/Type/WPObject/Config/Social/Youtube.php +++ b/src/Type/WPObject/Config/Social/Youtube.php @@ -31,6 +31,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / register_graphql_object_type( static::$type, [ + // phpcs:ignore // 'description' => static::get_description(), 'fields' => static::get_fields(), ] diff --git a/src/Type/WPObject/SEOConfig.php b/src/Type/WPObject/SEOConfig.php index 18bebed..12c6636 100644 --- a/src/Type/WPObject/SEOConfig.php +++ b/src/Type/WPObject/SEOConfig.php @@ -8,6 +8,7 @@ namespace WPGraphQL\YoastSEO\Type\WPObject; +use WP_Post_Type; use WPGraphQL\AppContext; use WPGraphQL\Registry\TypeRegistry; use WPGraphQL\YoastSEO\Interfaces\Field; @@ -88,16 +89,15 @@ public static function register_field() : void { 'type' => static::$type, 'description' => __( 'Returns seo site data.', 'wp-graphql-yoast-seo' ), 'resolve' => static function ( $source, array $args, AppContext $context ) use ( $post_types ) { - $wpseo_options = WPSEO_Options::get_instance(); - $all = $wpseo_options->get_all(); + $wpseo_options = WPSEO_Options::get_all(); - $redirects_obj = class_exists( 'WPSEO_Redirect_Option' ) ? new WPSEO_Redirect_Option() : false; + $redirects_obj = class_exists( 'WPSEO_Redirect_Option' ) ? new \WPSEO_Redirect_Option() : false; $redirects = $redirects_obj ? $redirects_obj->get_from_option() : []; - $user_id = $all['company_or_person_user_id']; + $user_id = $wpseo_options['company_or_person_user_id']; $user = get_userdata( $user_id ); - $mappedRedirects = function ( $value ) { + $mapped_redirects = function ( $value ) { return [ 'origin' => $value['origin'], 'target' => $value['url'], @@ -106,111 +106,67 @@ public static function register_field() : void { ]; }; - $contentTypes = self::build_content_type_data( $post_types, $all ); + $contentTypes = self::build_content_type_data( $post_types, $wpseo_options ); return [ 'contentTypes' => $contentTypes, 'webmaster' => [ - 'baiduVerify' => wp_gql_seo_format_string( - $all['baiduverify'] - ), - 'googleVerify' => wp_gql_seo_format_string( - $all['googleverify'] - ), - 'msVerify' => wp_gql_seo_format_string( $all['msverify'] ), - 'yandexVerify' => wp_gql_seo_format_string( - $all['yandexverify'] - ), + 'baiduVerify' => isset( $wpseo_options['baiduverify'] ) ? wp_gql_seo_format_string( $wpseo_options['baiduverify'] ) : null, + 'googleVerify' => isset( $wpseo_options['googleverify'] ) ? wp_gql_seo_format_string( $wpseo_options['googleverify'] ) : null, + 'msVerify' => isset( $wpseo_options['msverify'] ) ? wp_gql_seo_format_string( $wpseo_options['msverify'] ) : null, + 'yandexVerify' => isset( $wpseo_options['yandexverify'] ) ? wp_gql_seo_format_string( $wpseo_options['yandexverify'] ) : null, ], 'social' => [ 'facebook' => [ - 'url' => wp_gql_seo_format_string( $all['facebook_site'] ), - 'defaultImage' => $context - ->get_loader( 'post' ) - ->load_deferred( $all['og_default_image_id'] ), + 'url' => isset( $wpseo_options['facebook_site'] ) ? wp_gql_seo_format_string( $wpseo_options['facebook_site'] ) : null, + 'defaultImage' => isset( $wpseo_options['og_default_image_id'] ) ? $context->get_loader( 'post' )->load_deferred( $wpseo_options['og_default_image_id'] ) : null, ], 'twitter' => [ - 'username' => wp_gql_seo_format_string( - $all['twitter_site'] - ), - 'cardType' => wp_gql_seo_format_string( - $all['twitter_card_type'] - ), + 'username' => isset( $wpseo_options['twitter_site'] ) ? wp_gql_seo_format_string( $wpseo_options['twitter_site'] ) : null, + 'cardType' => isset( $wpseo_options['twitter_card_type'] ) ? wp_gql_seo_format_string( $wpseo_options['twitter_card_type'] ) : null, ], 'instagram' => [ - 'url' => wp_gql_seo_format_string( $all['instagram_url'] ), + 'url' => isset( $wpseo_options['instagram_url'] ) ? wp_gql_seo_format_string( $wpseo_options['instagram_url'] ) : null, ], 'linkedIn' => [ - 'url' => wp_gql_seo_format_string( $all['linkedin_url'] ), + 'url' => isset( $wpseo_options['linkedin_url'] ) ? wp_gql_seo_format_string( $wpseo_options['linkedin_url'] ) : null, ], 'mySpace' => [ - 'url' => wp_gql_seo_format_string( $all['myspace_url'] ), + 'url' => isset( $wpseo_options['myspace_url'] ) ? wp_gql_seo_format_string( $wpseo_options['myspace_url'] ) : null, ], 'pinterest' => [ - 'url' => wp_gql_seo_format_string( $all['pinterest_url'] ), - 'metaTag' => wp_gql_seo_format_string( - $all['pinterestverify'] - ), + 'url' => isset( $wpseo_options['pinterest_url'] ) ? wp_gql_seo_format_string( $wpseo_options['pinterest_url'] ) : null, + 'metaTag' => isset( $wpseo_options['pinterestverify'] ) ? wp_gql_seo_format_string( $wpseo_options['pinterestverify'] ) : null, ], 'youTube' => [ - 'url' => wp_gql_seo_format_string( $all['youtube_url'] ), + 'url' => isset( $wpseo_options['youtube_url'] ) ? wp_gql_seo_format_string( $wpseo_options['youtube_url'] ) : null, ], 'wikipedia' => [ - 'url' => wp_gql_seo_format_string( $all['wikipedia_url'] ), + 'url' => isset( $wpseo_options['wikipedia_url'] ) ? wp_gql_seo_format_string( $wpseo_options['wikipedia_url'] ) : null, ], ], 'breadcrumbs' => [ - 'enabled' => wp_gql_seo_format_string( - $all['breadcrumbs-enable'] - ), - 'boldLast' => wp_gql_seo_format_string( - $all['breadcrumbs-boldlast'] - ), - 'showBlogPage' => wp_gql_seo_format_string( - $all['breadcrumbs-display-blog-page'] - ), - 'archivePrefix' => wp_gql_seo_format_string( - $all['breadcrumbs-archiveprefix'] - ), - 'prefix' => wp_gql_seo_format_string( - $all['breadcrumbs-prefix'] - ), - 'notFoundText' => wp_gql_seo_format_string( - $all['breadcrumbs-404crumb'] - ), - 'homeText' => wp_gql_seo_format_string( - $all['breadcrumbs-home'] - ), - 'searchPrefix' => wp_gql_seo_format_string( - $all['breadcrumbs-searchprefix'] - ), - 'separator' => wp_gql_seo_format_string( - $all['breadcrumbs-sep'] - ), + 'enabled' => isset( $wpseo_options['breadcrumbs-enable'] ) ? wp_gql_seo_format_string( $wpseo_options['breadcrumbs-enable'] ) : null, + 'boldLast' => isset( $wpseo_options['breadcrumbs-boldlast'] ) ? wp_gql_seo_format_string( $wpseo_options['breadcrumbs-boldlast'] ) : null, + 'showBlogPage' => isset( $wpseo_options['breadcrumbs-display-blog-page'] ) ? wp_gql_seo_format_string( $wpseo_options['breadcrumbs-display-blog-page'] ) : null, + 'archivePrefix' => isset( $wpseo_options['breadcrumbs-archiveprefix'] ) ? wp_gql_seo_format_string( $wpseo_options['breadcrumbs-archiveprefix'] ) : null, + 'prefix' => isset( $wpseo_options['breadcrumbs-prefix'] ) ? wp_gql_seo_format_string( $wpseo_options['breadcrumbs-prefix'] ) : null, + 'notFoundText' => isset( $wpseo_options['breadcrumbs-404crumb'] ) ? wp_gql_seo_format_string( $wpseo_options['breadcrumbs-404crumb'] ) : null, + 'homeText' => isset( $wpseo_options['breadcrumbs-home'] ) ? wp_gql_seo_format_string( $wpseo_options['breadcrumbs-home'] ) : null, + 'searchPrefix' => isset( $wpseo_options['breadcrumbs-searchprefix'] ) ? wp_gql_seo_format_string( $wpseo_options['breadcrumbs-searchprefix'] ) : null, + 'separator' => isset( $wpseo_options['breadcrumbs-sep'] ) ? wp_gql_seo_format_string( $wpseo_options['breadcrumbs-sep'] ) : null, ], 'schema' => [ - 'companyName' => wp_gql_seo_format_string( - $all['company_name'] - ), - 'personName' => wp_gql_seo_format_string( - $user->user_nicename - ), - 'companyLogo' => $context - ->get_loader( 'post' ) - ->load_deferred( absint( $all['company_logo_id'] ) ), - 'personLogo' => $context - ->get_loader( 'post' ) - ->load_deferred( absint( $all['person_logo_id'] ) ), - 'logo' => $context - ->get_loader( 'post' ) - ->load_deferred( - $all['company_or_person'] === 'company' - ? absint( $all['company_logo_id'] ) - : absint( $all['person_logo_id'] ) - ), - 'companyOrPerson' => wp_gql_seo_format_string( - $all['company_or_person'] - ), + 'companyName' => isset( $wpseo_options['company_name'] ) ? wp_gql_seo_format_string( $wpseo_options['company_name'] ) : null, + 'personName' => $user instanceof WP_User ? wp_gql_seo_format_string( $user->user_nicename ) : null, + 'companyLogo' => isset( $wpseo_options['company_logo_id'] ) ? $context->get_loader( 'post' )->load_deferred( absint( $wpseo_options['company_logo_id'] ) ) : null, + 'personLogo' => isset( $wpseo_options['person_logo_id'] ) ? $context->get_loader( 'post' )->load_deferred( absint( $wpseo_options['person_logo_id'] ) ) : null, + 'logo' => $context->get_loader( 'post' )->load_deferred( + 'company' === $wpseo_options['company_or_person'] + ? absint( $wpseo_options['company_logo_id'] ) + : absint( $wpseo_options['person_logo_id'] ) + ), + 'companyOrPerson' => isset( $wpseo_options['company_or_person'] ) ? wp_gql_seo_format_string( $wpseo_options['company_or_person'] ) : null, 'siteName' => wp_gql_seo_format_string( YoastSEO()->helpers->site->get_site_name() ), @@ -227,23 +183,13 @@ public static function register_field() : void { get_bloginfo( 'language' ) ), ], - 'redirects' => array_map( $mappedRedirects, $redirects ), + 'redirects' => array_map( $mapped_redirects, $redirects ), 'openGraph' => [ - 'defaultImage' => $context - ->get_loader( 'post' ) - ->load_deferred( absint( $all['og_default_image_id'] ) ), + 'defaultImage' => isset( $wpseo_options['og_default_image_id'] ) ? $context->get_loader( 'post' )->load_deferred( absint( $wpseo_options['og_default_image_id'] ) ) : null, 'frontPage' => [ - 'title' => wp_gql_seo_format_string( - $all['og_frontpage_title'] - ), - 'description' => wp_gql_seo_format_string( - $all['og_frontpage_desc'] - ), - 'image' => $context - ->get_loader( 'post' ) - ->load_deferred( - absint( $all['og_frontpage_image_id'] ) - ), + 'title' => isset( $wpseo_options['og_frontpage_title'] ) ? wp_gql_seo_format_string( $wpseo_options['og_frontpage_title'] ) : null, + 'description' => isset( $wpseo_options['og_frontpage_desc'] ) ? wp_gql_seo_format_string( $wpseo_options['og_frontpage_desc'] ) : null, + 'image' => isset( $wpseo_options['og_frontpage_image_id'] ) ? $context->get_loader( 'post' )->load_deferred( absint( $wpseo_options['og_frontpage_image_id'] ) ) : null, ], ], ]; @@ -252,98 +198,55 @@ public static function register_field() : void { ); } - private static function build_content_type_data( $types, $all ) : array { + /** + * Builds the resolver data for all SEOContentTypes + * + * @param string[] $types The post types. + * @param array $wpseo_options An array of all WPSEO options. + */ + private static function build_content_type_data( $types, $wpseo_options ) : array { $carry = []; foreach ( $types as $type ) { $post_type_object = get_post_type_object( $type ); - if ( $post_type_object->graphql_single_name ) { + if ( $post_type_object instanceof WP_Post_Type && $post_type_object->graphql_single_name ) { $tag = wp_gql_seo_get_field_key( $post_type_object->graphql_single_name ); - $schemaArray = YoastSEO()->meta->for_post_type_archive( $type ) - ->schema; + $yoast_meta = YoastSEO()->meta->for_post_type_archive( $type ); + $schema_array = false !== $yoast_meta ? $yoast_meta->schema : null; $carry[ $tag ] = [ - 'title' => ! empty( $all[ 'title-' . $type ] ) - ? $all[ 'title-' . $type ] - : null, - 'metaDesc' => ! empty( $all[ 'metadesc-' . $type ] ) - ? $all[ 'metadesc-' . $type ] - : null, - 'metaRobotsNoindex' => ! empty( $all[ 'noindex-' . $type ] ) - ? boolval( $all[ 'noindex-' . $type ] ) - : false, - 'schemaType' => ! empty( $all[ 'schema-page-type-' . $type ] ) - ? $all[ 'schema-page-type-' . $type ] - : null, - + 'title' => ! empty( $wpseo_options[ 'title-' . $type ] ) ? $wpseo_options[ 'title-' . $type ] : null, + 'metaDesc' => ! empty( $wpseo_options[ 'metadesc-' . $type ] ) ? $wpseo_options[ 'metadesc-' . $type ] : null, + 'metaRobotsNoindex' => ! empty( $wpseo_options[ 'noindex-' . $type ] ), + 'schemaType' => ! empty( $wpseo_options[ 'schema-page-type-' . $type ] ) ? $wpseo_options[ 'schema-page-type-' . $type ] : null, 'schema' => [ - 'raw' => ! empty( $schemaArray ) - ? json_encode( $schemaArray, JSON_UNESCAPED_SLASHES ) - : null, + 'raw' => ! empty( $schema_array ) ? json_encode( $schema_array, JSON_UNESCAPED_SLASHES ) : null, ], - 'archive' => - $tag == 'post' // Posts are stored like this - ? [ - 'hasArchive' => true, - 'archiveLink' => get_post_type_archive_link( $type ), - 'title' => $all['title-archive-wpseo'] ?? null, - 'metaDesc' => $all['metadesc-archive-wpseo'] ?? null, - 'metaRobotsNoindex' => $all['noindex-archive-wpseo'] ?? null, - 'breadcrumbTitle' => $all['bctitle-archive-wpseo'] ?? null, - 'metaRobotsNoindex' => boolval( - $all['noindex-archive-wpseo'] - ), - 'fullHead' => is_string( - YoastSEO() - ->meta->for_post_type_archive( $type ) - ->get_head() - ) - ? YoastSEO() - ->meta->for_post_type_archive( $type ) - ->get_head() - : YoastSEO() - ->meta->for_post_type_archive( $type ) - ->get_head()->html, - ] - : [ - 'hasArchive' => boolval( - $post_type_object->has_archive - ), - 'archiveLink' => get_post_type_archive_link( $type ), - 'title' => ! empty( $all[ 'title-ptarchive-' . $type ] ) - ? $all[ 'title-ptarchive-' . $type ] - : null, - 'metaDesc' => ! empty( - $all[ 'metadesc-ptarchive-' . $type ] - ) - ? $all[ 'metadesc-ptarchive-' . $type ] - : null, - 'metaRobotsNoindex' => ! empty( - $all[ 'noindex-ptarchive-' . $type ] - ) - ? boolval( $all[ 'noindex-ptarchive-' . $type ] ) - : false, - 'breadcrumbTitle' => ! empty( - $all[ 'bctitle-ptarchive-' . $type ] - ) - ? $all[ 'bctitle-ptarchive-' . $type ] - : null, - 'fullHead' => is_string( - YoastSEO() - ->meta->for_post_type_archive( $type ) - ->get_head() - ) - ? YoastSEO() - ->meta->for_post_type_archive( $type ) - ->get_head() - : YoastSEO() - ->meta->for_post_type_archive( $type ) - ->get_head()->html, - ], + // These are shared by all post types. + 'archive' => [ + 'archiveLink' => get_post_type_archive_link( $type ), + 'fullHead' => is_string( $yoast_meta->get_head() ) ? $yoast_meta->get_head() : $yoast_meta->get_head()->html, + ], + ]; + + // Set archive values and merge with existing. + $archive_values = 'post' === $tag ? [ + 'hasArchive' => true, + 'title' => $wpseo_options['title-archive-wpseo'] ?? null, + 'metaDesc' => $wpseo_options['metadesc-archive-wpseo'] ?? null, + 'metaRobotsNoindex' => $wpseo_options['noindex-archive-wpseo'] ?? null, + 'breadcrumbTitle' => $wpseo_options['bctitle-archive-wpseo'] ?? null, + ] : [ + 'hasArchive' => boolval( $post_type_object->has_archive ), + 'title' => ! empty( $wpseo_options[ 'title-ptarchive-' . $type ] ) ? $wpseo_options[ 'title-ptarchive-' . $type ] : null, + 'metaDesc' => ! empty( $wpseo_options[ 'metadesc-ptarchive-' . $type ] ) ? $wpseo_options[ 'metadesc-ptarchive-' . $type ] : null, + 'metaRobotsNoindex' => ! empty( $wpseo_options[ 'noindex-ptarchive-' . $type ] ) ? boolval( $wpseo_options[ 'noindex-ptarchive-' . $type ] ) : false, + 'breadcrumbTitle' => ! empty( $wpseo_options[ 'bctitle-ptarchive-' . $type ] ) ? $wpseo_options[ 'bctitle-ptarchive-' . $type ] : null, ]; + $carry[ $tag ]['archive'] = array_merge( $carry[ $tag ]['archive'], $archive_values ); } } return $carry; diff --git a/src/Type/WPObject/SEOPostTypeBreadcrumbs.php b/src/Type/WPObject/SEOPostTypeBreadcrumbs.php index 7a7c5a5..1e3c46b 100644 --- a/src/Type/WPObject/SEOPostTypeBreadcrumbs.php +++ b/src/Type/WPObject/SEOPostTypeBreadcrumbs.php @@ -31,6 +31,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / register_graphql_object_type( static::$type, [ + // phpcs:ignore // 'description' => static::get_description(), 'fields' => static::get_fields(), ] @@ -42,7 +43,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / */ public static function get_description() : string { // @todo update description. - return __( 'The Schema types for Taxonomy', 'wp-graphql-yoast-seo' ); + return __( 'placeholder description', 'wp-graphql-yoast-seo' ); } /** diff --git a/src/Type/WPObject/SEOPostTypePageInfo.php b/src/Type/WPObject/SEOPostTypePageInfo.php index 10ce46d..41521db 100644 --- a/src/Type/WPObject/SEOPostTypePageInfo.php +++ b/src/Type/WPObject/SEOPostTypePageInfo.php @@ -8,14 +8,13 @@ namespace WPGraphQL\YoastSEO\Type\WPObject; -use WPGraphQL\AppContext; use WPGraphQL\Registry\TypeRegistry; use WPGraphQL\YoastSEO\Interfaces\Field; use WPGraphQL\YoastSEO\Type\WPObject\PageInfo; use WPGraphQL\YoastSEO\Interfaces\Registrable; use WPGraphQL\YoastSEO\Interfaces\Type; use WPGraphQL\YoastSEO\Interfaces\TypeWithFields; - +use YoastSEO; /** * Class - SEOPostTypePageInfo */ @@ -69,15 +68,13 @@ public static function register_field() : void { [ 'type' => self::$type, 'description' => __( 'Raw schema for archive', 'wp-graphql-yoast-seo' ), - 'resolve' => static function( $item, array $args, AppContext $context ) { - $schemaArray = YoastSEO()->meta->for_post_type_archive()->schema; + 'resolve' => static function() { + $yoast_meta = YoastSEO()->meta->for_post_type_archive(); + $schema_array = false !== $yoast_meta ? $yoast_meta->schema : []; return [ 'schema' => [ - 'raw' => json_encode( - $schemaArray, - JSON_UNESCAPED_SLASHES - ), + 'raw' => json_encode( $schema_array, JSON_UNESCAPED_SLASHES ), ], ]; }, diff --git a/src/Type/WPObject/SEOUser.php b/src/Type/WPObject/SEOUser.php index 8009c39..155f1ac 100644 --- a/src/Type/WPObject/SEOUser.php +++ b/src/Type/WPObject/SEOUser.php @@ -8,8 +8,9 @@ namespace WPGraphQL\YoastSEO\Type\WPObject; -use YoastSEO; +use function YoastSEO; use WPGraphQL\AppContext; +use WPGraphQL\Model\User as ModelUser; use WPGraphQL\Registry\TypeRegistry; use WPGraphQL\YoastSEO\Interfaces\Field; use WPGraphQL\YoastSEO\Interfaces\Registrable; @@ -42,6 +43,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / register_graphql_object_type( static::$type, [ + // phpcs:ignore // 'description' => static::get_description(), 'fields' => static::get_fields(), ] @@ -93,63 +95,27 @@ public static function register_field() : void { [ 'type' => static::$type, 'description' => __( 'The Yoast SEO data of a user', 'wp-graphql-yoast-seo' ), - 'resolve' => static function ( $user, array $args, AppContext $context ) { - $robots = YoastSEO()->meta->for_author( $user->userId )->robots; + 'resolve' => static function ( ModelUser $user, array $args, AppContext $context ) { + $yoast_meta = YoastSEO()->meta->for_author( $user->userId ); + $robots = isset( $yoast_meta->robots ) ? $yoast_meta->robots : []; - $schemaArray = YoastSEO()->meta->for_author( $user->userId )->schema; - $userSeo = [ - 'title' => wp_gql_seo_format_string( - YoastSEO()->meta->for_author( $user->userId )->title - ), - 'metaDesc' => wp_gql_seo_format_string( - YoastSEO()->meta->for_author( $user->userId )->description - ), - 'metaRobotsNoindex' => $robots['index'], - 'metaRobotsNofollow' => $robots['follow'], - 'canonical' => YoastSEO()->meta->for_author( $user->userId ) - ->canonical, - 'opengraphTitle' => YoastSEO()->meta->for_author( $user->userId ) - ->open_graph_title, - 'opengraphDescription' => YoastSEO()->meta->for_author( - $user->userId - )->open_graph_description, - 'opengraphImage' => $context - ->get_loader( 'post' ) - ->load_deferred( - absint( - YoastSEO()->meta->for_author( $user->userId ) - ->open_graph_image_id - ) - ), - 'twitterImage' => $context - ->get_loader( 'post' ) - ->load_deferred( - absint( - YoastSEO()->meta->for_author( $user->userId ) - ->twitter_image_id - ) - ), - 'twitterTitle' => YoastSEO()->meta->for_author( $user->userId ) - ->twitter_title, - 'twitterDescription' => YoastSEO()->meta->for_author( - $user->userId - )->twitter_description, - 'language' => YoastSEO()->meta->for_author( $user->userId ) - ->language, - 'region' => YoastSEO()->meta->for_author( $user->userId )->region, - 'breadcrumbTitle' => YoastSEO()->meta->for_author( $user->userId ) - ->breadcrumb_title, - 'fullHead' => is_string( - YoastSEO() - ->meta->for_author( $user->userId ) - ->get_head() - ) - ? YoastSEO() - ->meta->for_author( $user->userId ) - ->get_head() - : YoastSEO() - ->meta->for_author( $user->userId ) - ->get_head()->html, + $schema_array = isset( $yoast_meta->schema ) ? $yoast_meta->schema : []; + + $userSeo = [ + 'title' => wp_gql_seo_format_string( $yoast_meta->title ), + 'metaDesc' => wp_gql_seo_format_string( $yoast_meta->description ), + 'metaRobotsNoindex' => $robots['index'] ?? null, + 'metaRobotsNofollow' => $robots['follow'] ?? null, + 'canonical' => isset( $yoast_meta->canonical ) ? $yoast_meta->canonical : null, + 'opengraphTitle' => isset( $yoast_meta->open_graph_title ) ? $yoast_meta->open_graph_title : null, + 'opengraphDescription' => isset( $yoast_meta->open_graph_description ) ? $yoast_meta->open_graph_description : null, + 'opengraphImage' => isset( $yoast_meta->open_graph_image_id ) ? $context->get_loader( 'post' )->load_deferred( absint( $yoast_meta->open_graph_image_id ) ) : null, + 'twitterImage' => isset( $yoast_meta->twitter_image_id ) ? $context->get_loader( 'post' )->load_deferred( absint( $yoast_meta->twitter_image_id ) ) : null, + 'twitterDescription' => isset( $yoast_meta->twitter_description ) ? $yoast_meta->twitter_description : null, + 'language' => isset( $yoast_meta->language ) ? $yoast_meta->language : null, + 'region' => isset( $yoast_meta->region ) ? $yoast_meta->region : null, + 'breadcrumbTitle' => isset( $yoast_meta->breadcrumb_title ) ? $yoast_meta->breadcrumb_title : null, + 'fullHead' => is_string( $yoast_meta->get_head() ) ? $yoast_meta->get_head() : $yoast_meta->get_head()->html, 'social' => [ 'facebook' => wp_gql_seo_format_string( get_the_author_meta( 'facebook', $user->userId ) @@ -179,27 +145,14 @@ public static function register_field() : void { get_the_author_meta( 'wikipedia', $user->userId ) ), ], - 'schema' => [ - 'raw' => json_encode( $schemaArray, JSON_UNESCAPED_SLASHES ), - 'pageType' => is_array( - YoastSEO()->meta->for_author( $user->userId ) - ->schema_page_type - ) - ? YoastSEO()->meta->for_author( $user->userId ) - ->schema_page_type - : [], - 'articleType' => is_array( - YoastSEO()->meta->for_author( $user->userId ) - ->schema_article_type - ) - ? YoastSEO()->meta->for_author( $user->userId ) - ->schema_article_type - : [], + 'raw' => json_encode( $schema_array, JSON_UNESCAPED_SLASHES ), + 'pageType' => isset( $yoast_meta->schema_page_type ) ? $yoast_meta->schema_page_type : [], + 'articleType' => isset( $yoast_meta->indexable ) && isset( $yoast_meta->indexable->schema_article_type ) ? $yoast_meta->indexable->schema_article_type : [], ], ]; - return ! empty( $userSeo ) ? $userSeo : []; + return $userSeo; }, ] ); diff --git a/src/Type/WPObject/User/Social.php b/src/Type/WPObject/User/Social.php index d756b4d..83b9cd8 100644 --- a/src/Type/WPObject/User/Social.php +++ b/src/Type/WPObject/User/Social.php @@ -31,6 +31,7 @@ public static function register( TypeRegistry $type_registry = null ) : void { / register_graphql_object_type( static::$type, [ + // phpcs:ignore // 'description' => static::get_description(), 'fields' => static::get_fields(), ] diff --git a/vendor/autoload.php b/vendor/autoload.php new file mode 100644 index 0000000..4417350 --- /dev/null +++ b/vendor/autoload.php @@ -0,0 +1,7 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see https://www.php-fig.org/psr/psr-0/ + * @see https://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + /** @var ?string */ + private $vendorDir; + + // PSR-4 + /** + * @var array[] + * @psalm-var array> + */ + private $prefixLengthsPsr4 = array(); + /** + * @var array[] + * @psalm-var array> + */ + private $prefixDirsPsr4 = array(); + /** + * @var array[] + * @psalm-var array + */ + private $fallbackDirsPsr4 = array(); + + // PSR-0 + /** + * @var array[] + * @psalm-var array> + */ + private $prefixesPsr0 = array(); + /** + * @var array[] + * @psalm-var array + */ + private $fallbackDirsPsr0 = array(); + + /** @var bool */ + private $useIncludePath = false; + + /** + * @var string[] + * @psalm-var array + */ + private $classMap = array(); + + /** @var bool */ + private $classMapAuthoritative = false; + + /** + * @var bool[] + * @psalm-var array + */ + private $missingClasses = array(); + + /** @var ?string */ + private $apcuPrefix; + + /** + * @var self[] + */ + private static $registeredLoaders = array(); + + /** + * @param ?string $vendorDir + */ + public function __construct($vendorDir = null) + { + $this->vendorDir = $vendorDir; + } + + /** + * @return string[] + */ + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); + } + + return array(); + } + + /** + * @return array[] + * @psalm-return array> + */ + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + /** + * @return array[] + * @psalm-return array + */ + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + /** + * @return array[] + * @psalm-return array + */ + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + /** + * @return string[] Array of classname => path + * @psalm-return array + */ + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param string[] $classMap Class to filename map + * @psalm-param array $classMap + * + * @return void + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param string[]|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + * + * @return void + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param string[]|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param string[]|string $paths The PSR-0 base directories + * + * @return void + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param string[]|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + * + * @return void + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + * + * @return void + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + * + * @return void + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + * + * @return void + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + + if (null === $this->vendorDir) { + return; + } + + if ($prepend) { + self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; + } else { + unset(self::$registeredLoaders[$this->vendorDir]); + self::$registeredLoaders[$this->vendorDir] = $this; + } + } + + /** + * Unregisters this instance as an autoloader. + * + * @return void + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + + if (null !== $this->vendorDir) { + unset(self::$registeredLoaders[$this->vendorDir]); + } + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return true|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + + return null; + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + /** + * Returns the currently registered loaders indexed by their corresponding vendor directories. + * + * @return self[] + */ + public static function getRegisteredLoaders() + { + return self::$registeredLoaders; + } + + /** + * @param string $class + * @param string $ext + * @return string|false + */ + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath . '\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . $pathEnd)) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + * @private + */ +function includeFile($file) +{ + include $file; +} diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php new file mode 100644 index 0000000..d50e0c9 --- /dev/null +++ b/vendor/composer/InstalledVersions.php @@ -0,0 +1,350 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer; + +use Composer\Autoload\ClassLoader; +use Composer\Semver\VersionParser; + +/** + * This class is copied in every Composer installed project and available to all + * + * See also https://getcomposer.org/doc/07-runtime.md#installed-versions + * + * To require its presence, you can require `composer-runtime-api ^2.0` + */ +class InstalledVersions +{ + /** + * @var mixed[]|null + * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array}|array{}|null + */ + private static $installed; + + /** + * @var bool|null + */ + private static $canGetVendors; + + /** + * @var array[] + * @psalm-var array}> + */ + private static $installedByVendor = array(); + + /** + * Returns a list of all package names which are present, either by being installed, replaced or provided + * + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackages() + { + $packages = array(); + foreach (self::getInstalled() as $installed) { + $packages[] = array_keys($installed['versions']); + } + + if (1 === \count($packages)) { + return $packages[0]; + } + + return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); + } + + /** + * Returns a list of all package names with a specific type e.g. 'library' + * + * @param string $type + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackagesByType($type) + { + $packagesByType = array(); + + foreach (self::getInstalled() as $installed) { + foreach ($installed['versions'] as $name => $package) { + if (isset($package['type']) && $package['type'] === $type) { + $packagesByType[] = $name; + } + } + } + + return $packagesByType; + } + + /** + * Checks whether the given package is installed + * + * This also returns true if the package name is provided or replaced by another package + * + * @param string $packageName + * @param bool $includeDevRequirements + * @return bool + */ + public static function isInstalled($packageName, $includeDevRequirements = true) + { + foreach (self::getInstalled() as $installed) { + if (isset($installed['versions'][$packageName])) { + return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); + } + } + + return false; + } + + /** + * Checks whether the given package satisfies a version constraint + * + * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: + * + * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') + * + * @param VersionParser $parser Install composer/semver to have access to this class and functionality + * @param string $packageName + * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package + * @return bool + */ + public static function satisfies(VersionParser $parser, $packageName, $constraint) + { + $constraint = $parser->parseConstraints($constraint); + $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); + + return $provided->matches($constraint); + } + + /** + * Returns a version constraint representing all the range(s) which are installed for a given package + * + * It is easier to use this via isInstalled() with the $constraint argument if you need to check + * whether a given version of a package is installed, and not just whether it exists + * + * @param string $packageName + * @return string Version constraint usable with composer/semver + */ + public static function getVersionRanges($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + $ranges = array(); + if (isset($installed['versions'][$packageName]['pretty_version'])) { + $ranges[] = $installed['versions'][$packageName]['pretty_version']; + } + if (array_key_exists('aliases', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); + } + if (array_key_exists('replaced', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); + } + if (array_key_exists('provided', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); + } + + return implode(' || ', $ranges); + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['version'])) { + return null; + } + + return $installed['versions'][$packageName]['version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getPrettyVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['pretty_version'])) { + return null; + } + + return $installed['versions'][$packageName]['pretty_version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference + */ + public static function getReference($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['reference'])) { + return null; + } + + return $installed['versions'][$packageName]['reference']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. + */ + public static function getInstallPath($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @return array + * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string} + */ + public static function getRootPackage() + { + $installed = self::getInstalled(); + + return $installed[0]['root']; + } + + /** + * Returns the raw installed.php data for custom implementations + * + * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. + * @return array[] + * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array} + */ + public static function getRawData() + { + @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = include __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + + return self::$installed; + } + + /** + * Returns the raw data of all installed.php which are currently loaded for custom implementations + * + * @return array[] + * @psalm-return list}> + */ + public static function getAllRawData() + { + return self::getInstalled(); + } + + /** + * Lets you reload the static array from another file + * + * This is only useful for complex integrations in which a project needs to use + * this class but then also needs to execute another project's autoloader in process, + * and wants to ensure both projects have access to their version of installed.php. + * + * A typical case would be PHPUnit, where it would need to make sure it reads all + * the data it needs from this class, then call reload() with + * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure + * the project in which it runs can then also use this class safely, without + * interference between PHPUnit's dependencies and the project's dependencies. + * + * @param array[] $data A vendor/composer/installed.php data set + * @return void + * + * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array} $data + */ + public static function reload($data) + { + self::$installed = $data; + self::$installedByVendor = array(); + } + + /** + * @return array[] + * @psalm-return list}> + */ + private static function getInstalled() + { + if (null === self::$canGetVendors) { + self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); + } + + $installed = array(); + + if (self::$canGetVendors) { + foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { + if (isset(self::$installedByVendor[$vendorDir])) { + $installed[] = self::$installedByVendor[$vendorDir]; + } elseif (is_file($vendorDir.'/composer/installed.php')) { + $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; + if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { + self::$installed = $installed[count($installed) - 1]; + } + } + } + } + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = require __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + $installed[] = self::$installed; + + return $installed; + } +} diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE new file mode 100644 index 0000000..f27399a --- /dev/null +++ b/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php new file mode 100644 index 0000000..743381b --- /dev/null +++ b/vendor/composer/autoload_classmap.php @@ -0,0 +1,52 @@ + $vendorDir . '/composer/InstalledVersions.php', + 'WPGraphQL\\YoastSEO\\Connection\\PostTypeToTermNodeConnectionEdge' => $baseDir . '/src/Connection/PostTypeToTermNodeConnectionEdge.php', + 'WPGraphQL\\YoastSEO\\CoreSchemaFilters' => $baseDir . '/src/CoreSchemaFilters.php', + 'WPGraphQL\\YoastSEO\\Interfaces\\Field' => $baseDir . '/src/Interfaces/Field.php', + 'WPGraphQL\\YoastSEO\\Interfaces\\Hookable' => $baseDir . '/src/Interfaces/Hookable.php', + 'WPGraphQL\\YoastSEO\\Interfaces\\Registrable' => $baseDir . '/src/Interfaces/Registrable.php', + 'WPGraphQL\\YoastSEO\\Interfaces\\Type' => $baseDir . '/src/Interfaces/Type.php', + 'WPGraphQL\\YoastSEO\\Interfaces\\TypeWithFields' => $baseDir . '/src/Interfaces/TypeWithFields.php', + 'WPGraphQL\\YoastSEO\\Seo' => $baseDir . '/src/Seo.php', + 'WPGraphQL\\YoastSEO\\TypeRegistry' => $baseDir . '/src/TypeRegistry.php', + 'WPGraphQL\\YoastSEO\\Type\\Enum\\SEOCardTypeEnum' => $baseDir . '/src/Type/Enum/SEOCardTypeEnum.php', + 'WPGraphQL\\YoastSEO\\Type\\WPInterface\\ContentNodeWithSEO' => $baseDir . '/src/Type/WPInterface/ContentNodeWithSEO.php', + 'WPGraphQL\\YoastSEO\\Type\\WPInterface\\SEOBaseFields' => $baseDir . '/src/Type/WPInterface/SEOBaseFields.php', + 'WPGraphQL\\YoastSEO\\Type\\WPInterface\\TermNodeWithSEO' => $baseDir . '/src/Type/WPInterface/TermNodeWithSEO.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Breadcrumbs' => $baseDir . '/src/Type/WPObject/Config/Breadcrumbs.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\ContentType\\ContentType' => $baseDir . '/src/Type/WPObject/Config/ContentType/ContentType.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\ContentTypes' => $baseDir . '/src/Type/WPObject/Config/ContentTypes.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\OpenGraph' => $baseDir . '/src/Type/WPObject/Config/OpenGraph.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\OpenGraph\\FrontPage' => $baseDir . '/src/Type/WPObject/Config/OpenGraph/FrontPage.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Redirect' => $baseDir . '/src/Type/WPObject/Config/Redirect.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Schema' => $baseDir . '/src/Type/WPObject/Config/Schema.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social' => $baseDir . '/src/Type/WPObject/Config/Social.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Facebook' => $baseDir . '/src/Type/WPObject/Config/Social/Facebook.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Instagram' => $baseDir . '/src/Type/WPObject/Config/Social/Instagram.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\LinkedIn' => $baseDir . '/src/Type/WPObject/Config/Social/LinkedIn.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\MySpace' => $baseDir . '/src/Type/WPObject/Config/Social/MySpace.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Pinterest' => $baseDir . '/src/Type/WPObject/Config/Social/Pinterest.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Twitter' => $baseDir . '/src/Type/WPObject/Config/Social/Twitter.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Wikipedia' => $baseDir . '/src/Type/WPObject/Config/Social/Wikipedia.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Youtube' => $baseDir . '/src/Type/WPObject/Config/Social/Youtube.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Webmaster' => $baseDir . '/src/Type/WPObject/Config/Webmaster.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\ContentType\\Archive' => $baseDir . '/src/Type/WPObject/ContentType/Archive.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\PageInfo\\Schema' => $baseDir . '/src/Type/WPObject/PageInfo/Schema.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\PostTypeSEO' => $baseDir . '/src/Type/WPObject/PostTypeSEO.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\PostType\\Schema' => $baseDir . '/src/Type/WPObject/PostType/Schema.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\SEOConfig' => $baseDir . '/src/Type/WPObject/SEOConfig.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\SEOPostTypeBreadcrumbs' => $baseDir . '/src/Type/WPObject/SEOPostTypeBreadcrumbs.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\SEOPostTypePageInfo' => $baseDir . '/src/Type/WPObject/SEOPostTypePageInfo.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\SEOUser' => $baseDir . '/src/Type/WPObject/SEOUser.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\TaxonomySEO' => $baseDir . '/src/Type/WPObject/TaxonomySEO.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Taxonomy\\Schema' => $baseDir . '/src/Type/WPObject/Taxonomy/Schema.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\User\\Schema' => $baseDir . '/src/Type/WPObject/User/Schema.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\User\\Social' => $baseDir . '/src/Type/WPObject/User/Social.php', +); diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php new file mode 100644 index 0000000..67791f0 --- /dev/null +++ b/vendor/composer/autoload_files.php @@ -0,0 +1,10 @@ + $baseDir . '/access-functions.php', +); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php new file mode 100644 index 0000000..b7fc012 --- /dev/null +++ b/vendor/composer/autoload_namespaces.php @@ -0,0 +1,9 @@ + array($baseDir . '/src'), +); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php new file mode 100644 index 0000000..4ad717c --- /dev/null +++ b/vendor/composer/autoload_real.php @@ -0,0 +1,80 @@ += 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); + if ($useStaticLoader) { + require __DIR__ . '/autoload_static.php'; + + call_user_func(\Composer\Autoload\ComposerStaticInitccec7e4645ca6ddf694d702594caaacb::getInitializer($loader)); + } else { + $map = require __DIR__ . '/autoload_namespaces.php'; + foreach ($map as $namespace => $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + } + + $loader->register(true); + + if ($useStaticLoader) { + $includeFiles = Composer\Autoload\ComposerStaticInitccec7e4645ca6ddf694d702594caaacb::$files; + } else { + $includeFiles = require __DIR__ . '/autoload_files.php'; + } + foreach ($includeFiles as $fileIdentifier => $file) { + composerRequireccec7e4645ca6ddf694d702594caaacb($fileIdentifier, $file); + } + + return $loader; + } +} + +/** + * @param string $fileIdentifier + * @param string $file + * @return void + */ +function composerRequireccec7e4645ca6ddf694d702594caaacb($fileIdentifier, $file) +{ + if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { + $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; + + require $file; + } +} diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php new file mode 100644 index 0000000..6c1e3af --- /dev/null +++ b/vendor/composer/autoload_static.php @@ -0,0 +1,82 @@ + __DIR__ . '/../..' . '/access-functions.php', + ); + + public static $prefixLengthsPsr4 = array ( + 'W' => + array ( + 'WPGraphQL\\YoastSEO\\' => 19, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'WPGraphQL\\YoastSEO\\' => + array ( + 0 => __DIR__ . '/../..' . '/src', + ), + ); + + public static $classMap = array ( + 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', + 'WPGraphQL\\YoastSEO\\Connection\\PostTypeToTermNodeConnectionEdge' => __DIR__ . '/../..' . '/src/Connection/PostTypeToTermNodeConnectionEdge.php', + 'WPGraphQL\\YoastSEO\\CoreSchemaFilters' => __DIR__ . '/../..' . '/src/CoreSchemaFilters.php', + 'WPGraphQL\\YoastSEO\\Interfaces\\Field' => __DIR__ . '/../..' . '/src/Interfaces/Field.php', + 'WPGraphQL\\YoastSEO\\Interfaces\\Hookable' => __DIR__ . '/../..' . '/src/Interfaces/Hookable.php', + 'WPGraphQL\\YoastSEO\\Interfaces\\Registrable' => __DIR__ . '/../..' . '/src/Interfaces/Registrable.php', + 'WPGraphQL\\YoastSEO\\Interfaces\\Type' => __DIR__ . '/../..' . '/src/Interfaces/Type.php', + 'WPGraphQL\\YoastSEO\\Interfaces\\TypeWithFields' => __DIR__ . '/../..' . '/src/Interfaces/TypeWithFields.php', + 'WPGraphQL\\YoastSEO\\Seo' => __DIR__ . '/../..' . '/src/Seo.php', + 'WPGraphQL\\YoastSEO\\TypeRegistry' => __DIR__ . '/../..' . '/src/TypeRegistry.php', + 'WPGraphQL\\YoastSEO\\Type\\Enum\\SEOCardTypeEnum' => __DIR__ . '/../..' . '/src/Type/Enum/SEOCardTypeEnum.php', + 'WPGraphQL\\YoastSEO\\Type\\WPInterface\\ContentNodeWithSEO' => __DIR__ . '/../..' . '/src/Type/WPInterface/ContentNodeWithSEO.php', + 'WPGraphQL\\YoastSEO\\Type\\WPInterface\\SEOBaseFields' => __DIR__ . '/../..' . '/src/Type/WPInterface/SEOBaseFields.php', + 'WPGraphQL\\YoastSEO\\Type\\WPInterface\\TermNodeWithSEO' => __DIR__ . '/../..' . '/src/Type/WPInterface/TermNodeWithSEO.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Breadcrumbs' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Breadcrumbs.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\ContentType\\ContentType' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/ContentType/ContentType.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\ContentTypes' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/ContentTypes.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\OpenGraph' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/OpenGraph.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\OpenGraph\\FrontPage' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/OpenGraph/FrontPage.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Redirect' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Redirect.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Schema' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Schema.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Social.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Facebook' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Social/Facebook.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Instagram' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Social/Instagram.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\LinkedIn' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Social/LinkedIn.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\MySpace' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Social/MySpace.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Pinterest' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Social/Pinterest.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Twitter' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Social/Twitter.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Wikipedia' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Social/Wikipedia.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Social\\Youtube' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Social/Youtube.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Webmaster' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Webmaster.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\ContentType\\Archive' => __DIR__ . '/../..' . '/src/Type/WPObject/ContentType/Archive.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\PageInfo\\Schema' => __DIR__ . '/../..' . '/src/Type/WPObject/PageInfo/Schema.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\PostTypeSEO' => __DIR__ . '/../..' . '/src/Type/WPObject/PostTypeSEO.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\PostType\\Schema' => __DIR__ . '/../..' . '/src/Type/WPObject/PostType/Schema.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\SEOConfig' => __DIR__ . '/../..' . '/src/Type/WPObject/SEOConfig.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\SEOPostTypeBreadcrumbs' => __DIR__ . '/../..' . '/src/Type/WPObject/SEOPostTypeBreadcrumbs.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\SEOPostTypePageInfo' => __DIR__ . '/../..' . '/src/Type/WPObject/SEOPostTypePageInfo.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\SEOUser' => __DIR__ . '/../..' . '/src/Type/WPObject/SEOUser.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\TaxonomySEO' => __DIR__ . '/../..' . '/src/Type/WPObject/TaxonomySEO.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Taxonomy\\Schema' => __DIR__ . '/../..' . '/src/Type/WPObject/Taxonomy/Schema.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\User\\Schema' => __DIR__ . '/../..' . '/src/Type/WPObject/User/Schema.php', + 'WPGraphQL\\YoastSEO\\Type\\WPObject\\User\\Social' => __DIR__ . '/../..' . '/src/Type/WPObject/User/Social.php', + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticInitccec7e4645ca6ddf694d702594caaacb::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitccec7e4645ca6ddf694d702594caaacb::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitccec7e4645ca6ddf694d702594caaacb::$classMap; + + }, null, ClassLoader::class); + } +} diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php new file mode 100644 index 0000000..919e62a --- /dev/null +++ b/vendor/composer/installed.php @@ -0,0 +1,350 @@ + array( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'type' => 'wordpress-plugin', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'reference' => '5665c34f310076666caa5763e8fdd9385fa66b81', + 'name' => 'ashhitch/wp-graphql-yoast-seo', + 'dev' => true, + ), + 'versions' => array( + 'ashhitch/wp-graphql-yoast-seo' => array( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'type' => 'wordpress-plugin', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'reference' => '5665c34f310076666caa5763e8fdd9385fa66b81', + 'dev_requirement' => false, + ), + 'automattic/vipwpcs' => array( + 'pretty_version' => '2.3.3', + 'version' => '2.3.3.0', + 'type' => 'phpcodesniffer-standard', + 'install_path' => __DIR__ . '/../automattic/vipwpcs', + 'aliases' => array(), + 'reference' => '6cd0a6a82bc0ac988dbf9d6a7c2e293dc8ac640b', + 'dev_requirement' => true, + ), + 'dealerdirect/phpcodesniffer-composer-installer' => array( + 'pretty_version' => 'v0.7.2', + 'version' => '0.7.2.0', + 'type' => 'composer-plugin', + 'install_path' => __DIR__ . '/../dealerdirect/phpcodesniffer-composer-installer', + 'aliases' => array(), + 'reference' => '1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db', + 'dev_requirement' => true, + ), + 'giacocorsiglia/wordpress-stubs' => array( + 'dev_requirement' => true, + 'replaced' => array( + 0 => '*', + ), + ), + 'guzzlehttp/guzzle' => array( + 'pretty_version' => '7.4.1', + 'version' => '7.4.1.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../guzzlehttp/guzzle', + 'aliases' => array(), + 'reference' => 'ee0a041b1760e6a53d2a39c8c34115adc2af2c79', + 'dev_requirement' => true, + ), + 'guzzlehttp/promises' => array( + 'pretty_version' => '1.5.1', + 'version' => '1.5.1.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../guzzlehttp/promises', + 'aliases' => array(), + 'reference' => 'fe752aedc9fd8fcca3fe7ad05d419d32998a06da', + 'dev_requirement' => true, + ), + 'guzzlehttp/psr7' => array( + 'pretty_version' => '2.1.0', + 'version' => '2.1.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../guzzlehttp/psr7', + 'aliases' => array(), + 'reference' => '089edd38f5b8abba6cb01567c2a8aaa47cec4c72', + 'dev_requirement' => true, + ), + 'j4mie/idiorm' => array( + 'pretty_version' => 'v1.5.7', + 'version' => '1.5.7.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../j4mie/idiorm', + 'aliases' => array(), + 'reference' => 'd23f97053ef5d0b988a02c6a71eb5c6118b2f5b4', + 'dev_requirement' => true, + ), + 'league/oauth2-client' => array( + 'pretty_version' => '2.6.1', + 'version' => '2.6.1.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../league/oauth2-client', + 'aliases' => array(), + 'reference' => '2334c249907190c132364f5dae0287ab8666aa19', + 'dev_requirement' => true, + ), + 'paragonie/random_compat' => array( + 'pretty_version' => 'v9.99.100', + 'version' => '9.99.100.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../paragonie/random_compat', + 'aliases' => array(), + 'reference' => '996434e5492cb4c3edcb9168db6fbb1359ef965a', + 'dev_requirement' => true, + ), + 'php-stubs/wordpress-seo-stubs' => array( + 'pretty_version' => 'v17.2', + 'version' => '17.2.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../php-stubs/wordpress-seo-stubs', + 'aliases' => array(), + 'reference' => 'f4b272159d3091f07596e63f14525f8da0919caf', + 'dev_requirement' => true, + ), + 'php-stubs/wordpress-stubs' => array( + 'pretty_version' => 'v5.9.0', + 'version' => '5.9.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../php-stubs/wordpress-stubs', + 'aliases' => array(), + 'reference' => '0fa8dd9a1bd2a1b60e85afc6c798fca1f599cc1b', + 'dev_requirement' => true, + ), + 'phpcompatibility/php-compatibility' => array( + 'pretty_version' => '9.3.5', + 'version' => '9.3.5.0', + 'type' => 'phpcodesniffer-standard', + 'install_path' => __DIR__ . '/../phpcompatibility/php-compatibility', + 'aliases' => array(), + 'reference' => '9fb324479acf6f39452e0655d2429cc0d3914243', + 'dev_requirement' => true, + ), + 'phpcompatibility/phpcompatibility-paragonie' => array( + 'pretty_version' => '1.3.1', + 'version' => '1.3.1.0', + 'type' => 'phpcodesniffer-standard', + 'install_path' => __DIR__ . '/../phpcompatibility/phpcompatibility-paragonie', + 'aliases' => array(), + 'reference' => 'ddabec839cc003651f2ce695c938686d1086cf43', + 'dev_requirement' => true, + ), + 'phpcompatibility/phpcompatibility-wp' => array( + 'pretty_version' => '2.1.3', + 'version' => '2.1.3.0', + 'type' => 'phpcodesniffer-standard', + 'install_path' => __DIR__ . '/../phpcompatibility/phpcompatibility-wp', + 'aliases' => array(), + 'reference' => 'd55de55f88697b9cdb94bccf04f14eb3b11cf308', + 'dev_requirement' => true, + ), + 'phpstan/extension-installer' => array( + 'pretty_version' => '1.1.0', + 'version' => '1.1.0.0', + 'type' => 'composer-plugin', + 'install_path' => __DIR__ . '/../phpstan/extension-installer', + 'aliases' => array(), + 'reference' => '66c7adc9dfa38b6b5838a9fb728b68a7d8348051', + 'dev_requirement' => true, + ), + 'phpstan/phpstan' => array( + 'pretty_version' => '1.4.6', + 'version' => '1.4.6.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../phpstan/phpstan', + 'aliases' => array(), + 'reference' => '8a7761f1c520e0dad6e04d862fdc697445457cfe', + 'dev_requirement' => true, + ), + 'poolshark/wp-graphql-stubs' => array( + 'pretty_version' => 'v0.0.2', + 'version' => '0.0.2.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../poolshark/wp-graphql-stubs', + 'aliases' => array(), + 'reference' => '66ba54188d04788849abd07bfc9fff511839cdb3', + 'dev_requirement' => true, + ), + 'psr/container' => array( + 'pretty_version' => '1.1.2', + 'version' => '1.1.2.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/container', + 'aliases' => array(), + 'reference' => '513e0666f7216c7459170d56df27dfcefe1689ea', + 'dev_requirement' => true, + ), + 'psr/container-implementation' => array( + 'dev_requirement' => true, + 'provided' => array( + 0 => '1.0', + ), + ), + 'psr/http-client' => array( + 'pretty_version' => '1.0.1', + 'version' => '1.0.1.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/http-client', + 'aliases' => array(), + 'reference' => '2dfb5f6c5eff0e91e20e913f8c5452ed95b86621', + 'dev_requirement' => true, + ), + 'psr/http-client-implementation' => array( + 'dev_requirement' => true, + 'provided' => array( + 0 => '1.0', + ), + ), + 'psr/http-factory' => array( + 'pretty_version' => '1.0.1', + 'version' => '1.0.1.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/http-factory', + 'aliases' => array(), + 'reference' => '12ac7fcd07e5b077433f5f2bee95b3a771bf61be', + 'dev_requirement' => true, + ), + 'psr/http-factory-implementation' => array( + 'dev_requirement' => true, + 'provided' => array( + 0 => '1.0', + ), + ), + 'psr/http-message' => array( + 'pretty_version' => '1.0.1', + 'version' => '1.0.1.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/http-message', + 'aliases' => array(), + 'reference' => 'f6561bf28d520154e4b0ec72be95418abe6d9363', + 'dev_requirement' => true, + ), + 'psr/http-message-implementation' => array( + 'dev_requirement' => true, + 'provided' => array( + 0 => '1.0', + ), + ), + 'psr/log' => array( + 'pretty_version' => '1.1.4', + 'version' => '1.1.4.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/log', + 'aliases' => array(), + 'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11', + 'dev_requirement' => true, + ), + 'ralouphie/getallheaders' => array( + 'pretty_version' => '3.0.3', + 'version' => '3.0.3.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../ralouphie/getallheaders', + 'aliases' => array(), + 'reference' => '120b605dfeb996808c31b6477290a714d356e822', + 'dev_requirement' => true, + ), + 'sirbrillig/phpcs-variable-analysis' => array( + 'pretty_version' => 'v2.11.2', + 'version' => '2.11.2.0', + 'type' => 'phpcodesniffer-standard', + 'install_path' => __DIR__ . '/../sirbrillig/phpcs-variable-analysis', + 'aliases' => array(), + 'reference' => '3fad28475bfbdbf8aa5c440f8a8f89824983d85e', + 'dev_requirement' => true, + ), + 'squizlabs/php_codesniffer' => array( + 'pretty_version' => '3.6.2', + 'version' => '3.6.2.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../squizlabs/php_codesniffer', + 'aliases' => array(), + 'reference' => '5e4e71592f69da17871dba6e80dd51bce74a351a', + 'dev_requirement' => true, + ), + 'symfony/config' => array( + 'pretty_version' => 'v3.4.47', + 'version' => '3.4.47.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/config', + 'aliases' => array(), + 'reference' => 'bc6b3fd3930d4b53a60b42fe2ed6fc466b75f03f', + 'dev_requirement' => true, + ), + 'symfony/dependency-injection' => array( + 'pretty_version' => 'v3.4.47', + 'version' => '3.4.47.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/dependency-injection', + 'aliases' => array(), + 'reference' => '51d2a2708c6ceadad84393f8581df1dcf9e5e84b', + 'dev_requirement' => true, + ), + 'symfony/deprecation-contracts' => array( + 'pretty_version' => 'v3.0.0', + 'version' => '3.0.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/deprecation-contracts', + 'aliases' => array(), + 'reference' => 'c726b64c1ccfe2896cb7df2e1331c357ad1c8ced', + 'dev_requirement' => true, + ), + 'symfony/filesystem' => array( + 'pretty_version' => 'v4.4.37', + 'version' => '4.4.37.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/filesystem', + 'aliases' => array(), + 'reference' => 'c59f37705c3e513ae55b2735f128f4ce363c82ec', + 'dev_requirement' => true, + ), + 'symfony/polyfill-ctype' => array( + 'pretty_version' => 'v1.24.0', + 'version' => '1.24.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-ctype', + 'aliases' => array(), + 'reference' => '30885182c981ab175d4d034db0f6f469898070ab', + 'dev_requirement' => true, + ), + 'symfony/polyfill-php73' => array( + 'pretty_version' => 'v1.24.0', + 'version' => '1.24.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-php73', + 'aliases' => array(), + 'reference' => 'cc5db0e22b3cb4111010e48785a97f670b350ca5', + 'dev_requirement' => true, + ), + 'symfony/polyfill-php80' => array( + 'pretty_version' => 'v1.24.0', + 'version' => '1.24.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-php80', + 'aliases' => array(), + 'reference' => '57b712b08eddb97c762a8caa32c84e037892d2e9', + 'dev_requirement' => true, + ), + 'szepeviktor/phpstan-wordpress' => array( + 'pretty_version' => 'v1.0.2', + 'version' => '1.0.2.0', + 'type' => 'phpstan-extension', + 'install_path' => __DIR__ . '/../szepeviktor/phpstan-wordpress', + 'aliases' => array(), + 'reference' => 'd44b5abcaa529698e138b2d21bc2a7cf9834039c', + 'dev_requirement' => true, + ), + 'wp-coding-standards/wpcs' => array( + 'pretty_version' => '2.3.0', + 'version' => '2.3.0.0', + 'type' => 'phpcodesniffer-standard', + 'install_path' => __DIR__ . '/../wp-coding-standards/wpcs', + 'aliases' => array(), + 'reference' => '7da1894633f168fe244afc6de00d141f27517b62', + 'dev_requirement' => true, + ), + ), +); diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php new file mode 100644 index 0000000..580fa96 --- /dev/null +++ b/vendor/composer/platform_check.php @@ -0,0 +1,26 @@ += 70400)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 7.4.0". You are running ' . PHP_VERSION . '.'; +} + +if ($issues) { + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); + } elseif (!headers_sent()) { + echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; + } + } + trigger_error( + 'Composer detected issues in your platform: ' . implode(' ', $issues), + E_USER_ERROR + ); +} From eb60b9c37e9bdc4f1b10288eed114c1b418cb969 Mon Sep 17 00:00:00 2001 From: Dovid Levine Date: Sat, 19 Feb 2022 18:00:40 +0000 Subject: [PATCH 09/13] chore: bump tested WP version --- src/Type/WPInterface/ContentNodeWithSEO.php | 1 - wp-graphql-yoast-seo.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Type/WPInterface/ContentNodeWithSEO.php b/src/Type/WPInterface/ContentNodeWithSEO.php index 7e31209..72ad3c3 100644 --- a/src/Type/WPInterface/ContentNodeWithSEO.php +++ b/src/Type/WPInterface/ContentNodeWithSEO.php @@ -68,7 +68,6 @@ public static function get_fields() : array { $yoast_meta = YoastSEO()->meta->for_post( $post->ID ); - $schema_array = isset( $yoast_meta->schema ) ? $yoast_meta->schema : []; // @see https://developer.yoast.com/blog/yoast-seo-14-0-using-yoast-seo-surfaces/ diff --git a/wp-graphql-yoast-seo.php b/wp-graphql-yoast-seo.php index 5e07396..3b075b5 100755 --- a/wp-graphql-yoast-seo.php +++ b/wp-graphql-yoast-seo.php @@ -9,7 +9,7 @@ * Domain Path: /languages * Version: 4.16.1 * Requires at least: 5.4.1 - * Tested up to: 5.7.2 + * Tested up to: 5.9.0 * Requires PHP: 7.4 * License: GPL-3 * License URI: https://www.gnu.org/licenses/gpl-3.0.html From 06834810e5b65e66c382f881fdc1a6f7427166cc Mon Sep 17 00:00:00 2001 From: Dovid Levine Date: Sat, 19 Feb 2022 18:40:12 +0000 Subject: [PATCH 10/13] chore: hook interfaces onto other interfaces --- src/CoreSchemaFilters.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/CoreSchemaFilters.php b/src/CoreSchemaFilters.php index 559fcb6..526a06f 100644 --- a/src/CoreSchemaFilters.php +++ b/src/CoreSchemaFilters.php @@ -20,7 +20,7 @@ class CoreSchemaFilters implements Hookable { * {@inheritDoc} */ public static function register_hooks(): void { - add_filter( 'graphql_wp_object_type_config', [ __CLASS__, 'set_object_type_config' ] ); + add_filter( 'graphql_wp_interface_type_config', [ __CLASS__, 'set_interface_type_config' ] ); } /** @@ -28,13 +28,12 @@ public static function register_hooks(): void { * * @param array $config . */ - public static function set_object_type_config( array $config ) : array { - if ( ! isset( $config['interfaces'] ) ) { + public static function set_interface_type_config( array $config ) : array { + if ( ! isset( $config['name'] ) ) { return $config; } - // Add SEO interface to post types. - if ( in_array( 'ContentNode', $config['interfaces'], true ) ) { + if ( 'ContentNode' === $config['name'] ) { $config['interfaces'] = array_merge( $config['interfaces'] ?? [], [ @@ -44,7 +43,7 @@ public static function set_object_type_config( array $config ) : array { } // Add SEO interface to post types. - if ( in_array( 'TermNode', $config['interfaces'], true ) ) { + if ( 'TermNode' === $config['name'] ) { $config['interfaces'] = array_merge( $config['interfaces'] ?? [], [ From 4442ada0afd284682ca81e345db1fe2fa8b64a1a Mon Sep 17 00:00:00 2001 From: Dovid Levine Date: Sat, 19 Feb 2022 18:54:53 +0000 Subject: [PATCH 11/13] fix: add interface explicitly to Product. --- src/CoreSchemaFilters.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CoreSchemaFilters.php b/src/CoreSchemaFilters.php index 526a06f..f229d0e 100644 --- a/src/CoreSchemaFilters.php +++ b/src/CoreSchemaFilters.php @@ -32,8 +32,8 @@ public static function set_interface_type_config( array $config ) : array { if ( ! isset( $config['name'] ) ) { return $config; } - - if ( 'ContentNode' === $config['name'] ) { + // @todo Remove product check once it implements 'ContentNode'. + if ( 'ContentNode' === $config['name'] || 'Product' === $config['name'] ) { $config['interfaces'] = array_merge( $config['interfaces'] ?? [], [ From cf32379861a75024a9319ca41c3fe20310ebe3b4 Mon Sep 17 00:00:00 2001 From: Dovid Levine Date: Sat, 19 Feb 2022 19:28:05 +0000 Subject: [PATCH 12/13] chore: confirm php 8.0 compatibility --- composer.json | 2 +- composer.lock | 4 ++-- vendor/composer/installed.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 5ef9f7f..a3443e3 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "yoast/wordpress-seo": "Required to provide SEO data to this plugin" }, "require": { - "php": ">=7.4" + "php": ">=7.4 || ^8.0" }, "require-dev": { "automattic/vipwpcs": "^2.3", diff --git a/composer.lock b/composer.lock index 67a7dea..c4bcb7c 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": "c4038fd5680ffe2f9bce06a1e2caddba", + "content-hash": "32bc3df4ac81b730eceb318e2360a11b", "packages": [], "packages-dev": [ { @@ -2123,7 +2123,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.4" + "php": ">=7.4 || ^8.0" }, "platform-dev": [], "plugin-api-version": "2.2.0" diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 919e62a..e6d4d73 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -5,7 +5,7 @@ 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '5665c34f310076666caa5763e8fdd9385fa66b81', + 'reference' => '4442ada0afd284682ca81e345db1fe2fa8b64a1a', 'name' => 'ashhitch/wp-graphql-yoast-seo', 'dev' => true, ), @@ -16,7 +16,7 @@ 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '5665c34f310076666caa5763e8fdd9385fa66b81', + 'reference' => '4442ada0afd284682ca81e345db1fe2fa8b64a1a', 'dev_requirement' => false, ), 'automattic/vipwpcs' => array( From d5bd9268f39fa87df0ff01932c4121620cecded9 Mon Sep 17 00:00:00 2001 From: Dovid Levine Date: Sun, 17 Apr 2022 10:15:19 +0000 Subject: [PATCH 13/13] feat: add `seo` to ContentType object --- src/CoreSchemaFilters.php | 31 ++++++- src/Type/WPInterface/ContentNodeWithSEO.php | 2 +- src/Type/WPInterface/ContentTypeWithSEO.php | 66 ++++++++++++++ .../Config/ContentType/ContentType.php | 87 +++++++++++++++++-- src/Type/WPObject/Config/ContentTypes.php | 2 +- src/Type/WPObject/SEOConfig.php | 51 +++-------- src/TypeRegistry.php | 1 + vendor/composer/autoload_classmap.php | 1 + vendor/composer/autoload_static.php | 1 + vendor/composer/installed.php | 4 +- 10 files changed, 192 insertions(+), 54 deletions(-) create mode 100644 src/Type/WPInterface/ContentTypeWithSEO.php diff --git a/src/CoreSchemaFilters.php b/src/CoreSchemaFilters.php index f229d0e..e66662c 100644 --- a/src/CoreSchemaFilters.php +++ b/src/CoreSchemaFilters.php @@ -10,6 +10,7 @@ use WPGraphQL\YoastSEO\Interfaces\Hookable; use WPGraphQL\YoastSEO\Type\WPInterface\ContentNodeWithSEO; +use WPGraphQL\YoastSEO\Type\WPInterface\ContentTypeWithSEO; use WPGraphQL\YoastSEO\Type\WPInterface\TermNodeWithSEO; /** @@ -21,10 +22,11 @@ class CoreSchemaFilters implements Hookable { */ public static function register_hooks(): void { add_filter( 'graphql_wp_interface_type_config', [ __CLASS__, 'set_interface_type_config' ] ); + add_Filter( 'graphql_wp_object_type_config', [ __CLASS__, 'set_object_type_config' ] ); } /** - * Overwrites the GraphQL config for auto-registered object types. + * Overwrites the GraphQL config for auto-registered interface types. * * @param array $config . */ @@ -42,7 +44,9 @@ public static function set_interface_type_config( array $config ) : array { ); } - // Add SEO interface to post types. + + + // Add SEO interface to term nodes. if ( 'TermNode' === $config['name'] ) { $config['interfaces'] = array_merge( $config['interfaces'] ?? [], @@ -54,4 +58,27 @@ public static function set_interface_type_config( array $config ) : array { return $config; } + + /** + * Overwrites the GraphQL config for auto-registered object types. + * + * @param array $config . + */ + public static function set_object_type_config( array $config ) { + if ( ! isset( $config['name'] ) ) { + return $config; + } + + // Add SEO interface to content types. + if ( 'ContentType' === $config['name'] ) { + $config['interfaces'] = array_merge( + $config['interfaces'] ?? [], + [ + ContentTypeWithSEO::$type, + ] + ); + } + + return $config; + } } diff --git a/src/Type/WPInterface/ContentNodeWithSEO.php b/src/Type/WPInterface/ContentNodeWithSEO.php index 72ad3c3..0b6dd3d 100644 --- a/src/Type/WPInterface/ContentNodeWithSEO.php +++ b/src/Type/WPInterface/ContentNodeWithSEO.php @@ -111,7 +111,7 @@ public static function get_fields() : array { 'schema' => [ 'pageType' => isset( $yoast_meta->indexable ) && isset( $yoast_meta->indexable->schema_page_type ) ? $yoast_meta->schema_page_type : [], 'articleType' => isset( $yoast_meta->indexable ) && isset( $yoast_meta->indexable->schema_article_type ) ? $yoast_meta->schema_article_type : [], - 'raw' => json_encode( $schema_array, JSON_UNESCAPED_SLASHES ), + 'raw' => wp_json_encode( $schema_array, JSON_UNESCAPED_SLASHES ), ], ]; diff --git a/src/Type/WPInterface/ContentTypeWithSEO.php b/src/Type/WPInterface/ContentTypeWithSEO.php new file mode 100644 index 0000000..ba4be97 --- /dev/null +++ b/src/Type/WPInterface/ContentTypeWithSEO.php @@ -0,0 +1,66 @@ + self::get_description(), + 'fields' => self::get_fields(), + ] + ); + } + + /** + * {@inheritDoc} + */ + public static function get_description() : string { + return __( 'A Post type that can have assigned to it.', 'wp-graphql-yoast-seo' ); + } + + /** + * {@inheritDoc} + */ + public static function get_fields() : array { + return [ + 'seo' => [ + 'type' => ContentType::$type, + 'resolve' => function ( $source ) { + return $source; + }, + ], + ]; + } +} diff --git a/src/Type/WPObject/Config/ContentType/ContentType.php b/src/Type/WPObject/Config/ContentType/ContentType.php index f325770..8f5e021 100644 --- a/src/Type/WPObject/Config/ContentType/ContentType.php +++ b/src/Type/WPObject/Config/ContentType/ContentType.php @@ -8,11 +8,13 @@ namespace WPGraphQL\YoastSEO\Type\WPObject\Config\ContentType; +use WPGraphQL\Model\PostType; use WPGraphQL\Registry\TypeRegistry; use WPGraphQL\YoastSEO\Interfaces\Registrable; use WPGraphQL\YoastSEO\Interfaces\Type; use WPGraphQL\YoastSEO\Interfaces\TypeWithFields; use WPGraphQL\YoastSEO\Type\WPObject\ContentType\Archive; +use WPSEO_Options; /** * Class - SEOContentType @@ -34,6 +36,17 @@ public static function register( TypeRegistry $type_registry = null ) : void { / [ 'description' => static::get_description(), 'fields' => static::get_fields(), + 'resolve' => function ( $source ) { + if ( ! $source instanceof PostType ) { + return null; + } + + $type = $source->name; + + + $yoast_meta = YoastSEO()->meta->for_post_type_archive( $type ); + $schema_array = false !== $yoast_meta ? $yoast_meta->schema : null; + }, ] ); } @@ -49,14 +62,74 @@ public static function get_description() : string { * {@inheritDoc} */ public static function get_fields() : array { - // @todo add descriptions. + $wpseo_options = WPSEO_Options::get_all(); + return [ - 'title' => [ 'type' => 'String' ], - 'metaDesc' => [ 'type' => 'String' ], - 'metaRobotsNoindex' => [ 'type' => 'Boolean' ], - 'schemaType' => [ 'type' => 'String' ], - 'schema' => [ 'type' => 'SEOPageInfoSchema' ], - 'archive' => [ 'type' => Archive::$type ], + 'archive' => [ + 'type' => Archive::$type, + 'resolve' => function ( $source ) use ( $wpseo_options ) { + if ( empty( $source->hasArchive ) ) { + return null; + } + $yoast_meta = YoastSEO()->meta->for_post_type_archive( $source->name ); + + $default_values = [ + 'archiveLink' => get_post_type_archive_link( $source->name ), + 'fullHead' => is_string( $yoast_meta->get_head() ) ? $yoast_meta->get_head() : $yoast_meta->get_head()->html, + ]; + + // Set archive values and merge with existing. + $post_values = 'post' === $source->name ? [ + 'hasArchive' => true, + 'title' => $wpseo_options['title-archive-wpseo'] ?? null, + 'metaDesc' => $wpseo_options['metadesc-archive-wpseo'] ?? null, + 'metaRobotsNoindex' => $wpseo_options['noindex-archive-wpseo'] ?? null, + 'breadcrumbTitle' => $wpseo_options['bctitle-archive-wpseo'] ?? null, + ] : [ + 'hasArchive' => boolval( $source->hasArchive ), + 'title' => ! empty( $wpseo_options[ 'title-ptarchive-' . $source->name ] ) ? $wpseo_options[ 'title-ptarchive-' . $source->name ] : null, + 'metaDesc' => ! empty( $wpseo_options[ 'metadesc-ptarchive-' . $source->name ] ) ? $wpseo_options[ 'metadesc-ptarchive-' . $source->name ] : null, + 'metaRobotsNoindex' => ! empty( $wpseo_options[ 'noindex-ptarchive-' . $source->name ] ) ? boolval( $wpseo_options[ 'noindex-ptarchive-' . $source->name ] ) : false, + 'breadcrumbTitle' => ! empty( $wpseo_options[ 'bctitle-ptarchive-' . $source->name ] ) ? $wpseo_options[ 'bctitle-ptarchive-' . $source->name ] : null, + ]; + + return array_merge( $default_values, $post_values ); + }, + ], + 'metaDesc' => [ + 'type' => 'String', + 'resolve' => function ( $source ) use ( $wpseo_options ) { + return ! empty( $wpseo_options[ 'metadesc-' . $source->name ] ) ? $wpseo_options[ 'metadesc-' . $source->name ] : null; + }, + ], + 'metaRobotsNoindex' => [ + 'type' => 'Boolean', + 'resolve' => function ( $source ) use ( $wpseo_options ) { + return ! empty( $wpseo_options[ 'noindex-' . $source->name ] ); + }, + ], + 'schema' => [ + 'type' => 'SEOPageInfoSchema', + 'resolve' => function ( $source ) { + $yoast_meta = YoastSEO()->meta->for_post_type_archive( $source->name ); + $schema_array = false !== $yoast_meta ? $yoast_meta->schema : null; + return [ + 'raw' => ! empty( $schema_array ) ? wp_json_encode( $schema_array, JSON_UNESCAPED_SLASHES ) : null, + ]; + }, + ], + 'schemaType' => [ + 'type' => 'String', + 'resolve' => function ( $source ) use ( $wpseo_options ) { + return ! empty( $wpseo_options[ 'schema-page-type-' . $source->name ] ) ? $wpseo_options[ 'schema-page-type-' . $source->name ] : null; + }, + ], + 'title' => [ + 'type' => 'String', + 'resolve' => function ( $source ) use ( $wpseo_options ) { + return ! empty( $wpseo_options[ 'title-' . $source->name ] ) ? $wpseo_options[ 'title-' . $source->name ] : null; + }, + ], ]; } } diff --git a/src/Type/WPObject/Config/ContentTypes.php b/src/Type/WPObject/Config/ContentTypes.php index 4ec485c..c214614 100644 --- a/src/Type/WPObject/Config/ContentTypes.php +++ b/src/Type/WPObject/Config/ContentTypes.php @@ -71,7 +71,7 @@ private static function build_content_types( array $types ) : array { foreach ( $types as $type ) { $post_type_object = get_post_type_object( $type ); - if ( $post_type_object instanceof WP_Post_Type && $post_type_object->graphql_single_name ) { + if ( $post_type_object instanceof WP_Post_Type && isset( $post_type_object->graphql_single_name ) ) { $carry[ wp_gql_seo_get_field_key( $post_type_object->graphql_single_name ) ] = [ 'type' => ContentType::$type ]; } } diff --git a/src/Type/WPObject/SEOConfig.php b/src/Type/WPObject/SEOConfig.php index 12c6636..a87adb3 100644 --- a/src/Type/WPObject/SEOConfig.php +++ b/src/Type/WPObject/SEOConfig.php @@ -106,7 +106,7 @@ public static function register_field() : void { ]; }; - $contentTypes = self::build_content_type_data( $post_types, $wpseo_options ); + $contentTypes = self::get_content_types( $post_types ); return [ 'contentTypes' => $contentTypes, @@ -202,53 +202,22 @@ public static function register_field() : void { * Builds the resolver data for all SEOContentTypes * * @param string[] $types The post types. - * @param array $wpseo_options An array of all WPSEO options. */ - private static function build_content_type_data( $types, $wpseo_options ) : array { + private static function get_content_types( $types ) : array { $carry = []; foreach ( $types as $type ) { $post_type_object = get_post_type_object( $type ); - if ( $post_type_object instanceof WP_Post_Type && $post_type_object->graphql_single_name ) { - $tag = wp_gql_seo_get_field_key( - $post_type_object->graphql_single_name - ); - - $yoast_meta = YoastSEO()->meta->for_post_type_archive( $type ); - $schema_array = false !== $yoast_meta ? $yoast_meta->schema : null; - - $carry[ $tag ] = [ - 'title' => ! empty( $wpseo_options[ 'title-' . $type ] ) ? $wpseo_options[ 'title-' . $type ] : null, - 'metaDesc' => ! empty( $wpseo_options[ 'metadesc-' . $type ] ) ? $wpseo_options[ 'metadesc-' . $type ] : null, - 'metaRobotsNoindex' => ! empty( $wpseo_options[ 'noindex-' . $type ] ), - 'schemaType' => ! empty( $wpseo_options[ 'schema-page-type-' . $type ] ) ? $wpseo_options[ 'schema-page-type-' . $type ] : null, - 'schema' => [ - 'raw' => ! empty( $schema_array ) ? json_encode( $schema_array, JSON_UNESCAPED_SLASHES ) : null, - ], - // These are shared by all post types. - 'archive' => [ - 'archiveLink' => get_post_type_archive_link( $type ), - 'fullHead' => is_string( $yoast_meta->get_head() ) ? $yoast_meta->get_head() : $yoast_meta->get_head()->html, - ], - ]; - - // Set archive values and merge with existing. - $archive_values = 'post' === $tag ? [ - 'hasArchive' => true, - 'title' => $wpseo_options['title-archive-wpseo'] ?? null, - 'metaDesc' => $wpseo_options['metadesc-archive-wpseo'] ?? null, - 'metaRobotsNoindex' => $wpseo_options['noindex-archive-wpseo'] ?? null, - 'breadcrumbTitle' => $wpseo_options['bctitle-archive-wpseo'] ?? null, - ] : [ - 'hasArchive' => boolval( $post_type_object->has_archive ), - 'title' => ! empty( $wpseo_options[ 'title-ptarchive-' . $type ] ) ? $wpseo_options[ 'title-ptarchive-' . $type ] : null, - 'metaDesc' => ! empty( $wpseo_options[ 'metadesc-ptarchive-' . $type ] ) ? $wpseo_options[ 'metadesc-ptarchive-' . $type ] : null, - 'metaRobotsNoindex' => ! empty( $wpseo_options[ 'noindex-ptarchive-' . $type ] ) ? boolval( $wpseo_options[ 'noindex-ptarchive-' . $type ] ) : false, - 'breadcrumbTitle' => ! empty( $wpseo_options[ 'bctitle-ptarchive-' . $type ] ) ? $wpseo_options[ 'bctitle-ptarchive-' . $type ] : null, - ]; - $carry[ $tag ]['archive'] = array_merge( $carry[ $tag ]['archive'], $archive_values ); + if ( ! $post_type_object instanceof WP_Post_Type || empty( $post_type_object->graphql_single_name ) ) { + continue; } + $tag = wp_gql_seo_get_field_key( + $post_type_object->graphql_single_name + ); + + $carry[ $tag ] = $post_type_object; } + return $carry; } } diff --git a/src/TypeRegistry.php b/src/TypeRegistry.php index cb7f146..8f5daed 100644 --- a/src/TypeRegistry.php +++ b/src/TypeRegistry.php @@ -68,6 +68,7 @@ public static function register_enums( GraphQLRegistry $type_registry ) : void { public static function register_interfaces( GraphQLRegistry $type_registry ) : void { WPInterface\SEOBaseFields::register( $type_registry ); WPInterface\ContentNodeWithSEO::register( $type_registry ); + WPInterface\ContentTypeWithSEO::register( $type_registry ); WPInterface\TermNodeWithSEO::register( $type_registry ); /** diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 743381b..de78422 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -18,6 +18,7 @@ 'WPGraphQL\\YoastSEO\\TypeRegistry' => $baseDir . '/src/TypeRegistry.php', 'WPGraphQL\\YoastSEO\\Type\\Enum\\SEOCardTypeEnum' => $baseDir . '/src/Type/Enum/SEOCardTypeEnum.php', 'WPGraphQL\\YoastSEO\\Type\\WPInterface\\ContentNodeWithSEO' => $baseDir . '/src/Type/WPInterface/ContentNodeWithSEO.php', + 'WPGraphQL\\YoastSEO\\Type\\WPInterface\\ContentTypeWithSEO' => $baseDir . '/src/Type/WPInterface/ContentTypeWithSEO.php', 'WPGraphQL\\YoastSEO\\Type\\WPInterface\\SEOBaseFields' => $baseDir . '/src/Type/WPInterface/SEOBaseFields.php', 'WPGraphQL\\YoastSEO\\Type\\WPInterface\\TermNodeWithSEO' => $baseDir . '/src/Type/WPInterface/TermNodeWithSEO.php', 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Breadcrumbs' => $baseDir . '/src/Type/WPObject/Config/Breadcrumbs.php', diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 6c1e3af..85b192e 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -37,6 +37,7 @@ class ComposerStaticInitccec7e4645ca6ddf694d702594caaacb 'WPGraphQL\\YoastSEO\\TypeRegistry' => __DIR__ . '/../..' . '/src/TypeRegistry.php', 'WPGraphQL\\YoastSEO\\Type\\Enum\\SEOCardTypeEnum' => __DIR__ . '/../..' . '/src/Type/Enum/SEOCardTypeEnum.php', 'WPGraphQL\\YoastSEO\\Type\\WPInterface\\ContentNodeWithSEO' => __DIR__ . '/../..' . '/src/Type/WPInterface/ContentNodeWithSEO.php', + 'WPGraphQL\\YoastSEO\\Type\\WPInterface\\ContentTypeWithSEO' => __DIR__ . '/../..' . '/src/Type/WPInterface/ContentTypeWithSEO.php', 'WPGraphQL\\YoastSEO\\Type\\WPInterface\\SEOBaseFields' => __DIR__ . '/../..' . '/src/Type/WPInterface/SEOBaseFields.php', 'WPGraphQL\\YoastSEO\\Type\\WPInterface\\TermNodeWithSEO' => __DIR__ . '/../..' . '/src/Type/WPInterface/TermNodeWithSEO.php', 'WPGraphQL\\YoastSEO\\Type\\WPObject\\Config\\Breadcrumbs' => __DIR__ . '/../..' . '/src/Type/WPObject/Config/Breadcrumbs.php', diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index e6d4d73..c57716f 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -5,7 +5,7 @@ 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '4442ada0afd284682ca81e345db1fe2fa8b64a1a', + 'reference' => 'cf32379861a75024a9319ca41c3fe20310ebe3b4', 'name' => 'ashhitch/wp-graphql-yoast-seo', 'dev' => true, ), @@ -16,7 +16,7 @@ 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '4442ada0afd284682ca81e345db1fe2fa8b64a1a', + 'reference' => 'cf32379861a75024a9319ca41c3fe20310ebe3b4', 'dev_requirement' => false, ), 'automattic/vipwpcs' => array(