Automattic\WooCommerce\Internal\Admin\Notes

WooSubscriptionsNotes::update_option_woocommerce_helper_data()publicWC 1.0

Reacts to changes in the helper option.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$WooSubscriptionsNotes = new WooSubscriptionsNotes();
$WooSubscriptionsNotes->update_option_woocommerce_helper_data( $old_value, $value );
$old_value(массив) (обязательный)
The previous value of the option.
$value(массив) (обязательный)
The new value of the option.

Код WooSubscriptionsNotes::update_option_woocommerce_helper_data() WC 8.7.0

public function update_option_woocommerce_helper_data( $old_value, $value ) {
	if ( ! is_array( $old_value ) ) {
		$old_value = array();
	}
	if ( ! is_array( $value ) ) {
		$value = array();
	}

	$old_auth  = array_key_exists( 'auth', $old_value ) ? $old_value['auth'] : array();
	$new_auth  = array_key_exists( 'auth', $value ) ? $value['auth'] : array();
	$old_token = array_key_exists( 'access_token', $old_auth ) ? $old_auth['access_token'] : '';
	$new_token = array_key_exists( 'access_token', $new_auth ) ? $new_auth['access_token'] : '';

	// The site just disconnected.
	if ( ! empty( $old_token ) && empty( $new_token ) ) {
		$this->remove_notes();
		$this->add_no_connection_note();
		return;
	}

	// The site is connected.
	if ( $this->is_connected() ) {
		$this->remove_notes();
		$this->refresh_subscription_notes();
		return;
	}
}