From e31e035309ae3075e490b5e30b682d2e7321c1ca Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Thu, 8 Feb 2024 15:54:39 +0100 Subject: [PATCH 01/17] Update README to org-standard --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cc022f6..aa9eadb 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@

-## About +## About This is the long desc @@ -60,7 +60,7 @@ Figuren_Theater::API\get_...() ## Plugins included -This package contains the following plugins. +This package contains the following plugins. Thoose are completely managed by code and lack of their typical UI. * [Yoast SEO](https://wordpress.org/plugins/wordpress-seo/#developers) @@ -108,7 +108,7 @@ who participated in this project. ## License -This project is licensed under the [GPL-3.0-or-later](LICENSE.md), see the [LICENSE](LICENSE) file for +This project is licensed under the **GPL-3.0-or-later**, see the [LICENSE](/LICENSE) file for details ## Acknowledgments From be2137a9ce4ff0968ccc862f972812dc41e313fc Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Thu, 8 Feb 2024 15:55:24 +0100 Subject: [PATCH 02/17] Add Issue-Gardening workflow --- .github/workflows/ft-issue-gardening.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .github/workflows/ft-issue-gardening.yml diff --git a/.github/workflows/ft-issue-gardening.yml b/.github/workflows/ft-issue-gardening.yml new file mode 100644 index 0000000..96fd72a --- /dev/null +++ b/.github/workflows/ft-issue-gardening.yml @@ -0,0 +1,10 @@ +name: Issue gardening for figuren.theater + +on: + issues: + types: + - opened +jobs: + call-workflow-ft-issue-gardening: + uses: figuren-theater/.github/.github/workflows/issue-gardening.yml@main + secrets: inherit From 15938c55247019a925062c44e7dc437d686d5bc3 Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Thu, 8 Feb 2024 15:56:54 +0100 Subject: [PATCH 03/17] Fix line-endings and some automated CS issues --- inc/wordpress-seo/admin-ui.php | 52 +++++++++++++------------------- inc/wordpress-seo/namespace.php | 23 ++++++-------- inc/wordpress-seo/open-graph.php | 4 +-- 3 files changed, 32 insertions(+), 47 deletions(-) diff --git a/inc/wordpress-seo/admin-ui.php b/inc/wordpress-seo/admin-ui.php index c01efaa..26bf286 100644 --- a/inc/wordpress-seo/admin-ui.php +++ b/inc/wordpress-seo/admin-ui.php @@ -20,11 +20,9 @@ * Bootstrap module, when enabled. */ function bootstrap() { - // - add_action( 'admin_init', __NAMESPACE__ . '\\remove_roles', 11 ); + add_action( 'admin_init', __NAMESPACE__ . '\\remove_roles', 11 ); - // - add_action( 'network_admin_menu', __NAMESPACE__ . '\\remove_menus', 12 ); + add_action( 'network_admin_menu', __NAMESPACE__ . '\\remove_menus', 12 ); add_action( 'admin_menu', __NAMESPACE__ . '\\remove_menus', 12 ); // add_action( 'wp_dashboard_setup', __NAMESPACE__ . '\\remove_menu__courses' ); @@ -32,10 +30,10 @@ function bootstrap() { add_action( 'wp_dashboard_setup', __NAMESPACE__ . '\\remove_dashboard_widgets', 0 ); // add_action( 'admin_init', __NAMESPACE__ . '\\remove_dashboard_widgets', 0 ); - add_action( 'admin_head' , __NAMESPACE__ . '\\remove_bloat' ); + add_action( 'admin_head', __NAMESPACE__ . '\\remove_bloat' ); // Hide some Yoast Editor panels (ort parts of it) that are only ads. - add_action( 'admin_footer-post.php' , __NAMESPACE__ . '\\js_hide_metabox' ); + add_action( 'admin_footer-post.php', __NAMESPACE__ . '\\js_hide_metabox' ); add_action( 'admin_footer-post-new.php', __NAMESPACE__ . '\\js_hide_metabox' ); // Remove Helpscout. @@ -46,7 +44,6 @@ function bootstrap() { add_action( 'admin_head', __NAMESPACE__ . '\\hide_yoast_editor_sidebar_panels' ); } - /** * Remove Yoast SEO user roles * @@ -57,34 +54,32 @@ function bootstrap() { function remove_roles() : void { // Remove Yoast `SEO Manager` role - if ( get_role('wpseo_manager') ) { + if ( get_role( 'wpseo_manager' ) ) { remove_role( 'wpseo_manager' ); } // Remove Yoast `SEO Editor` role - if ( get_role('wpseo_editor') ) { + if ( get_role( 'wpseo_editor' ) ) { remove_role( 'wpseo_editor' ); } } - function remove_menus() : void { - + remove_submenu_page( 'wpseo_dashboard', 'wpseo_workouts' ); // Remove the Premium submenu. remove_submenu_page( 'wpseo_dashboard', 'wpseo_licenses' ); remove_submenu_page( 'wpseo_dashboard', 'wpseo_redirects' ); - - // - if ( is_super_admin() && true === constant( 'WP_DEBUG' ) ) + + if ( is_super_admin() && true === constant( 'WP_DEBUG' ) ) { return; + } remove_menu_page( 'wpseo_dashboard' ); // remove_menu_page( 'wpseo_workouts' ); } - /** * Yoast » Remove courses. * @@ -95,7 +90,6 @@ function remove_menu__courses() : void { remove_submenu_page( 'wpseo_dashboard', 'wpseo_courses' ); } - /** * Remove the Yoast SEO dashboard widget. * @@ -107,7 +101,7 @@ function remove_dashboard_widgets() { remove_meta_box( 'wpseo-dashboard-overview', 'dashboard', 'normal' ); remove_meta_box( 'wpseo-dashboard-overview', 'dashboard', 'side' ); - add_action( 'admin_enqueue_scripts', function(){ + add_action( 'admin_enqueue_scripts', function() { // This script & style are enqueued by Yoast. // \wp_dequeue_script( 'yoast-seo-dashboard-widget' ); \wp_dequeue_style( 'yoast-seo-wp-dashboard' ); @@ -115,7 +109,6 @@ function remove_dashboard_widgets() { }, 11 ); } - /** * Yoast » Remove bloat * @@ -123,7 +116,7 @@ function remove_dashboard_widgets() { * @see https://plugins.trac.wordpress.org/browser/smntcs-utilities/trunk/smntcs-utilities.php#L87 * @see https://github.com/Yoast/wordpress-seo/issues/3464 * @see https://wordpress.org/support/topic/please-remove-your-invasive-update-message - * + * * @since 1.0.0 * @return void */ @@ -140,11 +133,11 @@ function remove_bloat() { body.seo_page_wpseo_tools #sidebar-container, .yoast-notification.notice, #yoast-helpscout-beacon, - /* following from: + /* following from: https://github.com/courtness/wordpack/blob/1a9248a9965fead4a2276bb4f93ff402aacb9963/wp-content/themes/wordpack/inc/admin-functions.php#L12-L41 */ #wp-admin-bar-wpseo-menu, /* classic metaboxes - #misc-publishing-actions #content-score, + #misc-publishing-actions #content-score, #misc-publishing-actions #keyword-score, */ .yoast-notice, [name="seo_filter"], @@ -155,7 +148,7 @@ function remove_bloat() { } /** - * + * * @todo HIER STIMMT WAS GEWALTIG NICHT * * @package [package] @@ -181,9 +174,9 @@ function js_hide_metabox() { // @see https://github.com/WordPress/gutenberg/blob/4a4e32deb12d2ce104fbfb09734d2b0583315546/packages/interface/README.md#L67 const _wpseo_plugin = wp.data.select( 'core/interface' ).isItemPinned( 'core/edit-post', 'yoast-seo/seo-sidebar' ); if ( _wpseo_plugin ) { - wp.data.dispatch( 'core/interface' ).unpinItem( 'core/edit-post', 'yoast-seo/seo-sidebar' ); + wp.data.dispatch( 'core/interface' ).unpinItem( 'core/edit-post', 'yoast-seo/seo-sidebar' ); // setTimeout( function() { - // wp.data.dispatch( 'core/interface' ).unpinItem( 'core/edit-post', 'yoast-seo/seo-sidebar' ); + // wp.data.dispatch( 'core/interface' ).unpinItem( 'core/edit-post', 'yoast-seo/seo-sidebar' ); // }, 200 ); // yoast uses '100' } @@ -192,9 +185,6 @@ function js_hide_metabox() { div.notice-yoast', // 'Seo Analysis' editor sidebar panel > Premium-Links and Ad 'div.components-panel div:nth-child(3) div.yoast.components-panel__body:nth-child(1)>*', - + // 'Premium Seo Analysis' editor sidebar panel 'div.components-panel div:nth-child(3) div.yoast.components-panel__body:nth-child(2)', - + // 'Add related keywords' 'div.components-panel div:nth-child(5) div.yoast.components-panel__body', @@ -230,7 +220,7 @@ function hide_yoast_editor_sidebar_panels() { ]; - $styles = join(', ', $selectors ) . ' { + $styles = join( ', ', $selectors ) . ' { display: none; } /** Reset "Seo Analysis" editor sidebar panel > clickable title & results */ diff --git a/inc/wordpress-seo/namespace.php b/inc/wordpress-seo/namespace.php index f5ad351..b22d5f6 100644 --- a/inc/wordpress-seo/namespace.php +++ b/inc/wordpress-seo/namespace.php @@ -7,27 +7,23 @@ namespace Figuren_Theater\SEO\Yoast_SEO; -use Figuren_Theater\SEO\Yoast_SEO\Admin_UI; // use Figuren_Theater\SEO\Yoast_SEO\Open_Graph; use Figuren_Theater\SEO\Yoast_SEO\Options; use FT_VENDOR_DIR; -use WP_DEBUG; - -use WPSEO_DEBUG; -use WPSEO_Menu; -use WPSEO_Network_Admin_Menu; +use function add_action; +use function add_filter; // use WP_CLI; // use WP_Query; -use Yoast_Network_Admin; +use function get_plugins; -use function add_action; -use function add_filter; use function get_plugin_data; -use function get_plugins; use function is_admin; use function wp_cache_set; +use WPSEO_Menu; +use WPSEO_Network_Admin_Menu; +use Yoast_Network_Admin; const BASENAME = 'wordpress-seo/wp-seo.php'; const PLUGINPATH = FT_VENDOR_DIR . '/wpackagist-plugin/' . BASENAME; @@ -46,7 +42,7 @@ function load_plugin() { // Patch network activated plugin bootstrapping manually. add_action( 'wpseo_loaded', __NAMESPACE__ . '\\enable_yoast_network_admin' ); - + // Load Yoast SEO. require_once PLUGINPATH; @@ -63,8 +59,9 @@ function load_plugin() { // https://gist.github.com/paulcollett/4c81c4f6eb85334ba076 add_filter( 'wpseo_debug_markers', '__return_false' ); - if ( ! is_admin() ) + if ( ! is_admin() ) { return; + } if ( isset( $_SERVER['REQUEST_URI'] ) && strpos( $_SERVER['REQUEST_URI'], 'admin.php?page=wpseo_' ) !== false ) { add_action( 'plugins_loaded', __NAMESPACE__ . '\\add_yoast_plugins', 5 ); @@ -75,7 +72,6 @@ function load_plugin() { add_action( 'admin_menu', __NAMESPACE__ . '\\Admin_UI\\bootstrap', 0 ); } - /** * Allow Yoast to validate subscriptions by faking available plugins list. * @@ -133,7 +129,6 @@ function enable_yoast_network_admin() { $network_admin_menu->register_hooks(); } - /** * Add the Yoast SEO sitemap index to the robots.txt file. * diff --git a/inc/wordpress-seo/open-graph.php b/inc/wordpress-seo/open-graph.php index 8ff6144..f2c3d4e 100644 --- a/inc/wordpress-seo/open-graph.php +++ b/inc/wordpress-seo/open-graph.php @@ -69,9 +69,9 @@ function opengraph_presenters( array $presenters ) : array { * Because by default it is based on WPLANG constant * * @see https://developer.yoast.com/features/opengraph/api/changing-og-locale-output/#change-the-oglocale-tag - * + * * @param string $locale The current locale. - * + * * @return string The locale. */ function change_og_locale( string $locale ) : string { From e1c4a554a369227b7a185531038eaee9fe0e2726 Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Thu, 8 Feb 2024 16:09:24 +0100 Subject: [PATCH 04/17] NEW project-management actions --- .github/workflows/prerelease-changelog.yml | 12 ++++++++++++ .github/workflows/release-drafter.yml | 19 +++++++++++++++++++ CHANGELOG.md | 8 ++++++++ 3 files changed, 39 insertions(+) create mode 100644 .github/workflows/prerelease-changelog.yml create mode 100644 .github/workflows/release-drafter.yml create mode 100644 CHANGELOG.md diff --git a/.github/workflows/prerelease-changelog.yml b/.github/workflows/prerelease-changelog.yml new file mode 100644 index 0000000..265e9ab --- /dev/null +++ b/.github/workflows/prerelease-changelog.yml @@ -0,0 +1,12 @@ +name: 'pre-Release Changelog Update' + +on: + workflow_call: + release: + types: [prereleased] + +jobs: + call-workflow-update-changelog: + uses: figuren-theater/.github/.github/workflows/prerelease-changelog-update.yml@main + secrets: inherit + diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..3e5c659 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,19 @@ +name: Draft or update the next release + +on: + push: + # branches to consider in the event; optional, defaults to all + branches: + - main + # pull_request event is required only for autolabeler + pull_request: + # Only following types are handled by the action, but one can default to all as well + types: [opened, reopened, synchronize] + # pull_request_target event is required for autolabeler to support PRs from forks + # pull_request_target: + # types: [opened, reopened, synchronize] + +jobs: + call-workflow-release-drafter: + uses: figuren-theater/.github/.github/workflows/release-drafter.yml@main + secrets: inherit diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..3831f52 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,8 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +## [Unreleased](https://github.com/figuren-theater/ft-seo/compare/1.1.0...HEAD) + + + From 6ada5f3b1eabac470fc8c9a222b33b8877cb7dab Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Thu, 8 Feb 2024 16:10:53 +0100 Subject: [PATCH 05/17] NEW code-quality actions --- .editorconfig | 13 +++++++------ .github/workflows/build-test-measure.yml | 13 +++++++++++++ .gitignore | 24 +++++++++++++++++------- .phpcs.xml | 11 +++++++++++ phpstan.neon | 19 +++++++++++++++++++ 5 files changed, 67 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/build-test-measure.yml create mode 100644 .phpcs.xml create mode 100644 phpstan.neon diff --git a/.editorconfig b/.editorconfig index 79207a4..2612e4e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,14 +9,15 @@ root = true [*] charset = utf-8 end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true indent_style = tab indent_size = 4 +insert_final_newline = true +tabSize = 4 +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false -[{.jshintrc,*.json,*.yml}] +[{*.json,*.yml}] indent_style = space indent_size = 2 - -[{*.txt,wp-config-sample.php}] -end_of_line = crlf diff --git a/.github/workflows/build-test-measure.yml b/.github/workflows/build-test-measure.yml new file mode 100644 index 0000000..cd94352 --- /dev/null +++ b/.github/workflows/build-test-measure.yml @@ -0,0 +1,13 @@ +name: Build, test & measure + +on: + workflow_call: + pull_request: + push: + branches: + ['main'] + +jobs: + call-workflow-build-test-measure: + uses: figuren-theater/code-quality/.github/workflows/build-test-measure.yml@main + secrets: inherit diff --git a/.gitignore b/.gitignore index 448ac03..3791aed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,21 @@ -.DS_Store -phpcs.xml -phpunit.xml -Thumbs.db -wp-cli.local.yml -node_modules/ +/build/ +/node_modules +/vendor *.sql *.tar.gz *.zip +/wiki +.vscode + +# Generated via bin/transform-readme.php +/readme.txt +/.wp-env.override.json + +# misc +.DS_Store +Thumbs.db -/vendor/ +# is created during composer install, +# when package is tested +# and not running within ft-platform +/wp-content/ diff --git a/.phpcs.xml b/.phpcs.xml new file mode 100644 index 0000000..d715e81 --- /dev/null +++ b/.phpcs.xml @@ -0,0 +1,11 @@ + + + Coding standards for ft-seo + + . + + + + + + diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..9e185fd --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,19 @@ +#$ vendor/bin/phpstan analyze + +parameters: + level: max + inferPrivatePropertyTypeFromConstructor: true + paths: + - inc/ + - plugin.php + excludePaths: + analyse: + - vendor/ + # "/wp-content/" is created during composer install, + # when package is tested + # and not running within ft-platform + - wp-content/ + - tests/ + ignoreErrors: + # Find a nicer way instead of ignoring this Error on every ft-module + - '#Function Altis\\register_module not found\.#' From 47524607e0b51e642b945853613e4d143c65b5ee Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Thu, 8 Feb 2024 16:14:56 +0100 Subject: [PATCH 06/17] Install deps.: f.t/code-quality & normalize composer.json --- composer.json | 52 +- composer.lock | 2060 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 2092 insertions(+), 20 deletions(-) create mode 100644 composer.lock diff --git a/composer.json b/composer.json index 37fed25..0320b54 100644 --- a/composer.json +++ b/composer.json @@ -1,10 +1,14 @@ { "name": "figuren-theater/ft-seo", "description": "Integrations dedicated to search engines and social media plattforms for all sites of the WordPress multisite network figuren.theater", - "homepage": "https://websites.fuer.figuren.theater", - "type": "wordpress-muplugin", - "keywords": ["wordpress", "seo", "sitemaps", "opengraph"], "license": "GPL-3.0-or-later", + "type": "wordpress-muplugin", + "keywords": [ + "wordpress", + "seo", + "sitemaps", + "opengraph" + ], "authors": [ { "name": "figuren.theater", @@ -17,12 +21,31 @@ "role": "Developer" } ], + "homepage": "https://websites.fuer.figuren.theater", "support": { "email": "info@figuren.theater", "issues": "https://github.com/figuren-theater/ft-seo/issues", "source": "https://github.com/figuren-theater/ft-seo" }, + "require": { + "php": ">=7.1", + "figuren-theater/ft-options": "*", + "wpackagist-plugin/sharing-image": "2.0", + "wpackagist-plugin/wordpress-seo": "19.8" + }, + "require-dev": { + "figuren-theater/code-quality": "*" + }, + "repositories": [ + { + "type": "composer", + "url": "https://wpackagist.org" + } + ], "autoload": { + "classmap": [ + "inc/" + ], "files": [ "inc/sharing-image/admin-ui.php", "inc/sharing-image/frontend.php", @@ -34,26 +57,15 @@ "inc/wordpress-seo/options.php", "inc/wordpress-seo/namespace.php", "inc/namespace.php" - ], - "classmap": [ - "inc/" ] }, - "repositories": [ - { - "type": "git", - "url": "https://github.com/figuren-theater/ft-options" - }, - { - "type": "composer", - "url" : "https://wpackagist.org" + "config": { + "allow-plugins": { + "composer/installers": true, + "dealerdirect/phpcodesniffer-composer-installer": true, + "ergebnis/composer-normalize": true, + "phpstan/extension-installer": true } - ], - "require": { - "php": ">=7.1", - "figuren-theater/ft-options": "^1", - "wpackagist-plugin/sharing-image": "^2.0", - "wpackagist-plugin/wordpress-seo": "^19.8" }, "extra": { "altis": { diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..5532937 --- /dev/null +++ b/composer.lock @@ -0,0 +1,2060 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "23973075fa89914535f3cef96bd48938", + "packages": [ + { + "name": "composer/installers", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/composer/installers.git", + "reference": "c29dc4b93137acb82734f672c37e029dfbd95b35" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/installers/zipball/c29dc4b93137acb82734f672c37e029dfbd95b35", + "reference": "c29dc4b93137acb82734f672c37e029dfbd95b35", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0 || ^2.0", + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "composer/composer": "1.6.* || ^2.0", + "composer/semver": "^1 || ^3", + "phpstan/phpstan": "^0.12.55", + "phpstan/phpstan-phpunit": "^0.12.16", + "symfony/phpunit-bridge": "^5.3", + "symfony/process": "^5" + }, + "type": "composer-plugin", + "extra": { + "class": "Composer\\Installers\\Plugin", + "branch-alias": { + "dev-main": "2.x-dev" + }, + "plugin-modifies-install-path": true + }, + "autoload": { + "psr-4": { + "Composer\\Installers\\": "src/Composer/Installers" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kyle Robinson Young", + "email": "kyle@dontkry.com", + "homepage": "https://github.com/shama" + } + ], + "description": "A multi-framework Composer library installer", + "homepage": "https://composer.github.io/installers/", + "keywords": [ + "Dolibarr", + "Eliasis", + "Hurad", + "ImageCMS", + "Kanboard", + "Lan Management System", + "MODX Evo", + "MantisBT", + "Mautic", + "Maya", + "OXID", + "Plentymarkets", + "Porto", + "RadPHP", + "SMF", + "Starbug", + "Thelia", + "Whmcs", + "WolfCMS", + "agl", + "annotatecms", + "attogram", + "bitrix", + "cakephp", + "chef", + "cockpit", + "codeigniter", + "concrete5", + "croogo", + "dokuwiki", + "drupal", + "eZ Platform", + "elgg", + "expressionengine", + "fuelphp", + "grav", + "installer", + "itop", + "known", + "kohana", + "laravel", + "lavalite", + "lithium", + "magento", + "majima", + "mako", + "matomo", + "mediawiki", + "miaoxing", + "modulework", + "modx", + "moodle", + "osclass", + "pantheon", + "phpbb", + "piwik", + "ppi", + "processwire", + "puppet", + "pxcms", + "reindex", + "roundcube", + "shopware", + "silverstripe", + "sydes", + "sylius", + "tastyigniter", + "wordpress", + "yawik", + "zend", + "zikula" + ], + "support": { + "issues": "https://github.com/composer/installers/issues", + "source": "https://github.com/composer/installers/tree/v2.2.0" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2022-08-20T06:45:11+00:00" + }, + { + "name": "figuren-theater/ft-options", + "version": "1.2.3", + "source": { + "type": "git", + "url": "https://github.com/figuren-theater/ft-options.git", + "reference": "127e6c8bb62cce778ee7468aa548c8326fe9c29a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/figuren-theater/ft-options/zipball/127e6c8bb62cce778ee7468aa548c8326fe9c29a", + "reference": "127e6c8bb62cce778ee7468aa548c8326fe9c29a", + "shasum": "" + }, + "require": { + "markjaquith/wp-tlc-transients": "^1.0", + "php": ">=7.4" + }, + "require-dev": { + "figuren-theater/code-quality": "*" + }, + "type": "wordpress-muplugin", + "autoload": { + "classmap": [ + "inc/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-3.0-or-later" + ], + "authors": [ + { + "name": "figuren.theater", + "email": "info@figuren.theater" + }, + { + "name": "Carsten Bach", + "email": "mail@carsten-bach.de", + "homepage": "https://carsten-bach.de", + "role": "Developer" + } + ], + "description": "Options management via code for a WordPress multisite like figuren.theater", + "homepage": "https://websites.fuer.figuren.theater", + "keywords": [ + "Settings", + "multisite", + "options", + "wordpress" + ], + "support": { + "email": "info@figuren.theater", + "issues": "https://github.com/figuren-theater/ft-options/issues", + "source": "https://github.com/figuren-theater/ft-options" + }, + "time": "2023-09-11T10:27:33+00:00" + }, + { + "name": "markjaquith/wp-tlc-transients", + "version": "1.0", + "source": { + "type": "git", + "url": "https://github.com/markjaquith/WP-TLC-Transients.git", + "reference": "bdbe0691db6adaf08af0dee6c70ebebe881633d8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/markjaquith/WP-TLC-Transients/zipball/bdbe0691db6adaf08af0dee6c70ebebe881633d8", + "reference": "bdbe0691db6adaf08af0dee6c70ebebe881633d8", + "shasum": "" + }, + "type": "library", + "autoload": { + "files": [ + "functions.php" + ], + "classmap": [ + "class-tlc-transient.php", + "class-tlc-transient-update-server.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "authors": [ + { + "name": "Mark Jaquith", + "homepage": "http://markjaquith.com/" + } + ], + "description": "A WP transients interface with support for soft-expiration, background updating of the transients.", + "homepage": "https://github.com/markjaquith/WP-TLC-Transients", + "keywords": [ + "cache", + "wordpress" + ], + "support": { + "issues": "https://github.com/markjaquith/WP-TLC-Transients/issues", + "source": "https://github.com/markjaquith/WP-TLC-Transients" + }, + "time": "2013-05-07T18:12:10+00:00" + }, + { + "name": "wpackagist-plugin/sharing-image", + "version": "2.0", + "source": { + "type": "svn", + "url": "https://plugins.svn.wordpress.org/sharing-image/", + "reference": "tags/2.0" + }, + "dist": { + "type": "zip", + "url": "https://downloads.wordpress.org/plugin/sharing-image.2.0.zip" + }, + "require": { + "composer/installers": "^1.0 || ^2.0" + }, + "type": "wordpress-plugin", + "homepage": "https://wordpress.org/plugins/sharing-image/" + }, + { + "name": "wpackagist-plugin/wordpress-seo", + "version": "19.8", + "source": { + "type": "svn", + "url": "https://plugins.svn.wordpress.org/wordpress-seo/", + "reference": "tags/19.8" + }, + "dist": { + "type": "zip", + "url": "https://downloads.wordpress.org/plugin/wordpress-seo.19.8.zip" + }, + "require": { + "composer/installers": "^1.0 || ^2.0" + }, + "type": "wordpress-plugin", + "homepage": "https://wordpress.org/plugins/wordpress-seo/" + } + ], + "packages-dev": [ + { + "name": "automattic/vipwpcs", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/Automattic/VIP-Coding-Standards.git", + "reference": "1b8960ebff9ea3eb482258a906ece4d1ee1e25fd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Automattic/VIP-Coding-Standards/zipball/1b8960ebff9ea3eb482258a906ece4d1ee1e25fd", + "reference": "1b8960ebff9ea3eb482258a906ece4d1ee1e25fd", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "phpcsstandards/phpcsextra": "^1.1.0", + "phpcsstandards/phpcsutils": "^1.0.8", + "sirbrillig/phpcs-variable-analysis": "^2.11.17", + "squizlabs/php_codesniffer": "^3.7.2", + "wp-coding-standards/wpcs": "^3.0" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^1.0.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", + "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", + "static analysis", + "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": "2023-09-05T11:01:05+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": "ergebnis/composer-normalize", + "version": "2.39.0", + "source": { + "type": "git", + "url": "https://github.com/ergebnis/composer-normalize.git", + "reference": "a878360bc8cb5cb440b9381f72b0aaa125f937c7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ergebnis/composer-normalize/zipball/a878360bc8cb5cb440b9381f72b0aaa125f937c7", + "reference": "a878360bc8cb5cb440b9381f72b0aaa125f937c7", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.0.0", + "ergebnis/json": "^1.1.0", + "ergebnis/json-normalizer": "^4.3.0", + "ergebnis/json-printer": "^3.4.0", + "ext-json": "*", + "justinrainbow/json-schema": "^5.2.12", + "localheinz/diff": "^1.1.1", + "php": "~8.1.0 || ~8.2.0 || ~8.3.0" + }, + "require-dev": { + "composer/composer": "^2.6.5", + "ergebnis/license": "^2.2.0", + "ergebnis/php-cs-fixer-config": "~6.7.0", + "ergebnis/phpunit-slow-test-detector": "^2.3.0", + "fakerphp/faker": "^1.23.0", + "infection/infection": "~0.27.4", + "phpunit/phpunit": "^10.4.1", + "psalm/plugin-phpunit": "~0.18.4", + "rector/rector": "~0.18.5", + "symfony/filesystem": "^6.0.13", + "vimeo/psalm": "^5.15.0" + }, + "type": "composer-plugin", + "extra": { + "class": "Ergebnis\\Composer\\Normalize\\NormalizePlugin", + "composer-normalize": { + "indent-size": 2, + "indent-style": "space" + }, + "plugin-optional": true + }, + "autoload": { + "psr-4": { + "Ergebnis\\Composer\\Normalize\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andreas Möller", + "email": "am@localheinz.com", + "homepage": "https://localheinz.com" + } + ], + "description": "Provides a composer plugin for normalizing composer.json.", + "homepage": "https://github.com/ergebnis/composer-normalize", + "keywords": [ + "composer", + "normalize", + "normalizer", + "plugin" + ], + "support": { + "issues": "https://github.com/ergebnis/composer-normalize/issues", + "security": "https://github.com/ergebnis/composer-normalize/blob/main/.github/SECURITY.md", + "source": "https://github.com/ergebnis/composer-normalize" + }, + "time": "2023-10-10T15:43:27+00:00" + }, + { + "name": "ergebnis/json", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/ergebnis/json.git", + "reference": "a457f25a5ba7ea11fc94f84d53678c5211abfce0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ergebnis/json/zipball/a457f25a5ba7ea11fc94f84d53678c5211abfce0", + "reference": "a457f25a5ba7ea11fc94f84d53678c5211abfce0", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0" + }, + "require-dev": { + "ergebnis/data-provider": "^3.2.0", + "ergebnis/license": "^2.4.0", + "ergebnis/php-cs-fixer-config": "^6.20.0", + "ergebnis/phpunit-slow-test-detector": "^2.9.0", + "fakerphp/faker": "^1.23.1", + "infection/infection": "~0.26.6", + "phpunit/phpunit": "^9.6.16", + "psalm/plugin-phpunit": "~0.18.4", + "rector/rector": "~0.19.2", + "vimeo/psalm": "^5.20.0" + }, + "type": "library", + "extra": { + "composer-normalize": { + "indent-size": 2, + "indent-style": "space" + } + }, + "autoload": { + "psr-4": { + "Ergebnis\\Json\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andreas Möller", + "email": "am@localheinz.com", + "homepage": "https://localheinz.com" + } + ], + "description": "Provides a Json value object for representing a valid JSON string.", + "homepage": "https://github.com/ergebnis/json", + "keywords": [ + "json" + ], + "support": { + "issues": "https://github.com/ergebnis/json/issues", + "security": "https://github.com/ergebnis/json/blob/main/.github/SECURITY.md", + "source": "https://github.com/ergebnis/json" + }, + "time": "2024-01-29T15:09:24+00:00" + }, + { + "name": "ergebnis/json-normalizer", + "version": "4.5.0", + "source": { + "type": "git", + "url": "https://github.com/ergebnis/json-normalizer.git", + "reference": "f0ee9e70739f121b27fac8b743e4a52b23de2152" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ergebnis/json-normalizer/zipball/f0ee9e70739f121b27fac8b743e4a52b23de2152", + "reference": "f0ee9e70739f121b27fac8b743e4a52b23de2152", + "shasum": "" + }, + "require": { + "ergebnis/json": "^1.2.0", + "ergebnis/json-pointer": "^3.4.0", + "ergebnis/json-printer": "^3.5.0", + "ergebnis/json-schema-validator": "^4.2.0", + "ext-json": "*", + "justinrainbow/json-schema": "^5.2.12", + "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0" + }, + "require-dev": { + "composer/semver": "^3.4.0", + "ergebnis/data-provider": "^3.2.0", + "ergebnis/license": "^2.4.0", + "ergebnis/php-cs-fixer-config": "^6.20.0", + "ergebnis/phpunit-slow-test-detector": "^2.9.0", + "fakerphp/faker": "^1.23.1", + "infection/infection": "~0.26.6", + "phpunit/phpunit": "^9.6.16", + "psalm/plugin-phpunit": "~0.18.4", + "rector/rector": "~0.19.4", + "vimeo/psalm": "^5.20.0" + }, + "suggest": { + "composer/semver": "If you want to use ComposerJsonNormalizer or VersionConstraintNormalizer" + }, + "type": "library", + "autoload": { + "psr-4": { + "Ergebnis\\Json\\Normalizer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andreas Möller", + "email": "am@localheinz.com", + "homepage": "https://localheinz.com" + } + ], + "description": "Provides generic and vendor-specific normalizers for normalizing JSON documents.", + "homepage": "https://github.com/ergebnis/json-normalizer", + "keywords": [ + "json", + "normalizer" + ], + "support": { + "issues": "https://github.com/ergebnis/json-normalizer/issues", + "security": "https://github.com/ergebnis/json-normalizer/blob/main/.github/SECURITY.md", + "source": "https://github.com/ergebnis/json-normalizer" + }, + "time": "2024-01-30T09:10:15+00:00" + }, + { + "name": "ergebnis/json-pointer", + "version": "3.4.0", + "source": { + "type": "git", + "url": "https://github.com/ergebnis/json-pointer.git", + "reference": "b654757d873050622c2166f55ab25d04685261c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ergebnis/json-pointer/zipball/b654757d873050622c2166f55ab25d04685261c5", + "reference": "b654757d873050622c2166f55ab25d04685261c5", + "shasum": "" + }, + "require": { + "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0" + }, + "require-dev": { + "ergebnis/data-provider": "^3.2.0", + "ergebnis/license": "^2.4.0", + "ergebnis/php-cs-fixer-config": "^6.20.0", + "ergebnis/phpunit-slow-test-detector": "^2.9.0", + "fakerphp/faker": "^1.23.1", + "infection/infection": "~0.26.6", + "phpunit/phpunit": "^9.6.16", + "psalm/plugin-phpunit": "~0.18.4", + "rector/rector": "~0.19.2", + "vimeo/psalm": "^5.20.0" + }, + "type": "library", + "extra": { + "composer-normalize": { + "indent-size": 2, + "indent-style": "space" + } + }, + "autoload": { + "psr-4": { + "Ergebnis\\Json\\Pointer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andreas Möller", + "email": "am@localheinz.com", + "homepage": "https://localheinz.com" + } + ], + "description": "Provides an abstraction of a JSON pointer.", + "homepage": "https://github.com/ergebnis/json-pointer", + "keywords": [ + "RFC6901", + "json", + "pointer" + ], + "support": { + "issues": "https://github.com/ergebnis/json-pointer/issues", + "security": "https://github.com/ergebnis/json-pointer/blob/main/.github/SECURITY.md", + "source": "https://github.com/ergebnis/json-pointer" + }, + "time": "2024-01-29T16:37:15+00:00" + }, + { + "name": "ergebnis/json-printer", + "version": "3.5.0", + "source": { + "type": "git", + "url": "https://github.com/ergebnis/json-printer.git", + "reference": "549e16fe6de34b8c3aee7b421be12caa552f3ced" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ergebnis/json-printer/zipball/549e16fe6de34b8c3aee7b421be12caa552f3ced", + "reference": "549e16fe6de34b8c3aee7b421be12caa552f3ced", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-mbstring": "*", + "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0" + }, + "require-dev": { + "ergebnis/data-provider": "^3.2.0", + "ergebnis/license": "^2.4.0", + "ergebnis/php-cs-fixer-config": "^6.20.0", + "ergebnis/phpunit-slow-test-detector": "^2.9.0", + "fakerphp/faker": "^1.23.1", + "infection/infection": "~0.26.6", + "phpunit/phpunit": "^9.6.16", + "psalm/plugin-phpunit": "~0.18.4", + "rector/rector": "~0.19.2", + "vimeo/psalm": "^5.20.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Ergebnis\\Json\\Printer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andreas Möller", + "email": "am@localheinz.com", + "homepage": "https://localheinz.com" + } + ], + "description": "Provides a JSON printer, allowing for flexible indentation.", + "homepage": "https://github.com/ergebnis/json-printer", + "keywords": [ + "formatter", + "json", + "printer" + ], + "support": { + "issues": "https://github.com/ergebnis/json-printer/issues", + "security": "https://github.com/ergebnis/json-printer/blob/main/.github/SECURITY.md", + "source": "https://github.com/ergebnis/json-printer" + }, + "time": "2024-01-29T15:33:37+00:00" + }, + { + "name": "ergebnis/json-schema-validator", + "version": "4.2.0", + "source": { + "type": "git", + "url": "https://github.com/ergebnis/json-schema-validator.git", + "reference": "10ed514fdc3f9b71f8a92c567afea21a2f6fa1ef" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ergebnis/json-schema-validator/zipball/10ed514fdc3f9b71f8a92c567afea21a2f6fa1ef", + "reference": "10ed514fdc3f9b71f8a92c567afea21a2f6fa1ef", + "shasum": "" + }, + "require": { + "ergebnis/json": "^1.2.0", + "ergebnis/json-pointer": "^3.4.0", + "ext-json": "*", + "justinrainbow/json-schema": "^5.2.12", + "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0" + }, + "require-dev": { + "ergebnis/data-provider": "^3.2.0", + "ergebnis/license": "^2.4.0", + "ergebnis/php-cs-fixer-config": "^6.20.0", + "ergebnis/phpunit-slow-test-detector": "^2.9.0", + "fakerphp/faker": "^1.23.1", + "infection/infection": "~0.26.6", + "phpunit/phpunit": "^9.6.16", + "psalm/plugin-phpunit": "~0.18.4", + "rector/rector": "~0.19.2", + "vimeo/psalm": "^5.20.0" + }, + "type": "library", + "extra": { + "composer-normalize": { + "indent-size": 2, + "indent-style": "space" + } + }, + "autoload": { + "psr-4": { + "Ergebnis\\Json\\SchemaValidator\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andreas Möller", + "email": "am@localheinz.com", + "homepage": "https://localheinz.com" + } + ], + "description": "Provides a JSON schema validator, building on top of justinrainbow/json-schema.", + "homepage": "https://github.com/ergebnis/json-schema-validator", + "keywords": [ + "json", + "schema", + "validator" + ], + "support": { + "issues": "https://github.com/ergebnis/json-schema-validator/issues", + "security": "https://github.com/ergebnis/json-schema-validator/blob/main/.github/SECURITY.md", + "source": "https://github.com/ergebnis/json-schema-validator" + }, + "time": "2024-01-29T16:50:15+00:00" + }, + { + "name": "figuren-theater/code-quality", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/figuren-theater/code-quality.git", + "reference": "93fb1c34c5c0c14ccc5692969fdcbcba344e7a7c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/figuren-theater/code-quality/zipball/93fb1c34c5c0c14ccc5692969fdcbcba344e7a7c", + "reference": "93fb1c34c5c0c14ccc5692969fdcbcba344e7a7c", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "0.7.2", + "ergebnis/composer-normalize": "2.39.0", + "figuren-theater/coding-standards": "*", + "figuren-theater/phpstan": "*", + "phpstan/extension-installer": "1.3.1" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-3.0-or-later" + ], + "authors": [ + { + "name": "figuren.theater", + "email": "info@figuren.theater" + }, + { + "name": "Carsten Bach", + "email": "mail@carsten-bach.de", + "homepage": "https://carsten-bach.de", + "role": "Developer" + } + ], + "description": "Development tools to measure and test the code quality of figuren.theater, the WordPress Multisite network for puppeteers.", + "homepage": "https://websites.fuer.figuren.theater", + "keywords": [ + ".editorconfig", + "phpcs.xml", + "phpstan.neon", + "wordpress" + ], + "support": { + "email": "info@figuren.theater", + "issues": "https://github.com/figuren-theater/code-quality/issues", + "source": "https://github.com/figuren-theater/code-quality" + }, + "time": "2023-12-15T22:45:38+00:00" + }, + { + "name": "figuren-theater/coding-standards", + "version": "0.4.1", + "source": { + "type": "git", + "url": "https://github.com/figuren-theater/coding-standards.git", + "reference": "064a379d5660203f70423ebea5c0583ab15e9a32" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/figuren-theater/coding-standards/zipball/064a379d5660203f70423ebea5c0583ab15e9a32", + "reference": "064a379d5660203f70423ebea5c0583ab15e9a32", + "shasum": "" + }, + "require": { + "automattic/vipwpcs": "^3.0", + "ergebnis/composer-normalize": "^2.31", + "phpcompatibility/phpcompatibility-wp": "*", + "rarst/phpcs-cognitive-complexity": "^0.2.0" + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-3.0-or-later" + ], + "authors": [ + { + "name": "figuren.theater", + "email": "info@figuren.theater" + }, + { + "name": "Carsten Bach", + "email": "mail@carsten-bach.de", + "homepage": "https://carsten-bach.de", + "role": "Developer" + } + ], + "description": "Coding standards for PHP, JavaScript and CSS within the figuren.theater WordPress Multisite network.", + "homepage": "https://websites.fuer.figuren.theater", + "keywords": [ + "WordPressVIPMinimum", + "coding-standards", + "wordpress", + "wpcs" + ], + "support": { + "email": "info@figuren.theater", + "issues": "https://github.com/figuren-theater/coding-standards/issues", + "source": "https://github.com/figuren-theater/coding-standards" + }, + "time": "2023-12-15T22:39:27+00:00" + }, + { + "name": "figuren-theater/phpstan", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/figuren-theater/phpstan.git", + "reference": "8a6f5c51eb6afaa354611cd2290440d432808938" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/figuren-theater/phpstan/zipball/8a6f5c51eb6afaa354611cd2290440d432808938", + "reference": "8a6f5c51eb6afaa354611cd2290440d432808938", + "shasum": "" + }, + "require": { + "php-stubs/wordpress-globals": "^0.2.0", + "szepeviktor/phpstan-wordpress": "^1.3" + }, + "require-dev": { + "ergebnis/composer-normalize": "^2.31" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-3.0-or-later" + ], + "authors": [ + { + "name": "figuren.theater", + "email": "info@figuren.theater" + }, + { + "name": "Carsten Bach", + "email": "mail@carsten-bach.de", + "homepage": "https://carsten-bach.de", + "role": "Developer" + } + ], + "description": "org-wide used phpstan.neon file for the WordPress Multisite network for puppeteers figuren.theater", + "homepage": "https://figuren.theater", + "keywords": [ + "PHPStan", + "wordpress" + ], + "support": { + "email": "info@figuren.theater", + "issues": "https://github.com/figuren-theater/phpstan/issues", + "source": "https://github.com/figuren-theater/phpstan" + }, + "time": "2023-09-13T08:55:48+00:00" + }, + { + "name": "justinrainbow/json-schema", + "version": "v5.2.13", + "source": { + "type": "git", + "url": "https://github.com/justinrainbow/json-schema.git", + "reference": "fbbe7e5d79f618997bc3332a6f49246036c45793" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/fbbe7e5d79f618997bc3332a6f49246036c45793", + "reference": "fbbe7e5d79f618997bc3332a6f49246036c45793", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~2.2.20||~2.15.1", + "json-schema/json-schema-test-suite": "1.2.0", + "phpunit/phpunit": "^4.8.35" + }, + "bin": [ + "bin/validate-json" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "JsonSchema\\": "src/JsonSchema/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bruno Prieto Reis", + "email": "bruno.p.reis@gmail.com" + }, + { + "name": "Justin Rainbow", + "email": "justin.rainbow@gmail.com" + }, + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch" + }, + { + "name": "Robert Schönthal", + "email": "seroscho@googlemail.com" + } + ], + "description": "A library to validate a json schema.", + "homepage": "https://github.com/justinrainbow/json-schema", + "keywords": [ + "json", + "schema" + ], + "support": { + "issues": "https://github.com/justinrainbow/json-schema/issues", + "source": "https://github.com/justinrainbow/json-schema/tree/v5.2.13" + }, + "time": "2023-09-26T02:20:38+00:00" + }, + { + "name": "localheinz/diff", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/localheinz/diff.git", + "reference": "851bb20ea8358c86f677f5f111c4ab031b1c764c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/localheinz/diff/zipball/851bb20ea8358c86f677f5f111c4ab031b1c764c", + "reference": "851bb20ea8358c86f677f5f111c4ab031b1c764c", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^7.5 || ^8.0", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Fork of sebastian/diff for use with ergebnis/composer-normalize", + "homepage": "https://github.com/localheinz/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "source": "https://github.com/localheinz/diff/tree/main" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-07-06T04:49:32+00:00" + }, + { + "name": "php-stubs/wordpress-globals", + "version": "v0.2.0", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/wordpress-globals.git", + "reference": "748a1fb2ae8fda94844bd0545935095dbf404b32" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/wordpress-globals/zipball/748a1fb2ae8fda94844bd0545935095dbf404b32", + "reference": "748a1fb2ae8fda94844bd0545935095dbf404b32", + "shasum": "" + }, + "require-dev": { + "php": "~7.1" + }, + "suggest": { + "php-stubs/wordpress-stubs": "Up-to-date WordPress function and class declaration stubs", + "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Global variables and global constants from WordPress core.", + "homepage": "https://github.com/php-stubs/wordpress-globals", + "keywords": [ + "PHPStan", + "constants", + "globals", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/php-stubs/wordpress-globals/issues", + "source": "https://github.com/php-stubs/wordpress-globals/tree/master" + }, + "time": "2020-01-13T06:12:59+00:00" + }, + { + "name": "php-stubs/wordpress-stubs", + "version": "v6.4.1", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/wordpress-stubs.git", + "reference": "6d6063cf9464a306ca2a0529705d41312b08500b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/6d6063cf9464a306ca2a0529705d41312b08500b", + "reference": "6d6063cf9464a306ca2a0529705d41312b08500b", + "shasum": "" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "nikic/php-parser": "^4.13", + "php": "^7.4 || ~8.0.0", + "php-stubs/generator": "^0.8.3", + "phpdocumentor/reflection-docblock": "^5.3", + "phpstan/phpstan": "^1.10.12", + "phpunit/phpunit": "^9.5", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^0.8" + }, + "suggest": { + "paragonie/sodium_compat": "Pure PHP implementation of libsodium", + "symfony/polyfill-php80": "Symfony polyfill backporting some PHP 8.0+ 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/v6.4.1" + }, + "time": "2023-11-10T00:33:47+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.2", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git", + "reference": "bba5a9dfec7fcfbd679cfaf611d86b4d3759da26" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/bba5a9dfec7fcfbd679cfaf611d86b4d3759da26", + "reference": "bba5a9dfec7fcfbd679cfaf611d86b4d3759da26", + "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", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie" + }, + "time": "2022-10-25T01:46:02+00:00" + }, + { + "name": "phpcompatibility/phpcompatibility-wp", + "version": "2.1.4", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git", + "reference": "b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5", + "reference": "b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5", + "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", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibilityWP/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibilityWP" + }, + "time": "2022-10-24T09:00:36+00:00" + }, + { + "name": "phpcsstandards/phpcsextra", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHPCSExtra.git", + "reference": "11d387c6642b6e4acaf0bd9bf5203b8cca1ec489" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/11d387c6642b6e4acaf0bd9bf5203b8cca1ec489", + "reference": "11d387c6642b6e4acaf0bd9bf5203b8cca1ec489", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "phpcsstandards/phpcsutils": "^1.0.9", + "squizlabs/php_codesniffer": "^3.8.0" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", + "phpcsstandards/phpcsdevcs": "^1.1.6", + "phpcsstandards/phpcsdevtools": "^1.2.1", + "phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSExtra/graphs/contributors" + } + ], + "description": "A collection of sniffs and standards for use with PHP_CodeSniffer.", + "keywords": [ + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", + "phpcs", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/PHPCSExtra/issues", + "security": "https://github.com/PHPCSStandards/PHPCSExtra/security/policy", + "source": "https://github.com/PHPCSStandards/PHPCSExtra" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2023-12-08T16:49:07+00:00" + }, + { + "name": "phpcsstandards/phpcsutils", + "version": "1.0.9", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", + "reference": "908247bc65010c7b7541a9551e002db12e9dae70" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/908247bc65010c7b7541a9551e002db12e9dae70", + "reference": "908247bc65010c7b7541a9551e002db12e9dae70", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", + "php": ">=5.4", + "squizlabs/php_codesniffer": "^3.8.0 || 4.0.x-dev@dev" + }, + "require-dev": { + "ext-filter": "*", + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", + "phpcsstandards/phpcsdevcs": "^1.1.6", + "yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "autoload": { + "classmap": [ + "PHPCSUtils/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSUtils/graphs/contributors" + } + ], + "description": "A suite of utility functions for use with PHP_CodeSniffer", + "homepage": "https://phpcsutils.com/", + "keywords": [ + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", + "phpcs", + "phpcs3", + "standards", + "static analysis", + "tokens", + "utility" + ], + "support": { + "docs": "https://phpcsutils.com/", + "issues": "https://github.com/PHPCSStandards/PHPCSUtils/issues", + "security": "https://github.com/PHPCSStandards/PHPCSUtils/security/policy", + "source": "https://github.com/PHPCSStandards/PHPCSUtils" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2023-12-08T14:50:00+00:00" + }, + { + "name": "phpstan/extension-installer", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "f45734bfb9984c6c56c4486b71230355f066a58a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/f45734bfb9984c6c56c4486b71230355f066a58a", + "reference": "f45734bfb9984c6c56c4486b71230355f066a58a", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.0", + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.9.0" + }, + "require-dev": { + "composer/composer": "^2.0", + "php-parallel-lint/php-parallel-lint": "^1.2.0", + "phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0" + }, + "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.3.1" + }, + "time": "2023-05-24T08:59:17+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "1.10.57", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "1627b1d03446904aaa77593f370c5201d2ecc34e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/1627b1d03446904aaa77593f370c5201d2ecc34e", + "reference": "1627b1d03446904aaa77593f370c5201d2ecc34e", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2024-01-24T11:51:34+00:00" + }, + { + "name": "rarst/phpcs-cognitive-complexity", + "version": "0.2", + "source": { + "type": "git", + "url": "https://github.com/Rarst/phpcs-cognitive-complexity.git", + "reference": "b903498ba13b12cff037315a3b09ec67714b3a1d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Rarst/phpcs-cognitive-complexity/zipball/b903498ba13b12cff037315a3b09ec67714b3a1d", + "reference": "b903498ba13b12cff037315a3b09ec67714b3a1d", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "require-dev": { + "pds/skeleton": "^1.0", + "squizlabs/php_codesniffer": "^3.5" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "Installer plugin for automatic standard registration." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andrey Savchenko", + "homepage": "https://www.Rarst.net/" + } + ], + "description": "Cognitive complexity implementation for PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/Rarst/phpcs-cognitive-complexity/issues", + "source": "https://github.com/Rarst/phpcs-cognitive-complexity" + }, + "time": "2019-12-24T14:23:35+00:00" + }, + { + "name": "sirbrillig/phpcs-variable-analysis", + "version": "v2.11.17", + "source": { + "type": "git", + "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git", + "reference": "3b71162a6bf0cde2bff1752e40a1788d8273d049" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/3b71162a6bf0cde2bff1752e40a1788d8273d049", + "reference": "3b71162a6bf0cde2bff1752e40a1788d8273d049", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "squizlabs/php_codesniffer": "^3.5.6" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || ^1.0", + "phpcsstandards/phpcsdevcs": "^1.1", + "phpstan/phpstan": "^1.7", + "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.5 || ^7.0 || ^8.0 || ^9.0", + "sirbrillig/phpcs-import-detection": "^1.1", + "vimeo/psalm": "^0.2 || ^0.3 || ^1.1 || ^4.24 || ^5.0@beta" + }, + "type": "phpcodesniffer-standard", + "autoload": { + "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.", + "keywords": [ + "phpcs", + "static analysis" + ], + "support": { + "issues": "https://github.com/sirbrillig/phpcs-variable-analysis/issues", + "source": "https://github.com/sirbrillig/phpcs-variable-analysis", + "wiki": "https://github.com/sirbrillig/phpcs-variable-analysis/wiki" + }, + "time": "2023-08-05T23:46:11+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.8.1", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "14f5fff1e64118595db5408e946f3a22c75807f7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/14f5fff1e64118595db5408e946f3a22c75807f7", + "reference": "14f5fff1e64118595db5408e946f3a22c75807f7", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" + }, + "bin": [ + "bin/phpcbf", + "bin/phpcs" + ], + "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": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2024-01-11T20:47:48+00:00" + }, + { + "name": "symfony/polyfill-php73", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "21bd091060673a1177ae842c0ef8fe30893114d2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/21bd091060673a1177ae842c0ef8fe30893114d2", + "reference": "21bd091060673a1177ae842c0ef8fe30893114d2", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "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.29.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": "2024-01-29T20:11:03+00:00" + }, + { + "name": "szepeviktor/phpstan-wordpress", + "version": "v1.3.2", + "source": { + "type": "git", + "url": "https://github.com/szepeviktor/phpstan-wordpress.git", + "reference": "b8516ed6bab7ec50aae981698ce3f67f1be2e45a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/b8516ed6bab7ec50aae981698ce3f67f1be2e45a", + "reference": "b8516ed6bab7ec50aae981698ce3f67f1be2e45a", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "php-stubs/wordpress-stubs": "^4.7 || ^5.0 || ^6.0", + "phpstan/phpstan": "^1.10.30", + "symfony/polyfill-php73": "^1.12.0" + }, + "require-dev": { + "composer/composer": "^2.1.14", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.1", + "phpstan/phpstan-strict-rules": "^1.2", + "phpunit/phpunit": "^8.0 || ^9.0", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^0.8" + }, + "suggest": { + "swissspidy/phpstan-no-private": "Detect usage of internal core functions, classes and methods" + }, + "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.3.2" + }, + "time": "2023-10-16T17:23:56+00:00" + }, + { + "name": "wp-coding-standards/wpcs", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", + "reference": "b4caf9689f1a0e4a4c632679a44e638c1c67aff1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/b4caf9689f1a0e4a4c632679a44e638c1c67aff1", + "reference": "b4caf9689f1a0e4a4c632679a44e638c1c67aff1", + "shasum": "" + }, + "require": { + "ext-filter": "*", + "ext-libxml": "*", + "ext-tokenizer": "*", + "ext-xmlreader": "*", + "php": ">=5.4", + "phpcsstandards/phpcsextra": "^1.1.0", + "phpcsstandards/phpcsutils": "^1.0.8", + "squizlabs/php_codesniffer": "^3.7.2" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^1.0.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", + "phpcompatibility/php-compatibility": "^9.0", + "phpcsstandards/phpcsdevtools": "^1.2.0", + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "suggest": { + "ext-iconv": "For improved results", + "ext-mbstring": "For improved results" + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Contributors", + "homepage": "https://github.com/WordPress/WordPress-Coding-Standards/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions", + "keywords": [ + "phpcs", + "standards", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/WordPress/WordPress-Coding-Standards/issues", + "source": "https://github.com/WordPress/WordPress-Coding-Standards", + "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" + }, + "funding": [ + { + "url": "https://opencollective.com/thewpcc/contribute/wp-php-63406", + "type": "custom" + } + ], + "time": "2023-09-14T07:06:09+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=7.1" + }, + "platform-dev": [], + "plugin-api-version": "2.3.0" +} From c9d75faed20fca6b31dc843524630904fa978cc8 Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Fri, 9 Feb 2024 07:23:09 +0100 Subject: [PATCH 07/17] Fix (some, not all) phpstan issues --- inc/namespace.php | 18 +- inc/sharing-image/admin-ui.php | 59 ++-- inc/sharing-image/frontend.php | 86 +++--- inc/sharing-image/generation.php | 314 +++++++++++-------- inc/sharing-image/namespace.php | 64 ++-- inc/sharing-image/options.php | 33 +- inc/wordpress-seo/admin-ui.php | 54 ++-- inc/wordpress-seo/namespace.php | 40 +-- inc/wordpress-seo/open-graph.php | 27 +- inc/wordpress-seo/options.php | 503 ++++++++++++++++--------------- phpstan.neon | 3 + plugin.php | 2 +- 12 files changed, 661 insertions(+), 542 deletions(-) diff --git a/inc/namespace.php b/inc/namespace.php index f2292c1..4f10779 100644 --- a/inc/namespace.php +++ b/inc/namespace.php @@ -2,25 +2,27 @@ /** * Figuren_Theater SEO. * - * @package figuren-theater/seo + * @package figuren-theater/ft-seo */ namespace Figuren_Theater\SEO; use Altis; -use function Altis\register_module; +// use function Altis\register_module; /** * Register module. + * + * @return void */ -function register() { +function register(): void { $default_settings = [ 'enabled' => true, // needs to be set 'sharing-image' => false, ]; - $options = [ + $options = [ 'defaults' => $default_settings, ]; @@ -35,13 +37,15 @@ function register() { /** * Bootstrap module, when enabled. + * + * @return void */ -function bootstrap() { +function bootstrap(): void { // Plugins - Sharing_Image\bootstrap(); + // Sharing_Image\bootstrap(); !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Yoast_SEO\bootstrap(); // Best practices - //...\bootstrap(); + // ...\bootstrap(); } diff --git a/inc/sharing-image/admin-ui.php b/inc/sharing-image/admin-ui.php index d6b845c..7ba47af 100644 --- a/inc/sharing-image/admin-ui.php +++ b/inc/sharing-image/admin-ui.php @@ -2,7 +2,7 @@ /** * Figuren_Theater SEO Sharing_Image\Admin_UI. * - * @package figuren-theater/seo/sharing_image\admin_ui + * @package figuren-theater/ft-seo */ namespace Figuren_Theater\SEO\Sharing_Image\Admin_UI; @@ -15,13 +15,14 @@ use function add_filter; use function current_user_can; use function is_super_admin; -use function remove_menu_page; use function remove_submenu_page; /** * Bootstrap module, when enabled. + * + * @return void */ -function bootstrap() { +function bootstrap(): void { add_action( 'admin_menu', __NAMESPACE__ . '\\remove_menu', 11 ); @@ -51,18 +52,18 @@ function bootstrap() { // disable "Premium" tab on settings page add_filter( 'sharing_image_settings_tabs', __NAMESPACE__ . '\\sharing_image_settings_tabs' ); - - } - - - +/** + * Remove the plugins admin-menu. + * + * @return void + */ function remove_menu() : void { - // - if ( is_super_admin() && true === constant( 'WP_DEBUG' ) ) + if ( is_super_admin() && true === constant( 'WP_DEBUG' ) ) { return; + } remove_submenu_page( 'options-general.php', 'sharing-image' ); } @@ -70,31 +71,33 @@ function remove_menu() : void { /** - * [sharing_image_settings_tabs description] - * @param array $tabs List of settings tabs. + * This filter is used to update settings tabs. You can remove existing or add a new one. * * @see https://wpset.org/sharing-image/hooks/#sharing_image_settings_tabs * - * @package project_name - * @version version - * @author Carsten Bach + * @param string[] $tabs List of settings tabs. * - * @param array $tabs [description] - * @return [type] [description] + * @return string[] */ -function sharing_image_settings_tabs( array $tabs ) : array { - unset( $tabs['premium'] ); - return $tabs; +function sharing_image_settings_tabs( array $tabs ): array { + unset( $tabs['premium'] ); + return $tabs; } /** - * @param bool $hide_metabox Set true to hide metabox. + * Hides the 'Sharing Image' metabox, + * if the current user can not 'manage_site_options' (NEEDED_CAP). + * * @see https://wpset.org/sharing-image/hooks/#sharing_image_hide_metabox + * + * @param bool $hide_metabox Set true to hide metabox. + * + * @return bool */ -function sharing_image_hide_metabox( bool $hide_metabox ) : bool { - return current_user_can( Sharing_Image\NEEDED_CAP ); +function sharing_image_hide_metabox( bool $hide_metabox ): bool { + return current_user_can( Sharing_Image\NEEDED_CAP ); } @@ -108,10 +111,10 @@ public function mf_update_post_meta_sharing_image( $meta, $post_id ) { $featured_image = \get_post_thumbnail_id($post_id); # error_log(var_export([ - # \current_filter(), - # 'mf_update_post_meta_sharing_image()', - # $meta, $post_id - # ],true)); + # \current_filter(), + # 'mf_update_post_meta_sharing_image()', + # $meta, $post_id + # ],true)); if($featured_image) { @@ -148,6 +151,6 @@ public static function sharing_image_get_fontpath( $path, $layer ) { ],true)); return $path; - // return WP_PLUGIN_DIR . '/my-plugin/font.ttf'; + // return WP_PLUGIN_DIR . '/my-plugin/font.ttf'; } */ diff --git a/inc/sharing-image/frontend.php b/inc/sharing-image/frontend.php index c090beb..a9892c7 100644 --- a/inc/sharing-image/frontend.php +++ b/inc/sharing-image/frontend.php @@ -2,45 +2,46 @@ /** * Figuren_Theater SEO Sharing_Image\Frontend. * - * @package figuren-theater/seo/sharing_image\frontend + * @package figuren-theater/ft-seo */ namespace Figuren_Theater\SEO\Sharing_Image\Frontend; use Figuren_Theater\SEO\Sharing_Image\Options; +use Yoast\WP\SEO\Presentations\Indexable_Presentation; use function sharing_image_poster; -use function add_action; +use function add_filter; use function esc_url; use function get_option; /** * Bootstrap module, when enabled. + * + * @return void */ -function bootstrap() { +function bootstrap(): void { - // remove , which are done by yoast - // 'sharing_image_hide_meta' => 'sharing_image_hide_metatags', + /** + * Remove , which are done by yoast. + * + * @see https://wpset.org/sharing-image/hooks/#sharing_image_hide_meta + */ add_filter( 'sharing_image_hide_meta', '__return_true' ); - // Because 'wpseo_opengraph_image_size' FILTER IS BUGGY - // - // we can not use the already working 'wpseo_opengraph_image' - // and 'wpseo_twitter_image' filters - // 'wpseo_opengraph_image' => ['add_image_to_yoast_opengraph', 10, 2 ], - // 'wpseo_twitter_image' => ['add_image_to_yoast_opengraph', 10, 2 ], - // // 'wpseo_opengraph_image_size' => 'add_image_size_to_yoast_opengraph', // this one is buggy - // - // "Wrong image width and height when using "wpseo_opengraph_image" filter" - // Issue #15052 - // https://github.com/Yoast/wordpress-seo/issues/15052 - // working solution from the coments - // https://github.com/Yoast/wordpress-seo/issues/15052#issuecomment-695093003 + /** + * Because 'wpseo_opengraph_image_size' FILTER IS BUGGY + * + * we can not use the already working + * - 'wpseo_opengraph_image' and + * - 'wpseo_twitter_image' filters. + * + * @see "Wrong image width and height when using "wpseo_opengraph_image" filter" https://github.com/Yoast/wordpress-seo/issues/15052 + * @see working solution from the coments https://github.com/Yoast/wordpress-seo/issues/15052#issuecomment-695093003 + */ add_filter( 'wpseo_frontend_presentation', __NAMESPACE__ . '\\add_image_to_yoast_opengraph', 30 ); - - } @@ -49,47 +50,38 @@ function bootstrap() { * * @see https://github.com/Yoast/wordpress-seo/blob/76986597983c63c7c66fed3e9d07174f62cb2657/src/integrations/front-end-integration.php#L314 * - * @yoastapi Indexable_Presention The indexable presentation. - * - * - * @package project_name - * @version version - * @author Carsten Bach - * + * @param Indexable_Presentation $presentation The indexable presentation. + * + * @return Indexable_Presentation */ -function add_image_to_yoast_opengraph( $presentation ) { +function add_image_to_yoast_opengraph( Indexable_Presentation $presentation ) :Indexable_Presentation { $generated_image_url = esc_url( sharing_image_poster() ); - if( $generated_image_url ) { + if ( $generated_image_url ) { $si_options = get_option( Options\OPTION_NAME ); $si_config = get_option( 'sharing_image_config' ); + + if ( + ! \is_array( $si_options ) + || ! \is_array( $si_options[0] ) + || ! \is_array( $si_config ) + || ! isset( $si_options[0]['width'] ) + || ! isset( $si_options[0]['height'] ) + || ! isset( $si_config['format'] ) + ) { + return $presentation; + } $presentation->open_graph_images = [ [ 'url' => $generated_image_url, 'width' => $si_options[0]['width'], 'height' => $si_options[0]['height'], - 'type' => 'image/'. $si_config['format'] - ] + 'type' => 'image/' . $si_config['format'], + ], ]; } return $presentation; } -/** - * [sharing_image_hide_metatags description] - * @param bool $hide_header Set true to hide poster meta. - * - * @see https://wpset.org/sharing-image/hooks/#sharing_image_hide_meta - * - * @package project_name - * @version version - * @author Carsten Bach - * - * @param bool $hide_meta [description] - * @return [type] [description] -function sharing_image_hide_metatags( bool $hide_meta ) : bool { - return true; -} - */ diff --git a/inc/sharing-image/generation.php b/inc/sharing-image/generation.php index 1438b90..d62c0cc 100644 --- a/inc/sharing-image/generation.php +++ b/inc/sharing-image/generation.php @@ -2,7 +2,7 @@ /** * Figuren_Theater SEO Sharing_Image\Generation. * - * @package figuren-theater/seo/sharing_image\generation + * @package figuren-theater/ft-seo */ namespace Figuren_Theater\SEO\Sharing_Image\Generation; @@ -42,8 +42,10 @@ /** * Bootstrap module, when enabled. + * + * @return void */ -function bootstrap() { +function bootstrap() :void { // add_action( 'admin_init', __NAMESPACE__ . '\\load', 0 ); add_action( 'init', __NAMESPACE__ . '\\load', 0 ); // Figuren_Theater\Media\Auto_Featured_Image runs on 10 // add_action( 'admin_init', __NAMESPACE__ . '\\load', 0 ); // Figuren_Theater\Media\Auto_Featured_Image runs on 10 @@ -54,7 +56,12 @@ function bootstrap() { } -function load() { +/** + * Load Autogeneration logic hooks at relevant spots of the save_post workflow. + * + * @return void + */ +function load() : void { //////////////////////////////////// // BACKEND | Autogeneration logic // @@ -74,7 +81,7 @@ function load() { // which is not happening reliable on autogeneration // // BUGGY - add_filter( 'sharing_image_prepare_template', __NAMESPACE__ . '\\sharing_image_prepare_template', 10, 3 ); + add_filter( 'sharing_image_prepare_template', __NAMESPACE__ . '\\sharing_image_prepare_template', 10, 2 ); add_filter( 'sharing_image_autogenerated_poster', __NAMESPACE__ . '\\delete_previous_image', 10, 2 ); @@ -112,71 +119,38 @@ function load() { /** * The only way to get into that process * and get the ID of the current edited post + * + * Normally the 'sharing_image_disable_autogeneration' filter is used to disable posters autogeneration process based on Post ID. + * It could also be used to skip autogeneration for some post types. + * + * @see https://wpset.org/sharing-image/hooks/#sharing_image_disable_autogeneration * - * @package project_name - * @version version - * @author Carsten Bach - * - * @param bool $disable_autogeneration [description] - * @param [type] $post_id [description] - * @return [type] [description] + * @param bool $disable_autogeneration Set true to disable autogeneration. + * @param int $post_id Post ID. + * + * @return bool */ -function persist_current_post( bool $disable_autogeneration, $post_id) : bool { +function persist_current_post( bool $disable_autogeneration, int $post_id ) : bool { if ( wp_installing() ) return true; - // - // if ( wp_is_post_revision( $post_id ) ) { - // $this->current_post = get_post_parent( $post_id ); - // __current_post( get_post_parent( $post_id ) ); - // currentPost::init()->get_id( get_post_parent( $post_id ) ); - // THIS COULD ALÖSO BE - // + // Make sure meta is got for the post, not for its revision. if ( wp_is_post_revision( $post_id ) ) { - $post_id = get_post_parent( $post_id )->ID; // NEW - - // - // TRY OUT - // disbaling this for all revisiosn - // return true;# - -error_log(var_export([ - __FUNCTION__ . '//wp_is_post_revision()', - // currentPost::init()->get_id(), - $post_id -],true)); - - } else { - // persist post_id - // $this->current_post = $post_id; - // __current_post( $post_id ); - // currentPost::init()->get_id( $post_id ); -error_log(var_export([ - __FUNCTION__, - // currentPost::init()->get_id(), - $post_id -],true)); - + $post_parent = get_post_parent( $post_id ); + if (null !== $post_parent) { + $post_id = $post_parent->ID; + } } - // THIS COULD ALÖSO BE, v2 - // - // Make sure meta is got for the post, not for a revision. - #$the_post = wp_is_post_revision( $post_id ); - #if ( $the_post ) { - # $post_id = $the_post; - #} - - + // Support Typesafety. + $post_pt = get_post_type( $post_id ); + if ( false === $post_pt ) { + return $disable_autogeneration; + } // - if ( ! post_type_supports( - // get_post_type( $this->current_post ), - // get_post_type( __current_post() ), - get_post_type( $post_id ), - Sharing_Image\POST_TYPE_SUPPORT ) - ) { + if ( ! post_type_supports( $post_pt, Sharing_Image\POST_TYPE_SUPPORT ) ) { return true; } @@ -185,27 +159,66 @@ function persist_current_post( bool $disable_autogeneration, $post_id) : bool { return $disable_autogeneration; } -function pre_option_sharing_image_templates( $option ) : array|bool { - -global $post; - -if (null === $post) { +function try_to_get_post() : WP_Post|false { + $post = \get_post(); + if ( $post instanceof WP_Post ) { + return $post; + } + if ( ! isset($_SERVER['REQUEST_URI'] ) || ! \is_string( $_SERVER['REQUEST_URI'] ) ) { + return false; + } - $_request_path = parse_url( $_SERVER['REQUEST_URI'] )['path']; - $_is_json_route = ( 0 === strpos($_request_path, '/wp-json/wp/v2/posts/') ); -} -if (null === $post && $_is_json_route ) { + $url_parts = parse_url( $_SERVER['REQUEST_URI'] ); + if ( ! isset( $url_parts['path'] ) ) { + return false; + } + + $is_json_route = ( 0 === strpos($url_parts['path'], '/wp-json/wp/v2/posts/') ); + if (false === $is_json_route ) { + return false; + } + $post_id = (int) str_replace( '/wp-json/wp/v2/posts/', '', - \untrailingslashit( $_request_path ) + \untrailingslashit( $url_parts['path'] ) ); $post = \get_post( $post_id ); + if ( $post instanceof WP_Post ) { + return $post; + } + + return false; } +/** + * Filters the value of the 'sharing_image_templates' option before it is retrieved. + * + * This allows us to add all automated layers on the fly, when a new image is created and this option is used by WordPress. + * + * @param array|bool $option + * + * @return array|bool + */ +function pre_option_sharing_image_templates( $option ) : array|bool { + + // when this original option is set + // during SiteSetup or within our weekly cron job + // this filter should return false + if ( ! is_array( $option ) || ! isset( $option[0] ) || ! is_array( $option[0] ) ) { + return $option; + } + + + $post = try_to_get_post(); + if (false === $post ) { + return false; + } + + // global $wp, $wp_query; @@ -227,14 +240,7 @@ function pre_option_sharing_image_templates( $option ) : array|bool { - // when this original option is set - // during SiteSetup or within our weekly cron job - // this filter should return false - if ( ! is_array( $option ) ) - return $option; - - // $template = $this->options[ $this->option_name ][0]; $template = $option[0]; // @@ -332,27 +338,37 @@ function pre_option_sharing_image_templates( $option ) : array|bool { return $option; } -function sharing_image_prepare_template($template, $fieldset, $index) { - // $thumbnail_id = \get_post_thumbnail_id( $this->current_post ); - error_log( var_export([ - __FUNCTION__, - \wp_debug_backtrace_summary(), - \get_post(), - ],true) ); +/** + * Prepare template before creating poster with this filter. + * Used to update fieldset texts and background image. + * + * @see https://wpset.org/sharing-image/hooks/#sharing_image_prepare_template + * + * @param array $template List of template data. + * @param array $fieldset Fieldset data from picker. + * + * @return array + */ +function sharing_image_prepare_template( array $template, array $fieldset ) : array { + + // error_log( var_export([ + // __FUNCTION__, + // \wp_debug_backtrace_summary(), + // \get_post(), + // ],true) ); // 0. - if ( isset($template['image']) && \esc_url( $template['image'] )) + if ( isset( $template['image'] ) && \is_string( $template['image'] ) && \esc_url( $template['image'] )) return $template; // 1.'generate_template()' @ plugins\sharing-image\classes\class-generator.php - // $thumbnail_id = \get_post_thumbnail_id( $this->current_post ); $thumbnail_id = \get_post_thumbnail_id(); if ( ! empty( $thumbnail_id ) ) { $fieldset['attachment'] = $thumbnail_id; } // 2.'prepare_template()' @ plugins\sharing-image\classes\class-generator.php - if ( ! empty( $fieldset['attachment'] ) ) { + if ( ! empty( $fieldset['attachment'] ) && \is_int( $fieldset['attachment'] ) ) { $template['image'] = \get_attached_file( $fieldset['attachment'] ); } @@ -365,6 +381,8 @@ function sharing_image_prepare_template($template, $fieldset, $index) { * * The 'sharing_image_autogenerated_poster' filter normally * "Filters autogenerated poster data." + * + * @see https://wpset.org/sharing-image/hooks/#sharing_image_autogenerated_poster * * but we can use it to check, * if we have a new image @@ -372,24 +390,29 @@ function sharing_image_prepare_template($template, $fieldset, $index) { * * @since Sharing_Image 2.0.11 * - * @param array|false $poster Poster image, width and height data or false if undefined. - * @param integer $post_id Post ID. + * @param array|false $poster Poster image, width and height data or false if undefined. + * @param int $post_id Post ID. + * + * @return array|false */ -function delete_previous_image( $poster, $post_id ) : array|false { +function delete_previous_image( array|false $poster, int $post_id ) : array|false { // return early // if we have no new image - if ( false === $poster ) + if ( false === $poster || ! isset( $poster['poster'] ) || ! \is_string( $poster['poster'] ) || ! esc_url( $poster['poster'] ) ) { return $poster; + } + error_log(var_export([ __FUNCTION__, # currentPost::init()->get_id(), $post_id ],true)); + + // compress image // this makes 25kb > 15kb and 93kb > 49kb $_path = __get_path_from_url( $poster['poster'] ); - // $file_put_contents = ft_proto__image_replace( $_path ); - $file_put_contents = Image_Optimization\replace( $_path ); + Image_Optimization\replace( $_path ); // return early // if it is a revision @@ -405,16 +428,14 @@ function delete_previous_image( $poster, $post_id ) : array|false { // which happens directly after this filter // @plugins\sharing-image\classes\class-widget.php - // CLONED FROM: // 'update_post_meta()' - // Make sure meta is got for the post, not for a revision. - #$the_post = wp_is_post_revision( $post_id ); - #if ( $the_post ) { - # $post_id = $the_post; - #} + // Make sure meta is got for the post, not for its revision. if ( wp_is_post_revision( $post_id ) ) { - $post_id = get_post_parent( $post_id )->ID; // NEW + $post_parent = get_post_parent( $post_id ); + if (null !== $post_parent) { + $post_id = $post_parent->ID; + } } - // CLONED FROM: // 'update_post_meta()' + error_log(var_export([ __FUNCTION__, #currentPost::init()->get_id(), @@ -433,7 +454,7 @@ function delete_previous_image( $poster, $post_id ) : array|false { // return // if there was no image, yet - if ( ! isset( $old_poster['poster'] ) || ! esc_url( $old_poster['poster'] ) ) + if ( ! is_array( $old_poster ) || ! isset( $old_poster['poster'] ) || ! \is_string( $old_poster['poster'] ) || ! esc_url( $old_poster['poster'] ) ) return $poster; // here, we know @@ -550,14 +571,26 @@ function trigger_autogeneration( $meta_id, $object_id, $meta_key, $_meta_value ) // Generate new poster data using post data. // ( new Sharing_Image\Meta() )->get_poster( $object_id ); $SIW = new Sharing_Image_Plugin\Widget(); - $source = ( $SIW )->autogenerate_poster( $object_id ); + // $source = ( $SIW )->autogenerate_poster( $object_id ); // ?? not existing anymore ?? ... + $source = ( $SIW )->generate_poster( ); } +/** + * Delete auto-generated 'Sharing Image's + * + * @param int $post_id Post-ID of the currently managed post. + * @param WP_Post $post Full WP_Post object. + * + * @return void + */ +function delete_generated_image( int $post_id, WP_Post $post ) : void { -function delete_generated_image( int $post_id, WP_Post $post ) { - if ( ! post_type_supports( $post->post_type, Sharing_Image\POST_TYPE_SUPPORT ) ) + if ( ! post_type_supports( $post->post_type, Sharing_Image\POST_TYPE_SUPPORT ) ) { return; -error_log(var_export([ + } + + + error_log(var_export([ __FUNCTION__, // currentPost::init()->get_id(), $post_id @@ -569,9 +602,9 @@ function delete_generated_image( int $post_id, WP_Post $post ) { // $_sharing_image = \sharing_image_poster( $post_id ); // - if ( ! isset( $_sharing_image['poster'] ) || ! esc_url( $_sharing_image['poster'] ) ) - // if ( ! \esc_url( $_sharing_image ) ) + if ( ! \is_array( $_sharing_image ) || ! isset( $_sharing_image['poster'] ) || ! \is_string( $_sharing_image['poster'] ) || ! esc_url( $_sharing_image['poster'] ) ) { return; + } $_sharing_image_path = __get_path_from_url( $_sharing_image['poster'] ); @@ -608,25 +641,38 @@ function __prepare_text_layer( $layer_name = 'title', $new_text = '' ) { } */ - +/** + * Add a new 'Logo' Layer to the 'Sharing Image' template. + * + * @param array>> $template + * + * @return array>> + */ function __get_site_logo( array $template ) : array { - // which index has this layer - // in the array of saved layers for this template - $layer_index = LAYER[ 'logo' ]; + // Which index has this layer in the array of saved layers for this template? + $layer_index = (int) LAYER[ 'logo' ]; - // get site-logo ID + // Get site-logo ID. $logo = get_option( 'site_icon' ); - if (empty($logo)) { - // the plugin itself checks if 'attachment' isset() + if ( empty( $logo ) || ! \is_string( $logo ) ) { + // The plugin itself checks if 'attachment' isset(). unset( $template['layers'][$layer_index]['attachment'] ); - } else { - $template['layers'][$layer_index]['attachment'] = $logo; + return $template; } - + + $template['layers'][$layer_index]['attachment'] = $logo; + return $template; } +/** + * Add color-definitions to existing layers of the 'Sharing Image' template to match the current theme. + * + * @param array>|string> $template + * + * @return array>|string> + */ function __get_theme_color( array $template ) : array { // get colors from gutenberg // from mu-plugins\ft_FEATURES__customizer-powered-login.php @@ -643,9 +689,17 @@ function __get_theme_color( array $template ) : array { return $template; } +/** + * Set the background-image for the 'Sharing Image' template to match the current posts featured-image. + * + * @param array $template + * @param WP_Post|null $post + * + * @return array + */ function __get_featured_image( array $template, WP_Post|null $post ) : array { // 0. - if ( isset($template['image']) && esc_url( $template['image'] )) + if ( isset( $template['image'] ) && \is_string( $template['image'] ) && esc_url( $template['image'] )) return $template; // 1.'generate_template()' @ plugins\sharing-image\classes\class-generator.php @@ -659,15 +713,22 @@ function __get_featured_image( array $template, WP_Post|null $post ) : array { return $template; } +/** + * Set the URL text of the 'Sharing Image' template + * to the shortlink of the given post or the site_url as a fallback. + * + * @param array>> $template + * @param WP_Post|null $post + * + * @return array>> + */ function __get_shortlink( array $template, WP_Post|null $post ) : array { // prepare url $url = null; // get url of current post or site - if ( empty( $url ) ) - // $url = wp_get_shortlink( __current_post() ); - // $url = wp_get_shortlink( currentPost::init()->get_id() ); - $url = wp_get_shortlink( $post ); + if ( null !== $post ) + $url = wp_get_shortlink( $post->ID ); // fallback if ( empty( $url ) ) @@ -680,7 +741,7 @@ function __get_shortlink( array $template, WP_Post|null $post ) : array { if ( esc_url( $url ) ) { // remove protocoll - $url = str_replace('https://', '', $url); + $url = str_replace('https://', '', esc_url( $url ) ); // set data $template['layers'][ LAYER['url'] ]['sample'] = $url; @@ -691,6 +752,13 @@ function __get_shortlink( array $template, WP_Post|null $post ) : array { return $template; } +/** + * Extract an image path from its URL. + * + * @param string $url + * + * @return string + */ function __get_path_from_url( string $url='' ) : string { // $wp_upload_dir = wp_get_upload_dir(); @@ -722,7 +790,7 @@ function __current_post( int $post_id=0 ) : int { /** * Ugly helper to persist the post_ID - * during one request, but one different + * during one request, but on different * action hooks */ class currentPost { diff --git a/inc/sharing-image/namespace.php b/inc/sharing-image/namespace.php index ba28514..d292f98 100644 --- a/inc/sharing-image/namespace.php +++ b/inc/sharing-image/namespace.php @@ -2,7 +2,7 @@ /** * Figuren_Theater SEO Sharing_Image. * - * @package figuren-theater/seo/sharing_image + * @package figuren-theater/ft-seo */ namespace Figuren_Theater\SEO\Sharing_Image; @@ -21,65 +21,73 @@ const BASENAME = 'sharing-image/sharing-image.php'; -const PLUGINPATH = FT_VENDOR_DIR . '/wpackagist-plugin/' . BASENAME; +const PLUGINPATH = '/wpackagist-plugin/' . BASENAME; const POST_TYPE_SUPPORT = 'sharing-image'; const NEEDED_CAP = 'manage_site_options'; /** * Bootstrap module, when enabled. + * + * @return void */ -function bootstrap() { +function bootstrap(): void { Options\bootstrap(); add_action( 'plugins_loaded', __NAMESPACE__ . '\\load_plugin', 9 ); } -function load_plugin() { +/** + * Conditionally load the plugin itself and its modifications. + * + * @return void + */ +function load_plugin(): void { // Do only load in "normal" admin view // and public views. // Not for: // - network-admin views // - user-admin views - if ( is_network_admin() || is_user_admin() ) + if ( is_network_admin() || is_user_admin() ) { return; + } add_post_type_support( 'post', POST_TYPE_SUPPORT ); add_post_type_support( 'page', POST_TYPE_SUPPORT ); - array_walk( - \get_post_types([ - '_builtin' => false, - 'public' => true, - 'publicly_queryable' => true, - ]), - function ($post_type_name) { - add_post_type_support( $post_type_name, POST_TYPE_SUPPORT ); - } - ); - - require_once PLUGINPATH; - - ////////////// + \array_map( + function ( string $post_type ) : void { + add_post_type_support( $post_type, POST_TYPE_SUPPORT ); + }, + \get_post_types( + [ + '_builtin' => false, + 'public' => true, + 'publicly_queryable' => true, + ] + ) + ); + + require_once FT_VENDOR_DIR . PLUGINPATH; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingCustomConstant + + // // FRONTEND // - ////////////// + // Frontend\bootstrap(); -# if ( ! is_admin() ) -# return; + // if ( ! is_admin() ) + // return; - ///////////// + // // BACKEND // - ///////////// + // Admin_UI\bootstrap(); - ////////////////////////////////////////////////////////////////// + // // BACKEND | Autogeneration logic // // triggered on 'wp_insert_post' and/or on 'updated_post_meta' // - ////////////////////////////////////////////////////////////////// + // Generation\bootstrap(); - } - diff --git a/inc/sharing-image/options.php b/inc/sharing-image/options.php index f03fdff..723271c 100644 --- a/inc/sharing-image/options.php +++ b/inc/sharing-image/options.php @@ -2,7 +2,7 @@ /** * Figuren_Theater SEO Sharing_Image\Options. * - * @package figuren-theater/seo/sharing_image\options + * @package figuren-theater/ft-seo */ namespace Figuren_Theater\SEO\Sharing_Image\Options; @@ -24,36 +24,43 @@ /** * Bootstrap module, when enabled. + * + * @return void */ -function bootstrap() { +function bootstrap(): void { add_action( 'Figuren_Theater\loaded', __NAMESPACE__ . '\\filter_options', 11 ); } -function filter_options() { +/** + * Handle options + * + * @return void + */ +function filter_options() :void { $_options = [ - 'sharing_image_license' => array ( + 'sharing_image_license' => array( 'premium' => true, 'develop' => WP_DEBUG, ), - 'sharing_image_config' => array ( + 'sharing_image_config' => array( 'format' => 'jpg', 'quality' => 95, 'uploads' => 'default', 'autogenerate' => 0, // not a true/false switch, but the index of the templates-array, with the template for autogeneration ), - OPTION_NAME => array ( - 0 => array ( + OPTION_NAME => array( + 0 => array( 'preview' => '', 'title' => 'standard', 'fill' => '#000000', 'background' => 'dynamic', 'width' => 1200, 'height' => 630, - 'layers' => array ( - 0 => array ( + 'layers' => array( + 0 => array( 'type' => 'text', 'dynamic' => 'dynamic', 'title' => 'Text', @@ -71,7 +78,7 @@ function filter_options() { 'width' => 1000, // 'height' => '', ), - 1 => array ( + 1 => array( 'type' => 'image', // 'attachment' => 45, // do not set this at all, to prevent fatal errors 'x' => 25, @@ -79,7 +86,7 @@ function filter_options() { 'width' => 50, 'height' => 50, ), - 2 => array ( + 2 => array( 'type' => 'text', // 'dynamic' => 'dynamic', 'dynamic' => 0, @@ -98,7 +105,7 @@ function filter_options() { 'width' => 1175, // 'height' => '', ), - 3 => array ( + 3 => array( 'type' => 'rectangle', 'color' => '#ff0000', 'opacity' => 35, @@ -111,7 +118,7 @@ function filter_options() { ), ), ), - ) + ), ]; // gets added to the 'OptionsCollection' diff --git a/inc/wordpress-seo/admin-ui.php b/inc/wordpress-seo/admin-ui.php index 26bf286..4de4bc0 100644 --- a/inc/wordpress-seo/admin-ui.php +++ b/inc/wordpress-seo/admin-ui.php @@ -2,7 +2,7 @@ /** * Figuren_Theater SEO Yoast_SEO\Admin_UI. * - * @package figuren-theater/seo/yoast_seo\admin_ui + * @package figuren-theater/ft-seo */ namespace Figuren_Theater\SEO\Yoast_SEO\Admin_UI; @@ -18,18 +18,20 @@ /** * Bootstrap module, when enabled. + * + * @return void */ -function bootstrap() { - add_action( 'admin_init', __NAMESPACE__ . '\\remove_roles', 11 ); +function bootstrap(): void { + add_action( 'admin_init', __NAMESPACE__ . '\\remove_roles', 11 ); - add_action( 'network_admin_menu', __NAMESPACE__ . '\\remove_menus', 12 ); + add_action( 'network_admin_menu', __NAMESPACE__ . '\\remove_menus', 12 ); add_action( 'admin_menu', __NAMESPACE__ . '\\remove_menus', 12 ); // add_action( 'wp_dashboard_setup', __NAMESPACE__ . '\\remove_menu__courses' ); // Remove Yoast SEO dashboard widget. add_action( 'wp_dashboard_setup', __NAMESPACE__ . '\\remove_dashboard_widgets', 0 ); - // add_action( 'admin_init', __NAMESPACE__ . '\\remove_dashboard_widgets', 0 ); + // Remove Ads, Merch & other bloat. add_action( 'admin_head', __NAMESPACE__ . '\\remove_bloat' ); // Hide some Yoast Editor panels (ort parts of it) that are only ads. @@ -51,7 +53,7 @@ function bootstrap() { * @author Yoast Team * Last Tested: Oct 25 2017 using Yoast SEO 5.7.1 on WordPress 4.8.2 */ -function remove_roles() : void { +function remove_roles(): void { // Remove Yoast `SEO Manager` role if ( get_role( 'wpseo_manager' ) ) { @@ -64,6 +66,11 @@ function remove_roles() : void { } } +/** + * Remove the plugins admin-menu. + * + * @return void + */ function remove_menus() : void { remove_submenu_page( 'wpseo_dashboard', 'wpseo_workouts' ); @@ -86,7 +93,7 @@ function remove_menus() : void { * @see https://plugins.trac.wordpress.org/browser/smntcs-utilities/trunk/smntcs-utilities.php#L63 * @return void */ -function remove_menu__courses() : void { +function remove_menu__courses(): void { remove_submenu_page( 'wpseo_dashboard', 'wpseo_courses' ); } @@ -101,12 +108,15 @@ function remove_dashboard_widgets() { remove_meta_box( 'wpseo-dashboard-overview', 'dashboard', 'normal' ); remove_meta_box( 'wpseo-dashboard-overview', 'dashboard', 'side' ); - add_action( 'admin_enqueue_scripts', function() { - // This script & style are enqueued by Yoast. - // \wp_dequeue_script( 'yoast-seo-dashboard-widget' ); - \wp_dequeue_style( 'yoast-seo-wp-dashboard' ); - - }, 11 ); + add_action( + 'admin_enqueue_scripts', + function () { + // This script & style are enqueued by Yoast. + // \wp_dequeue_script( 'yoast-seo-dashboard-widget' ); + \wp_dequeue_style( 'yoast-seo-wp-dashboard' ); + }, + 11 + ); } /** @@ -120,7 +130,7 @@ function remove_dashboard_widgets() { * @since 1.0.0 * @return void */ -function remove_bloat() { +function remove_bloat() : void { ?> "; // phpcs:ignore HM.Security.EscapeOutput.OutputNotEscaped + $escaped_css = strtr( + wp_filter_nohtml_kses( $css ), + [ + '>' => '>', + "\'" => "'", + '\"' => '"', + ] + ); + \printf( + '', + $escaped_css // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + ); } diff --git a/inc/wordpress-seo/namespace.php b/inc/wordpress-seo/namespace.php index 5fc9068..257edcd 100644 --- a/inc/wordpress-seo/namespace.php +++ b/inc/wordpress-seo/namespace.php @@ -7,23 +7,16 @@ namespace Figuren_Theater\SEO\Yoast_SEO; -// use Figuren_Theater\SEO\Yoast_SEO\Open_Graph; -use Figuren_Theater\SEO\Yoast_SEO\Options; - use FT_VENDOR_DIR; - +use WPSEO_Menu; +use WPSEO_Network_Admin_Menu; +use Yoast_Network_Admin; use function add_action; use function add_filter; -// use WP_CLI; -// use WP_Query; use function get_plugins; - use function get_plugin_data; use function is_admin; use function wp_cache_set; -use WPSEO_Menu; -use WPSEO_Network_Admin_Menu; -use Yoast_Network_Admin; const BASENAME = 'wordpress-seo/wp-seo.php'; const PLUGINPATH = '/wpackagist-plugin/' . BASENAME; @@ -55,22 +48,18 @@ function load_plugin(): void { Open_Graph\bootstrap(); - // Intend to save indexables. - // @see https://github.com/Yoast/wordpress-seo/blob/trunk/src/builders/indexable-builder.php#L258 - // add_filter( 'wpseo_should_save_indexable', '__return_true' ); - - // Add sitemap to robots.txt. - add_filter( 'robots_txt', __NAMESPACE__ . '\\add_sitemap_index_to_robots', 11, 2 ); - - // Remove All Yoast HTML Comments - // https://gist.github.com/paulcollett/4c81c4f6eb85334ba076 + /** + * Remove All Yoast HTML Comments. + * + * @see https://gist.github.com/paulcollett/4c81c4f6eb85334ba076 + */ add_filter( 'wpseo_debug_markers', '__return_false' ); if ( ! is_admin() ) { return; } - if ( isset( $_SERVER['REQUEST_URI'] ) && \is_string( $_SERVER['REQUEST_URI'] ) && strpos( $_SERVER['REQUEST_URI'], 'admin.php?page=wpseo_' ) !== false ) { + if ( isset( $_SERVER['REQUEST_URI'] ) && \is_string( $_SERVER['REQUEST_URI'] ) && strpos( \sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'admin.php?page=wpseo_' ) !== false ) { add_action( 'plugins_loaded', __NAMESPACE__ . '\\add_yoast_plugins', 5 ); add_filter( 'site_option_active_sitewide_plugins', __NAMESPACE__ . '\\active_yoast_plugins' ); } @@ -89,7 +78,6 @@ function add_yoast_plugins(): void { $updated_plugins = $plugins; $available = array_keys( $plugins ); - // $plugin_path = Altis\ROOT_DIR . '/vendor/yoast/' . $plugin_file; if ( is_readable( PLUGINPATH ) && ! in_array( BASENAME, $available, true ) ) { $updated_plugins[ BASENAME ] = get_plugin_data( PLUGINPATH, false, false ); } @@ -132,19 +120,3 @@ function enable_yoast_network_admin() { $network_admin_menu = new WPSEO_Network_Admin_Menu( $admin_menu ); $network_admin_menu->register_hooks(); } - -/** - * Add the Yoast SEO sitemap index to the robots.txt file. - * - * @param string $output The original robots.txt content. - * @param bool $public Whether the site is public. - * - * @return string The filtered robots.txt content. - */ -function add_sitemap_index_to_robots( string $output, bool $public ): string { - if ( $public ) { - $output .= sprintf( "Sitemap: %s\n", site_url( '/sitemap_index.xml' ) ); - } - - return $output; -} diff --git a/inc/wordpress-seo/open-graph.php b/inc/wordpress-seo/open-graph.php index 9b159e8..4ec15d8 100644 --- a/inc/wordpress-seo/open-graph.php +++ b/inc/wordpress-seo/open-graph.php @@ -19,16 +19,13 @@ function bootstrap(): void { // WARNING: bootstrap() itself is called on 'plugins_loaded', 19.01.2023 - // add_action( 'muplugins_loaded', __NAMESPACE__ . '\\load_metadata', 0 ); - + // add_action( 'muplugins_loaded', __NAMESPACE__ . '\\load_metadata', 0 ); // Maybe re-use old altis stuff? // Yoast debug mode will pretty print the yoast-schema-graph HTML. - defined( 'WPSEO_DEBUG' ) || define( 'WPSEO_DEBUG', WP_DEBUG ); + defined( 'WPSEO_DEBUG' ) || define( 'WPSEO_DEBUG', WP_DEBUG ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound - add_filter( 'wpseo_og_locale', __NAMESPACE__ . '\\change_og_locale' ); - // 'wpseo_og_locale' => 'preferred_languages_filter_locale', - // 'locale' => 'change_og_locale', // done pref_lang on prio 5 - // 'locale' => ['change_og_locale', 100], + // Update the 'locale' output, to not rely on WPLANG constant. + add_filter( 'wpseo_og_locale', __NAMESPACE__ . '\\change_og_locale' ); } diff --git a/inc/wordpress-seo/options.php b/inc/wordpress-seo/options.php index 3ae1f7b..c9d423d 100644 --- a/inc/wordpress-seo/options.php +++ b/inc/wordpress-seo/options.php @@ -7,12 +7,9 @@ namespace Figuren_Theater\SEO\Yoast_SEO\Options; -use Figuren_Theater\SEO\Yoast_SEO; - use Figuren_Theater; +use Figuren_Theater\SEO\Yoast_SEO; use Figuren_Theater\Network\Taxonomies; -use Figuren_Theater\Options as FT_Options; - use function __; use function add_action; use function get_option; @@ -28,19 +25,8 @@ function bootstrap(): void { add_action( 'Figuren_Theater\loaded', __NAMESPACE__ . '\\filter_options', 11 ); - // after the Options_Manager, which runs on 13 + // After the Options_Manager, which runs on 13. add_action( 'Figuren_Theater\loaded', __NAMESPACE__ . '\\re_set_dynamic_options', 15 ); - - - // add_action( 'plugins_loaded', __NAMESPACE__ . '\\debug', 20 ); -} - -function debug() { - \do_action( 'qm/debug', get_site_option('wpseo_ms') ); - \do_action( 'qm/debug', get_option('wpseo_titles') ); - \do_action( 'qm/debug', get_option('wpseo_ryte') ); - \do_action( 'qm/debug', get_option('wpseo') ); - \do_action( 'qm/debug', get_option('wpseo_social') ); } /** @@ -49,7 +35,6 @@ function debug() { * @return void */ function filter_options(): void { - $_options = [ 'yoast_migrations_free' => 0, @@ -74,6 +59,8 @@ function filter_options(): void { 'allow_zapier_integration_active' => false, ], /** + * Prepare data using %%yoast-variables%% for each post_type and taxonomy. + * * @see plugins\wordpress-seo\inc\options\class-wpseo-option-titles.php */ 'wpseo_titles' => [ @@ -83,65 +70,66 @@ function filter_options(): void { 'title-home-wpseo' => '%%sitename%% %%page%% %%sep%% %%sitedesc%%', // Text field. 'metadesc-home-wpseo' => '%%sitedesc%%', - 'title-author-wpseo' => '', // WILL BE SET ON ENABLE, due to get_text-calls - 'social-title-author-wpseo' => '', // WILL BE SET ON ENABLE, due to get_text-calls, - 'metadesc-author-wpseo' => '', // WILL BE SET ON ENABLE, due to get_text-calls, - 'social-description-author-wpseo' => '', // WILL BE SET ON ENABLE, due to get_text-calls, + 'title-author-wpseo' => '', // WILL BE SET ON ENABLE, due to get_text-calls. + 'social-title-author-wpseo' => '', // WILL BE SET ON ENABLE, due to get_text-calls. + 'metadesc-author-wpseo' => '', // WILL BE SET ON ENABLE, due to get_text-calls. + 'social-description-author-wpseo' => '', // WILL BE SET ON ENABLE, due to get_text-calls. 'title-archive-wpseo' => '%%date%% %%page%% %%sep%% %%sitename%%', // Text field. 'social-title-archive-wpseo' => '%%date%% %%page%% %%sep%% %%sitename%%', - 'metadesc-archive-wpseo' => '', // WILL BE SET ON ENABLE, due to get_text-calls, - 'social-description-archive-wpseo' => '', // WILL BE SET ON ENABLE, due to get_text-calls, + 'metadesc-archive-wpseo' => '', // WILL BE SET ON ENABLE, due to get_text-calls. + 'social-description-archive-wpseo' => '', // WILL BE SET ON ENABLE, due to get_text-calls. - 'title-search-wpseo' => '', // WILL BE SET ON ENABLE, due to get_text-calls - 'title-404-wpseo' => '', // WILL BE SET ON ENABLE, due to get_text-calls + 'title-search-wpseo' => '', // WILL BE SET ON ENABLE, due to get_text-calls. + 'title-404-wpseo' => '', // WILL BE SET ON ENABLE, due to get_text-calls. 'social-image-url-author-wpseo' => '', - 'social-image-url-archive-wpseo' => '', // WILL BE SET ON ENABLE + 'social-image-url-archive-wpseo' => '', // WILL BE SET ON ENABLE. 'social-image-id-author-wpseo' => 0, - 'social-image-id-archive-wpseo' => 0, // WILL BE SET ON ENABLE + 'social-image-id-archive-wpseo' => 0, // WILL BE SET ON ENABLE. 'rssbefore' => '', - 'rssafter' => '', // WILL BE SET ON ENABLE, due to get_text-calls + 'rssafter' => '', // WILL BE SET ON ENABLE, due to get_text-calls. - 'noindex-author-wpseo' => false, // do not use FALSE, because it gets handled as "non existing option", so the query will be done + 'noindex-author-wpseo' => false, // Do not use FALSE, because it gets handled as "non existing option", so the query will be done. 'noindex-author-noposts-wpseo' => true, 'noindex-archive-wpseo' => true, - 'disable-author' => '', // WILL BE SET ON ENABLE + 'disable-author' => '', // WILL BE SET ON ENABLE. 'disable-date' => false, 'disable-post_format' => true, 'disable-attachment' => true, - // 'is-media-purge-relevant' => false, - 'breadcrumbs-404crumb' => '', // WILL BE SET ON ENABLE, due to get_text-calls + // phpcs:ignore // 'is-media-purge-relevant' => false, + 'breadcrumbs-404crumb' => '', // WILL BE SET ON ENABLE, due to get_text-calls. 'breadcrumbs-display-blog-page' => true, 'breadcrumbs-boldlast' => true, - 'breadcrumbs-archiveprefix' => '', // WILL BE SET ON ENABLE, due to get_text-calls - 'breadcrumbs-enable' => false, // do not use FALSE, because it gets handled as "non existing option", so the query will be done + 'breadcrumbs-archiveprefix' => '', // WILL BE SET ON ENABLE, due to get_text-calls. + 'breadcrumbs-enable' => false, // Do not use FALSE, because it gets handled as "non existing option", so the query will be done. 'breadcrumbs-home' => '⌂', // 'Start', 'breadcrumbs-prefix' => '', - 'breadcrumbs-searchprefix' => '', // WILL BE SET ON ENABLE, due to get_text-calls + 'breadcrumbs-searchprefix' => '', // WILL BE SET ON ENABLE, due to get_text-calls. 'breadcrumbs-sep' => '»', - 'website_name' => '', // WILL BE SET ON ENABLE - // 'person_name' => '', - // 'person_logo' => '', - // 'person_logo_id' => 0, - // 'alternate_website_name' => '', - 'company_logo' => '', // WILL BE SET ON ENABLE - 'company_logo_id' => '', // WILL BE SET ON ENABLE - 'company_name' => '', // WILL BE SET ON ENABLE + 'website_name' => '', // WILL BE SET ON ENABLE. + // phpcs:ignore // 'person_name' => '', + // phpcs:ignore // 'person_logo' => '', + // phpcs:ignore // 'person_logo_id' => 0, + // phpcs:ignore // 'alternate_website_name' => '', + 'company_logo' => '', // WILL BE SET ON ENABLE. + 'company_logo_id' => '', // WILL BE SET ON ENABLE. + 'company_name' => '', // WILL BE SET ON ENABLE. 'company_or_person' => 'company', 'company_or_person_user_id' => false, - 'stripcategorybase' => true, // IMPORTANT // removes '.' used as category_base // do not use FALSE, because it gets handled as "non existing option", so the query will be done + 'stripcategorybase' => true, // IMPORTANT // removes '.' used as category_base // Do not use FALSE, because it gets handled as "non existing option", so the query will be done. 'open_graph_frontpage_title' => '%%sitename%%', 'open_graph_frontpage_desc' => '%%sitedesc%%', - 'open_graph_frontpage_image' => '', // WILL BE SET ON ENABLE - 'open_graph_frontpage_image_id' => 0, // WILL BE SET ON ENABLE - - // PT POST + 'open_graph_frontpage_image' => '', // WILL BE SET ON ENABLE. + 'open_graph_frontpage_image_id' => 0, // WILL BE SET ON ENABLE. + /** + * PT POST + */ 'title-post' => '%%title%% %%page%% %%sep%% %%ct_ft_production_shadow%% %%sep%% %%category%% %%sep%% %%sitename%%', 'metadesc-post' => '%%ft_geolocation_last%%: %%excerpt%%', - 'noindex-post' => false, // false is OK here // do not use FALSE, because it gets handled as "non existing option", so the query will be done + 'noindex-post' => false, // false is OK here // Do not use FALSE, because it gets handled as "non existing option", so the query will be done. 'display-metabox-pt-post' => true, 'post_types-post-maintax' => 'category', 'schema-page-type-post' => 'WebPage', @@ -151,11 +139,12 @@ function filter_options(): void { 'social-image-url-post' => '', 'social-image-id-post' => 0, - // PT PAGE - + /** + * PT PAGE + */ 'title-page' => '%%title%% %%page%% %%sep%% %%parent_title%% %%sep%% %%sitename%%', 'metadesc-page' => '%%excerpt%%', - 'noindex-page' => false, // THIS HANDLES rel=canonical // false is OK here // do not use FALSE, because it gets handled as "non existing option", so the query will be done + 'noindex-page' => false, // THIS HANDLES rel=canonical // false is OK here // Do not use FALSE, because it gets handled as "non existing option", so the query will be done. 'display-metabox-pt-page' => true, 'post_types-page-maintax' => '0', 'schema-page-type-page' => 'WebPage', @@ -165,46 +154,51 @@ function filter_options(): void { 'social-image-url-page' => '', 'social-image-id-page' => 0, - // PT ATTACHMENT // PT-views are disabled by this plugin 'Yoast SEO' - + /** + * PT ATTACHMENT // PT-views are disabled by this plugin 'Yoast SEO' + // 'title-attachment' => '%%title%% %%sep%% %%sitename%%', // 'metadesc-attachment' => '%%excerpt%%', - // 'noindex-attachment' => true, // prevents robots indexing // do not use FALSE, because it gets handled as "non existing option", so the query will be done + // 'noindex-attachment' => true, // prevents robots indexing // Do not use FALSE, because it gets handled as "non existing option", so the query will be done. // 'display-metabox-pt-attachment' => true, // 'post_types-attachment-maintax' => '0', // 'schema-page-type-attachment' => 'WebPage', // 'schema-article-type-attachment' => 'None', - - // TAX CATEGORY - + */ + + /** + * TAX CATEGORY + */ 'title-tax-category' => '%%term_hierarchy%% %%page%% %%sep%% %%sitename%%', 'metadesc-tax-category' => '%%category_description%%', 'display-metabox-tax-category' => true, - 'noindex-tax-category' => false, // false is OK here // do not use FALSE, because it gets handled as "non existing option", so the query will be done + 'noindex-tax-category' => false, // false is OK here // Do not use FALSE, because it gets handled as "non existing option", so the query will be done. 'social-title-tax-category' => '%%term_title%% %%sep%% %%sitename%%', 'social-description-tax-category' => '%%category_description%%', 'social-image-url-tax-category' => '', 'social-image-id-tax-category' => 0, 'taxonomy-category-ptparent' => 'post', - // TAX POST_TAG - + /** + * TAX POST_TAG + */ 'title-tax-post_tag' => '%%term_title%% %%page%% %%sep%% %%sitename%%', 'metadesc-tax-post_tag' => '%%term_description%%', 'display-metabox-tax-post_tag' => true, - 'noindex-tax-post_tag' => false, // false is OK here // do not use FALSE, because it gets handled as "non existing option", so the query will be done + 'noindex-tax-post_tag' => false, // false is OK here // Do not use FALSE, because it gets handled as "non existing option", so the query will be done. 'social-title-tax-post_tag' => '%%term_title%% %%sep%% %%sitename%%', 'social-description-tax-post_tag' => '%%term_description%%', 'social-image-url-tax-post_tag' => '', 'social-image-id-tax-post_tag' => 0, 'taxonomy-post_tag-ptparent' => 'post', - // TAX POST_FORMAT - + /** + * TAX POST_FORMAT + */ 'title-tax-post_format' => '%%term_title%% %%page%% %%sep%% %%sitename%%', 'metadesc-tax-post_format' => '%%term_description%%', 'display-metabox-tax-post_format' => false, - 'noindex-tax-post_format' => true, // prevents robots indexing + 'noindex-tax-post_format' => true, // Prevents robots indexing. 'social-title-tax-post_format' => '%%term_title%% %%sep%% %%sitename%%', 'social-description-tax-post_format' => '%%term_description%%', 'social-image-url-tax-post_format' => '', @@ -212,8 +206,9 @@ function filter_options(): void { 'taxonomy-post_format-ptparent' => 'post', - // PLUGIN 'FORMALITY' - + /** + * PLUGIN 'FORMALITY' + */ 'title-formality_form' => '%%title%% %%page%% %%sep%% %%sitename%%', 'metadesc-formality_form' => '', 'noindex-formality_form' => true, @@ -227,19 +222,18 @@ function filter_options(): void { 'status' => -1, 'last_fetch' => 1616325888, ], - // 'wpseo' => new Sync\SyncAndMerge( [ 'wpseo' => [ 'dismiss_configuration_workout_notice' => true, 'tracking' => false, - // 'license_server_version' => false, // DO NOT HANDLE, because it stores critical data + // phpcs:ignore // 'license_server_version' => false, // DO NOT HANDLE, because it stores relevant, non-filterable and or critical data. 'ms_defaults_set' => true, 'ignore_search_engines_discouraged_notice' => false, - // 'indexing_first_time' => true, // DO NOT HANDLE, because it stores critical data - // 'indexing_started' => false, // DO NOT HANDLE, because it stores critical data - // 'indexing_reason' => 'permalink_settings_changed', // DO NOT HANDLE, because it stores critical data - // 'indexables_indexing_completed' => false, // DO NOT HANDLE, because it stores critical data - // 'version' => '16.0.2', // DO NOT HANDLE, because it stores critical data - // 'previous_version' => '15.5', // DO NOT HANDLE, because it stores critical data + // phpcs:ignore // 'indexing_first_time' => true, // DO NOT HANDLE, because it stores relevant, non-filterable and or critical data. + // phpcs:ignore // 'indexing_started' => false, // DO NOT HANDLE, because it stores relevant, non-filterable and or critical data. + // phpcs:ignore // 'indexing_reason' => 'permalink_settings_changed', // DO NOT HANDLE, because it stores relevant, non-filterable and or critical data. + // phpcs:ignore // 'indexables_indexing_completed' => false, // DO NOT HANDLE, because it stores relevant, non-filterable and or critical data. + // phpcs:ignore // 'version' => '16.0.2', // DO NOT HANDLE, because it stores relevant, non-filterable and or critical data. + // phpcs:ignore // 'previous_version' => '15.5', // DO NOT HANDLE, because it stores relevant, non-filterable and or critical data. 'disableadvanced_meta' => true, 'enable_headless_rest_endpoints' => false, 'ryte_indexability' => false, @@ -248,12 +242,12 @@ function filter_options(): void { 'msverify' => '', 'yandexverify' => '', 'site_type' => 'smallBusiness', // @see wordpress-seo/inc/options/class-wpseo-option-wpseo.php#L115 - 'has_multiple_authors' => '', // WILL BE SET ON ENABLE // will deaktivate the author.php-templates to negletate duplicated-content - 'environment_type' => ( 'local' === \wp_get_environment_type() ) ? 'development' : \wp_get_environment_type(), // @see wordpress-seo/inc/options/class-wpseo-option-wpseo.php#L130 + 'has_multiple_authors' => '', // WILL BE SET ON ENABLE // will deaktivate the author.php-templates to negletate duplicated-content. + 'environment_type' => ( 'local' === \wp_get_environment_type() ) ? 'development' : \wp_get_environment_type(), // @see wordpress-seo/inc/options/class-wpseo-option-wpseo.php#L130 . 'content_analysis_active' => true, 'keyword_analysis_active' => true, 'enable_admin_bar_menu' => false, - 'enable_cornerstone_content' => false, // @TODO enable as advanced FEATURE + 'enable_cornerstone_content' => false, // @TODO enable as advanced FEATURE. 'enable_xml_sitemap' => true, 'enable_text_link_counter' => true, 'enable_index_now' => ( 'production' === \wp_get_environment_type() ), @@ -263,15 +257,15 @@ function filter_options(): void { 'semrush_integration_active' => false, 'semrush_tokens' => [], 'semrush_country_code' => 'us', - 'permalink_structure' => '', // WILL BE SET ON ENABLE - 'home_url' => '', // WILL BE SET ON ENABLE - 'dynamic_permalinks' => false, // Polylang needs it to be TRUE, for many reasons: READ Issue & Commit files of https://github.com/polylang/polylang/pull/907 - 'category_base_url' => '.', // WILL BE RE-SET ON ENABLE - 'tag_base_url' => '!!', // WILL BE RE-SET ON ENABLE + 'permalink_structure' => '', // WILL BE SET ON ENABLE. + 'home_url' => '', // WILL BE SET ON ENABLE. + 'dynamic_permalinks' => false, // Polylang needs it to be TRUE, for many reasons: READ Issue & Commit files of https://github.com/polylang/polylang/pull/907. + 'category_base_url' => '.', // WILL BE RE-SET ON ENABLE. + 'tag_base_url' => '!!', // WILL BE RE-SET ON ENABLE. 'custom_taxonomy_slugs' => array( - // 'event-venue' => 'events/venues', - // 'event-category' => 'events/category', - // 'event-tag' => 'typ', + // phpcs:ignore // 'event-venue' => 'events/venues', + // phpcs:ignore // 'event-category' => 'events/category', + // phpcs:ignore // 'event-tag' => 'typ', 'hm-utility' => 'hm-utility', Taxonomies\Taxonomy__ft_geolocation::NAME => Taxonomies\Taxonomy__ft_geolocation::SLUG, Taxonomies\Taxonomy__ft_site_shadow::NAME => Taxonomies\Taxonomy__ft_site_shadow::SLUG, // 'von', @@ -283,75 +277,75 @@ function filter_options(): void { 'zapier_integration_active' => false, 'zapier_subscription' => array(), 'zapier_api_key' => '', - // ] ), // former SyncAndMerge ], 'wpseo_social' => [ - 'facebook_site' => '', // DO NOT HANDLE, leave to ft-network-sources-Manager - 'instagram_url' => '', // DO NOT HANDLE, leave to ft-network-sources-Manager - 'linkedin_url' => '', // DO NOT HANDLE, leave to ft-network-sources-Manager - 'myspace_url' => '', // DO NOT HANDLE, leave to ft-network-sources-Manager - 'og_default_image' => '', // WILL BE SET ON ENABLE - 'og_default_image_id' => '', // WILL BE SET ON ENABLE - 'og_frontpage_title' => '', // WILL BE SET ON ENABLE - 'og_frontpage_desc' => '', // WILL BE SET ON ENABLE - 'og_frontpage_image' => '', // WILL BE SET ON ENABLE - 'og_frontpage_image_id' => '', // WILL BE SET ON ENABLE + 'facebook_site' => '', // DO NOT HANDLE, leave to ft-network-sources-Manager. + 'instagram_url' => '', // DO NOT HANDLE, leave to ft-network-sources-Manager. + 'linkedin_url' => '', // DO NOT HANDLE, leave to ft-network-sources-Manager. + 'myspace_url' => '', // DO NOT HANDLE, leave to ft-network-sources-Manager. + 'og_default_image' => '', // WILL BE SET ON ENABLE. + 'og_default_image_id' => '', // WILL BE SET ON ENABLE. + 'og_frontpage_title' => '', // WILL BE SET ON ENABLE. + 'og_frontpage_desc' => '', // WILL BE SET ON ENABLE. + 'og_frontpage_image' => '', // WILL BE SET ON ENABLE. + 'og_frontpage_image_id' => '', // WILL BE SET ON ENABLE. 'opengraph' => true, - 'pinterest_url' => '', // DO NOT HANDLE, leave to ft-network-sources-Manager - // 'pinterestverify' => '', // DO NOT HANDLE, leave to ft-network-sources-Manager (not yet implemented, should be post_meta of 'ft_link') + 'pinterest_url' => '', // DO NOT HANDLE, leave to ft-network-sources-Manager. + // phpcs:ignore // 'pinterestverify' => '', // DO NOT HANDLE, leave to ft-network-sources-Manager (not yet implemented, should be post_meta of 'ft_link'). 'twitter' => true, - 'twitter_site' => '', // DO NOT HANDLE, leave to ft-network-sources-Manager + 'twitter_site' => '', // DO NOT HANDLE, leave to ft-network-sources-Manager. 'twitter_card_type' => 'summary_large_image', - 'youtube_url' => '', // DO NOT HANDLE, leave to ft-network-sources-Manager - 'wikipedia_url' => '', // DO NOT HANDLE, leave to ft-network-sources-Manager + 'youtube_url' => '', // DO NOT HANDLE, leave to ft-network-sources-Manager. + 'wikipedia_url' => '', // DO NOT HANDLE, leave to ft-network-sources-Manager. ], ]; - - - // gets added to the 'OptionsCollection' - // from within itself on creation - // new FT_Options\Option( - // 'wpseo', - // $_options['wpseo'], - // Yoast_SEO\BASENAME - // ); - new FT_Options\Option_Merged( + /* + * Gets added to the 'OptionsCollection' + * from within itself on creation. + */ + new Options\Option_Merged( 'wpseo', $_options['wpseo'], Yoast_SEO\BASENAME ); - // gets added to the 'OptionsCollection' - // from within itself on creation - new FT_Options\Option( + /* + * Gets added to the 'OptionsCollection' + * from within itself on creation. + */ + new Options\Option( 'wpseo_ms', $_options['wpseo_ms'], Yoast_SEO\BASENAME, 'site_option' ); - - // gets added to the 'OptionsCollection' - // from within itself on creation - new FT_Options\Option( + /* + * Gets added to the 'OptionsCollection' + * from within itself on creation. + */ + new Options\Option( 'wpseo_titles', $_options['wpseo_titles'], Yoast_SEO\BASENAME ); - - // gets added to the 'OptionsCollection' - // from within itself on creation - new FT_Options\Option( + /* + * Gets added to the 'OptionsCollection' + * from within itself on creation. + */ + new Options\Option( 'wpseo_ryte', $_options['wpseo_ryte'], Yoast_SEO\BASENAME ); - // gets added to the 'OptionsCollection' - // from within itself on creation - new FT_Options\Option( + /* + * Gets added to the 'OptionsCollection' + * from within itself on creation. + */ + new Options\Option( 'wpseo_social', $_options['wpseo_social'], Yoast_SEO\BASENAME @@ -368,22 +362,16 @@ function re_set_dynamic_options(): void { $_has_multiple_authors = ( ! Figuren_Theater\FT::site()->has_feature( [ 'einsamer-wolf' ] ) ) ? true : ''; - // fallback - $_logo_id = $_logo = $_logo_url = ''; + $_logo_id = null; + $_logo_url = null; - // $_logo_id = (int) \get_theme_mod( 'custom_logo' ); - // do this only on the frontend - // or for the 'wpseo' admin-views - // - // and because we're very early - // we need to go for REQUEST - if ( empty( $_REQUEST ) || ( isset( $_REQUEST['page'] ) && is_string( $_REQUEST['page'] ) && false !== strpos( $_REQUEST['page'], 'wpseo' ) ) ) { + // Do this only on the frontend or for the 'wpseo' admin-views. + // And because we're very early we need to go for REQUEST. + // phpcs:ignore WordPress.Security.NonceVerification.Recommended + if ( empty( $_REQUEST ) || ( isset( $_REQUEST['page'] ) && is_string( $_REQUEST['page'] ) && false !== strpos( \sanitize_text_field( $_REQUEST['page'] ), 'wpseo' ) ) ) { $_logo_id = get_option( 'site_logo' ); if ( is_int( $_logo_id ) && 0 < $_logo_id ) { - // - // $_logo = (array) \wp_get_attachment_image_src( $_logo_id , 'full' ); - // $_logo_url = (string) $_logo[0]; $_logo_url = (string) wp_get_attachment_image_url( $_logo_id, 'full' ); } } @@ -394,35 +382,39 @@ function re_set_dynamic_options(): void { $_category_base_url = get_option( 'category_base' ); $_tag_base_url = get_option( 'tag_base' ); $_home_url = get_option( 'home' ); - + $_rssafter = sprintf( '

