diff --git a/css/bbpress-threaded-replies.css b/css/bbpress-threaded-replies.css
index 7990f7a..3e0bda6 100644
--- a/css/bbpress-threaded-replies.css
+++ b/css/bbpress-threaded-replies.css
@@ -1,32 +1,46 @@
/* Modifications for threading; tested under bbp-theme-compat and bbp-twentyten. */
-#content .replylist {
+#bbpress-forums div.reply.even div.even,
+#bbpress-forums div.reply.even ul.even,
+#bbpress-forums div.reply.even div.odd,
+#bbpress-forums div.reply.even ul.odd {
+ background-color: #fff;
+}
+
+#bbpress-forums div.reply.odd div.odd,
+#bbpress-forums div.reply.odd ul.odd,
+#bbpress-forums div.reply.odd div.even,
+#bbpress-forums div.reply.odd ul.even {
+ background-color: #fbfbfb;
+}
+
+#bbpress-forums .replylist {
list-style: none;
margin: 0;
}
-#content .replylist table,
-#content .replylist tbody,
-#content .replylist tr,
-#content .replylist td {
+#bbpress-forums .replylist table,
+#bbpress-forums .replylist tbody,
+#bbpress-forums .replylist tr,
+#bbpress-forums .replylist td {
border-collapse: collapse;
}
-#content .replylist ul.children {
+#bbpress-forums .replylist ul.children {
list-style: none;
margin: 0 0 0 2.0em ;
}
-#content .replylist li,
-#content .replylist li div.reply {
+#bbpress-forums .replylist li,
+#bbpress-forums .replylist li div.reply {
padding-bottom: 0;
}
-#content table.bbp-replies,
-#content .replylist table.bbp-replies {
+#bbpress-forums table.bbp-replies,
+#bbpress-forums .replylist table.bbp-replies {
margin: -1px 0 0 0;
}
-#content .replylist .ucc-bbp-in-reply-to {
+#bbpress-forums .replylist .ucc-bbp-in-reply-to {
padding: 0 1.625em 1.625em 1.625em;
border-top: 0px;
text-align: right;
}
-#content .replylist .bbp-reply-form {
+#bbpress-forums .replylist .bbp-reply-form {
margin-bottom: 0;
-moz-border-radius: 0px;
border-radius: 0px;
@@ -34,7 +48,7 @@
width: auto;
position: relative;
}
-#content .replylist #cancel-in-reply-to-link {
+#bbpress-forums .replylist #cancel-in-reply-to-link {
position: absolute;
right: 1.625em;
top: 0.7em;
@@ -47,8 +61,8 @@
color: #fff;
text-transform: uppercase;
}
-#content fieldset.bbp-form,
-#container fieldset.bbp-form,
+#bbpress-forums fieldset.bbp-form,
+#container fieldset.bbp-form,
#wrapper fieldset.bbp-form {
border-color: #ddd;
}
diff --git a/includes/bbpress-threaded-replies.php b/includes/bbpress-threaded-replies.php
index 1eb9b1e..b195896 100644
--- a/includes/bbpress-threaded-replies.php
+++ b/includes/bbpress-threaded-replies.php
@@ -16,7 +16,7 @@ public function __construct() {
} // __construct
public function init() {
- // Input handling (metabox, reply input form).
+ // Input handling (metabox, reply input form)
if ( is_admin() ) {
add_action( 'bbp_reply_metabox', array( $this, 'extend_reply_metabox' ), 10, 1 );
add_action( 'bbp_reply_attributes_metabox_save', array( $this, 'extend_reply_attributes_metabox_save' ), 10, 3 );
@@ -25,17 +25,18 @@ public function init() {
add_action( 'bbp_theme_before_reply_form', array( $this, 'add_cancel_link' ) );
}
- // bbPress action/filter hooks.
+ // bbPress action/filter hooks
add_filter( 'bbp_has_replies', array( $this, 'has_replies' ), 10, 2 );
add_filter( 'bbp_new_reply_pre_set_terms', array( $this, 'save_post' ), 10, 3 );
add_filter( 'bbp_get_reply_url', array( $this, 'reply_url' ), 15, 3 );
add_filter( 'bbp_get_replies_per_page', array( $this, 'replies_per_page' ), 10, 2 );
add_filter( 'bbp_replies_pagination', array( $this, 'replies_pagination' ) );
add_filter( 'bbp_get_topic_pagination', array( $this, 'get_topic_pagination' ), 10, 2 );
+ add_filter( 'bbp_get_topic_pagination_count', array( $this, 'get_topic_pagination_count' ) );
add_action( 'bbp_merge_topic', array( $this, 'merge_topic' ), 10, 2 );
- add_action( 'bbp_pre_split_topic', array( $this, 'split_topic' ), 10, 3 );
+ add_action( 'bbp_pre_split_topic', array( $this, 'split_topic' ), 10, 3 );
- // Caching interactions.
+ // Caching interactions
add_action( 'bbp_new_reply_pre_extras', array( $this, 'clean_cache' ) );
add_action( 'bbp_edit_reply_pre_extras', array( $this, 'clean_cache' ) );
add_action( 'bbp_spam_reply', array( $this, 'clean_cache' ) );
@@ -56,7 +57,7 @@ public function init() {
add_action( 'bbp_untrashed_topic', array( $this, 'clean_cache' ) );
} // init
- // Admin-side edit functionality and input handling.
+ // Admin-side edit functionality and input handling
public function extend_reply_metabox( $reply_id ) {
$value = absint( get_post_meta( $reply_id, '_ucc_btr_in_reply_to', true ) );
?>
@@ -73,7 +74,7 @@ public function extend_reply_metabox( $reply_id ) {
public function extend_reply_attributes_metabox_save( $reply_id, $topic_id, $forum_id ) {
$in_reply_to = !empty( $_REQUEST['inreplyto'] ) ? (int) $_REQUEST['inreplyto'] : 0;
- // Trust but verify.
+ // Trust but verify
if ( !isset( $_REQUEST['inreplyto_nonce'] ) )
return;
if ( !check_admin_referer( 'inreplyto_metabox', 'inreplyto_nonce' ) )
@@ -82,15 +83,15 @@ public function extend_reply_attributes_metabox_save( $reply_id, $topic_id, $for
update_post_meta( $reply_id, '_ucc_btr_in_reply_to', $in_reply_to );
} // extend_reply_attributes_metabox_save
- // Add hidden replyto form field and nonce to reply form.
+ // Add hidden replyto form field and nonce to reply form
public function add_form_field() {
if ( bbp_is_reply_edit() )
return;
- // We have to set this for non-JS replies.
+ // We have to set this for non-JS replies
$in_reply_to = !empty( $_REQUEST['inreplyto'] ) ? (int) $_REQUEST['inreplyto'] : 0;
- // Trust but verify.
+ // Trust but verify
if ( !isset( $_REQUEST['inreplyto_nonce'] ) ) {
$in_reply_to = 0;
} else {
@@ -102,7 +103,7 @@ public function add_form_field() {
echo "\t\t\t\t\t\t\n";
} // add_form_field
- // Add cancel link to reply form.
+ // Add cancel link to reply form
public function add_cancel_link() {
if ( bbp_is_reply_edit() )
return;
@@ -110,22 +111,22 @@ public function add_cancel_link() {
echo "
" . ucc_btr_get_cancel_in_reply_to_link( 'Cancel reply' ) . "
";
} // add_cancel_link
- // Set up replies for threading on bbPress has_replies().
+ // Set up replies for threading on bbPress has_replies()
public function has_replies( $have_posts, $reply_query ) {
global $bbp, $wp_rewrite, $overridden_rpage;
if ( is_object( $bbp ) ) {
- // bbPress version < 2.1 or already initialized.
+ // bbPress version < 2.1 or already initialized
} elseif ( function_exists( 'bbpress' ) ) {
$bbp = bbpress();
}
- // Heavy lifting for future calls.
+ // Heavy lifting for future calls
$posts = $reply_query->posts;
$replies = array();
if ( !empty( $posts ) ) {
foreach( $posts as &$post ) {
- // Ignore the topic if included.
+ // Ignore the topic if included
if ( bbp_get_reply_post_type() == $post->post_type ) {
$in_reply_to = get_post_meta( $post->ID, '_ucc_btr_in_reply_to', true );
if ( empty( $in_reply_to ) || ( bbp_get_reply_topic_id( $post->ID ) == $in_reply_to ) )
@@ -140,7 +141,7 @@ public function has_replies( $have_posts, $reply_query ) {
$bbp->reply_query->posts = $posts;
$bbp->replies = $replies;
- // Set up based on options.
+ // Set up based on options
$options = get_option( '_ucc_btr_options' );
$roots = ucc_btr_get_root_element_count( $bbp->current_topic_id );
if ( $options['page_replies'] ) {
@@ -157,7 +158,7 @@ public function has_replies( $have_posts, $reply_query ) {
$bbp->reply_query->posts_per_page = $replies_per_page;
$bbp->reply_query->max_num_pages = $max_num_pages;
- // Deal with reply pagination here.
+ // Deal with reply pagination here
$topic_id = bbp_get_topic_id();
if ( $wp_rewrite->using_permalinks() )
$base = trailingslashit( get_permalink( $topic_id ) ) . user_trailingslashit( $wp_rewrite->pagination_base . '/%#%/' );
@@ -179,11 +180,11 @@ public function has_replies( $have_posts, $reply_query ) {
return $have_posts;
} // has_replies
- // Add post_meta for in_reply_to on save.
+ // Add post_meta for in_reply_to on save
public function save_post( $terms, $topic_id, $reply_id ) {
$in_reply_to = !empty( $_REQUEST['inreplyto'] ) ? (int) $_REQUEST['inreplyto'] : 0;
- // Trust but verify.
+ // Trust but verify
if ( !isset( $_REQUEST['inreplyto_nonce'] ) )
return;
if ( !wp_verify_nonce( $_REQUEST['inreplyto_nonce'], 'inreplyto-nonce' ) )
@@ -194,7 +195,7 @@ public function save_post( $terms, $topic_id, $reply_id ) {
return $terms;
} // save_post
- // Reply URL for non-JS users.
+ // Reply URL for non-JS users
public function reply_url( $url, $reply_id, $redirect_to ) {
$reply = get_post( $reply_id );
if ( bbp_get_reply_post_type() == $reply->post_type ) {
@@ -203,15 +204,15 @@ public function reply_url( $url, $reply_id, $redirect_to ) {
return $url;
} // reply_url
- // Return all replies if on a single topic view.
- public function replies_per_page( $retval, $per ) {
+ // Return all replies if on a single topic view
+ public function replies_per_page( $retval, $default ) {
if ( bbp_is_single_topic() && !( bbp_is_topic_merge() || bbp_is_topic_split() || bbp_is_topic_edit() ) )
return -1;
else
return $retval;
} // replies_per_page
- // Pagination for threaded replies.
+ // Pagination for threaded replies
public function replies_pagination( $args ) {
global $wp_rewrite;
@@ -224,7 +225,7 @@ public function replies_pagination( $args ) {
return $args;
} // replies_pagination
- // Fix topic pagination for display on forum pages.
+ // Fix topic pagination for display on forum pages
public function get_topic_pagination( $links, $args ) {
global $wp_rewrite;
@@ -271,7 +272,13 @@ public function get_topic_pagination( $links, $args ) {
return $pagination_links;
} // get_topic_pagination
- // Handle inheritance on merges.
+ // Remove topic pagination count for display on topic pages
+ // @todo Fix with actual numbers
+ public function get_topic_pagination_count( $retstr ) {
+ return '';
+ } // get_topic_pagination_count
+
+ // Handle inheritance on merges
public function merge_topic( $destination_topic_id, $source_topic_id ) {
$replies = (array) get_posts( array(
'post_parent' => $source_topic_id,
@@ -280,7 +287,7 @@ public function merge_topic( $destination_topic_id, $source_topic_id ) {
'order' => 'ASC'
) );
- // Clean up orphans by setting them as replies to the source topic.
+ // Clean up orphans by setting them as replies to the source topic
if ( !empty( $replies ) ) {
foreach ( $replies as $reply ) {
$in_reply_to = get_post_meta( $reply->ID, '_ucc_btr_in_reply_to', true );
@@ -289,19 +296,19 @@ public function merge_topic( $destination_topic_id, $source_topic_id ) {
}
}
- // Fix the source topic.
+ // Fix the source topic
update_post_meta( $source_topic_id, '_ucc_btr_in_reply_to', '0' );
} // merge_topic
- // Handle inheritance on splits.
+ // Handle inheritance on splits
public function split_topic( $from_reply_id, $source_topic_id, $destination_topic_id ) {
global $wpdb;
$from_reply = get_post( $from_reply_id );
- // get_posts() is not used because it does not have the >= comparison for post_date.
+ // get_posts() is not used because it does not have the >= comparison for post_date
$replies = (array) $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->posts} WHERE {$wpdb->posts}.post_date >= %s AND {$wpdb->posts}.post_parent = %d AND {$wpdb->posts}.post_type = %s ORDER BY {$wpdb->posts}.post_date ASC", $from_reply->post_date, $source_topic_id, bbp_get_reply_post_type() ) );
- // Clean up orphans.
+ // Clean up orphans
$ids = array();
if ( !empty( $replies ) && !is_wp_error( $replies ) ) {
foreach ( $replies as $reply ) {
@@ -309,17 +316,17 @@ public function split_topic( $from_reply_id, $source_topic_id, $destination_topi
$in_reply_to = get_post_meta( $reply->ID, '_ucc_btr_in_reply_to', true );
if ( !in_array( $in_reply_to, $ids ) )
update_post_meta( $reply->ID, '_ucc_btr_in_reply_to', 0 );
- // Special case for new topic from reply.
+ // Special case for new topic from reply
if ( ( $from_reply_id == $destination_topic_id ) && ( $from_reply_id == $in_reply_to ) )
update_post_meta( $reply->ID, '_ucc_btr_in_reply_to', 0 );
}
}
- // Fix the parent reply.
+ // Fix the parent reply
update_post_meta( $from_reply_id, '_ucc_btr_in_reply_to', 0 );
} // split_topic
- // Tidy up topic information after major changes.
+ // Tidy up topic information after major changes
public function clean_cache() {
$group = 'ucc_btr';
$expires = ucc_btr_get_expires();
@@ -346,8 +353,8 @@ public function clean_cache() {
$cache = wp_cache_get( $key, $group );
if ( is_array( $cache ) && !empty( $cache ) ) {
- if ( array_key_exists( $topic_id, $cache ) ) {
- unset( $cache[$topic_id] );
+ if ( array_key_exists( $topic_id, $cache ) ) {
+ unset( $cache[$topic_id] );
wp_cache_set( $key, $cache, $group, $expires );
}
}
@@ -355,7 +362,7 @@ public function clean_cache() {
}
}
- // Wipe cache completely (when settings change, etc.).
+ // Wipe cache completely (when settings change, etc.)
public function clear_cache() {
$group = 'ucc_btr';
diff --git a/includes/ucc-btr-callbacks.php b/includes/ucc-btr-callbacks.php
index 926953a..fab628d 100644
--- a/includes/ucc-btr-callbacks.php
+++ b/includes/ucc-btr-callbacks.php
@@ -4,13 +4,13 @@
if ( !defined( 'ABSPATH' ) ) exit;
-// Default table-based callback (bbp-twentyten) for Walker_Comment.
+// Default table-based callback (bbp-twentyten) for Walker_Comment
if ( !function_exists( 'ucc_btr_bbpress_reply_cb' ) ) {
function ucc_btr_bbpress_reply_cb( $_reply, $args, $depth ) {
global $bbp, $post, $reply;
if ( is_object( $bbp ) ) {
- // bbPress version < 2.1 or already initialized.
+ // bbPress version < 2.1 or already initialized
} elseif ( function_exists( 'bbpress' ) ) {
$bbp = bbpress();
}
@@ -18,7 +18,7 @@ function ucc_btr_bbpress_reply_cb( $_reply, $args, $depth ) {
$original_post = $post;
$original_reply = $reply;
- // Force WordPress/bbPress functions to use the right reply.
+ // Force WordPress/bbPress functions to use the right reply
$post = $_reply;
$bbp->reply_query->post = $_reply;
$reply = $_reply;
@@ -29,7 +29,7 @@ function ucc_btr_bbpress_reply_cb( $_reply, $args, $depth ) {
} else {
$tag = 'li';
$add_below = 'reply';
- }
+ }
$reply_text = __( 'Reply ↓', 'bbpress-threaded-replies' );
?>
@@ -49,20 +49,20 @@ function ucc_btr_bbpress_reply_cb( $_reply, $args, $depth ) {
reply_query->post = $original_post;
$reply = $original_reply;
} }
-// Div-based callback (bbp-theme-compat) for Walker_Comment.
+// Div-based callback (bbp-theme-compat) for Walker_Comment.
if ( !function_exists( 'ucc_btr_bbpress_theme_compat_reply_cb' ) ) {
function ucc_btr_bbpress_theme_compat_reply_cb( $_reply, $args, $depth ) {
global $bbp, $post, $reply;
if ( is_object( $bbp ) ) {
- // bbPress version < 2.1 or already initialized.
+ // bbPress version < 2.1 or already initialized
} elseif ( function_exists( 'bbpress' ) ) {
$bbp = bbpress();
}
@@ -70,7 +70,7 @@ function ucc_btr_bbpress_theme_compat_reply_cb( $_reply, $args, $depth ) {
$original_post = $post;
$original_reply = $reply;
- // Force WordPress/bbPress functions to use the right reply.
+ // Force WordPress/bbPress functions to use the right reply
$post = $_reply;
$bbp->reply_query->post = $_reply;
$reply = $_reply;
@@ -96,7 +96,7 @@ function ucc_btr_bbpress_theme_compat_reply_cb( $_reply, $args, $depth ) {
reply_query->post = $original_post;
$reply = $original_reply;
diff --git a/includes/ucc-btr-functions.php b/includes/ucc-btr-functions.php
index 3384b5f..6795b82 100644
--- a/includes/ucc-btr-functions.php
+++ b/includes/ucc-btr-functions.php
@@ -25,7 +25,7 @@ function ucc_btr_get_root_element_id( $reply_id ) {
function ucc_btr_get_root_element_count( $topic_id, $all = false ) {
global $wpdb;
- // Check cache first.
+ // Check cache first
$group = 'ucc_btr';
$expires = ucc_btr_get_expires();
if ( bbp_get_view_all( 'edit_others_replies' ) || $all )
@@ -41,7 +41,7 @@ function ucc_btr_get_root_element_count( $topic_id, $all = false ) {
}
$post_status = join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) );
- if ( bbp_get_view_all( 'edit_others_replies' ) || $all )
+ if ( bbp_get_view_all( 'edit_others_replies' ) || $all )
$post_status = join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id() ) );
$post_status = explode( ',', $post_status );
$post_status_in_array = array();
@@ -49,7 +49,7 @@ function ucc_btr_get_root_element_count( $topic_id, $all = false ) {
$post_status_in_array[] = $wpdb->prepare( "%s", $ps );
$post_status_in_array = implode( ',', $post_status_in_array );
- // Direct SQL is more efficient than trying to use WP_Query here.
+ // Direct SQL is more efficient than trying to use WP_Query here
$sql = $wpdb->prepare( "
SELECT COUNT(*) FROM {$wpdb->posts} p
WHERE p.post_parent = %d
@@ -67,7 +67,7 @@ function ucc_btr_get_root_element_count( $topic_id, $all = false ) {
);
$reply_count = (int) $wpdb->get_var( $sql );
- // Populate cache.
+ // Populate cache
$counts[$topic_id] = (int) $reply_count;
wp_cache_set( $key, $counts, $group, $expires );
@@ -76,13 +76,13 @@ function ucc_btr_get_root_element_count( $topic_id, $all = false ) {
// Source: wp-includes/comment.php
-// Derived from get_comment_pages_count().
+// Derived from get_comment_pages_count()
if ( !function_exists( 'ucc_btr_get_reply_pages_count' ) ) {
function ucc_btr_get_reply_pages_count( $replies = null, $per_page = null, $threaded = null ) {
global $bbp, $wp_query;
if ( is_object( $bbp ) ) {
- // bbPress version < 2.1 or already initialized.
+ // bbPress version < 2.1 or already initialized
} elseif ( function_exists( 'bbpress' ) ) {
$bbp = bbpress();
}
@@ -107,7 +107,7 @@ function ucc_btr_get_reply_pages_count( $replies = null, $per_page = null, $thre
return 1;
if ( !isset( $threaded ) )
- $threaded = $options['thread_replies'];
+ $threaded = $options['thread_replies'];
if ( $threaded ) {
$count = (int) ucc_btr_get_root_element_count( bbp_get_topic_id() );
@@ -121,19 +121,19 @@ function ucc_btr_get_reply_pages_count( $replies = null, $per_page = null, $thre
// Source: wp-includes/comment.php
-// Derived from get_page_of_comment().
+// Derived from get_page_of_comment()
if ( !function_exists( 'ucc_btr_get_page_of_reply' ) ) {
function ucc_btr_get_page_of_reply( $reply_id, $all = false ) {
global $wpdb;
$topic_id = bbp_get_reply_topic_id( $reply_id );
- // Check for paging.
+ // Check for paging
$options = get_option( '_ucc_btr_options' );
if ( !$options['page_replies'] )
return 1;
- // Check cache first.
+ // Check cache first
$group = 'ucc_btr';
$expires = ucc_btr_get_expires();
if ( bbp_get_view_all( 'edit_others_replies' ) || $all )
@@ -157,7 +157,7 @@ function ucc_btr_get_page_of_reply( $reply_id, $all = false ) {
$post_date_gmt = get_post_time( 'Y-m-d H:i:s', true, $root_id );
$post_status = join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) );
- if ( bbp_get_view_all( 'edit_others_replies' ) || $all )
+ if ( bbp_get_view_all( 'edit_others_replies' ) || $all )
$post_status = join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id() ) );
$post_status = explode( ',', $post_status );
$post_status_in_array = array();
@@ -165,7 +165,7 @@ function ucc_btr_get_page_of_reply( $reply_id, $all = false ) {
$post_status_in_array[] = $wpdb->prepare( "%s", $ps );
$post_status_in_array = implode( ',', $post_status_in_array );
- // Direct SQL is more efficient than trying to use WP_Query here.
+ // Direct SQL is more efficient than trying to use WP_Query here
$sql = $wpdb->prepare( "
SELECT COUNT(*) FROM {$wpdb->posts} p
WHERE p.post_parent = %d
@@ -184,19 +184,19 @@ function ucc_btr_get_page_of_reply( $reply_id, $all = false ) {
);
$previous = $wpdb->get_var( $sql );
- // Calculate page.
+ // Calculate page
$options = get_option( '_ucc_btr_options' );
- $replies_per_page = $options['replies_per_page'];
+ $replies_per_page = $options['replies_per_page'];
$page = ceil( ( $previous + 1 ) / $replies_per_page );
- // Deal with $overridden_rpage.
+ // Deal with $overridden_rpage
$options = get_option( '_ucc_btr_options' );
if ( array_key_exists( 'default_replies_page', $options ) && $options['default_replies_page'] == 'newest' ) {
$total = ceil( ucc_btr_get_root_element_count( $topic_id ) / $replies_per_page );
$page = $total - $page + 1;
}
- // Populate cache.
+ // Populate cache
$pages[$topic_id][$reply_id] = $page;
wp_cache_set( $key, $pages, $group, $expires );
@@ -205,7 +205,7 @@ function ucc_btr_get_page_of_reply( $reply_id, $all = false ) {
// Source: wp-includes/comment-template.php
-// Derived from get_comment_link().
+// Derived from get_comment_link()
if ( !function_exists( 'ucc_btr_get_reply_link' ) ) {
function ucc_btr_get_reply_link( $url, $reply_id, $redirect_to ) {
global $wp_rewrite;
@@ -217,7 +217,7 @@ function ucc_btr_get_reply_link( $url, $reply_id, $redirect_to ) {
$topic_url = remove_query_arg( 'view', $topic_url );
- // Deal with pagination and permalink structure.
+ // Deal with pagination and permalink structure
if ( 1 >= $reply_page ) {
$url = user_trailingslashit( $topic_url ) . $reply_hash;
} else {
@@ -236,7 +236,7 @@ function ucc_btr_get_reply_link( $url, $reply_id, $redirect_to ) {
// Source: wp-includes/comment-template.php
-// Derived from get_comment_class().
+// Derived from get_comment_class()
if ( !function_exists( 'ucc_btr_get_reply_class' ) ) {
function ucc_btr_get_reply_class( $class = '', $reply_id = null, $topic_id = null ) {
global $reply, $reply_alt, $reply_depth, $reply_thread_alt;
@@ -248,12 +248,12 @@ function ucc_btr_get_reply_class( $class = '', $reply_id = null, $topic_id = nul
$classes[] = 'reply';
- // If the reply author is a user, print the cleaned user_nicename.
+ // If the reply author is a user, print the cleaned user_nicename
if ( $reply->post_author > 0 && $user = get_userdata( $reply->post_author ) ) {
- // For all registered users, 'byuser'.
+ // For all registered users, 'byuser'
$classes[] = 'byuser';
$classes[] = 'reply-author-' . sanitize_html_class( $user->user_nicename, $reply->post_author );
- // For reply authors who are the author of the topic.
+ // For reply authors who are the author of the topic
if ( $reply->post_author === $topic->post_author ) {
$classes[] = 'bytopicauthor';
}
@@ -275,7 +275,7 @@ function ucc_btr_get_reply_class( $class = '', $reply_id = null, $topic_id = nul
$reply_alt++;
- // Alt for top-level replies.
+ // Alt for top-level replies
if ( 1 == $reply_depth ) {
if ( $reply_thread_alt % 2 ) {
$classes[] = 'thread-odd';
@@ -303,7 +303,7 @@ function ucc_btr_get_reply_class( $class = '', $reply_id = null, $topic_id = nul
// Source: wp-includes/comment-template.php
-// Derived from comment_class().
+// Derived from comment_class()
if ( !function_exists( 'ucc_btr_reply_class' ) ) {
function ucc_btr_reply_class( $class = '', $reply_id = null, $topic_id = null, $echo = true ) {
$class = 'class="' . join( ' ', ucc_btr_get_reply_class( $class, $reply_id, $topic_id ) ) . '"';
@@ -315,7 +315,7 @@ function ucc_btr_reply_class( $class = '', $reply_id = null, $topic_id = null, $
// Source: wp-includes/comment-template.php
-// Derived from get_comment_reply_link().
+// Derived from get_comment_reply_link()
if ( !function_exists( 'ucc_btr_get_in_reply_to_link' ) ) {
function ucc_btr_get_in_reply_to_link( $args = array(), $_reply = null, $topic = null ) {
global $user_ID, $reply;
@@ -353,7 +353,7 @@ function ucc_btr_get_in_reply_to_link( $args = array(), $_reply = null, $topic =
// Source: wp-includes/comment-template.php
-// Derived from comment_reply_link().
+// Derived from comment_reply_link()
if ( !function_exists( 'ucc_btr_in_reply_to_link' ) ) {
function ucc_btr_in_reply_to_link( $args = array(), $reply = null, $topic = null ) {
echo ucc_btr_get_in_reply_to_link( $args, $reply, $topic );
@@ -361,7 +361,7 @@ function ucc_btr_in_reply_to_link( $args = array(), $reply = null, $topic = null
// Source: wp-includes/comment-template.php
-// Derived from get_cancel_comment_reply_link().
+// Derived from get_cancel_comment_reply_link()
if ( !function_exists( 'ucc_btr_get_cancel_in_reply_to_link' ) ) {
function ucc_btr_get_cancel_in_reply_to_link( $text = '' ) {
if ( empty( $text ) )
@@ -375,7 +375,7 @@ function ucc_btr_get_cancel_in_reply_to_link( $text = '' ) {
// Source: wp-includes/comment-template.php
-// Derived from get_cancel_comment_reply_link().
+// Derived from get_cancel_comment_reply_link()
if ( !function_exists( 'ucc_btr_cancel_in_reply_to_link' ) ) {
function ucc_btr_cancel_in_reply_to_link( $text = '' ) {
echo ucc_btr_get_cancel_in_reply_to_link( $text );
@@ -383,7 +383,7 @@ function ucc_btr_cancel_in_reply_to_link( $text = '' ) {
// Source: wp-includes/comment-template.php
-// Derived from wp_list_comments().
+// Derived from wp_list_comments()
if ( !function_exists( 'ucc_btr_list_replies' ) ) {
function ucc_btr_list_replies( $args = array(), $replies = null ) {
global $bbp, $wp_query, $reply_alt, $reply_depth, $reply_thread_alt, $overridden_rpage, $in_reply_loop;
@@ -441,17 +441,17 @@ function ucc_btr_list_replies( $args = array(), $replies = null ) {
if ( empty( $overridden_rpage ) ) {
$r['page'] = get_query_var( 'paged' );
} else {
- // Handle $overridden_rpage here.
+ // Handle $overridden_rpage here
$threaded = ( -1 != $r['max_depth'] );
$paged = get_query_var( 'paged' );
- $paged = ( !empty( $paged ) ) ? (int) $paged : 1;
+ $paged = ( !empty( $paged ) ) ? (int) $paged : 1;
$r['page'] = ( 'newest' == $options['default_replies_page'] ) ? ucc_btr_get_reply_pages_count( $_replies, $r['per_page'], $threaded ) - $paged + 1 : 1;
set_query_var( 'paged', $r['page'] );
$page = $r['page'];
}
}
- // Validation check.
+ // Validation check
$r['page'] = intval( $r['page'] );
if ( 0 == $r['page'] && 0 != $r['per_page'] )
$r['page'] = 1;
diff --git a/js/bbpress-threaded-replies.js b/js/bbpress-threaded-replies.js
index 3ff2002..769e348 100644
--- a/js/bbpress-threaded-replies.js
+++ b/js/bbpress-threaded-replies.js
@@ -47,7 +47,7 @@ addReply = {
I : function(e) {
return document.getElementById(e);
},
-
+
rmTiny : function() {
try {
tinyMCE.triggerSave();
@@ -57,7 +57,7 @@ addReply = {
},
addTiny : function() {
- try {
+ try {
tinyMCE.execCommand('mceAddControl', false, 'bbp_reply_content');
} catch (e) {}
}
diff --git a/readme.txt b/readme.txt
index 521fe1c..6d36785 100755
--- a/readme.txt
+++ b/readme.txt
@@ -1,9 +1,9 @@
=== bbPress Threaded Replies ===
Contributors: jmdodd
-Tags: bbpress, replies, threaded, nested
+Tags: bbpress, replies, threaded, nested, hierarchical
Requires at least: WordPress 3.4, bbPress 2.0
-Tested up to: 3.4
-Stable tag: 0.4.2
+Tested up to: 3.5-beta1, bbPress 2.2-beta2
+Stable tag: 0.4.3
Add threaded (nested) reply functionality to bbPress.
@@ -11,9 +11,12 @@ Add threaded (nested) reply functionality to bbPress.
bbPress Threaded Replies is based on comment-display functions from WordPress
and topic-display functions from bbPress. Settings can be adjusted on the bbPress
-Forums options page of WordPress. bbPress running as a WordPress plugin is required.
+Forums options page of WordPress. bbPress running as a WordPress plugin is required.
-The plugin checks first in the stylesheet and template directories before reverting
+bbPress Threaded Replies is incompatible with the Fancy Editor; enabling threading will
+automatically disable the Fancy Editor.
+
+The plugin checks first in the stylesheet and template directories before reverting
to the default plugin templates.
== Installation ==
@@ -24,6 +27,13 @@ to the default plugin templates.
== Changelog ==
+= 0.4.3 =
+* Move activation from init to plugins_loaded.
+* Improve CSS.
+* BuddyPress Group Forums compat.
+* Disable Fancy Editor when using threaded replies.
+* Remove "Viewing X replies" counts.
+
= 0.4.2 =
* Change constants STYLESHEETPATH and TEMPLATEPATH to corresponding functions.
* Fix divide-by-zero in replies_per_page.
@@ -52,7 +62,7 @@ to the default plugin templates.
* SQL fix: change wp_postmeta to {$wpdb->postmeta} in queries.
= 0.1 =
-* Initial release.
+* Initial release.
== Upgrade Notice ==
@@ -62,7 +72,7 @@ to the default plugin templates.
= 0.2 =
* SQL and template updates. Fixes missing pagination for blogs without default 'wp_' database prefix.
-= 0.1 =
+= 0.1 =
* Initial release.
== Credits ==
diff --git a/templates/bbpress/ucc-loop-replies.php b/templates/bbpress/ucc-loop-replies.php
index 7b623d8..9fcec4d 100644
--- a/templates/bbpress/ucc-loop-replies.php
+++ b/templates/bbpress/ucc-loop-replies.php
@@ -50,11 +50,11 @@
-
+
-
+
-
+
diff --git a/ucc-btr-loader.php b/ucc-btr-loader.php
index 406edfd..a3e9c62 100644
--- a/ucc-btr-loader.php
+++ b/ucc-btr-loader.php
@@ -1,8 +1,8 @@
version = '20121002';
- $this->plugin_dir = plugin_dir_path( __FILE__ );
- $this->plugin_url = plugins_url( __FILE__ );
- $this->template_dir = trailingslashit( $this->plugin_dir ) . 'templates';
+ self::$instance = $this;
+ self::$version = '2012111101';
+ self::$plugin_dir = plugin_dir_path( __FILE__ );
+ self::$plugin_url = plugins_url( __FILE__ );
+ self::$template_dir = trailingslashit( self::$plugin_dir ) . 'templates';
- // Languages.
+ // Languages
load_plugin_textdomain( 'bbpress-threaded-replies', false, basename( dirname( __FILE__ ) ) . '/languages' );
- // Default settings.
+ // Default settings
$options = get_option( '_ucc_btr_options' );
if ( !$options ) {
$options = array(
@@ -64,40 +64,41 @@ public function __construct() {
update_option( '_ucc_btr_options', $options );
}
- // Admin-side plugin settings.
+ // Admin-side plugin settings
if ( is_admin() )
add_action( 'bbp_admin_init', array( $this, 'register_admin_settings' ), 15 );
- // Includes.
+ // Includes
$this->includes();
- // Load main.
+ // Load main
if ( $options['thread_replies'] ) {
- // Template and script handlers.
+ // Template and script handlers
if ( function_exists( 'bbpress' ) ) {
- add_action( 'get_template_part_loop', array( $this, 'get_template_part' ), 10, 2 );
- add_filter( 'bbp_get_template_part', array( $this, 'bbp_get_template_part' ), 10, 3 );
- } else { // bbPress < 2.1 compat.
+ add_action( 'get_template_part_loop', array( $this, 'get_template_part' ), 10, 2 );
+ add_filter( 'bbp_get_template_part', array( $this, 'bbp_get_template_part' ), 10, 3 );
+ } else { // bbPress < 2.1 compat
add_action( 'template_redirect', array( $this, 'template_redirect' ), 15 );
}
+ add_filter( 'bbp_use_wp_editor', '__return_false' );
add_action( 'wp_enqueue_scripts', array( $this, 'register_externals' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'load_externals' ) );
new UCC_bbPress_Threaded_Replies;
}
- // Caching.
+ // Caching
wp_cache_add_global_groups( 'ucc_btr' );
} // __construct
- // Includes.
+ // Includes
public function includes() {
- require( $this->plugin_dir . 'includes/bbpress-threaded-replies.php' );
- require( $this->plugin_dir . 'includes/ucc-btr-callbacks.php' );
- require( $this->plugin_dir . 'includes/ucc-btr-functions.php' );
+ require( self::$plugin_dir . 'includes/bbpress-threaded-replies.php' );
+ require( self::$plugin_dir . 'includes/ucc-btr-callbacks.php' );
+ require( self::$plugin_dir . 'includes/ucc-btr-functions.php' );
} // includes
- // Admin-side settings.
+ // Admin-side settings
public function register_admin_settings() {
add_settings_section( 'threaded_replies', __( 'Threaded Replies', 'bbpress-threaded-replies' ), array( $this, 'threaded_replies_text' ), 'bbpress' );
add_settings_field( '_ucc_btr_options', __( 'Threaded replies', 'bbpress-threaded-replies' ), array( $this, 'threaded_replies_settings' ), 'bbpress', 'threaded_replies' );
@@ -174,10 +175,10 @@ public function validate_settings( $_options ) {
return $options;
} // validate_settings
- // New way of doing this.
+ // New way of doing this
public function get_template_part( $slug, $name ) {
if ( $slug == 'loop' && $name == 'replies' && bbp_is_single_topic() && !bbp_is_topic_merge() && !bbp_is_topic_edit() && !bbp_is_topic_split() ) {
- if ( bbp_is_theme_compat_active() )
+ if ( bbp_is_theme_compat_active() || bbp_is_group_forums_active() && function_exists( 'bp_is_groups_component' ) && bp_is_groups_component() )
$template_name = 'bbpress/ucc-loop-compat.php';
else
$template_name = 'bbpress/ucc-loop-replies.php';
@@ -192,9 +193,10 @@ public function get_template_part( $slug, $name ) {
} elseif ( file_exists( trailingslashit( bbp_get_theme_compat_dir() ) . $template_name ) ) {
$located = trailingslashit( bbp_get_theme_compat_dir() ) . $template_name;
// Use default plugin template
- } else {
- $located = trailingslashit( $this->template_dir ) . $template_name;
+ } else {
+ $located = trailingslashit( self::$template_dir ) . $template_name;
}
+
load_template( $located, true );
}
} // get_template_part
@@ -205,7 +207,7 @@ public function bbp_get_template_part( $templates, $slug, $name ) {
return $templates;
} // bbp_get_template_part
- // bbPress 2.0 compat, simplified.
+ // bbPress 2.0 compat, simplified
public function template_redirect() {
if ( bbp_is_single_topic() && !bbp_is_topic_merge() && !bbp_is_topic_edit() && !bbp_is_topic_split() ) {
$file = 'ucc-single-topic.php';
@@ -218,15 +220,15 @@ public function template_redirect() {
include ( trailingslashit( get_template_directory() ) . $file );
exit;
} else {
- include ( trailingslashit( $this->template_dir ) . $file );
+ include ( trailingslashit( self::$template_dir ) . $file );
exit;
}
}
} // template_redirect
public function register_externals() {
- wp_register_style( 'bbpress-threaded-replies', plugins_url( 'css/bbpress-threaded-replies.css', __FILE__ ), false, $this->version );
- wp_register_script( 'bbpress-threaded-replies', plugins_url( 'js/bbpress-threaded-replies.js', __FILE__ ), false, $this->version, false );
+ wp_register_style( 'bbpress-threaded-replies', plugins_url( 'css/bbpress-threaded-replies.css', __FILE__ ), false, self::$version );
+ wp_register_script( 'bbpress-threaded-replies', plugins_url( 'js/bbpress-threaded-replies.js', __FILE__ ), false, self::$version, false );
} // register_externals
public function load_externals() {
@@ -234,12 +236,19 @@ public function load_externals() {
wp_enqueue_style( 'bbpress-threaded-replies' );
wp_enqueue_script( 'bbpress-threaded-replies' );
}
+
+ // BuddyPress group forums
+ if ( bbp_is_group_forums_active() && function_exists( 'bp_is_groups_component' ) && bp_is_groups_component() && bp_action_variable( 0 ) == bbp_get_topic_post_type() ) {
+ wp_enqueue_style( 'bbpress-threaded-replies' );
+ wp_enqueue_script( 'bbpress-threaded-replies' );
+ }
} // load_externals
} }
-// Only load if bbPress is active.
+
+// Only load if bbPress is active
function ucc_btr_loader() {
if ( in_array( 'bbpress/bbpress.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) )
new UCC_bbPress_Threaded_Replies_Loader;
}
-add_action( 'init', 'ucc_btr_loader' );
+add_action( 'plugins_loaded', 'ucc_btr_loader' );