private function raw_parse($pless, $type) { $pless = $this->add_constants('') . $this->add_bootstrap() . $pless; try { $css = $this->lparser->compile($pless); } catch (Exception $e) { plupop("pl_less_error_{$type}", $e->getMessage()); return sprintf("/* LESS PARSE ERROR in your %s CSS: %s */\r\n", ucfirst($type), $e->getMessage()); } // were good! plupop("pl_less_error_{$type}", false); return $css; }
/** * Add Guide * * Use to add a user's guide for the section * * @since ... * * @param $options * * @uses ploption * @uses plupop * @uses PAGELINES_SPECIAL * * @return array * @TODO document */ function add_guide($options) { if (is_file($this->base_dir . '/guide.php')) { ob_start(); include $this->base_dir . '/guide.php'; $guide = ob_get_clean(); $key = sprintf('hide_guide_%s', $this->id); $opt = array($key => array('type' => 'text_content', 'title' => __('Getting Started', 'pagelines'), 'shortexp' => __('How to use this section', 'pagelines'), 'exp' => $guide, 'inputlabel' => __('Hide This Overview', 'pagelines'))); // Has this been hidden? $special_oset = array('setting' => PAGELINES_SPECIAL); $global_option = (bool) ploption($key); $special_option = (bool) ploption($key, $special_oset); // var_dump( $special_option ); if ($global_option && $special_option) { $hide = true; } elseif ($special_option && !$global_option) { plupop($key, true); $hide = true; } elseif (!$special_option && $global_option) { plupop($key, false); $hide = false; } else { $hide = false; } if (!$hide) { $options = array_merge($opt, $options); } else { $opt = array($key => array('type' => 'text_content_reverse', 'inputlabel' => __('Hide Section Guide', 'pagelines'))); $options = array_merge($options, $opt); } } return $options; }
/** * These functions pull options/settings * from the options database. * **/ function get_pagelines_option($key, $setting = null, $default = null) { // get setting $setting = $setting ? $setting : PAGELINES_SETTINGS; if (!isset($setting) || $setting == PAGELINES_SETTINGS) { global $global_pagelines_settings; if (is_array($global_pagelines_settings) && isset($global_pagelines_settings[$key])) { return $global_pagelines_settings[$key]; } else { if ($default) { plupop($key, $default); return $default; } } return false; } }
private function raw_parse($pless, $type) { require_once PL_INCLUDES . '/less.plugin.php'; if (!$this->lparser) { $this->lparser = new plessc(); } $pless = $this->add_constants('') . $this->add_bootstrap() . $pless; try { $css = $this->lparser->compile($pless); } catch (Exception $e) { plupop("pl_less_error_{$type}", $e->getMessage()); return sprintf("/* LESS PARSE ERROR in your %s CSS: %s */\r\n", ucfirst($type), $e->getMessage()); } // we're good! plupop("pl_less_error_{$type}", false); return $css; }
private static function regenerate_purge_key() { plupop(self::PL_OPT_KEY, self::generate_purge_key()); }
/** * * @TODO document * */ function pagelines_register_settings() { register_setting(PAGELINES_SETTINGS, PAGELINES_SETTINGS, 'pagelines_settings_callback'); register_setting(PAGELINES_SPECIAL, PAGELINES_SPECIAL); register_setting(PAGELINES_TEMPLATES, PAGELINES_TEMPLATES); /* Typography Options */ $GLOBALS['pl_foundry'] = new PageLinesFoundry(); /* Import/Exporting */ pagelines_import_export(); pagelines_process_reset_options(); if (!isset($_REQUEST['page']) || $_REQUEST['page'] != 'pagelines') { return; } global $new_default_settings; /* New Default Options in Child Themes */ if (!isset($_GET['newoptions']) && pagelines_activate_or_reset() && !empty($new_default_settings)) { $type = sprintf('&%s=true', pagelines_activate_or_reset()); foreach ($new_default_settings as $key => $set) { plupop($set['key'], $set['value'], array('parent' => $set['parent'], 'subkey' => $set['subkey'], 'setting' => $set['setting'])); } wp_redirect(admin_url(PL_SETTINGS_URL . '&newoptions=true' . $type)); } /* Handle Reset of Options */ if (ploption('reset')) { update_option(PAGELINES_SETTINGS, pagelines_settings_defaults()); global $extension_control; $extension_control->flush_caches(); wp_redirect(admin_url(PL_SETTINGS_URL . '&reset=true')); exit; } }
function pagelines_ajax_callback() { /** This is how you get access to the database */ global $wpdb; $save_type = $_POST['type'] ? $_POST['type'] : null; $setting = $_POST['setting']; $button_id = $_POST['oid']; $pieces = explode('OID', $_POST['oid']); $oid = $pieces[0]; $parent_oid = isset($pieces[1]) ? $pieces[1] : null; // Uploads if ($save_type == 'upload') { $arr_file_type = wp_check_filetype(basename($_FILES[$button_id]['name'])); $uploaded_file_type = $arr_file_type['type']; // Set an array containing a list of acceptable formats $allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/x-icon'); if (in_array($uploaded_file_type, $allowed_file_types)) { $filename = $_FILES[$button_id]; $filename['name'] = preg_replace('/[^a-zA-Z0-9._\\-]/', '', $filename['name']); $override['test_form'] = false; $override['action'] = 'wp_handle_upload'; $uploaded_file = wp_handle_upload($filename, $override); $upload_tracking[] = $button_id; plupop($oid, $uploaded_file['url'], array('setting' => $setting, 'parent' => $parent_oid)); $name = 'PageLines- ' . addslashes($filename['name']); $attachment = array('guid' => $uploaded_file['url'], 'post_mime_type' => $uploaded_file_type, 'post_title' => $name, 'post_content' => '', 'post_status' => 'inherit'); $attach_id = wp_insert_attachment($attachment, $uploaded_file['file']); $attach_data = wp_generate_attachment_metadata($attach_id, $uploaded_file['file']); wp_update_attachment_metadata($attach_id, $attach_data); } else { $uploaded_file['error'] = __('Unsupported file type!', 'pagelines'); } if (!empty($uploaded_file['error'])) { echo sprintf(__('Upload Error: %s', 'pagelines'), $uploaded_file['error']); } else { //print_r($r); echo $uploaded_file['url']; // Is the Response } } elseif ($save_type == 'image_reset') { plupop($oid, null, array('setting' => $setting, 'parent' => $parent_oid)); } die; }
/** * * @TODO document * */ function full_upgrade($settings) { // here we go, 1st were gonna set the defaults add_option(PAGELINES_SETTINGS, pagelines_settings_defaults()); add_option(PAGELINES_TEMPLATE_MAP, get_option(PAGELINES_TEMPLATE_MAP_LEGACY)); $defaults = get_option(PAGELINES_SETTINGS); // copy the template-maps update_option(PAGELINES_TEMPLATE_MAP, get_option(PAGELINES_TEMPLATE_MAP_LEGACY)); // now were gonna merge... foreach ($settings as $key => $data) { if (isset($defaults[$key])) { if (!empty($data)) { plupop($key, $data); } } } plupop('pagelines_version', PL_CORE_VERSION); }
/** * Save Meta Options * * Use tabs array to save options... * Need to identify if the option is being set to empty or has never been set * *Section Control* gets its own saving schema */ function save_meta_options($postID) { // Make sure we are saving on the correct post type... // Current post type is passed in $_POST $current_post_type = isset($_POST['post_type']) ? $_POST['post_type'] : false; $post_type_save = in_array($current_post_type, $this->settings['posttype']) ? true : false; if ((isset($_POST['update']) || isset($_POST['save']) || isset($_POST['publish'])) && $post_type_save) { $page_template = isset($_POST['page_template']) ? $_POST['page_template'] : null; $save_template = $this->get_save_template_type($_POST['post_type'], $page_template); $template_type = new PageLinesTemplate($save_template); $template_type->load_section_optionator(); // Loop through tabs foreach ($this->tabs as $tab => $t) { // Loop through tab options foreach ($t->options as $oid => $o) { if ($oid == 'section_control') { $this->save_sc($postID); } elseif ($oid == 'page_background_image') { $this->save_bg($oid, $postID); } elseif ($o['type'] == 'text_content' || $o['type'] == 'text_content_reverse') { $option_value = isset($_POST[$oid]) ? $_POST[$oid] : null; plupop($oid, $option_value); plupop($oid, $option_value, array('setting' => PAGELINES_SPECIAL)); } elseif ($o['type'] == 'check' && (bool) pldefault($oid)) { $reverse = $oid . "_reverse"; $option_value = isset($_POST[$reverse]) ? $_POST[$reverse] : null; if (!empty($option_value) || get_post_meta($postID, $reverse)) { update_post_meta($postID, $reverse, $option_value); } } else { // Note: If the value is null, then test to see if the option is already set to something // create and overwrite the option to null in that case (i.e. it is being set to empty) if (isset($o['selectvalues']) && pagelines_is_multi_option($oid, $o)) { foreach ($o['selectvalues'] as $sid => $s) { $option_value = isset($_POST[$sid]) ? $_POST[$sid] : null; if (!empty($option_value) || get_post_meta($postID, $sid)) { update_post_meta($postID, $sid, $option_value); } } } else { $option_value = isset($_POST[$oid]) ? $_POST[$oid] : null; if (!empty($option_value) || get_post_meta($postID, $oid)) { update_post_meta($postID, $oid, $option_value); } } } } } } }