WPSEO_Metabox::get_metabox_post
Returns post in metabox context.
Метод класса: WPSEO_Metabox{}
Хуков нет.
Возвращает
WP_Post|Массив<Строку|int|true|false>.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_metabox_post();
Код WPSEO_Metabox::get_metabox_post() WPSEO Metabox::get metabox post Yoast 26.9
protected function get_metabox_post() {
if ( $this->post !== null ) {
return $this->post;
}
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
if ( isset( $_GET['post'] ) && is_string( $_GET['post'] ) ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, Sanitization happens in the validate_int function.
$post_id = (int) WPSEO_Utils::validate_int( wp_unslash( $_GET['post'] ) );
$this->post = get_post( $post_id );
return $this->post;
}
if ( isset( $GLOBALS['post'] ) ) {
$this->post = $GLOBALS['post'];
return $this->post;
}
return [];
}