Yoast\WP\SEO\Helpers

Current_Page_Helper::get_current_taxonomy │ public │ Yoast 1.0

Retrieves the current taxonomy.

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

Хуков нет.

Возвращает

string. The taxonomy.

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

$Current_Page_Helper = new Current_Page_Helper();
$Current_Page_Helper->get_current_taxonomy(): string;

Код Current_Page_Helper::get_current_taxonomy() Yoast 28.9

public function get_current_taxonomy(): string {
	if ( ! isset( $_SERVER['REQUEST_METHOD'] ) || ! \in_array( $_SERVER['REQUEST_METHOD'], [ 'GET', 'POST' ], true ) ) {
		return '';
	}

	// phpcs:ignore WordPress.Security.NonceVerification -- Reason: We are not processing form information.
	if ( $_SERVER['REQUEST_METHOD'] === 'POST' ) {
		// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Reason: should be done outside the helper function.
		if ( isset( $_POST['taxonomy'] ) && \is_string( $_POST['taxonomy'] ) ) {
			// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Reason: should be done outside the helper function.
			return \sanitize_text_field( \wp_unslash( $_POST['taxonomy'] ) );
		}
		return '';
	}

	// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
	if ( isset( $_GET['taxonomy'] ) && \is_string( $_GET['taxonomy'] ) ) {
		// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
		return \sanitize_text_field( \wp_unslash( $_GET['taxonomy'] ) );
	}

	return '';
}