-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from iamsayan/develop
Develop
- Loading branch information
Showing
26 changed files
with
350 additions
and
483 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
||
|
@@ -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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
@@ -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' ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
||
|
@@ -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; | ||
|
@@ -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> | ||
<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> <strong>|</strong> | ||
<a href="<?php echo esc_url( $no_thanks ); ?>" class="later"><strong><?php esc_html_e( 'Nope, 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> | ||
<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> <strong>|</strong> | ||
<a href="<?php echo esc_url( $no_thanks ); ?>" class="later"><strong><?php esc_html_e( 'Nope, 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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
@@ -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'; | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
@@ -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' ); | ||
} | ||
} |
Oops, something went wrong.