Yoast\WP\SEO\User_Meta\Framework\Custom_Meta

Keyword_Analysis_Disable{}Yoast 1.0

The Keyword_Analysis_Disable custom meta.

Хуков нет.

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

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

Методы

  1. public __construct( Options_Helper $options_helper )
  2. public get_field_id()
  3. public get_key()
  4. public get_render_priority()
  5. public get_value( $user_id )
  6. public is_empty_allowed()
  7. public is_setting_enabled()
  8. public render_field( $user_id )

Код Keyword_Analysis_Disable{} Yoast 25.1

class Keyword_Analysis_Disable implements Custom_Meta_Interface {

	/**
	 * The options helper.
	 *
	 * @var Options_Helper
	 */
	private $options_helper;

	/**
	 * The constructor.
	 *
	 * @param Options_Helper $options_helper The options helper.
	 */
	public function __construct( Options_Helper $options_helper ) {
		$this->options_helper = $options_helper;
	}

	/**
	 * Returns the priority which the custom meta's form field should be rendered with.
	 *
	 * @return int The priority which the custom meta's form field should be rendered with.
	 */
	public function get_render_priority(): int {
		return 400;
	}

	/**
	 * Returns the db key of the Keyword_Analysis_Disable custom meta.
	 *
	 * @return string The db key of the Keyword_Analysis_Disable custom meta.
	 */
	public function get_key(): string {
		return 'wpseo_keyword_analysis_disable';
	}

	/**
	 * Returns the id of the custom meta's form field.
	 *
	 * @return string The id of the custom meta's form field.
	 */
	public function get_field_id(): string {
		return 'wpseo_keyword_analysis_disable';
	}

	/**
	 * Returns the meta value.
	 *
	 * @param int $user_id The user ID.
	 *
	 * @return string The meta value.
	 */
	public function get_value( $user_id ): string {
		return \get_the_author_meta( $this->get_key(), $user_id );
	}

	/**
	 * Returns whether the respective global setting is enabled.
	 *
	 * @return bool Whether the respective global setting is enabled.
	 */
	public function is_setting_enabled(): bool {
		return ( $this->options_helper->get( 'keyword_analysis_active', false ) );
	}

	/**
	 * Returns whether the custom meta is allowed to be empty.
	 *
	 * @return bool Whether the custom meta is allowed to be empty.
	 */
	public function is_empty_allowed(): bool {
		return true;
	}

	/**
	 * Renders the custom meta's field in the user form.
	 *
	 * @param int $user_id The user ID.
	 *
	 * @return void
	 */
	public function render_field( $user_id ): void {
		echo '

		<input
			class="yoast-settings__checkbox double"
			type="checkbox"
			id="' . \esc_attr( $this->get_field_id() ) . '"
			name="' . \esc_attr( $this->get_field_id() ) . '"
			aria-describedby="' . \esc_attr( $this->get_field_id() ) . '_desc"
			value="on" '
			. \checked( $this->get_value( $user_id ), 'on', false )
		. '/>';

		echo '

		<label class="yoast-label-strong" for="' . \esc_attr( $this->get_field_id() ) . '">'
			. \esc_html__( 'Disable SEO analysis', 'wordpress-seo' )
		. '</label><br>';

		echo '

		<p class="description" id="' . \esc_attr( $this->get_field_id() ) . '_desc">'
			. \esc_html__( 'Removes the focus keyphrase section from the metabox and disables all SEO-related suggestions.', 'wordpress-seo' )
		. '</p>';
	}
}