WPSEO_Shortcode_Filter::do_filter()publicYoast 1.0

Parse the shortcodes.

Метод класса: WPSEO_Shortcode_Filter{}

Хуков нет.

Возвращает

null. Ничего.

Использование

$WPSEO_Shortcode_Filter = new WPSEO_Shortcode_Filter();
$WPSEO_Shortcode_Filter->do_filter();

Код WPSEO_Shortcode_Filter::do_filter() Yoast 19.11

public function do_filter() {
	check_ajax_referer( 'wpseo-filter-shortcodes', 'nonce' );

	if ( ! isset( $_POST['data'] ) || ! is_array( $_POST['data'] ) ) {
		// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: WPSEO_Utils::format_json_encode is considered safe.
		wp_die( WPSEO_Utils::format_json_encode( [] ) );
	}

	// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: $shortcodes is getting sanitized later, before it's used.
	$shortcodes        = wp_unslash( $_POST['data'] );
	$parsed_shortcodes = [];

	foreach ( $shortcodes as $shortcode ) {
		if ( $shortcode !== sanitize_text_field( $shortcode ) ) {
			// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: WPSEO_Utils::format_json_encode is considered safe.
			wp_die( WPSEO_Utils::format_json_encode( [] ) );
		}

		$parsed_shortcodes[] = [
			'shortcode' => $shortcode,
			'output'    => do_shortcode( $shortcode ),
		];
	}

	// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: WPSEO_Utils::format_json_encode is considered safe.
	wp_die( WPSEO_Utils::format_json_encode( $parsed_shortcodes ) );
}