Skip to content

Instantly share code, notes, and snippets.

@EricBusch
Created December 20, 2017 17:14
Show Gist options
  • Save EricBusch/3798f06cd2bd4c9d9533b944c5d00b12 to your computer and use it in GitHub Desktop.
Save EricBusch/3798f06cd2bd4c9d9533b944c5d00b12 to your computer and use it in GitHub Desktop.
Configure the hours in which Product Sets should update. [datafeedr][dfrps]
<?php
/**
* Configure the hours in which Product Sets should
* do updates.
*
* @param array $post
*
* @return array $post
*/
function mycode_set_update_hours( $post ) {
/**
* Configure the hours in which Product Sets should update.
*
* Possible hour values are:
*
* 0, 1, 2, 3, 4, 5, 6,
* 7, 8, 9, 10, 11, 12,
* 13, 14, 15, 16, 17,
* 18, 19, 20, 21, 22, 23
*
* All hours should be comma-separated.
*
* The following code forces Product Set updates to only
* occur between 10pm and 7am.
*/
$update_hours = array( 22, 23, 0, 1, 2, 3, 4, 5, 6 );
if ( '0' != $post['update_phase'] ) {
return $post;
}
$current_hour = date_i18n( 'G' );
if ( ! in_array( $current_hour, $update_hours ) ) {
$post['post_status'] = 'draft';
}
return $post;
}
add_filter( 'dfrps_cron_before_delete_or_update', 'mycode_set_update_hours' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment