Файловый менеджер - Редактировать - /home/kunzqhe/photostocker/2/schema.tar
Назад
html-helper.php 0000644 00000002511 15153701363 0007501 0 ustar 00 <?php namespace Yoast\WP\SEO\Helpers\Schema; /** * Class HTML_Helper. */ class HTML_Helper { /** * Sanitizes a HTML string by stripping all tags except headings, breaks, lists, links, paragraphs and formatting. * * @param string $html The original HTML. * * @return string The sanitized HTML. */ public function sanitize( $html ) { return \strip_tags( $html, '<h1><h2><h3><h4><h5><h6><br><ol><ul><li><a><p><b><strong><i><em>' ); } /** * Strips the tags in a smart way. * * @param string $html The original HTML. * * @return string The sanitized HTML. */ public function smart_strip_tags( $html ) { // Replace all new lines with spaces. $html = \preg_replace( '/(\r|\n)/', ' ', $html ); // Replace <br> tags with spaces. $html = \preg_replace( '/<br(\s*)?\/?>/i', ' ', $html ); // Replace closing </p> and other tags with the same tag with a space after it, so we don't end up connecting words when we remove them later. $html = \preg_replace( '/<\/(p|div|h\d)>/i', '</$1> ', $html ); // Replace list items with list identifiers so it still looks natural. $html = \preg_replace( '/(<li[^>]*>)/i', '$1• ', $html ); // Strip tags. $html = \wp_strip_all_tags( $html ); // Replace multiple spaces with one space. $html = \preg_replace( '!\s+!', ' ', $html ); return \trim( $html ); } } image-helper.php 0000644 00000012417 15153701363 0007625 0 ustar 00 <?php namespace Yoast\WP\SEO\Helpers\Schema; use Yoast\WP\SEO\Helpers\Image_Helper as Main_Image_Helper; /** * Class Image_Helper. */ class Image_Helper { /** * The HTML helper. * * @var HTML_Helper */ private $html; /** * The language helper. * * @var Language_Helper */ private $language; /** * Represents the main image helper. * * @var Main_Image_Helper */ private $image; /** * Image_Helper constructor. * * @codeCoverageIgnore It handles dependencies. * * @param HTML_Helper $html The HTML helper. * @param Language_Helper $language The language helper. * @param Main_Image_Helper $image The 'main' image helper. */ public function __construct( HTML_Helper $html, Language_Helper $language, Main_Image_Helper $image ) { $this->html = $html; $this->language = $language; $this->image = $image; } /** * Find an image based on its URL and generate a Schema object for it. * * @param string $schema_id The `@id` to use for the returned image. * @param string $url The image URL to base our object on. * @param string $caption An optional caption. * * @return array Schema ImageObject array. */ public function generate_from_url( $schema_id, $url, $caption = '' ) { $attachment_id = $this->image->get_attachment_by_url( $url ); if ( $attachment_id > 0 ) { return $this->generate_from_attachment_id( $schema_id, $attachment_id, $caption ); } return $this->simple_image_object( $schema_id, $url, $caption ); } /** * Retrieve data about an image from the database and use it to generate a Schema object. * * @param string $schema_id The `@id` to use for the returned image. * @param int $attachment_id The attachment to retrieve data from. * @param string $caption The caption string, if there is one. * * @return array Schema ImageObject array. */ public function generate_from_attachment_id( $schema_id, $attachment_id, $caption = '' ) { $data = $this->generate_object( $schema_id ); $data['url'] = $this->image->get_attachment_image_url( $attachment_id, 'full' ); $data['contentUrl'] = $data['url']; $data = $this->add_image_size( $data, $attachment_id ); $data = $this->add_caption( $data, $attachment_id, $caption ); return $data; } /** * Retrieve data about an image from the database and use it to generate a Schema object. * * @param string $schema_id The `@id` to use for the returned image. * @param array $attachment_meta The attachment metadata. * @param string $caption The caption string, if there is one. * * @return array Schema ImageObject array. */ public function generate_from_attachment_meta( $schema_id, $attachment_meta, $caption = '' ) { $data = $this->generate_object( $schema_id ); $data['url'] = $attachment_meta['url']; $data['contentUrl'] = $data['url']; $data['width'] = $attachment_meta['width']; $data['height'] = $attachment_meta['height']; if ( ! empty( $caption ) ) { $data['caption'] = $this->html->smart_strip_tags( $caption ); } return $data; } /** * If we can't find $url in our database, we output a simple ImageObject. * * @param string $schema_id The `@id` to use for the returned image. * @param string $url The image URL. * @param string $caption A caption, if set. * * @return array Schema ImageObject array. */ public function simple_image_object( $schema_id, $url, $caption = '' ) { $data = $this->generate_object( $schema_id ); $data['url'] = $url; $data['contentUrl'] = $url; if ( ! empty( $caption ) ) { $data['caption'] = $this->html->smart_strip_tags( $caption ); } return $data; } /** * Retrieves an image's caption if set, or uses the alt tag if that's set. * * @param array $data An ImageObject Schema array. * @param int $attachment_id Attachment ID. * @param string $caption The caption string, if there is one. * * @return array An imageObject with width and height set if available. */ private function add_caption( $data, $attachment_id, $caption = '' ) { if ( $caption !== '' ) { $data['caption'] = $caption; return $data; } $caption = $this->image->get_caption( $attachment_id ); if ( ! empty( $caption ) ) { $data['caption'] = $this->html->smart_strip_tags( $caption ); return $data; } return $data; } /** * Generates our bare bone ImageObject. * * @param string $schema_id The `@id` to use for the returned image. * * @return array an empty ImageObject */ private function generate_object( $schema_id ) { $data = [ '@type' => 'ImageObject', '@id' => $schema_id, ]; $data = $this->language->add_piece_language( $data ); return $data; } /** * Adds image's width and height. * * @param array $data An ImageObject Schema array. * @param int $attachment_id Attachment ID. * * @return array An imageObject with width and height set if available. */ private function add_image_size( $data, $attachment_id ) { $image_meta = $this->image->get_metadata( $attachment_id ); if ( empty( $image_meta['width'] ) || empty( $image_meta['height'] ) ) { return $data; } $data['width'] = $image_meta['width']; $data['height'] = $image_meta['height']; return $data; } } language-helper.php 0000644 00000001462 15153701363 0010324 0 ustar 00 <?php namespace Yoast\WP\SEO\Helpers\Schema; /** * Class Language_Helper. */ class Language_Helper { /** * Adds the `inLanguage` property to a Schema piece. * * Must use one of the language codes from the IETF BCP 47 standard. The * language tag syntax is made of one or more subtags separated by a hyphen * e.g. "en", "en-US", "zh-Hant-CN". * * @param array $data The Schema piece data. * * @return array The Schema piece data with added language property */ public function add_piece_language( $data ) { /** * Filter: 'wpseo_schema_piece_language' - Allow changing the Schema piece language. * * @api string $type The Schema piece language. */ $data['inLanguage'] = \apply_filters( 'wpseo_schema_piece_language', \get_bloginfo( 'language' ), $data ); return $data; } } id-helper.php 0000644 00000001263 15153701363 0007134 0 ustar 00 <?php namespace Yoast\WP\SEO\Helpers\Schema; use Yoast\WP\SEO\Config\Schema_IDs; use Yoast\WP\SEO\Context\Meta_Tags_Context; /** * Schema utility functions. */ class ID_Helper { /** * Retrieve a users Schema ID. * * @param int $user_id The ID of the User you need a Schema ID for. * @param Meta_Tags_Context $context A value object with context variables. * * @return string The user's schema ID. */ public function get_user_schema_id( $user_id, $context ) { $user = \get_userdata( $user_id ); if ( \is_a( $user, 'WP_User' ) ) { return $context->site_url . Schema_IDs::PERSON_HASH . \wp_hash( $user->user_login . $user_id ); } return ''; } } article-helper.php 0000644 00000002214 15153701363 0010160 0 ustar 00 <?php namespace Yoast\WP\SEO\Helpers\Schema; /** * Class Article_Helper. */ class Article_Helper { /** * Determines whether a given post type should have Article schema. * * @param string|null $post_type Post type to check. * * @return bool True if it has Article schema, false if not. */ public function is_article_post_type( $post_type = null ) { if ( \is_null( $post_type ) ) { $post_type = \get_post_type(); } /** * Filter: 'wpseo_schema_article_post_types' - Allow changing for which post types we output Article schema. * * @api string[] $post_types The post types for which we output Article. */ $post_types = \apply_filters( 'wpseo_schema_article_post_types', [ 'post' ] ); return \in_array( $post_type, $post_types, true ); } /** * Checks whether author is supported for the passed object sub type. * * @param string $object_sub_type The sub type of the object to check author support for. * * @return bool True if author is supported for the passed object sub type. */ public function is_author_supported( $object_sub_type ) { return \post_type_supports( $object_sub_type, 'author' ); } } replace-vars-helper.php 0000644 00000006764 15153701363 0011137 0 ustar 00 <?php namespace Yoast\WP\SEO\Helpers\Schema; use Closure; use WPSEO_Replace_Vars; use Yoast\WP\SEO\Conditionals\No_Conditionals; use Yoast\WP\SEO\Config\Schema_IDs; use Yoast\WP\SEO\Context\Meta_Tags_Context; use Yoast\WP\SEO\Helpers\Date_Helper; use Yoast\WP\SEO\Presentations\Indexable_Presentation; /** * Registers the Schema replace variables and exposes a method to replace variables on a Schema graph. */ class Replace_Vars_Helper { use No_Conditionals; /** * The replace vars. * * @var WPSEO_Replace_Vars */ protected $replace_vars; /** * The Schema ID helper. * * @var ID_Helper */ protected $id_helper; /** * The date helper. * * @var Date_Helper */ protected $date_helper; /** * Replace_Vars_Helper constructor. * * @param WPSEO_Replace_Vars $replace_vars The replace vars. * @param ID_Helper $id_helper The Schema ID helper. * @param Date_Helper $date_helper The date helper. */ public function __construct( WPSEO_Replace_Vars $replace_vars, ID_Helper $id_helper, Date_Helper $date_helper ) { $this->replace_vars = $replace_vars; $this->id_helper = $id_helper; $this->date_helper = $date_helper; } /** * Replaces the variables. * * @param array $schema_data The Schema data. * @param Indexable_Presentation $presentation The indexable presentation. * * @return array The array with replaced vars. */ public function replace( array $schema_data, Indexable_Presentation $presentation ) { foreach ( $schema_data as $key => $value ) { if ( \is_array( $value ) ) { $schema_data[ $key ] = $this->replace( $value, $presentation ); continue; } $schema_data[ $key ] = $this->replace_vars->replace( $value, $presentation->source ); } return $schema_data; } /** * Registers the Schema-related replace vars. * * @param Meta_Tags_Context $context The meta tags context. * * @return void */ public function register_replace_vars( $context ) { $replace_vars = [ 'main_schema_id' => $context->main_schema_id, 'author_id' => $this->id_helper->get_user_schema_id( $context->indexable->author_id, $context ), 'person_id' => $context->site_url . Schema_IDs::PERSON_HASH, 'primary_image_id' => $context->canonical . Schema_IDs::PRIMARY_IMAGE_HASH, 'webpage_id' => $context->canonical . Schema_IDs::WEBPAGE_HASH, 'website_id' => $context->site_url . Schema_IDs::WEBSITE_HASH, 'organization_id' => $context->site_url . Schema_IDs::ORGANIZATION_HASH, ]; if ( $context->post ) { // Post does not always exist, e.g. on term pages. $replace_vars['post_date'] = $this->date_helper->format( $context->post->post_date, \DATE_ATOM ); } foreach ( $replace_vars as $var => $value ) { $this->register_replacement( $var, $value ); } } /** * Registers a replace var and its value. * * @param string $variable The replace variable. * @param string $value The value that the variable should be replaced with. */ protected function register_replacement( $variable, $value ) { $this->replace_vars->safe_register_replacement( $variable, $this->get_identity_function( $value ) ); } /** * Returns an anonymous function that in turn just returns the given value. * * @param mixed $value The value that the function should return. * * @return Closure A function that returns the given value. */ protected function get_identity_function( $value ) { return static function() use ( $value ) { return $value; }; } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка