Created
December 20, 2017 17:14
-
-
Save EricBusch/3798f06cd2bd4c9d9533b944c5d00b12 to your computer and use it in GitHub Desktop.
Configure the hours in which Product Sets should update. [datafeedr][dfrps]
This file contains hidden or 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
<?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