Yoast\WP\SEO\Conditionals\Admin

Estimated_Reading_Time_Conditional::is_met()publicYoast 1.0

Returns whether this conditional is met.

Метод класса: Estimated_Reading_Time_Conditional{}

Хуков нет.

Возвращает

true|false. Whether the conditional is met.

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

$Estimated_Reading_Time_Conditional = new Estimated_Reading_Time_Conditional();
$Estimated_Reading_Time_Conditional->is_met();

Код Estimated_Reading_Time_Conditional::is_met() Yoast 22.8

public function is_met() {
	// phpcs:disable WordPress.Security.NonceVerification.Recommended,WordPress.Security.NonceVerification.Missing -- Reason: Nonce verification should not be done in a conditional but rather in the classes using the conditional.
	// Check if we are in our Elementor ajax request (for saving).
	if ( \wp_doing_ajax() && isset( $_POST['action'] ) && \is_string( $_POST['action'] ) ) {
		// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are only strictly comparing the variable.
		$post_action = \wp_unslash( $_POST['action'] );
		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.
	if ( isset( $_GET['post'] ) && \is_string( $_GET['post'] ) ) {
		// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are casting to an integer.
		$post_id = (int) \wp_unslash( $_GET['post'] );
		if ( $post_id !== 0 && \get_post_type( $post_id ) === 'attachment' ) {
			return false;
		}
	}

	return true;
	// phpcs:enable WordPress.Security.NonceVerification.Recommended,WordPress.Security.NonceVerification.Missing
}