Changeset 461508
- Timestamp:
- 11/10/2011 09:27:07 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wp-popular-posts-tool/trunk/wp-popular-posts-tool.php
r395546 r461508 5 5 Description: Enables you to automatically display most commented posts, either by category or tag. Optional: You can choose manually the category or tag you want to display its most commented posts. It has a widget to add it easily to your sidebar. See this plugin in action in http://teofiloisrael.com 6 6 Author: Teofilo Israel Vizcaino Rodriguez 7 Version: 2. 0.17 Version: 2.1 8 8 Author URI: http://teofiloisrael.com 9 9 Demo URI: http://teofiloisrael.com … … 21 21 * Prints the list of popular posts 22 22 */ 23 function ti_popular_posts($num, $my_id=0, $begin='<ul>', $end='</ul>', $pre='<li>', $suf='</li>' ){23 function ti_popular_posts($num, $my_id=0, $begin='<ul>', $end='</ul>', $pre='<li>', $suf='</li>', $mode=0){ 24 24 global $wpdb; 25 25 if($my_id==0): … … 39 39 40 40 $myposts = $wpdb->get_results($querystr, OBJECT); 41 echo $begin; 41 42 if($mode==0) echo $begin; 43 $postCount = 0; 44 $maxPostComments = 0; 45 $colors = array('red', 'orange', 'yellow', 'green', 'blue'); 42 46 foreach($myposts as $post) { 43 echo $pre; 44 ?><a href="<?php echo get_permalink($post->ID); ?>"><?php echo $post->post_title ?></a><?php 45 echo '<br />' . $post->comment_count . ' '; _e('comments'); 46 echo $suf; 47 } echo '<li><small style="color:#666666; font-size:9px;"><a style="color:#666666; font-size:9px;" href="http://teofiloisrael.com/plugin-popular-posts-tool/">Popular posts Tool</a> for Wordpress by <a style="color:#666666; font-size:9px;" href="http://teofiloisrael.com/">Teofilo Israel</a></small></li>'; 47 if($mode==0) echo $pre; 48 switch($mode){ 49 case 0://Normal mode, with comment count 50 default: 51 ?><a href="<?php echo get_permalink($post->ID); ?>"><?php echo $post->post_title ?></a><?php 52 echo '<br />' . $post->comment_count . ' '; _e('comments'); 53 break; 54 case 1://Graphical mode 55 if($postCount==0) $maxPostComments = $post->comment_count; 56 $width = $post->comment_count / $maxPostComments * 100 / 2; 57 ?><table> 58 <tr style="height:40px"> 59 <td style="width:<?php echo ($post->comment_count / $maxPostComments * 100); ?>px; 60 background-color:<?php if($postCount < 5){echo $colors[$postCount];}else{echo 'blue';}; ?>"></td> 61 <td style="width:<?php echo 200 - $width;?>px;padding-left:6px"> 62 <a href="<?php echo get_permalink($post->ID); ?>"> 63 <?php echo $post->post_title ?> 64 </a><?php echo $post->comment_count . ' '; _e('comments');?> 65 </td><?php 66 ?> 67 </tr> 68 </table> 69 <?php 70 $postCount++; 71 break; 72 } 73 if($mode==0) echo $suf; 74 } //echo '<li><small style="color:#666666; font-size:9px;"><a style="color:#666666; font-size:9px;" href="http://teofiloisrael.com/plugin-popular-posts-tool/">Popular posts Tool</a> for Wordpress by <a style="color:#666666; font-size:9px;" href="http://teofiloisrael.com/">Teofilo Israel</a></small></li>'; 48 75 echo $end; 49 76 } … … 100 127 ?> 101 128 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php echo esc_html__('Title'); ?>: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p> 102 <p><label for="<?php echo $this->get_field_id('itemsQuantity'); ?>"><?php echo esc_html__('Number of items to show :'); ?>: <input class="widefat" id="<?php echo $this->get_field_id('itemsQuantity'); ?>" name="<?php echo $this->get_field_name('itemsQuantity'); ?>" type="text" value="<?php echo attribute_escape($itemsQuantity); ?>" /></label></p>103 <p><label for="<?php echo $this->get_field_id('catId'); ?>"><?php echo esc_html__('Id of the cateogory or tag (leave it blank for automatic detection) :'); ?>: <input class="widefat" id="<?php echo $this->get_field_id('catId'); ?>" name="<?php echo $this->get_field_name('catId'); ?>" type="text" value="<?php echo attribute_escape($catId); ?>" /></label></p><?php129 <p><label for="<?php echo $this->get_field_id('itemsQuantity'); ?>"><?php echo esc_html__('Number of items to show'); ?>: <input class="widefat" id="<?php echo $this->get_field_id('itemsQuantity'); ?>" name="<?php echo $this->get_field_name('itemsQuantity'); ?>" type="text" value="<?php echo attribute_escape($itemsQuantity); ?>" /></label></p> 130 <p><label for="<?php echo $this->get_field_id('catId'); ?>"><?php echo esc_html__('Id of the cateogory or tag (leave it blank for automatic detection)'); ?>: <input class="widefat" id="<?php echo $this->get_field_id('catId'); ?>" name="<?php echo $this->get_field_name('catId'); ?>" type="text" value="<?php echo attribute_escape($catId); ?>" /></label></p><?php 104 131 } 105 132 } … … 108 135 * Use this function if you want to use the plugin directly from the code 109 136 */ 110 function ti_popular_posts($num, $my_id=0, $begin='<ul>', $end='</ul>', $pre='<li>', $suf='</li>' ){111 WpPopularPostsTool::ti_popular_posts($num, $my_id, $begin, $end, $pre, $suf );137 function ti_popular_posts($num, $my_id=0, $begin='<ul>', $end='</ul>', $pre='<li>', $suf='</li>', $mode=0){ 138 WpPopularPostsTool::ti_popular_posts($num, $my_id, $begin, $end, $pre, $suf, $mode); 112 139 } 113 140
Note: See TracChangeset
for help on using the changeset viewer.