Changeset 3280737
- Timestamp:
- 04/24/2025 09:34:20 AM (11 months ago)
- Location:
- on-demand-revalidation
- Files:
-
- 62 added
- 18 edited
- 1 copied
-
tags/1.3.0 (copied) (copied from on-demand-revalidation/trunk)
-
tags/1.3.0/.devcontainer (added)
-
tags/1.3.0/.devcontainer/Dockerfile (added)
-
tags/1.3.0/.devcontainer/data (added)
-
tags/1.3.0/.devcontainer/data/plugins (added)
-
tags/1.3.0/.devcontainer/data/plugins/.keep (added)
-
tags/1.3.0/.devcontainer/devcontainer.json (added)
-
tags/1.3.0/.devcontainer/docker-compose.yml (added)
-
tags/1.3.0/.devcontainer/git-setup.sh (added)
-
tags/1.3.0/.devcontainer/setup-post-types.sh (added)
-
tags/1.3.0/.devcontainer/wp-setup.sh (added)
-
tags/1.3.0/.eslintignore (added)
-
tags/1.3.0/.eslintrc.js (added)
-
tags/1.3.0/.husky (added)
-
tags/1.3.0/.husky/commit-msg (added)
-
tags/1.3.0/.husky/pre-commit (added)
-
tags/1.3.0/.prettierignore (added)
-
tags/1.3.0/.prettierrc.js (added)
-
tags/1.3.0/.stylelintignore (added)
-
tags/1.3.0/.stylelintrc.js (added)
-
tags/1.3.0/.vscode (added)
-
tags/1.3.0/.vscode/launch.json (added)
-
tags/1.3.0/commitlint.config.js (added)
-
tags/1.3.0/on-demand-revalidation.php (modified) (5 diffs)
-
tags/1.3.0/package-lock.json (added)
-
tags/1.3.0/package.json (added)
-
tags/1.3.0/phpunit.xml.dist (added)
-
tags/1.3.0/readme.txt (modified) (3 diffs)
-
tags/1.3.0/src/Admin/Settings.php (modified) (4 diffs)
-
tags/1.3.0/src/Revalidation.php (modified) (8 diffs)
-
tags/1.3.0/tests (added)
-
tags/1.3.0/tests/bootstrap.php (added)
-
tags/1.3.0/tests/test_revalidation.php (added)
-
tags/1.3.0/tsconfig.json (added)
-
tags/1.3.0/vendor/autoload.php (modified) (1 diff)
-
tags/1.3.0/vendor/composer/InstalledVersions.php (modified) (4 diffs)
-
tags/1.3.0/vendor/composer/autoload_real.php (modified) (2 diffs)
-
tags/1.3.0/vendor/composer/autoload_static.php (modified) (2 diffs)
-
tags/1.3.0/vendor/composer/installed.php (modified) (2 diffs)
-
tags/1.3.0/vendor/composer/platform_check.php (added)
-
tags/1.3.0/webpack.config.js (added)
-
trunk/.devcontainer (added)
-
trunk/.devcontainer/Dockerfile (added)
-
trunk/.devcontainer/data (added)
-
trunk/.devcontainer/data/plugins (added)
-
trunk/.devcontainer/data/plugins/.keep (added)
-
trunk/.devcontainer/devcontainer.json (added)
-
trunk/.devcontainer/docker-compose.yml (added)
-
trunk/.devcontainer/git-setup.sh (added)
-
trunk/.devcontainer/setup-post-types.sh (added)
-
trunk/.devcontainer/wp-setup.sh (added)
-
trunk/.eslintignore (added)
-
trunk/.eslintrc.js (added)
-
trunk/.husky (added)
-
trunk/.husky/commit-msg (added)
-
trunk/.husky/pre-commit (added)
-
trunk/.prettierignore (added)
-
trunk/.prettierrc.js (added)
-
trunk/.stylelintignore (added)
-
trunk/.stylelintrc.js (added)
-
trunk/.vscode (added)
-
trunk/.vscode/launch.json (added)
-
trunk/commitlint.config.js (added)
-
trunk/on-demand-revalidation.php (modified) (5 diffs)
-
trunk/package-lock.json (added)
-
trunk/package.json (added)
-
trunk/phpunit.xml.dist (added)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/src/Admin/Settings.php (modified) (4 diffs)
-
trunk/src/Revalidation.php (modified) (8 diffs)
-
trunk/tests (added)
-
trunk/tests/bootstrap.php (added)
-
trunk/tests/test_revalidation.php (added)
-
trunk/tsconfig.json (added)
-
trunk/vendor/autoload.php (modified) (1 diff)
-
trunk/vendor/composer/InstalledVersions.php (modified) (4 diffs)
-
trunk/vendor/composer/autoload_real.php (modified) (2 diffs)
-
trunk/vendor/composer/autoload_static.php (modified) (2 diffs)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/vendor/composer/platform_check.php (added)
-
trunk/webpack.config.js (added)
Legend:
- Unmodified
- Added
- Removed
-
on-demand-revalidation/tags/1.3.0/on-demand-revalidation.php
r3225736 r3280737 7 7 * GitHub Plugin URI: https://github.com/dexerto/on-demand-revalidation 8 8 * Description: Next.js On-Demand Revalidation on the post update, revalidate specific paths, tags on the post update. 9 * Version: 1. 2.59 * Version: 1.3.0 10 10 * Author: Dexerto 11 11 * Author URI: https://dexerto.com … … 13 13 * License: GPL-3 14 14 * License URI: https://www.gnu.org/licenses/gpl-3.0.html 15 * 15 * 16 16 * @package OnDemandRevalidation 17 17 */ … … 55 55 self::$instance->revalidation(); 56 56 self::$instance->plugin_links(); 57 self::$instance->load_textdomain(); 57 58 58 59 \OnDemandRevalidation\Helpers::prevent_wrong_api_url(); … … 122 123 // Plugin version. 123 124 if ( ! defined( 'ON_DEMAND_REVALIDATION_VERSION' ) ) { 124 define( 'ON_DEMAND_REVALIDATION_VERSION', get_plugin_data( __FILE__ )['Version'] ); 125 $plugin_data = get_file_data( __FILE__, array( 'Version' => 'Version' ) ); 126 define( 'ON_DEMAND_REVALIDATION_VERSION', $plugin_data['Version'] ); 125 127 } 126 128 … … 226 228 ); 227 229 } 230 231 /** 232 * Load plugin text domain. 233 * 234 * @since 1.3.0 235 */ 236 private function load_textdomain(): void { 237 add_action( 238 'init', 239 function () { 240 load_plugin_textdomain( 'on-demand-revalidation', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); 241 } 242 ); 243 } 228 244 } 229 245 -
on-demand-revalidation/tags/1.3.0/readme.txt
r3225736 r3280737 2 2 Contributors: bebjakub 3 3 Tags: nextjs, ssg, revalidation, on-demand 4 Requires at least: 4.75 Tested up to: 6.7. 16 Stable tag: 1. 2.54 Requires at least: 6.0.0 5 Tested up to: 6.7.2 6 Stable tag: 1.3.0 7 7 Requires PHP: 8.0 8 8 License: GPL-3 … … 11 11 === Description === 12 12 13 Next.js On-Demand Revalidation for Wordpress on the post update, revalidate specific paths and tags on the post update.13 Next.js On-Demand Revalidation for Wordpress on post updates, revalidate specific paths and tags on post updates. 14 14 15 15 Feel free to create a PR to [plugin Github repo](https://github.com/Dexerto/on-demand-revalidation). … … 25 25 26 26 == Changelog == 27 = 1.3.0 = 28 - feat: Add ability to provide custom paths and tags per post type from @MuhammedAO 29 - fix: prevent locales from being loaded too early @humet 27 30 = 1.2.5 = 28 31 - feat: prevent revalidate functions from running more than once within a single save_post request from @MuhammedAO -
on-demand-revalidation/tags/1.3.0/src/Admin/Settings.php
r3073849 r3280737 69 69 */ 70 70 public function register_settings() { 71 $tag_desc = 'One tag per row.<br/><br/><i>Available current placeholders:</i><br/><code>%slug%</code> <code>%author_nicename%</code> <code>%author_username%</code> <code>%category%</code> <code>%post_tag%</code><code>%database_id%</code> <code>%id%</code> <code>%custom_taxonomy%</code><br/><br/><i>Note:</i> Replace <code>%custom_taxonomy%</code> with your custom taxonomy name.'; 71 72 72 73 $this->settings_api->register_section( … … 74 75 array( 75 76 'title' => __( 'General', 'on-demand-revalidation' ), 76 ) 77 ) 77 78 ); 78 79 … … 90 91 'type' => 'password', 91 92 ), 92 ) 93 ); 94 95 $this->settings_api->register_section( 96 'on_demand_revalidation_post_update_settings', 97 array( 98 'title' => __( 'On post update', 'on-demand-revalidation' ), 99 'desc' => __( 'On post update is current page revalidated automatically.', 'on-demand-revalidation' ), 100 ) 101 ); 102 103 $this->settings_api->register_fields( 104 'on_demand_revalidation_post_update_settings', 105 array( 106 array( 107 'name' => 'revalidate_homepage', 108 'desc' => __( 'Revalidate Homepage on post update', 'on-demand-revalidation' ), 109 'type' => 'checkbox', 110 'default' => 'on', 111 ), 93 112 94 array( 113 95 'name' => 'disable_cron', 114 96 'desc' => __( "<b>Disable scheduled revalidation.</b> Revalidation triggered immediately without using WP-Cron. It'll slow down post update.", 'on-demand-revalidation' ), 115 97 'type' => 'checkbox', 116 ),117 array(118 'name' => 'revalidate_paths',119 'label' => __( 'Additional paths to revalidate on Post update', 'on-demand-revalidation' ),120 'desc' => 'One path per row.',121 'placeholder' => '/category/%category%',122 'type' => 'textarea',123 ),124 125 array(126 'name' => 'revalidate_tags',127 'label' => __( 'Tags to revalidate on Post update', 'on-demand-revalidation' ),128 'desc' => 'One tag per row.<br/><br/><i>Available current Post placeholders:</i><br/><code>%slug%</code> <code>%author_nicename%</code> <code>%author_username%</code> <code>%category%</code> <code>%post_tag%</code><code>%database_id%</code> <code>%id%</code> <code>%custom_taxonomy%</code><br/><br/><i>Note:</i> Replace <code>%custom_taxonomy%</code> with your custom taxonomy name.',129 'placeholder' => '%databaseid%',130 'type' => 'textarea',131 98 ), 132 99 … … 137 104 'type' => 'html', 138 105 ), 139 ) 140 ); 106 ) 107 ); 108 109 $this->settings_api->register_section( 110 'on_demand_revalidation_post_update_settings', 111 array( 112 'title' => __( 'All Settings', 'on-demand-revalidation' ), 113 'desc' => __( 'Revalidation settings for all post types.', 'on-demand-revalidation' ), 114 ) 115 ); 116 117 $this->settings_api->register_fields( 118 'on_demand_revalidation_post_update_settings', 119 array( 120 array( 121 'name' => 'revalidate_homepage', 122 'desc' => __( 'Revalidate homepage on all post updates', 'on-demand-revalidation' ), 123 'type' => 'checkbox', 124 'default' => 'on', 125 ), 126 127 array( 128 'name' => 'revalidate_paths', 129 'label' => __( 'Paths to revalidate on all updates', 'on-demand-revalidation' ), 130 'desc' => 'One path per row.', 131 'placeholder' => '/category/%category%', 132 'type' => 'textarea', 133 ), 134 135 array( 136 'name' => 'revalidate_tags', 137 'label' => __( 'Tags to revalidate on all updates', 'on-demand-revalidation' ), 138 'desc' => $tag_desc, 139 'placeholder' => '%databaseid%', 140 'type' => 'textarea', 141 ), 142 143 144 ) 145 ); 146 147 $post_types = get_post_types( array( 'public' => true ), 'objects' ); 148 foreach ( $post_types as $post_type_obj ) { 149 150 if ( 'attachment' === $post_type_obj->name ) { 151 continue; 152 } 153 $section_id = 'on_demand_revalidation_' . $post_type_obj->name . '_settings'; 154 $this->settings_api->register_section( 155 $section_id, 156 array( 157 // translators: %s: plural name of the post type, e.g. "Posts" or "Books". 158 'title' => sprintf( __( '%s Settings', 'on-demand-revalidation', ), $post_type_obj->labels->name ), 159 // translators: %s: singular name of the post type, e.g. "Post" or "Book". 160 'desc' => sprintf( __( 'Revalidation settings specific to %s posts.', 'on-demand-revalidation', ), $post_type_obj->labels->singular_name ), 161 ) 162 ); 163 $this->settings_api->register_fields( 164 $section_id, 165 array( 166 array( 167 'name' => 'revalidate_enabled_' . $post_type_obj->name, 168 // translators: %s: singular post type name, used in the checkbox label. 169 'desc' => sprintf( __( 'Enable revalidation for %s', 'on-demand-revalidation' ), $post_type_obj->labels->singular_name ), 170 'type' => 'checkbox', 171 'default' => 'on', 172 ), 173 array( 174 'name' => 'revalidate_homepage_' . $post_type_obj->name, 175 // translators: %s: singular post type name, used in the textarea label. 176 'desc' => sprintf( __( 'Revalidate Homepage on all updates for %s', 'on-demand-revalidation' ), $post_type_obj->labels->singular_name ), 177 'type' => 'checkbox', 178 'default' => 'on', 179 ), 180 array( 181 'name' => 'revalidate_paths_' . $post_type_obj->name, 182 // translators: %s: singular post type name, used in the textarea label. 183 'label' => sprintf( __( 'Additional paths for %s', 'on-demand-revalidation' ), $post_type_obj->labels->singular_name ), 184 'desc' => __( 'One path per row. Leave empty if not applicable.', 'on-demand-revalidation' ), 185 'placeholder' => '/custom/path/$placeholder%/', 186 'type' => 'textarea', 187 ), 188 array( 189 'name' => 'revalidate_tags_' . $post_type_obj->name, 190 // translators: %s: singular post type name, used in the textarea label. 191 'label' => sprintf( __( 'Tags for %s', 'on-demand-revalidation' ), $post_type_obj->labels->singular_name ), 192 'desc' => $tag_desc, 193 'placeholder' => '%slug%', 194 'type' => 'textarea', 195 ), 196 ) 197 ); 198 } 141 199 } 142 200 -
on-demand-revalidation/tags/1.3.0/src/Revalidation.php
r3225736 r3280737 44 44 return; 45 45 } 46 46 47 47 $old_permalink = get_permalink( $post_ID ); 48 48 update_post_meta( $post_ID, '_old_permalink', $old_permalink ); … … 66 66 public static function handle_save_post( $post_id, $post ) { 67 67 $excluded_statuses = array( 'auto-draft', 'inherit', 'draft', 'trash' ); 68 68 69 69 if ( isset( $post->post_status ) && in_array( $post->post_status, $excluded_statuses, true ) ) { 70 70 return; 71 71 } 72 72 73 73 if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { 74 74 return; 75 75 } 76 76 77 77 if ( false !== wp_is_post_revision( $post_id ) ) { 78 78 return; 79 79 } 80 80 81 if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {82 return;83 }84 85 81 self::revalidate_post( $post ); 86 82 } … … 99 95 self::revalidate_post( $post ); 100 96 } 101 } 97 } 102 98 103 99 /** … … 129 125 } 130 126 127 $post_type = $post->post_type; 128 129 // Check if revalidation is enabled for this post type. 130 $individual_toggle = Settings::get( 'revalidate_enabled_' . $post_type, 'on', 'on_demand_revalidation_' . $post_type . '_settings' ); 131 if ( 'on' !== $individual_toggle ) { 132 return (object) array( 133 'success' => false, 134 // translators: %s: post type slug, e.g. "post" or "page". 135 'message' => sprintf( __( 'Revalidation is disabled for %s.', 'on-demand-revalidation' ), $post_type ), 136 ); 137 } 138 131 139 $paths = array(); 132 140 133 if ( Settings::get( 'revalidate_homepage', 'on', 'on_demand_revalidation_post_update_settings' ) === 'on' ) { 141 $individual_homepage = Settings::get( 'revalidate_homepage_' . $post_type, null, 'on_demand_revalidation_' . $post_type . '_settings' ); 142 143 if ( null === $individual_homepage ) { 144 // no per‑type override, use global. 145 $home_enabled = ( 146 Settings::get( 147 'revalidate_homepage', 148 'on', 149 'on_demand_revalidation_post_update_settings' 150 ) === 'on' 151 ); 152 } else { 153 // use per‑type setting. 154 $home_enabled = ( 'on' === $individual_homepage ); 155 } 156 157 if ( $home_enabled ) { 134 158 $paths[] = '/'; 135 159 } 160 136 161 137 162 $post_permalink = get_permalink( $post ); … … 148 173 if ( ! empty( $old_permalink ) ) { 149 174 $parse_old_permalink = wp_parse_url( $old_permalink ); 150 175 151 176 if ( isset( $parse_old_permalink['path'] ) && '/' !== $parse_old_permalink['path'] ) { 152 177 $old_page_path = substr( $parse_old_permalink['path'], -1 ) === '/' ? substr( $parse_old_permalink['path'], 0, -1 ) : $parse_old_permalink['path']; … … 158 183 159 184 $revalidate_paths = trim( Settings::get( 'revalidate_paths', '', 'on_demand_revalidation_post_update_settings' ) ); 160 185 161 186 if ( ! empty( $revalidate_paths ) ) { 162 187 $revalidate_paths = preg_split( '/\r\n|\n|\r/', $revalidate_paths ); … … 181 206 } 182 207 208 // per‑post‑type additional paths. 209 $post_type_raw_paths = Settings::get( 'revalidate_paths_' . $post_type, '', 'on_demand_revalidation_' . $post_type . '_settings' ); 210 if ( ! empty( $post_type_raw_paths ) ) { 211 $post_type_defined_paths = preg_split( '/\r\n|\n|\r/', $post_type_raw_paths ); 212 $post_type_defined_paths = Helpers::rewrite_placeholders( $post_type_defined_paths, $post ); 213 foreach ( $post_type_defined_paths as $path ) { 214 if ( str_starts_with( $path, '/' ) ) { 215 $paths[] = $path; 216 } 217 } 218 } 219 183 220 $paths = apply_filters( 'on_demand_revalidation_paths', $paths, $post ); 184 $tags = apply_filters( 'on_demand_revalidation_tags', $tags, $post ); 221 222 223 224 // per‑post‑type additional tags. 225 $post_type_raw_tags = Settings::get( 'revalidate_tags_' . $post_type, '', 'on_demand_revalidation_' . $post_type . '_settings' ); 226 if ( ! empty( $post_type_raw_tags ) ) { 227 $post_type_defined_tags = preg_split( '/\r\n|\n|\r/', $post_type_raw_tags ); 228 $post_type_defined_tags = Helpers::rewrite_placeholders( $post_type_defined_tags, $post ); 229 $tags = array_merge( $tags, $post_type_defined_tags ); 230 } 231 232 $tags = apply_filters( 'on_demand_revalidation_tags', $tags, $post ); 185 233 186 234 $data = array( 187 235 'postId' => $post->ID, 188 236 ); 189 237 190 238 if ( ! empty( $paths ) ) { 191 239 $data['paths'] = $paths; 192 240 } 193 241 194 242 if ( ! empty( $tags ) ) { 195 243 $data['tags'] = $tags; … … 219 267 220 268 if ( ! is_array( $response_data ) || ! isset( $response_data['revalidated'] ) ) { 221 return new WP_Error( 222 'revalidate_error', 223 'Invalid response from revalidation endpoint', 224 array( 'status' => 403 ) 269 return new WP_Error( 270 'revalidate_error', 271 'Invalid response from revalidation endpoint', 272 array( 'status' => 403 ) 225 273 ); 226 274 } -
on-demand-revalidation/tags/1.3.0/vendor/autoload.php
r3073815 r3280737 23 23 require_once __DIR__ . '/composer/autoload_real.php'; 24 24 25 return ComposerAutoloaderInit abe7fdb289c442ae5244023b8c11b676::getLoader();25 return ComposerAutoloaderInit34bda8da618ea87a4aa4928738826a53::getLoader(); -
on-demand-revalidation/tags/1.3.0/vendor/composer/InstalledVersions.php
r3225736 r3280737 32 32 */ 33 33 private static $installed; 34 35 /** 36 * @var bool 37 */ 38 private static $installedIsLocalDir; 34 39 35 40 /** … … 310 315 self::$installed = $data; 311 316 self::$installedByVendor = array(); 317 318 // when using reload, we disable the duplicate protection to ensure that self::$installed data is 319 // always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not, 320 // so we have to assume it does not, and that may result in duplicate data being returned when listing 321 // all installed packages for example 322 self::$installedIsLocalDir = false; 312 323 } 313 324 … … 326 337 327 338 if (self::$canGetVendors) { 339 $selfDir = strtr(__DIR__, '\\', '/'); 328 340 foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { 341 $vendorDir = strtr($vendorDir, '\\', '/'); 329 342 if (isset(self::$installedByVendor[$vendorDir])) { 330 343 $installed[] = self::$installedByVendor[$vendorDir]; … … 334 347 self::$installedByVendor[$vendorDir] = $required; 335 348 $installed[] = $required; 336 if (s trtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {349 if (self::$installed === null && $vendorDir.'/composer' === $selfDir) { 337 350 self::$installed = $required; 338 $copiedLocalDir = true;351 self::$installedIsLocalDir = true; 339 352 } 353 } 354 if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) { 355 $copiedLocalDir = true; 340 356 } 341 357 } -
on-demand-revalidation/tags/1.3.0/vendor/composer/autoload_real.php
r3073815 r3280737 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit abe7fdb289c442ae5244023b8c11b6765 class ComposerAutoloaderInit34bda8da618ea87a4aa4928738826a53 6 6 { 7 7 private static $loader; … … 23 23 } 24 24 25 spl_autoload_register(array('ComposerAutoloaderInitabe7fdb289c442ae5244023b8c11b676', 'loadClassLoader'), true, true); 25 require __DIR__ . '/platform_check.php'; 26 27 spl_autoload_register(array('ComposerAutoloaderInit34bda8da618ea87a4aa4928738826a53', 'loadClassLoader'), true, true); 26 28 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 27 spl_autoload_unregister(array('ComposerAutoloaderInit abe7fdb289c442ae5244023b8c11b676', 'loadClassLoader'));29 spl_autoload_unregister(array('ComposerAutoloaderInit34bda8da618ea87a4aa4928738826a53', 'loadClassLoader')); 28 30 29 31 require __DIR__ . '/autoload_static.php'; 30 call_user_func(\Composer\Autoload\ComposerStaticInit abe7fdb289c442ae5244023b8c11b676::getInitializer($loader));32 call_user_func(\Composer\Autoload\ComposerStaticInit34bda8da618ea87a4aa4928738826a53::getInitializer($loader)); 31 33 32 34 $loader->register(true); -
on-demand-revalidation/tags/1.3.0/vendor/composer/autoload_static.php
r3073815 r3280737 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit abe7fdb289c442ae5244023b8c11b6767 class ComposerStaticInit34bda8da618ea87a4aa4928738826a53 8 8 { 9 9 public static $prefixLengthsPsr4 = array ( … … 32 32 { 33 33 return \Closure::bind(function () use ($loader) { 34 $loader->prefixLengthsPsr4 = ComposerStaticInit abe7fdb289c442ae5244023b8c11b676::$prefixLengthsPsr4;35 $loader->prefixDirsPsr4 = ComposerStaticInit abe7fdb289c442ae5244023b8c11b676::$prefixDirsPsr4;36 $loader->classMap = ComposerStaticInit abe7fdb289c442ae5244023b8c11b676::$classMap;34 $loader->prefixLengthsPsr4 = ComposerStaticInit34bda8da618ea87a4aa4928738826a53::$prefixLengthsPsr4; 35 $loader->prefixDirsPsr4 = ComposerStaticInit34bda8da618ea87a4aa4928738826a53::$prefixDirsPsr4; 36 $loader->classMap = ComposerStaticInit34bda8da618ea87a4aa4928738826a53::$classMap; 37 37 38 38 }, null, ClassLoader::class); -
on-demand-revalidation/tags/1.3.0/vendor/composer/installed.php
r3225736 r3280737 1 1 <?php return array( 2 2 'root' => array( 3 'name' => ' gdidentity/on-demand-revalidation',4 'pretty_version' => '1. 2.5',5 'version' => '1. 2.5.0',6 'reference' => null,3 'name' => 'dexerto/on-demand-revalidation', 4 'pretty_version' => '1.3.0', 5 'version' => '1.3.0.0', 6 'reference' => 'f807a12333d6e0b83df7b801038e56859eae8a0b', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 11 11 ), 12 12 'versions' => array( 13 ' gdidentity/on-demand-revalidation' => array(14 'pretty_version' => '1. 2.5',15 'version' => '1. 2.5.0',16 'reference' => null,13 'dexerto/on-demand-revalidation' => array( 14 'pretty_version' => '1.3.0', 15 'version' => '1.3.0.0', 16 'reference' => 'f807a12333d6e0b83df7b801038e56859eae8a0b', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../', -
on-demand-revalidation/trunk/on-demand-revalidation.php
r3225736 r3280737 7 7 * GitHub Plugin URI: https://github.com/dexerto/on-demand-revalidation 8 8 * Description: Next.js On-Demand Revalidation on the post update, revalidate specific paths, tags on the post update. 9 * Version: 1. 2.59 * Version: 1.3.0 10 10 * Author: Dexerto 11 11 * Author URI: https://dexerto.com … … 13 13 * License: GPL-3 14 14 * License URI: https://www.gnu.org/licenses/gpl-3.0.html 15 * 15 * 16 16 * @package OnDemandRevalidation 17 17 */ … … 55 55 self::$instance->revalidation(); 56 56 self::$instance->plugin_links(); 57 self::$instance->load_textdomain(); 57 58 58 59 \OnDemandRevalidation\Helpers::prevent_wrong_api_url(); … … 122 123 // Plugin version. 123 124 if ( ! defined( 'ON_DEMAND_REVALIDATION_VERSION' ) ) { 124 define( 'ON_DEMAND_REVALIDATION_VERSION', get_plugin_data( __FILE__ )['Version'] ); 125 $plugin_data = get_file_data( __FILE__, array( 'Version' => 'Version' ) ); 126 define( 'ON_DEMAND_REVALIDATION_VERSION', $plugin_data['Version'] ); 125 127 } 126 128 … … 226 228 ); 227 229 } 230 231 /** 232 * Load plugin text domain. 233 * 234 * @since 1.3.0 235 */ 236 private function load_textdomain(): void { 237 add_action( 238 'init', 239 function () { 240 load_plugin_textdomain( 'on-demand-revalidation', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); 241 } 242 ); 243 } 228 244 } 229 245 -
on-demand-revalidation/trunk/readme.txt
r3225736 r3280737 2 2 Contributors: bebjakub 3 3 Tags: nextjs, ssg, revalidation, on-demand 4 Requires at least: 4.75 Tested up to: 6.7. 16 Stable tag: 1. 2.54 Requires at least: 6.0.0 5 Tested up to: 6.7.2 6 Stable tag: 1.3.0 7 7 Requires PHP: 8.0 8 8 License: GPL-3 … … 11 11 === Description === 12 12 13 Next.js On-Demand Revalidation for Wordpress on the post update, revalidate specific paths and tags on the post update.13 Next.js On-Demand Revalidation for Wordpress on post updates, revalidate specific paths and tags on post updates. 14 14 15 15 Feel free to create a PR to [plugin Github repo](https://github.com/Dexerto/on-demand-revalidation). … … 25 25 26 26 == Changelog == 27 = 1.3.0 = 28 - feat: Add ability to provide custom paths and tags per post type from @MuhammedAO 29 - fix: prevent locales from being loaded too early @humet 27 30 = 1.2.5 = 28 31 - feat: prevent revalidate functions from running more than once within a single save_post request from @MuhammedAO -
on-demand-revalidation/trunk/src/Admin/Settings.php
r3073849 r3280737 69 69 */ 70 70 public function register_settings() { 71 $tag_desc = 'One tag per row.<br/><br/><i>Available current placeholders:</i><br/><code>%slug%</code> <code>%author_nicename%</code> <code>%author_username%</code> <code>%category%</code> <code>%post_tag%</code><code>%database_id%</code> <code>%id%</code> <code>%custom_taxonomy%</code><br/><br/><i>Note:</i> Replace <code>%custom_taxonomy%</code> with your custom taxonomy name.'; 71 72 72 73 $this->settings_api->register_section( … … 74 75 array( 75 76 'title' => __( 'General', 'on-demand-revalidation' ), 76 ) 77 ) 77 78 ); 78 79 … … 90 91 'type' => 'password', 91 92 ), 92 ) 93 ); 94 95 $this->settings_api->register_section( 96 'on_demand_revalidation_post_update_settings', 97 array( 98 'title' => __( 'On post update', 'on-demand-revalidation' ), 99 'desc' => __( 'On post update is current page revalidated automatically.', 'on-demand-revalidation' ), 100 ) 101 ); 102 103 $this->settings_api->register_fields( 104 'on_demand_revalidation_post_update_settings', 105 array( 106 array( 107 'name' => 'revalidate_homepage', 108 'desc' => __( 'Revalidate Homepage on post update', 'on-demand-revalidation' ), 109 'type' => 'checkbox', 110 'default' => 'on', 111 ), 93 112 94 array( 113 95 'name' => 'disable_cron', 114 96 'desc' => __( "<b>Disable scheduled revalidation.</b> Revalidation triggered immediately without using WP-Cron. It'll slow down post update.", 'on-demand-revalidation' ), 115 97 'type' => 'checkbox', 116 ),117 array(118 'name' => 'revalidate_paths',119 'label' => __( 'Additional paths to revalidate on Post update', 'on-demand-revalidation' ),120 'desc' => 'One path per row.',121 'placeholder' => '/category/%category%',122 'type' => 'textarea',123 ),124 125 array(126 'name' => 'revalidate_tags',127 'label' => __( 'Tags to revalidate on Post update', 'on-demand-revalidation' ),128 'desc' => 'One tag per row.<br/><br/><i>Available current Post placeholders:</i><br/><code>%slug%</code> <code>%author_nicename%</code> <code>%author_username%</code> <code>%category%</code> <code>%post_tag%</code><code>%database_id%</code> <code>%id%</code> <code>%custom_taxonomy%</code><br/><br/><i>Note:</i> Replace <code>%custom_taxonomy%</code> with your custom taxonomy name.',129 'placeholder' => '%databaseid%',130 'type' => 'textarea',131 98 ), 132 99 … … 137 104 'type' => 'html', 138 105 ), 139 ) 140 ); 106 ) 107 ); 108 109 $this->settings_api->register_section( 110 'on_demand_revalidation_post_update_settings', 111 array( 112 'title' => __( 'All Settings', 'on-demand-revalidation' ), 113 'desc' => __( 'Revalidation settings for all post types.', 'on-demand-revalidation' ), 114 ) 115 ); 116 117 $this->settings_api->register_fields( 118 'on_demand_revalidation_post_update_settings', 119 array( 120 array( 121 'name' => 'revalidate_homepage', 122 'desc' => __( 'Revalidate homepage on all post updates', 'on-demand-revalidation' ), 123 'type' => 'checkbox', 124 'default' => 'on', 125 ), 126 127 array( 128 'name' => 'revalidate_paths', 129 'label' => __( 'Paths to revalidate on all updates', 'on-demand-revalidation' ), 130 'desc' => 'One path per row.', 131 'placeholder' => '/category/%category%', 132 'type' => 'textarea', 133 ), 134 135 array( 136 'name' => 'revalidate_tags', 137 'label' => __( 'Tags to revalidate on all updates', 'on-demand-revalidation' ), 138 'desc' => $tag_desc, 139 'placeholder' => '%databaseid%', 140 'type' => 'textarea', 141 ), 142 143 144 ) 145 ); 146 147 $post_types = get_post_types( array( 'public' => true ), 'objects' ); 148 foreach ( $post_types as $post_type_obj ) { 149 150 if ( 'attachment' === $post_type_obj->name ) { 151 continue; 152 } 153 $section_id = 'on_demand_revalidation_' . $post_type_obj->name . '_settings'; 154 $this->settings_api->register_section( 155 $section_id, 156 array( 157 // translators: %s: plural name of the post type, e.g. "Posts" or "Books". 158 'title' => sprintf( __( '%s Settings', 'on-demand-revalidation', ), $post_type_obj->labels->name ), 159 // translators: %s: singular name of the post type, e.g. "Post" or "Book". 160 'desc' => sprintf( __( 'Revalidation settings specific to %s posts.', 'on-demand-revalidation', ), $post_type_obj->labels->singular_name ), 161 ) 162 ); 163 $this->settings_api->register_fields( 164 $section_id, 165 array( 166 array( 167 'name' => 'revalidate_enabled_' . $post_type_obj->name, 168 // translators: %s: singular post type name, used in the checkbox label. 169 'desc' => sprintf( __( 'Enable revalidation for %s', 'on-demand-revalidation' ), $post_type_obj->labels->singular_name ), 170 'type' => 'checkbox', 171 'default' => 'on', 172 ), 173 array( 174 'name' => 'revalidate_homepage_' . $post_type_obj->name, 175 // translators: %s: singular post type name, used in the textarea label. 176 'desc' => sprintf( __( 'Revalidate Homepage on all updates for %s', 'on-demand-revalidation' ), $post_type_obj->labels->singular_name ), 177 'type' => 'checkbox', 178 'default' => 'on', 179 ), 180 array( 181 'name' => 'revalidate_paths_' . $post_type_obj->name, 182 // translators: %s: singular post type name, used in the textarea label. 183 'label' => sprintf( __( 'Additional paths for %s', 'on-demand-revalidation' ), $post_type_obj->labels->singular_name ), 184 'desc' => __( 'One path per row. Leave empty if not applicable.', 'on-demand-revalidation' ), 185 'placeholder' => '/custom/path/$placeholder%/', 186 'type' => 'textarea', 187 ), 188 array( 189 'name' => 'revalidate_tags_' . $post_type_obj->name, 190 // translators: %s: singular post type name, used in the textarea label. 191 'label' => sprintf( __( 'Tags for %s', 'on-demand-revalidation' ), $post_type_obj->labels->singular_name ), 192 'desc' => $tag_desc, 193 'placeholder' => '%slug%', 194 'type' => 'textarea', 195 ), 196 ) 197 ); 198 } 141 199 } 142 200 -
on-demand-revalidation/trunk/src/Revalidation.php
r3225736 r3280737 44 44 return; 45 45 } 46 46 47 47 $old_permalink = get_permalink( $post_ID ); 48 48 update_post_meta( $post_ID, '_old_permalink', $old_permalink ); … … 66 66 public static function handle_save_post( $post_id, $post ) { 67 67 $excluded_statuses = array( 'auto-draft', 'inherit', 'draft', 'trash' ); 68 68 69 69 if ( isset( $post->post_status ) && in_array( $post->post_status, $excluded_statuses, true ) ) { 70 70 return; 71 71 } 72 72 73 73 if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { 74 74 return; 75 75 } 76 76 77 77 if ( false !== wp_is_post_revision( $post_id ) ) { 78 78 return; 79 79 } 80 80 81 if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {82 return;83 }84 85 81 self::revalidate_post( $post ); 86 82 } … … 99 95 self::revalidate_post( $post ); 100 96 } 101 } 97 } 102 98 103 99 /** … … 129 125 } 130 126 127 $post_type = $post->post_type; 128 129 // Check if revalidation is enabled for this post type. 130 $individual_toggle = Settings::get( 'revalidate_enabled_' . $post_type, 'on', 'on_demand_revalidation_' . $post_type . '_settings' ); 131 if ( 'on' !== $individual_toggle ) { 132 return (object) array( 133 'success' => false, 134 // translators: %s: post type slug, e.g. "post" or "page". 135 'message' => sprintf( __( 'Revalidation is disabled for %s.', 'on-demand-revalidation' ), $post_type ), 136 ); 137 } 138 131 139 $paths = array(); 132 140 133 if ( Settings::get( 'revalidate_homepage', 'on', 'on_demand_revalidation_post_update_settings' ) === 'on' ) { 141 $individual_homepage = Settings::get( 'revalidate_homepage_' . $post_type, null, 'on_demand_revalidation_' . $post_type . '_settings' ); 142 143 if ( null === $individual_homepage ) { 144 // no per‑type override, use global. 145 $home_enabled = ( 146 Settings::get( 147 'revalidate_homepage', 148 'on', 149 'on_demand_revalidation_post_update_settings' 150 ) === 'on' 151 ); 152 } else { 153 // use per‑type setting. 154 $home_enabled = ( 'on' === $individual_homepage ); 155 } 156 157 if ( $home_enabled ) { 134 158 $paths[] = '/'; 135 159 } 160 136 161 137 162 $post_permalink = get_permalink( $post ); … … 148 173 if ( ! empty( $old_permalink ) ) { 149 174 $parse_old_permalink = wp_parse_url( $old_permalink ); 150 175 151 176 if ( isset( $parse_old_permalink['path'] ) && '/' !== $parse_old_permalink['path'] ) { 152 177 $old_page_path = substr( $parse_old_permalink['path'], -1 ) === '/' ? substr( $parse_old_permalink['path'], 0, -1 ) : $parse_old_permalink['path']; … … 158 183 159 184 $revalidate_paths = trim( Settings::get( 'revalidate_paths', '', 'on_demand_revalidation_post_update_settings' ) ); 160 185 161 186 if ( ! empty( $revalidate_paths ) ) { 162 187 $revalidate_paths = preg_split( '/\r\n|\n|\r/', $revalidate_paths ); … … 181 206 } 182 207 208 // per‑post‑type additional paths. 209 $post_type_raw_paths = Settings::get( 'revalidate_paths_' . $post_type, '', 'on_demand_revalidation_' . $post_type . '_settings' ); 210 if ( ! empty( $post_type_raw_paths ) ) { 211 $post_type_defined_paths = preg_split( '/\r\n|\n|\r/', $post_type_raw_paths ); 212 $post_type_defined_paths = Helpers::rewrite_placeholders( $post_type_defined_paths, $post ); 213 foreach ( $post_type_defined_paths as $path ) { 214 if ( str_starts_with( $path, '/' ) ) { 215 $paths[] = $path; 216 } 217 } 218 } 219 183 220 $paths = apply_filters( 'on_demand_revalidation_paths', $paths, $post ); 184 $tags = apply_filters( 'on_demand_revalidation_tags', $tags, $post ); 221 222 223 224 // per‑post‑type additional tags. 225 $post_type_raw_tags = Settings::get( 'revalidate_tags_' . $post_type, '', 'on_demand_revalidation_' . $post_type . '_settings' ); 226 if ( ! empty( $post_type_raw_tags ) ) { 227 $post_type_defined_tags = preg_split( '/\r\n|\n|\r/', $post_type_raw_tags ); 228 $post_type_defined_tags = Helpers::rewrite_placeholders( $post_type_defined_tags, $post ); 229 $tags = array_merge( $tags, $post_type_defined_tags ); 230 } 231 232 $tags = apply_filters( 'on_demand_revalidation_tags', $tags, $post ); 185 233 186 234 $data = array( 187 235 'postId' => $post->ID, 188 236 ); 189 237 190 238 if ( ! empty( $paths ) ) { 191 239 $data['paths'] = $paths; 192 240 } 193 241 194 242 if ( ! empty( $tags ) ) { 195 243 $data['tags'] = $tags; … … 219 267 220 268 if ( ! is_array( $response_data ) || ! isset( $response_data['revalidated'] ) ) { 221 return new WP_Error( 222 'revalidate_error', 223 'Invalid response from revalidation endpoint', 224 array( 'status' => 403 ) 269 return new WP_Error( 270 'revalidate_error', 271 'Invalid response from revalidation endpoint', 272 array( 'status' => 403 ) 225 273 ); 226 274 } -
on-demand-revalidation/trunk/vendor/autoload.php
r3073815 r3280737 23 23 require_once __DIR__ . '/composer/autoload_real.php'; 24 24 25 return ComposerAutoloaderInit abe7fdb289c442ae5244023b8c11b676::getLoader();25 return ComposerAutoloaderInit34bda8da618ea87a4aa4928738826a53::getLoader(); -
on-demand-revalidation/trunk/vendor/composer/InstalledVersions.php
r3225736 r3280737 32 32 */ 33 33 private static $installed; 34 35 /** 36 * @var bool 37 */ 38 private static $installedIsLocalDir; 34 39 35 40 /** … … 310 315 self::$installed = $data; 311 316 self::$installedByVendor = array(); 317 318 // when using reload, we disable the duplicate protection to ensure that self::$installed data is 319 // always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not, 320 // so we have to assume it does not, and that may result in duplicate data being returned when listing 321 // all installed packages for example 322 self::$installedIsLocalDir = false; 312 323 } 313 324 … … 326 337 327 338 if (self::$canGetVendors) { 339 $selfDir = strtr(__DIR__, '\\', '/'); 328 340 foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { 341 $vendorDir = strtr($vendorDir, '\\', '/'); 329 342 if (isset(self::$installedByVendor[$vendorDir])) { 330 343 $installed[] = self::$installedByVendor[$vendorDir]; … … 334 347 self::$installedByVendor[$vendorDir] = $required; 335 348 $installed[] = $required; 336 if (s trtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {349 if (self::$installed === null && $vendorDir.'/composer' === $selfDir) { 337 350 self::$installed = $required; 338 $copiedLocalDir = true;351 self::$installedIsLocalDir = true; 339 352 } 353 } 354 if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) { 355 $copiedLocalDir = true; 340 356 } 341 357 } -
on-demand-revalidation/trunk/vendor/composer/autoload_real.php
r3073815 r3280737 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit abe7fdb289c442ae5244023b8c11b6765 class ComposerAutoloaderInit34bda8da618ea87a4aa4928738826a53 6 6 { 7 7 private static $loader; … … 23 23 } 24 24 25 spl_autoload_register(array('ComposerAutoloaderInitabe7fdb289c442ae5244023b8c11b676', 'loadClassLoader'), true, true); 25 require __DIR__ . '/platform_check.php'; 26 27 spl_autoload_register(array('ComposerAutoloaderInit34bda8da618ea87a4aa4928738826a53', 'loadClassLoader'), true, true); 26 28 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 27 spl_autoload_unregister(array('ComposerAutoloaderInit abe7fdb289c442ae5244023b8c11b676', 'loadClassLoader'));29 spl_autoload_unregister(array('ComposerAutoloaderInit34bda8da618ea87a4aa4928738826a53', 'loadClassLoader')); 28 30 29 31 require __DIR__ . '/autoload_static.php'; 30 call_user_func(\Composer\Autoload\ComposerStaticInit abe7fdb289c442ae5244023b8c11b676::getInitializer($loader));32 call_user_func(\Composer\Autoload\ComposerStaticInit34bda8da618ea87a4aa4928738826a53::getInitializer($loader)); 31 33 32 34 $loader->register(true); -
on-demand-revalidation/trunk/vendor/composer/autoload_static.php
r3073815 r3280737 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit abe7fdb289c442ae5244023b8c11b6767 class ComposerStaticInit34bda8da618ea87a4aa4928738826a53 8 8 { 9 9 public static $prefixLengthsPsr4 = array ( … … 32 32 { 33 33 return \Closure::bind(function () use ($loader) { 34 $loader->prefixLengthsPsr4 = ComposerStaticInit abe7fdb289c442ae5244023b8c11b676::$prefixLengthsPsr4;35 $loader->prefixDirsPsr4 = ComposerStaticInit abe7fdb289c442ae5244023b8c11b676::$prefixDirsPsr4;36 $loader->classMap = ComposerStaticInit abe7fdb289c442ae5244023b8c11b676::$classMap;34 $loader->prefixLengthsPsr4 = ComposerStaticInit34bda8da618ea87a4aa4928738826a53::$prefixLengthsPsr4; 35 $loader->prefixDirsPsr4 = ComposerStaticInit34bda8da618ea87a4aa4928738826a53::$prefixDirsPsr4; 36 $loader->classMap = ComposerStaticInit34bda8da618ea87a4aa4928738826a53::$classMap; 37 37 38 38 }, null, ClassLoader::class); -
on-demand-revalidation/trunk/vendor/composer/installed.php
r3225736 r3280737 1 1 <?php return array( 2 2 'root' => array( 3 'name' => ' gdidentity/on-demand-revalidation',4 'pretty_version' => '1. 2.5',5 'version' => '1. 2.5.0',6 'reference' => null,3 'name' => 'dexerto/on-demand-revalidation', 4 'pretty_version' => '1.3.0', 5 'version' => '1.3.0.0', 6 'reference' => 'f807a12333d6e0b83df7b801038e56859eae8a0b', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 11 11 ), 12 12 'versions' => array( 13 ' gdidentity/on-demand-revalidation' => array(14 'pretty_version' => '1. 2.5',15 'version' => '1. 2.5.0',16 'reference' => null,13 'dexerto/on-demand-revalidation' => array( 14 'pretty_version' => '1.3.0', 15 'version' => '1.3.0.0', 16 'reference' => 'f807a12333d6e0b83df7b801038e56859eae8a0b', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.