public static function getTag($tag) { if (strpos($tag, 'post_type_') === 0) { if (!post_type_exists($post_type = substr($tag, 10))) { return false; } return array('callback' => function () use($post_type) { return is_singular($post_type); }, 'priority' => 20); } else { if (strpos($tag, 'template_') === 0) { $template = preg_replace('/_(php)$/i', '.\\1', substr($tag, 9)); return array('callback' => function () use($template) { return is_page_template($template); }, 'priority' => 17); } else { if (strpos($tag, 'term_') === 0) { if (!preg_match('/^term_(?P<taxonomy>.+)_(?P<id>[0-9]+)$/', $tag, $term) || !taxonomy_exists($term['taxonomy'])) { return false; } return array('callback' => function () use($term) { if (is_singular()) { return has_term($term['id'], $term['taxonomy']); } switch ($term['taxonomy']) { case 'category': return is_category($term['id']); case 'post_tag': return is_tag($term['id']); default: return is_tax($term['taxonomy'], $term['id']); } }, 'priority' => $term['taxonomy'] == 'post_format' ? 17 : 15 + (int) is_taxonomy_hierarchical($term['taxonomy'])); } else { switch ($tag) { case 'front_page': return array('callback' => 'is_front_page', 'priority' => 10); case 'blog': return array('callback' => function () { return is_home() || is_archive(); }, 'priority' => 40); case 'search': return array('callback' => 'is_search', 'priority' => 10); case '404': return array('callback' => 'is_404', 'priority' => 10); } if (Theme::isPluginActive('bbpress')) { switch ($tag) { case 'bbpress_forum': return array('callback' => 'bbp_is_single_forum', 'priority' => 10); case 'bbpress_topic': return array('callback' => 'bbp_is_single_topic', 'priority' => 10); case 'bbpress': return array('callback' => 'is_bbpress', 'priority' => 10); } } if (Theme::isPluginActive('woocommerce')) { switch ($tag) { case 'woocommerce_shop': return array('callback' => function () { return is_shop() || is_product_taxonomy() || is_product(); }, 'priority' => 30); case 'woocommerce_cart': return array('callback' => 'is_cart', 'priority' => 10); case 'woocommerce_checkout': return array('callback' => 'is_checkout', 'priority' => 10); case 'woocommerce_order_received_page': return array('callback' => 'is_order_received_page', 'priority' => 10); case 'woocommerce_account_page': return array('callback' => 'is_account_page', 'priority' => 10); case 'woocommerce': return array('callback' => function () { return is_shop() || is_product_taxonomy() || is_product() || is_cart() || is_checkout() || is_order_received_page() || is_account_page(); }, 'priority' => 30); } } return false; } } } }
public function __filterPostGallery($output, $atts) { if (Theme::isPluginActive('jetpack') && (isset($atts['type']) && $atts['type'] && $atts['type'] != 'default' || get_option('tiled_galleries'))) { return ''; } return $this->shortcode($atts, null, $this->tag); }