WC_Product_Usage_Notice::ajax_dismiss()
AJAX handler for dismiss action of product usage notice.
Метод класса: WC_Product_Usage_Notice{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$result = WC_Product_Usage_Notice::ajax_dismiss();
Код WC_Product_Usage_Notice::ajax_dismiss() WC Product Usage Notice::ajax dismiss WC 9.4.2
public static function ajax_dismiss() { if ( ! check_ajax_referer( 'dismiss_product_usage_notice' ) ) { wp_die( -1 ); } $user_id = get_current_user_id(); if ( ! $user_id ) { wp_die( -1 ); } $product_id = absint( $_GET['product_id'] ?? 0 ); if ( ! $product_id ) { wp_die( -1 ); } $dismiss_count = absint( get_user_meta( $user_id, self::DISMISSED_COUNT_META_PREFIX . $product_id, true ) ); update_user_meta( $user_id, self::DISMISSED_COUNT_META_PREFIX . $product_id, $dismiss_count + 1 ); update_user_meta( $user_id, self::DISMISSED_TIMESTAMP_META_PREFIX . $product_id, time() ); update_user_meta( $user_id, self::LAST_DISMISSED_TIMESTAMP_META, time() ); wp_die( 1 ); }