示例#1
0
    function widget($args, $instance)
    {
        extract($args);
        $orderby = empty($instance['orderby']) ? 'name' : $instance['orderby'];
        $postcount = isset($instance['postcount']) ? $instance['postcount'] : false;
        $showcategories = isset($instance['showcategories']) ? $instance['showcategories'] : false;
        $showtags = isset($instance['showtags']) ? $instance['showtags'] : false;
        $showarchives = isset($instance['showarchives']) ? $instance['showarchives'] : false;
        $showpopular = isset($instance['showpopular']) ? $instance['showpopular'] : false;
        $showrecentcomm = isset($instance['showrecentcomm']) ? $instance['showrecentcomm'] : false;
        $popularpostnumber = empty($instance['popularpostnumber']) ? '10' : $instance['popularpostnumber'];
        $commentnumber = empty($instance['commentnumber']) ? '8' : $instance['commentnumber'];
        $id = $args['widget_id'];
        $jquery = get_mystique_option('jquery');
        echo $before_widget;
        ?>
      <?php 
        if ($jquery) {
            // no tab navigation if jquery is disabled
            ?>
      <!-- tabbed content -->
      <div class="tabbed-content sidebar-tabs clear-block" id="<?php 
            echo $id;
            ?>
">

       <!-- tab navigation (items must be in reverse order because of the tab-design) -->
       <ul class="box-tabs clear-block">
          <?php 
            if ($showrecentcomm && WP_VERSION > 2.8) {
                ?>
<li class="recentcomm"><a href="#<?php 
                echo $id;
                ?>
-section-recentcomments" title="<?php 
                _e('Recent comments', 'mystique');
                ?>
"><span><?php 
                _e('Recent comments', 'mystique');
                ?>
</span></a></li><?php 
            }
            ?>
          <?php 
            if ($showpopular) {
                ?>
<li class="popular"><a href="#<?php 
                echo $id;
                ?>
-section-popular" title="<?php 
                _e('Popular posts', 'mystique');
                ?>
"><span><?php 
                _e('Popular posts', 'mystique');
                ?>
</span></a></li><?php 
            }
            ?>
          <?php 
            if ($showarchives) {
                ?>
<li class="archives"><a href="#<?php 
                echo $id;
                ?>
-section-archives" title="<?php 
                _e('Archives', 'mystique');
                ?>
"><span><?php 
                _e('Archives', 'mystique');
                ?>
</span></a></li><?php 
            }
            ?>
          <?php 
            if ($showtags) {
                ?>
<li class="tags"><a href="#<?php 
                echo $id;
                ?>
-section-tags" title="<?php 
                _e('Tags', 'mystique');
                ?>
"><span><?php 
                _e('Tags', 'mystique');
                ?>
</span></a></li><?php 
            }
            ?>
          <?php 
            if ($showcategories) {
                ?>
<li class="categories"><a href="#<?php 
                echo $id;
                ?>
-section-categories" title="<?php 
                _e('Categories', 'mystique');
                ?>
"><span><?php 
                _e('Categories', 'mystique');
                ?>
</span></a></li><?php 
            }
            ?>
       </ul>
       <!-- /tab nav -->

       <!-- tab sections -->
       <div class="sections">

        <?php 
            if ($showcategories) {
                ?>
        <!-- comments -->

         <div class="box section" id="<?php 
                echo $id;
                ?>
-section-categories">
          <div class="box-top-left"><div class="box-top-right"></div></div>
          <div class="box-main">
           <div class="box-content">
            <ul class="menuList categories">
             <?php 
                if ($postcount) {
                    echo preg_replace('@\\<li([^>]*)>\\<a([^>]*)>(.*?)\\<\\/a> \\(\\<a ([^>]*)([^>]*)>XML\\<\\/a>\\) \\((.*?)\\)@i', '<li $1><a$2 class="fadeThis"><span class="entry">$3 <span class="details inline">($6)</span></span></a><a class="rss bubble" $4></a>', wp_list_categories('orderby=' . $orderby . '&show_count=1&echo=0&title_li=&feed=XML'));
                } else {
                    echo preg_replace('@\\<li([^>]*)>\\<a([^>]*)>(.*?)\\<\\/a> \\(\\<a ([^>]*) ([^>]*)>(.*?)\\<\\/a>\\)@i', '<li $1><a$2 class="fadeThis"><span class="entry">$3</span></a><a class="rss bubble" $4></a>', wp_list_categories('orderby=' . $orderby . '&show_count=0&echo=0&title_li=&feed=XML'));
                }
                ?>
            </ul>
           </div>
          </div>
         </div>

        <?php 
            }
            ?>

        <?php 
            if ($showtags) {
                ?>

         <div class="box section" id="<?php 
                echo $id;
                ?>
-section-tags">
          <div class="box-top-left"><div class="box-top-right"></div></div>
          <div class="box-main">
           <div class="box-content">
            <div class="tag-cloud">
             <?php 
                wp_tag_cloud(apply_filters('widget_tag_cloud_args', array()));
                ?>
            </div>
           </div>
          </div>
         </div>

       <?php 
            }
            ?>

        <?php 
            if ($showarchives) {
                ?>

         <div class="box section" id="<?php 
                echo $id;
                ?>
-section-archives">
          <div class="box-top-left"><div class="box-top-right"></div></div>
          <div class="box-main">
           <div class="box-content">
            <ul class="menuList">
      	     <?php 
                //wp_get_archives(apply_filters('widget_archives_args', array('type' => 'monthly', 'show_post_count' => $postcount)));
                if ($postcount) {
                    echo preg_replace('@\\<li>\\<a([^>]*)>(.*?)\\<\\/a>([^>]*)\\((.*?)\\)@i', '<li><a$1 class="fadeThis"><span class="entry">$2 <span class="details inline">($4)</span></span></a>', wp_get_archives(apply_filters('widget_archives_args', array('type' => 'monthly', 'show_post_count' => $postcount, 'echo' => 0))));
                } else {
                    echo preg_replace('@\\<li>\\<a([^>]*)>(.*?)\\<\\/a>@i', '<li><a$1 class="fadeThis"><span class="entry">$2</span></a>', wp_get_archives(apply_filters('widget_archives_args', array('type' => 'monthly', 'show_post_count' => $postcount, 'echo' => 0))));
                }
                ?>
            </ul>
           </div>
          </div>
         </div>

       <?php 
            }
            ?>

        <?php 
            if ($showpopular) {
                ?>

         <div class="box section" id="<?php 
                echo $id;
                ?>
-section-popular">
          <div class="box-top-left"><div class="box-top-right"></div></div>
          <div class="box-main">
           <div class="box-content">
            <?php 
                $popular = new WP_Query('orderby=comment_count&caller_get_posts=1&posts_per_page=' . $popularpostnumber);
                if ($popular->have_posts()) {
                    ?>
              <ul class="menuList"><?php 
                    while ($popular->have_posts()) {
                        $popular->the_post();
                        ?>
               <li><a class="fadeThis" href="<?php 
                        the_permalink();
                        ?>
" rel="bookmark" title="<?php 
                        the_title_attribute();
                        ?>
"><span class="entry"><?php 
                        the_title();
                        ?>
 <span class="details inline">(<?php 
                        comments_number('0', '1', '%');
                        ?>
)</span></span></a></li><?php 
                    }
                    ?>
              </ul> <?php 
                } else {
                    _e("Didn't find any posts popular enough :(", "mystique");
                }
                wp_reset_query();
                ?>
           </div>
          </div>
         </div>

       <?php 
            }
            ?>

       <?php 
            if ($showrecentcomm && WP_VERSION > 2.8) {
                ?>

         <div class="box section" id="<?php 
                echo $id;
                ?>
-section-recentcomments">
          <div class="box-top-left"><div class="box-top-right"></div></div>
          <div class="box-main">
           <div class="box-content">

            <ul class="menuList recentcomm">
            <?php 
                $comments = get_comments('number=' . $commentnumber . '&status=approve');
                //$true_comment_count = 0;
                foreach ($comments as $comment) {
                    $comment_type = get_comment_type();
                    //if($comment_type == 'comment'):
                    //$true_comment_count = $true_comment_count+1;
                    //$comm_title = get_the_title($comment->comment_post_ID);
                    $comm_content = get_comment($comment->comment_ID, ARRAY_A);
                    ?>
                <li class="clear-block"><a title="<?php 
                    printf(__("Posted in: %s", "mystique"), get_the_title($comment->comment_post_ID));
                    ?>
" class="fadeThis" href="<?php 
                    echo get_comment_link($comment->comment_ID);
                    ?>
"><span class="avatar"><?php 
                    echo mystique_get_avatar($comment->comment_author_email, 32);
                    ?>
</span><span class="entry"><?php 
                    echo $comment->comment_author;
                    ?>
: <span class="details"> <?php 
                    echo mystique_strip_string(100, $comm_content['comment_content']);
                    ?>
</span></span></a></li>
               <?php 
                    //endif;
                    //if($true_comment_count == $commentnumber) break;
                }
                ?>
            </ul>

           </div>
          </div>
         </div>

       <?php 
            }
            ?>

       </div>
      </div>
      <!-- tabbed content -->
      <?php 
        } else {
            echo $before_title . __("Sidebar tabs", "mystique") . $after_title;
            ?>
      <p class="error"><?php 
            _e("jQuery is disabled and this widget needs it", "mystique");
            ?>
</p>
      <?php 
        }
        ?>

      <?php 
        echo $after_widget;
    }
