public function add_js_defaults($data) { $newdata = array('defaults' => self::default_properties(), 'template' => upfront_get_template_url('uaccordion', upfront_element_url('tpl/uaccordion.html', dirname(__FILE__)))); if (isset($data['uaccordion'])) { if (isset($data['uaccordion']['defaults'])) { $merged_defaults = array_merge($data['uaccordion']['defaults'], $newdata['defaults']); $data['uaccordion']['defaults'] = $merged_defaults; } else { $data['uaccordion']['defaults'] = $newdata['defaults']; } $data['uaccordion']['template'] = $newdata['template']; } else { $data['uaccordion'] = $newdata; } return $data; }
/** * Fetching and pre-processing the relative/absolute paths in styles. */ private function _get_style_contents($frags) { $path = upfront_element_dir($frags[0], $frags[1]); $url = upfront_element_url($frags[0], $frags[1]); if (!file_exists($path)) { return false; } $style = file_get_contents($path); // Obtain the first "../" level $base_url = trailingslashit(dirname(dirname($url))); // First up, let's build up allowed directories list $dirs = explode('/', $base_url); $relatives = array(); $upfront_root = preg_quote(Upfront::get_root_url(), '/'); while (array_pop($dirs) !== NULL) { $rel = join('/', $dirs); $relatives[] = $rel; if (preg_match('/^' . $upfront_root . '$/', $rel)) { break; } // Let's not allow relative paths inclusion higher than the Upfront root } if (empty($relatives)) { return $style; } // Next, let's build the matching patterns list $matchers = array(); foreach ($relatives as $idx => $relpath) { $count = $idx + 1; $matchers[$count] = array('url' => $relpath, 'pattern' => str_repeat('../', $count)); } $matchers = array_reverse($matchers); // Start with longest match first // Lastly, let's actually replace the relative paths $slash = preg_quote('/', '/'); foreach ($matchers as $match) { if (empty($match['pattern']) || empty($match['url'])) { continue; } $rx = "/([^{$slash}])" . preg_quote($match['pattern'], '/') . '([^.]{2})/'; // Let's start small $rpl = '$1' . trailingslashit($match['url']) . '$2'; $style = preg_replace($rx, $rpl, $style); } return $style; }
/** * Adds element script resource. * @param string $slug Script ID to be keyed under (hopefully unique) * @param array $path_info Two-member array, describing resource location. The members are like arguments for upfront_element_dir/upfront_element_url * @return bool False on failure/invalid arguments, true on success */ function upfront_add_element_script($slug, $path_info) { if (empty($slug) || empty($path_info)) { return false; } if (!is_array($path_info)) { return false; } if (count($path_info) != 2) { return false; } if (current_theme_supports("upfront-element_scripts") && current_theme_supports("{$slug}-script")) { return true; } // Current theme supports element scripts, and this script in particular if (empty($_GET['dev']) && empty($_GET['debug'])) { // Yeah, so re-intorduce the hacks $hub = Upfront_PublicScripts_Registry::get_instance(); return $hub->set($slug, $path_info); } else { wp_enqueue_script($slug, upfront_element_url($path_info[0], $path_info[1]), array('jquery')); } }
public function add_js_defaults($data) { $post_types = get_post_types(array('public' => true), 'objects'); $labels = get_terms('media_label', array('hide_empty' => false)); $labels_names = array(); $labels_ids = array(); foreach ($labels as $label) { if (!is_object($label)) { continue; } $labels_ids[$label->term_id] = array('id' => $label->term_id, 'text' => $label->name); $labels_names[$label->name] = array('id' => $label->term_id, 'text' => $label->name); } // Sanitize post type objects array foreach ($post_types as $ptidx => $ptype) { if (empty($ptype->register_meta_box_cb)) { continue; } $ptype->register_meta_box_cb = false; $post_types[$ptidx] = $ptype; } // Whatever we need in the post types array, I am fairly sure metabox callback is *NOT* one of those things... $data['ugallery'] = array('defaults' => self::default_properties(), 'imageDefaults' => self::image_defaults(), 'template' => upfront_get_template_url('ugallery', upfront_element_url('tpl/ugallery.html', dirname(__FILE__))), 'lightboxTpl' => upfront_get_template('lightbox', array(), dirname(dirname(__FILE__)) . '/tpl/lightbox.html'), 'postTypes' => $post_types, 'grids' => array(), 'label_names' => $labels_names, 'label_ids' => $labels_ids, 'themeDefaults' => apply_filters('upfront_gallery_defaults', array())); return $data; }
public function add_js_defaults($data) { $data['uimage'] = array('defaults' => self::default_properties(), 'template' => upfront_get_template_url('uimage', upfront_element_url('tpl/image.html', dirname(__FILE__)))); return $data; }
function upfront_maps_add_maps_local_url($data) { $data['upfront_maps'] = array("root_url" => trailingslashit(upfront_element_url('/', dirname(__FILE__))), "markers" => trailingslashit(upfront_element_url('img/markers/', dirname(__FILE__)))); return $data; }
public static function add_data_defaults($data) { $data['upfront_login'] = array("defaults" => self::default_properties(), "root_url" => trailingslashit(upfront_element_url('/', dirname(__FILE__)))); return $data; }
public static function add_js_defaults($data) { $data['uslider'] = array('defaults' => self::default_properties(), 'slideDefaults' => self::slide_defaults(), 'template' => upfront_get_template_url('uslider', upfront_element_url('tpls/uslider.html', dirname(__FILE__)))); return $data; }