| Server IP : 172.67.134.116 / Your IP : 216.73.217.140 Web Server : Apache System : Linux server.rehabsharif.com 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64 User : nobi37te ( 1003) PHP Version : 8.2.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/nobi37te/public_html/wp-content/plugins/analogwp-templates/inc/ |
Upload File : |
<?php
namespace Analog;
use Analog\Admin\Notice;
/**
* Class Consumer.
*
* Classname changed from User to Consumer due to a conflict with Elementor/User class usage.
*
* @since 1.5.0
* @package Analog
*/
final class Consumer {
const ADMIN_NOTICES_KEY = 'analog_admin_notices';
/**
* Init.
*
* @since 1.5.0
* @access public
*/
public function register() {
add_action( 'wp_ajax_analog_set_admin_notice_viewed', array( __CLASS__, 'ajax_set_admin_notice_viewed' ) );
add_action( 'admin_post_analog_set_admin_notice_viewed', array( __CLASS__, 'ajax_set_admin_notice_viewed' ) );
}
/**
* Set admin notice as viewed.
*
* Flag the user admin notice as viewed using an authenticated ajax request.
*
* Fired by `wp_ajax_elementor_set_admin_notice_viewed` action.
*
* @since 1.5.0
* @access public
* @static
*/
public static function ajax_set_admin_notice_viewed() {
check_ajax_referer( Notice::$nonce_action, 'nonce' );
$notices = self::get_user_notices();
if ( empty( $notices ) ) {
$notices = array();
}
if ( ! isset( $_POST['key'] ) ) {
wp_send_json_error();
}
$notices[ sanitize_key( $_POST['key'] ) ] = 'true';
update_user_meta( get_current_user_id(), self::ADMIN_NOTICES_KEY, $notices );
wp_send_json_success();
}
/**
* Is user notice viewed.
*
* Whether the notice was viewed by the user.
*
* @since 1.5.0
* @access public
* @static
*
* @param int $notice_id The notice ID.
*
* @return bool Whether the notice was viewed by the user.
*/
public static function is_user_notice_viewed( $notice_id ) {
$notices = self::get_user_notices();
return ! ( empty( $notices ) || empty( $notices[ $notice_id ] ) );
}
/**
* Get user notices.
*
* Retrieve the list of notices for the current user.
*
* @since 1.5.0
* @access private
* @static
*
* @return array A list of user notices.
*/
private static function get_user_notices() {
return get_user_meta( get_current_user_id(), self::ADMIN_NOTICES_KEY, true );
}
}