function scripts() { wp_enqueue_style('css3colorpicker', PL_JS . '/colorpicker/colorpicker.css'); pl_enqueue_codemirror(); // PageLines Specific JS @Code Stuff wp_enqueue_script('pl-less-parser', PL_JS . '/utils.less.js', array('jquery'), pl_get_cache_key(), true); wp_enqueue_script('pl-js-code', $this->url . '/js/pl.code.js', array('jquery', 'codemirror', 'pl-less-parser'), pl_get_cache_key(), true); // less.js $lessjs_config = array('env' => is_pl_debug() ? 'development' : 'production'); wp_localize_script('pl-less-parser', 'less', $lessjs_config); }
function __construct() { if (!is_pl_debug()) { return; } // Add tab to toolbar add_filter('pl_toolbar_config', array($this, 'toolbar')); // Add developer settings to JSON blob add_filter('pl_json_blob_objects', array($this, 'add_to_blob')); add_action('wp_footer', array($this, 'draw_developer_data'), 200); add_action('wp_before_admin_bar_render', array($this, 'admin_bar')); $this->url = PL_PARENT_URL . '/editor'; global $pl_perform; $pl_perform = array(); }
function get_section_data($uids) { $start_time = microtime(TRUE); $imploded_uids = join("','", $uids); $query = sprintf("SELECT uid, draft, live from {$this->table_name} Where uid IN ( '%s' )", $imploded_uids); $rows = $this->wpdb->get_results($query); $config = $this->configure_section_data($uids, $rows); if (is_pl_debug()) { pl_add_perform_data(round(microtime(TRUE) - $start_time, 3), __('Section Data Query', 'pagelines'), __('Seconds', 'pagelines'), __('Time for section data DB query and configuration.', 'pagelines')); } return $config; }
/** * Whether or not uncompressed styles should be served. * @return [type] [description] */ public static function serve_pristine() { return defined('SCRIPT_DEBUG') && SCRIPT_DEBUG || is_pl_debug() || !ploption('pl_minify'); }
function get_dev_mode() { return is_pl_debug() ? 'true' : 'false'; }
/** * * Adds PageLines to Admin Bar * * @package PageLines Framework * @subpackage Functions Library * @since 1.3.0 * */ function pagelines_settings_menu_link() { global $wp_admin_bar; global $pagelines_template; if (!current_user_can('edit_theme_options')) { return; } $wp_admin_bar->add_menu(array('id' => 'pl_settings', 'title' => __('PageLines', 'pagelines'), 'href' => admin_url(PL_DASH_URL))); $wp_admin_bar->add_menu(array('id' => 'pl_dashboard', 'parent' => 'pl_settings', 'title' => __('Dashboard', 'pagelines'), 'href' => admin_url(PL_DASH_URL))); $wp_admin_bar->add_menu(array('id' => 'pl_main_settings', 'parent' => 'pl_settings', 'title' => __('Site Options', 'pagelines'), 'href' => admin_url(PL_SETTINGS_URL))); $wp_admin_bar->add_menu(array('id' => 'pl_special', 'parent' => 'pl_settings', 'title' => __('Page Options', 'pagelines'), 'href' => admin_url(PL_SPECIAL_OPTS_URL))); $wp_admin_bar->add_menu(array('id' => 'pl_templates', 'parent' => 'pl_settings', 'title' => __('Drag & Drop', 'pagelines'), 'href' => admin_url(PL_TEMPLATE_SETUP_URL))); $wp_admin_bar->add_menu(array('id' => 'pl_extend', 'parent' => 'pl_settings', 'title' => __('Store', 'pagelines'), 'href' => admin_url(PL_ADMIN_STORE_URL))); $template_name = isset($pagelines_template->template_name) ? $pagelines_template->template_name : false; if ($template_name) { $page_type = __('Template: ', 'pagelines') . ucfirst($template_name); $wp_admin_bar->add_menu(array('id' => 'template_type', 'title' => $page_type, 'href' => admin_url(PL_TEMPLATE_SETUP_URL))); } $spurl = pl_special_url($template_name); if ($template_name && is_pagelines_special() && $spurl) { $wp_admin_bar->add_menu(array('id' => 'special_settings', 'title' => __('Edit Meta', 'pagelines'), 'href' => $spurl)); } if (is_pl_debug() && !is_admin()) { $wp_admin_bar->add_menu(array('id' => 'pl_flush', 'title' => __('Flush LESS', 'pagelines'), 'href' => get_pl_reset_less_url())); } }
/** * Show debug info in footer ( wrapped in tags ) * */ function pl_debug($text = '', $before = "\n/*", $after = '*/') { if (!is_pl_debug()) { return; } $out = sprintf('echo "%s %s %s";', $before, $text, $after); add_action('shutdown', create_function('', $out), 9999); }
/** * Outputs HTML comment to source */ function plcomment($data, $title = 'DEBUG', $type = 'html') { if (is_pl_debug()) { $open = 'html' == $type ? "\n<!-- " : "\n/* "; $close = 'html' == $type ? " -->\n" : "*/\n"; $pre = sprintf('%s START %s %s', $open, $title, $close); $post = sprintf('%s END %s %s', $open, $title, $close); return $pre . $data . $post; } else { return $data; } }
/** * Throw up on error */ function error_handler($type) { $a = error_get_last(); $error = ''; // Unable to activate if ($a['type'] == 4 || $a['type'] == 1) { $error .= sprintf('Unable to activate the %s.', $type); } //Error on line if ($error && is_pl_debug()) { $error .= sprintf('<br />%s in %s on line: %s', $a['message'], basename($a['file']), $a['line']); } echo $error; }
/** * * Minify * * @package PageLines Framework * @since 2.2 */ function minify($css) { if (is_pl_debug()) { return $css; } if (!ploption('pl_minify')) { return $css; } $data = $css; $data = preg_replace('#/\\*.*?\\*/#s', '', $data); // remove new lines \\n, tabs and \\r $data = preg_replace('/(\\t|\\r|\\n)/', '', $data); // replace multi spaces with singles $data = preg_replace('/(\\s+)/', ' ', $data); //Remove empty rules $data = preg_replace('/[^}{]+{\\s?}/', '', $data); // Remove whitespace around selectors and braces $data = preg_replace('/\\s*{\\s*/', '{', $data); // Remove whitespace at end of rule $data = preg_replace('/\\s*}\\s*/', '}', $data); // Just for clarity, make every rules 1 line tall $data = preg_replace('/}/', "}\n", $data); $data = str_replace(';}', '}', $data); $data = str_replace(', ', ',', $data); $data = str_replace('; ', ';', $data); $data = str_replace(': ', ':', $data); $data = preg_replace('#\\s+#', ' ', $data); if (!preg_last_error()) { return $data; } else { return $css; } }