Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add filter for cron interval time #8

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions vip-jetpack-sync-cron/vip-jetpack-sync-cron.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
<?php

/*
Plugin Name: VIP Jetpack Sync Cron
Description: This drop-in plugin ensures that Jetpack only syncs on the dedicated cron task.
Version: 2.0
Author: Rebecca Hum, Automattic
Author: Rebecca Hum, Automattic
*/

use Automattic\Jetpack\Sync\Actions;
Expand All @@ -19,7 +19,7 @@ class VIP_Jetpack_Sync_Cron {

/**
* Initiate an instance of this class if one doesn't exist already.
*
*
* @return VIP_Jetpack_Sync_Cron instance
*/
static public function init() {
Expand All @@ -42,7 +42,7 @@ static public function init() {

/**
* Class constructor for hooking actions/filters.
*
*
* @return void
*/
public function __construct() {
Expand All @@ -54,21 +54,33 @@ public function __construct() {

/**
* Filter to add custom interval to schedule.
*
*
* @param array $schedules
*/
public function jp_sync_cron_schedule_interval( $schedules ) {

/**
* Allows for overruling the Jetpack Sync Cron Interval time.
*
* If cron jobs are bottle necking, lowering this value will increase
* jobs and may help elevate the queue. It may also cause too many
* threads, so keep an eye on performance after changing.
*
* @since 2.0
*/
$interval = apply_filters( 'vip_jetpack_sync_cron_interval', 60 );

$schedules[ self::SYNC_INTERVAL_NAME ] = [
'interval' => 60,
'interval' => $interval,
'display' => esc_html__( 'Every minute' ),
];

return $schedules;
}

/**
* Filter to return custom cron interval name.
*
*
* @param string $incremental_sync_cron_schedule
*/
public function filter_jetpack_sync_interval() {
Expand Down