diff --git a/.github/workflows/deploy-to-wp-on-release.yml b/.github/workflows/deploy-to-wp-on-release.yml new file mode 100644 index 0000000..c7e1340 --- /dev/null +++ b/.github/workflows/deploy-to-wp-on-release.yml @@ -0,0 +1,31 @@ +name: Deploy to WordPress.org + +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + extensions: mbstring, intl + tools: composer + + - name: Install PHP dependencies + run: | + composer install --no-dev --optimize-autoloader + + - name: WordPress Plugin Deploy + uses: 10up/action-wordpress-plugin-deploy@stable + env: + SVN_USERNAME: ${{ secrets.SVN_USERNAME }} + SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} + SLUG: on-demand-revalidation + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/on-demand-revalidation.php b/class-ondemandrevalidation.php similarity index 86% rename from on-demand-revalidation.php rename to class-ondemandrevalidation.php index 2a37ab5..158cf18 100644 --- a/on-demand-revalidation.php +++ b/class-ondemandrevalidation.php @@ -4,14 +4,16 @@ * * Plugin Name: On-Demand Revalidation * Plugin URI: https://wordpress.org/plugins/on-demand-revalidation - * GitHub Plugin URI: https://github.com/gdidentity/on-demand-revalidation - * Description: Next.js On-Demand Revalidation on the post update, revalidate specific paths on the post update. - * Version: 1.1.3 - * Author: GD IDENTITY - * Author URI: https://gdidentity.sk + * GitHub Plugin URI: https://github.com/dexerto/on-demand-revalidation + * Description: Next.js On-Demand Revalidation on the post update, revalidate specific paths, tags on the post update. + * Version: 1.2.0 + * Author: Dexerto + * Author URI: https://dexerto.com * Text Domain: on-demand-revalidation * License: GPL-3 * License URI: https://www.gnu.org/licenses/gpl-3.0.html + * + * @package OnDemandRevalidation */ use OnDemandRevalidation\Admin\Settings; @@ -51,9 +53,9 @@ public static function instance(): self { if ( self::$instance->includes() ) { self::$instance->settings(); self::$instance->revalidation(); - self::$instance->pluginLinks(); + self::$instance->plugin_links(); - \OnDemandRevalidation\Helpers::preventWrongApiUrl(); + \OnDemandRevalidation\Helpers::prevent_wrong_api_url(); } } @@ -114,7 +116,7 @@ public function __wakeup() { private function setup_constants(): void { if ( ! function_exists( 'get_plugin_data' ) ) { - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; } // Plugin version. @@ -160,7 +162,7 @@ private function includes(): bool { // Bail if installed incorrectly. if ( ! class_exists( '\OnDemandRevalidation\Admin\Settings' ) ) { - add_action( 'admin_notices', [ $this, 'missing_notice' ] ); + add_action( 'admin_notices', array( $this, 'missing_notice' ) ); return false; } } @@ -211,14 +213,17 @@ private function revalidation(): void { * * @since 0.0.1 */ - private function pluginLinks(): void { + private function plugin_links(): void { // Setup Settings link. - add_filter('plugin_action_links_' . plugin_basename( __FILE__ ), function ( $links ) { - $links[] = 'Settings'; + add_filter( + 'plugin_action_links_' . plugin_basename( __FILE__ ), + function ( $links ) { + $links[] = 'Settings'; - return $links; - }); + return $links; + } + ); } } diff --git a/composer.json b/composer.json index 46a480b..59aa8a5 100644 --- a/composer.json +++ b/composer.json @@ -19,9 +19,9 @@ } }, "require-dev": { - "automattic/vipwpcs": "^2.3", - "dealerdirect/phpcodesniffer-composer-installer": "^0.7", - "phpcompatibility/phpcompatibility-wp": "*" + "squizlabs/php_codesniffer": "^3.9", + "automattic/vipwpcs": "^3.0", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0" }, "scripts": { "phpcs": [ diff --git a/composer.lock b/composer.lock index 011656b..cbb058b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,33 +4,34 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "73dd93049347a923592fffa3f95e8779", + "content-hash": "abe7fdb289c442ae5244023b8c11b676", "packages": [], "packages-dev": [ { "name": "automattic/vipwpcs", - "version": "2.3.3", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/Automattic/VIP-Coding-Standards.git", - "reference": "6cd0a6a82bc0ac988dbf9d6a7c2e293dc8ac640b" + "reference": "1b8960ebff9ea3eb482258a906ece4d1ee1e25fd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Automattic/VIP-Coding-Standards/zipball/6cd0a6a82bc0ac988dbf9d6a7c2e293dc8ac640b", - "reference": "6cd0a6a82bc0ac988dbf9d6a7c2e293dc8ac640b", + "url": "https://api.github.com/repos/Automattic/VIP-Coding-Standards/zipball/1b8960ebff9ea3eb482258a906ece4d1ee1e25fd", + "reference": "1b8960ebff9ea3eb482258a906ece4d1ee1e25fd", "shasum": "" }, "require": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7", "php": ">=5.4", - "sirbrillig/phpcs-variable-analysis": "^2.11.1", - "squizlabs/php_codesniffer": "^3.5.5", - "wp-coding-standards/wpcs": "^2.3" + "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": "^0.5", - "php-parallel-lint/php-parallel-lint": "^1.0", + "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" @@ -50,6 +51,7 @@ "keywords": [ "phpcs", "standards", + "static analysis", "wordpress" ], "support": { @@ -57,39 +59,42 @@ "source": "https://github.com/Automattic/VIP-Coding-Standards", "wiki": "https://github.com/Automattic/VIP-Coding-Standards/wiki" }, - "time": "2021-09-29T16:20:23+00:00" + "time": "2023-09-05T11:01:05+00:00" }, { "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v0.7.2", + "version": "v1.0.0", "source": { "type": "git", - "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", - "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db" + "url": "https://github.com/PHPCSStandards/composer-installer.git", + "reference": "4be43904336affa5c2f70744a348312336afd0da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", - "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", + "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/4be43904336affa5c2f70744a348312336afd0da", + "reference": "4be43904336affa5c2f70744a348312336afd0da", "shasum": "" }, "require": { "composer-plugin-api": "^1.0 || ^2.0", - "php": ">=5.3", + "php": ">=5.4", "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" }, "require-dev": { "composer/composer": "*", + "ext-json": "*", + "ext-zip": "*", "php-parallel-lint/php-parallel-lint": "^1.3.1", - "phpcompatibility/php-compatibility": "^9.0" + "phpcompatibility/php-compatibility": "^9.0", + "yoast/phpunit-polyfills": "^1.0" }, "type": "composer-plugin", "extra": { - "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" }, "autoload": { "psr-4": { - "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -105,7 +110,7 @@ }, { "name": "Contributors", - "homepage": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer/graphs/contributors" + "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors" } ], "description": "PHP_CodeSniffer Standards Composer Installer Plugin", @@ -129,50 +134,49 @@ "tests" ], "support": { - "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", - "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" + "issues": "https://github.com/PHPCSStandards/composer-installer/issues", + "source": "https://github.com/PHPCSStandards/composer-installer" }, - "time": "2022-02-04T12:51:07+00:00" + "time": "2023-01-05T11:28:13+00:00" }, { - "name": "phpcompatibility/php-compatibility", - "version": "9.3.5", + "name": "phpcsstandards/phpcsextra", + "version": "1.2.1", "source": { "type": "git", - "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", - "reference": "9fb324479acf6f39452e0655d2429cc0d3914243" + "url": "https://github.com/PHPCSStandards/PHPCSExtra.git", + "reference": "11d387c6642b6e4acaf0bd9bf5203b8cca1ec489" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243", - "reference": "9fb324479acf6f39452e0655d2429cc0d3914243", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/11d387c6642b6e4acaf0bd9bf5203b8cca1ec489", + "reference": "11d387c6642b6e4acaf0bd9bf5203b8cca1ec489", "shasum": "" }, "require": { - "php": ">=5.3", - "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" - }, - "conflict": { - "squizlabs/php_codesniffer": "2.6.2" + "php": ">=5.4", + "phpcsstandards/phpcsutils": "^1.0.9", + "squizlabs/php_codesniffer": "^3.8.0" }, "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." + "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": "Wim Godden", - "homepage": "https://github.com/wimg", - "role": "lead" - }, { "name": "Juliette Reinders Folmer", "homepage": "https://github.com/jrfnl", @@ -180,156 +184,152 @@ }, { "name": "Contributors", - "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" + "homepage": "https://github.com/PHPCSStandards/PHPCSExtra/graphs/contributors" } ], - "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", - "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", + "description": "A collection of sniffs and standards for use with PHP_CodeSniffer.", "keywords": [ - "compatibility", + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", "phpcs", - "standards" + "standards", + "static analysis" ], "support": { - "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", - "source": "https://github.com/PHPCompatibility/PHPCompatibility" - }, - "time": "2019-12-27T09:44:58+00:00" - }, - { - "name": "phpcompatibility/phpcompatibility-paragonie", - "version": "1.3.1", - "source": { - "type": "git", - "url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git", - "reference": "ddabec839cc003651f2ce695c938686d1086cf43" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/ddabec839cc003651f2ce695c938686d1086cf43", - "reference": "ddabec839cc003651f2ce695c938686d1086cf43", - "shasum": "" - }, - "require": { - "phpcompatibility/php-compatibility": "^9.0" - }, - "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7", - "paragonie/random_compat": "dev-master", - "paragonie/sodium_compat": "dev-master" - }, - "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", - "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + "issues": "https://github.com/PHPCSStandards/PHPCSExtra/issues", + "security": "https://github.com/PHPCSStandards/PHPCSExtra/security/policy", + "source": "https://github.com/PHPCSStandards/PHPCSExtra" }, - "type": "phpcodesniffer-standard", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL-3.0-or-later" - ], - "authors": [ + "funding": [ { - "name": "Wim Godden", - "role": "lead" + "url": "https://github.com/PHPCSStandards", + "type": "github" }, { - "name": "Juliette Reinders Folmer", - "role": "lead" + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" } ], - "description": "A set of rulesets for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by the Paragonie polyfill libraries.", - "homepage": "http://phpcompatibility.com/", - "keywords": [ - "compatibility", - "paragonie", - "phpcs", - "polyfill", - "standards" - ], - "support": { - "issues": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/issues", - "source": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie" - }, - "time": "2021-02-15T10:24:51+00:00" + "time": "2023-12-08T16:49:07+00:00" }, { - "name": "phpcompatibility/phpcompatibility-wp", - "version": "2.1.3", + "name": "phpcsstandards/phpcsutils", + "version": "1.0.10", "source": { "type": "git", - "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git", - "reference": "d55de55f88697b9cdb94bccf04f14eb3b11cf308" + "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", + "reference": "51609a5b89f928e0c463d6df80eb38eff1eaf544" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/d55de55f88697b9cdb94bccf04f14eb3b11cf308", - "reference": "d55de55f88697b9cdb94bccf04f14eb3b11cf308", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/51609a5b89f928e0c463d6df80eb38eff1eaf544", + "reference": "51609a5b89f928e0c463d6df80eb38eff1eaf544", "shasum": "" }, "require": { - "phpcompatibility/php-compatibility": "^9.0", - "phpcompatibility/phpcompatibility-paragonie": "^1.0" + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", + "php": ">=5.4", + "squizlabs/php_codesniffer": "^3.9.0 || 4.0.x-dev@dev" }, "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." + "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": "Wim Godden", + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", "role": "lead" }, { - "name": "Juliette Reinders Folmer", - "role": "lead" + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSUtils/graphs/contributors" } ], - "description": "A ruleset for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by WordPress.", - "homepage": "http://phpcompatibility.com/", + "description": "A suite of utility functions for use with PHP_CodeSniffer", + "homepage": "https://phpcsutils.com/", "keywords": [ - "compatibility", + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", "phpcs", + "phpcs3", "standards", - "wordpress" + "static analysis", + "tokens", + "utility" ], "support": { - "issues": "https://github.com/PHPCompatibility/PHPCompatibilityWP/issues", - "source": "https://github.com/PHPCompatibility/PHPCompatibilityWP" + "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" }, - "time": "2021-12-30T16:37:40+00:00" + "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-03-17T23:44:50+00:00" }, { "name": "sirbrillig/phpcs-variable-analysis", - "version": "v2.11.3", + "version": "v2.11.17", "source": { "type": "git", "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git", - "reference": "c921498b474212fe4552928bbeb68d70250ce5e8" + "reference": "3b71162a6bf0cde2bff1752e40a1788d8273d049" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/c921498b474212fe4552928bbeb68d70250ce5e8", - "reference": "c921498b474212fe4552928bbeb68d70250ce5e8", + "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" + "squizlabs/php_codesniffer": "^3.5.6" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", - "limedeck/phpunit-detailed-printer": "^3.1 || ^4.0 || ^5.0", - "phpstan/phpstan": "^0.11.8", - "phpunit/phpunit": "^5.0 || ^6.5 || ^7.0 || ^8.0", - "sirbrillig/phpcs-import-detection": "^1.1" + "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": { @@ -352,25 +352,29 @@ } ], "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": "2022-02-21T17:01:13+00:00" + "time": "2023-08-05T23:46:11+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.7.0", + "version": "3.9.1", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "a2cd51b45bcaef9c1f2a4bda48f2dd2fa2b95563" + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/a2cd51b45bcaef9c1f2a4bda48f2dd2fa2b95563", - "reference": "a2cd51b45bcaef9c1f2a4bda48f2dd2fa2b95563", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/267a4405fff1d9c847134db3a3c92f1ab7f77909", + "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909", "shasum": "" }, "require": { @@ -380,11 +384,11 @@ "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" }, "bin": [ - "bin/phpcs", - "bin/phpcbf" + "bin/phpcbf", + "bin/phpcs" ], "type": "library", "extra": { @@ -399,48 +403,80 @@ "authors": [ { "name": "Greg Sherwood", - "role": "lead" + "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/squizlabs/PHP_CodeSniffer", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", "keywords": [ "phpcs", - "standards" + "standards", + "static analysis" ], "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + "issues": "https://github.com/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" }, - "time": "2022-06-13T06:31:38+00:00" + "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-03-31T21:03:09+00:00" }, { "name": "wp-coding-standards/wpcs", - "version": "2.3.0", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", - "reference": "7da1894633f168fe244afc6de00d141f27517b62" + "reference": "9333efcbff231f10dfd9c56bb7b65818b4733ca7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/7da1894633f168fe244afc6de00d141f27517b62", - "reference": "7da1894633f168fe244afc6de00d141f27517b62", + "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/9333efcbff231f10dfd9c56bb7b65818b4733ca7", + "reference": "9333efcbff231f10dfd9c56bb7b65818b4733ca7", "shasum": "" }, "require": { + "ext-filter": "*", + "ext-libxml": "*", + "ext-tokenizer": "*", + "ext-xmlreader": "*", "php": ">=5.4", - "squizlabs/php_codesniffer": "^3.3.1" + "phpcsstandards/phpcsextra": "^1.2.1", + "phpcsstandards/phpcsutils": "^1.0.10", + "squizlabs/php_codesniffer": "^3.9.0" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || ^0.6", + "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.0", - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "phpcsstandards/phpcsdevtools": "^1.2.0", + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" }, "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.6 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically." + "ext-iconv": "For improved results", + "ext-mbstring": "For improved results" }, "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", @@ -457,6 +493,7 @@ "keywords": [ "phpcs", "standards", + "static analysis", "wordpress" ], "support": { @@ -464,7 +501,13 @@ "source": "https://github.com/WordPress/WordPress-Coding-Standards", "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" }, - "time": "2020-05-13T23:57:56+00:00" + "funding": [ + { + "url": "https://opencollective.com/php_codesniffer", + "type": "custom" + } + ], + "time": "2024-03-25T16:39:00+00:00" } ], "aliases": [], @@ -474,5 +517,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.6.0" } diff --git a/phpcs.xml.dist b/phpcs.xml.dist index d8d8e04..e1cb527 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,71 +1,19 @@ - - Wordpress Coding Standards - - - - - - - - - - - - - ./on-demand-revalidation.php - ./uninstall.php - ./src - - */node_modules/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + . + + + vendor/* + node_modules/* + + + + + + + + + + + \ No newline at end of file diff --git a/src/Admin/Settings.php b/src/Admin/Settings.php deleted file mode 100644 index f609f85..0000000 --- a/src/Admin/Settings.php +++ /dev/null @@ -1,148 +0,0 @@ -settings_api = new SettingsRegistry(); - add_action( 'admin_menu', [ $this, 'add_options_page' ] ); - add_action( 'init', [ $this, 'register_settings' ] ); - add_action( 'admin_init', [ $this, 'initialize_settings_page' ] ); - - if ( is_admin() ) { - Revalidation::testRevalidationButton(); - } - } - - - /** - * Add the options page to the WP Admin - * - * @return void - */ - public function add_options_page() { - - add_options_page( - __( 'Next.js On-Demand Revalidation', 'on-demand-revalidation' ), - __( 'Next.js On-Demand Revalidation', 'on-demand-revalidation' ), - 'manage_options', - 'on-demand-revalidation', - [ $this, 'render_settings_page' ] - ); - - } - - /** - * Registers the settings fields - * - * @return void - */ - public function register_settings() { - - $this->settings_api->register_section( 'on_demand_revalidation_default_settings', [ - 'title' => __( 'General', 'on-demand-revalidation' ), - ] ); - - $this->settings_api->register_fields( 'on_demand_revalidation_default_settings', [ - [ - 'name' => 'frontend_url', - 'label' => __( 'Next.js URL', 'on-demand-revalidation' ), - 'type' => 'text', - ], - [ - 'name' => 'revalidate_secret_key', - 'label' => __( 'Revalidate Secret Key', 'on-demand-revalidation' ), - 'type' => 'password', - ], - ] ); - - $this->settings_api->register_section( 'on_demand_revalidation_post_update_settings', [ - 'title' => __( 'On post update', 'on-demand-revalidation' ), - 'desc' => __( 'On post update is current page revalidated automatically.', 'on-demand-revalidation' ), - ] ); - - $this->settings_api->register_fields( 'on_demand_revalidation_post_update_settings', [ - [ - 'name' => 'revalidate_homepage', - 'desc' => __( 'Revalidate Homepage on post update', 'on-demand-revalidation' ), - 'type' => 'checkbox', - 'default' => 'on', - ], - [ - 'name' => 'disable_cron', - 'desc' => __( "Disable scheduled revalidation. Revalidation triggered immediately without using WP-Cron. It'll slow down post update.", 'on-demand-revalidation' ), - 'type' => 'checkbox', - ], - [ - 'name' => 'revalidate_paths', - 'label' => __( 'Additional paths to revalidate on Post update', 'on-demand-revalidation' ), - 'desc' => 'One path per row.

