✘✘ GRAYBYTE WORDPRESS FILE MANAGER ✘✘

​🇳​​🇦​​🇲​​🇪♯➤ webm004.cluster127.gra.hosting.ovh.net ​🇻​♯➤ 6.18.42-ovh-vps-grsec-zfs+ #1 SMP 🇾​♯➤ 2026

𝗛𝗢𝗠𝗘 𝗜𝗗 ♯➤ 54.36.91.62 ♯➤ 𝗔𝗗𝗠𝗜𝗡 𝗜𝗗 216.73.216.191
𝗢𝗣𝗧𝗜𝗢𝗡𝗦 ♯ CRL ♯➤ 𝗢𝗞 ┃ WGT ♯➤ 𝗢𝗞 ┃ SDO ♯➤ 𝗢𝗙𝗙 ┃ PKEX ♯➤ 𝗢𝗙𝗙
𝗗𝗘𝗔𝗖𝗧𝗜𝗩𝗔𝗧𝗘𝗗 ♯➤ _dyuweyrj4,_dyuweyrj4r,dl

𝗛𝗢𝗠𝗘
𝗖𝗨𝗥𝗥𝗘𝗡𝗧 𝗙𝗜𝗟𝗘 : /home/docteuh/www/dist/serverhttpson/01/third-party/src/routes//yoast-head-rest-field.php
<?php // phpcs:ignore Yoast.Files.FileName.InvalidClassFileName -- Reason: this explicitly concerns the Yoast head fields.

namespace Yoast\WP\SEO\Routes;

use Yoast\WP\SEO\Actions\Indexables\Indexable_Head_Action;
use Yoast\WP\SEO\Conditionals\Headless_Rest_Endpoints_Enabled_Conditional;
use Yoast\WP\SEO\Helpers\Post_Helper;
use Yoast\WP\SEO\Helpers\Post_Type_Helper;
use Yoast\WP\SEO\Helpers\Taxonomy_Helper;

/**
 * Yoast_Head_REST_Field class.
 *
 * Registers the yoast head REST field.
 * Not technically a route but behaves the same so is included here.
 */
class Yoast_Head_REST_Field implements Route_Interface {

	/**
	 * The name of the Yoast head field.
	 *
	 * @var string
	 */
	public const YOAST_HEAD_ATTRIBUTE_NAME = 'yoast_head';

	/**
	 * The name of the Yoast head JSON field.
	 *
	 * @var string
	 */
	public const YOAST_JSON_HEAD_ATTRIBUTE_NAME = 'yoast_head_json';

	/**
	 * The post type helper.
	 *
	 * @var Post_Type_Helper
	 */
	protected $post_type_helper;

	/**
	 * The taxonomy helper.
	 *
	 * @var Taxonomy_Helper
	 */
	protected $taxonomy_helper;

	/**
	 * The post helper.
	 *
	 * @var Post_Helper
	 */
	protected $post_helper;

	/**
	 * The head action.
	 *
	 * @var Indexable_Head_Action
	 */
	protected $head_action;

	/**
	 * Returns the conditionals based in which this loadable should be active.
	 *
	 * @return array
	 */
	public static function get_conditionals() {
		return [ Headless_Rest_Endpoints_Enabled_Conditional::class ];
	}

	/**
	 * Yoast_Head_REST_Field constructor.
	 *
	 * @param Post_Type_Helper      $post_type_helper The post type helper.
	 * @param Taxonomy_Helper       $taxonomy_helper  The taxonomy helper.
	 * @param Post_Helper           $post_helper      The post helper.
	 * @param Indexable_Head_Action $head_action      The head action.
	 */
	public function __construct(
		Post_Type_Helper $post_type_helper,
		Taxonomy_Helper $taxonomy_helper,
		Post_Helper $post_helper,
		Indexable_Head_Action $head_action
	) {
		$this->post_type_helper = $post_type_helper;
		$this->taxonomy_helper  = $taxonomy_helper;
		$this->post_helper      = $post_helper;
		$this->head_action      = $head_action;
	}

	/**
	 * Registers routes with WordPress.
	 *
	 * @return void
	 */
	public function register_routes() {
		$public_post_types = $this->post_type_helper->get_indexable_post_types();

		foreach ( $public_post_types as $post_type ) {
			$this->register_rest_fields( $post_type, 'for_post' );
		}

		$public_taxonomies = $this->taxonomy_helper->get_indexable_taxonomies();

		foreach ( $public_taxonomies as $taxonomy ) {
			if ( $taxonomy === 'post_tag' ) {
				$taxonomy = 'tag';
			}
			$this->register_rest_fields( $taxonomy, 'for_term' );
		}

		$this->register_rest_fields( 'user', 'for_author' );
		$this->register_rest_fields( 'type', 'for_post_type_archive' );
	}

