JFIF $ d d 7 * Z qn )ZP 0 !1 A "#a$2Qr D8 a Ri [f \m I ykI w0 c u F c Rı?lO7 к _f˓ [C $殷WF< _W ԣ s Kc ëI zyQy /_LK ℂ ;C",p F A : /] =H ~ , l s / 9 ć: [=/#f ; ) x { ٛE Q )~ = 𘙲r*2~ a _V = ' ku m F D } KYYC )( { * g& f `툪 r y ` = ^ c J. I ]( * `wq 1dđ #̩ ͑ 0 ; H ] u 搂 @:~ ו K L N s h } O I R* 8 :2 ! lD JV o ( 3 = M ( z Ȱ+i *N A r6K n S l ) ! J J Ӂ* % ݉?|D } d5: eP0 R; {$X' x F @ .ÊB {,WJ uQ ɲRI ;9 Q E琯 6 2fT .DU J ;*c P A\IL Nj! J ۱+ O\ ͔ ] ޒ S J ȧ c%A N ol ՎprU L Zԛe r E2= X D Xg VQeӓ k y P7 U* o m Q I s ,K `) 6\G3t?pgjr m ۛجw luGt f h 9uyP 0D;Uڽ"OXl i f $ ) &|ML 0 Z rm1 [ H XP l P R0 'G=i 2N +0 e 2 ]] 9 VT P O 7 h(F * 癈 ' = Q VZD F,d ߬ ~ T X G[ `le 69C R(!S2! P < 0 x < !1AQ "Raq 02Br #S CTb ? Ζ "]mH5WR 7 k.ۛ ! } Q~ + yԏ z |@ T20 S~ K e k *zF f^2X *( @ 8 r ? C I uI|֓>^Ex LgNU Y+{.R Ѫ τV YT D I 6 2 '8Y2 7'\T P.6 d &˦ @V q i |8 -O Ε ] ʔ U= T L 8= ;6c | !qfF3 a ů& ~$ l} 'NW U s$U k^S V : U#6w + +s &r+n ڐ { @ 29gL u " T Ù M=6 (^ "7 r}=6Yݾ lC u hquymp Ǧ G jhs ǜNl ɻ} o 7 #S6 a w 4 ! OS r D 5 7 % | ?x> L | / nD 6?/8 w # [ ) L 7 +6〼T A T g ! %5 Mm Z /c -{1_Je "| ^$ 'O & ޱմ < H vNqϡQ$ < 6 &Nݛ ֨tǻN (9 n ru~'όN sMG& ,uH Kw *Ī 5@ u6 BԒ i YN * f 0 _ GhKW u lT <nj- 0{ M L~ | /a v\ E = ?1 \ɟuq Ђ Y O a K ޡP q $ H8o Q˼EV ~ k 0 h' L Pp M -M" m^ !6l nմ 쮝C U T . ! :vMǨb h ډ Vc r @~p # !1QAa q ? AL0L x LU 4 d ; x " 16ad0 7.\ߋ 0 = P l v/ " c A Ay A|2pO8"d MV #1] = \ " ˡ ] k v I9 d ۓ & q ) ǐq E ꞅ v "P )q X &Q З non]я u ג./ ; gZ$ M QР 2M ]h ni 0 P $ێ 3CɏGjώy : m c # S_ l@ '_ \m|C 2`K _ 1 cIvGc $? PCQ S+D ? K aײ k Fr b 8 ύ NEدg ĝ U 3 6 #Ik+ v { v i ( ވ ? a e) X xy/*@Q Ǽ Ծ ) $ IWO l c G; !i k{ gOŀ L ('x T rb $ w) R $ & N1E td U3Uȉ1p M"N* (DNy d96.(jQ) X 5 c QɎMy W ? Q *!R > 6=7)Xj 5`J ] e 8%t ! + ' ! 1Q 5 !1 AQaq ё #2 "0BRb ? G t^ ## .l lQ T $ v , ,m 㵜5u bV =sY+ @d { N ! dn O < .- B; _w J t 6;Q Jd. Q c%p{ 1 ,sND dF H I0 Гo X ш e黅X ۢ F :)[ F G X ƹ / w _c MeD ,ʡc c . W D tA $ j@ : ) - #u c1< @ۗ9F ) KJ- hpP] _ x [ q B lb p ʖ w q " LFGd ƶ * s +ډ_Zc " ? % t[I P 6 J ]# =ɺ V v v CGs Gh1 > )6 |e y ? L ӣ m,4 G W Ui ` ] uJVo VDG< SB 6ϏQ @ TiU l y O U 0 kfV ~ ~}S Z @ *WU Ui ## ; s /[ = ! 7}" W N ] ' (L ! ~ y5 g9T̅J kbM' +s :S +B) v @ M j e C f j E 0 Y\Qn z G 1 д~ W o{T 9?` Rm yhsy3 !HAD ] m c1 ~ 2 L S u7x T ;j$ `} 4-> L# vzŏ I L S ֭ T { r jGK C ; b pU= - ` Bs K. S F w4 M q] Z dH S 0 ) tLg
<?php
namespace Yoast\WP\SEO\Surfaces;
use Yoast\WP\SEO\Context\Meta_Tags_Context;
use Yoast\WP\SEO\Helpers\Indexable_Helper;
use Yoast\WP\SEO\Memoizers\Meta_Tags_Context_Memoizer;
use Yoast\WP\SEO\Models\Indexable;
use Yoast\WP\SEO\Repositories\Indexable_Repository;
use Yoast\WP\SEO\Surfaces\Values\Meta;
use Yoast\WP\SEO\Wrappers\WP_Rewrite_Wrapper;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Meta_Surface class.
*
* Surface for the indexables.
*/
class Meta_Surface {
/**
* The container.
*
* @var ContainerInterface
*/
private $container;
/**
* The memoizer for the meta tags context.
*
* @var Meta_Tags_Context_Memoizer
*/
private $context_memoizer;
/**
* The indexable repository.
*
* @var Indexable_Repository
*/
private $repository;
/**
* Holds the WP rewrite wrapper instance.
*
* @var WP_Rewrite_Wrapper
*/
private $wp_rewrite_wrapper;
/**
* The indexable helper.
*
* @var Indexable_Helper
*/
private $indexable_helper;
/**
* Meta_Surface constructor.
*
* @param ContainerInterface $container The DI container.
* @param Meta_Tags_Context_Memoizer $context_memoizer The meta tags context memoizer.
* @param Indexable_Repository $indexable_repository The indexable repository.
* @param WP_Rewrite_Wrapper $wp_rewrite_wrapper The WP rewrite wrapper.
* @param Indexable_Helper $indexable_helper The indexable helper.
*/
public function __construct(
ContainerInterface $container,
Meta_Tags_Context_Memoizer $context_memoizer,
Indexable_Repository $indexable_repository,
WP_Rewrite_Wrapper $wp_rewrite_wrapper,
Indexable_Helper $indexable_helper
) {
$this->container = $container;
$this->context_memoizer = $context_memoizer;
$this->repository = $indexable_repository;
$this->wp_rewrite_wrapper = $wp_rewrite_wrapper;
$this->indexable_helper = $indexable_helper;
}
/**
* Returns the meta tags context for the current page.
*
* @return Meta The meta values.
*/
public function for_current_page() {
return $this->build_meta( $this->context_memoizer->for_current_page() );
}
/**
* Returns the meta tags context for the home page.
*
* @return Meta|false The meta values. False if none could be found.
*/
public function for_home_page() {
$front_page_id = (int) \get_option( 'page_on_front' );
if ( \get_option( 'show_on_front' ) === 'page' && $front_page_id !== 0 ) {
$indexable = $this->repository->find_by_id_and_type( $front_page_id, 'post' );
if ( ! $indexable ) {
return false;
}
return $this->build_meta( $this->context_memoizer->get( $indexable, 'Static_Home_Page' ) );
}
$indexable = $this->repository->find_for_home_page();
if ( ! $indexable ) {
return false;
}
return $this->build_meta( $this->context_memoizer->get( $indexable, 'Home_Page' ) );
}
/**
* Returns the meta tags context for the posts page.
*
* @return Meta|false The meta values. False if none could be found.
*/
public function for_posts_page() {
$posts_page_id = (int) \get_option( 'page_for_posts' );
if ( $posts_page_id !== 0 ) {
$indexable = $this->repository->find_by_id_and_type( $posts_page_id, 'post' );
if ( ! $indexable ) {
return false;
}
return $this->build_meta( $this->context_memoizer->get( $indexable, 'Static_Posts_Page' ) );
}
$indexable = $this->repository->find_for_home_page();
if ( ! $indexable ) {
return false;
}
return $this->build_meta( $this->context_memoizer->get( $indexable, 'Home_Page' ) );
}
/**
* Returns the meta tags context for a post type archive.
*
* @param string|null $post_type Optional. The post type to get the archive meta for. Defaults to the current post type.
*
* @return Meta|false The meta values. False if none could be found.
*/
public function for_post_type_archive( $post_type = null ) {
$post_type ??= \get_post_type();
$indexable = $this->repository->find_for_post_type_archive( $post_type );
if ( ! $indexable ) {
return false;
}
return $this->build_meta( $this->context_memoizer->get( $indexable, 'Post_Type_Archive' ) );
}
/**
* Returns the meta tags context for the search result page.
*
* @return Meta|false The meta values. False if none could be found.
*/
public function for_search_result() {
$indexable = $this->repository->find_for_system_page( 'search-result' );
if ( ! $indexable ) {
return false;
}
return $this->build_meta( $this->context_memoizer->get( $indexable, 'Search_Result_Page' ) );
}
/**
* Returns the meta tags context for the search result page.
*
* @return Meta|false The meta values. False if none could be found.
*/
public function for_404() {
$indexable = $this->repository->find_for_system_page( '404' );
if ( ! $indexable ) {
return false;
}
return $this->build_meta( $this->context_memoizer->get( $indexable, 'Error_Page' ) );
}
/**
* Returns the meta tags context for a post.
*
* @param int $id The ID of the post.
*
* @return Meta|false The meta values. False if none could be found.
*/
public function for_post( $id ) {
$indexable = $this->repository->find_by_id_and_type( $id, 'post' );
if ( ! $indexable ) {
return false;
}
return $this->build_meta( $this->context_memoizer->get( $indexable, 'Post_Type' ) );
}
/**
* Returns the meta tags context for a number of posts.
*
* @param int[] $ids The IDs of the posts.
*
* @return Meta[]|false The meta values. False if none could be found.
*/
public function for_posts( $ids ) {
$indexables = $this->repository->find_by_multiple_ids_and_type( $ids, 'post' );
if ( empty( $indexables ) ) {
return false;
}
// Remove all false values.
$indexables = \array_filter( $indexables );
return \array_map(
function ( $indexable ) {
return $this->build_meta( $this->context_memoizer->get( $indexable, 'Post_Type' ) );
},
$indexables,
);
}
/**
* Returns the meta tags context for a term.
*
* @param int $id The ID of the term.
*
* @return Meta|false The meta values. False if none could be found.
*/
public function for_term( $id ) {
$indexable = $this->repository->find_by_id_and_type( $id, 'term' );
if ( ! $indexable ) {
return false;
}
return $this->build_meta( $this->context_memoizer->get( $indexable, 'Term_Archive' ) );
}
/**
* Returns the meta tags context for an author.
*
* @param int $id The ID of the author.
*
* @return Meta|false The meta values. False if none could be found.
*/
public function for_author( $id ) {
$indexable = $this->repository->find_by_id_and_type( $id, 'user' );
if ( ! $indexable ) {
return false;
}
return $this->build_meta( $this->context_memoizer->get( $indexable, 'Author_Archive' ) );
}
/**
* Returns the meta for an indexable.
*
* @param Indexable $indexable The indexable.
* @param string|null $page_type Optional. The page type if already known.
*
* @return Meta|false The meta values. False if none could be found.
*/
public function for_indexable( $indexable, $page_type = null ) {
if ( ! \is_a( $indexable, Indexable::class ) ) {
return false;
}
$page_type ??= $this->indexable_helper->get_page_type_for_indexable( $indexable );
return $this->build_meta( $this->context_memoizer->get( $indexable, $page_type ) );
}
/**
* Returns the meta for an indexable.
*
* @param Indexable[] $indexables The indexables.
* @param string|null $page_type Optional. The page type if already known.
*
* @return Meta|false The meta values. False if none could be found.
*/
public function for_indexables( $indexables, $page_type = null ) {
$closure = function ( $indexable ) use ( $page_type ) {
$this_page_type = $page_type;
$this_page_type ??= $this->indexable_helper->get_page_type_for_indexable( $indexable );
return $this->build_meta( $this->context_memoizer->get( $indexable, $this_page_type ) );
};
return \array_map( $closure, $indexables );
}
/**
* Returns the meta tags context for a url.
*
* @param string $url The url of the page. Required to be relative to the site url.
*
* @return Meta|false The meta values. False if none could be found.
*/
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 ) );
}
/**
* Checks if a given URL is a date archive URL.
*
* @param string $url The url.
*
* @return bool
*/
protected function is_date_archive_url( $url ) {
$path = \wp_parse_url( $url, \PHP_URL_PATH );
if ( $path === null ) {
return false;
}
$path = \ltrim( $path, '/' );
$wp_rewrite = $this->wp_rewrite_wrapper->get();
$date_rewrite = $wp_rewrite->generate_rewrite_rules( $wp_rewrite->get_date_permastruct(), \EP_DATE );
$date_rewrite = \apply_filters( 'date_rewrite_rules', $date_rewrite );
foreach ( (array) $date_rewrite as $match => $query ) {
if ( \preg_match( "#^$match#", $path ) ) {
return true;
}
}
return false;
}
/**
* Creates a new meta value object
*
* @param Meta_Tags_Context $context The meta tags context.
*
* @return Meta The meta value
*/
protected function build_meta( Meta_Tags_Context $context ) {
return new Meta( $context, $this->container );
}
}