Changeset 555004
- Timestamp:
- 06/08/2012 08:06:46 PM (14 years ago)
- Location:
- reverse-order-comments/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (4 diffs)
-
reverse-order-comments.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
reverse-order-comments/trunk/readme.txt
r554360 r555004 1 1 === Reverse Order Comments === 2 2 Contributors: TimZ 3 Donate link: http://www. zyblog.de/wordpress-plugins/reverse-order-comments/3 Donate link: http://www.kiva.org/invitedby/tim5156 4 4 Tags: guestbook, gästebuch, comments, reverse, order 5 5 Requires at least: 1.5 6 Tested up to: 2.57 Stable tag: 1. 0.36 Tested up to: 3.3.2 7 Stable tag: 1.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 13 13 == Description == 14 14 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 15 A 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). 18 16 19 17 == Installation == 20 18 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 19 1. Install & activate the plugin. 20 1. Edit your theme files and implement the new function as described in the FAQ section. 37 21 38 22 39 23 == Frequently Asked Questions == 40 24 41 = What are the files in theme-examples directory = 25 = How do I implement the plugin function in my templates? = 26 27 Open the template file which should show the comments in a reverse order in your favorite editor. 28 Locate the line 29 30 `<?php comments_template(); ?>` 31 32 and replace it with 33 34 `<?php if(function_exists('ro_comments_template')) ro_comments_template(); else comments_template(); ?>` 35 36 __Note:__ 37 38 The arguments of the function can be different in your template, for example if it is 39 40 `<?php comments_template('', true); ?>` 41 change 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? = 42 45 43 46 ` theme-examples/ 44 47 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 47 50 48 51 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 51 54 ` 55 56 = Will it work with paged comments? = 57 58 Yes, 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. 59 In this case I suggest not to use the plugin in combination with comment-pagination or you should change your navigation labels. 52 60 53 61 = Building a guestbook for the Kubrik theme = … … 89 97 90 98 99 == Changelog == 91 100 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 96 103 97 104 = 1.0.3 = 98 105 99 * 07.0 5.12 maintenance release; change of plugin owner106 * 07.06.12 maintenance release; change of plugin owner 100 107 101 108 = 1.0.2 = 102 109 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 autoupdate110 * 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 104 111 105 112 = 1.0.1 = … … 114 121 == Upgrade Notice == 115 122 123 = 1.1 = 124 Now compatible with WP 3.3.2 125 116 126 = 1.0.3 = 117 127 Maintenance release; upgrade is not required -
reverse-order-comments/trunk/reverse-order-comments.php
r554367 r555004 6 6 Description: Allows to display the comments in reverse order. Latest comment first, oldest last. 7 7 Author: Tim Zylinski 8 Version: 1. 0.38 Version: 1.1 9 9 Author URI: http://www.zyblog.de/ 10 10 */ 11 11 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 12 function ro_comments_template( $file = '/comments.php', $separate_comments = false ) { 13 add_filter('comments_array','ro_change_order'); 14 comments_template( $file, $separate_comments ); 15 } 14 16 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; 17 function ro_change_order($comms) { 18 return array_reverse($comms); 42 19 } 43 20 ?>
Note: See TracChangeset
for help on using the changeset viewer.