/**
*
* @TODO do
*
*/
function pagelines_import_export()
{
    if (isset($_POST['form_submitted']) && $_POST['form_submitted'] == 'export_settings_form') {
        $pagelines_settings = (array) get_option(PAGELINES_SETTINGS);
        $pagelines_template_map = (array) get_option(PAGELINES_TEMPLATE_MAP);
        $pagelines_templates = (array) get_option(PAGELINES_TEMPLATES);
        $pagelines_special = (array) get_option(PAGELINES_SPECIAL);
        $options['pagelines_templates'] = $pagelines_templates;
        $options['pagelines_template_map'] = $pagelines_template_map;
        $options['pagelines_settings'] = $pagelines_settings;
        $options['pagelines_special'] = $pagelines_special;
        if (isset($options) && is_array($options)) {
            header('Cache-Control: public, must-revalidate');
            header('Pragma: hack');
            header('Content-Type: text/plain');
            header('Content-Disposition: attachment; filename="' . PL_THEMENAME . '-Settings-' . date('Ymd') . '.dat"');
            echo json_encode($options);
            exit;
        }
    }
    if (isset($_POST['form_submitted']) && $_POST['form_submitted'] == 'import_settings_form') {
        if (strpos($_FILES['file']['name'], 'Settings') === false && strpos($_FILES['file']['name'], 'settings') === false) {
            wp_redirect(admin_url(PL_IMPORT_EXPORT_URL . '&pageaction=import&error=wrongfile'));
        } elseif ($_FILES['file']['error'] > 0) {
            $error_type = $_FILES['file']['error'];
            wp_redirect(admin_url(PL_IMPORT_EXPORT_URL . '&pageaction=import&error=file&' . $error_type));
        } else {
            $raw_options = pl_file_get_contents($_FILES['file']['tmp_name']);
            $all_options = json_decode(json_encode(json_decode($raw_options)), true);
            if (!isset($_POST['pagelines_layout']) && is_array($all_options) && isset($all_options['pagelines_settings']) && is_array($all_options['pagelines_settings'])) {
                unset($all_options['pagelines_settings']['layout']);
            }
            if (isset($_POST['pagelines_settings']) && is_array($all_options) && isset($all_options['pagelines_settings']) && is_array($all_options['pagelines_settings'])) {
                update_option(PAGELINES_SETTINGS, array_merge(get_option(PAGELINES_SETTINGS), $all_options['pagelines_settings']));
                $done = 1;
            }
            if (isset($_POST['pagelines_special']) && is_array($all_options) && isset($all_options['pagelines_special']) && is_array($all_options['pagelines_special'])) {
                $special = (array) get_option(PAGELINES_SPECIAL);
                update_option(PAGELINES_SPECIAL, array_merge($special, $all_options['pagelines_special']));
                $done = 1;
            }
            if (isset($_POST['pagelines_templates']) && is_array($all_options) && isset($all_options['pagelines_template_map']) && is_array($all_options['pagelines_template_map'])) {
                $template_map = (array) get_option(PAGELINES_TEMPLATE_MAP);
                $template_settings = (array) get_option(PAGELINES_TEMPLATES);
                $template_settings_new = isset($all_options['pagelines_templates']) && is_array($all_options['pagelines_templates']) ? $all_options['pagelines_templates'] : array();
                $template_map_new = isset($all_options['pagelines_template_map']) && is_array($all_options['pagelines_template_map']) ? $all_options['pagelines_template_map'] : array();
                update_option(PAGELINES_TEMPLATE_MAP, array_merge($template_map, $template_map_new));
                update_option(PAGELINES_TEMPLATES, array_merge($template_settings, $template_settings_new));
                $done = 1;
            }
            if (function_exists('wp_cache_clean_cache')) {
                global $file_prefix;
                wp_cache_clean_cache($file_prefix);
            }
            if (isset($done)) {
                wp_redirect(admin_url(PL_IMPORT_EXPORT_URL . '&pageaction=import&imported=true'));
            } else {
                wp_redirect(admin_url(PL_IMPORT_EXPORT_URL . '&pageaction=import&error=wrongfile'));
            }
        }
    }
}
Beispiel #2
0
 function pagelines_insert_core_less_callback($code)
 {
     global $pagelines_raw_lesscode_external;
     $out = '';
     if (is_array($pagelines_raw_lesscode_external) && !empty($pagelines_raw_lesscode_external)) {
         foreach ($pagelines_raw_lesscode_external as $file) {
             if (is_file($file)) {
                 $out .= pl_file_get_contents($file);
             }
         }
         return $code . $out;
     }
     return $code;
 }
