is_dismissed() ) { return; } // The dismiss handler is attached through the script API (1.21.13), // in the footer, where the notice element already exists. wp_register_script( 'cachingout-object-cache-notice', false, array(), CACHINGOUT_VERSION, true ); wp_enqueue_script( 'cachingout-object-cache-notice' ); wp_add_inline_script( 'cachingout-object-cache-notice', sprintf( '(function(){var el=document.getElementById("cachingout-object-cache-notice");if(!el){return;}' . 'el.addEventListener("click",function(e){if(e.target.closest(".notice-dismiss")){' . 'fetch(%1$s,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},' . 'body:new URLSearchParams({action:"cachingout_dismiss_object_cache_notice",nonce:%2$s})});}});})();', wp_json_encode( admin_url( 'admin-ajax.php' ) ), wp_json_encode( wp_create_nonce( 'cachingout_dismiss_object_cache_notice' ) ) ) ); ?>

:

'Insufficient permissions.' ) ); } update_user_meta( get_current_user_id(), self::DISMISS_META_KEY, 1 ); wp_send_json_success(); } /** * Check if the current user has dismissed the notice. * * @since 0.1.1 * * @return bool True if dismissed. */ private function is_dismissed(): bool { return (bool) get_user_meta( get_current_user_id(), self::DISMISS_META_KEY, true ); } }