Abstract_Account_Api::ajax_delete( string|null $nonce = null )
Handles the request to delete a an API account.
Contents
Parameters
- $nonce
-
(string|null) (Optional) The nonce that should accompany the request.
Default value: null
Return
(bool) Whether the request was handled or not.
Source
File: src/Tribe/Integrations/Abstract_Account_Api.php
public function ajax_delete( $nonce = null ) {
if ( ! $this->check_ajax_nonce( static::$delete_action, $nonce ) ) {
return false;
}
$account_id = tribe_get_request_var( 'account_id' );
$account = $this->get_account_by_id( $account_id );
// If no account id found, fail the request.
if ( empty( $account_id ) || empty( $account ) ) {
$error_message = sprintf(
// translators: the placeholders is for the API name.
_x(
'The %1$s Account ID or Account is missing to change the status.',
'Account ID is missing on status change error message.',
'events-virtual'
),
static::$api_name
);
$this->get_settings_message_template( $error_message, 'error' );
wp_die();
}
$success = $this->delete_account_by_id( $account_id );
if ( $success ) {
$message = sprintf(
/* Translators: %1$s: the name of the account that has been deleted. */
_x(
'%1$s was successfully deleted',
'Account ID is missing on status change error message.',
'events-virtual'
),
static::$api_name
);
$this->get_settings_message_template( $message );
wp_die();
}
$error_message = sprintf(
/* Translators: %1$s: the name of the account that has been deleted. */
_x(
'The %1$s Account access token could not be revoked.',
'Message to display when the %1$s account could not be loaded after being enabled.',
'events-virtual'
),
static::$api_name
);
$this->get_settings_message_template( $error_message, 'error' );
wp_die();
}
Changelog
| Version | Description |
|---|---|
| 1.9.0 | Introduced. |