| Server IP : 108.167.142.43 / Your IP : 216.73.217.58 Web Server : Apache System : Linux gator4174.hostgator.com 5.14.0-687.39.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Aug 18 06:09:16 EDT 2026 x86_64 User : delarice ( 2406) PHP Version : 8.3.36 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home2/delarice/www/wp-content/plugins/image-optimization/modules/core/components/ |
Upload File : |
<?php
namespace ImageOptimization\Modules\Core\Components;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class Pointers {
const DISMISSED_POINTERS_META_KEY = 'image_optimizer_dismissed_pointers';
public function dismiss_pointers() {
if ( empty( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'image-optimization-pointer-dismissed' ) ) {
wp_send_json_error( [ 'message' => 'Invalid nonce' ] );
}
$pointer = isset( $_POST['data']['pointer'] ) ?
sanitize_text_field( wp_unslash( $_POST['data']['pointer'] ) ) :
null;
if ( empty( $pointer ) ) {
wp_send_json_error( [ 'message' => 'The pointer id must be provided' ] );
}
$pointer = explode( ',', $pointer );
$user_dismissed_meta = get_user_meta( get_current_user_id(), self::DISMISSED_POINTERS_META_KEY, true );
if ( ! $user_dismissed_meta ) {
$user_dismissed_meta = [];
}
foreach ( $pointer as $item ) {
$user_dismissed_meta[ $item ] = true;
}
update_user_meta( get_current_user_id(), self::DISMISSED_POINTERS_META_KEY, $user_dismissed_meta );
wp_send_json_success( [] );
}
public static function is_dismissed( string $slug ): bool {
$meta = (array) get_user_meta( get_current_user_id(), self::DISMISSED_POINTERS_META_KEY, true );
return key_exists( $slug, $meta );
}
public function __construct() {
add_action( 'wp_ajax_image_optimizer_pointer_dismissed', [ $this, 'dismiss_pointers' ] );
}
}