WPSEO_Primary_Term_Admin::get_current_id()protectedYoast 1.0

Gets the current post ID.

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

Хуков нет.

Возвращает

int. The post ID.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_current_id();

Код WPSEO_Primary_Term_Admin::get_current_id() Yoast 22.4

protected function get_current_id() {
	// phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, We are casting to an integer.
	$post_id = isset( $_GET['post'] ) && is_string( $_GET['post'] ) ? (int) wp_unslash( $_GET['post'] ) : 0;

	if ( $post_id === 0 && isset( $GLOBALS['post_ID'] ) ) {
		$post_id = (int) $GLOBALS['post_ID'];
	}

	return $post_id;
}