Пример #1
0
 /**
  * Simple cache.
  * @return object
  */
 function get_latest_cached($type, $flush = null)
 {
     $url = trailingslashit(PL_API . $type);
     $options = array('body' => array('username' => $this->username != '' ? $this->username : false, 'password' => $this->password != '' ? $this->password : false, 'flush' => $flush));
     if (false === ($api_check = get_transient('pagelines_extend_' . $type))) {
         // ok no transient, we need an update...
         $response = pagelines_try_api($url, $options);
         if ($response !== false) {
             // ok we have the data parse and store it
             $api = wp_remote_retrieve_body($response);
             set_transient('pagelines_extend_' . $type, true, 86400);
             update_option('pagelines_extend_' . $type, $api);
         }
     }
     $api = get_option('pagelines_extend_' . $type, false);
     if (!$api) {
         return __('<h2>Unable to fetch from API</h2>', 'pagelines');
     }
     return json_decode($api);
 }
Пример #2
0
 function pagelines_get_user_updates()
 {
     $options = array('body' => array('updates' => json_encode(get_theme_mod('available_updates'))));
     $url = PL_API . '?get_updates';
     $response = pagelines_try_api($url, $options);
     $pagelines_update = wp_remote_retrieve_body($response);
     set_theme_mod('pending_updates', $pagelines_update);
 }
Пример #3
0
 function pagelines_livechat_rules()
 {
     $url = 'api.pagelines.com/plus_latest';
     if ($welcome = get_transient('pagelines_pluschat')) {
         return json_decode($welcome);
     }
     $response = pagelines_try_api($url, false);
     if ($response !== false) {
         if (!is_array($response) || is_array($response) && $response['response']['code'] != 200) {
             $out = '';
         } else {
             $welcome = wp_remote_retrieve_body($response);
             set_transient('pagelines_pluschat', $welcome, 86400);
             $out = json_decode($welcome);
         }
     }
     return $out;
 }
 /**
  *
  * @TODO document
  *
  */
 function unsubscribe($type, $file, $path, $uploader, $checked)
 {
     print __('Unsubscribing...', 'pagelines');
     $data = explode('|', $path);
     $options = array('body' => array('email' => get_bloginfo('admin_email'), 'version' => $data[2], 'username' => $data[0]));
     $url = 'api.pagelines.com/unsubscribe/' . $data[1];
     $result = pagelines_try_api($url, $options);
     if ($result['response']['code'] == 200 && $result['body'] == $data[1]) {
         delete_transient(sprintf(PL_ADMIN_STORE_SLUG . '_%ss', $type));
         $message = __('Done.', 'pagelines');
         $text = sprintf('&extend_text=%s_install#added', $type);
         $this->page_reload(PL_ADMIN_STORE_SLUG . $text, null, $message);
     }
 }