WordPress at Your Fingertips
function is not described

WC_Marketplace_Suggestions::post_add_dismissed_suggestion_handler() public WC 1.0

POST handler for adding a dismissed suggestion.

{} It's a method of the class: WC_Marketplace_Suggestions{}

No Hooks.

Return

null. Nothing.

Usage

$result = WC_Marketplace_Suggestions::post_add_dismissed_suggestion_handler();

Code of WC_Marketplace_Suggestions::post_add_dismissed_suggestion_handler() WC 5.9.0

public static function post_add_dismissed_suggestion_handler() {
	if ( ! check_ajax_referer( 'add_dismissed_marketplace_suggestion' ) ) {
		wp_die();
	}

	$post_data       = wp_unslash( $_POST );
	$suggestion_slug = sanitize_text_field( $post_data['slug'] );
	if ( ! $suggestion_slug ) {
		wp_die();
	}

	$dismissed_suggestions = self::get_dismissed_suggestions();

	if ( in_array( $suggestion_slug, $dismissed_suggestions, true ) ) {
		wp_die();
	}

	$dismissed_suggestions[] = $suggestion_slug;
	update_user_meta(
		get_current_user_id(),
		'wc_marketplace_suggestions_dismissed_suggestions',
		$dismissed_suggestions
	);

	wp_die();
}