Skip to content

Commit

Permalink
Merge pull request #8 from iamsayan/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
iamsayan authored Aug 28, 2022
2 parents 06871df + 79a22fb commit 7b3f7cc
Show file tree
Hide file tree
Showing 40 changed files with 766 additions and 395 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ If you like Advanced Cron Scheduler plugin, please take a moment to [give a 5-st

All notable changes to this project will be documented in this file.

## 1.0.8
Release Date: 28th August, 2022

* Added: Settings to toggle settings under Settings > General.
* Updated: Action Scheduler library to v3.5.0.
* Improved: Cron Logic.

## 1.0.7
Release Date: 24th June, 2022

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"scripts": {
"build": [
"composer dump-autoload -o"
"composer dump-autoload"
],
"pot" : [
"wp i18n make-pot . languages/migrate-wp-cron-to-action-scheduler.pot --exclude=\"/vendor\""
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions includes/Base/AdminNotice.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function notice() {
unset( $_GET['activate'] ); // phpcs:ignore
}
/* translators: %s: Plugin Name */
echo '<div class="error"><p>' . sprintf( __( 'Your version of WordPress is below the minimum version of WordPress required by %s plugin. Please upgrade WordPress to 5.2.0 or later.', 'migrate-wp-cron-to-action-scheduler' ), $this->name ) . '</p></div>';
echo '<div class="error"><p>' . sprintf( esc_html__( 'Your version of WordPress is below the minimum version of WordPress required by %s plugin. Please upgrade WordPress to 5.2.0 or later.', 'migrate-wp-cron-to-action-scheduler' ), esc_html( $this->name ) ) . '</p></div>';
return;
}

Expand All @@ -54,7 +54,7 @@ public function notice() {
unset( $_GET['activate'] ); // phpcs:ignore
}
/* translators: %s: Plugin Name */
echo '<div class="error"><p>' . sprintf( __( 'Your version of PHP is below the minimum version of PHP required by %s plugin. Please contact your host and request that your version be upgraded to 5.6 or later.', 'migrate-wp-cron-to-action-scheduler' ), $this->name ) . '</p></div>';
echo '<div class="error"><p>' . sprintf( esc_html__( 'Your version of PHP is below the minimum version of PHP required by %s plugin. Please contact your host and request that your version be upgraded to 5.6 or later.', 'migrate-wp-cron-to-action-scheduler' ), esc_html( $this->name ) ) . '</p></div>';
return;
}

Expand All @@ -63,7 +63,7 @@ public function notice() {
<div class="notice notice-success">
<p><strong><?php
/* translators: %s: Plugin Name */
printf( __( 'Thanks for installing %1$s v%2$s plugin. Click <a href="%3$s">here</a> to view Action Scheduler tasks.', 'migrate-wp-cron-to-action-scheduler' ), $this->name, $this->version, admin_url( 'tools.php?page=action-scheduler' ) ); ?></strong></p>
printf( esc_html__( 'Thanks for installing %1$s v%2$s plugin. Click <a href="%3$s">here</a> to view Action Scheduler tasks.', 'migrate-wp-cron-to-action-scheduler' ), 'Advanced Cron Scheduler', esc_html( ACSWP_PLUGIN_VERSION ), esc_url( admin_url( 'tools.php?page=action-scheduler' ) ) ); ?></strong></p>
</div> <?php
delete_transient( 'acswp-show-notice-on-activation' );
}
Expand All @@ -78,7 +78,7 @@ public function notice() {
if ( $show_rating ) {
$dismiss = wp_nonce_url( add_query_arg( 'acswp_notice_action', 'dismiss_rating' ), 'acswp_notice_nonce' );
$no_thanks = wp_nonce_url( add_query_arg( 'acswp_notice_action', 'no_thanks_rating' ), 'acswp_notice_nonce' ); ?>

<div class="notice notice-success">
<p><?php echo wp_kses_post( 'Hey, I noticed you\'ve been using Advanced Cron Scheduler for more than 1 week – that’s awesome! Could you please do me a BIG favor and give it a <strong>5-star</strong> rating on WordPress? Just to help us spread the word and boost my motivation.', 'migrate-wp-cron-to-action-scheduler' ); ?></p>
<p><a href="https://wordpress.org/support/plugin/migrate-wp-cron-to-action-scheduler/reviews/?filter=5#new-post" target="_blank" class="button button-secondary" rel="noopener"><?php esc_html_e( 'Ok, you deserve it', 'migrate-wp-cron-to-action-scheduler' ); ?></a>&nbsp;
Expand All @@ -98,7 +98,7 @@ public function notice() {
if ( $show_donate ) {
$dismiss = wp_nonce_url( add_query_arg( 'acswp_notice_action', 'dismiss_donate' ), 'acswp_notice_nonce' );
$no_thanks = wp_nonce_url( add_query_arg( 'acswp_notice_action', 'no_thanks_donate' ), 'acswp_notice_nonce' ); ?>

<div class="notice notice-success">
<p><?php echo wp_kses_post( 'Hey, I noticed you\'ve been using Advanced Cron Scheduler for more than 2 week – that’s awesome! If you like Advanced Cron Scheduler and you are satisfied with the plugin, isn’t that worth a coffee or two? Please consider donating. Donations help me to continue support and development of this free plugin! Thank you very much!', 'migrate-wp-cron-to-action-scheduler' ); ?></p>
<p><a href="https://www.paypal.me/iamsayan" target="_blank" class="button button-secondary" rel="noopener"><?php esc_html_e( 'Donate Now', 'migrate-wp-cron-to-action-scheduler' ); ?></a>&nbsp;
Expand Down Expand Up @@ -133,7 +133,7 @@ public function dismiss_notice() {

check_admin_referer( 'acswp_notice_nonce' );

$notice = sanitize_text_field( $_REQUEST['acswp_notice_action'] );
$notice = sanitize_text_field( wp_unslash( $_REQUEST['acswp_notice_action'] ) );
$notice = explode( '_', $notice );
$notice_type = end( $notice );
array_pop( $notice );
Expand All @@ -153,7 +153,7 @@ public function dismiss_notice() {
}
}

wp_redirect( remove_query_arg( [ 'acswp_notice_action', '_wpnonce' ] ) );
wp_safe_redirect( remove_query_arg( [ 'acswp_notice_action', '_wpnonce' ] ) );
exit;
}

Expand Down
6 changes: 2 additions & 4 deletions includes/Base/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,16 @@ public function __construct() {
$this->plugin_path = plugin_dir_path( $this->dirname_r( __FILE__, 2 ) );
$this->plugin_url = plugin_dir_url( $this->dirname_r( __FILE__, 2 ) );
$this->plugin = plugin_basename( $this->dirname_r( __FILE__, 3 ) ) . '/migrate-wp-cron-to-action-scheduler.php';
$this->version = ACS_PLUGIN_VERSION;
$this->name = 'Advanced Cron Scheduler';
}

/**
* PHP < 7.0.0 compatibility
*/
private function dirname_r( $path, $count = 1 ) {
if ( $count > 1 ) {
return dirname( $this->dirname_r( $path, --$count ) );
return dirname( $this->dirname_r( $path, --$count ) );
} else {
return dirname( $path );
return dirname( $path );
}
}
}
7 changes: 3 additions & 4 deletions includes/Core/AdminBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
namespace ACSWP\Plugin\Core;

use ACSWP\Plugin\Helpers\Hooker;
use ACSWP\Plugin\Helpers\HelperFunctions;

defined( 'ABSPATH' ) || exit;

Expand All @@ -20,7 +19,7 @@
*/
class AdminBar
{
use HelperFunctions, Hooker;
use Hooker;

/**
* Register functions.
Expand All @@ -33,9 +32,9 @@ public function register() {
* Add admin bar content.
*/
public function admin_bar( $wp_admin_bar ) {
$item = $this->do_filter( 'show_admin_bar_item', true );
$item = (bool) $this->do_filter( 'show_admin_bar_item', get_option( 'acswp_admin_bar' ) );

if ( true === $item ) {
if ( $item ) {
$args = array(
'id' => 'acswp-link',
'parent' => 'top-secondary',
Expand Down
19 changes: 9 additions & 10 deletions includes/Core/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace ACSWP\Plugin\Core;

use ACSWP\Plugin\Helpers\Hooker;
use ACSWP\Plugin\Helpers\Scheduler;
use ACSWP\Plugin\Helpers\HelperFunctions;

Expand All @@ -21,7 +20,7 @@
*/
class Connection
{
use Hooker, HelperFunctions, Scheduler;
use HelperFunctions, Scheduler;

/**
* List of Events.
Expand All @@ -41,7 +40,7 @@ public function register() {
$this->filter( 'pre_clear_scheduled_hook', 'pre_clear_scheduled_hook', 10, 3 );
$this->filter( 'pre_get_scheduled_event', 'pre_get_scheduled_event', 10, 4 );
$this->filter( 'pre_get_ready_cron_jobs', 'pre_get_ready_cron_jobs' );
$this->action( 'init', 'register_crons' );
$this->action( 'init', 'register_crons', 10 );
}

/**
Expand Down Expand Up @@ -72,7 +71,7 @@ public function pre_schedule_event( $pre, $event ) {
return null;
}

if ( ! did_action( 'init' ) ) {
if ( ! $this->is_as_initialized() ) {
$this->events[ $event->hook ] = $event;

return false;
Expand Down Expand Up @@ -168,7 +167,7 @@ public function pre_reschedule_event( $pre, $event ) {
return null;
}

if ( ! did_action( 'init' ) ) {
if ( ! $this->is_as_initialized() ) {
return false;
}

Expand Down Expand Up @@ -218,7 +217,7 @@ public function pre_unschedule_event( $pre, $timestamp, $hook, $args ) {
return null;
}

if ( ! did_action( 'init' ) ) {
if ( ! $this->is_as_initialized() ) {
return false;
}

Expand Down Expand Up @@ -259,7 +258,7 @@ public function pre_unschedule_hook( $pre, $hook ) {
return null;
}

if ( ! did_action( 'init' ) ) {
if ( ! $this->is_as_initialized() ) {
return false;
}

Expand Down Expand Up @@ -297,7 +296,7 @@ public function pre_clear_scheduled_hook( $pre, $hook, $args ) {
return null;
}

if ( ! did_action( 'init' ) ) {
if ( ! $this->is_as_initialized() ) {
return false;
}

Expand Down Expand Up @@ -333,7 +332,7 @@ public function pre_get_scheduled_event( $pre, $hook, $args, $timestamp ) {
return null;
}

if ( ! did_action( 'init' ) ) {
if ( ! $this->is_as_initialized() ) {
return false;
}

Expand Down Expand Up @@ -407,7 +406,7 @@ public function pre_get_ready_cron_jobs( $pre ) {
}
}

if ( ! did_action( 'init' ) ) {
if ( ! $this->is_as_initialized() ) {
return $crons;
}

Expand Down
3 changes: 1 addition & 2 deletions includes/Core/MigrateActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace ACSWP\Plugin\Core;

use ACSWP\Plugin\Helpers\Hooker;
use ACSWP\Plugin\Helpers\Scheduler;
use ACSWP\Plugin\Helpers\HelperFunctions;

Expand All @@ -21,7 +20,7 @@
*/
class MigrateActions
{
use Hooker, HelperFunctions, Scheduler;
use HelperFunctions, Scheduler;

/**
* Register functions.
Expand Down
57 changes: 57 additions & 0 deletions includes/Core/Settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
* Settings fields.
*
* @since 1.0.8
* @package Advanced Cron Scheduler
* @subpackage ACSWP\Plugin\Core
* @author Sayan Datta <[email protected]>
*/

namespace ACSWP\Plugin\Core;

use ACSWP\Plugin\Helpers\Hooker;

defined( 'ABSPATH' ) || exit;

/**
* Admin Bar class.
*/
class Settings
{
use Hooker;

/**
* Register functions.
*/
public function register() {
$this->action( 'admin_init', 'register_fields' );
}

/**
* Register custom settings.
*/
public function register_fields() {
register_setting( 'general', 'acswp_admin_bar' );
add_settings_field( 'acswp_admin_bar', __( 'Show Admin Bar', 'migrate-wp-cron-to-action-scheduler' ), [ $this, 'admin_bar_field' ], 'general' );

register_setting( 'general', 'acswp_unique_action' );
add_settings_field( 'acswp_unique_action', __( 'Enable Unique Actions', 'migrate-wp-cron-to-action-scheduler' ), [ $this, 'unique_action_field' ], 'general' );
}

/*
* Print settings field
*/
public function admin_bar_field() { ?>
<label><input type="checkbox" name="acswp_admin_bar" value="1" <?php checked( get_option( 'acswp_admin_bar' ), 1 ); ?> /> <?php esc_html_e( 'Show Action Schedular Link in Admin Bar', 'migrate-wp-cron-to-action-scheduler' ); ?></label>
<?php
}

/*
* Print settings field
*/
public function unique_action_field() { ?>
<label><input type="checkbox" name="acswp_unique_action" value="1" <?php checked( get_option( 'acswp_unique_action' ), 1 ); ?> /> <?php esc_html_e( 'Enabling Unique Actions will prevent actions from being duplicated', 'migrate-wp-cron-to-action-scheduler' ); ?></label>
<?php
}
}
Loading

0 comments on commit 7b3f7cc

Please sign in to comment.