Skip to content

Instantly share code, notes, and snippets.

@bwmarkle
Created September 1, 2022 19:29
Show Gist options
  • Save bwmarkle/98532330919d063dea105ddffdb6d291 to your computer and use it in GitHub Desktop.
Save bwmarkle/98532330919d063dea105ddffdb6d291 to your computer and use it in GitHub Desktop.
add_action( 'update_option', function( $option, $old_value, $value ) {
if ( 'cron' !== $option ) {
return;
}
$json_old = wp_json_encode( $old_value );
$json_new = wp_json_encode( $value );
$old_contains = strpos( $json_old, 'boldgrid_backup_wp_cron_run_jobs' ) !== false;
$new_contains = strpos( $json_new, 'boldgrid_backup_wp_cron_run_jobs' ) !== false;
if ( $old_contains && ! $new_contains ) {
$core = apply_filters( 'boldgrid_backup_get_core', false );
$logger = new Boldgrid_Backup_Admin_Log( $core );
$logger->init( 'update_option.log' );
// We want to include the trace to see what is clearing the schedule.
$e = new \Exception();
$e = explode( "\n", $e->getTraceAsString() );
$logger->add( print_r( array(
'$e' => $e,
), 1 ) );
}
}, 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment