self::HOOK, 'group' => self::GROUP, 'status' => 'pending', 'per_page' => -1, ), 'ids' ); return count( (array) $actions ); } $count = 0; foreach ( (array) _get_cron_array() as $events ) { if ( isset( $events[ self::HOOK ] ) ) { $count += count( (array) $events[ self::HOOK ] ); } } return $count; } /** * Whether a queue runner worth using is installed. * * Action Scheduler is loaded by whichever plugin ships the newest copy of it, * on plugins_loaded - well before anything here asks. */ private static function has_action_scheduler(): bool { $has = function_exists( 'as_enqueue_async_action' ) && function_exists( 'as_has_scheduled_action' ); /** * Filter whether the queue runs on Action Scheduler. * * Return false to stay on WP-Cron on a site that has Action Scheduler - * worth having where the site would rather not add to that queue. * * @param bool $has Whether Action Scheduler is installed. */ return (bool) apply_filters( 'ajax_thumbnail_rebuild_use_action_scheduler', $has ); } /** * Drop the WP-Cron jobs when the plugin goes away. * * Nothing would answer them, so they would sit in the cron array being * retried. Action Scheduler cleans up after itself. */ public static function clear(): void { if ( function_exists( 'wp_unschedule_hook' ) ) { wp_unschedule_hook( self::HOOK ); } } }