diff --git a/includes/admin/class-wc-amazon-payments-advanced-admin.php b/includes/admin/class-wc-amazon-payments-advanced-admin.php index d06670ad..5ed2af5b 100644 --- a/includes/admin/class-wc-amazon-payments-advanced-admin.php +++ b/includes/admin/class-wc-amazon-payments-advanced-admin.php @@ -45,7 +45,9 @@ public function __construct() { // Admin notices. add_action( 'admin_notices', array( $this, 'admin_notices' ) ); + add_action( 'admin_notices', array( $this, 'review_prompt' ) ); add_action( 'wp_ajax_amazon_pay_dismiss_notice', array( $this, 'ajax_dismiss_notice' ) ); + add_action( 'wp_ajax_amazon_pay_dismiss_review_prompt', array( $this, 'ajax_dismiss_review_prompt' ) ); // Admin Scripts. add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) ); @@ -322,6 +324,103 @@ public function admin_notices() { } } + /** + * Display a prompt for reviews! + * + * @return void + */ + public function review_prompt() { + global $current_section; + + $anniversary_date = get_option( 'amazon_payments_advanced_anniversary_date' ); + $hidden_until_date = get_option( 'amazon_payments_advanced_hidden_until_date' ); + + // Set up the dates. + // We do this here, so its on admin side but not dependant on user visiting the plugin's settings. + if ( ! $anniversary_date || ! $hidden_until_date ) { + $anniversary_date = time(); + $hidden_until_date = strtotime( '+1 month' ); + update_option( 'amazon_payments_advanced_anniversary_date', $anniversary_date ); + update_option( 'amazon_payments_advanced_hidden_until_date', $hidden_until_date ); + } + + // If it should be hidden yet, bail! + if ( $hidden_until_date > time() ) { + return; + } + + // We only want prompt to appear in plugin's settings page. + if ( ! isset( $current_section ) || 'amazon_payments_advanced' !== $current_section ) { + return; + } + + $screen = get_current_screen(); + + // Ensures we are in plugin's settings page. + if ( ! isset( $screen, $screen->id ) || 'woocommerce_page_wc-settings' !== $screen->id ) { + return; + } + ?> +
+

+ +

+ +

+ + + +

+

+ + + +

+

+ + + +

+ +
+