Файловый менеджер - Редактировать - /home/kunzqhe/photostocker/2/presentations.tar
Назад
indexable-error-page-presentation.php 0000644 00000001265 15154100313 0013757 0 ustar 00 <?php namespace Yoast\WP\SEO\Presentations; /** * Class Indexable_Error_Page_Presentation. * * Presentation object for indexables. */ class Indexable_Error_Page_Presentation extends Indexable_Presentation { /** * Generates the robots value. * * @return array The robots value. */ public function generate_robots() { $robots = $this->get_base_robots(); $robots['index'] = 'noindex'; return $this->filter_robots( $robots ); } /** * Generates the title. * * @return string The title. */ public function generate_title() { if ( $this->model->title ) { return $this->model->title; } return $this->options->get_title_default( 'title-404-wpseo' ); } } indexable-date-archive-presentation.php 0000644 00000005512 15154100313 0014247 0 ustar 00 <?php namespace Yoast\WP\SEO\Presentations; use Yoast\WP\SEO\Helpers\Pagination_Helper; /** * Class Indexable_Date_Archive_Presentation. * * Presentation object for indexables. */ class Indexable_Date_Archive_Presentation extends Indexable_Presentation { /** * Holds the Pagination_Helper instance. * * @var Pagination_Helper */ protected $pagination; /** * Indexable_Date_Archive_Presentation constructor. * * @param Pagination_Helper $pagination The pagination helper. */ public function __construct( Pagination_Helper $pagination ) { $this->pagination = $pagination; } /** * Generates the canonical. * * @return string The canonical. */ public function generate_canonical() { $canonical = $this->current_page->get_date_archive_permalink(); $current_page = $this->pagination->get_current_archive_page_number(); if ( $current_page > 1 ) { return $this->pagination->get_paginated_url( $canonical, $current_page ); } return $canonical; } /** * Generates the robots value. * * @return array The robots value. */ public function generate_robots() { $robots = $this->get_base_robots(); if ( $this->options->get( 'noindex-archive-wpseo', false ) ) { $robots['index'] = 'noindex'; } return $this->filter_robots( $robots ); } /** * Generates the title. * * @return string The title. */ public function generate_title() { if ( $this->model->title ) { return $this->model->title; } return $this->options->get_title_default( 'title-archive-wpseo' ); } /** * Generates the rel prev. * * @return string The rel prev value. */ public function generate_rel_prev() { if ( $this->pagination->is_rel_adjacent_disabled() ) { return ''; } $current_page = \max( 1, $this->pagination->get_current_archive_page_number() ); // Check if there is a previous page. if ( $current_page === 1 ) { return ''; } // Check if the previous page is the first page. if ( $current_page === 2 ) { return $this->current_page->get_date_archive_permalink(); } return $this->pagination->get_paginated_url( $this->current_page->get_date_archive_permalink(), ( $current_page - 1 ) ); } /** * Generates the rel next. * * @return string The rel prev next. */ public function generate_rel_next() { if ( $this->pagination->is_rel_adjacent_disabled() ) { return ''; } $current_page = \max( 1, $this->pagination->get_current_archive_page_number() ); if ( $this->pagination->get_number_of_archive_pages() <= $current_page ) { return ''; } return $this->pagination->get_paginated_url( $this->current_page->get_date_archive_permalink(), ( $current_page + 1 ) ); } /** * Generates the open graph url. * * @return string The open graph url. */ public function generate_open_graph_url() { return $this->current_page->get_date_archive_permalink(); } } indexable-post-type-archive-presentation.php 0000644 00000002723 15154100313 0015277 0 ustar 00 <?php namespace Yoast\WP\SEO\Presentations; /** * Class Indexable_Post_Type_Archive_Presentation. * * Presentation object for indexables. */ class Indexable_Post_Type_Archive_Presentation extends Indexable_Presentation { use Archive_Adjacent; /** * Generates the canonical. * * @return string The canonical. */ public function generate_canonical() { $permalink = $this->get_permalink(); if ( ! $permalink ) { return ''; } $current_page = $this->pagination->get_current_archive_page_number(); if ( $current_page > 1 ) { return $this->pagination->get_paginated_url( $permalink, $current_page ); } return $permalink; } /** * Generates the robots value. * * @return array The robots value. */ public function generate_robots() { $robots = $this->get_base_robots(); if ( $this->options->get( 'noindex-ptarchive-' . $this->model->object_sub_type, false ) ) { $robots['index'] = 'noindex'; } return $this->filter_robots( $robots ); } /** * Generates the title. * * @return string The title. */ public function generate_title() { if ( $this->model->title ) { return $this->model->title; } $post_type = $this->model->object_sub_type; $title = $this->options->get_title_default( 'title-ptarchive-' . $post_type ); return $title; } /** * Generates the source. * * @return array The source. */ public function generate_source() { return [ 'post_type' => $this->model->object_sub_type ]; } } abstract-presentation.php 0000644 00000004442 15154100313 0011566 0 ustar 00 <?php namespace Yoast\WP\SEO\Presentations; use Exception; /** * The abstract presentation class. */ class Abstract_Presentation { /** * The model. * * @var mixed */ public $model; /** * Whether or not there is a presentation prototype. * * @var bool */ private $is_prototype = true; /** * Creates a model presentation. * * @param array $data The data that this is a presentation of. * * @return static A model presentation. * * @throws Exception If attempting to create a model presentation from another model presentation. */ public function of( $data ) { if ( ! $this->is_prototype() ) { throw new Exception( 'Attempting to create a model presentation from another model presentation. Use the prototype presentation gained from DI instead.' ); } // Clone self to allow stateful services that do benefit from DI. $presentation = clone $this; foreach ( $data as $key => $value ) { $presentation->{$key} = $value; } $presentation->is_prototype = false; return $presentation; } /** * Magic getter for lazy loading of generate functions. * * @param string $name The property to get. * * @return mixed The value if it could be generated. * * @throws Exception If there is no generator for the property. */ public function __get( $name ) { if ( $this->is_prototype() ) { throw new Exception( 'Attempting property access on prototype presentation. Use Presentation::of( $data ) to get a model presentation.' ); } $generator = "generate_$name"; if ( \method_exists( $this, $generator ) ) { $this->{$name} = $this->$generator(); return $this->{$name}; } throw new Exception( "Property $name has no generator. Expected function $generator." ); } /** * Magic isset for ensuring methods that have a generator are recognised. * * @codeCoverageIgnore Wrapper method. * * @param string $name The property to get. * * @return bool Whether or not there is a generator for the requested property. */ public function __isset( $name ) { return \method_exists( $this, "generate_$name" ); } /** * Returns `true` if this class is a prototype. * * @codeCoverageIgnore Wrapper method. * * @return bool If this class is a prototype or not. */ protected function is_prototype() { return $this->is_prototype; } } indexable-static-home-page-presentation.php 0000644 00000001411 15154100313 0015034 0 ustar 00 <?php namespace Yoast\WP\SEO\Presentations; /** * Class Indexable_Static_Home_Page_Presentation. * * Presentation object for indexables. */ class Indexable_Static_Home_Page_Presentation extends Indexable_Post_Type_Presentation { /** * Wraps the get_paginated_url pagination helper method. * * @param string $url The un-paginated URL of the current archive. * @param string $page The page number to add on to $url for the $link tag. * * @return string The paginated URL. */ protected function get_paginated_url( $url, $page ) { return $this->pagination->get_paginated_url( $url, $page ); } /** * Generates the Open Graph type. * * @return string The Open Graph type. */ public function generate_open_graph_type() { return 'website'; } } indexable-post-type-presentation.php 0000644 00000024654 15154100313 0013667 0 ustar 00 <?php namespace Yoast\WP\SEO\Presentations; use Yoast\WP\SEO\Helpers\Date_Helper; use Yoast\WP\SEO\Helpers\Pagination_Helper; use Yoast\WP\SEO\Helpers\Post_Helper; use Yoast\WP\SEO\Helpers\Post_Type_Helper; /** * Class Indexable_Post_Type_Presentation. * * Presentation object for indexables. */ class Indexable_Post_Type_Presentation extends Indexable_Presentation { /** * Holds the Post_Type_Helper instance. * * @var Post_Type_Helper */ protected $post_type; /** * Holds the Date_Helper instance. * * @var Date_Helper */ protected $date; /** * Holds the Pagination_Helper instance. * * @var Pagination_Helper */ protected $pagination; /** * Holds the Post_Helper instance. * * @var Post_Helper */ protected $post; /** * Indexable_Post_Type_Presentation constructor. * * @codeCoverageIgnore * * @param Post_Type_Helper $post_type The post type helper. * @param Date_Helper $date The date helper. * @param Pagination_Helper $pagination The pagination helper. * @param Post_Helper $post The post helper. */ public function __construct( Post_Type_Helper $post_type, Date_Helper $date, Pagination_Helper $pagination, Post_Helper $post ) { $this->post_type = $post_type; $this->date = $date; $this->pagination = $pagination; $this->post = $post; } /** * Generates the canonical. * * @return string The canonical. */ public function generate_canonical() { if ( $this->model->canonical ) { return $this->model->canonical; } $permalink = $this->get_permalink(); // Fix paginated pages canonical, but only if the page is truly paginated. $current_page = $this->pagination->get_current_post_page_number(); if ( $current_page > 1 ) { $number_of_pages = $this->model->number_of_pages; if ( $number_of_pages && $current_page <= $number_of_pages ) { $permalink = $this->get_paginated_url( $permalink, $current_page ); } } return $this->url->ensure_absolute_url( $permalink ); } /** * Generates the rel prev. * * @return string The rel prev value. */ public function generate_rel_prev() { if ( $this->model->number_of_pages === null ) { return ''; } if ( $this->pagination->is_rel_adjacent_disabled() ) { return ''; } $current_page = \max( 1, $this->pagination->get_current_post_page_number() ); // Check if there is a previous page. if ( $current_page < 2 ) { return ''; } // Check if the previous page is the first page. if ( $current_page === 2 ) { return $this->model->permalink; } return $this->get_paginated_url( $this->model->permalink, ( $current_page - 1 ) ); } /** * Generates the rel next. * * @return string The rel prev next. */ public function generate_rel_next() { if ( $this->model->number_of_pages === null ) { return ''; } if ( $this->pagination->is_rel_adjacent_disabled() ) { return ''; } $current_page = \max( 1, $this->pagination->get_current_post_page_number() ); if ( $this->model->number_of_pages <= $current_page ) { return ''; } return $this->get_paginated_url( $this->model->permalink, ( $current_page + 1 ) ); } /** * Generates the open graph title. * * @return string The open graph title. */ public function generate_title() { if ( $this->model->title ) { return $this->model->title; } // Get SEO title as entered in Search appearance. $post_type = $this->model->object_sub_type; $title = $this->options->get( 'title-' . $this->model->object_sub_type ); if ( $title ) { return $title; } // Get installation default title. return $this->options->get_title_default( 'title-' . $post_type ); } /** * Generates the meta description. * * @return string The meta description. */ public function generate_meta_description() { if ( $this->model->description ) { return $this->model->description; } return $this->options->get( 'metadesc-' . $this->model->object_sub_type ); } /** * Generates the open graph description. * * @return string The open graph description. */ public function generate_open_graph_description() { if ( $this->model->open_graph_description ) { $open_graph_description = $this->model->open_graph_description; } if ( empty( $open_graph_description ) ) { // The helper applies a filter, but we don't have a default value at this stage so we pass an empty string. $open_graph_description = $this->values_helper->get_open_graph_description( '', $this->model->object_type, $this->model->object_sub_type ); } if ( empty( $open_graph_description ) ) { $open_graph_description = $this->meta_description; } if ( empty( $open_graph_description ) ) { $open_graph_description = $this->post->get_the_excerpt( $this->model->object_id ); $open_graph_description = $this->post->strip_shortcodes( $open_graph_description ); } return $open_graph_description; } /** * Generates the open graph images. * * @return array The open graph images. */ public function generate_open_graph_images() { if ( \post_password_required() ) { return []; } return parent::generate_open_graph_images(); } /** * Generates the Open Graph type. * * @return string The Open Graph type. */ public function generate_open_graph_type() { return 'article'; } /** * Generates the open graph article author. * * @return string The open graph article author. */ public function generate_open_graph_article_author() { if ( $this->model->object_sub_type !== 'post' ) { return ''; } $post = $this->source; $open_graph_article_author = $this->user->get_the_author_meta( 'facebook', $post->post_author ); if ( $open_graph_article_author ) { return $open_graph_article_author; } return ''; } /** * Generates the open graph article publisher. * * @return string The open graph article publisher. */ public function generate_open_graph_article_publisher() { $open_graph_article_publisher = $this->context->open_graph_publisher; if ( $open_graph_article_publisher ) { return $open_graph_article_publisher; } return ''; } /** * Generates the open graph article published time. * * @return string The open graph article published time. */ public function generate_open_graph_article_published_time() { if ( $this->model->object_sub_type !== 'post' ) { /** * Filter: 'wpseo_opengraph_show_publish_date' - Allow showing publication date for other post types. * * @param string $post_type The current URL's post type. * * @api bool Whether or not to show publish date. */ if ( ! \apply_filters( 'wpseo_opengraph_show_publish_date', false, $this->post->get_post_type( $this->source ) ) ) { return ''; } } return $this->date->format( $this->source->post_date_gmt ); } /** * Generates the open graph article modified time. * * @return string The open graph article modified time. */ public function generate_open_graph_article_modified_time() { if ( $this->source->post_modified_gmt !== $this->source->post_date_gmt ) { return $this->date->format( $this->source->post_modified_gmt ); } return ''; } /** * Generates the source. * * @return array The source. */ public function generate_source() { return \get_post( $this->model->object_id ); } /** * Generates the robots value. * * @return array The robots value. */ public function generate_robots() { $robots = $this->get_base_robots(); $robots = \array_merge( $robots, [ 'imageindex' => ( $this->model->is_robots_noimageindex === true ) ? 'noimageindex' : null, 'archive' => ( $this->model->is_robots_noarchive === true ) ? 'noarchive' : null, 'snippet' => ( $this->model->is_robots_nosnippet === true ) ? 'nosnippet' : null, ] ); // No snippet means max snippet can be omitted. if ( $this->model->is_robots_nosnippet === true ) { $robots['max-snippet'] = null; } // No image index means max image preview can be omitted. if ( $this->model->is_robots_noimageindex === true ) { $robots['max-image-preview'] = null; } // When the post specific index is not set, look to the post status and default of the post type. if ( $this->model->is_robots_noindex === null ) { $post_status_private = \get_post_status( $this->model->object_id ) === 'private'; $post_type_noindex = ! $this->post_type->is_indexable( $this->model->object_sub_type ); if ( $post_status_private || $post_type_noindex ) { $robots['index'] = 'noindex'; } } return $this->filter_robots( $robots ); } /** * Generates the Twitter description. * * @return string The Twitter description. */ public function generate_twitter_description() { $twitter_description = parent::generate_twitter_description(); if ( $twitter_description ) { return $twitter_description; } if ( $this->open_graph_description && $this->context->open_graph_enabled === true ) { return ''; } return $this->post->get_the_excerpt( $this->model->object_id ); } /** * Generates the Twitter image. * * @return string The Twitter image. */ public function generate_twitter_image() { if ( \post_password_required() ) { return ''; } return parent::generate_twitter_image(); } /** * Generates the Twitter creator. * * @return string The Twitter creator. */ public function generate_twitter_creator() { if ( $this->model->object_sub_type !== 'post' ) { return ''; } $twitter_creator = \ltrim( \trim( \get_the_author_meta( 'twitter', $this->source->post_author ) ), '@' ); /** * Filter: 'wpseo_twitter_creator_account' - Allow changing the Twitter account as output in the Twitter card by Yoast SEO. * * @api string $twitter The twitter account name string. */ $twitter_creator = \apply_filters( 'wpseo_twitter_creator_account', $twitter_creator ); if ( \is_string( $twitter_creator ) && $twitter_creator !== '' ) { return '@' . $twitter_creator; } $site_twitter = $this->options->get( 'twitter_site', '' ); if ( \is_string( $site_twitter ) && $site_twitter !== '' ) { return '@' . $site_twitter; } return ''; } /** * Wraps the get_paginated_url pagination helper method. * * @codeCoverageIgnore A wrapper method. * * @param string $url The un-paginated URL of the current archive. * @param string $page The page number to add on to $url for the $link tag. * * @return string The paginated URL. */ protected function get_paginated_url( $url, $page ) { return $this->pagination->get_paginated_url( $url, $page, false ); } } indexable-home-page-presentation.php 0000644 00000002326 15154100313 0013555 0 ustar 00 <?php namespace Yoast\WP\SEO\Presentations; /** * Class Indexable_Home_Page_Presentation. * * Presentation object for indexables. */ class Indexable_Home_Page_Presentation extends Indexable_Presentation { use Archive_Adjacent; /** * Generates the canonical. * * @return string The canonical. */ public function generate_canonical() { if ( $this->model->canonical ) { return $this->model->canonical; } $permalink = $this->get_permalink(); if ( ! $permalink ) { return ''; } $current_page = $this->pagination->get_current_archive_page_number(); if ( $current_page > 1 ) { return $this->pagination->get_paginated_url( $permalink, $current_page ); } return $permalink; } /** * Generates the meta description. * * @return string The meta description. */ public function generate_meta_description() { if ( $this->model->description ) { return $this->model->description; } return $this->options->get( 'metadesc-home-wpseo' ); } /** * Generates the title. * * @return string The title. */ public function generate_title() { if ( $this->model->title ) { return $this->model->title; } return $this->options->get_title_default( 'title-home-wpseo' ); } } indexable-static-posts-page-presentation.php 0000644 00000001765 15154100313 0015270 0 ustar 00 <?php namespace Yoast\WP\SEO\Presentations; use Yoast\WP\SEO\Helpers\Pagination_Helper; /** * Class Indexable_Static_Posts_Page_Presentation. * * Presentation object for indexables. */ class Indexable_Static_Posts_Page_Presentation extends Indexable_Post_Type_Presentation { use Archive_Adjacent; /** * The pagination helper. * * @var Pagination_Helper */ protected $pagination; /** * Generates the canonical. * * @return string The canonical. */ public function generate_canonical() { if ( $this->model->canonical ) { return $this->model->canonical; } $current_page = $this->pagination->get_current_archive_page_number(); $permalink = $this->get_permalink(); if ( $current_page > 1 ) { return $this->pagination->get_paginated_url( $permalink, $current_page ); } return $permalink; } /** * Generates the Open Graph URL. * * @return string The Open Graph URL. */ public function generate_open_graph_url() { return $this->get_permalink(); } } indexable-search-result-page-presentation.php 0000644 00000002635 15154100313 0015411 0 ustar 00 <?php namespace Yoast\WP\SEO\Presentations; /** * Class Indexable_Search_Result_Page_Presentation. * * Presentation object for indexables. */ class Indexable_Search_Result_Page_Presentation extends Indexable_Presentation { /** * Generates the robots value. * * @return array The robots value. */ public function generate_robots() { $robots = $this->get_base_robots(); $robots['index'] = 'noindex'; return $this->filter_robots( $robots ); } /** * Generates the title. * * @return string The title. */ public function generate_title() { if ( $this->model->title ) { return $this->model->title; } return $this->options->get_title_default( 'title-search-wpseo' ); } /** * Generates the Twitter title. * * @return string The Twitter title. */ public function generate_twitter_title() { return $this->title; } /** * Generates the Open Graph URL. * * @return string The Open Graph URL. */ public function generate_open_graph_url() { $search_query = \get_search_query(); // Regex catches case when /search/page/N without search term is itself mistaken for search term. if ( ! empty( $search_query ) && ! \preg_match( '|^page/\d+$|', $search_query ) ) { return \get_search_link(); } return ''; } /** * Generates the Open Graph type. * * @return string The Open Graph type. */ public function generate_open_graph_type() { return 'article'; } } indexable-presentation.php 0000644 00000046276 15154100313 0011731 0 ustar 00 <?php namespace Yoast\WP\SEO\Presentations; use Yoast\WP\SEO\Context\Meta_Tags_Context; use Yoast\WP\SEO\Generators\Breadcrumbs_Generator; use Yoast\WP\SEO\Generators\Open_Graph_Image_Generator; use Yoast\WP\SEO\Generators\Open_Graph_Locale_Generator; use Yoast\WP\SEO\Generators\Schema_Generator; use Yoast\WP\SEO\Generators\Twitter_Image_Generator; use Yoast\WP\SEO\Helpers\Current_Page_Helper; use Yoast\WP\SEO\Helpers\Image_Helper; use Yoast\WP\SEO\Helpers\Indexable_Helper; use Yoast\WP\SEO\Helpers\Open_Graph\Values_Helper; use Yoast\WP\SEO\Helpers\Options_Helper; use Yoast\WP\SEO\Helpers\Permalink_Helper; use Yoast\WP\SEO\Helpers\Url_Helper; use Yoast\WP\SEO\Helpers\User_Helper; use Yoast\WP\SEO\Models\Indexable; /** * Class Indexable_Presentation. * * Presentation object for indexables. * * @property string $title * @property string $meta_description * @property array $robots * @property string $canonical * @property string $rel_next * @property string $rel_prev * @property string $open_graph_type * @property string $open_graph_title * @property string $open_graph_description * @property array $open_graph_images * @property string $open_graph_url * @property string $open_graph_site_name * @property string $open_graph_article_publisher * @property string $open_graph_article_author * @property string $open_graph_article_published_time * @property string $open_graph_article_modified_time * @property string $open_graph_locale * @property string $open_graph_fb_app_id * @property array $schema * @property string $twitter_card * @property string $twitter_title * @property string $twitter_description * @property string $twitter_image * @property string $twitter_creator * @property string $twitter_site * @property array $source * @property array $breadcrumbs * @property int $estimated_reading_time_minutes */ class Indexable_Presentation extends Abstract_Presentation { /** * The indexable. * * @var Indexable */ public $model; /** * The meta tags context. * * @var Meta_Tags_Context */ public $context; /** * The Schema generator. * * @var Schema_Generator */ protected $schema_generator; /** * The Open Graph image generator. * * @var Open_Graph_Image_Generator */ protected $open_graph_image_generator; /** * The Twitter image generator. * * @var Twitter_Image_Generator */ protected $twitter_image_generator; /** * The Open Graph locale generator. * * @var Open_Graph_Locale_Generator */ private $open_graph_locale_generator; /** * The breadcrumbs generator. * * @var Breadcrumbs_Generator */ private $breadcrumbs_generator; /** * The current page helper. * * @var Current_Page_Helper */ protected $current_page; /** * The image helper. * * @var Image_Helper */ protected $image; /** * The options helper. * * @var Options_Helper */ protected $options; /** * The URL helper. * * @var Url_Helper */ protected $url; /** * The user helper. * * @var User_Helper */ protected $user; /** * The indexable helper. * * @var Indexable_Helper */ protected $indexable_helper; /** * The permalink helper. * * @var Permalink_Helper */ protected $permalink_helper; /** * The values helper. * * @var Values_Helper */ protected $values_helper; /** * Sets the generator dependencies. * * @required * * @param Schema_Generator $schema_generator The schema generator. * @param Open_Graph_Locale_Generator $open_graph_locale_generator The Open Graph locale generator. * @param Open_Graph_Image_Generator $open_graph_image_generator The Open Graph image generator. * @param Twitter_Image_Generator $twitter_image_generator The Twitter image generator. * @param Breadcrumbs_Generator $breadcrumbs_generator The breadcrumbs generator. */ public function set_generators( Schema_Generator $schema_generator, Open_Graph_Locale_Generator $open_graph_locale_generator, Open_Graph_Image_Generator $open_graph_image_generator, Twitter_Image_Generator $twitter_image_generator, Breadcrumbs_Generator $breadcrumbs_generator ) { $this->schema_generator = $schema_generator; $this->open_graph_locale_generator = $open_graph_locale_generator; $this->open_graph_image_generator = $open_graph_image_generator; $this->twitter_image_generator = $twitter_image_generator; $this->breadcrumbs_generator = $breadcrumbs_generator; } /** * Used by dependency injection container to inject the helpers. * * @required * * @param Image_Helper $image The image helper. * @param Options_Helper $options The options helper. * @param Current_Page_Helper $current_page The current page helper. * @param Url_Helper $url The URL helper. * @param User_Helper $user The user helper. * @param Indexable_Helper $indexable The indexable helper. * @param Permalink_Helper $permalink The permalink helper. * @param Values_Helper $values The values helper. */ public function set_helpers( Image_Helper $image, Options_Helper $options, Current_Page_Helper $current_page, Url_Helper $url, User_Helper $user, Indexable_Helper $indexable, Permalink_Helper $permalink, Values_Helper $values ) { $this->image = $image; $this->options = $options; $this->current_page = $current_page; $this->url = $url; $this->user = $user; $this->indexable_helper = $indexable; $this->permalink_helper = $permalink; $this->values_helper = $values; } /** * Gets the permalink from the indexable or generates it if dynamic permalinks are enabled. * * @return string The permalink. */ public function get_permalink() { if ( $this->indexable_helper->dynamic_permalinks_enabled() ) { return $this->permalink_helper->get_permalink_for_indexable( $this->model ); } return $this->model->permalink; } /** * Generates the title. * * @return string The title. */ public function generate_title() { if ( $this->model->title ) { return $this->model->title; } return ''; } /** * Generates the meta description. * * @return string The meta description. */ public function generate_meta_description() { if ( $this->model->description ) { return $this->model->description; } return ''; } /** * Generates the robots value. * * @return array The robots value. */ public function generate_robots() { $robots = $this->get_base_robots(); return $this->filter_robots( $robots ); } /** * Gets the base robots value. * * @return array The base robots value. */ protected function get_base_robots() { return [ 'index' => ( $this->model->is_robots_noindex === true ) ? 'noindex' : 'index', 'follow' => ( $this->model->is_robots_nofollow === true ) ? 'nofollow' : 'follow', 'max-snippet' => 'max-snippet:-1', 'max-image-preview' => 'max-image-preview:large', 'max-video-preview' => 'max-video-preview:-1', ]; } /** * Run the robots output content through the `wpseo_robots` filter. * * @param array $robots The meta robots values to filter. * * @return array The filtered meta robots values. */ protected function filter_robots( $robots ) { // Remove values that are only listened to when indexing. if ( $robots['index'] === 'noindex' ) { $robots['imageindex'] = null; $robots['archive'] = null; $robots['snippet'] = null; $robots['max-snippet'] = null; $robots['max-image-preview'] = null; $robots['max-video-preview'] = null; } $robots_string = \implode( ', ', \array_filter( $robots ) ); /** * Filter: 'wpseo_robots' - Allows filtering of the meta robots output of Yoast SEO. * * @api string $robots The meta robots directives to be echoed. * * @param Indexable_Presentation $presentation The presentation of an indexable. */ $robots_filtered = \apply_filters( 'wpseo_robots', $robots_string, $this ); // Convert the robots string back to an array. if ( \is_string( $robots_filtered ) ) { $robots_values = \explode( ', ', $robots_filtered ); $robots_new = []; foreach ( $robots_values as $value ) { $key = $value; // Change `noindex` to `index. if ( \strpos( $key, 'no' ) === 0 ) { $key = \substr( $value, 2 ); } // Change `max-snippet:-1` to `max-snippet`. $colon_position = \strpos( $key, ':' ); if ( $colon_position !== false ) { $key = \substr( $value, 0, $colon_position ); } $robots_new[ $key ] = $value; } $robots = $robots_new; } if ( ! $robots_filtered ) { return []; } /** * Filter: 'wpseo_robots_array' - Allows filtering of the meta robots output array of Yoast SEO. * * @api array $robots The meta robots directives to be used. * * @param Indexable_Presentation $presentation The presentation of an indexable. */ return \apply_filters( 'wpseo_robots_array', \array_filter( $robots ), $this ); } /** * Generates the robots value for the googlebot tag. * * @deprecated 14.9 Values merged into the robots meta tag. * @codeCoverageIgnore * * @return array The robots value with opt-in snippets. */ public function generate_googlebot() { \_deprecated_function( __METHOD__, 'WPSEO 14.9' ); return []; } /** * Generates the value for the bingbot tag. * * @deprecated 14.9 Values merged into the robots meta tag. * @codeCoverageIgnore * * @return array The robots value with opt-in snippets. */ public function generate_bingbot() { \_deprecated_function( __METHOD__, 'WPSEO 14.9' ); return []; } /** * Generates the canonical. * * @return string The canonical. */ public function generate_canonical() { if ( $this->model->canonical ) { return $this->model->canonical; } $permalink = $this->get_permalink(); if ( $permalink ) { return $permalink; } return ''; } /** * Generates the rel prev. * * @return string The rel prev value. */ public function generate_rel_prev() { return ''; } /** * Generates the rel next. * * @return string The rel prev next. */ public function generate_rel_next() { return ''; } /** * Generates the Open Graph type. * * @return string The Open Graph type. */ public function generate_open_graph_type() { return 'website'; } /** * Generates the open graph title. * * @return string The open graph title. */ public function generate_open_graph_title() { if ( $this->model->open_graph_title ) { $open_graph_title = $this->model->open_graph_title; } if ( empty( $open_graph_title ) ) { // The helper applies a filter, but we don't have a default value at this stage so we pass an empty string. $open_graph_title = $this->values_helper->get_open_graph_title( '', $this->model->object_type, $this->model->object_sub_type ); } if ( empty( $open_graph_title ) ) { $open_graph_title = $this->title; } return $open_graph_title; } /** * Generates the open graph description. * * @return string The open graph description. */ public function generate_open_graph_description() { if ( $this->model->open_graph_description ) { $open_graph_description = $this->model->open_graph_description; } if ( empty( $open_graph_description ) ) { // The helper applies a filter, but we don't have a default value at this stage so we pass an empty string. $open_graph_description = $this->values_helper->get_open_graph_description( '', $this->model->object_type, $this->model->object_sub_type ); } if ( empty( $open_graph_description ) ) { $open_graph_description = $this->meta_description; } return $open_graph_description; } /** * Generates the open graph images. * * @return array The open graph images. */ public function generate_open_graph_images() { if ( $this->context->open_graph_enabled === false ) { return []; } return $this->open_graph_image_generator->generate( $this->context ); } /** * Generates the open graph image ID. * * @return string The open graph image ID. */ public function generate_open_graph_image_id() { if ( $this->model->open_graph_image_id ) { return $this->model->open_graph_image_id; } return $this->values_helper->get_open_graph_image_id( 0, $this->model->object_type, $this->model->object_sub_type ); } /** * Generates the open graph image URL. * * @return string The open graph image URL. */ public function generate_open_graph_image() { if ( $this->model->open_graph_image ) { return $this->model->open_graph_image; } return $this->values_helper->get_open_graph_image( '', $this->model->object_type, $this->model->object_sub_type ); } /** * Generates the open graph url. * * @return string The open graph url. */ public function generate_open_graph_url() { if ( $this->model->canonical ) { return $this->model->canonical; } return $this->get_permalink(); } /** * Generates the open graph article publisher. * * @return string The open graph article publisher. */ public function generate_open_graph_article_publisher() { return ''; } /** * Generates the open graph article author. * * @return string The open graph article author. */ public function generate_open_graph_article_author() { return ''; } /** * Generates the open graph article published time. * * @return string The open graph article published time. */ public function generate_open_graph_article_published_time() { return ''; } /** * Generates the open graph article modified time. * * @return string The open graph article modified time. */ public function generate_open_graph_article_modified_time() { return ''; } /** * Generates the open graph locale. * * @return string The open graph locale. */ public function generate_open_graph_locale() { return $this->open_graph_locale_generator->generate( $this->context ); } /** * Generates the open graph Facebook app ID. * * @deprecated 15.5 * @codeCoverageIgnore * * @return string The open graph Facebook app ID. */ public function generate_open_graph_fb_app_id() { return $this->options->get( 'fbadminapp', '' ); } /** * Generates the open graph site name. * * @return string The open graph site name. */ public function generate_open_graph_site_name() { return $this->context->wordpress_site_name; } /** * Generates the Twitter card type. * * @return string The Twitter card type. */ public function generate_twitter_card() { return $this->context->twitter_card; } /** * Generates the Twitter title. * * @return string The Twitter title. */ public function generate_twitter_title() { if ( $this->model->twitter_title ) { return $this->model->twitter_title; } if ( $this->context->open_graph_enabled === true ) { $social_template_title = $this->values_helper->get_open_graph_title( '', $this->model->object_type, $this->model->object_sub_type ); $open_graph_title = $this->open_graph_title; // If the helper returns a value and it's different from the OG value in the indexable, // output it in a twitter: tag. if ( ! empty( $social_template_title ) && $social_template_title !== $open_graph_title ) { return $social_template_title; } // If the OG title is set, let og: tag take care of this. if ( ! empty( $open_graph_title ) ) { return ''; } } if ( $this->title ) { return $this->title; } return ''; } /** * Generates the Twitter description. * * @return string The Twitter description. */ public function generate_twitter_description() { if ( $this->model->twitter_description ) { return $this->model->twitter_description; } if ( $this->context->open_graph_enabled === true ) { $social_template_description = $this->values_helper->get_open_graph_description( '', $this->model->object_type, $this->model->object_sub_type ); $open_graph_description = $this->open_graph_description; // If the helper returns a value and it's different from the OG value in the indexable, // output it in a twitter: tag. if ( ! empty( $social_template_description ) && $social_template_description !== $open_graph_description ) { return $social_template_description; } // If the OG description is set, let og: tag take care of this. if ( ! empty( $open_graph_description ) ) { return ''; } } if ( $this->meta_description ) { return $this->meta_description; } return ''; } /** * Generates the Twitter image. * * @return string The Twitter image. */ public function generate_twitter_image() { $images = $this->twitter_image_generator->generate( $this->context ); $image = \reset( $images ); // Use a user-defined Twitter image, if present. if ( $image && $this->context->indexable->twitter_image_source === 'set-by-user' ) { return $image['url']; } // Let the Open Graph tags, if enabled, handle the rest of the fallback hierarchy. if ( $this->context->open_graph_enabled === true && $this->open_graph_images ) { return ''; } // Set a Twitter tag with the featured image, or a prominent image from the content, if present. if ( $image ) { return $image['url']; } return ''; } /** * Generates the Twitter creator. * * @return string The Twitter creator. */ public function generate_twitter_creator() { return ''; } /** * Generates the Twitter site. * * @return string The Twitter site. */ public function generate_twitter_site() { switch ( $this->context->site_represents ) { case 'person': $twitter = $this->user->get_the_author_meta( 'twitter', (int) $this->context->site_user_id ); if ( empty( $twitter ) ) { $twitter = $this->options->get( 'twitter_site' ); } break; case 'company': default: $twitter = $this->options->get( 'twitter_site' ); break; } return $twitter; } /** * Generates the source. * * @return array The source. */ public function generate_source() { return []; } /** * Generates the schema for the page. * * @codeCoverageIgnore Wrapper method. * * @return array The Schema object. */ public function generate_schema() { return $this->schema_generator->generate( $this->context ); } /** * Generates the breadcrumbs for the page. * * @codeCoverageIgnore Wrapper method. * * @return array The breadcrumbs. */ public function generate_breadcrumbs() { return $this->breadcrumbs_generator->generate( $this->context ); } /** * Generates the estimated reading time. * * @codeCoverageIgnore Wrapper method. * * @return int|null The estimated reading time. */ public function generate_estimated_reading_time_minutes() { if ( $this->model->estimated_reading_time_minutes !== null ) { return $this->model->estimated_reading_time_minutes; } if ( $this->context->post === null ) { return null; } // 200 is the approximate estimated words per minute across languages. $words_per_minute = 200; $words = \str_word_count( \wp_strip_all_tags( $this->context->post->post_content ) ); return (int) \round( $words / $words_per_minute ); } /** * Strips all nested dependencies from the debug info. * * @return array */ public function __debugInfo() { return [ 'model' => $this->model, 'context' => $this->context, ]; } } indexable-term-archive-presentation.php 0000644 00000011602 15154100313 0014276 0 ustar 00 <?php namespace Yoast\WP\SEO\Presentations; use WP_Term; use Yoast\WP\SEO\Helpers\Taxonomy_Helper; use Yoast\WP\SEO\Wrappers\WP_Query_Wrapper; /** * Class Indexable_Term_Archive_Presentation. * * Presentation object for indexables. * * @property WP_Term $source */ class Indexable_Term_Archive_Presentation extends Indexable_Presentation { use Archive_Adjacent; /** * Holds the WP query wrapper instance. * * @var WP_Query_Wrapper */ private $wp_query_wrapper; /** * Holds the taxonomy helper instance. * * @var Taxonomy_Helper */ private $taxonomy; /** * Indexable_Post_Type_Presentation constructor. * * @codeCoverageIgnore * * @param WP_Query_Wrapper $wp_query_wrapper The wp query wrapper. * @param Taxonomy_Helper $taxonomy The Taxonomy helper. */ public function __construct( WP_Query_Wrapper $wp_query_wrapper, Taxonomy_Helper $taxonomy ) { $this->wp_query_wrapper = $wp_query_wrapper; $this->taxonomy = $taxonomy; } /** * Generates the canonical. * * @return string The canonical. */ public function generate_canonical() { if ( $this->is_multiple_terms_query() ) { return ''; } if ( $this->model->canonical ) { return $this->model->canonical; } $permalink = $this->get_permalink(); if ( ! $permalink ) { return ''; } $current_page = $this->pagination->get_current_archive_page_number(); if ( $current_page > 1 ) { return $this->pagination->get_paginated_url( $permalink, $current_page ); } return $permalink; } /** * Generates the meta description. * * @return string The meta description. */ public function generate_meta_description() { if ( $this->model->description ) { return $this->model->description; } return $this->options->get( 'metadesc-tax-' . $this->model->object_sub_type ); } /** * Generates the source. * * @return array The source. */ public function generate_source() { return \get_term( $this->model->object_id, $this->model->object_sub_type ); } /** * Generates the Open Graph description. * * @return string The Open Graph description. */ public function generate_open_graph_description() { $open_graph_description = parent::generate_open_graph_description(); if ( $open_graph_description ) { return $open_graph_description; } return $this->taxonomy->get_term_description( $this->model->object_id ); } /** * Generates the Twitter description. * * @return string The Twitter description. */ public function generate_twitter_description() { $twitter_description = parent::generate_twitter_description(); if ( $twitter_description ) { return $twitter_description; } if ( $this->open_graph_description && $this->context->open_graph_enabled === true ) { return ''; } return $this->taxonomy->get_term_description( $this->model->object_id ); } /** * Generates the robots value. * * @return array The robots value. */ public function generate_robots() { $robots = $this->get_base_robots(); /** * If its a multiple terms archive page return a noindex. */ if ( $this->current_page->is_multiple_terms_page() ) { $robots['index'] = 'noindex'; return $this->filter_robots( $robots ); } /** * First we get the no index option for this taxonomy, because it can be overwritten the indexable value for * this specific term. */ if ( ! $this->taxonomy->is_indexable( $this->source->taxonomy ) ) { $robots['index'] = 'noindex'; } /** * Overwrite the index directive when there is a term specific directive set. */ if ( $this->model->is_robots_noindex !== null ) { $robots['index'] = ( $this->model->is_robots_noindex ) ? 'noindex' : 'index'; } return $this->filter_robots( $robots ); } /** * Generates the title. * * @return string The title. */ public function generate_title() { if ( $this->model->title ) { return $this->model->title; } // Get the SEO title as entered in Search Appearance. $title = $this->options->get( 'title-tax-' . $this->source->taxonomy ); if ( $title ) { return $title; } // Get the installation default title. $title = $this->options->get_title_default( 'title-tax-' . $this->source->taxonomy ); return $title; } /** * Generates the Open Graph type. * * @return string The Open Graph type. */ public function generate_open_graph_type() { return 'article'; } /** * Checks if term archive query is for multiple terms (/term-1,term-2/ or /term-1+term-2/). * * @return bool Whether the query contains multiple terms. */ protected function is_multiple_terms_query() { $query = $this->wp_query_wrapper->get_query(); if ( ! isset( $query->tax_query ) ) { return false; } $queried_terms = $query->tax_query->queried_terms; if ( empty( $queried_terms[ $this->source->taxonomy ]['terms'] ) ) { return false; } return \count( $queried_terms[ $this->source->taxonomy ]['terms'] ) > 1; } } archive-adjacent-trait.php 0000644 00000003362 15154100313 0011563 0 ustar 00 <?php namespace Yoast\WP\SEO\Presentations; use Yoast\WP\SEO\Helpers\Pagination_Helper; use Yoast\WP\SEO\Models\Indexable; /** * Class Archive_Adjacent. * * Presentation object for indexables. * * @property Indexable $model The indexable. * @property Pagination_Helper $pagination The pagination helper. Should be defined in the parent * class because of trait issues in PHP 5.6. */ trait Archive_Adjacent { /** * Sets the helpers for the trait. * * @required * * @codeCoverageIgnore * * @param Pagination_Helper $pagination The pagination helper. */ public function set_archive_adjacent_helpers( Pagination_Helper $pagination ) { $this->pagination = $pagination; } /** * Generates the rel prev. * * @return string */ public function generate_rel_prev() { if ( $this->pagination->is_rel_adjacent_disabled() ) { return ''; } $current_page = \max( 1, $this->pagination->get_current_archive_page_number() ); // Check if there is a previous page. if ( $current_page === 1 ) { return ''; } // Check if the previous page is the first page. if ( $current_page === 2 ) { return $this->get_permalink(); } return $this->pagination->get_paginated_url( $this->get_permalink(), ( $current_page - 1 ) ); } /** * Generates the rel next. * * @return string */ public function generate_rel_next() { if ( $this->pagination->is_rel_adjacent_disabled() ) { return ''; } $current_page = \max( 1, $this->pagination->get_current_archive_page_number() ); if ( $this->pagination->get_number_of_archive_pages() <= $current_page ) { return ''; } return $this->pagination->get_paginated_url( $this->get_permalink(), ( $current_page + 1 ) ); } } indexable-author-archive-presentation.php 0000644 00000010355 15154100313 0014635 0 ustar 00 <?php namespace Yoast\WP\SEO\Presentations; use Yoast\WP\SEO\Helpers\Author_Archive_Helper; use Yoast\WP\SEO\Helpers\Post_Type_Helper; /** * Class Indexable_Author_Archive_Presentation. * * Presentation object for indexables. */ class Indexable_Author_Archive_Presentation extends Indexable_Presentation { use Archive_Adjacent; /** * Holds the post type helper instance. * * @var Post_Type_Helper */ protected $post_type; /** * Holds the author archive helper instance. * * @var Author_Archive_Helper */ protected $author_archive; /** * Indexable_Author_Archive_Presentation constructor. * * @codeCoverageIgnore * * @param Post_Type_Helper $post_type The post type helper. * @param Author_Archive_Helper $author_archive The author archive helper. */ public function __construct( Post_Type_Helper $post_type, Author_Archive_Helper $author_archive ) { $this->post_type = $post_type; $this->author_archive = $author_archive; } /** * Generates the canonical. * * @return string The canonical. */ public function generate_canonical() { if ( $this->model->canonical ) { return $this->model->canonical; } $permalink = $this->get_permalink(); if ( ! $permalink ) { return ''; } $current_page = $this->pagination->get_current_archive_page_number(); if ( $current_page > 1 ) { return $this->pagination->get_paginated_url( $permalink, $current_page ); } return $permalink; } /** * Generates the title. * * @return string The title. */ public function generate_title() { if ( $this->model->title ) { return $this->model->title; } $option_titles_key = 'title-author-wpseo'; $title = $this->options->get( $option_titles_key ); if ( $title ) { return $title; } return $this->options->get_title_default( $option_titles_key ); } /** * Generates the meta description. * * @return string The meta description. */ public function generate_meta_description() { if ( $this->model->description ) { return $this->model->description; } $option_titles_key = 'metadesc-author-wpseo'; $description = $this->options->get( $option_titles_key ); if ( $description ) { return $description; } return $this->options->get_title_default( $option_titles_key ); } /** * Generates the robots value. * * @return array The robots value. */ public function generate_robots() { $robots = $this->get_base_robots(); // Global option: "Show author archives in search results". if ( $this->options->get( 'noindex-author-wpseo', false ) ) { $robots['index'] = 'noindex'; return $this->filter_robots( $robots ); } $current_author = \get_userdata( $this->model->object_id ); // Safety check. The call to `get_user_data` could return false (called in `get_queried_object`). if ( $current_author === false ) { $robots['index'] = 'noindex'; return $this->filter_robots( $robots ); } $author_archive_post_types = $this->author_archive->get_author_archive_post_types(); // Global option: "Show archives for authors without posts in search results". if ( $this->options->get( 'noindex-author-noposts-wpseo', false ) && $this->user->count_posts( $current_author->ID, $author_archive_post_types ) === 0 ) { $robots['index'] = 'noindex'; return $this->filter_robots( $robots ); } // User option: "Do not allow search engines to show this author's archives in search results". if ( $this->user->get_meta( $current_author->ID, 'wpseo_noindex_author', true ) === 'on' ) { $robots['index'] = 'noindex'; return $this->filter_robots( $robots ); } return $this->filter_robots( $robots ); } /** * Generates the Open Graph type. * * @return string The Open Graph type. */ public function generate_open_graph_type() { return 'profile'; } /** * Generates the open graph images. * * @return array The open graph images. */ public function generate_open_graph_images() { if ( $this->context->open_graph_enabled === false ) { return []; } return $this->open_graph_image_generator->generate_for_author_archive( $this->context ); } /** * Generates the source. * * @return array The source. */ public function generate_source() { return [ 'post_author' => $this->model->object_id ]; } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка