static function tag($name, $data = '', $attr = array(), $do = TRUE, $esc_html = FALSE) { if (!$do) { return $data; } if (!WPHF::_is_scalar($data)) { $data = ''; } trim($data); $data = $esc_html ? esc_html($data) : $data; $attr = WPHF::parse_attributes($attr); if (self::is_tag($name)) { if (strlen($data) == 0 and !in_array($name, array('script'))) { return ''; } $data = sprintf('<%1$s%3$s>%2$s</%1$s>', $name, $data, $attr); } elseif (self::is_tag($name, FALSE)) { $data = sprintf('<%1$s%2$s />', $name, $attr); } return $data; }
function save_wp_query() { // _log($this->wp_query); $this->cache['wp_query'] = $this->wp_query; foreach ((array) $this->wp_query as $property_name => $property_value) { // save conditional tags if (WPHF::has_prefix($property_name, self::$conditional_tag)) { $this->is[$property_name] = $property_value; } } }
function _filter_scripts() { $store =& $this->stores['scripts']; // get deps $deps_global = array(); $deps_plugin = array(); foreach ($store as $script) { extract($script); $pieces = explode('.', $file); $len = count($pieces); // library handle if ($len >= 2 and !in_array($pieces[0], $deps_global)) { $deps_global[] = $pieces[0]; } // plugin handle if ($len >= 3 and !in_array($pieces[1], $deps_plugin) and !WPHF::has_segment('widgets', $url)) { $deps_plugin[] = $file; } } foreach ($store as &$script) { extract($script); $pieces = explode('.', basename($file)); $len = count($pieces); if ($len >= 2) { $script['deps'] = array_merge($script['deps'], $deps_global); } if ($len < 3) { $script['deps'] = array_merge($script['deps'], $deps_plugin); } } // add ie substore $store_new = array('normal' => array(), 'ie' => array()); foreach ($store as &$script) { extract($script); $vars = array_keys($script); $store_sub = 'normal'; $is_ie_script = ($matches = $this->is_ie_script($url) and $matches !== FALSE); if ($is_ie_script) { list(, $ie_op, $ie_ver, $ie_plugin) = $matches; if ($ie_plugin == 'png') { $ie_op = 'lte'; $ie_ver = 6; } $vars = array_merge($vars, array('ie_op', 'ie_ver')); $store_sub = 'ie'; // make tag $vars[] = 'tag'; $tag = WPOT::tag('script', '', array('src' => $url . '?ver=' . $ver, 'type' => 'text/javascript', 'charset' => 'UTF-8')) . PHP_EOL; } $store_new[$store_sub][] = compact($vars); } $store = $store_new; }
/** * @see class Walker_Page, function start_el */ function nav_link_post_to_page($output, $count = FALSE, $smarttip = FALSE) { if ($this->is_single) { $pages = explode('<li', $output); $web_root = trailingslashit(get_bloginfo('url')); $current_category = WPHF::element($this->wp_query->query['category_name'], $this->categories); // key is slug if (!$current_category) { return $output; } foreach ($pages as &$page) { preg_match('/href="[-a-z:_\\/]+\\/([-a-z]+)"/i', $page, $matches); // get the last part // match wp format if (count($matches) < 2) { continue; } $section_category = WPHF::element($matches[1], $this->categories); if ($section_category and $section_category->slug == $current_category->slug) { $page = str_replace('class="', 'class="current_page_parent ', $page); } else { $custom_routing = WPHF::element('children', WPHF::element($matches[1], $this->routing)); if ($custom_routing and in_array($current_category->slug, $custom_routing)) { $page = str_replace('class="', 'class="current_page_ancestor ', $page); } } } $output = implode('<li', $pages); } return $output; }