id, 'agentorie' ) ) { return false; } // Only for administrators. if ( ! current_user_can( 'manage_options' ) ) { return false; } $user_id = get_current_user_id(); // Permanently dismissed. if ( get_user_meta( $user_id, self::META_DISMISSED, true ) ) { return false; } // "Remind me later" still active. $remind_at = (int) get_user_meta( $user_id, self::META_REMIND_AT, true ); if ( $remind_at > 0 && time() < $remind_at ) { return false; } // Check minimum days since activation. $activated_at = (int) get_option( self::OPTION_ACTIVATED_AT, 0 ); if ( 0 === $activated_at || ( time() - $activated_at ) < ( self::MIN_DAYS * DAY_IN_SECONDS ) ) { return false; } // Check minimum conversations. $license_cache = get_transient( 'agentorie_chat_license_cache' ); $conversations = 0; if ( is_array( $license_cache ) && isset( $license_cache['usage']['conversations'] ) ) { $conversations = (int) $license_cache['usage']['conversations']; } if ( $conversations < self::MIN_CONVERSATIONS ) { return false; } self::$should_show = true; return true; } /** * Enqueue CSS and JS assets for the review notice. * * @since 1.1.7 * @param string $hook Current admin page hook. * @return void */ public static function enqueue_assets( $hook ) { if ( ! self::should_show() ) { return; } wp_enqueue_style( 'agentorie-chat-review-notice', AGENTORIE_CHAT_PLUGIN_URL . 'admin/css/review-notice.css', array(), AGENTORIE_CHAT_VERSION ); wp_enqueue_script( 'agentorie-chat-review-notice', AGENTORIE_CHAT_PLUGIN_URL . 'admin/js/review-notice.js', array(), AGENTORIE_CHAT_VERSION, true ); wp_localize_script( 'agentorie-chat-review-notice', 'agentorieReviewNotice', array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'agentorie_chat_review_dismiss' ), ) ); } /** * Display the review notice if conditions are met. * * @since 1.1.7 * @return void */ public static function maybe_display_notice() { if ( ! self::should_show() ) { return; } self::render_notice(); } /** * Render the review notice HTML. * * @since 1.1.7 * @return void */ private static function render_notice() { $review_url = 'https://wordpress.org/support/plugin/agentorie-chat/reviews/#new-post'; ?>
💬