Changeset 10209 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-manager.php
- Timestamp:
- 08/26/2020 07:25:50 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-manager.php
r9974 r10209 30 30 // Register the wildcard cron hook tasks. 31 31 if ( defined( 'DOING_CRON' ) && DOING_CRON ) { 32 // add_action( 'pre_option_cron', array( $this, 'register_colon_based_hook_handlers' ), 100 );33 }34 add_action( 'wporg_after_cron_event_run', array( $this, 'after_cron_event_run' ), 10, 2 );32 // This must be run after plugins_loaded, as that's when Cavalcade hooks in. 33 add_action( 'init', array( $this, 'register_colon_based_hook_handlers' ) ); 34 } 35 35 } 36 36 … … 278 278 * These cron tasks are in the form of 'import_plugin:$slug', this maps them to their expected handlers. 279 279 */ 280 public function after_cron_event_run( $hook, $args ) { 281 if ( has_action( $hook ) ) { 282 return; 283 } 284 list( $base, ) = explode( ':', $hook, 2 ); 280 public function register_colon_based_hook_handlers() { 281 $cron_array = get_option( 'cron' ); 285 282 286 283 $wildcard_cron_tasks = array( … … 290 287 ); 291 288 292 if ( isset( $wildcard_cron_tasks[ $base ] ) ) {293 call_user_func_array( $wildcard_cron_tasks[ $base ], $args );294 }295 }296 297 /**298 * The WordPress Cron implementation isn't great at determining if a job is already enqueued,299 * as a result, we use a "fake" hook to encode the plugin slug into the job name to allow us to300 * detect if a cron task for that plugin has already been registered.301 *302 * These cron tasks are in the form of 'import_plugin:$slug', this maps them to their expected handlers.303 *304 * @param array $cron_array The Cron array.305 * @return array The Cron array passed, unchanged.306 */307 public function register_colon_based_hook_handlers( $cron_array ) {308 $wildcard_cron_tasks = array(309 'import_plugin' => array( __NAMESPACE__ . '\Plugin_Import', 'cron_trigger' ),310 'import_plugin_i18n' => array( __NAMESPACE__ . '\Plugin_i18n_Import', 'cron_trigger' ),311 'tide_sync' => array( __NAMESPACE__ . '\Tide_Sync', 'cron_trigger' ),312 );313 314 289 if ( is_array( $cron_array ) ) { 315 290 foreach ( $cron_array as $timestamp => $handlers ) { … … 332 307 } 333 308 } 334 335 return $cron_array;336 309 } 337 310
Note: See TracChangeset
for help on using the changeset viewer.