Available current Post placeholders:
%slug% %author_nicename% %author_username% %category% %post_tag% %custom_taxonomy%

Note: Replace %custom_taxonomy% with your custom taxonomy name.', - 'placeholder' => '/category/%category%', - 'type' => 'textarea', - ], - [ - 'name' => 'test-config', - 'label' => __( 'Test your config:', 'on-demand-revalidation' ), - 'desc' => 'Revalidate Latest Post', - 'type' => 'html', - ], - ] ); - - } - - /** - * Initialize the settings admin page - * - * @return void - */ - public function initialize_settings_page() { - $this->settings_api->admin_init(); - } - - /** - * Render the settings page in the admin - * - * @return void - */ - public function render_settings_page() { - if ( ! current_user_can( 'manage_options' ) ) { - wp_die( esc_html__( 'You do not have sufficient permissions to access this page.' ) ); - } - - ?> -
- Next.js On-Demand Revalidation'; - $this->settings_api->show_navigation(); - $this->settings_api->show_forms(); - ?> -
- settings_api = new SettingsRegistry(); + add_action( 'admin_menu', array( $this, 'add_options_page' ) ); + add_action( 'init', array( $this, 'register_settings' ) ); + add_action( 'admin_init', array( $this, 'initialize_settings_page' ) ); + + if ( is_admin() ) { + Revalidation::test_revalidation_button(); + } + } + + + /** + * Add the options page to the WP Admin + * + * @return void + */ + public function add_options_page() { + + add_options_page( + __( 'Next.js On-Demand Revalidation', 'on-demand-revalidation' ), + __( 'Next.js On-Demand Revalidation', 'on-demand-revalidation' ), + 'manage_options', + 'on-demand-revalidation', + array( $this, 'render_settings_page' ) + ); + } + + /** + * Registers the settings fields + * + * @return void + */ + public function register_settings() { + + $this->settings_api->register_section( + 'on_demand_revalidation_default_settings', + array( + 'title' => __( 'General', 'on-demand-revalidation' ), + ) + ); + + $this->settings_api->register_fields( + 'on_demand_revalidation_default_settings', + array( + array( + 'name' => 'frontend_url', + 'label' => __( 'Next.js URL', 'on-demand-revalidation' ), + 'type' => 'text', + ), + array( + 'name' => 'revalidate_secret_key', + 'label' => __( 'Revalidate Secret Key', 'on-demand-revalidation' ), + 'type' => 'password', + ), + ) + ); + + $this->settings_api->register_section( + 'on_demand_revalidation_post_update_settings', + array( + 'title' => __( 'On post update', 'on-demand-revalidation' ), + 'desc' => __( 'On post update is current page revalidated automatically.', 'on-demand-revalidation' ), + ) + ); + + $this->settings_api->register_fields( + 'on_demand_revalidation_post_update_settings', + array( + array( + 'name' => 'revalidate_homepage', + 'desc' => __( 'Revalidate Homepage on post update', 'on-demand-revalidation' ), + 'type' => 'checkbox', + 'default' => 'on', + ), + array( + 'name' => 'disable_cron', + 'desc' => __( "Disable scheduled revalidation. Revalidation triggered immediately without using WP-Cron. It'll slow down post update.", 'on-demand-revalidation' ), + 'type' => 'checkbox', + ), + array( + 'name' => 'revalidate_paths', + 'label' => __( 'Additional paths to revalidate on Post update', 'on-demand-revalidation' ), + 'desc' => 'One path per row.

Available current Post placeholders:
%slug% %author_nicename% %author_username% %category% %post_tag% %custom_taxonomy%

Note: Replace %custom_taxonomy% with your custom taxonomy name.', + 'placeholder' => '/category/%category%', + 'type' => 'textarea', + ), + + array( + 'name' => 'revalidate_tags', + 'label' => __( 'Tags to revalidate on Post update', 'on-demand-revalidation' ), + 'desc' => 'Enter each tag on a new line, using placeholders like {databaseId}, {id}, {category}. Placeholders will be replaced with actual values from the post during revalidation.', + 'type' => 'textarea', + ), + + array( + 'name' => 'test-config', + 'label' => __( 'Test your config:', 'on-demand-revalidation' ), + 'desc' => 'Revalidate Latest Post', + 'type' => 'html', + ), + ) + ); + } + + /** + * Initialize the settings admin page + * + * @return void + */ + public function initialize_settings_page() { + $this->settings_api->admin_init(); + } + + /** + * Render the settings page in the admin + * + * @return void + */ + public function render_settings_page() { + if ( ! current_user_can( 'manage_options' ) ) { + wp_die( esc_html__( 'You do not have sufficient permissions to access this page.' ) ); + } + + ?> +
+ Next.js On-Demand Revalidation'; + $this->settings_api->show_navigation(); + $this->settings_api->show_forms(); + ?> +
+ settings_sections[ $slug ] = $section; @@ -84,12 +92,12 @@ function register_section( string $slug, array $section ) { /** * Register fields to a section * - * @param string $section The slug of the section to register a field to - * @param array $fields settings fields array + * @param string $section The slug of the section to register a field to. + * @param array $fields settings fields array. * * @return SettingsRegistry */ - function register_fields( string $section, array $fields ) { + public function register_fields( string $section, array $fields ) { foreach ( $fields as $field ) { $this->register_field( $section, $field ); } @@ -100,25 +108,25 @@ function register_fields( string $section, array $fields ) { /** * Register a field to a section * - * @param string $section The slug of the section to register a field to - * @param array $field The config for the field being registered + * @param string $section The slug of the section to register a field to. + * @param array $field The config for the field being registered. * * @return SettingsRegistry */ - function register_field( string $section, array $field ) { - $defaults = [ + public function register_field( string $section, array $field ) { + $defaults = array( 'name' => '', 'label' => '', 'desc' => '', 'type' => 'text', - ]; + ); $field_config = wp_parse_args( $field, $defaults ); // Get the field name before the filter is passed. $field_name = $field_config['name']; - // Unset it, as we don't want it to be filterable + // Unset it, as we don't want it to be filterable. unset( $field_config['name'] ); /** @@ -130,10 +138,10 @@ function register_field( string $section, array $field ) { */ $field = apply_filters( 'on_demand_revalidation_setting_field_config', $field_config, $field_name, $section ); - // Add the field name back after the filter has been applied + // Add the field name back after the filter has been applied. $field['name'] = $field_name; - // Add the field to the section + // Add the field to the section. $this->settings_fields[ $section ][] = $field; return $this; @@ -149,9 +157,9 @@ function register_field( string $section, array $field ) { * * @return void */ - function admin_init() { + public function admin_init() { - // Action that fires when settings are being initialized + // Action that fires when settings are being initialized. do_action( 'on_demand_revalidation_init_settings', $this ); /** @@ -180,19 +188,19 @@ function admin_init() { add_settings_section( $id, $section['title'], $callback, $id ); } - //register settings fields + // register settings fields. foreach ( $this->settings_fields as $section => $field ) { foreach ( $field as $option ) { $name = $option['name']; $type = isset( $option['type'] ) ? $option['type'] : 'text'; $label = isset( $option['label'] ) ? $option['label'] : ''; - $callback = isset( $option['callback'] ) ? $option['callback'] : [ + $callback = isset( $option['callback'] ) ? $option['callback'] : array( $this, 'callback_' . $type, - ]; + ); - $args = [ + $args = array( 'id' => $name, 'class' => isset( $option['class'] ) ? $option['class'] : $name, 'label_for' => "{$section}[{$name}]", @@ -210,22 +218,22 @@ function admin_init() { 'step' => isset( $option['step'] ) ? $option['step'] : '', 'disabled' => isset( $option['disabled'] ) ? (bool) $option['disabled'] : false, 'value' => isset( $option['value'] ) ? $option['value'] : null, - ]; + ); add_settings_field( "{$section}[{$name}]", $label, $callback, $section, $section, $args ); } } - // creates our settings in the options table + // creates our settings in the options table. foreach ( $this->settings_sections as $id => $section ) { - register_setting( $id, $id, [ $this, 'sanitize_options' ] ); + register_setting( $id, $id, array( $this, 'sanitize_options' ) ); } } /** * Get field description for display * - * @param array $args settings field args + * @param array $args settings field args. * * @return string */ @@ -242,11 +250,11 @@ public function get_field_description( array $args ): string { /** * Displays a text field for a settings field * - * @param array $args settings field args + * @param array $args settings field args. * * @return void */ - function callback_text( array $args ) { + public function callback_text( array $args ) { $value = isset( $args['value'] ) && ! empty( $args['value'] ) ? esc_attr( $args['value'] ) : esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) ); $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular'; $type = isset( $args['type'] ) ? $args['type'] : 'text'; @@ -261,22 +269,22 @@ function callback_text( array $args ) { /** * Displays a url field for a settings field * - * @param array $args settings field args + * @param array $args settings field args. * * @return void */ - function callback_url( array $args ) { + public function callback_url( array $args ) { $this->callback_text( $args ); } /** * Displays a number field for a settings field * - * @param array $args settings field args + * @param array $args settings field args. * * @return void */ - function callback_number( array $args ) { + public function callback_number( array $args ) { $value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) ); $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular'; $type = isset( $args['type'] ) ? $args['type'] : 'number'; @@ -294,11 +302,11 @@ function callback_number( array $args ) { /** * Displays a checkbox for a settings field * - * @param array $args settings field args + * @param array $args settings field args. * * @return void */ - function callback_checkbox( array $args ) { + public function callback_checkbox( array $args ) { $value = isset( $args['value'] ) && ! empty( $args['value'] ) ? esc_attr( $args['value'] ) : esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) ); $disabled = isset( $args['disabled'] ) && true === $args['disabled'] ? 'disabled' : null; @@ -316,11 +324,11 @@ function callback_checkbox( array $args ) { /** * Displays a multicheckbox for a settings field * - * @param array $args settings field args + * @param array $args settings field args. * * @return void */ - function callback_multicheck( array $args ) { + public function callback_multicheck( array $args ) { $value = $this->get_option( $args['id'], $args['section'], $args['std'] ); $html = '
'; @@ -341,11 +349,11 @@ function callback_multicheck( array $args ) { /** * Displays a radio button for a settings field * - * @param array $args settings field args + * @param array $args settings field args. * * @return void */ - function callback_radio( array $args ) { + public function callback_radio( array $args ) { $value = $this->get_option( $args['id'], $args['section'], $args['std'] ); $html = '
'; @@ -365,11 +373,11 @@ function callback_radio( array $args ) { /** * Displays a selectbox for a settings field * - * @param array $args settings field args + * @param array $args settings field args. * * @return void */ - function callback_select( array $args ) { + public function callback_select( array $args ) { $value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) ); $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular'; @@ -388,11 +396,11 @@ function callback_select( array $args ) { /** * Displays a textarea for a settings field * - * @param array $args settings field args + * @param array $args settings field args. * * @return void */ - function callback_textarea( array $args ) { + public function callback_textarea( array $args ) { $value = esc_textarea( $this->get_option( $args['id'], $args['section'], $args['std'] ) ); $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular'; @@ -407,33 +415,33 @@ function callback_textarea( array $args ) { /** * Displays the html for a settings field * - * @param array $args settings field args + * @param array $args settings field args. * * @return void */ - function callback_html( array $args ) { + public function callback_html( array $args ) { echo wp_kses( $this->get_field_description( $args ), $this->get_allowed_wp_kses_html() ); } /** * Displays a rich text textarea for a settings field * - * @param array $args settings field args + * @param array $args settings field args. * * @return void */ - function callback_wysiwyg( array $args ) { + public function callback_wysiwyg( array $args ) { $value = $this->get_option( $args['id'], $args['section'], $args['std'] ); $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : '500px'; echo '
'; - $editor_settings = [ + $editor_settings = array( 'teeny' => true, 'textarea_name' => $args['section'] . '[' . $args['id'] . ']', 'textarea_rows' => 10, - ]; + ); if ( isset( $args['options'] ) && is_array( $args['options'] ) ) { $editor_settings = array_merge( $editor_settings, $args['options'] ); @@ -449,15 +457,16 @@ function callback_wysiwyg( array $args ) { /** * Displays a file upload field for a settings field * - * @param array $args settings field args + * @param array $args settings field args. * * @return void */ - function callback_file( array $args ) { + public function callback_file( array $args ) { $value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) ); $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular'; $id = $args['section'] . '[' . $args['id'] . ']'; + unset( $id ); $label = isset( $args['options']['button_label'] ) ? $args['options']['button_label'] : __( 'Choose File' ); $html = sprintf( '', $size, $args['section'], $args['id'], $value ); @@ -470,11 +479,11 @@ function callback_file( array $args ) { /** * Displays a password field for a settings field * - * @param array $args settings field args + * @param array $args settings field args. * * @return void */ - function callback_password( array $args ) { + public function callback_password( array $args ) { $value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) ); $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular'; @@ -488,11 +497,11 @@ function callback_password( array $args ) { /** * Displays a color picker field for a settings field * - * @param array $args settings field args + * @param array $args settings field args. * * @return void */ - function callback_color( $args ) { + public function callback_color( $args ) { $value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) ); $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular'; @@ -507,26 +516,29 @@ function callback_color( $args ) { /** * Displays a select box for creating the pages select box * - * @param array $args settings field args + * @param array $args settings field args. * * @return void */ - function callback_pages( array $args ) { + public function callback_pages( array $args ) { - $dropdown_args = array_merge( [ - 'selected' => esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) ), - 'name' => $args['section'] . '[' . $args['id'] . ']', - 'id' => $args['section'] . '[' . $args['id'] . ']', - 'echo' => 0, - ], $args ); + $dropdown_args = array_merge( + array( + 'selected' => esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) ), + 'name' => $args['section'] . '[' . $args['id'] . ']', + 'id' => $args['section'] . '[' . $args['id'] . ']', + 'echo' => 0, + ), + $args + ); - $clean_args = []; + $clean_args = array(); foreach ( $dropdown_args as $key => $arg ) { $clean_args[ $key ] = wp_kses( $arg, $this->get_allowed_wp_kses_html() ); } // Ignore phpstan as this is providing an array as expected - // @phpstan-ignore-next-line + // @phpstan-ignore-next-line. // phpcs:ignore echo wp_dropdown_pages( $clean_args ); } @@ -534,11 +546,11 @@ function callback_pages( array $args ) { /** * Displays a select box for user roles * - * @param array $args settings field args + * @param array $args settings field args. * * @return void */ - function callback_user_role_select( array $args ) { + public function callback_user_role_select( array $args ) { $selected = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) ); if ( empty( $selected ) ) { @@ -558,11 +570,11 @@ function callback_user_role_select( array $args ) { /** * Sanitize callback for Settings API * - * @param array $options + * @param array $options array options. * * @return mixed */ - function sanitize_options( array $options ) { + public function sanitize_options( array $options ) { if ( ! $options ) { return $options; @@ -571,7 +583,7 @@ function sanitize_options( array $options ) { foreach ( $options as $option_slug => $option_value ) { $sanitize_callback = $this->get_sanitize_callback( $option_slug ); - // If callback is set, call it + // If callback is set, call it. if ( $sanitize_callback ) { $options[ $option_slug ] = call_user_func( $sanitize_callback, $option_value ); continue; @@ -584,23 +596,24 @@ function sanitize_options( array $options ) { /** * Get sanitization callback for given option slug * - * @param string $slug option slug + * @param string $slug option slug. * - * @return mixed string or bool false + * @return mixed string or bool false. */ - function get_sanitize_callback( $slug = '' ) { + public function get_sanitize_callback( $slug = '' ) { if ( empty( $slug ) ) { return false; } - // Iterate over registered fields and see if we can find proper callback + // Iterate over registered fields and see if we can find proper callback. foreach ( $this->settings_fields as $section => $options ) { + unset( $section ); foreach ( $options as $option ) { if ( $slug !== $option['name'] ) { continue; } - // Return the callback name + // Return the callback name. return isset( $option['sanitize_callback'] ) && is_callable( $option['sanitize_callback'] ) ? $option['sanitize_callback'] : false; } } @@ -611,13 +624,13 @@ function get_sanitize_callback( $slug = '' ) { /** * Get the value of a settings field * - * @param string $option settings field name - * @param string $section the section name this field belongs to - * @param string $default default text if it's not found + * @param string $option settings field name. + * @param string $section the section name this field belongs to. + * @param string $default_value default text if it's not found. * * @return string */ - function get_option( $option, $section, $default = '' ) { + public function get_option( $option, $section, $default_value = '' ) { $options = get_option( $section ); @@ -625,7 +638,7 @@ function get_option( $option, $section, $default = '' ) { return $options[ $option ]; } - return $default; + return $default_value; } /** @@ -635,12 +648,12 @@ function get_option( $option, $section, $default = '' ) { * * @return void */ - function show_navigation() { + public function show_navigation() { $html = '