/** * Class constructor. * * @param string $_api_url The URL pointing to the custom API endpoint. * @param string $_plugin_file Path to the plugin file. * @param array $_api_data Optional data to send with API calls. * * @return Ai1ec_EDD_SL_Plugin_Updater */ public function __construct($_api_url, $_plugin_file, $_api_data = null) { $this->_timely_api_data = $_api_data; $_api_url = $this->_modify_api_url($_api_url, $_plugin_file, $_api_data); $this->_timely_api_url = $_api_url; parent::__construct($_api_url, $_plugin_file, $_api_data); $this->_timely_api_url = trailingslashit($this->_timely_api_url); }
protected function api_request($_action, $_data) { $time_key = $this->slug . '-plugin_updater_api_request_last_checked'; $api_key = $this->slug . '-plugin_updater_api_request'; $entity = new WPFront_User_Role_Editor_Entity_Options(); $time = $entity->get_option($time_key); if ($time === NULL || $time < time() - 6 * 3600) { $api = NULL; } else { $api = $entity->get_option($api_key); } if ($api === NULL) { $api = parent::api_request($_action, $_data); if ($api) { $entity->update_option($api_key, serialize($api)); $entity->update_option($time_key, time()); } } else { $api = unserialize($api); } return $api; }