| 1 |
<?php |
| 2 |
/** |
| 3 |
* ConvertKit Tags Resource class. |
| 4 |
* |
| 5 |
* @package ConvertKit |
| 6 |
* @author ConvertKit |
| 7 |
*/ |
| 8 |
|
| 9 |
/** |
| 10 |
* Reads ConvertKit Tags from the options table, and refreshes |
| 11 |
* ConvertKit Tags data stored locally from the API. |
| 12 |
* |
| 13 |
* @since 1.9.6 |
| 14 |
*/ |
| 15 |
class ConvertKit_Resource_Tags extends ConvertKit_Resource_V4 { |
| 16 |
|
| 17 |
/** |
| 18 |
* Holds the Settings Key that stores site wide ConvertKit settings |
| 19 |
* |
| 20 |
* @var string |
| 21 |
*/ |
| 22 |
public $settings_name = 'convertkit_tags'; |
| 23 |
|
| 24 |
/** |
| 25 |
* The type of resource |
| 26 |
* |
| 27 |
* @var string |
| 28 |
*/ |
| 29 |
public $type = 'tags'; |
| 30 |
|
| 31 |
/** |
| 32 |
* Constructor. |
| 33 |
* |
| 34 |
* @since 1.9.8.4 |
| 35 |
* |
| 36 |
* @param bool|string $context Context. |
| 37 |
*/ |
| 38 |
public function __construct( $context = false ) { |
| 39 |
|
| 40 |
// Initialize the API if the Access Token has been defined in the Plugin Settings. |
| 41 |
$settings = new ConvertKit_Settings(); |
| 42 |
if ( $settings->has_access_and_refresh_token() ) { |
| 43 |
$this->api = new ConvertKit_API_V4( |
| 44 |
CONVERTKIT_OAUTH_CLIENT_ID, |
| 45 |
CONVERTKIT_OAUTH_CLIENT_REDIRECT_URI, |
| 46 |
$settings->get_access_token(), |
| 47 |
$settings->get_refresh_token(), |
| 48 |
$settings->debug_enabled(), |
| 49 |
$context |
| 50 |
); |
| 51 |
} |
| 52 |
|
| 53 |
// Get last query time and existing resources. |
| 54 |
$this->last_queried = get_option( $this->settings_name . '_last_queried' ); |
| 55 |
$this->resources = get_option( $this->settings_name ); |
| 56 |
|
| 57 |
} |
| 58 |
|
| 59 |
} |
| 60 |
|