| @@ -23,13 +23,8 @@ | ||
| 23 | 23 | self::makeAllTableChartsTabular(); |
| 24 | 24 | $upgraded = true; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - if ( wp_next_scheduled( 'visualizer_schedule_refresh_db' ) ) { | |
| 28 | - self::migrate_action_scheduler(); | |
| 29 | - $upgraded = true; | |
| 30 | - } | |
| 31 | - | |
| 32 | 27 | if ( ! $upgraded ) { |
| 33 | 28 | return; |
| 34 | 29 | } |
| 35 | 30 | |
| @@ -77,43 +72,6 @@ | ||
| 77 | 72 | AND pm.meta_key = '" . Visualizer_Plugin::CF_CHART_TYPE . "' |
| 78 | 73 | AND pm.meta_value IN ( 'dataTable', 'table' )" |
| 79 | 74 | ); |
| 80 | 75 | // phpcs:enable WordPress.DB.PreparedSQL.NotPrepared |
| 81 | - } | |
| 82 | - | |
| 83 | - /** | |
| 84 | - * Migrate recurring WP-Cron jobs to Action Scheduler. | |
| 85 | - */ | |
| 86 | - private static function migrate_action_scheduler(): void { | |
| 87 | - if ( ! function_exists( 'as_schedule_recurring_action' ) || ! function_exists( 'as_next_scheduled_action' ) ) { | |
| 88 | - return; | |
| 89 | - } | |
| 90 | - | |
| 91 | - $hook = 'visualizer_schedule_refresh_db'; | |
| 92 | - $group = 'visualizer'; | |
| 93 | - $interval_key = apply_filters( 'visualizer_chart_schedule_interval', 'visualizer_ten_minutes' ); | |
| 94 | - $interval = self::get_schedule_interval_seconds( $interval_key ); | |
| 95 | - $timestamp = strtotime( 'midnight' ) - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS; | |
| 96 | - | |
| 97 | - $next = as_next_scheduled_action( $hook, array(), $group ); | |
| 98 | - if ( false === $next ) { | |
| 99 | - as_schedule_recurring_action( $timestamp, $interval, $hook, array(), $group ); | |
| 100 | - } | |
| 101 | - | |
| 102 | - wp_clear_scheduled_hook( $hook ); | |
| 103 | - } | |
| 104 | - | |
| 105 | - /** | |
| 106 | - * Resolve a cron schedule key to seconds. | |
| 107 | - * | |
| 108 | - * @param string $interval_key Cron schedule key. | |
| 109 | - * @return int Interval in seconds. | |
| 110 | - */ | |
| 111 | - private static function get_schedule_interval_seconds( $interval_key ) { | |
| 112 | - $schedules = wp_get_schedules(); | |
| 113 | - if ( isset( $schedules[ $interval_key ]['interval'] ) ) { | |
| 114 | - return (int) $schedules[ $interval_key ]['interval']; | |
| 115 | - } | |
| 116 | - | |
| 117 | - return 600; | |
| 118 | 76 | } |
| 119 | 77 | } |