Abstract_Account_Api::load_account( TribeEventsVirtualIntegrationsarray $account = array() )
Load a specific account into the API.
Contents
Parameters
- $account
-
(<span class="TribeEventsVirtualIntegrationsarrayTribeEventsVirtualIntegrationsarray<string|">TribeEventsVirtualIntegrationsstring>) (Optional) An account with the fields to access the API.
Default value: array()
Return
(boolean) Whether the account is loaded into the class to use for the API, default is false.
Source
File: src/Tribe/Integrations/Abstract_Account_Api.php
public function load_account( array $account = [] ) {
if ( $this->is_valid_account( $account ) ) {
$this->init_account( $account );
return true;
}
// Check for single events first.
$loaded_account = '';
if ( is_singular( TEC::POSTTYPE ) ){
$post_id = get_the_ID();
// Get the account id and if found, use to get the account.
if ( $account_id = get_post_meta( $post_id, $this->account_id_meta_field_name, true ) ) {
$loaded_account = $this->get_account_by_id( $account_id );
}
if ( ! $loaded_account ) {
return false;
}
if ( $this->is_valid_account( $loaded_account ) ) {
$this->init_account( $loaded_account );
return true;
}
}
// If nothing loaded so far and this is not the admin, then return false.
if ( ! is_admin() ) {
return false;
}
$account_id = $this->get_account_id_in_admin();
// Get the account id and if found, use to get the account.
if ( $account_id ) {
$loaded_account = $this->get_account_by_id( $account_id );
}
if ( ! $loaded_account ) {
return false;
}
if ( $this->is_valid_account( $loaded_account ) ) {
$this->init_account( $loaded_account );
return true;
}
return false;
}
Changelog
| Version | Description |
|---|---|
| 1.9.0 | Introduced. |