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

Yoast\WP\SEO\Conditionals\Admin

Estimated_Reading_Time_Conditional{} Yoast 1.0

Conditional that is only when we want the Estimated Reading Time.

Хуков нет.

Возвращает

Null. Ничего.

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

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

Методы

  1. __construct( Post_Conditional $post_conditional, Input_Helper $input_helper )
  2. is_met()

Код Estimated_Reading_Time_Conditional{} Yoast 15.6.2

<?php
class Estimated_Reading_Time_Conditional implements Conditional {

	/**
	 * The Post Conditional.
	 *
	 * @var Post_Conditional
	 */
	protected $post_conditional;

	/**
	 * The Input Helper.
	 *
	 * @var Input_Helper
	 */
	protected $input_helper;

	/**
	 * Constructs the Estimated Reading Time Conditional.
	 *
	 * @param Post_Conditional $post_conditional The post conditional.
	 * @param Input_Helper     $input_helper     The input helper.
	 */
	public function __construct( Post_Conditional $post_conditional, Input_Helper $input_helper ) {
		$this->post_conditional = $post_conditional;
		$this->input_helper     = $input_helper;
	}

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return boolean Whether or not the conditional is met.
	 */
	public function is_met() {
		// Check if we are in our Elementor ajax request (for saving).
		if ( \wp_doing_ajax() ) {
			$post_action = $this->input_helper->filter( INPUT_POST, 'action', FILTER_SANITIZE_STRING );
			if ( $post_action === 'wpseo_elementor_save' ) {
				return true;
			}
		}

		if ( ! $this->post_conditional->is_met() ) {
			return false;
		}

		// We don't support Estimated Reading Time on the attachment post type.
		$post_id = (int) $this->input_helper->filter( INPUT_GET, 'post', FILTER_SANITIZE_NUMBER_INT );
		if ( \get_post_type( $post_id ) === 'attachment' ) {
			return false;
		}

		return true;
	}
}