Yoast\WP\SEO\Actions\Configuration

First_Time_Configuration_Action::set_enable_tracking()publicYoast 1.0

Stores the values to enable/disable tracking.

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

Хуки из метода

Возвращает

Объект. The response object.

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

$First_Time_Configuration_Action = new First_Time_Configuration_Action();
$First_Time_Configuration_Action->set_enable_tracking( $params );
$params(массив) (обязательный)
The values to store.

Код First_Time_Configuration_Action::set_enable_tracking() Yoast 22.1

public function set_enable_tracking( $params ) {
	$success      = true;
	$option_value = $this->options_helper->get( 'tracking' );

	if ( $option_value !== $params['tracking'] ) {
		$this->options_helper->set( 'toggled_tracking', true );
		$success = $this->options_helper->set( 'tracking', $params['tracking'] );
	}

	/**
	 * Action: 'wpseo_post_update_enable_tracking' - Allows for Hiive event tracking.
	 *
	 * @param array $new_value The new value.
	 * @param array $old_value The old value.
	 * @param bool  $failure   Whether the option failed to be stored.
	 *
	 * @internal
	 */
	// $success is negated to be aligned with the other two actions which pass $failures.
	\do_action( 'wpseo_ftc_post_update_enable_tracking', $params['tracking'], $option_value, ! $success );

	if ( $success ) {
		return (object) [
			'success' => true,
			'status'  => 200,
		];
	}

	return (object) [
		'success' => false,
		'status'  => 500,
		'error'   => 'Could not save the option in the database',
	];
}