Skip to content

Commit

Permalink
Merge pull request #7 from iamsayan/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
iamsayan authored Jun 24, 2022
2 parents 2b84b95 + 162dde5 commit 06871df
Show file tree
Hide file tree
Showing 26 changed files with 350 additions and 483 deletions.
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# Changelog

If you like WP Cron Action Schedular plugin, please take a moment to [give a 5-star rating](https://wordpress.org/support/plugin/migrate-wp-cron-to-action-scheduler/reviews/#new-post). It helps to keep development and support going strong. Thank you!
If you like Advanced Cron Scheduler plugin, please take a moment to [give a 5-star rating](https://wordpress.org/support/plugin/migrate-wp-cron-to-action-scheduler/reviews/?filter=5#new-post). It helps to keep development and support going strong. Thank you!

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

## 1.0.7
Release Date: 24th June, 2022

* Added: Admin Bar Link.
* Removed: Unused code.
* Fixed: Typo.

## 1.0.6
Release Date: 24th June, 2022

Expand All @@ -15,7 +22,7 @@ Release Date: 24th June, 2022
## 1.0.5
Release Date: 3rd December, 2021

* Fixed: An errors which occurs if cron is creating early before initialization of Action schedular library.
* Fixed: An errors which occurs if cron is creating early before initialization of Action scheduler library.

## 1.0.4
Release Date: 2nd December, 2021
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# WP Cron Action Schedular
# Advanced Cron Scheduler for WordPress

The WP Cron Action Schedular plugin helps to easily replace or migrate Native WordPress Cron to the Action Scheduler Library.
The Advanced Cron Scheduler for WordPress plugin helps to easily replace or migrate Native WordPress Cron to the Action Scheduler Library.

The WP-Cron system in WordPress is not a "real" cron system, which means events may not run exactly according to their schedule because the system relies on regular traffic to the website in order to trigger scheduled events.

Expand All @@ -15,7 +15,7 @@ The WP-Cron system in WordPress is not a "real" cron system, which means events
* Long-running events may temporarily block the event runner
* High traffic websites may suffer from sequential processing issues that block the event runner

The WP Cron Action Schedular plugin does alter the way that WordPress core runs cron events using the Action Scheduler Library.
The Advanced Cron Scheduler for WordPress plugin does alter the way that WordPress core runs cron events using the Action Scheduler Library.

Action Scheduler is a scalable, traceable job queue for background processing large sets of actions in WordPress. It's specially designed to be distributed in WordPress plugins.

Expand Down Expand Up @@ -51,8 +51,8 @@ There you will find:

## Contribute

* Active development of this plugin is handled [on GitHub](https://github.com/iamsayan/migrate-wp-cron-to-action-scheduler/).
* Feel free to [fork the project on GitHub](https://github.com/iamsayan/migrate-wp-cron-to-action-scheduler/) and submit your contributions via pull request.
* Active development of this plugin is handled [on GitHub](https://github.com/iamsayan/advanced-cron-scheduler/).
* Feel free to [fork the project on GitHub](https://github.com/iamsayan/advanced-cron-scheduler/) and submit your contributions via pull request.

## Credits

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iamsayan/migrate-wp-cron-to-action-scheduler",
"description": "The WP Cron Action Schedular plugin helps to easily migrate Native WordPress Cron to the Action Scheduler Library",
"name": "iamsayan/advanced-cron-scheduler",
"description": "The Advanced Cron Scheduler plugin helps to easily migrate Native WordPress Cron to the Action Scheduler Library",
"type": "wordpress-plugin",
"license": "GPL-3.0",
"authors": [
Expand All @@ -23,7 +23,7 @@
"minimum-stability": "stable",
"autoload": {
"psr-4": {
"Mwpcac\\": "./includes"
"ACSWP\\Plugin\\": "./includes"
},
"files": [ "vendor/woocommerce/action-scheduler/action-scheduler.php" ]
},
Expand Down
18 changes: 10 additions & 8 deletions includes/Base/Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
* Action links.
*
* @since 1.0.0
* @package WP Cron Action Schedular
* @subpackage Mwpcac\Base
* @package Advanced Cron Scheduler
* @subpackage ACSWP\Plugin\Base
* @author Sayan Datta <[email protected]>
*/

namespace Mwpcac\Base;
namespace ACSWP\Plugin\Base;

use Mwpcac\Helpers\Hooker;
use Mwpcac\Base\BaseController;
use ACSWP\Plugin\Helpers\Hooker;
use ACSWP\Plugin\Base\BaseController;

defined( 'ABSPATH' ) || exit;

Expand Down Expand Up @@ -44,9 +44,11 @@ public function settings_link( $links ) {
*/
public function meta_links( $links, $file ) {
if ( $file === $this->plugin ) { // only for this plugin
$links[] = '<a href="https://actionscheduler.org/api/" target="_blank">' . __( 'Usage', 'migrate-wp-cron-to-action-scheduler' ) . '</a>';
$links[] = '<a href="https://actionscheduler.org/faq/" target="_blank">' . __( 'FAQ', 'migrate-wp-cron-to-action-scheduler' ) . '</a>';
$links[] = '<a href="https://github.com/iamsayan/migrate-wp-cron-to-action-scheduler" target="_blank">' . __( 'GitHub', 'migrate-wp-cron-to-action-scheduler' ) . '</a>';
$links[] = '<a href="https://actionscheduler.org/api/" target="_blank" rel="noopener">' . __( 'Usage', 'migrate-wp-cron-to-action-scheduler' ) . '</a>';
$links[] = '<a href="https://actionscheduler.org/faq/" target="_blank" rel="noopener">' . __( 'FAQ', 'migrate-wp-cron-to-action-scheduler' ) . '</a>';
$links[] = '<a href="https://github.com/iamsayan/advanced-cron-scheduler" target="_blank" rel="noopener">' . __( 'GitHub', 'migrate-wp-cron-to-action-scheduler' ) . '</a>';
$links[] = '<a href="https://www.paypal.me/iamsayan/" target="_blank" rel="noopener">' . __( 'Donate', 'migrate-wp-cron-to-action-scheduler' ) . '</a>';
$links[] = '<a href="https://wordpress.org/support/plugin/migrate-wp-cron-to-action-scheduler/reviews/?filter=5#new-post" target="_blank" rel="noopener" style="color: #ff2000;">★★★★★</a>';
}

return $links;
Expand Down
10 changes: 5 additions & 5 deletions includes/Base/Activate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
* Activation.
*
* @since 1.1.0
* @package WP Cron Action Schedular
* @subpackage Mwpcac\Base
* @package Advanced Cron Scheduler
* @subpackage ACSWP\Plugin\Base
* @author Sayan Datta <[email protected]>
*/

namespace Mwpcac\Base;
namespace ACSWP\Plugin\Base;

/**
* Activation class.
Expand All @@ -23,9 +23,9 @@ public static function activate() {
return;
}

set_transient( 'mwpcac-show-notice-on-activation', true, 15 );
set_transient( 'acswp-show-notice-on-activation', true, 15 );

// action
do_action( 'mwpcac/plugin_activate' );
do_action( 'acswp/plugin_activate' );
}
}
127 changes: 118 additions & 9 deletions includes/Base/AdminNotice.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
* Admin notices.
*
* @since 1.0.0
* @package WP Cron Action Schedular
* @subpackage Mwpcac\Base
* @package Advanced Cron Scheduler
* @subpackage ACSWP\Plugin\Base
* @author Sayan Datta <[email protected]>
*/

namespace Mwpcac\Base;
namespace ACSWP\Plugin\Base;

use Mwpcac\Helpers\Hooker;
use Mwpcac\Base\BaseController;
use ACSWP\Plugin\Helpers\Hooker;
use ACSWP\Plugin\Base\BaseController;

defined( 'ABSPATH' ) || exit;

Expand All @@ -26,18 +26,22 @@ class AdminNotice extends BaseController
* Register functions.
*/
public function register() {
$this->action( 'admin_notices', 'install_notice' );
$this->action( 'admin_notices', 'notice' );
$this->action( 'admin_init', 'dismiss_notice' );
}

/**
* Show internal admin notices.
*/
public function install_notice() {
public function notice() {
global $wp_version;

// Show a warning to sites running PHP < 5.6
if ( version_compare( $wp_version, '5.2.0', '<' ) ) {
deactivate_plugins( $this->plugin );
if ( isset( $_GET['activate'] ) ) { // phpcs:ignore
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>';
return;
Expand All @@ -46,19 +50,124 @@ public function install_notice() {
// Show a warning to sites running PHP < 5.6
if ( version_compare( PHP_VERSION, '5.6', '<' ) ) {
deactivate_plugins( $this->plugin );
if ( isset( $_GET['activate'] ) ) { // phpcs:ignore
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>';
return;
}

// Check transient, if available display notice
if ( get_transient( 'mwpcac-show-notice-on-activation' ) !== false ) { ?>
if ( get_transient( 'acswp-show-notice-on-activation' ) !== false ) { ?>
<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>
</div> <?php
delete_transient( 'mwpcac-show-notice-on-activation' );
delete_transient( 'acswp-show-notice-on-activation' );
}

$show_rating = true;
if ( $this->calculate_time() > strtotime( '-7 days' )
|| '1' === get_option( 'acswp_plugin_dismiss_rating_notice' )
|| apply_filters( 'acswp/hide_sticky_rating_notice', false ) ) {
$show_rating = false;
}

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;
<a href="<?php echo esc_url( $dismiss ); ?>" class="already-did"><strong><?php esc_html_e( 'I already did', 'migrate-wp-cron-to-action-scheduler' ); ?></strong></a>&nbsp;<strong>|</strong>
<a href="<?php echo esc_url( $no_thanks ); ?>" class="later"><strong><?php esc_html_e( 'Nope&#44; maybe later', 'migrate-wp-cron-to-action-scheduler' ); ?></strong></a></p>
</div>
<?php
}

$show_donate = true;
if ( $this->calculate_time() > strtotime( '-240 hours' )
|| '1' === get_option( 'acswp_plugin_dismiss_donate_notice' )
|| apply_filters( 'acswp/hide_sticky_donate_notice', false ) ) {
$show_donate = false;
}

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;
<a href="<?php echo esc_url( $dismiss ); ?>" class="already-did"><strong><?php esc_html_e( 'I already donated', 'migrate-wp-cron-to-action-scheduler' ); ?></strong></a>&nbsp;<strong>|</strong>
<a href="<?php echo esc_url( $no_thanks ); ?>" class="later"><strong><?php esc_html_e( 'Nope&#44; maybe later', 'migrate-wp-cron-to-action-scheduler' ); ?></strong></a></p>
</div>
<?php
}
}

/**
* Dismiss admin notices.
*/
public function dismiss_notice() {
// Check for Rating Notice
if ( get_option( 'acswp_plugin_no_thanks_rating_notice' ) === '1'
&& get_option( 'acswp_plugin_dismissed_time' ) <= strtotime( '-7 days' ) ) {
delete_option( 'acswp_plugin_dismiss_rating_notice' );
delete_option( 'acswp_plugin_no_thanks_rating_notice' );
}

// Check for Donate Notice
if ( get_option( 'acswp_plugin_no_thanks_donate_notice' ) === '1'
&& get_option( 'acswp_plugin_dismissed_time_donate' ) <= strtotime( '-14 days' ) ) {
delete_option( 'acswp_plugin_dismiss_donate_notice' );
delete_option( 'acswp_plugin_no_thanks_donate_notice' );
}

if ( ! isset( $_REQUEST['acswp_notice_action'] ) || empty( $_REQUEST['acswp_notice_action'] ) ) {
return;
}

check_admin_referer( 'acswp_notice_nonce' );

$notice = sanitize_text_field( $_REQUEST['acswp_notice_action'] );
$notice = explode( '_', $notice );
$notice_type = end( $notice );
array_pop( $notice );
$notice_action = join( '_', $notice );

if ( 'dismiss' === $notice_action ) {
update_option( 'acswp_plugin_dismiss_' . $notice_type . '_notice', '1' );
}

if ( 'no_thanks' === $notice_action ) {
update_option( 'acswp_plugin_no_thanks_' . $notice_type . '_notice', '1' );
update_option( 'acswp_plugin_dismiss_' . $notice_type . '_notice', '1' );
if ( 'donate' === $notice_type ) {
update_option( 'acswp_plugin_dismissed_time_donate', time() );
} else {
update_option( 'acswp_plugin_dismissed_time', time() );
}
}

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

/**
* Calculate install time.
*/
private function calculate_time() {
$installed_time = get_option( 'acswp_plugin_installed_time' );

if ( ! $installed_time ) {
$installed_time = time();
update_option( 'acswp_plugin_installed_time', $installed_time );
}

return $installed_time;
}
}
10 changes: 5 additions & 5 deletions includes/Base/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
* Base controller class.
*
* @since 1.0.0
* @package WP Cron Action Schedular
* @subpackage Mwpcac\Core
* @package Advanced Cron Scheduler
* @subpackage ACSWP\Plugin\Core
* @author Sayan Datta <[email protected]>
*/

namespace Mwpcac\Base;
namespace ACSWP\Plugin\Base;

/**
* Base Controller class.
Expand Down Expand Up @@ -64,8 +64,8 @@ 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 = '1.0.5';
$this->name = 'WP Cron Action Schedular';
$this->version = ACS_PLUGIN_VERSION;
$this->name = 'Advanced Cron Scheduler';
}

/**
Expand Down
14 changes: 7 additions & 7 deletions includes/Base/Deactivate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
* Deactivation.
*
* @since 1.0.0
* @package WP Cron Action Schedular
* @subpackage Mwpcac\Base
* @package Advanced Cron Scheduler
* @subpackage ACSWP\Plugin\Base
* @author Sayan Datta <[email protected]>
*/

namespace Mwpcac\Base;
namespace ACSWP\Plugin\Base;

/**
* Deactivation class.
Expand All @@ -23,11 +23,11 @@ public static function deactivate() {
return;
}

delete_option( 'mwpcac_plugin_dismiss_rating_notice' );
delete_option( 'mwpcac_plugin_no_thanks_rating_notice' );
delete_option( 'mwpcac_plugin_installed_time' );
delete_option( 'acswp_plugin_dismiss_rating_notice' );
delete_option( 'acswp_plugin_no_thanks_rating_notice' );
delete_option( 'acswp_plugin_installed_time' );

// action
do_action( 'mwpcac/plugin_deactivate' );
do_action( 'acswp/plugin_deactivate' );
}
}
Loading

0 comments on commit 06871df

Please sign in to comment.