Skip to content

Instantly share code, notes, and snippets.

@paulgoodchild
Last active March 27, 2021 15:07
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 paulgoodchild/6a4d299a21246ca1c058335dfb352a29 to your computer and use it in GitHub Desktop.
Save paulgoodchild/6a4d299a21246ca1c058335dfb352a29 to your computer and use it in GitHub Desktop.
Specify the hour of the day that the Shield Security plugin executes its daily cron
<?php
/**
* The Scanner cron job run by the Shield plugin is responsible for executing the scans.
* If you're running ShieldFREE, the scans runs automatically once per day. On ShieldPRO, it can repeat up to every hour.
*
* The Cron is configured to have a start time - i.e. the first time that the cron will execute. Then it repeats based on your settings.
*
* If the hour at which the cron is set to run is 3 a.m. (the default), it will first run the next day at 3am, and then
* every day thereafter at 3 a.m. If this default hour doesn't suit, you can change it using a WordPress filter.
*
* The following example will change the hour to 5 a.m. instead of the default, 3 a.m.
*
* Note: The hour is 24hr notation, so 5 a.m. is '5', and 5 p.m. is '17'.
*
* Note: Shield crons are reset/setup at instant the plugin is upgraded/activated - ensure that this filter is in-place beforehand so your preferences are applied.
*/
add_filter( 'shield/scan_cron_start_hour', function ( $hour ) {
return 5;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment