Last active
February 4, 2023 21:54
-
-
Save NigelRodgers/7dc9a8ef7c3e16eec65b2f65a93bab35 to your computer and use it in GitHub Desktop.
Reschedule Data Fetch From 7 days to 3 days
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reschedule_analytics_fetch_nr() { | |
if ( true === as_has_scheduled_action( 'rank_math/analytics/data_fetch' ) ) { | |
$data_fetch = as_get_scheduled_actions( ['hook' => 'rank_math/analytics/data_fetch', 'status' => 'pending'] ); | |
if(259200 !== $data_fetch->interval_in_seconds){ | |
as_unschedule_action( 'rank_math/analytics/data_fetch' ); | |
} | |
as_schedule_recurring_action( strtotime( 'tomorrow' ), 3*DAY_IN_SECONDS, 'rank_math/analytics/data_fetch', array(), "rank-math" ); | |
} | |
} | |
add_action( 'init', 'reschedule_analytics_fetch_nr' ); |
//If data fetch function is missing create a new one
function reschedule_analytics_fetch_nr() { if( ! get_option('run_create_vip_order_once') ) { as_schedule_recurring_action( strtotime( 'tomorrow' ), 3*DAY_IN_SECONDS, 'rank_math/analytics/data_fetch', array(), "rank-math" ); update_option( 'run_create_vip_order_once', true ); } } add_action( 'init', 'reschedule_analytics_fetch_nr' );
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instructions: