Twilio_Helpers::automator_twilio_disconnect()

Callback function to hook wp_ajax_automator_twilio_disconnect.


Description Description

Deletes all the option and transients then redirect the user back to the settings page.


Top ↑

Return Return

(Uncanny_Automatorvoid.)


Source Source

File: src/integrations/twilio/helpers/twilio-helpers.php

	public function automator_twilio_disconnect() {

		if ( wp_verify_nonce( filter_input( INPUT_GET, 'nonce', FILTER_DEFAULT ), 'automator_twilio_disconnect' ) ) {

			// Remove option
			$option_keys = array(
				'_uncannyowl_twilio_settings',
				'_uncannyowl_twilio_settings_expired',
				'uap_automator_twilio_api_auth_token',
				'uap_automator_twilio_api_phone_number',
				'uap_automator_twilio_api_account_sid',
				'uap_twilio_connected_user',
			);

			foreach ( $option_keys as $option_key ) {
				delete_option( $option_key );
			}

			// Remove transients.
			$transient_keys = array(
				'_uncannyowl_twilio_settings',
				'_automator_twilio_account_info',
				'uap_automator_twilio_api_accounts_response'
			);

			foreach ( $transient_keys as $transient_key ) {
				delete_transient( $transient_key );
			}
		}

		wp_safe_redirect(
			add_query_arg(
				array(
					'post_type' 	=> 'uo-recipe',
					'page'      	=> 'uncanny-automator-config',
					'tab'       	=> 'premium-integrations',
					'integration' 	=> 'twilio-api'
				),
				admin_url( 'edit.php' )
			)
		);

		exit;
	}