| 1 |
<?php |
| 2 |
/** |
| 3 |
* Admin Notices |
| 4 |
* |
| 5 |
* @package AutomatorWP\Admin\Notices |
| 6 |
* @author AutomatorWP <[email protected]>, Ruben Garcia <[email protected]> |
| 7 |
* @since 1.1.1 |
| 8 |
*/ |
| 9 |
// Exit if accessed directly |
| 10 |
if( !defined( 'ABSPATH' ) ) exit; |
| 11 |
|
| 12 |
/** |
| 13 |
* AutomatorWP admin notices |
| 14 |
* |
| 15 |
* @since 1.1.1 |
| 16 |
*/ |
| 17 |
function automatorwp_admin_notices() { |
| 18 |
|
| 19 |
// Bail if current user is not a site administrator |
| 20 |
if( ! current_user_can( 'update_plugins' ) ) { |
| 21 |
return; |
| 22 |
} |
| 23 |
|
| 24 |
// Check if user checked already hide the review notice |
| 25 |
$hide_review_notice = ( $exists = get_option( 'automatorwp_hide_review_notice' ) ) ? $exists : ''; |
| 26 |
|
| 27 |
if( $hide_review_notice !== 'yes' ) { |
| 28 |
|
| 29 |
// Get the installation date |
| 30 |
$automatorwp_install_date = ( $exists = get_option( 'automatorwp_install_date' ) ) ? $exists : date( 'Y-m-d H:i:s' ); |
| 31 |
|
| 32 |
$now = date( 'Y-m-d h:i:s' ); |
| 33 |
$datetime1 = new DateTime( $automatorwp_install_date ); |
| 34 |
$datetime2 = new DateTime( $now ); |
| 35 |
|
| 36 |
// Difference in days between installation date and now |
| 37 |
$diff_interval = round( ( $datetime2->format( 'U' ) - $datetime1->format( 'U' ) ) / ( 60 * 60 * 24 ) ); |
| 38 |
|
| 39 |
if( $diff_interval >= 7 ) { |
| 40 |
?> |
| 41 |
|
| 42 |
<div class="notice automatorwp-review-notice"> |
| 43 |
<div class="automatorwp-logo"></div> |
| 44 |
<p> |
| 45 |
<?php _e( 'Awesome! You\'ve been using <strong>AutomatorWP</strong> for a while.', 'automatorwp' ); ?><br> |
| 46 |
<?php _e( 'May I ask you to give it a <strong>5-star rating</strong> on WordPress?', 'automatorwp' ); ?><br> |
| 47 |
<?php _e( 'This will help to spread its popularity and to make this plugin a better one.', 'automatorwp' ); ?><br> |
| 48 |
<br> |
| 49 |
<?php _e( 'Your help is much appreciated. Thank you very much,', 'automatorwp' ); ?><br> |
| 50 |
<span>~Ruben Garcia</span> |
| 51 |
</p> |
| 52 |
<ul> |
| 53 |
<li><a href="https://wordpress.org/support/plugin/automatorwp/reviews/?rate=5#new-post" class="button button-primary" target="_blank" title="<?php _e( 'Yes, I want to rate it!', 'automatorwp' ); ?>"><?php _e( 'Yes, I want to rate it!', 'automatorwp' ); ?></a></li> |
| 54 |
<li><a href="javascript:void(0);" class="automatorwp-hide-review-notice button" title="<?php _e( 'I already did', 'automatorwp' ); ?>"><?php _e( 'I already did', 'automatorwp' ); ?></a></li> |
| 55 |
<li><a href="javascript:void(0);" class="automatorwp-hide-review-notice" title="<?php _e( 'No, I don\'t want to rate it', 'automatorwp' ); ?>"><small><?php _e( 'No, I don\'t want to rate it', 'automatorwp' ); ?></small></a></li> |
| 56 |
</ul> |
| 57 |
</div> |
| 58 |
|
| 59 |
<?php |
| 60 |
} |
| 61 |
|
| 62 |
} |
| 63 |
|
| 64 |
} |
| 65 |
add_action( 'admin_notices', 'automatorwp_admin_notices' ); |
| 66 |
|
| 67 |
/** |
| 68 |
* Ajax handler for hide review notice action |
| 69 |
* |
| 70 |
* @since 1.1.1 |
| 71 |
*/ |
| 72 |
function automatorwp_ajax_hide_review_notice() { |
| 73 |
// Security check, forces to die if not security passed |
| 74 |
check_ajax_referer( 'automatorwp_admin', 'nonce' ); |
| 75 |
|
| 76 |
update_option( 'automatorwp_hide_review_notice', 'yes' ); |
| 77 |
|
| 78 |
wp_send_json_success( array( 'success' ) ); |
| 79 |
exit; |
| 80 |
} |
| 81 |
|
| 82 |
add_action( 'wp_ajax_automatorwp_hide_review_notice', 'automatorwp_ajax_hide_review_notice' ); |
| 83 |
|