Skip to content

Instantly share code, notes, and snippets.

@kagg-design
Created January 17, 2019 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kagg-design/080d4de58331dd5428e8e9f0616f6d42 to your computer and use it in GitHub Desktop.
Save kagg-design/080d4de58331dd5428e8e9f0616f6d42 to your computer and use it in GitHub Desktop.
Clear multiple cron jobs created by Google Reviews Business plugin.
<?php
/**
* Clear multiple cron jobs created by Google Reviews Business plugin.
*/
function clear_cron_jobs() {
$crons = _get_cron_array();
$hook = 'grp_auto_save';
$args_array = array();
$new_cron = array();
foreach ( $crons as $timestamp => $cron ) {
if ( isset( $cron[ $hook ] ) ) {
$args = serialize( array_values($cron[ $hook ])[0]['args'] );
if ( in_array( $args, $args_array, true ) ) {
unset( $cron[ $hook ] );
} else {
$args_array[] = $args;
}
}
if ( ! empty( $cron ) ) {
$new_cron[ $timestamp ] = $cron;
}
}
_set_cron_array( $new_cron );
}
add_action( 'shutdown', 'clear_cron_jobs' );
@azoswald
Copy link

azoswald commented Apr 5, 2019

Hi there. Sorry for the newb question. But where do I place this code? And how do I get it to run? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment