Yoast\WP\SEO\Surfaces
Meta_Surface::for_url()
Returns the meta tags context for a url.
Метод класса: Meta_Surface{}
Хуков нет.
Возвращает
Meta|false
. The meta values. False if none could be found.
Использование
$Meta_Surface = new Meta_Surface(); $Meta_Surface->for_url( $url );
- $url(строка) (обязательный)
- The url of the page. Required to be relative to the site url.
Код Meta_Surface::for_url() Meta Surface::for url Yoast 24.3
public function for_url( $url ) { $url_parts = \wp_parse_url( $url ); $site_parts = \wp_parse_url( \site_url() ); if ( ( ! \is_array( $url_parts ) || ! \is_array( $site_parts ) ) || ! isset( $url_parts['host'], $url_parts['path'], $site_parts['host'], $site_parts['scheme'] ) ) { return false; } if ( $url_parts['host'] !== $site_parts['host'] ) { return false; } // Ensure the scheme is consistent with values in the DB. $url = $site_parts['scheme'] . '://' . $url_parts['host'] . $url_parts['path']; if ( $this->is_date_archive_url( $url ) ) { $indexable = $this->repository->find_for_date_archive(); } else { $indexable = $this->repository->find_by_permalink( $url ); } // If we still don't have an indexable abort, the WP globals could be anything so we can't use the unknown indexable. if ( ! $indexable ) { return false; } $page_type = $this->indexable_helper->get_page_type_for_indexable( $indexable ); if ( $page_type === false ) { return false; } return $this->build_meta( $this->context_memoizer->get( $indexable, $page_type ) ); }