Beispiel #3
0
 function import($file, $opts = array())
 {
     $def_opts = array('page_tpl_import' => 'checked', 'global_import' => 'checked', 'type_import' => 'checked');
     $opts = wp_parse_args($opts, $def_opts);
     $parsed['opts'] = $opts;
     $parsed = array('nothing');
     $file_contents = pl_file_get_contents($file);
     $import_defaults = array('draft' => array(), 'live' => array());
     $file_data = $this->strip_header($file_contents);
     $file_data = json_decode($file_data);
     $file_data = json_decode(json_encode($file_data), true);
     // IMPORT MAIN
     if (isset($file_data[PL_SETTINGS]) && 'checked' == $opts['global_import']) {
         pl_update_global_settings($file_data[PL_SETTINGS]);
         $parsed[] = 'globals';
     }
     // IMPORT USER MAPS
     if (isset($file_data['pl-user-templates']) && 'checked' == $opts['page_tpl_import']) {
         $new = $import_defaults;
         $old = get_option('pl-user-templates', $import_defaults);
         $import = wp_parse_args($file_data['pl-user-templates'], $import_defaults);
         $new['draft'] = array_merge($old['draft'], $import['draft']);
         $new['live'] = array_merge($old['live'], $import['live']);
         update_option('pl-user-templates', $new);
         $parsed[] = 'user_templates';
     }
     // IMPORT AWESOMENESS
     if (isset($file_data['post_meta']) && 'checked' == $opts['type_import']) {
         foreach ($file_data['post_meta'] as $key => $data) {
             update_post_meta($key, 'pl-settings', $data[0]);
         }
         $parsed[] = 'meta-data';
     }
     if (isset($file_data['custom'])) {
         $parsed[] = 'custom';
         update_option('pl-user-sections', $file_data['custom']);
     }
     if (isset($file_data['section_data'])) {
         $section_opts = $file_data['section_data'];
         global $sections_data_handler;
         if (!is_object($sections_data_handler)) {
             $sections_data_handler = new PLSectionData();
         }
         $section_data = array();
         foreach ($section_opts as $data) {
             $section_data[$data['uid']] = stripslashes_deep($this->unserialize($data['live']));
         }
         $sections = $sections_data_handler->create_items($section_data);
         $parsed['section_data'] = $section_data;
     }
     return json_encode(pl_arrays_to_objects($parsed));
 }
 function get_all_active_sections()
 {
     global $load_sections;
     // refresh sections cache
     $available = $load_sections->pagelines_register_sections(true, true);
     $less = array();
     foreach (pl_get_sections() as $s) {
         $data = $s->sinfo;
         if ($data['less'] && $data['loadme']) {
             if (is_file("{$s->base_dir}/style.less")) {
                 $less[] = pl_file_get_contents("{$s->base_dir}/style.less");
             } elseif (is_file("{$s->base_dir}/color.less")) {
                 $less[] = pl_file_get_contents("{$s->base_dir}/color.less");
             }
         }
     }
     $less = join("\n", $less);
     return apply_filters('pagelines_lesscode', $less);
 }
 public function add_less($path)
 {
     if (is_file($path)) {
         $this->lesscode .= pl_file_get_contents($path);
     }
 }
 function load_less_file($file)
 {
     $file = sprintf('%s.less', $file);
     $parent = sprintf('%s/%s', PL_CORE_LESS, $file);
     $child = sprintf('%s/%s', PL_CHILD_LESS, $file);
     // check for child 1st if not load the main file.
     if (is_file($child)) {
         return pl_file_get_contents($child);
     } else {
         return pl_file_get_contents($parent);
     }
 }
 function import($file, $opts = array())
 {
     $def_opts = array('page_tpl_import' => 'checked', 'global_import' => 'checked', 'type_import' => 'checked');
     $opts = wp_parse_args($opts, $def_opts);
     $parsed['opts'] = $opts;
     $parsed = array('nothing');
     $file_contents = pl_file_get_contents($file);
     $file_data = $this->strip_header($file_contents);
     $file_data = json_decode($file_data);
     $file_data = json_decode(json_encode($file_data), true);
     // IMPORT MAIN
     if (isset($file_data[PL_SETTINGS]) && 'checked' == $opts['global_import']) {
         pl_update_global_settings($file_data[PL_SETTINGS]);
         $parsed[] = 'globals';
     }
     // IMPORT USER MAPS
     if (isset($file_data['pl-user-templates']) && 'checked' == $opts['page_tpl_import']) {
         $existing_templates = get_option('pl-user-templates');
         $new = array('draft' => $file_data['pl-user-templates'], 'live' => $file_data['pl-user-templates']);
         $new_templates = wp_parse_args($new, $existing_templates);
         $parsed['imported_data'] = $file_data['pl-user-templates'];
         $parsed['existing'] = $existing_templates;
         $parsed['merged'] = $new_templates;
         update_option('pl-user-templates', $new_templates);
         $parsed[] = 'user_templates';
     }
     // IMPORT AWESOMENESS
     if (isset($file_data['post_meta']) && 'checked' == $opts['type_import']) {
         foreach ($file_data['post_meta'] as $key => $data) {
             update_post_meta($key, 'pl-settings', $data[0]);
         }
         $parsed[] = 'meta-data';
     }
     if (isset($file_data['section_data'])) {
         $section_opts = $file_data['section_data'];
         global $sections_data_handler;
         $section_data = array();
         foreach ($section_opts as $data) {
             $section_data[$data['uid']] = unserialize($data['live']);
         }
         $sections = $sections_data_handler->create_items($section_data);
         $parsed['section_data'] = $section_data;
     }
     return json_encode(pl_arrays_to_objects($parsed));
 }
