Exemplo n.º 1
0
 private function get_notice_json()
 {
     // filesystem object
     $filesystem = $this->parent->filesystem;
     // get notice data from server
     //$data = $filesystem->execute('get_contents', $this->server_file);// 'http://www.reduxframework.com/' . 'wp-content/uploads/redux/redux_notice.json');
     $data = wp_remote_get($this->server_file, array('sslverify' => false));
     $data = $data['body'];
     // if some data exists
     if ($data != '' || !empty($data)) {
         // if local notice file exists
         if (file_exists($this->notice_json)) {
             // get cached data
             $cache_data = $filesystem->execute('get_contents', $this->notice_json);
             // if local and server data are same, then return
             if (strcmp($data, $cache_data) == 0) {
                 // set new cookie for interval value
                 Redux_Functions::setCookie($this->cookie_id, time(), time() + 86400 * $this->interval, '/');
                 // bail out
                 return;
             }
         }
         // set server data
         $params = array('content' => $data);
         // write local notice file with new data
         $filesystem->execute('put_contents', $this->notice_json, $params);
         // set cookie for three day expiry
         setcookie($this->cookie_id, time(), time() + 86400 * $this->interval, '/');
         // set unique key for dismiss meta key
         update_option($this->cookie_id, time());
     }
 }
Exemplo n.º 2
0
 private function get_notice_json()
 {
     // get notice data from server
     $data = @wp_remote_get($this->server_file, array('sslverify' => false));
     if (isset($data) && !empty($data) && !is_wp_error($data) && $data['response']['code'] == 200) {
         $data = $data['body'];
         // if some data exists
         if ($data != '' || !empty($data)) {
             if (!empty($this->notice_data)) {
                 if (strcmp($data, $this->notice_data) == 0) {
                     // set new cookie for interval value
                     Redux_Functions::setCookie($this->cookie_id, time(), time() + 86400 * $this->interval, '/');
                     // bail out
                     return;
                 }
             }
             update_option('r_notice_data', $data);
             $this->notice_data = $data;
             // set cookie for three day expiry
             setcookie($this->cookie_id, time(), time() + 86400 * $this->interval, '/');
             // set unique key for dismiss meta key
             update_option($this->cookie_id, time());
         }
     }
 }