%1$s

', __( '%%POSTLINK%% was published first on %%BLOGLINK%%', 'figurentheater' ), sprintf( - __( 'using the machines of %1$s', 'figurentheater' ), + /* translators: %s is a link to websites.fuer.figuren.theater. */ + __( 'using the machines of %s', 'figurentheater' ), 'https://websites.fuer.figuren.theater/' ) ); - // update wpseo + // Update 'wpseo' option. $_wpseo = Figuren_Theater\API::get( 'Options' )->get( 'option_wpseo' ); - // prevent problems with SyncFrom-Options - // if ($_wpseo->value instanceof Sync\SyncAndMerge__Interface) { + // Prevent problems with SyncFrom-Options. if ( is_array( $_wpseo->value ) ) { - // $_wpseo_temp = $_wpseo->value->container; $_wpseo_temp = $_wpseo->value; $_wpseo_temp['has_multiple_authors'] = $_has_multiple_authors; $_wpseo_temp['permalink_structure'] = $_permalink_structure; $_wpseo_temp['category_base_url'] = $_category_base_url; $_wpseo_temp['tag_base_url'] = $_tag_base_url; $_wpseo_temp['home_url'] = $_home_url; - // $_wpseo->set_value( new Sync\SyncAndMerge( $_wpseo_temp ) ); - $_wpseo->set_value( $_wpseo_temp ); + + $_wpseo->set_value( + \apply_filters( + __NAMESPACE__ . '\\option_wpseo', + $_wpseo_temp + ) + ); } - // update wpseo_social + // Update 'wpseo_social' option. $_wpseo_social = Figuren_Theater\API::get( 'Options' )->get( 'option_wpseo_social' ); - // prevent problems with SyncFrom-Options + // Prevent problems with SyncFrom-Options. if ( is_array( $_wpseo_social->value ) ) { $_wpseo_social_temp = $_wpseo_social->value; $_wpseo_social_temp['og_default_image'] = $_logo_url; @@ -434,9 +426,9 @@ function re_set_dynamic_options(): void { $_wpseo_social->set_value( $_wpseo_social_temp ); } - // update wpseo_titles + // Update 'wpseo_titles' option. $_wpseo_titles = Figuren_Theater\API::get( 'Options' )->get( 'option_wpseo_titles' ); - // prevent problems with SyncFrom-Options + // Prevent problems with SyncFrom-Options. if ( is_array( $_wpseo_titles->value ) ) { $_wpseo_titles_temp = $_wpseo_titles->value; $_wpseo_titles_temp['disable-author'] = ! $_has_multiple_authors; From f27581c7f6c45c0627dfd4ddd04769c237a5046d Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Sat, 24 Feb 2024 00:23:47 +0100 Subject: [PATCH 12/17] Upgrading figuren-theater/ft-options (1.2.3 => 1.2.4) --- composer.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index 5532937..ca01367 100644 --- a/composer.lock +++ b/composer.lock @@ -153,16 +153,16 @@ }, { "name": "figuren-theater/ft-options", - "version": "1.2.3", + "version": "1.2.4", "source": { "type": "git", "url": "https://github.com/figuren-theater/ft-options.git", - "reference": "127e6c8bb62cce778ee7468aa548c8326fe9c29a" + "reference": "f834d9d398078817c2653b054b584a11468fe6b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/figuren-theater/ft-options/zipball/127e6c8bb62cce778ee7468aa548c8326fe9c29a", - "reference": "127e6c8bb62cce778ee7468aa548c8326fe9c29a", + "url": "https://api.github.com/repos/figuren-theater/ft-options/zipball/f834d9d398078817c2653b054b584a11468fe6b8", + "reference": "f834d9d398078817c2653b054b584a11468fe6b8", "shasum": "" }, "require": { @@ -170,7 +170,7 @@ "php": ">=7.4" }, "require-dev": { - "figuren-theater/code-quality": "*" + "figuren-theater/code-quality": "^1.1" }, "type": "wordpress-muplugin", "autoload": { @@ -207,7 +207,7 @@ "issues": "https://github.com/figuren-theater/ft-options/issues", "source": "https://github.com/figuren-theater/ft-options" }, - "time": "2023-09-11T10:27:33+00:00" + "time": "2024-02-23T03:54:22+00:00" }, { "name": "markjaquith/wp-tlc-transients", From 4fefd146360c9592b82ef9350cf4a8d51947339b Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Sat, 24 Feb 2024 00:26:44 +0100 Subject: [PATCH 13/17] Upgrading figuren-theater/code-quality (1.0.1 => 1.1.1) --- composer.json | 2 +- composer.lock | 114 +++++++++++++++++++++++++------------------------- 2 files changed, 58 insertions(+), 58 deletions(-) diff --git a/composer.json b/composer.json index 0320b54..fbd7d1c 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ "wpackagist-plugin/wordpress-seo": "19.8" }, "require-dev": { - "figuren-theater/code-quality": "*" + "figuren-theater/code-quality": "^1.1" }, "repositories": [ { diff --git a/composer.lock b/composer.lock index ca01367..02a7873 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": "23973075fa89914535f3cef96bd48938", + "content-hash": "ce415eee6abf0794241a0e91d8edf37a", "packages": [ { "name": "composer/installers", @@ -424,40 +424,40 @@ }, { "name": "ergebnis/composer-normalize", - "version": "2.39.0", + "version": "2.42.0", "source": { "type": "git", "url": "https://github.com/ergebnis/composer-normalize.git", - "reference": "a878360bc8cb5cb440b9381f72b0aaa125f937c7" + "reference": "02cf2b69ad2a74c6f11a8c3f5f054b8f949df910" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ergebnis/composer-normalize/zipball/a878360bc8cb5cb440b9381f72b0aaa125f937c7", - "reference": "a878360bc8cb5cb440b9381f72b0aaa125f937c7", + "url": "https://api.github.com/repos/ergebnis/composer-normalize/zipball/02cf2b69ad2a74c6f11a8c3f5f054b8f949df910", + "reference": "02cf2b69ad2a74c6f11a8c3f5f054b8f949df910", "shasum": "" }, "require": { "composer-plugin-api": "^2.0.0", - "ergebnis/json": "^1.1.0", - "ergebnis/json-normalizer": "^4.3.0", - "ergebnis/json-printer": "^3.4.0", + "ergebnis/json": "^1.2.0", + "ergebnis/json-normalizer": "^4.5.0", + "ergebnis/json-printer": "^3.5.0", "ext-json": "*", "justinrainbow/json-schema": "^5.2.12", "localheinz/diff": "^1.1.1", - "php": "~8.1.0 || ~8.2.0 || ~8.3.0" + "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0" }, "require-dev": { - "composer/composer": "^2.6.5", - "ergebnis/license": "^2.2.0", - "ergebnis/php-cs-fixer-config": "~6.7.0", - "ergebnis/phpunit-slow-test-detector": "^2.3.0", - "fakerphp/faker": "^1.23.0", - "infection/infection": "~0.27.4", - "phpunit/phpunit": "^10.4.1", + "composer/composer": "^2.6.6", + "ergebnis/license": "^2.4.0", + "ergebnis/php-cs-fixer-config": "^6.20.0", + "ergebnis/phpunit-slow-test-detector": "^2.9.0", + "fakerphp/faker": "^1.23.1", + "infection/infection": "~0.26.6", + "phpunit/phpunit": "^9.6.16", "psalm/plugin-phpunit": "~0.18.4", - "rector/rector": "~0.18.5", - "symfony/filesystem": "^6.0.13", - "vimeo/psalm": "^5.15.0" + "rector/rector": "~0.19.2", + "symfony/filesystem": "^5.4.25", + "vimeo/psalm": "^5.20.0" }, "type": "composer-plugin", "extra": { @@ -497,7 +497,7 @@ "security": "https://github.com/ergebnis/composer-normalize/blob/main/.github/SECURITY.md", "source": "https://github.com/ergebnis/composer-normalize" }, - "time": "2023-10-10T15:43:27+00:00" + "time": "2024-01-30T11:54:02+00:00" }, { "name": "ergebnis/json", @@ -833,21 +833,21 @@ }, { "name": "figuren-theater/code-quality", - "version": "1.0.1", + "version": "1.1.1", "source": { "type": "git", "url": "https://github.com/figuren-theater/code-quality.git", - "reference": "93fb1c34c5c0c14ccc5692969fdcbcba344e7a7c" + "reference": "c3d56f0e03d78be437079c6893920f03da3bc264" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/figuren-theater/code-quality/zipball/93fb1c34c5c0c14ccc5692969fdcbcba344e7a7c", - "reference": "93fb1c34c5c0c14ccc5692969fdcbcba344e7a7c", + "url": "https://api.github.com/repos/figuren-theater/code-quality/zipball/c3d56f0e03d78be437079c6893920f03da3bc264", + "reference": "c3d56f0e03d78be437079c6893920f03da3bc264", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "0.7.2", - "ergebnis/composer-normalize": "2.39.0", + "ergebnis/composer-normalize": "2.42.0", "figuren-theater/coding-standards": "*", "figuren-theater/phpstan": "*", "phpstan/extension-installer": "1.3.1" @@ -882,20 +882,20 @@ "issues": "https://github.com/figuren-theater/code-quality/issues", "source": "https://github.com/figuren-theater/code-quality" }, - "time": "2023-12-15T22:45:38+00:00" + "time": "2024-02-15T17:33:00+00:00" }, { "name": "figuren-theater/coding-standards", - "version": "0.4.1", + "version": "0.4.2", "source": { "type": "git", "url": "https://github.com/figuren-theater/coding-standards.git", - "reference": "064a379d5660203f70423ebea5c0583ab15e9a32" + "reference": "d2c0ec0e2ba2690099ccfeb8a23bf571dc4599ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/figuren-theater/coding-standards/zipball/064a379d5660203f70423ebea5c0583ab15e9a32", - "reference": "064a379d5660203f70423ebea5c0583ab15e9a32", + "url": "https://api.github.com/repos/figuren-theater/coding-standards/zipball/d2c0ec0e2ba2690099ccfeb8a23bf571dc4599ac", + "reference": "d2c0ec0e2ba2690099ccfeb8a23bf571dc4599ac", "shasum": "" }, "require": { @@ -934,28 +934,28 @@ "issues": "https://github.com/figuren-theater/coding-standards/issues", "source": "https://github.com/figuren-theater/coding-standards" }, - "time": "2023-12-15T22:39:27+00:00" + "time": "2024-02-10T04:32:28+00:00" }, { "name": "figuren-theater/phpstan", - "version": "1.2.1", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/figuren-theater/phpstan.git", - "reference": "8a6f5c51eb6afaa354611cd2290440d432808938" + "reference": "cdab496710bae6416ef3463eb5b879c137130268" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/figuren-theater/phpstan/zipball/8a6f5c51eb6afaa354611cd2290440d432808938", - "reference": "8a6f5c51eb6afaa354611cd2290440d432808938", + "url": "https://api.github.com/repos/figuren-theater/phpstan/zipball/cdab496710bae6416ef3463eb5b879c137130268", + "reference": "cdab496710bae6416ef3463eb5b879c137130268", "shasum": "" }, "require": { - "php-stubs/wordpress-globals": "^0.2.0", - "szepeviktor/phpstan-wordpress": "^1.3" + "php-stubs/wordpress-globals": "0.2.0", + "szepeviktor/phpstan-wordpress": "1.3.2" }, "require-dev": { - "ergebnis/composer-normalize": "^2.31" + "ergebnis/composer-normalize": "2.42.0" }, "type": "phpstan-extension", "extra": { @@ -992,7 +992,7 @@ "issues": "https://github.com/figuren-theater/phpstan/issues", "source": "https://github.com/figuren-theater/phpstan" }, - "time": "2023-09-13T08:55:48+00:00" + "time": "2024-02-15T17:24:24+00:00" }, { "name": "justinrainbow/json-schema", @@ -1167,16 +1167,16 @@ }, { "name": "php-stubs/wordpress-stubs", - "version": "v6.4.1", + "version": "v6.4.3", "source": { "type": "git", "url": "https://github.com/php-stubs/wordpress-stubs.git", - "reference": "6d6063cf9464a306ca2a0529705d41312b08500b" + "reference": "6105bdab2f26c0204fe90ecc53d5684754550e8f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/6d6063cf9464a306ca2a0529705d41312b08500b", - "reference": "6d6063cf9464a306ca2a0529705d41312b08500b", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/6105bdab2f26c0204fe90ecc53d5684754550e8f", + "reference": "6105bdab2f26c0204fe90ecc53d5684754550e8f", "shasum": "" }, "require-dev": { @@ -1185,9 +1185,9 @@ "php": "^7.4 || ~8.0.0", "php-stubs/generator": "^0.8.3", "phpdocumentor/reflection-docblock": "^5.3", - "phpstan/phpstan": "^1.10.12", + "phpstan/phpstan": "^1.10.49", "phpunit/phpunit": "^9.5", - "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^0.8" + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^0.11" }, "suggest": { "paragonie/sodium_compat": "Pure PHP implementation of libsodium", @@ -1208,9 +1208,9 @@ ], "support": { "issues": "https://github.com/php-stubs/wordpress-stubs/issues", - "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.4.1" + "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.4.3" }, - "time": "2023-11-10T00:33:47+00:00" + "time": "2024-02-11T18:56:19+00:00" }, { "name": "phpcompatibility/php-compatibility", @@ -1598,16 +1598,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.57", + "version": "1.10.59", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "1627b1d03446904aaa77593f370c5201d2ecc34e" + "reference": "e607609388d3a6d418a50a49f7940e8086798281" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/1627b1d03446904aaa77593f370c5201d2ecc34e", - "reference": "1627b1d03446904aaa77593f370c5201d2ecc34e", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e607609388d3a6d418a50a49f7940e8086798281", + "reference": "e607609388d3a6d418a50a49f7940e8086798281", "shasum": "" }, "require": { @@ -1656,7 +1656,7 @@ "type": "tidelift" } ], - "time": "2024-01-24T11:51:34+00:00" + "time": "2024-02-20T13:59:13+00:00" }, { "name": "rarst/phpcs-cognitive-complexity", @@ -1764,16 +1764,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.8.1", + "version": "3.9.0", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "14f5fff1e64118595db5408e946f3a22c75807f7" + "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/14f5fff1e64118595db5408e946f3a22c75807f7", - "reference": "14f5fff1e64118595db5408e946f3a22c75807f7", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/d63cee4890a8afaf86a22e51ad4d97c91dd4579b", + "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b", "shasum": "" }, "require": { @@ -1840,7 +1840,7 @@ "type": "open_collective" } ], - "time": "2024-01-11T20:47:48+00:00" + "time": "2024-02-16T15:06:51+00:00" }, { "name": "symfony/polyfill-php73", From 46ab57736be588bf6e13dfa5d3268984160cb324 Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Sat, 24 Feb 2024 11:35:48 +0100 Subject: [PATCH 14/17] Fix CS issues --- inc/sharing-image/admin-ui.php | 68 ++-- inc/sharing-image/generation.php | 531 ++++++++----------------------- inc/sharing-image/namespace.php | 6 +- inc/sharing-image/options.php | 39 +-- inc/wordpress-seo/options.php | 10 +- 5 files changed, 195 insertions(+), 459 deletions(-) diff --git a/inc/sharing-image/admin-ui.php b/inc/sharing-image/admin-ui.php index 4706b97..1f53e33 100644 --- a/inc/sharing-image/admin-ui.php +++ b/inc/sharing-image/admin-ui.php @@ -35,13 +35,6 @@ function bootstrap(): void { // // 'sharing_image_get_fontpath' => ['sharing_image_get_fontpath', 10, 2], // ! - // maybe TODO later - // This is only relevant (and called), if the metabox is visible! - // - // hand over the just yet selected - // and not yet saved fetaured-image to our autogeneration logic - // 'sharing_image_update_post_meta' => ['mf_update_post_meta_sharing_image', 10, 2], // ! - // Disable any UI for the user // which is not that reliable // and not save to use. @@ -90,51 +83,64 @@ function sharing_image_settings_tabs( array $tabs ): array { * Hides the 'Sharing Image' metabox, * if the current user can not 'manage_site_options' (NEEDED_CAP). * + * This could be the chance for a selectable, additional feature tzo have this metabox available to the editor, + * BUT it gets totally buggy and clunky, with this metabox activated. + * + * Keep the metabox disabled, until you did enormous testing! + * * @see https://wpset.org/sharing-image/hooks/#sharing_image_hide_metabox * * @return bool */ function sharing_image_hide_metabox(): bool { - return current_user_can( Sharing_Image\NEEDED_CAP ); + return true; + // return ! current_user_can( Sharing_Image\NEEDED_CAP ); + // + // maybe TODO later + // This is only relevant (and called), if the metabox is visible! + // + // hand over the just yet selected + // and not yet saved fetaured-image to our autogeneration logic + // add_filter('sharing_image_update_post_meta', __NAMESPACE__ . '\\mf_update_post_meta_sharing_image', 10, 2 ); // ! } /** * This is only relevant, if the metabox is visible! + * + * This filter allows you to change the array with widget post meta right before the update_post_meta request. + * + * @see https://wpset.org/sharing-image/hooks/#sharing_image_update_post_meta * - * @param string $meta Updated post meta. - * @param string $post_id Post ID. -public function mf_update_post_meta_sharing_image( $meta, $post_id ) { - // get featured image - $featured_image = \get_post_thumbnail_id($post_id); - - # error_log(var_export([ - # \current_filter(), - # 'mf_update_post_meta_sharing_image()', - # $meta, $post_id - # ],true)); - - - if($featured_image) { - if(isset($meta) && isset($meta['fieldset'])){ - // loop all templates - foreach ($meta['fieldset'] as $index => $template) { - // assign featured image as attachment if no attachment defined - if(!isset($template['attachment']) || !$template['attachment']){ - $meta['fieldset'][$index]['attachment'] = $featured_image; - } + * @param array $meta Updated post meta. + * @param int $post_id Post ID. + * + * @return array + */ +function mf_update_post_meta_sharing_image( array $meta, int $post_id ): array { + $featured_image = \get_post_thumbnail_id( $post_id ); + if ( $featured_image ) { + if ( isset( $meta ) && isset( $meta['fieldset'] ) ) { + // Loop all templates. + foreach ( $meta['fieldset'] as $index => $template ) { + // Assign featured image as attachment if no attachment defined. + if ( ! isset( $template['attachment'] ) || ! $template['attachment'] ) { + $meta['fieldset'][ $index ]['attachment'] = $featured_image; } + } } } return $meta; } - */ + /** - * UNUSED right now + * Use theme specific fonts for the headline. + * + * @todo #8 Use the new webfont-API as soon as it got published. * * @param string $path Font file path. * @param array $layer Layer data. diff --git a/inc/sharing-image/generation.php b/inc/sharing-image/generation.php index b801d8f..3550f7f 100644 --- a/inc/sharing-image/generation.php +++ b/inc/sharing-image/generation.php @@ -7,17 +7,19 @@ namespace Figuren_Theater\SEO\Sharing_Image\Generation; -// use Figuren_Theater\SEO\Sharing_Image; // POST_TYPE_SUPPORT - use Figuren_Theater\Media\Image_Optimization; -use Sharing_Image as Sharing_Image_Plugin; +use Figuren_Theater\SEO\Sharing_Image; +use Sharing_Image\Generator; +use Sharing_Image\Widget; use WP_Post; use function add_action; -use function delete_post_meta; +use function add_filter; +use function did_action; +use function do_action; use function esc_url; -use function ft_get_relevant_colors; use function get_attached_file; use function get_option; +use function get_post; use function get_post_meta; use function get_post_parent; use function get_post_thumbnail_id; @@ -28,12 +30,16 @@ use function wp_get_upload_dir; use function wp_installing; use function wp_is_post_revision; +use function wp_parse_url; +use function sanitize_url; +use function untrailingslashit; const LAYER = [ 'title' => 0, 'logo' => 1, 'url' => 2, 'overlay' => 3, + 'blur' => 4, ]; /** @@ -42,13 +48,7 @@ * @return void */ function bootstrap(): void { - // add_action( 'admin_init', __NAMESPACE__ . '\\load', 0 ); - add_action( 'init', __NAMESPACE__ . '\\load', 0 ); // Figuren_Theater\Media\Auto_Featured_Image runs on 10 - // add_action( 'admin_init', __NAMESPACE__ . '\\load', 0 ); // Figuren_Theater\Media\Auto_Featured_Image runs on 10 - // add_action( 'rest_api_init', __NAMESPACE__ . '\\load', 0 ); // Figuren_Theater\Media\Auto_Featured_Image runs on 10 - - - // add_action( 'updated_post_meta', __NAMESPACE__ . '\\trigger_autogeneration', 10, 4 ); + add_action( 'init', __NAMESPACE__ . '\\load', 0 ); // Figuren_Theater\Media\Auto_Featured_Image runs on 'init:10'. } /** @@ -60,10 +60,8 @@ function load(): void { // BACKEND | Autogeneration logic triggered on 'wp_insert_post'. - // Helper (just) to get current post_id - // used because it is (one of) the earliest point possible - // to hook into the autogeneration-process. - // add_filter( 'sharing_image_disable_autogeneration', __NAMESPACE__ . '\\persist_current_post', 10, 2 ); + // Delete post_meta to allow for proper autogenerate poster if it is needed. + add_action( 'wp_insert_post', __NAMESPACE__ . '\\prepare_autogenerate_poster', 0, 3 ); // The plugin runs on 10. // Update static, with more dynamic, site-specific options. add_filter( 'pre_option_sharing_image_templates', __NAMESPACE__ . '\\pre_option_sharing_image_templates', 20 ); @@ -71,38 +69,50 @@ function load(): void { // Re-Enables default functionality // of using the featured-image as background-image // which is not happening reliable on autogeneration. - // - // BUGGY add_filter( 'sharing_image_prepare_template', __NAMESPACE__ . '\\sharing_image_prepare_template', 10, 2 ); + // Shrink new image and delete previous image. + add_filter( 'sharing_image_autogenerated_poster', __NAMESPACE__ . '\\optimize_new_delete_previous_image', 10, 2 ); - add_filter( 'sharing_image_autogenerated_poster', __NAMESPACE__ . '\\delete_previous_image', 10, 2 ); - - - // BACKEND | Autogeneration logic triggered on 'updated_post_meta' + add_filter( 'sharing_image_disable_autogeneration', __NAMESPACE__ . '\\maybe_disable_autogeneration', 10, 2 ); // Re-Enables default func. // of using the featured-image as background-image // which is not happening reliable on autogeneration. - add_action( 'updated_post_meta', __NAMESPACE__ . '\\trigger_autogeneration', 10, 4 ); - + // + // Super buggy! + // add_action( 'updated_post_meta', __NAMESPACE__ . '\\trigger_autogeneration', 10, 4 ); // ! - /** - * Fires before a post is deleted, at the start of wp_delete_post(). - * - * The 'delete_post' hook is too late, because the relevant post_meta is already deleted. - * - * @param int $postid Post ID. - * @param WP_Post $post Post object. - */ + // Delete auto-generated 'Sharing Image's. add_action( 'before_delete_post', __NAMESPACE__ . '\\delete_generated_image', 10, 2 ); } /** - * The only way to get into that process - * and get the ID of the current edited post + * Delete previous image & post_meta on every 'wp_insert_post'. * + * @param int $post_id Post ID. + * @param \WP_Post $post Post object. + * @param bool $update Whether this is an existing post being updated. + * + * @return void + */ +function prepare_autogenerate_poster( int $post_id, WP_Post $post, bool $update ): void { + // There could be nothing to delete, + // on a new post. + if ( ! $update ) { + return; + } + + // Make sure this runs only once. + do_action( __NAMESPACE__ . '\\delete_generated_image' ); + if ( ! did_action( __NAMESPACE__ . '\\delete_generated_image' ) ) { + delete_generated_image( $post_id, $post ); + } +} + + +/** * Normally the 'sharing_image_disable_autogeneration' filter is used to disable posters autogeneration process based on Post ID. * It could also be used to skip autogeneration for some post types. * @@ -113,7 +123,7 @@ function load(): void { * * @return bool */ -function persist_current_post( bool $disable_autogeneration, int $post_id ): bool { +function maybe_disable_autogeneration( bool $disable_autogeneration, int $post_id ): bool { if ( wp_installing() ) { return true; } @@ -130,7 +140,7 @@ function persist_current_post( bool $disable_autogeneration, int $post_id ): boo // Support Typesafety. $post_pt = get_post_type( $post_id ); if ( false === $post_pt ) { - return $disable_autogeneration; + return true; } if ( ! post_type_supports( $post_pt, Sharing_Image\POST_TYPE_SUPPORT ) ) { @@ -141,9 +151,16 @@ function persist_current_post( bool $disable_autogeneration, int $post_id ): boo return $disable_autogeneration; } + +/** + * Enhanced version of get_post() + * which also looks for the post-ID in the requested URL of a REST API call, if one occured. + * + * @return WP_Post|false + */ function try_to_get_post(): WP_Post|false { - $post = \get_post(); + $post = get_post(); if ( $post instanceof WP_Post ) { return $post; } @@ -152,7 +169,7 @@ function try_to_get_post(): WP_Post|false { return false; } - $url_parts = parse_url( $_SERVER['REQUEST_URI'] ); + $url_parts = wp_parse_url( sanitize_url( $_SERVER['REQUEST_URI'] ) ); if ( ! isset( $url_parts['path'] ) ) { return false; } @@ -165,10 +182,10 @@ function try_to_get_post(): WP_Post|false { $post_id = (int) str_replace( '/wp-json/wp/v2/posts/', '', - \untrailingslashit( $url_parts['path'] ) + untrailingslashit( $url_parts['path'] ) ); - $post = \get_post( $post_id ); + $post = get_post( $post_id ); if ( $post instanceof WP_Post ) { return $post; } @@ -180,8 +197,11 @@ function try_to_get_post(): WP_Post|false { * Filters the value of the 'sharing_image_templates' option before it is retrieved. * * This allows us to add all automated layers on the fly, when a new image is created and this option is used by WordPress. + * + * Because this is a 'pre_option' filter, this needs some data. + * The data could come either from the options table or from our OptionsFactory filter. * - * @param array|bool $option + * @param array|bool $option The full option 'sharing_image_templates' array. * * @return array|bool */ @@ -199,119 +219,14 @@ function pre_option_sharing_image_templates( $option ): array|bool { return false; } - // global $wp, $wp_query; - error_log( - var_export( - [ - __FUNCTION__ . '\\DOING_AJAX', - \wp_debug_backtrace_summary(), - // parse_url( $_SERVER['REQUEST_URI'] ), - // $GLOBALS, - // $wp, - // $wp_query, - // \get_post(), - $option, - 'EXTRACTED :::: ', - $post->ID, - - ], - true - ) - ); - if ( defined( 'DOING_AJAX' ) ) { - } - - + $template = $option[0]; + $template = get_site_logo( $template ); + $template = get_theme_color( $template ); + $template = get_featured_image( $template, $post ); + $template = get_shortlink( $template, $post ); + $option[0] = $template; - - $template = $option[0]; - - $template = __get_site_logo( $template ); - - $template = __get_theme_color( $template ); - // $template['fill'] = '#0000ff'; // Testing this filter - // $template['layers'][3]['color'] = '#0000ff'; // Testing this filter // ['layers'][3] == rectangle - - $template = __get_featured_image( $template, $post ); - - $template = __get_shortlink( $template, $post ); - - // BEWARE - // do this last - // because the order of the layers gets modified - // and so LAYER might break - // - - - /* - // if ('will-trigger-never' === \get_post_type( $this->current_post )) { - if ('will-trigger-never' === \get_post_type( __current_post() )) { - // if ( Post_Types\Post_Type__ft_production::NAME === \get_post_type( $this->current_post )) { - - $_new_text_layer = array ( - 'type' => 'text', - 'dynamic' => 0, - 'title' => 'Dauer', - 'content' => 'Dauer: 75 Minuten', // @TODO - 'sample' => 'Dauer: 75 Minuten', // @TODO - 'preset' => 'title', - 'color' => '#ffffff', // @TODO - 'horizontal' => 'left', - 'vertical' => 'top', - 'fontsize' => 10, - 'lineheight' => 1.5, - 'fontname' => 'open-sans', - 'x' => 100, - 'y' => 595, - 'width' => 1000, - // 'height' => '', - ); - // v1 - // $template['layers'][4] = $_new_text_layer; - // v2 - array_unshift($template['layers'], $_new_text_layer); - - - $_new_text_layer = array ( - 'type' => 'text', - 'dynamic' => 0, - 'title' => 'Zielgruppe', - 'content' => 'für alle ab 5 Jahren', // @TODO - 'sample' => 'für alle ab 5 Jahren', // @TODO - 'preset' => 'title', - 'color' => '#ffffff', // @TODO - 'horizontal' => 'left', - 'vertical' => 'top', - 'fontsize' => 10, - 'lineheight' => 1.5, - 'fontname' => 'open-sans', - 'x' => 300, - 'y' => 595, - 'width' => 800, - // 'height' => '', - ); - // v1 - // $template['layers'][4] = $_new_text_layer; - // v2 - array_unshift($template['layers'], $_new_text_layer); - } - */ - - $option[0] = $template; - /* - error_log(var_export([ - __FUNCTION__, - \wp_debug_backtrace_summary(), - $post->ID, - $_REQUEST, - $_POST, - $_GET, - $_SERVER, - // \get_post(), - // $option - ],true));*/ - - return $option; + return $option; } /** @@ -320,18 +235,12 @@ function pre_option_sharing_image_templates( $option ): array|bool { * * @see https://wpset.org/sharing-image/hooks/#sharing_image_prepare_template * - * @param array $template List of template data. - * @param array $fieldset Fieldset data from picker. + * @param array $template List of template data. + * @param array|null $fieldset Fieldset data from picker. * * @return array */ -function sharing_image_prepare_template( array $template, array $fieldset ): array { - - // error_log( var_export([ - // __FUNCTION__, - // \wp_debug_backtrace_summary(), - // \get_post(), - // ],true) ); +function sharing_image_prepare_template( array $template, array|null $fieldset ): array { // 0. if ( isset( $template['image'] ) && \is_string( $template['image'] ) && \esc_url( $template['image'] ) ) { @@ -339,19 +248,20 @@ function sharing_image_prepare_template( array $template, array $fieldset ): arr } // 1.'generate_template()' @ plugins\sharing-image\classes\class-generator.php. - $thumbnail_id = \get_post_thumbnail_id(); + $thumbnail_id = get_post_thumbnail_id(); if ( ! empty( $thumbnail_id ) ) { $fieldset['attachment'] = $thumbnail_id; } // 2.'prepare_template()' @ plugins\sharing-image\classes\class-generator.php. if ( ! empty( $fieldset['attachment'] ) && \is_int( $fieldset['attachment'] ) ) { - $template['image'] = \get_attached_file( $fieldset['attachment'] ); + $template['image'] = get_attached_file( $fieldset['attachment'] ); } return $template; } + /** * Delete previous, old autogenerated-image * to save disk-space @@ -372,42 +282,21 @@ function sharing_image_prepare_template( array $template, array $fieldset ): arr * * @return array|false */ -function delete_previous_image( array|false $poster, int $post_id ): array|false { - // return early - // if we have no new image +function optimize_new_delete_previous_image( array|false $poster, int $post_id ): array|false { + // Return early, if we have no new image. if ( false === $poster || ! isset( $poster['poster'] ) || ! \is_string( $poster['poster'] ) || ! esc_url( $poster['poster'] ) ) { return $poster; } - error_log( - var_export( - [ - __FUNCTION__, - $post_id, - ], - true - ) - ); - - - // compress image - // this makes 25kb > 15kb and 93kb > 49kb - $_path = __get_path_from_url( $poster['poster'] ); + // Compress image, + // this makes 25kb > 15kb and 93kb > 49kb ! + $_path = get_path_from_url( $poster['poster'] ); Image_Optimization\replace( $_path ); - // return early - // if it is a revision - // - // !! not needed, because 'update_post_meta()' - // !! does correct the post_id to point to the post_parent - // - // if ( \wp_is_post_revision( $post_id ) ) - // return false; - - // grab the last image from post_meta, + // Grab the last image from post_meta, // before it gets updated // which happens directly after this filter - // @plugins\sharing-image\classes\class-widget.php + // @plugins\sharing-image\classes\class-widget.php . // Make sure meta is got for the post, not for its revision. if ( wp_is_post_revision( $post_id ) ) { @@ -416,48 +305,16 @@ function delete_previous_image( array|false $poster, int $post_id ): array|false $post_id = $post_parent->ID; } } - - error_log( - var_export( - [ - __FUNCTION__, - $post_id, - ], - true - ) - ); - - - // get old image data, if any - $old_poster = get_post_meta( - $post_id, - Sharing_Image_Plugin\Widget::WIDGET_META, - true - ); - // could be replaced with - // $old_poster = \sharing_image_poster( $post_id ); - // return - // if there was no image, yet - if ( ! is_array( $old_poster ) || ! isset( $old_poster['poster'] ) || ! \is_string( $old_poster['poster'] ) || ! esc_url( $old_poster['poster'] ) ) { - return $poster; - } + // Get old image data, if any + // and delete it. + delete_generated_image( $post_id, get_post( $post_id ) ); - // here, we know - // we already had one image, - // so we have a valid url - // so find its path - // and delete it - $old_poster_path = __get_path_from_url( $old_poster['poster'] ); - if ( file_exists( $old_poster_path ) ) { - unlink( $old_poster_path ); - } - - // bye bye - // and return the un-modified, new image (data) + // Bye bye and return the un-modified, new image (data). return $poster; } + /** * By default the autogenartion is not done, when just swapping featured-images, * because it is not the whole $post that is changed, but only some metadata. @@ -479,103 +336,41 @@ function delete_previous_image( array|false $poster, int $post_id ): array|false * - `updated_term_meta` * - `updated_user_meta` * - * @since 2.9.0 - * * @param int $meta_id ID of updated metadata entry. * @param int $object_id ID of the object metadata is for. * @param string $meta_key Metadata key. - * @param mixed $_meta_value Metadata value. */ -function trigger_autogeneration( $meta_id, $object_id, $meta_key, $_meta_value ): void { +function trigger_autogeneration( $meta_id, $object_id, $meta_key ): void { if ( '_thumbnail_id' !== $meta_key ) { return; } - error_log( - var_export( - [ - __FUNCTION__ . 'BEFORE wp_is_post_revision( $object_id )', - $object_id, - ], - true - ) - ); - if ( wp_is_post_revision( $object_id ) ) { return; } - - error_log( - var_export( - [ - __FUNCTION__ . 'AFTER wp_is_post_revision( $object_id )', - $object_id, - ], - true - ) - ); - - /* - // helper (just) to get current post_id - // used because it is (one of) the earliest point possible - // to hook into the autogeneration-process - add_filter( 'sharing_image_disable_autogeneration', __NAMESPACE__ . '\\persist_current_post', 10, 2 ); - - // update static, with more dynamic, site-specific options - add_filter( 'pre_option_sharing_image_templates', __NAMESPACE__ . '\\pre_option_sharing_image_templates', 20 ); - - // Re-Enables default func. - // of using the featured-image as background-image - // which is not happening reliable on autogeneration + // The autogenerate_poster() function will do nothing, + // as long as an existing set of 'poster' post_meta exists. // - // BUGGY - // add_...('sharing_image_prepare_template', __NAMESPACE__ . '\\sharing_image_prepare_template', 10, 3 ); + // So we have to delete this at first + // to make sure this runs properly. + delete_generated_image( $object_id, get_post( $object_id ) ); - - add_filter( 'sharing_image_autogenerated_poster', __NAMESPACE__ . '\\delete_previous_image', 10, 2 ); - - - - */ - - - - - // autogenerate_poster() does nothing because - // a meta['poster'] is not empty - // - // so we have to delete this at first - // to make sure this runs properly - delete_post_meta( + // Generate new poster data using post data. + ( new Generator() )->compose( + [ + 'template' => 0, + ], $object_id, - Sharing_Image_Plugin\Widget::WIDGET_META + 'post' ); - - // make sure this is set - // __current_post( $object_id ); - // ?????????????? - - error_log( - var_export( - [ - __FUNCTION__, - $object_id, - ], - true - ) - ); - - - // Generate new poster data using post data. - // ( new Sharing_Image\Meta() )->get_poster( $object_id ); - $SIW = new Sharing_Image_Plugin\Widget(); - // $source = ( $SIW )->autogenerate_poster( $object_id ); // ?? not existing anymore ?? ... - $source = ( $SIW )->generate_poster(); } /** - * Delete auto-generated 'Sharing Image's + * Delete auto-generated 'Sharing Image's. + * + * Fires before a post is deleted, at the start of wp_delete_post(). + * The 'delete_post' hook is too late, because the relevant post_meta is already deleted. * * @param int $post_id Post-ID of the currently managed post. * @param WP_Post $post Full WP_Post object. @@ -588,33 +383,18 @@ function delete_generated_image( int $post_id, WP_Post $post ): void { return; } - - error_log( - var_export( - [ - __FUNCTION__, - $post_id, - ], - true - ) - ); - - $_sharing_image = get_post_meta( $post_id, Sharing_Image_Plugin\Widget::WIDGET_META, true ); - // could be replaced with - // $_sharing_image = \sharing_image_poster( $post_id ); + $_sharing_image = get_post_meta( $post_id, Widget::WIDGET_META, true ); if ( ! \is_array( $_sharing_image ) || ! isset( $_sharing_image['poster'] ) || ! \is_string( $_sharing_image['poster'] ) || ! esc_url( $_sharing_image['poster'] ) ) { return; } - - $_sharing_image_path = __get_path_from_url( $_sharing_image['poster'] ); - // $_sharing_image_path = $this->__get_path_from_url($_sharing_image); + $_sharing_image_path = get_path_from_url( $_sharing_image['poster'] ); if ( empty( $_sharing_image_path ) ) { return; } - unlink( $_sharing_image_path ); + unlink( $_sharing_image_path ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_unlink } @@ -646,11 +426,11 @@ function __prepare_text_layer( $layer_name = 'title', $new_text = '' ) { /** * Add a new 'Logo' Layer to the 'Sharing Image' template. * - * @param array>> $template + * @param array>> $template List of template data. * * @return array>> */ -function __get_site_logo( array $template ): array { +function get_site_logo( array $template ): array { // Which index has this layer in the array of saved layers for this template? $layer_index = (int) LAYER['logo']; @@ -671,22 +451,19 @@ function __get_site_logo( array $template ): array { /** * Add color-definitions to existing layers of the 'Sharing Image' template to match the current theme. * - * @param array>|string> $template + * @param array>|string> $template List of template data. * * @return array>|string> */ -function __get_theme_color( array $template ): array { - // get colors from gutenberg - // from mu-plugins\ft_FEATURES__customizer-powered-login.php - // - // >>> array ( 'ft_background' => '#0f0b0e', 'ft_accent' => '#d20394', 'ft_text' => '#fbf9fa', ) - extract( ft_get_relevant_colors() ); +function get_theme_color( array $template ): array { + // Get colors from gutenberg. + $colors = \Figuren_Theater\Theming\Themed_Login\ft_get_relevant_colors(); - // prepare color options with site-specific stuff - $template['fill'] = $ft_background; - $template['layers'][ LAYER['title'] ]['color'] = $ft_text; // ['layers'][0] == text - $template['layers'][ LAYER['url'] ]['color'] = $ft_text; // ['layers'][2] == text - $template['layers'][ LAYER['overlay'] ]['color'] = $ft_accent; // ['layers'][3] == rectangle + // Prepare color options with site-specific stuff, fallback to f.t scheme. + $template['fill'] = ( isset( $colors['ft_background'] ) && \is_string( $colors['ft_background'] ) ) ? $colors['ft_background'] : '#0f0b0e'; + $template['layers'][ LAYER['title'] ]['color'] = ( isset( $colors['ft_text'] ) && \is_string( $colors['ft_text'] ) ) ? $colors['ft_text'] : '#fbf9fa'; + $template['layers'][ LAYER['url'] ]['color'] = ( isset( $colors['ft_text'] ) && \is_string( $colors['ft_text'] ) ) ? $colors['ft_text'] : '#fbf9fa'; + $template['layers'][ LAYER['overlay'] ]['color'] = ( isset( $colors['ft_accent'] ) && \is_string( $colors['ft_accent'] ) ) ? $colors['ft_accent'] : '#d20394'; return $template; } @@ -694,12 +471,12 @@ function __get_theme_color( array $template ): array { /** * Set the background-image for the 'Sharing Image' template to match the current posts featured-image. * - * @param array $template - * @param WP_Post|null $post + * @param array $template List of template data. + * @param WP_Post|null $post * * @return array */ -function __get_featured_image( array $template, WP_Post|null $post ): array { +function get_featured_image( array $template, WP_Post|null $post ): array { // 0. if ( isset( $template['image'] ) && \is_string( $template['image'] ) && esc_url( $template['image'] ) ) { return $template; @@ -718,39 +495,38 @@ function __get_featured_image( array $template, WP_Post|null $post ): array { * Set the URL text of the 'Sharing Image' template * to the shortlink of the given post or the site_url as a fallback. * - * @param array>> $template - * @param WP_Post|null $post + * @param array>> $template List of template data. + * @param WP_Post|null $post Current Post object. * * @return array>> */ -function __get_shortlink( array $template, WP_Post|null $post ): array { - // prepare url +function get_shortlink( array $template, WP_Post|null $post ): array { + // Prepare url. $url = null; - // get url of current post or site + // Get url of current post or site. if ( null !== $post ) { $url = wp_get_shortlink( $post->ID ); } - // fallback + // Fallback. if ( empty( $url ) ) { $url = wp_get_shortlink(); } - // still empty ? + // Still empty ? if ( empty( $url ) ) { $url = site_url(); } if ( esc_url( $url ) ) { - // remove protocoll + // Remove protocoll. $url = str_replace( 'https://', '', esc_url( $url ) ); - // set data + // Set data. $template['layers'][ LAYER['url'] ]['sample'] = $url; $template['layers'][ LAYER['url'] ]['content'] = $url; - // __prepare_text_layer( 'url', $url ); // this safes into prop } return $template; @@ -759,11 +535,11 @@ function __get_shortlink( array $template, WP_Post|null $post ): array { /** * Extract an image path from its URL. * - * @param string $url + * @param string $url Full URL to image. * - * @return string + * @return string Absolute path to image. */ -function __get_path_from_url( string $url = '' ): string { +function get_path_from_url( string $url = '' ): string { $wp_upload_dir = wp_get_upload_dir(); $path = str_replace( @@ -778,48 +554,3 @@ function __get_path_from_url( string $url = '' ): string { return $path; } - -/* -function __current_post( int $post_id=0 ) : int { - if ( ! $current_post_id ) { - $current_post_id = 0; - } - if ( 0 < $post_id ) { - static $current_post_id = $post_id; - } - return $current_post_id; -} - */ - -/** - * Ugly helper to persist the post_ID - * during one request, but on different - * action hooks - -class currentPost { - - public $id = 0; - - public function get_id( int $post_id=0 ) { - - if ( 0 < $post_id ) { - $this->id = $post_id; - } - -error_log( current_filter() ); -error_log( spl_object_hash( $this ) ); -error_log($this->id); - return $this->id; - } - - public static function init() - { - static $instance; - - if ( NULL === $instance ) { - $instance = new self; - } - - return $instance; - } -} */ diff --git a/inc/sharing-image/namespace.php b/inc/sharing-image/namespace.php index b739e71..fbeafa9 100644 --- a/inc/sharing-image/namespace.php +++ b/inc/sharing-image/namespace.php @@ -69,13 +69,9 @@ function ( string $post_type ): void { // FRONTEND. Frontend\bootstrap(); - // if ( ! is_admin() ) - // return; - // BACKEND. Admin_UI\bootstrap(); - // BACKEND | Autogeneration logic - // Triggered on 'wp_insert_post' and/or on 'updated_post_meta'. + // BACKEND | Autogeneration logic. Generation\bootstrap(); } diff --git a/inc/sharing-image/options.php b/inc/sharing-image/options.php index fcb7a8a..29d50da 100644 --- a/inc/sharing-image/options.php +++ b/inc/sharing-image/options.php @@ -7,12 +7,10 @@ namespace Figuren_Theater\SEO\Sharing_Image\Options; -use Figuren_Theater\Options; +use Figuren_Theater; use Figuren_Theater\SEO\Sharing_Image; use WP_DEBUG; -use function __; use function add_action; -use function get_option; // Defined at "Sharing_Image_Plugin\Settings::OPTION_TEMPLATES" within the plugin. const OPTION_NAME = 'sharing_image_templates'; @@ -23,7 +21,6 @@ * @return void */ function bootstrap(): void { - add_action( 'Figuren_Theater\loaded', __NAMESPACE__ . '\\filter_options', 11 ); } @@ -47,7 +44,7 @@ function filter_options(): void { 'autogenerate' => 0, // Not a true/false switch, but the index of the templates-array, with the template for autogeneration. ), OPTION_NAME => array( - 0 => array( + array( 'preview' => '', 'title' => 'standard', 'fill' => '#000000', @@ -65,39 +62,38 @@ function filter_options(): void { 'color' => '#ffffff', 'horizontal' => 'left', 'vertical' => 'center', - 'fontsize' => 50, + 'fontsize' => 48, 'lineheight' => 1.5, 'fontname' => 'open-sans', 'x' => 100, - 'y' => 100, + // 'y' => 100, is unused & unset by purpose. 'width' => 1000, // 'height' is unused & unset by purpose. ), 1 => array( - 'type' => 'image', + 'type' => 'image', // 'attachment' => 45, Do not set this at all, to prevent fatal errors. - 'x' => 25, - 'y' => 25, - 'width' => 50, - 'height' => 50, + 'x' => 25, + 'y' => 25, + 'width' => 50, + // 'height' => 50, is unused & unset by purpose. ), 2 => array( 'type' => 'text', // 'dynamic' => 'dynamic', is unused & unset by purpose. - 'dynamic' => 0, 'title' => 'URL', 'content' => 'figuren.theater', 'sample' => 'figuren.theater/1234567', 'preset' => 'ft_shortlink', // Must be a custom name and not empty. 'color' => '#ffffff', - 'horizontal' => 'right', + 'horizontal' => 'left', 'vertical' => 'top', 'fontsize' => 10, 'lineheight' => 1.5, 'fontname' => 'open-sans', - 'x' => 0, - 'y' => 595, - 'width' => 1175, + 'x' => 1000, + 'y' => 600, + // 'width' => 1175, is unused & unset by purpose. // 'height' => '', is unused & unset by purpose. ), 3 => array( @@ -111,6 +107,13 @@ function filter_options(): void { 'width' => 1200, 'height' => 630, ), + 4 => array( + 'type' => 'filter', + 'blur' => 'blur', + 'brightness' => 0, + 'contrast' => 0, + 'blackout' => 0, + ), ), ), ), @@ -118,7 +121,7 @@ function filter_options(): void { // Gets added to the 'OptionsCollection' // from within itself on creation. - new Options\Factory( + new Figuren_Theater\Options\Factory( $_options, 'Figuren_Theater\Options\Option', Sharing_Image\BASENAME diff --git a/inc/wordpress-seo/options.php b/inc/wordpress-seo/options.php index c9d423d..3c8ee87 100644 --- a/inc/wordpress-seo/options.php +++ b/inc/wordpress-seo/options.php @@ -304,7 +304,7 @@ function filter_options(): void { * Gets added to the 'OptionsCollection' * from within itself on creation. */ - new Options\Option_Merged( + new Figuren_Theater\Options\Option_Merged( 'wpseo', $_options['wpseo'], Yoast_SEO\BASENAME @@ -314,7 +314,7 @@ function filter_options(): void { * Gets added to the 'OptionsCollection' * from within itself on creation. */ - new Options\Option( + new Figuren_Theater\Options\Option( 'wpseo_ms', $_options['wpseo_ms'], Yoast_SEO\BASENAME, @@ -325,7 +325,7 @@ function filter_options(): void { * Gets added to the 'OptionsCollection' * from within itself on creation. */ - new Options\Option( + new Figuren_Theater\Options\Option( 'wpseo_titles', $_options['wpseo_titles'], Yoast_SEO\BASENAME @@ -335,7 +335,7 @@ function filter_options(): void { * Gets added to the 'OptionsCollection' * from within itself on creation. */ - new Options\Option( + new Figuren_Theater\Options\Option( 'wpseo_ryte', $_options['wpseo_ryte'], Yoast_SEO\BASENAME @@ -345,7 +345,7 @@ function filter_options(): void { * Gets added to the 'OptionsCollection' * from within itself on creation. */ - new Options\Option( + new Figuren_Theater\Options\Option( 'wpseo_social', $_options['wpseo_social'], Yoast_SEO\BASENAME From b7c772a5793600a46170269ee96e82262caa1a9d Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Sat, 24 Feb 2024 11:41:54 +0100 Subject: [PATCH 15/17] Upgrading wpackagist-plugin/sharing-image (2.0 => 2.0.17) --- composer.json | 2 +- composer.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index fbd7d1c..d65b5bb 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "require": { "php": ">=7.1", "figuren-theater/ft-options": "*", - "wpackagist-plugin/sharing-image": "2.0", + "wpackagist-plugin/sharing-image": "^2.0", "wpackagist-plugin/wordpress-seo": "19.8" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 02a7873..95da357 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": "ce415eee6abf0794241a0e91d8edf37a", + "content-hash": "e4521d5976bf881988a299bf01d096e7", "packages": [ { "name": "composer/installers", @@ -257,15 +257,15 @@ }, { "name": "wpackagist-plugin/sharing-image", - "version": "2.0", + "version": "2.0.17", "source": { "type": "svn", "url": "https://plugins.svn.wordpress.org/sharing-image/", - "reference": "tags/2.0" + "reference": "tags/2.0.17" }, "dist": { "type": "zip", - "url": "https://downloads.wordpress.org/plugin/sharing-image.2.0.zip" + "url": "https://downloads.wordpress.org/plugin/sharing-image.2.0.17.zip" }, "require": { "composer/installers": "^1.0 || ^2.0" From 22c6c13383795063f8e087b53856a1970dbca6fa Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Sat, 24 Feb 2024 11:53:06 +0100 Subject: [PATCH 16/17] Add suggest for figuren-theater/ft-media --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index d65b5bb..142ba07 100644 --- a/composer.json +++ b/composer.json @@ -36,6 +36,9 @@ "require-dev": { "figuren-theater/code-quality": "^1.1" }, + "suggest": { + "figuren-theater/ft-media": "Contains the mandatory function to shrink and minify images." + }, "repositories": [ { "type": "composer", From 13ae61805bfb0ff6ab4cdd7864a345e0b15fef40 Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Sat, 24 Feb 2024 15:00:38 +0100 Subject: [PATCH 17/17] Fix phpstan issues --- inc/sharing-image/admin-ui.php | 8 ++-- inc/sharing-image/generation.php | 73 +++++++++++++++++++++++--------- inc/wordpress-seo/options.php | 2 +- phpstan.neon | 7 +++ 4 files changed, 66 insertions(+), 24 deletions(-) diff --git a/inc/sharing-image/admin-ui.php b/inc/sharing-image/admin-ui.php index 1f53e33..f5ac779 100644 --- a/inc/sharing-image/admin-ui.php +++ b/inc/sharing-image/admin-ui.php @@ -112,15 +112,15 @@ function sharing_image_hide_metabox(): bool { * * @see https://wpset.org/sharing-image/hooks/#sharing_image_update_post_meta * - * @param array $meta Updated post meta. - * @param int $post_id Post ID. + * @param array>> $meta Updated post meta. + * @param int $post_id Post ID. * - * @return array + * @return array>> */ function mf_update_post_meta_sharing_image( array $meta, int $post_id ): array { $featured_image = \get_post_thumbnail_id( $post_id ); if ( $featured_image ) { - if ( isset( $meta ) && isset( $meta['fieldset'] ) ) { + if ( isset( $meta['fieldset'] ) && ! empty( $meta['fieldset'] ) ) { // Loop all templates. foreach ( $meta['fieldset'] as $index => $template ) { // Assign featured image as attachment if no attachment defined. diff --git a/inc/sharing-image/generation.php b/inc/sharing-image/generation.php index 3550f7f..b99bc7c 100644 --- a/inc/sharing-image/generation.php +++ b/inc/sharing-image/generation.php @@ -42,6 +42,7 @@ 'blur' => 4, ]; + /** * Bootstrap module, when enabled. * @@ -51,6 +52,7 @@ function bootstrap(): void { add_action( 'init', __NAMESPACE__ . '\\load', 0 ); // Figuren_Theater\Media\Auto_Featured_Image runs on 'init:10'. } + /** * Load Autogeneration logic hooks at relevant spots of the save_post workflow. * @@ -193,6 +195,7 @@ function try_to_get_post(): WP_Post|false { return false; } + /** * Filters the value of the 'sharing_image_templates' option before it is retrieved. * @@ -229,6 +232,7 @@ function pre_option_sharing_image_templates( $option ): array|bool { return $option; } + /** * Prepare template before creating poster with this filter. * Used to update fieldset texts and background image. @@ -290,8 +294,10 @@ function optimize_new_delete_previous_image( array|false $poster, int $post_id ) // Compress image, // this makes 25kb > 15kb and 93kb > 49kb ! - $_path = get_path_from_url( $poster['poster'] ); - Image_Optimization\replace( $_path ); + if ( \function_exists( '\Figuren_Theater\Media\Image_Optimization\replace' ) ) { + $_path = get_path_from_url( $poster['poster'] ); + Image_Optimization\replace( $_path ); + } // Grab the last image from post_meta, // before it gets updated @@ -308,7 +314,7 @@ function optimize_new_delete_previous_image( array|false $poster, int $post_id ) // Get old image data, if any // and delete it. - delete_generated_image( $post_id, get_post( $post_id ) ); + delete_generated_image( $post_id ); // Bye bye and return the un-modified, new image (data). return $poster; @@ -354,7 +360,7 @@ function trigger_autogeneration( $meta_id, $object_id, $meta_key ): void { // // So we have to delete this at first // to make sure this runs properly. - delete_generated_image( $object_id, get_post( $object_id ) ); + delete_generated_image( $object_id ); // Generate new poster data using post data. ( new Generator() )->compose( @@ -366,6 +372,7 @@ function trigger_autogeneration( $meta_id, $object_id, $meta_key ): void { ); } + /** * Delete auto-generated 'Sharing Image's. * @@ -377,7 +384,13 @@ function trigger_autogeneration( $meta_id, $object_id, $meta_key ): void { * * @return void */ -function delete_generated_image( int $post_id, WP_Post $post ): void { +function delete_generated_image( int $post_id, ?WP_Post $post = null ): void { + if ( ! $post instanceof WP_Post ) { + $post = get_post( $post_id ); + } + if ( ! $post instanceof WP_Post ) { + return; + } if ( ! post_type_supports( $post->post_type, Sharing_Image\POST_TYPE_SUPPORT ) ) { return; @@ -423,39 +436,50 @@ function __prepare_text_layer( $layer_name = 'title', $new_text = '' ) { } */ + /** * Add a new 'Logo' Layer to the 'Sharing Image' template. * - * @param array>> $template List of template data. + * @param array $template List of template data. * - * @return array>> + * @return array */ function get_site_logo( array $template ): array { - // Which index has this layer in the array of saved layers for this template? - $layer_index = (int) LAYER['logo']; + + if ( ! isset( $template['layers'] ) + || ! \is_array( $template['layers'] ) + || ! isset( $template['layers'][ LAYER['logo'] ] ) + || ! \is_array( $template['layers'][ LAYER['logo'] ] ) ) { + return $template; + } // Get site-logo ID. $logo = get_option( 'site_icon' ); if ( empty( $logo ) || ! \is_string( $logo ) ) { // The plugin itself checks if 'attachment' isset(). - unset( $template['layers'][ $layer_index ]['attachment'] ); + unset( $template['layers'][ LAYER['logo'] ]['attachment'] ); return $template; } - $template['layers'][ $layer_index ]['attachment'] = $logo; + $template['layers'][ LAYER['logo'] ]['attachment'] = $logo; return $template; } + /** * Add color-definitions to existing layers of the 'Sharing Image' template to match the current theme. * - * @param array>|string> $template List of template data. + * @param array $template List of template data. * - * @return array>|string> + * @return array */ function get_theme_color( array $template ): array { + if ( ! \function_exists( '\Figuren_Theater\Theming\Themed_Login\ft_get_relevant_colors' ) ) { + return $template; + } + // Get colors from gutenberg. $colors = \Figuren_Theater\Theming\Themed_Login\ft_get_relevant_colors(); @@ -468,13 +492,14 @@ function get_theme_color( array $template ): array { return $template; } + /** * Set the background-image for the 'Sharing Image' template to match the current posts featured-image. * - * @param array $template List of template data. - * @param WP_Post|null $post + * @param array $template List of template data. + * @param WP_Post|null $post * - * @return array + * @return array */ function get_featured_image( array $template, WP_Post|null $post ): array { // 0. @@ -491,16 +516,25 @@ function get_featured_image( array $template, WP_Post|null $post ): array { return $template; } + /** * Set the URL text of the 'Sharing Image' template * to the shortlink of the given post or the site_url as a fallback. * - * @param array>> $template List of template data. - * @param WP_Post|null $post Current Post object. + * @param array $template List of template data. + * @param WP_Post|null $post Current Post object. * - * @return array>> + * @return array */ function get_shortlink( array $template, WP_Post|null $post ): array { + + if ( ! isset( $template['layers'] ) + || ! \is_array( $template['layers'] ) + || ! isset( $template['layers'][ LAYER['url'] ] ) + || ! \is_array( $template['layers'][ LAYER['url'] ] ) ) { + return $template; + } + // Prepare url. $url = null; @@ -532,6 +566,7 @@ function get_shortlink( array $template, WP_Post|null $post ): array { return $template; } + /** * Extract an image path from its URL. * diff --git a/inc/wordpress-seo/options.php b/inc/wordpress-seo/options.php index 3c8ee87..4786b97 100644 --- a/inc/wordpress-seo/options.php +++ b/inc/wordpress-seo/options.php @@ -360,7 +360,7 @@ function filter_options(): void { */ function re_set_dynamic_options(): void { - $_has_multiple_authors = ( ! Figuren_Theater\FT::site()->has_feature( [ 'einsamer-wolf' ] ) ) ? true : ''; + $_has_multiple_authors = ( ! \Figuren_Theater\FT::site()->has_feature( [ 'einsamer-wolf' ] ) ) ? true : ''; $_logo_id = null; $_logo_url = null; diff --git a/phpstan.neon b/phpstan.neon index 711c95c..7666504 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -20,3 +20,10 @@ parameters: ignoreErrors: # Find a nicer way instead of ignoring this Error on every ft-module - '#Function Altis\\register_module not found\.#' + # TODO https://github.com/figuren-theater/ft-seo/issues/15 Remove ugly dependencies to old spaghetti code + - '#Access to constant NAME on an unknown class Figuren_Theater\\Network\\Taxonomies\\Taxonomy__ft_geolocation\.#' + - '#Access to constant SLUG on an unknown class Figuren_Theater\\Network\\Taxonomies\\Taxonomy__ft_geolocation\.#' + - '#Access to constant NAME on an unknown class Figuren_Theater\\Network\\Taxonomies\\Taxonomy__ft_site_shadow\.#' + - '#Access to constant SLUG on an unknown class Figuren_Theater\\Network\\Taxonomies\\Taxonomy__ft_site_shadow\.#' + - '#Call to static method get\(\) on an unknown class Figuren_Theater\\API\.#' + - '#Call to static method site\(\) on an unknown class Figuren_Theater\\FT\.#' \ No newline at end of file