Status::update_option( $old_value,  $new_value,  $option_name )

Summary

No summary available.

Parameters

$old_value

(Required)

$new_value

(Required)

$option_name

(Required)


Source

File: src/BigCommerce/Webhooks/Status.php

	public function update_option( $old_value, $new_value, $option_name ) {
		if ( $old_value === $new_value ) {
			return;
		}

		// If we are enabling webhooks, call the existing action.
		if ( $new_value ) {
			/**
			 * This hook is documented in src/BigCommerce/Webhooks/Webhook.php.
			 */
			do_action( 'bigcommerce/settings/webhoooks_updated' );

			return;
		}

		$api_webhooks = (array) $this->api->listWebhooks();

		// Delete the hooks.
		foreach ( $this->hooks as $hook ) {
			$matching    = array_filter( $api_webhooks, function ( $api_hook ) use ( $hook ) {
				return $hook->scope() === $api_hook->scope && $hook->destination() === $api_hook->destination;
			} );
			foreach ( $matching as $api_hook ) {
				$hook->delete( $api_hook->id );
			}
		}

		// Reset the hooks options so we can re-enable.
		delete_option( 'schema-' . Webhook_Versioning::class );
		delete_option( Webhook::WEBHOOKS_OPTION );
		delete_option( Webhook::AUTH_KEY_OPTION );
	}


User Contributed Notes

You must log in before being able to contribute a note or feedback.