Skip to content

Commit a93f6d8

Browse files
authored
Merge pull request #12 from iamsayan/develop
Update plugin to version 1.1.2, add new build script for localization…
2 parents 81b97de + 9acc76c commit a93f6d8

File tree

88 files changed

+2602
-1139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+2602
-1139
lines changed

.github/workflows/deploy.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ jobs:
1111
environment: wp.org plugin
1212

1313
steps:
14+
- name: Install Subversion
15+
run: sudo apt-get install subversion
16+
1417
- name: Checkout code
15-
uses: actions/checkout@v2
18+
uses: actions/checkout@v4
1619

1720
- name: WordPress Plugin Deploy
1821
id: deploy

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
},
3030
"scripts": {
3131
"build": [
32-
"composer dump-autoload"
32+
"composer dump-autoload",
33+
"composer pot"
3334
],
3435
"pot" : [
3536
"wp i18n make-pot . languages/migrate-wp-cron-to-action-scheduler.pot --exclude=\"/vendor\""

composer.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/Base/AdminNotice.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,17 @@ public function dismiss_notice() {
116116
$notice_action = join( '_', $notice );
117117

118118
if ( 'dismiss' === $notice_action ) {
119-
update_option( 'acswp_plugin_dismiss_' . $notice_type . '_notice', '1' );
119+
update_option( 'acswp_plugin_dismiss_' . $notice_type . '_notice', '1', false );
120120
}
121121

122122
if ( 'no_thanks' === $notice_action ) {
123-
update_option( 'acswp_plugin_no_thanks_' . $notice_type . '_notice', '1' );
124-
update_option( 'acswp_plugin_dismiss_' . $notice_type . '_notice', '1' );
123+
update_option( 'acswp_plugin_no_thanks_' . $notice_type . '_notice', '1', false );
124+
update_option( 'acswp_plugin_dismiss_' . $notice_type . '_notice', '1', false );
125+
125126
if ( 'donate' === $notice_type ) {
126-
update_option( 'acswp_plugin_dismissed_time_donate', time() );
127+
update_option( 'acswp_plugin_dismissed_time_donate', time(), false );
127128
} else {
128-
update_option( 'acswp_plugin_dismissed_time', time() );
129+
update_option( 'acswp_plugin_dismissed_time', time(), false );
129130
}
130131
}
131132

@@ -141,7 +142,7 @@ private function calculate_time() {
141142

142143
if ( ! $installed_time ) {
143144
$installed_time = time();
144-
update_option( 'acswp_plugin_installed_time', $installed_time );
145+
update_option( 'acswp_plugin_installed_time', $installed_time, false );
145146
}
146147

147148
return $installed_time;

includes/Core/Admin.php

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
namespace ACSWP\Plugin\Core;
1212

1313
use ACSWP\Plugin\Helpers\Hooker;
14+
use ACSWP\Plugin\Helpers\HelperFunctions;
1415

1516
defined( 'ABSPATH' ) || exit;
1617

@@ -19,21 +20,27 @@
1920
*/
2021
class Admin
2122
{
22-
use Hooker;
23+
use Hooker, HelperFunctions;
2324

2425
/**
2526
* Register functions.
2627
*/
2728
public function register() {
2829
$this->action( 'admin_bar_menu', 'admin_bar' );
2930
$this->filter( 'action_scheduler_check_pastdue_actions', 'past_due_actions', 100 );
31+
$this->filter( 'action_scheduler_retention_period', 'retention_period', 100 );
32+
$this->filter( 'action_scheduler_queue_runner_batch_size', 'queue_batch_size', 10000 );
33+
$this->filter( 'action_scheduler_queue_runner_concurrent_batches', 'concurrent_batches', 10000 );
34+
$this->filter( 'action_scheduler_timeout_period', 'timeout', 100 );
35+
$this->filter( 'action_scheduler_failure_period', 'timeout', 100 );
36+
$this->filter( 'action_scheduler_queue_runner_time_limit', 'time_limit', 100 );
3037
}
3138

3239
/**
3340
* Add admin bar content.
3441
*/
3542
public function admin_bar( $wp_admin_bar ) {
36-
$item = (bool) $this->do_filter( 'show_admin_bar_item', get_option( 'acswp_admin_bar' ) );
43+
$item = (bool) $this->do_filter( 'show_admin_bar_item', $this->get_settings( 'admin_bar' ) );
3744

3845
if ( $item ) {
3946
$args = array(
@@ -48,11 +55,61 @@ public function admin_bar( $wp_admin_bar ) {
4855
}
4956

5057
/**
51-
* Add admin bar content.
58+
* Disable past-due actions checking.
5259
*/
5360
public function past_due_actions( $check ) {
54-
$is_disabled = (bool) get_option( 'acswp_disable_past_due_checking' );
61+
$is_disabled = (bool) $this->get_settings( 'disable_past_due_checking' );
5562

5663
return $is_disabled ? false : $check;
5764
}
65+
66+
/**
67+
* Change retention period.
68+
*/
69+
public function retention_period( $retention_period ) {
70+
$units = [
71+
'minutes' => MINUTE_IN_SECONDS,
72+
'hours' => HOUR_IN_SECONDS,
73+
'days' => DAY_IN_SECONDS,
74+
'weeks' => WEEK_IN_SECONDS,
75+
'months' => MONTH_IN_SECONDS,
76+
'years' => YEAR_IN_SECONDS,
77+
];
78+
$retention_period = $this->get_settings( 'data_retention_period', 0 );
79+
$selected_unit = $this->get_settings( 'data_retention_unit', 'days' );
80+
81+
if ( $retention_period > 0 && isset( $units[ $selected_unit ] ) ) {
82+
return $retention_period * $units[ $selected_unit ];
83+
}
84+
85+
return $retention_period;
86+
}
87+
88+
/**
89+
* Change queue batch size.
90+
*/
91+
public function queue_batch_size( $batch_size ) {
92+
return $this->get_settings( 'queue_batch_size', $batch_size );
93+
}
94+
95+
/**
96+
* Change concurrent batches.
97+
*/
98+
public function concurrent_batches( $concurrent_batches ) {
99+
return $this->get_settings( 'concurrent_batches', $concurrent_batches );
100+
}
101+
102+
/**
103+
* Change timeout.
104+
*/
105+
public function timeout( $timeout ) {
106+
return $this->get_settings( 'timeout', $timeout );
107+
}
108+
109+
/**
110+
* Change time limit.
111+
*/
112+
public function time_limit( $time_limit ) {
113+
return $this->get_settings( 'time_limit', $time_limit );
114+
}
58115
}

includes/Core/Connection.php

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -356,15 +356,15 @@ public function pre_get_scheduled_event( $pre, $hook, $args, $timestamp ) {
356356
'args' => $args,
357357
);
358358

359-
$job = $this->get_next_action_by_data( $hook, $args, $timestamp );
360-
361-
if ( ! empty( $job ) ) {
362-
$schedule = $this->get_schedule( $job[0] );
363-
if ( $schedule->is_recurring() ) {
364-
if ( method_exists( $schedule, 'get_recurrence' ) ) {
365-
$event->schedule = $this->get_schedule_by_interval( $schedule->get_recurrence() );
366-
$event->interval = (int) $schedule->get_recurrence();
367-
}
359+
$action = $this->get_next_action_by_data( $hook, $args, $timestamp );
360+
361+
if ( ! empty( $action ) ) {
362+
$schedule = $this->get_schedule( $action[0] );
363+
364+
if ( $schedule && $schedule->is_recurring() && method_exists( $schedule, 'get_recurrence' ) ) {
365+
$recurrence = (int) $schedule->get_recurrence();
366+
$event->schedule = $this->get_schedule_by_interval( $recurrence );
367+
$event->interval = $recurrence;
368368
}
369369
}
370370

@@ -398,11 +398,11 @@ public function pre_get_ready_cron_jobs( $pre ) {
398398
}
399399

400400
if ( $proceed ) {
401-
foreach ( $wp_crons as $timestamp => $cronhooks ) {
401+
foreach ( $wp_crons as $timestamp => $cron_hooks ) {
402402
if ( $timestamp > $gmt_time ) {
403403
break;
404404
}
405-
$crons[ $timestamp ] = $cronhooks;
405+
$crons[ $timestamp ] = $cron_hooks;
406406
}
407407
}
408408
}
@@ -419,22 +419,26 @@ public function pre_get_ready_cron_jobs( $pre ) {
419419
] );
420420

421421
foreach ( $results as $action_id ) {
422-
$action = \ActionScheduler::store()->fetch_action( $action_id );
422+
$action = $this->get_action( $action_id );
423+
if ( ! $action ) {
424+
continue;
425+
}
423426

424-
$hook = $action->get_hook();
425-
$key = md5( serialize( $action->get_args() ) ); // PHPCS:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
426-
$value = [
427+
$schedule = $action->get_schedule();
428+
$hook = $action->get_hook();
429+
$key = md5( serialize( $action->get_args() ) ); // PHPCS:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
430+
$value = [
427431
'args' => $action->get_args(),
428432
'_job' => $action,
429433
];
430434

431-
$timestamp = $action->get_schedule();
432-
if ( method_exists( $timestamp, 'get_recurrence' ) ) {
433-
$value['schedule'] = $this->get_schedule_by_interval( $timestamp->get_recurrence() );
434-
$value['interval'] = (int) $timestamp->get_recurrence();
435+
if ( $schedule && method_exists( $schedule, 'get_recurrence' ) ) {
436+
$recurrence = (int) $schedule->get_recurrence();
437+
$value['schedule'] = $this->get_schedule_by_interval( $recurrence );
438+
$value['interval'] = $recurrence;
435439
}
436440

437-
$next = $timestamp->get_date();
441+
$next = $schedule->get_date();
438442
if ( $next ) {
439443
$timestamp = $next->getTimestamp();
440444
} else {

0 commit comments

Comments
 (0)