Exemplo n.º 1
0
 * Template name: Tags index
 */
get_header();
?>
<div class="g">
	<div class="content-reset">
		<?php 
the_content();
?>
	</div>
	<div class="tags-index">
		<?php 
if (!class_exists('theme_page_tags')) {
    ?>
			<div class="page-tip"><?php 
    echo status_tip('error', ___('Missing initialization files.'));
    ?>
</div>
		<?php 
} else {
    ?>
			<?php 
    theme_page_tags::display_frontend();
    ?>
		<?php 
}
?>
	</div>
</div><!-- /.container -->
<?php 
get_footer();
    function widget($args = [], $instance = [])
    {
        $instance = array_merge(['title' => '', 'number' => 20, 'sticky' => []], $instance);
        echo $args['before_widget'];
        if (!empty($instance['title'])) {
            echo $args['before_title'];
            /**
             * if have theme page tags, mark as more
             */
            if (class_exists('theme_page_tags') && theme_page_tags::get_url()) {
                ?>
<a title="<?php 
                echo ___('Views tags index');
                ?>
" href="<?php 
                echo theme_page_tags::get_url();
                ?>
">
			<?php 
            }
            ?>
			<i class="fa fa-tags"></i> <?php 
            echo $instance['title'];
            ?>
			<?php 
            if (class_exists('theme_page_tags') && theme_page_tags::get_url()) {
                ?>
 &raquo;</a><?php 
            }
            ?>
			
			<?php 
            echo $args['after_title'];
        }
        ?>
		<div class="widget-content">
		<?php 
        self::frontend_display($args, $instance);
        ?>
		</div>
		<?php 
        echo $args['after_widget'];
    }
Exemplo n.º 3
0
 public static function get_tags($posts)
 {
     if (!$posts) {
         return false;
     }
     foreach ($posts as $post) {
         $tags = get_the_tags($post->ID);
         if (!$tags) {
             continue;
         }
         foreach ($tags as $tag) {
             self::save_tags($tag->term_id, $tag->name, $post->ID);
         }
     }
     unset($posts);
     $new_tags = [];
     foreach (self::$tags as $tag_id => $tag) {
         $initial = self::get_tag_name_pinyin(['term_id' => $tag_id, 'name' => $tag['name']]);
         if (!$new_tags[$initial]) {
             $new_tags[$initial] = [$tag_id => self::$tags[$tag_id]];
         } else {
             $new_tags[$initial][$tag_id] = self::$tags[$tag_id];
         }
     }
     ksort($new_tags);
     self::$tags = null;
     return $new_tags;
 }