Skip to content

Commit

Permalink
Reschedule the feed file generation to 24h.
Browse files Browse the repository at this point in the history
  • Loading branch information
budzanowski committed May 12, 2021
1 parent 5248ce2 commit bf360eb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 15 additions & 0 deletions includes/Lifecycle.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function __construct( $plugin ) {
'2.0.3',
'2.0.4',
'2.4.0',
'2.5.0',
);
}

Expand Down Expand Up @@ -347,4 +348,18 @@ protected function upgrade_to_2_4_0() {
delete_transient( 'wc_facebook_google_product_categories' );
}

/**
* Upgrades to version 2.5.0
*
* @since 2.5.0
*/
protected function upgrade_to_2_5_0() {
/**
* Since 2.5.0 the feed generation interval is increased to 2.5.0.
* Update procedure just needs to remove all current actions.
* The Feed class will reschedule new generation with proper cadence.
*/
as_unschedule_all_actions( \SkyVerge\WooCommerce\Facebook\Products\Feed::GENERATE_FEED_ACTION );
}

}
6 changes: 3 additions & 3 deletions includes/Products/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ public function regenerate_feed() {
* @since 1.11.0
*/
public function schedule_feed_generation() {

$integration = facebook_for_woocommerce()->get_integration();
$integration = facebook_for_woocommerce()->get_integration();
$configured_ok = $integration && $integration->is_configured();

// Only schedule feed job if store has not opted out of product sync.
Expand All @@ -174,10 +173,11 @@ public function schedule_feed_generation() {
* Filters the frequency with which the product feed data is generated.
*
* @since 1.11.0
* @since 2.5.0 Feed generation interval increased to 24h.
*
* @param int $interval the frequency with which the product feed data is generated, in seconds. Defaults to every 15 minutes.
*/
$interval = apply_filters( 'wc_facebook_feed_generation_interval', MINUTE_IN_SECONDS * 15 );
$interval = apply_filters( 'wc_facebook_feed_generation_interval', DAY_IN_SECONDS );

if ( ! as_next_scheduled_action( self::GENERATE_FEED_ACTION ) ) {
as_schedule_recurring_action( time(), max( 2, $interval ), self::GENERATE_FEED_ACTION, array(), facebook_for_woocommerce()->get_id_dasherized() );
Expand Down

0 comments on commit bf360eb

Please sign in to comment.