/** * 9IPHP <Get all tags> in the theme. * 标签页面 * * @version 1.0 * @package Specs * @copyright 2014 all rights reserved * @reference http://codex.wordpress.org/Function_Reference/get_terms */ function specs_show_tags() { if (!($output = get_option('specs_tags_list'))) { include_once 'inc/zh_to_py.php'; $categories = get_terms('post_tag', array('orderby' => 'count', 'hide_empty' => 1)); $r = array(); foreach ($categories as $v) { for ($i = 65; $i <= 90; $i++) { if (strtoupper(Chinese_to_PY::getPY($v->name, 'one')) == chr($i)) { $r[chr($i)][] = $v; } } for ($i = 48; $i <= 57; $i++) { if (strtoupper(Chinese_to_PY::getPY($v->name, 'one')) == chr($i)) { $r[chr($i)][] = $v; } } } ksort($r); $output = "<ul class='list-inline clearfix text-center' id='tag_letter'>"; for ($i = 65; $i <= 90; $i++) { $tagi = $r[chr($i)]; if (is_array($tagi)) { $output .= "<li class='col-sm-1 col-xs-2'><a href='#" . chr($i) . "'>" . chr($i) . "</a></li>"; } else { $output .= "<li class='col-sm-1 col-xs-2'>" . chr($i) . "</li>"; } } for ($i = 48; $i <= 57; $i++) { $tagi = $r[chr($i)]; if (is_array($tagi)) { $output .= "<li class='col-sm-1 col-xs-2'><a href='#" . chr($i) . "'>" . chr($i) . "</a></li>"; } else { $output .= "<li class='col-sm-1 col-xs-2'>" . chr($i) . "</li>"; } } $output .= "</ul>"; $output .= "<ul id='all_tags' class='list-unstyled'>"; for ($i = 65; $i <= 90; $i++) { $tagi = $r[chr($i)]; if (is_array($tagi)) { $output .= "<li id='" . chr($i) . "'><h4 class='tag_name'>" . chr($i) . "</h4>"; foreach ($tagi as $tag) { $output .= "<a href='" . get_tag_link($tag->term_id) . "'>" . $tag->name . "(" . specs_post_count_by_tag($tag->term_id) . ")</a>"; } } } for ($i = 48; $i <= 57; $i++) { $tagi = $r[chr($i)]; if (is_array($tagi)) { $output .= "<li id='" . chr($i) . "'><h4 class='tag_name'>" . chr($i) . "</h4>"; foreach ($tagi as $tag) { $output .= "<a href='" . get_tag_link($tag->term_id) . "'>" . $tag->name . "(" . specs_post_count_by_tag($tag->term_id) . ")</a>"; } } } $output .= "</ul>"; update_option('specs_tags_list', $output); } echo $output; }
function specs_show_tags() { if (!($output = get_option('specs_tags_list'))) { $categories = get_terms('post_tag', array('orderby' => 'count', 'hide_empty' => 1)); foreach ($categories as $v) { for ($i = 65; $i <= 90; $i++) { if (specs_pinyin($v->name) == chr($i)) { $r[chr($i)][] = $v; } } for ($i = 48; $i <= 57; $i++) { if (specs_pinyin($v->name) == chr($i)) { $r[chr($i)][] = $v; } } } ksort($r); $output = "<ul id='tag-letter'>"; for ($i = 65; $i <= 90; $i++) { $tagi = $r[chr($i)]; if (is_array($tagi)) { $output .= "<li><a href='#" . chr($i) . "'>" . chr($i) . "</a></li>"; } else { $output .= "<li><a class='none' href='javascript:;'>" . chr($i) . "</a></li>"; } } for ($i = 48; $i <= 57; $i++) { $tagi = $r[chr($i)]; if (is_array($tagi)) { $output .= "<li><a href='#" . chr($i) . "'>" . chr($i) . "</a></li>"; } else { $output .= "<li><a class='none' href='javascript:;'>" . chr($i) . "</a></li>"; } } $output .= "</ul>"; $output .= "<ul id='all-tags'>"; for ($i = 65; $i <= 90; $i++) { $tagi = $r[chr($i)]; if (is_array($tagi)) { $output .= "<li id='" . chr($i) . "'><h4 class='tag-name'>" . chr($i) . "</h4><div class='tag-list clearfix'>"; foreach ($tagi as $tag) { $output .= "<a href='" . get_tag_link($tag->term_id) . "'>" . $tag->name . "<span class='number'>" . specs_post_count_by_tag($tag->term_id) . "</span></a>"; } $output .= '</div>'; } } for ($i = 48; $i <= 57; $i++) { $tagi = $r[chr($i)]; if (is_array($tagi)) { $output .= "<li id='" . chr($i) . "'><h4 class='tag-name'>" . chr($i) . "</h4><div class='tag-list clearfix'>"; foreach ($tagi as $tag) { $output .= "<a href='" . get_tag_link($tag->term_id) . "'>" . $tag->name . "<span class='number'>" . specs_post_count_by_tag($tag->term_id) . "</span></a>"; } $output .= '</div>'; } } $output .= "</ul>"; update_option('specs_tags_list', $output); } echo $output; }