WordPress.org

Plugin Directory

Changeset 555004


Ignore:
Timestamp:
06/08/12 20:06:46 (23 months ago)
Author:
TimZ
Message:

now using a filter hook

Location:
reverse-order-comments/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • reverse-order-comments/trunk/readme.txt

    r554360 r555004  
    11=== Reverse Order Comments === 
    22Contributors: TimZ 
    3 Donate link: http://www.zyblog.de/wordpress-plugins/reverse-order-comments/ 
     3Donate link: http://www.kiva.org/invitedby/tim5156 
    44Tags: guestbook, gästebuch, comments, reverse, order 
    55Requires at least: 1.5 
    6 Tested up to: 2.5 
    7 Stable tag: 1.0.3 
     6Tested up to: 3.3.2 
     7Stable tag: 1.1 
    88License: GPLv2 or later 
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    1313== Description == 
    1414 
    15 A really simple Wordpress Plugin. It provides the function `ro_comments_template()`, which allows the comments to be 
    16 displayed in reverse order (thus the newest comments first, oldest last). 
    17  
     15A really simple WordPress Plugin. It provides the function `ro_comments_template()`, which allows the comments to be displayed in reverse order (thus the newest comments first, oldest last). 
    1816 
    1917== Installation == 
    2018 
    21 Just unpack the archive contents into the WordPress directory. Then activate the Plugin in the Plugin Manger. 
    22 The files in the `theme-examples` directory are examples for the integration into your themes. 
    23 You do not need to upload this subdirectory to your blog. 
    24  
    25 *OR* 
    26  
    27 To use the new function you need to implement it in your templates. 
    28  
    29 If you want your comments to be displayed in reverse order in every post, you need to replace in file "single.php" the line 
    30  
    31 `<?php comments_template(); ?>` 
    32  
    33 with 
    34  
    35 `<?php if(function_exists('ro_comments_template')) ro_comments_template(); else comments_template(); ?>` 
    36  
     191. Install & activate the plugin. 
     201. Edit your theme files and implement the new function as described in the FAQ section. 
    3721 
    3822 
    3923== Frequently Asked Questions == 
    4024 
    41 = What are the files in theme-examples directory = 
     25= How do I implement the plugin function in my templates? = 
     26 
     27Open the template file which should show the comments in a reverse order in your favorite editor. 
     28Locate the line 
     29 
     30`<?php comments_template(); ?>` 
     31 
     32and replace it with 
     33 
     34`<?php if(function_exists('ro_comments_template')) ro_comments_template(); else comments_template(); ?>` 
     35 
     36__Note:__  
     37 
     38The arguments of the function can be different in your template, for example if it is  
     39 
     40`<?php comments_template('', true); ?>` 
     41change the plugin function accordingly to  
     42`<?php if(function_exists('ro_comments_template')) ro_comments_template('', true); else comments_template('', true); ?>` 
     43 
     44= What are the files in theme-examples directory? = 
    4245 
    4346`  theme-examples/ 
    4447    default                      (English default theme) 
    45       comments-topinput.php      comments.php adapted for a guestbook (engl) 
    46       tpl_guestbook.php          template for a guestbook (engl) 
     48      comments-topinput.php      comments.php adapted for a guestbook 
     49      tpl_guestbook.php          template for a guestbook 
    4750 
    4851    default_de                   (German default theme) 
    49       comments-topinput.php      comments.php adapted for a guestbook (engl) 
    50       tpl_gaestebuch.php         template for a guestbook (engl) 
     52      comments-topinput.php      comments.php adapted for a guestbook 
     53      tpl_gaestebuch.php         template for a guestbook 
    5154` 
     55 
     56= Will it work with paged comments? = 
     57 
     58Yes, but if you use comment navigations with labels like "older" and "newer", then it might be puzzling for the user, as the comment order is opposite to the navigation. 
     59In this case I suggest not to use the plugin in combination with comment-pagination or you should change your navigation labels. 
    5260 
    5361= Building a guestbook for the Kubrik theme = 
     
    8997 
    9098 
     99== Changelog == 
    91100 
    92  
    93  
    94  
    95 == Changelog == 
     101= 1.1 = 
     102* 08.06.12 Updated to work with WP 3.3.2; Now using filers, making it compatible, faster and future proof 
    96103 
    97104= 1.0.3 = 
    98105 
    99 * 07.05.12 maintenance release; change of plugin owner 
     106* 07.06.12 maintenance release; change of plugin owner 
    100107 
    101108= 1.0.2 = 
    102109 
    103 * 18.05.08 release on the wordpress plugin directory; renamed the plugin to reverse-order-comments; changed the directory structure to enable wordpress plugin autoupdate 
     110* 18.05.08 release on the WordPress plugin directory; renamed the plugin to reverse-order-comments; changed the directory structure to enable the WordPress plugin autoupdate 
    104111 
    105112= 1.0.1 = 
     
    114121== Upgrade Notice == 
    115122 
     123= 1.1 = 
     124Now compatible with WP 3.3.2  
     125 
    116126= 1.0.3 = 
    117127Maintenance release; upgrade is not required 
  • reverse-order-comments/trunk/reverse-order-comments.php

    r554367 r555004  
    66 Description: Allows to display the comments in reverse order. Latest comment first, oldest last. 
    77 Author: Tim Zylinski 
    8  Version: 1.0.3 
     8 Version: 1.1 
    99 Author URI: http://www.zyblog.de/ 
    1010 */ 
    1111 
    12 // This is a copy of the comments_template() function from wp-includes/comment-functions.php with very little changes. 
    13 // Just added the DESC parameter to the SQL queries 
     12function ro_comments_template( $file = '/comments.php', $separate_comments = false ) { 
     13    add_filter('comments_array','ro_change_order'); 
     14    comments_template( $file, $separate_comments ); 
     15} 
    1416 
    15 function ro_comments_template($file = '/comments.php') { 
    16     global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity; 
    17  
    18     if (is_single() || is_page() || $withcomments) 
    19     : $req = get_settings('require_name_email'); 
    20     $comment_author = isset ($_COOKIE['comment_author_' . COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_' . COOKIEHASH])) : ''; 
    21     $comment_author_email = isset ($_COOKIE['comment_author_email_' . COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_email_' . COOKIEHASH])) : ''; 
    22     $comment_author_url = isset ($_COOKIE['comment_author_url_' . COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_url_' . COOKIEHASH])) : ''; 
    23  
    24     if (empty ($comment_author)) { 
    25         $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' ORDER BY comment_date DESC"); 
    26     } else { 
    27         $author_db = addslashes($comment_author); 
    28         $email_db = addslashes($comment_author_email); 
    29         $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND ( comment_approved = '1' OR ( comment_author = '$author_db' AND comment_author_email = '$email_db' AND comment_approved = '0' ) ) ORDER BY comment_date DESC"); 
    30     } 
    31  
    32     get_currentuserinfo(); 
    33  
    34     define('RO_COMMENTS_TEMPLATE', true); 
    35     $include = apply_filters('comments_template', TEMPLATEPATH . $file); 
    36  
    37     if (file_exists($include)) 
    38         require ($include); 
    39     else 
    40         require (ABSPATH . 'wp-content/themes/default/comments.php'); 
    41     endif; 
     17function ro_change_order($comms) { 
     18    return array_reverse($comms); 
    4219} 
    4320?> 
Note: See TracChangeset for help on using the changeset viewer.