past_date = false == get_option('wpr_maybe_later_time') ? strtotime( '-14 days' ) : strtotime('-7 days'); if ( current_user_can('administrator') ) { if ( empty(get_option('wpr_rating_dismiss_notice', false)) && empty(get_option('wpr_rating_already_rated', false)) ) { add_action( 'admin_init', [$this, 'check_plugin_install_time'] ); } } if ( is_admin() ) { add_action( 'admin_head', [$this, 'enqueue_scripts' ] ); } add_action( 'wp_ajax_wpr_rating_dismiss_notice', [$this, 'wpr_rating_dismiss_notice'] ); add_action( 'wp_ajax_wpr_rating_maybe_later', [$this, 'wpr_rating_maybe_later'] ); add_action( 'wp_ajax_wpr_rating_already_rated', [$this, 'wpr_rating_already_rated'] ); add_action( 'wp_ajax_wpr_rating_need_help', [$this, 'wpr_rating_need_help'] ); } public function check_plugin_install_time() { $install_date = get_option('royal_elementor_addons_activation_time'); if ( false == get_option('wpr_maybe_later_time') && false !== $install_date && $this->past_date >= $install_date ) { add_action( 'admin_notices', [$this, 'render_rating_notice' ]); } else if ( false != get_option('wpr_maybe_later_time') && $this->past_date >= get_option('wpr_maybe_later_time') ) { add_action( 'admin_notices', [$this, 'render_rating_notice' ]); } } public function wpr_rating_maybe_later() { $nonce = $_POST['nonce']; if ( !wp_verify_nonce( $nonce, 'wpr-plugin-notice-js') || !current_user_can( 'manage_options' ) ) { exit; // Get out of here, the nonce is rotten! } update_option( 'wpr_maybe_later_time', strtotime('now') ); } function wpr_rating_already_rated() { $nonce = $_POST['nonce']; if ( !wp_verify_nonce( $nonce, 'wpr-plugin-notice-js') || !current_user_can( 'manage_options' ) ) { exit; // Get out of here, the nonce is rotten! } update_option( 'wpr_rating_already_rated' , true ); } public function wpr_rating_dismiss_notice() { $nonce = $_POST['nonce']; if ( !wp_verify_nonce( $nonce, 'wpr-plugin-notice-js') || !current_user_can( 'manage_options' ) ) { exit; // Get out of here, the nonce is rotten! } update_option( 'wpr_rating_dismiss_notice', true ); } public function wpr_rating_need_help() { $nonce = $_POST['nonce']; if ( !wp_verify_nonce( $nonce, 'wpr-plugin-notice-js') || !current_user_can( 'manage_options' ) ) { exit; // Get out of here, the nonce is rotten! } // Reset Activation Time if user Needs Help update_option( 'royal_elementor_addons_activation_time', strtotime('now') ); } public function render_rating_notice() { global $pagenow; if ( is_admin() ) { $plugin_info = get_plugin_data( __FILE__ , true, true ); $dont_disturb = esc_url( get_admin_url() . '?spare_me=1' ); echo '
'; // I need support! // NO, not good enough } } public static function enqueue_scripts() { echo " "; echo " "; } } if ( 'Royal Addons' === Utilities::get_plugin_name() ) { new WprRatingNotice(); }