Page_API::clear_access_token( string $nonce )

Clear a Facebook Page access token using ajax.


Parameters

$nonce

(string) (Required) The clear access action nonce to check.


Top ↑

Return

(string) An html message for success or failure when clearing.


Top ↑

Source

File: src/Tribe/Meetings/Facebook/Page_API.php

	public function clear_access_token( $nonce ) {
		if ( ! $this->check_ajax_nonce( Settings::$clear_access_action, $nonce ) ) {
			return false;
		}

		$local_id     = tribe_get_request_var( 'local_id' );
		// If missing information fail the request.
		if ( empty( $local_id ) ) {
			$error_message = _x(
				'No access token to clear as the the Facebook Page local ID is missing.',
				'Facebook Page ID local ID is missing error message.',
				'events-virtual'
			);
			tribe( Template_Modifications::class )->get_settings_message_template( $error_message, 'error' );

			wp_die();
		}

		// Check if the page exists.
		$page_data = $this->get_page_by_id( $local_id );
		if ( empty( $page_data ) ) {
			$message = _x(
				'No access token is cleared as no Facebook Page was found to update.',
				'Error message if the Facebook Page was not found in the options.',
				'events-virtual'
			);
			tribe( Template_Modifications::class )->get_settings_message_template( $message, 'error' );

			wp_die();
		}

		$this->set_page_access_by_id( $local_id, '', '' );

		$message = _x(
			'Facebook Page access token cleared.',
			'Facebook Page access token is cleared message.',
			'events-virtual'
		);
		tribe( Template_Modifications::class )->get_settings_message_template( $message );

		$page = $this->get_page_by_id( $local_id );
		tribe( Template_Modifications::class )->get_page_fields( $local_id, $page );

		wp_die();
	}

Top ↑

Changelog

Changelog
Version Description
1.7.0 Introduced.