wp_create_nonce( 'adasprso-dismiss-notice-nonce' ), 'ajaxurl' => admin_url( 'admin-ajax.php' ), ) ); } /** * Display the review request notice after 8 days, then again at 16 days * if the user dismissed round 1 without leaving a review. */ public function display_review_notice() { if ( ! current_user_can( 'manage_options' ) ) { return; } // Skip on our own settings page. $screen = get_current_screen(); if ( $screen && 'settings_page_add-as-preferred-source' === $screen->id ) { return; } // Never show again once the user has left (or clicked) a review. if ( get_option( 'adasprso_user_already_reviewed', false ) ) { return; } $activation_date = get_option( 'adasprso_activation_date', false ); if ( false === $activation_date ) { return; } $days_active = ( time() - $activation_date ) / DAY_IN_SECONDS; $r1_dismissed = get_option( 'adasprso_review_notice_dismissed', false ); $r2_dismissed = get_option( 'adasprso_review_dismissed_r2', false ); if ( $days_active >= 16 && $r1_dismissed && ! $r2_dismissed ) { $round = 2; } elseif ( $days_active >= 8 && ! $r1_dismissed ) { $round = 1; } else { return; } wp_enqueue_style( 'adasprso-admin-notices', ADASPRSO_PLUGIN_URL . 'admin/css/admin-notices.css', array(), ADASPRSO_VERSION ); wp_enqueue_script( 'adasprso-admin-notices' ); $review_url = 'https://wordpress.org/support/plugin/add-as-preferred-source/reviews/#new-post'; $support_url = 'https://wordpress.org/support/plugin/add-as-preferred-source/#new-topic-0'; ?> 'Unauthorized' ) ); wp_die(); } $round = isset( $_POST['round'] ) ? absint( $_POST['round'] ) : 1; if ( 2 === $round ) { update_option( 'adasprso_review_dismissed_r2', true ); } else { update_option( 'adasprso_review_notice_dismissed', true ); } if ( isset( $_POST['dismiss_reason'] ) ) { $dismiss_reason = sanitize_text_field( wp_unslash( $_POST['dismiss_reason'] ) ); if ( in_array( $dismiss_reason, array( 'already_reviewed', 'leave_review_clicked' ), true ) ) { update_option( 'adasprso_user_already_reviewed', true ); } elseif ( in_array( $dismiss_reason, array( 'needs_help_dismissed', 'needs_help_clicked' ), true ) ) { update_option( 'adasprso_user_needs_help', true ); } } wp_send_json_success(); } }