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. Строка. $pagenow Current page identifier.
- Global. WP_Post|null. $post Current post object, or null if none available.
Код WPSEO_Admin_Bar_Menu::get_singular_post() WPSEO Admin Bar Menu::get singular post Yoast 22.4
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; }