WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Получай пассивный доход от сайта
класс не описан

Yoast\WP\SEO\Presenters

Abstract_Indexable_Tag_Presenter{} Yoast 1.0

Abstract presenter class for indexable tag presentations.

Хуков нет.

Возвращает

null. Ничего.

Использование

$Abstract_Indexable_Tag_Presenter = new Abstract_Indexable_Tag_Presenter();
// use class methods

Методы

  1. escape_value( $value )
  2. present()

Код Abstract_Indexable_Tag_Presenter{} Yoast 16.8

<?php
abstract class Abstract_Indexable_Tag_Presenter extends Abstract_Indexable_Presenter {

	const META_PROPERTY_CONTENT = '<meta property="%2$s" content="%1$s" />';
	const META_NAME_CONTENT     = '<meta name="%2$s" content="%1$s" />';
	const LINK_REL_HREF         = '<link rel="%2$s" href="%1$s" />';
	const DEFAULT_TAG_FORMAT    = self::META_NAME_CONTENT;

	/**
	 * The tag format including placeholders.
	 *
	 * @var string
	 */
	protected $tag_format = self::DEFAULT_TAG_FORMAT;

	/**
	 * The method of escaping to use.
	 *
	 * @var string
	 */
	protected $escaping = 'attribute';

	/**
	 * Returns a tag in the head.
	 *
	 * @return string The tag.
	 */
	public function present() {
		$value = $this->get();

		if ( ! \is_string( $value ) || $value === '' ) {
			return '';
		}

		/**
		 * There may be some classes that are derived from this class that do not use the $key property
		 * in their $tag_format string. In that case the key property will simply not be used.
		 */
		return \sprintf( $this->tag_format, $this->escape_value( $value ), $this->key );
	}

	/**
	 * Escaped the output.
	 *
	 * @param string $value The desired method of escaping; 'html', 'url' or 'attribute'.
	 *
	 * @return string The escaped value.
	 */
	protected function escape_value( $value ) {
		switch ( $this->escaping ) {
			case 'html':
				return \esc_html( $value );
			case 'url':
				return \esc_url( $value );
			case 'attribute':
			default:
				return \esc_attr( $value );
		}
	}
}