/** * Overrides archive pages e.g. locations, events, event tags, event tags based on user settings * @param string $template * @return string */ function template($template) { global $wp_query, $EM_Tag, $em_tag_id; if (is_tax(EM_TAXONOMY_TAG) && get_option('dbem_cp_tags_formats', true)) { add_filter('the_content', array('EM_Tag_Taxonomy', 'the_content')); $EM_Tag = em_get_tag($wp_query->queried_object->term_id); $wp_query->em_tag_id = $em_tag_id = $EM_Tag->term_id; //we assign $em_category_id just in case other themes/plugins do something out of the ordinary to WP_Query $wp_query->posts = array(); $wp_query->posts[0] = new stdClass(); $wp_query->posts[0]->post_title = $wp_query->queried_object->post_title = $EM_Tag->output(get_option('dbem_tag_page_title_format')); $post_array = array('ID', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_content_filtered', 'post_parent', 'guid', 'menu_order', 'post_type', 'post_mime_type', 'comment_count', 'filter'); foreach ($post_array as $post_array_item) { $wp_query->posts[0]->{$post_array_item} = ''; } $wp_query->post = $wp_query->posts[0]; $wp_query->post_count = 1; $wp_query->found_posts = 1; $wp_query->max_num_pages = 1; //tweak flags for determining page type $wp_query->is_tax = 0; $wp_query->is_page = 1; $wp_query->is_single = 0; $wp_query->is_singular = 1; $wp_query->is_archive = 0; $template = locate_template(array('page.php', 'index.php'), false); //category becomes a page } return $template; }
function the_content($content) { global $wp_query, $EM_Tag, $post, $em_tag_id; if (!empty($wp_query->em_tag_id) || $post->ID == get_option('dbem_tags_page') && !empty($em_tag_id)) { $EM_Tag = empty($wp_query->em_tag_id) ? em_get_tag($em_tag_id) : em_get_tag($wp_query->em_tag_id); ob_start(); em_locate_template('templates/tag-single.php', true); return ob_get_clean(); } }
public static function the_content($content) { global $wp_query, $EM_Tag, $post, $em_tag_id; $is_tags_page = $post->ID == get_option('dbem_tags_page'); $tag_flag = !empty($wp_query->em_tag_id) || !empty($em_tag_id); if ($is_tags_page && $tag_flag || empty($post->ID) && $tag_flag) { $EM_Tag = empty($wp_query->em_tag_id) ? em_get_tag($em_tag_id) : em_get_tag($wp_query->em_tag_id); ob_start(); em_locate_template('templates/tag-single.php', true); return ob_get_clean(); } return $content; }
/** * Overrides archive pages e.g. locations, events, event tags, event tags based on user settings * @param string $template * @return string */ function template($template) { global $wp_query; if (is_archive()) { if (!empty($wp_query->queried_object->taxonomy) && $wp_query->queried_object->taxonomy == EM_TAXONOMY_TAG && get_option('dbem_cp_tags_formats', true)) { add_filter('the_content', array('EM_Tag_Taxonomy', 'the_content')); $EM_Tag = em_get_tag($wp_query->queried_object->term_id); $wp_query->posts = array(); $wp_query->posts[0] = new stdClass(); $wp_query->posts[0]->post_title = $EM_Tag->output(get_option('dbem_tag_page_title_format')); $wp_query->posts[0]->post_content = ''; $wp_query->post = $wp_query->posts[0]; $wp_query->post_count = 1; $wp_query->found_posts = 1; $wp_query->max_num_pages = 1; $template = locate_template(array('page.php', 'index.php'), false); //category becomes a page } } return $template; }
/** * Is this a a single category page? * @return boolean */ function em_is_tag_page($tag = false) { if (!empty($tag)) { global $wp_query, $post, $em_tag_id; if (is_tax(EM_TAXONOMY_TAG, $tag)) { return true; } if (!empty($wp_query->em_tag_id) || !empty($em_tag_id)) { $tag_id = !empty($wp_query->em_tag_id) ? $wp_query->em_tag_id : $em_tag_id; $EM_Tag = em_get_tag($tag_id); if (is_array($tag)) { $is_tag = array(); foreach ($tag as $id_or_term) { $is_tag[] = is_numeric($id_or_term) ? $EM_Tag->id == $id_or_term : $EM_Tag->slug == $id_or_term || $EM_Tag->name == $id_or_term; } return in_array(true, $is_tag); } else { $is_tag = is_numeric($tag) ? $EM_Tag->id == $tag : $EM_Tag->slug == $tag || $EM_Tag->name == $tag; return $is_tag; } return false; } return false; } return em_get_page_type() == 'tag'; }