Esempio n. 1
0
 function avia_generate_stylesheet($options = false)
 {
     global $avia;
     $safe_name = avia_backend_safe_string($avia->base_data['prefix']);
     $safe_name = apply_filters('avf_dynamic_stylesheet_filename', $safe_name);
     if (defined('AVIA_CSSFILE') && AVIA_CSSFILE === FALSE) {
         $dir_flag = update_option('avia_stylesheet_dir_writable' . $safe_name, 'false');
         $stylesheet_flag = update_option('avia_stylesheet_exists' . $safe_name, 'false');
         return;
     }
     $wp_upload_dir = wp_upload_dir();
     $stylesheet_dir = $wp_upload_dir['basedir'] . '/dynamic_avia';
     $stylesheet_dir = str_replace('\\', '/', $stylesheet_dir);
     $stylesheet_dir = apply_filters('avia_dyn_stylesheet_dir_path', $stylesheet_dir);
     $isdir = avia_backend_create_folder($stylesheet_dir);
     /*
      * directory could not be created (WP upload folder not write able)
      * @todo save error in db and output error message for user.
      * @todo maybe add mkdirfix: http://php.net/manual/de/function.mkdir.php
      */
     if ($isdir === false) {
         $dir_flag = update_option('avia_stylesheet_dir_writable' . $safe_name, 'false');
         $stylesheet_flag = update_option('avia_stylesheet_exists' . $safe_name, 'false');
         return;
     }
     /*
      *  Go ahead - WP managed to create the folder as expected
      */
     $stylesheet = trailingslashit($stylesheet_dir) . $safe_name . '.css';
     $stylesheet = apply_filters('avia_dyn_stylesheet_file_path', $stylesheet);
     //import avia_superobject and reset the options array
     $avia_superobject = $GLOBALS['avia'];
     $avia_superobject->reset_options();
     //regenerate style array after saving options page so we can create a new css file that has the actual values and not the ones that were active when the script was called
     avia_prepare_dynamic_styles();
     //generate stylesheet content
     $generate_style = new avia_style_generator($avia_superobject, false, false, false);
     $styles = $generate_style->create_styles();
     $created = avia_backend_create_file($stylesheet, $styles, true);
     if ($created === true) {
         $dir_flag = update_option('avia_stylesheet_dir_writable' . $safe_name, 'true');
         $stylesheet_flag = update_option('avia_stylesheet_exists' . $safe_name, 'true');
         $dynamic_id = update_option('avia_stylesheet_dynamic_version' . $safe_name, uniqid());
     }
 }
Esempio n. 2
0
 function avia_custom_styles()
 {
     require_once 'includes/admin/register-dynamic-styles.php';
     // register the styles for dynamic frontend styling
     avia_prepare_dynamic_styles();
 }