WPSEO_Admin_Bar_Menu::get_singular_post
Gets the current post if in a singular post context.
Метод класса: WPSEO_Admin_Bar_Menu{}
Хуков нет.
Возвращает
WP_Post|null. Post object, or null if not in singular context.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_singular_post();
Заметки
- Global. Строка.
$pagenowCurrent page identifier. - Global. WP_Post|null.
$postCurrent post object, or null if none available.
Код WPSEO_Admin_Bar_Menu::get_singular_post() WPSEO Admin Bar Menu::get singular post Yoast 27.3
protected function get_singular_post() {
global $pagenow, $post;
if ( ! is_singular() && ( ! is_blog_admin() || ! WPSEO_Metabox::is_post_edit( $pagenow ) ) ) {
return null;
}
if ( ! isset( $post ) || ! is_object( $post ) || ! $post instanceof WP_Post ) {
return null;
}
return $post;
}