Yoast\WP\SEO\AI_Free_Sparks\Application

Free_Sparks_Handler{} │ Yoast 1.0└─ Free_Sparks_Handler_Interface

Устарела с версии 28.4. Больше не поддерживается и может быть удалена. Рекомендуется заменить эту функцию на аналог.

Handles the free sparks started on timestamp.

Хуков нет.

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

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

Методы

  1. public __construct( Options_Helper $options_helper )
  2. public get( string $format = 'Y-m-d H:i:s' )
  3. public start( ?int $timestamp = null )
  4. ERROR: no method name found on line `* @codeCoverageIgnore`
  5. ERROR: no method name found on line `*`
  6. ERROR: no method name found on line ``

Список изменений

Устарела с 28.4

Код Free_Sparks_Handler{} Yoast 28.9

class Free_Sparks_Handler implements Free_Sparks_Handler_Interface {

	/**
	 * The key used to store the timestamp when the user started using free sparks.
	 *
	 * @var string
	 */
	public const OPTION_KEY = 'ai_free_sparks_started_on';

	/**
	 * Holds the options helper instance.
	 *
	 * @var Options_Helper
	 */
	private $options_helper;

	/**
	 * Class constructor.
	 *
	 * @deprecated 28.4
	 * @codeCoverageIgnore
	 *
	 * @param Options_Helper $options_helper The options helper.
	 */
	public function __construct( Options_Helper $options_helper ) {
		\_deprecated_function( __METHOD__, 'Yoast SEO 28.4' );
		$this->options_helper = $options_helper;
	}

	/**
	 * Retrieves the timestamp.
	 *
	 * @deprecated 28.4
	 * @codeCoverageIgnore
	 *
	 * @param string $format The format in which to return the timestamp. Defaults to 'Y-m-d H:i:s'.
	 *
	 * @return ?string The timestamp when the user started using free sparks, or null if not set.
	 */
	public function get( string $format = 'Y-m-d H:i:s' ): ?string {
		\_deprecated_function( __METHOD__, 'Yoast SEO 28.4' );
		$timestamp = $this->options_helper->get( self::OPTION_KEY, null );
		if ( $timestamp === null ) {
			return null;
		}

		return \gmdate( $format, (int) $timestamp );
	}

	/**
	 * Registers the starting of the free sparks.
	 *
	 * @deprecated 28.4
	 * @codeCoverageIgnore
	 *
	 * @param ?int $timestamp The timestamp when the user started using free sparks. If null, the current time will be
	 *                        used.
	 *
	 * @return bool True if the operation was successful, false otherwise.
	 */
	public function start( ?int $timestamp = null ): bool {
		\_deprecated_function( __METHOD__, 'Yoast SEO 28.4' );
		return (bool) $this->options_helper->set( self::OPTION_KEY, ( $timestamp === null ) ? \time() : $timestamp, 'wpseo' );
	}
}