Beispiel #8
0
 function legacy()
 {
     $fonts = pl_file_get_contents(dirname(__FILE__) . '/fonts.json');
     return json_decode($fonts);
 }
 public function compileFile($fname, $outFname = null)
 {
     if (!is_readable($fname)) {
         throw new Exception('load error: failed to find ' . $fname);
     }
     $pi = pathinfo($fname);
     $oldImport = $this->importDir;
     $this->importDir = (array) $this->importDir;
     $this->importDir[] = $pi['dirname'] . '/';
     $this->addParsedFile($fname);
     $out = $this->compile(pl_file_get_contents($fname), $fname);
     $this->importDir = $oldImport;
     return $out;
 }
 function get_all_active_sections()
 {
     $out = '';
     global $load_sections;
     $available = $load_sections->pagelines_register_sections(true, true);
     $disabled = get_option('pagelines_sections_disabled', array());
     /*
      * Filter out disabled sections
      */
     foreach ($disabled as $type => $data) {
         if (isset($disabled[$type])) {
             foreach ($data as $class => $state) {
                 unset($available[$type][$class]);
             }
         }
     }
     /*
      * We need to reorder the array so sections css is loaded in the right order.
      * Core, then pagelines-sections, followed by anything else.
      */
     $sections = array();
     $sections['parent'] = $available['parent'];
     unset($available['parent']);
     $sections['child'] = (array) $available['child'];
     unset($available['child']);
     if (is_array($available)) {
         $sections = array_merge($sections, $available);
     }
     foreach ($sections as $t) {
         foreach ($t as $key => $data) {
             if ($data['less'] && $data['loadme']) {
                 if (is_file($data['base_dir'] . '/style.less')) {
                     $out .= pl_file_get_contents($data['base_dir'] . '/style.less');
                 } elseif (is_file($data['base_dir'] . '/color.less')) {
                     $out .= pl_file_get_contents($data['base_dir'] . '/color.less');
                 }
             }
         }
     }
     return apply_filters('pagelines_lesscode', $out);
 }