function setCache($content, $file = "")
 {
     if ($file != "") {
         $this->file = $file;
     }
     if ($this->method === false) {
         return false;
     }
     if (file_exists($this->file)) {
         $filetime = filemtime($this->file);
     } else {
         $filetime = 0;
     }
     $current_time = time();
     if ($current_time - $filetime > $this->time) {
         @wpd_put_file($this->file, $content);
     }
 }
Beispiel #2
0
 /**
  * Generates all Ajax Search Pro CSS code
  */
 function asp_generate_the_css()
 {
     global $wpdb;
     $css_arr = array();
     if (isset($wpdb->base_prefix)) {
         $_prefix = $wpdb->base_prefix;
     } else {
         $_prefix = $wpdb->prefix;
     }
     $comp_settings = get_option('asp_compatibility');
     $async_load = w_isset_def($comp_settings['css_async_load'], false);
     $search = $wpdb->get_results("SELECT * FROM " . $_prefix . "ajaxsearchpro", ARRAY_A);
     if (is_array($search) && count($search) > 0) {
         foreach ($search as $s) {
             $s['data'] = json_decode($s['data'], true);
             // $style and $id needed in the include
             $style = $s['data'];
             $id = $s['id'];
             ob_start();
             include ASP_PATH . "/css/style.css.php";
             $out = ob_get_contents();
             $css_arr[$id] = $out;
             ob_end_clean();
         }
         // Too big, disabled...
         //update_option('asp_styles_base64', base64_encode($css));
         $css = implode(" ", $css_arr);
         if ($async_load == 1) {
             foreach ($css_arr as $sid => $c) {
                 wpd_put_file(ASP_CSS_PATH . "/async/search" . $sid . ".css", $c);
             }
         } else {
             wpd_put_file(ASP_CSS_PATH . "/style.instances.css", $css);
         }
         update_option("asp_media_query", asp_gen_rnd_str());
         return $css;
     }
 }
Beispiel #3
0
 /**
  * Generates all Ajax Search Pro CSS code
  */
 function asp_generate_the_css()
 {
     global $wpdb;
     $css = "";
     if (isset($wpdb->base_prefix)) {
         $_prefix = $wpdb->base_prefix;
     } else {
         $_prefix = $wpdb->prefix;
     }
     $search = $wpdb->get_results("SELECT * FROM " . $_prefix . "ajaxsearchpro", ARRAY_A);
     if (is_array($search) && count($search) > 0) {
         foreach ($search as $s) {
             $s['data'] = json_decode($s['data'], true);
             // $style and $id needed in the include
             $style = $s['data'];
             $id = $s['id'];
             ob_start();
             include ASP_PATH . "/css/style.css.php";
             $out = ob_get_contents();
             $css .= $out . " ";
             ob_end_clean();
         }
         update_option('asp_styles_base64', base64_encode($css));
         wpd_put_file(ASP_CSS_PATH . "/style.instances.css", $css);
     }
 }