ng edited). * * @global \WP_Query $wp_the_query * * @return false|WP_Post The Post object, false if we are not on a post. */ public function get_current_post() { global $wp_the_query; if ( \is_admin() ) { $post = \get_post(); } else { $post = $wp_the_query->get_queried_object(); } if ( empty( $post ) || ! $post instanceof WP_Post ) { return false; } if ( ( ! $this->permissions_helper->is_edit_post_screen() && ! \is_singular( $post->post_type ) ) || ! $this->permissions_helper->post_type_has_admin_bar( $post->post_type ) ) { return false; } if ( ! $this->permissions_helper->should_links_be_displayed( $post ) ) { return false; } return $post; } }