| 1 |
<?php |
| 2 |
/** |
| 3 |
* ConvertKit Posts Resource class. |
| 4 |
* |
| 5 |
* @package ConvertKit |
| 6 |
* @author ConvertKit |
| 7 |
*/ |
| 8 |
|
| 9 |
/** |
| 10 |
* Reads ConvertKit Posts from the options table, and refreshes |
| 11 |
* ConvertKit Posts data stored locally from the API. |
| 12 |
* |
| 13 |
* @since 1.9.7.4 |
| 14 |
*/ |
| 15 |
class ConvertKit_Resource_Posts extends ConvertKit_Resource { |
| 16 |
|
| 17 |
/** |
| 18 |
* Holds the Settings Key that stores site wide ConvertKit settings |
| 19 |
* |
| 20 |
* @var string |
| 21 |
*/ |
| 22 |
public $settings_name = 'convertkit_posts'; |
| 23 |
|
| 24 |
/** |
| 25 |
* The type of resource |
| 26 |
* |
| 27 |
* @var string |
| 28 |
*/ |
| 29 |
public $type = 'posts'; |
| 30 |
|
| 31 |
/** |
| 32 |
* The number of seconds resources are valid, before they should be |
| 33 |
* fetched again from the API. |
| 34 |
* |
| 35 |
* @var int |
| 36 |
*/ |
| 37 |
public $cache_duration = DAY_IN_SECONDS; |
| 38 |
|
| 39 |
/** |
| 40 |
* How often to refresh this resource through WordPress' Cron. |
| 41 |
* If false, won't be refreshed through WordPress' Cron |
| 42 |
* If a string, must be a value from wp_get_schedules(). |
| 43 |
* |
| 44 |
* @since 1.9.7.4 |
| 45 |
* |
| 46 |
* @var bool|string |
| 47 |
*/ |
| 48 |
public $wp_cron_schedule = 'hourly'; |
| 49 |
|
| 50 |
/** |
| 51 |
* The key to use when alphabetically sorting resources. |
| 52 |
* |
| 53 |
* @since 2.0.8 |
| 54 |
* |
| 55 |
* @var string |
| 56 |
*/ |
| 57 |
public $order_by = 'published_at'; |
| 58 |
|
| 59 |
/** |
| 60 |
* The order to return resources. |
| 61 |
* |
| 62 |
* @since 2.0.8 |
| 63 |
* |
| 64 |
* @var string |
| 65 |
*/ |
| 66 |
public $order = 'desc'; |
| 67 |
|
| 68 |
/** |
| 69 |
* Constructor. |
| 70 |
* |
| 71 |
* @since 1.9.8.4 |
| 72 |
* |
| 73 |
* @param bool|string $context Context. |
| 74 |
*/ |
| 75 |
public function __construct( $context = false ) { |
| 76 |
|
| 77 |
// Initialize the API if the API Key and Secret have been defined in the Plugin Settings. |
| 78 |
$settings = new ConvertKit_Settings(); |
| 79 |
if ( $settings->has_api_key_and_secret() ) { |
| 80 |
$this->api = new ConvertKit_API( |
| 81 |
$settings->get_api_key(), |
| 82 |
$settings->get_api_secret(), |
| 83 |
$settings->debug_enabled(), |
| 84 |
$context |
| 85 |
); |
| 86 |
} |
| 87 |
|
| 88 |
// Call parent initialization function. |
| 89 |
parent::init(); |
| 90 |
|
| 91 |
} |
| 92 |
|
| 93 |
} |
| 94 |
|