示例#2
0
function mystique_featured_post()
{
    if (mystique_featured_post_target_page()) {
        //global $valid_featured_posts;
        global $wp_query;
        $featured_posts = get_mystique_option('featured_posts');
        $found_posts = array();
        $featured_posts = explode(',', $featured_posts);
        shuffle($featured_posts);
        // randomize
        foreach ($featured_posts as $featured_post) {
            $current_post = get_post($featured_post);
            $current_post = (array) $current_post;
            if ($current_post) {
                // take it in consideration only if is a recent post
                if (strtotime($current_post['post_date_gmt']) > strtotime('-' . get_mystique_option('featured_timeframe') . ' days')) {
                    $found_posts[] = $current_post;
                }
            }
        }
        // remove posts from the main loop (on homepage)?
        // $wp_query->query_vars['post__not_in'] = $found_posts;
        $count = (int) get_mystique_option('featured_count');
        ?>

<div id="featured-content"<?php 
        if ($count > 1 && count($found_posts) > 1) {
            ?>
 class="withSlider"<?php 
        }
        ?>
>
 <?php 
        if ($found_posts) {
            // only show if the global variable is set in the function above
            ?>
 <!-- block container -->
 <div class="slide-container">
  <ul class="slides">
       <?php 
            $number = 1;
            foreach ($found_posts as $featured_post) {
                ?>
         <!-- slide (100%) -->
         <li class="slide slide-<?php 
                echo $number;
                ?>
 featured-content">
          <div class="slide-content clearfix">
            <div class="details clearfix">
             <?php 
                mystique_post_thumb('featured-thumbnail', $featured_post['ID']);
                echo '<h2><a href="' . get_permalink($featured_post['ID']) . '">' . mystique_strip_string(70, strip_tags($featured_post['post_title'])) . '</a></h2>';
                echo '<div class="summary">' . mystique_strip_string(420, strip_tags(strip_shortcodes($featured_post['post_content']))) . '</div>';
                ?>
            </div>
          <a class="readmore" href="<?php 
                echo get_permalink($featured_post['ID']);
                ?>
"><?php 
                _e("More", "mystique");
                ?>
</a>
          </div>
         </li>
         <!-- /slide -->
         <?php 
                if ($count == $number) {
                    break;
                }
                $number++;
            }
            ?>
  </ul>
 </div>
 <!-- /block container -->
 <?php 
        } else {
            if (current_user_can('switch_themes')) {
                echo '<h4>' . sprintf(__("No featured posts found older than %s days.", "mystique"), get_mystique_option('featured_timeframe')) . '</h4>';
            }
        }
        ?>
</div>

   <?php 
    }
}