	/**
	 * Returns the head for a post.
	 *
	 * @param array  $params The rest request params.
	 * @param string $format The desired output format.
	 *
	 * @return string|null The head.
	 */
	public function for_post( $params, $format = self::YOAST_HEAD_ATTRIBUTE_NAME ) {
		if ( ! isset( $params['id'] ) ) {
			return null;
		}

		if ( ! $this->post_helper->is_post_indexable( $params['id'] ) ) {
			return null;
		}
		$obj = $this->head_action->for_post( $params['id'] );

		return $this->render_object( $obj, $format );
	}

	/**
	 * Returns the head for a term.
	 *
	 * @param array  $params The rest request params.
	 * @param string $format The desired output format.
	 *
	 * @return string|null The head.
	 */
	public function for_term( $params, $format = self::YOAST_HEAD_ATTRIBUTE_NAME ) {
		$obj = $this->head_action->for_term( $params['id'] );

		return $this->render_object( $obj, $format );
	}

	/**
	 * Returns the head for an author.
	 *
	 * @param array  $params The rest request params.
	 * @param string $format The desired output format.
	 *
	 * @return string|null The head.
	 */
	public function for_author( $params, $format = self::YOAST_HEAD_ATTRIBUTE_NAME ) {
		$obj = $this->head_action->for_author( $params['id'] );

		return $this->render_object( $obj, $format );
	}

	/**
	 * Returns the head for a post type archive.
	 *
	 * @param array  $params The rest request params.
	 * @param string $format The desired output format.
	 *
	 * @return string|null The head.
	 */
	public function for_post_type_archive( $params, $format = self::YOAST_HEAD_ATTRIBUTE_NAME ) {
		if ( $params['slug'] === 'post' ) {
			$obj = $this->head_action->for_posts_page();
		}
		elseif ( ! $this->post_type_helper->has_archive( $params['slug'] ) ) {
			return null;
		}
		else {
			$obj = $this->head_action->for_post_type_archive( $params['slug'] );
		}

		return $this->render_object( $obj, $format );
	}

	/**
	 * Registers the Yoast rest fields.
	 *
	 * @param string $object_type The object type.
	 * @param string $callback    The function name of the callback.
	 *
	 * @return void
	 */
	protected function register_rest_fields( $object_type, $callback ) {
		// Output metadata in page head meta tags.
		\register_rest_field( $object_type, self::YOAST_HEAD_ATTRIBUTE_NAME, [ 'get_callback' => [ $this, $callback ] ] );
		// Output metadata in a json object in a head meta tag.
		\register_rest_field( $object_type, self::YOAST_JSON_HEAD_ATTRIBUTE_NAME, [ 'get_callback' => [ $this, $callback ] ] );
	}

	/**
	 * Returns the correct property for the Yoast head.
	 *
	 * @param stdObject $head   The Yoast head.
	 * @param string    $format The format to return.
	 *
	 * @return string|array|null The output value. String if HTML was requested, array otherwise.
	 */
	protected function render_object( $head, $format = self::YOAST_HEAD_ATTRIBUTE_NAME ) {
		if ( $head->status === 404 ) {
			return null;
		}

		switch ( $format ) {
			case self::YOAST_HEAD_ATTRIBUTE_NAME:
				return $head->html;
			case self::YOAST_JSON_HEAD_ATTRIBUTE_NAME:
				return $head->json;
		}

		return null;
	}
}


Current_dir [ 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ] Document_root [ 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ]


[ Back ]
𝗡𝗔𝗠𝗘
𝗦𝗜𝗭𝗘
𝗟𝗔𝗦𝗧 𝗧𝗢𝗨𝗖𝗛
𝗨𝗦𝗘𝗥
𝗦𝗧𝗔𝗧𝗨𝗦
𝗙𝗨𝗡𝗖𝗧𝗜𝗢𝗡𝗦
..
--
10 Sep 2026 7.21 PM
docteuh / users
0755
endpoint
--
10 Sep 2026 7.21 PM
docteuh / users
0755
abstract-action-route.php
0.62 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
alert-dismissal-route.php
2.33 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
breadcrumbs-generator.php
12.619 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
class-admin-asset-manager.php
20.573 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
first-time-configuration-route.php
8.062 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
icon-redirect-manager.svg
1.299 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
importing-route.php
4.073 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
indexables-head-route.php
2.393 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
indexing-route.php
12.331 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
meta-search-route.php
1.971 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
route-interface.php
0.261 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
semrush-route-20260828145007.php
6.258 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
semrush-route.php
6.258 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
supported-features-route.php
1.28 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
wincher-route.php
8.75 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
workouts-route.php
3.101 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
yoast-head-rest-field.php
5.795 KB
23 Jun 2026 6.19 PM
docteuh / users
0644

✘✘ GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME ✘✘
Static GIF Static GIF