Changeset 1108642
- Timestamp:
- 03/09/2015 08:33:32 AM (11 years ago)
- Location:
- vhm-show-comments/trunk
- Files:
-
- 3 added
- 3 edited
-
languages (added)
-
languages/vhm-show-comments-es_ES.mo (added)
-
languages/vhm-show-comments-es_ES.po (added)
-
readme.txt (modified) (2 diffs)
-
settings.php (modified) (2 diffs)
-
vhm-show-comments.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vhm-show-comments/trunk/readme.txt
r1108186 r1108642 4 4 Requires at least: 3.1 5 5 Tested up to: 4.1 6 Stable tag: trunk6 Stable tag: 1.2 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 24 24 1. Activate the plugin 25 25 1. Go to `Settings > VHM Show Comments` for further information 26 27 == Changelog == 28 29 = 1.2 = 30 *Release Date - 8th March 2015* 31 32 * NEW: Added ORDER BY DESCENDANT/ASCENDANT/RANDOM option 33 * NEW: Spanish translation 34 35 = 1.1 = 36 *Release Date - 8th March, 2015* 37 38 * Some visual changes -
vhm-show-comments/trunk/settings.php
r1108217 r1108642 47 47 </tr> 48 48 <tr valign="top"> 49 <th scope="row"><label for=" before_items"><?php _e('Before items', 'vhm-show-comments')?></label></th>49 <th scope="row"><label for="order"><?php _e('Order by', 'vhm-show-comments')?></label></th> 50 50 <td> 51 <input type="text" name="vhmShowCommentsSettings[before_items]" id="show_quantity" value="<?php echo (!empty($options['before_items'])) ? esc_attr($options['before_items']) : '<ol>' ; ?>" /> 51 <select name="vhmShowCommentsSettings[order]"> 52 <option value="DESC"<?php echo ($options['order'] == 'DESC') ? ' selected="selected"' : false ; ?>><?php _e('Descendant', 'vhm-show-comments'); ?></option> 53 <option value="ASC"<?php echo ($options['order'] == 'ASC') ? ' selected="selected"' : false ; ?>><?php _e('Ascendant', 'vhm-show-comments'); ?></option> 54 <option value="RAND"<?php echo ($options['order'] == 'RAND') ? ' selected="selected"' : false ; ?>><?php _e('Random', 'vhm-show-comments'); ?></option> 55 </select> 56 <p class="description"><?php _e('Choose how the comments should be ordered', 'vhm-show-comments'); ?></p> 57 </td> 58 </tr> 59 <tr valign="top"> 60 <th scope="row"><label for="before_items"><?php _e('Before items', 'vhm-show-comments'); ?></label></th> 61 <td> 62 <input type="text" name="vhmShowCommentsSettings[before_items]" id="before_items" value="<?php echo (!empty($options['before_items'])) ? esc_attr($options['before_items']) : '<ol>' ; ?>" /> 52 63 <p class="description"> 53 64 <?php … … 71 82 <p class="description"><?php _e('%URL% is the URL provided by the author of the comment', 'vhm-show-comments'); ?></p> 72 83 <p class="description"><?php _e('%AUTHOR% is the name of the author of the comment', 'vhm-show-comments'); ?></p> 84 <p class="description"><?php _e('%POST_TITLE% is the title of the post where the user left the comment', 'vhm-show-comments'); ?></p> 85 <p class="description"><?php _e('%POST_URL% is the URL of the post where the user left the comment', 'vhm-show-comments'); ?></p> 73 86 </td> 74 87 </tr> -
vhm-show-comments/trunk/vhm-show-comments.php
r1108217 r1108642 4 4 * Plugin URI: http://viktormorales.com 5 5 * Description: Show comments on your pages, posts, sidebar with a shortcode or PHP code 6 * Version: 1. 16 * Version: 1.2 7 7 * Author: Viktor H. Morales 8 8 * Author URI: http://viktormorales.com … … 101 101 $new_input['show_quantity'] = absint( $input['show_quantity'] ); 102 102 103 if( isset( $input['order'] ) ) 104 $new_input['order'] = $input['order']; 105 103 106 if( isset( $input['before_items'] ) ) 104 107 $new_input['before_items'] = $input['before_items']; … … 128 131 public function output( $atts = false ) 129 132 { 133 global $wpdb; 134 130 135 // Get the shortcode/function arguments 131 136 extract( shortcode_atts( array( 132 137 'number' => ($number) ? $number : $this->options['show_quantity'], 133 138 'id' => ($id) ? $id : false, 134 'post_id' => ($post_id) ? $post_id : false 139 'post_id' => ($post_id) ? $post_id : false, 140 'order' => ($oder) ? 'DESC' : $this->options['order'] 135 141 ), $atts ) ); 136 142 … … 138 144 $out = $this->options['before_items']; 139 145 146 $sql = 'SELECT * FROM wp_comments WHERE comment_approved="1"'; 140 147 if ($id) 141 148 { 142 $comment = get_comment($id); 143 $out .= str_replace( 144 array( "%COMMENT%", "%URL%", "%AUTHOR%" ), 145 array( $comment->comment_content, $comment->comment_author_url, $comment->comment_author ), 146 $this->options['items_template'] 147 ); 149 $sql .= ' AND comment_ID = ' . $id; 150 $sql .= ' LIMIT 1'; 148 151 } 149 else 152 else 150 153 { 151 $comments = get_comments('&status=approve&number=' . $number . '&post_id=' . $post_id); 152 if ($comments): 153 foreach ($comments as $comment) 154 { 155 $out .= str_replace( 156 array( "%COMMENT%", "%URL%", "%AUTHOR%" ), 157 array( $comment->comment_content, $comment->comment_author_url, $comment->comment_author ), 158 $this->options['items_template'] 159 ); 160 } 161 endif; 154 if ($post_id) 155 $sql .= ' AND comment_post_ID = ' . $post_id; 156 if ($order == 'ASC' || $order == 'DESC') 157 $sql .= ' ORDER BY comment_ID ' . $order; 158 else 159 $sql .= ' ORDER BY RAND()'; 160 if ($number) 161 $sql .= ' LIMIT ' . $number; 162 162 } 163 164 $comments = $wpdb->get_results( $sql, OBJECT ); 165 if ($comments): 166 foreach ($comments as $comment) 167 { 168 $out .= str_replace( 169 array( "%COMMENT%", "%URL%", "%AUTHOR%", "%POST_URL%", "%POST_TITLE%" ), 170 array( $comment->comment_content, $comment->comment_author_url, $comment->comment_author, get_permalink($comment->comment_post_ID), get_the_title($comment->comment_post_ID) ), 171 $this->options['items_template'] 172 ); 173 } 174 endif; 163 175 164 176 // Print the after_items option
Note: See TracChangeset
for help on using the changeset viewer.