WordPress.org

Plugin Directory

Changeset 601748


Ignore:
Timestamp:
09/20/12 20:14:22 (19 months ago)
Author:
jmdodd
Message:

Merge for 0.4 release

Location:
bbpress-threaded-replies/trunk
Files:
7 added
5 deleted
2 edited
4 moved

Legend:

Unmodified
Added
Removed
  • bbpress-threaded-replies/trunk/css/bbpress-threaded-replies.css

    r496517 r601748  
    1 /*  Source: bbpress/bbp-themes/bbp-twentyten/css/bbpress.css     
    2     Modifications for threading the bbPress default theme. */ 
    3 #content .bbp-topic-wrapper .reply { 
    4     margin: 0; 
    5     padding: 0; 
    6     border: 0; 
    7     font-family: inherit; 
    8     font-size: inherit; 
    9 } 
    10 #content .bbp-topic-wrapper a { 
    11     text-decoration: none; 
    12 } 
     1/* Modifications for threading; tested under bbp-theme-compat and bbp-twentyten. */ 
    132#content .replylist { 
    143    list-style: none; 
    154    margin: 0; 
    16     width: 100%; 
    175} 
    18 #content .replylist ul { 
     6#content .replylist table, 
     7#content .replylist tbody, 
     8#content .replylist tr, 
     9#content .replylist td { 
     10    border-collapse: collapse; 
     11} 
     12#content .replylist ul.children { 
    1913    list-style: none; 
     14    margin: 0 0 0 2.0em ; 
    2015} 
     16#content .replylist li, 
     17#content .replylist li div.reply { 
     18    padding-bottom: 0; 
     19} 
     20#content table.bbp-replies, 
    2121#content .replylist table.bbp-replies { 
    22     border-left: 1px solid #ddd; 
    23     margin-bottom: 0; 
     22    margin: -1px 0 0 0; 
    2423} 
    25 #content .replylist td.bbp-reply-author { 
    26     width: 120px; 
    27 } 
    28 #content .replylist table.bbp-replies { 
    29     margin-bottom: 0; 
    30     border-collapse: collapse; 
    31     margin-top: -1px; 
    32 } 
    33 #content .replylist tr.noheight, 
    34 #content .replylist td.noheight.bbp-reply-author, 
    35 #content .replylist td.noheight.bbp-reply-content { 
    36     height: 0; 
    37     line-height: 0; 
    38     margin: 0; 
    39     padding: 0; 
    40     border: 0; 
    41 } 
    42 #content .replylist td.ucc-bbp-in-reply-to { 
    43     border-top: 0; 
    44     padding: 4px 10px; 
     24#content .replylist .ucc-bbp-in-reply-to { 
     25    padding: 0 1.625em 1.625em 1.625em; 
     26    border-top: 0px; 
    4527    text-align: right; 
    4628} 
  • bbpress-threaded-replies/trunk/includes/ucc-btr-functions.php

    r496912 r601748  
    55 
    66 
    7 if ( ! function_exists( 'ucc_btr_get_expires' ) ) { 
     7if ( !function_exists( 'ucc_btr_get_expires' ) ) { 
    88function ucc_btr_get_expires() { 
    99    $expires = apply_filters( 'ucc_btr_expires', 3600 ); 
     
    1212 
    1313 
    14 if ( ! function_exists( 'ucc_btr_get_root_element_id' ) ) { 
     14if ( !function_exists( 'ucc_btr_get_root_element_id' ) ) { 
    1515function ucc_btr_get_root_element_id( $reply_id ) { 
    1616    $in_reply_to = get_post_meta( $reply_id, '_ucc_btr_in_reply_to', true ); 
     
    2222 
    2323 
    24 if ( ! function_exists( 'ucc_btr_get_root_element_count' ) ) { 
     24if ( !function_exists( 'ucc_btr_get_root_element_count' ) ) { 
    2525function ucc_btr_get_root_element_count( $topic_id, $all = false ) { 
    2626    global $wpdb; 
    2727 
    28     $group = 'ucc-btr'; 
     28    // Check cache first. 
     29    $group = 'ucc_btr'; 
    2930    $expires = ucc_btr_get_expires(); 
    3031    if ( bbp_get_view_all( 'edit_others_replies' ) || $all ) 
    31         $cache_key = 'topic_count_all_' . $topic_id; 
     32        $key = 'reply_count_all'; 
    3233    else 
    33         $cache_key = 'topic_count_' . $topic_id; 
    34      
    35     $count = wp_cache_get( $cache_key, $group ); 
    36     if ( false !== $count ) 
    37         return $count; 
    38      
     34        $key = 'reply_count'; 
     35 
     36    $counts = wp_cache_get( $key, $group ); 
     37    if ( empty( $counts ) ) { 
     38        $counts = array(); 
     39    } elseif ( is_array( $counts ) && array_key_exists( $topic_id, $counts ) ) { 
     40        return $counts[$topic_id]; 
     41    } 
     42 
    3943    $post_status = join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) ); 
    40     if ( bbp_get_view_all( 'edit_others_replies' ) || $all ) { 
     44    if ( bbp_get_view_all( 'edit_others_replies' ) || $all )  
    4145        $post_status = join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id() ) ); 
    42     } 
    4346    $post_status = explode( ',', $post_status ); 
    4447    $post_status_in_array = array(); 
    45     foreach ( $post_status as $ps ) 
     48    foreach ( (array) $post_status as $ps ) 
    4649        $post_status_in_array[] = $wpdb->prepare( "%s", $ps ); 
    4750    $post_status_in_array = implode( ',', $post_status_in_array ); 
    48      
    49     //  Direct SQL is more efficient than trying to use WP_Query here. 
     51 
     52    // Direct SQL is more efficient than trying to use WP_Query here. 
    5053    $sql = $wpdb->prepare( " 
    51         SELECT COUNT(*) FROM {$wpdb->posts} p  
     54        SELECT COUNT(*) FROM {$wpdb->posts} p 
    5255        WHERE p.post_parent = %d 
    5356            AND p.post_type = %s 
    5457            AND p.post_status IN ( {$post_status_in_array} ) 
    55             AND (  
    56                 NOT EXISTS (  
    57                     SELECT pm.* FROM {$wpdb->postmeta} pm WHERE p.ID = pm.post_id AND pm.meta_key = '_ucc_btr_in_reply_to'  
    58                 ) OR EXISTS (  
    59                     SELECT pm.* FROM {$wpdb->postmeta} pm WHERE p.ID = pm.post_id AND pm.meta_key = '_ucc_btr_in_reply_to' AND pm.meta_value = 0  
    60                 ) OR EXISTS (  
    61                     SELECT pm.* FROM {$wpdb->postmeta} pm WHERE p.ID = pm.post_id AND pm.meta_key = '_ucc_btr_in_reply_to' AND pm.meta_value = %d  
     58            AND ( 
     59                NOT EXISTS ( 
     60                    SELECT pm.* FROM {$wpdb->postmeta} pm WHERE p.ID = pm.post_id AND pm.meta_key = '_ucc_btr_in_reply_to' 
     61                ) OR EXISTS ( 
     62                    SELECT pm.* FROM {$wpdb->postmeta} pm WHERE p.ID = pm.post_id AND pm.meta_key = '_ucc_btr_in_reply_to' AND pm.meta_value = 0 
     63                ) OR EXISTS ( 
     64                    SELECT pm.* FROM {$wpdb->postmeta} pm WHERE p.ID = pm.post_id AND pm.meta_key = '_ucc_btr_in_reply_to' AND pm.meta_value = %d 
    6265        ) ) ORDER BY p.post_date_gmt ASC", 
    6366        $topic_id, bbp_get_reply_post_type(), $topic_id 
    6467    ); 
    65     $count = $wpdb->get_var( $sql ); 
    66  
    67     wp_cache_set( $cache_key, $count, $group, $expires ); 
    68      
    69     return $count; 
    70 } } 
    71  
    72  
    73 //  Source: wp-includes/comment.php 
    74 //  Derived from get_comment_pages_count(). 
    75 if ( ! function_exists( 'ucc_btr_get_reply_paged_count' ) ) { 
     68    $reply_count = (int) $wpdb->get_var( $sql ); 
     69 
     70    // Populate cache. 
     71    $counts[$topic_id] = (int) $reply_count; 
     72    wp_cache_set( $key, $counts, $group, $expires ); 
     73 
     74    return $reply_count; 
     75} } 
     76 
     77 
     78// Source: wp-includes/comment.php 
     79// Derived from get_comment_pages_count(). 
     80if ( !function_exists( 'ucc_btr_get_reply_pages_count' ) ) { 
    7681function ucc_btr_get_reply_pages_count( $replies = null, $per_page = null, $threaded = null ) { 
    7782    global $bbp, $wp_query; 
    7883 
    79     if ( null === $replies && null === $per_page && null === $threaded && ! empty( $bbp->max_num_pages ) ) 
     84    if ( is_object( $bbp ) ) { 
     85        // bbPress version < 2.1 or already initialized. 
     86    } elseif ( function_exists( 'bbpress' ) ) { 
     87        $bbp = bbpress(); 
     88    } 
     89 
     90    if ( null === $replies && null === $per_page && null === $threaded && !empty( $bbp->max_num_pages ) ) 
    8091        return $bbp->max_num_pages; 
    8192 
    82     if ( ! $replies || ! is_array( $replies ) ) 
     93    if ( !$replies || !is_array( $replies ) ) 
    8394        $replies = $bbp->replies; 
    8495 
     
    8697        return 0; 
    8798 
    88     if ( ! isset( $per_page ) ) 
    89         $per_page = (int) get_option( '_bbp_replies_per_page' ); 
    90     if ( 0 === $per_page ) 
    91         $per_page = (int) get_option( 'comments_per_page' ); 
     99    $options = get_option( '_ucc_btr_options' ); 
     100 
     101    if ( !$options['page_replies'] ) 
     102        return 0; 
     103 
     104    if ( !isset( $per_page ) ) 
     105        $per_page = (int) $options['replies_per_page']; 
    92106    if ( 0 === $per_page ) 
    93107        return 1; 
    94108 
    95     if ( ! isset( $threaded ) ) 
    96         $threaded = get_option( 'thread_comments' ); 
     109    if ( !isset( $threaded ) ) 
     110        $threaded = $options['thread_replies'];  
    97111 
    98112    if ( $threaded ) { 
     
    107121 
    108122 
    109 //  Source: wp-includes/comment.php 
    110 //  Derived from get_page_of_comment(). 
    111 if ( ! function_exists( 'ucc_btr_get_page_of_reply' ) ) { 
     123// Source: wp-includes/comment.php 
     124// Derived from get_page_of_comment(). 
     125if ( !function_exists( 'ucc_btr_get_page_of_reply' ) ) { 
    112126function ucc_btr_get_page_of_reply( $reply_id, $all = false ) { 
    113127    global $wpdb; 
     
    115129    $topic_id = bbp_get_reply_topic_id( $reply_id ); 
    116130 
    117     $group = 'ucc-btr'; 
     131    // Check for paging. 
     132    $options = get_option( '_ucc_btr_options' ); 
     133    if ( !$options['page_replies'] ) 
     134        return 1; 
     135 
     136    // Check cache first. 
     137    $group = 'ucc_btr'; 
    118138    $expires = ucc_btr_get_expires(); 
    119139    if ( bbp_get_view_all( 'edit_others_replies' ) || $all ) 
    120         $cache_key = 'topic_pages_all_' . $topic_id; 
     140        $key = 'reply_pages_all'; 
    121141    else 
    122         $cache_key = 'topic_pages_' . $topic_id; 
    123  
    124     $pages = wp_cache_get( $cache_key, $group ); 
    125  
    126     if ( empty( $pages ) )  
     142        $key = 'reply_pages'; 
     143 
     144    $pages = wp_cache_get( $key, $group ); 
     145    if ( empty( $pages ) ) { 
    127146        $pages = array(); 
    128     elseif ( is_array( $pages ) && array_key_exists( $reply_id, $pages ) )  
    129         return $pages[$reply_id]; 
     147    } elseif ( is_array( $pages ) ) { 
     148        if ( array_key_exists( $topic_id, $pages ) ) { 
     149            if ( array_key_exists( $reply_id, $pages[$topic_id] ) ) 
     150                return $pages[$topic_id][$reply_id]; 
     151        } else { 
     152            $pages[$topic_id] = array(); 
     153        } 
     154    } 
    130155 
    131156    $root_id = ucc_btr_get_root_element_id( $reply_id ); 
     
    133158 
    134159    $post_status = join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) ); 
    135     if ( bbp_get_view_all( 'edit_others_replies' ) || $all ) { 
     160    if ( bbp_get_view_all( 'edit_others_replies' ) || $all )  
    136161        $post_status = join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id() ) ); 
    137     } 
    138162    $post_status = explode( ',', $post_status ); 
    139163    $post_status_in_array = array(); 
    140     foreach ( $post_status as $ps ) 
     164    foreach ( (array) $post_status as $ps ) 
    141165        $post_status_in_array[] = $wpdb->prepare( "%s", $ps ); 
    142166    $post_status_in_array = implode( ',', $post_status_in_array ); 
    143167 
    144     //  Direct SQL is more efficient than trying to use WP_Query here. 
     168    // Direct SQL is more efficient than trying to use WP_Query here. 
    145169    $sql = $wpdb->prepare( " 
    146170        SELECT COUNT(*) FROM {$wpdb->posts} p 
     
    161185    $previous = $wpdb->get_var( $sql ); 
    162186 
    163     $posts_per_page = get_option( '_bbp_replies_per_page' ); 
    164     $page = ceil( ( $previous + 1 ) / $posts_per_page ); 
    165  
    166     $pages[$reply_id] = $page; 
    167     wp_cache_set( $cache_key, $pages, $group, $expires );    
     187    // Calculate page. 
     188    $options = get_option( '_ucc_btr_options' ); 
     189    $replies_per_page = $options['replies_per_page'];  
     190    $page = ceil( ( $previous + 1 ) / $replies_per_page ); 
     191 
     192        // Deal with $overridden_rpage. 
     193        $options = get_option( '_ucc_btr_options' ); 
     194        if ( array_key_exists( 'default_replies_page', $options ) && $options['default_replies_page'] == 'newest' ) { 
     195        $total = ceil( ucc_btr_get_root_element_count( $topic_id ) / $replies_per_page ); 
     196        $page = $total - $page + 1; 
     197        } 
     198 
     199    // Populate cache. 
     200    $pages[$topic_id][$reply_id] = $page; 
     201    wp_cache_set( $key, $pages, $group, $expires ); 
    168202 
    169203    return $page; 
     
    171205 
    172206 
    173 //  Source: wp-includes/comment-template.php 
    174 //  Derived from get_comment_link(). 
    175 if ( ! function_exists( 'ucc_btr_get_reply_link' ) ) { 
     207// Source: wp-includes/comment-template.php 
     208// Derived from get_comment_link(). 
     209if ( !function_exists( 'ucc_btr_get_reply_link' ) ) { 
    176210function ucc_btr_get_reply_link( $url, $reply_id, $redirect_to ) { 
    177211    global $wp_rewrite; 
    178      
     212 
    179213    $reply_page = ucc_btr_get_page_of_reply( $reply_id ); 
    180214    $topic_id = bbp_get_reply_topic_id( $reply_id ); 
     
    184218    $topic_url = remove_query_arg( 'view', $topic_url ); 
    185219 
    186     //  Deal with pagination and permalink structure. 
     220    // Deal with pagination and permalink structure. 
    187221    if ( 1 >= $reply_page ) { 
    188222        $url = user_trailingslashit( $topic_url ) . $reply_hash; 
     
    202236 
    203237 
    204 //  Source: wp-includes/comment-template.php 
    205 //  Derived from get_comment_class(). 
    206 if ( ! function_exists( 'ucc_btr_get_reply_class' ) ) { 
     238// Source: wp-includes/comment-template.php 
     239// Derived from get_comment_class(). 
     240if ( !function_exists( 'ucc_btr_get_reply_class' ) ) { 
    207241function ucc_btr_get_reply_class( $class = '', $reply_id = null, $topic_id = null ) { 
    208242    global $reply, $reply_alt, $reply_depth, $reply_thread_alt; 
    209243 
    210     if ( null == $reply_id )  
     244    if ( null == $reply_id ) 
    211245        $reply_id = bbp_get_reply_id(); 
    212246    $topic = get_post( bbp_get_reply_topic_id( $reply_id ) ); 
    213247    $classes = array(); 
    214      
    215     if ( defined( 'REPLIES_COMMENTSTYLE' ) && REPLIES_COMMENTSTYLE ) 
    216         $classes[] = 'comment'; 
    217     else 
    218         $classes[] = 'reply'; 
    219  
    220     //  If the reply author is a user, print the cleaned user_nicename. 
     248 
     249    $classes[] = 'reply'; 
     250 
     251    // If the reply author is a user, print the cleaned user_nicename. 
    221252    if ( $reply->post_author > 0 && $user = get_userdata( $reply->post_author ) ) { 
    222         //  For all registered users, 'byuser' 
     253        // For all registered users, 'byuser'. 
    223254        $classes[] = 'byuser'; 
    224         if ( defined( 'REPLIES_COMMENTSTYLE' ) && REPLIES_COMMENTSTYLE ) 
    225             $classes[] = 'comment-author-' . sanitize_html_class( $user->user_nicename, $reply->post_author ); 
    226         else 
    227             $classes[] = 'reply-author-' . sanitize_html_class( $user->user_nicename, $reply->post_author ); 
    228         //  For reply authors who are the author of the topic 
     255        $classes[] = 'reply-author-' . sanitize_html_class( $user->user_nicename, $reply->post_author ); 
     256        // For reply authors who are the author of the topic. 
    229257        if ( $reply->post_author === $topic->post_author ) { 
    230             if ( defined( 'REPLIES_COMMENTSTYLE' ) && REPLIES_COMMENTSTYLE ) 
    231                 $classes[] = 'bypostauthor'; 
    232             else 
    233                 $classes[] = 'bytopicauthor'; 
     258            $classes[] = 'bytopicauthor'; 
    234259        } 
    235260    } 
     
    251276    $reply_alt++; 
    252277 
    253     //  Alt for top-level comments 
     278    // Alt for top-level replies. 
    254279    if ( 1 == $reply_depth ) { 
    255280        if ( $reply_thread_alt % 2 ) { 
     
    263288 
    264289    $classes[] = "depth-$reply_depth"; 
    265      
     290 
    266291    $classes[] = 'status-' . bbp_get_reply_status(); 
    267292 
    268     if ( ! empty( $class ) ) { 
    269         if ( ! is_array( $class ) ) 
     293    if ( !empty( $class ) ) { 
     294        if ( !is_array( $class ) ) 
    270295            $class = preg_split( '#\s+#', $class ); 
    271296        $classes = array_merge( $classes, $class ); 
     
    278303 
    279304 
    280 //  Source: wp-includes/comment-template.php 
    281 //  Derived from comment_class(). 
    282 if ( ! function_exists( 'ucc_btr_reply_class' ) ) { 
     305// Source: wp-includes/comment-template.php 
     306// Derived from comment_class(). 
     307if ( !function_exists( 'ucc_btr_reply_class' ) ) { 
    283308function ucc_btr_reply_class( $class = '', $reply_id = null, $topic_id = null, $echo = true ) { 
    284309    $class = 'class="' . join( ' ', ucc_btr_get_reply_class( $class, $reply_id, $topic_id ) ) . '"'; 
     
    290315 
    291316 
    292 //  Source: wp-includes/comment-template.php 
    293 //  Derived from get_comment_reply_link(). 
    294 if ( ! function_exists( 'ucc_btr_get_in_reply_to_link' ) ) { 
     317// Source: wp-includes/comment-template.php 
     318// Derived from get_comment_reply_link(). 
     319if ( !function_exists( 'ucc_btr_get_in_reply_to_link' ) ) { 
    295320function ucc_btr_get_in_reply_to_link( $args = array(), $_reply = null, $topic = null ) { 
    296321    global $user_ID, $reply; 
    297322 
    298     $defaults = array(  
    299         'add_below' => 'reply',  
     323    $defaults = array( 
     324        'add_below' => 'reply', 
    300325        'respond_id' => 'new-reply-' . bbp_get_topic_id(), 
    301326        'reply_text' => __( 'Reply to this', 'bbpress-threaded-replies' ), 
    302         'login_text' => __( 'Log in to Reply', 'bbpress-threaded-replies' ),  
     327        'login_text' => __( 'Log in to Reply', 'bbpress-threaded-replies' ), 
    303328        'depth' => 0, 
    304         'before' => '',  
    305         'after' => ''  
     329        'before' => '', 
     330        'after' => '' 
    306331    ); 
    307332 
     
    328353 
    329354 
    330 //  Source: wp-includes/comment-template.php 
    331 //  Derived from comment_reply_link(). 
    332 if ( ! function_exists( 'ucc_btr_in_reply_to_link' ) ) { 
     355// Source: wp-includes/comment-template.php 
     356// Derived from comment_reply_link(). 
     357if ( !function_exists( 'ucc_btr_in_reply_to_link' ) ) { 
    333358function ucc_btr_in_reply_to_link( $args = array(), $reply = null, $topic = null ) { 
    334359    echo ucc_btr_get_in_reply_to_link( $args, $reply, $topic ); 
     
    336361 
    337362 
    338 //  Source: wp-includes/comment-template.php 
    339 //  Derived from get_cancel_comment_reply_link(). 
    340 if ( ! function_exists( 'ucc_btr_get_cancel_in_reply_to_link' ) ) { 
     363// Source: wp-includes/comment-template.php 
     364// Derived from get_cancel_comment_reply_link(). 
     365if ( !function_exists( 'ucc_btr_get_cancel_in_reply_to_link' ) ) { 
    341366function ucc_btr_get_cancel_in_reply_to_link( $text = '' ) { 
    342367    if ( empty( $text ) ) 
    343368        $text = __( 'Click here to cancel reply.', 'bbpress-threaded-replies' ); 
    344          
     369 
    345370    $style = isset( $_GET['inreplyto'] ) ? '' : ' style="display:none;"'; 
    346371    $link = esc_html( remove_query_arg( array( 'inreplyto', 'inreplyto_nonce' ) ) ) . '#respond'; 
    347      
     372 
    348373    return apply_filters( 'ucc_btr_cancel_in_reply_to_link', '<a rel="nofollow" id="cancel-in-reply-to-link" href="' . $link . '"' . $style . '>' . $text . '</a>', $link, $text ); 
    349374} } 
    350375 
    351376 
    352 //  Source: wp-includes/comment-template.php 
    353 //  Derived from get_cancel_comment_reply_link(). 
    354 if ( ! function_exists( 'ucc_btr_cancel_in_reply_to_link' ) ) { 
     377// Source: wp-includes/comment-template.php 
     378// Derived from get_cancel_comment_reply_link(). 
     379if ( !function_exists( 'ucc_btr_cancel_in_reply_to_link' ) ) { 
    355380function ucc_btr_cancel_in_reply_to_link( $text = '' ) { 
    356381    echo ucc_btr_get_cancel_in_reply_to_link( $text ); 
     
    358383 
    359384 
    360 //  Source: wp-includes/comment-template.php 
    361 //  Derived from comments_template(). 
    362 if ( ! function_exists( 'ucc_btr_replies_template' ) ) { 
    363 function ucc_btr_replies_template( $file = '/replies.php' ) { 
    364     global $bbp, $wp_query, $overridden_rpage; 
    365      
    366     if ( ! defined( 'REPLIES_COMMENTSTYLE' ) || ! REPLIES_COMMENTSTYLE ) 
    367         define( 'REPLIES_COMMENTSTYLE', true ); 
    368  
    369     if ( ! ( bbp_is_single_topic() && ! bbp_is_topic_edit() && ! bbp_is_topic_merge() && ! bbp_is_topic_split() ) ) 
    370         return; 
    371  
    372     if ( empty( $file ) ) 
    373         $file = '/replies.php'; 
    374  
    375     $replies = $bbp->replies; 
    376  
    377     $overridden_rpage = FALSE; 
    378     if ( '' == get_query_var( 'paged' ) && get_option( 'page_comments' ) ) { 
    379         set_query_var( 'paged', 'newest' == get_option( 'default_comments_page' ) ? ucc_btr_get_reply_pages_count() : 1 ); 
    380         $overridden_rpage = TRUE; 
    381     } 
    382  
    383     if ( ! defined( 'REPLIES_TEMPLATE' ) || ! REPLIES_TEMPLATE ) 
    384         define( 'REPLIES_TEMPLATE', true ); 
    385      
    386     //  Step backwards for the template: child theme, theme, plugin. 
    387     $include = apply_filters( 'ucc_btr_replies_template', STYLESHEETPATH . $file ); 
    388     if ( file_exists( $include ) ) 
    389         require( $include ); 
    390     elseif ( file_exists( TEMPLATEPATH . $file ) ) 
    391         require( TEMPLATEPATH .  $file ); 
    392     else 
    393         require( UCC_BTR_DIR . 'templates/replies.php' ); 
    394 } } 
    395  
    396  
    397 //  Source: wp-includes/comment-template.php 
    398 //  Derived from wp_list_comments(). 
    399 if ( ! function_exists( 'ucc_btr_list_replies' ) ) { 
     385// Source: wp-includes/comment-template.php 
     386// Derived from wp_list_comments(). 
     387if ( !function_exists( 'ucc_btr_list_replies' ) ) { 
    400388function ucc_btr_list_replies( $args = array(), $replies = null ) { 
    401389    global $bbp, $wp_query, $reply_alt, $reply_depth, $reply_thread_alt, $overridden_rpage, $in_reply_loop; 
     
    406394    $reply_depth = 1; 
    407395 
    408     $defaults = array(  
    409         'walker' => null,  
    410         'max_depth' => '',  
    411         'style' => 'ul',  
    412         'callback' => 'ucc_btr_bbpress_reply_cb',  
    413         'end-callback' => null,  
    414         'type' => 'all',  
    415         'page' => '',  
    416         'per_page' => '',  
    417         'avatar_size' => 32,  
    418         'reverse_top_level' => null,  
     396    $defaults = array( 
     397        'walker' => null, 
     398        'max_depth' => '', 
     399        'style' => 'ul', 
     400        'callback' => 'ucc_btr_bbpress_reply_cb', 
     401        'end-callback' => null, 
     402        'type' => 'all', 
     403        'page' => '', 
     404        'per_page' => '', 
     405        'avatar_size' => 32, 
     406        'reverse_top_level' => null, 
    419407        'reverse_children' => '' 
    420408    ); 
     
    433421    } 
    434422 
    435     if ( '' === $r['per_page'] ) 
    436         $r['per_page'] = get_option( '_bbp_replies_per_page' ); 
     423    $options = get_option( '_ucc_btr_options' ); 
     424 
     425    if ( '' === $r['per_page'] && $options['page_replies'] ) 
     426        $r['per_page'] = $options['replies_per_page']; 
    437427 
    438428    if ( empty( $r['per_page'] ) ) { 
     
    442432 
    443433    if ( '' === $r['max_depth'] ) { 
    444         if ( get_option( 'thread_comments' ) ) 
    445             $r['max_depth'] = get_option( 'thread_comments_depth' ); 
     434        if ( $options['thread_replies'] ) 
     435            $r['max_depth'] = $options['thread_replies_depth']; 
    446436        else 
    447437            $r['max_depth'] = -1; 
     
    452442            $r['page'] = get_query_var( 'paged' ); 
    453443        } else { 
     444            // Handle $overridden_rpage here. 
    454445            $threaded = ( -1 != $r['max_depth'] ); 
    455             $r['page'] = ( 'newest' == get_option( 'default_comments_page' ) ) ? ucc_btr_get_reply_pages_count( $_replies, $r['per_page'], $threaded ) : 1; 
     446            $paged = get_query_var( 'paged' ); 
     447            $paged = ( !empty( $paged ) ) ? (int) $paged : 1;  
     448            $r['page'] = ( 'newest' == $options['default_replies_page'] ) ? ucc_btr_get_reply_pages_count( $_replies, $r['per_page'], $threaded ) - $paged + 1 : 1; 
    456449            set_query_var( 'paged', $r['page'] ); 
     450            $page = $r['page']; 
    457451        } 
    458452    } 
    459      
    460     //  Validation check 
     453 
     454    // Validation check. 
    461455    $r['page'] = intval( $r['page'] ); 
    462456    if ( 0 == $r['page'] && 0 != $r['per_page'] ) 
     
    464458 
    465459    if ( null === $r['reverse_top_level'] ) 
    466         $r['reverse_top_level'] = ( 'desc' == get_option( 'comment_order' ) ); 
     460        $r['reverse_top_level'] = ( 'desc' == $options['reply_order'] ); 
    467461 
    468462    extract( $r, EXTR_SKIP ); 
     
    471465        $walker = new Walker_Comment; 
    472466    $walker->db_fields = array( 'parent' => 'in_reply_to', 'id' => 'ID' ); 
    473      
     467 
    474468    $walker->paged_walk( $_replies, $max_depth, $page, $per_page, $r ); 
    475469    $bbp->max_num_pages = $walker->max_pages; 
     
    477471    $in_reply_loop = false; 
    478472} } 
     473 
  • bbpress-threaded-replies/trunk/readme.txt

    r496912 r601748  
    22Contributors: jmdodd 
    33Tags: bbpress, replies, threaded, nested 
    4 Requires at least: 3.1.4 
    5 Tested up to: 3.3.1 
    6 Stable tag: 0.3 
     4Requires at least: WordPress 3.4, bbPress 2.0 
     5Tested up to: 3.4 
     6Stable tag: 0.4 
    77 
    88Add threaded (nested) reply functionality to bbPress. 
     
    1111 
    1212bbPress Threaded Replies is based on comment-display functions from WordPress 
    13 and topic-display functions from bbPress. It currently gets all of its settings 
    14 from the Settings > Discussion panel of WordPress, inheriting comment threading 
    15 options. If comment threading (nesting) is not enabled, this plugin will not 
    16 load. bbPress running as a WordPress plugin is also required.  
     13and topic-display functions from bbPress. Settings can be adjusted on the bbPress 
     14Forums options page of WordPress. bbPress running as a WordPress plugin is required.  
    1715 
    18 Template files can be copied to theme directories. The TwentyEleven theme  
    19 triggers a comment-style reply framework; its absence causes the plugin to 
    20 revert to the bbPress default table for each reply, indented. The plugin checks 
    21 first in the stylesheet and template directories before reverting to the default 
    22 plugin templates. 
    23  
    24 Filters are available for modification of plugin behavior.  
     16The plugin checks first in the stylesheet and template directories before reverting  
     17to the default plugin templates. 
    2518 
    2619== Installation == 
     
    28211. Upload the directory `bbpress-threaded-replies` and its contents to the `/wp-content/plugins/` directory. 
    29221. Activate the plugin through the 'Plugins' menu in WordPress. 
     231. Visit the bbPress Forums panel to adjust threading settings. 
    3024 
    3125== Changelog == 
     26 
     27= 0.4 = 
     28* Update for bbPress 2.1; retain backwards compat to 2.0. 
     29* Add separate settings section on Forums options page. 
     30* Update cache layout for complete flush on settings update. 
     31* Remove twentyeleven theme; rename templates to avoid collisions. 
     32* Add support for theme-compat. 
     33* Fix behavior of thread split. 
     34* Fix default_replies_page reversal. 
    3235 
    3336= 0.3 = 
     
    4649== Upgrade Notice == 
    4750 
     51= 0.4 = 
     52* bbPress 2.0 and 2.1 compatible. Template files have been renamed to avoid filename collisions. 
     53 
    4854= 0.2 = 
    4955* SQL and template updates. Fixes missing pagination for blogs without default 'wp_' database prefix. 
  • bbpress-threaded-replies/trunk/templates/bbpress/ucc-content-single-topic.php

    r496912 r601748  
    11<?php 
    2  
    3  
    4 if ( ! defined( 'ABSPATH' ) ) exit; 
    5  
    6  
    7 //  Source: bbpress/bbp-themes/bbp-twentyten/bbpress/content-single-topic.php 
     2// Source: bbp-themes/bbp-twentyten/content-single-topic.php 
    83?> 
    94 
     
    3227            <?php bbp_get_template_part( 'bbpress/pagination', 'replies' ); ?> 
    3328 
    34             <?php include( 'loop-replies.php' ); ?> 
     29            <?php include( 'ucc-loop-replies.php' ); ?> 
    3530 
    3631            <?php bbp_get_template_part( 'bbpress/pagination', 'replies' ); ?> 
     
    4338 
    4439    <?php do_action( 'bbp_template_after_single_topic' ); ?> 
     40 
  • bbpress-threaded-replies/trunk/templates/bbpress/ucc-loop-replies.php

    r496912 r601748  
    11<?php 
    2  
    3  
    4 if ( ! defined( 'ABSPATH' ) ) exit; 
    5  
    6  
    7 //  Source: bbpress/bbp-themes/bbp-twentyten/bbpress/loop-replies.php 
     2// Source: bbp-themes/bbp-twentyten/bbpress/loop-replies.php 
    83?> 
    94 
     
    138        <thead> 
    149            <tr> 
    15                 <th class="bbp-reply-author"><?php  _e( 'Author',  'bbpress' ); ?></th> 
     10                <th class="bbp-reply-author"><?php  _e( 'Author',  'bbpress-threaded-replies' ); ?></th> 
    1611                <th class="bbp-reply-content"> 
    1712 
    1813                    <?php if ( !bbp_show_lead_topic() ) : ?> 
    1914 
    20                         <?php _e( 'Posts', 'bbpress' ); ?> 
     15                        <?php _e( 'Posts', 'bbpress-threaded-replies' ); ?> 
    2116 
    2217                        <?php bbp_user_subscribe_link(); ?> 
     
    2621                    <?php else : ?> 
    2722 
    28                         <?php _e( 'Replies', 'bbpress' ); ?> 
     23                        <?php _e( 'Replies', 'bbpress-threaded-replies' ); ?> 
    2924 
    3025                    <?php endif; ?> 
     
    3631        <tfoot> 
    3732            <tr> 
    38                 <th class="bbp-reply-author"><?php  _e( 'Author',  'bbpress' ); ?></th> 
     33                <th class="bbp-reply-author"><?php  _e( 'Author',  'bbpress-threaded-replies' ); ?></th> 
    3934                <th class="bbp-reply-content"> 
    4035 
    4136                    <?php if ( !bbp_show_lead_topic() ) : ?> 
    4237 
    43                         <?php _e( 'Posts', 'bbpress' ); ?> 
     38                        <?php _e( 'Posts', 'bbpress-threaded-replies' ); ?> 
    4439 
    4540                    <?php else : ?> 
    4641 
    47                         <?php _e( 'Replies', 'bbpress' ); ?> 
     42                        <?php _e( 'Replies', 'bbpress-threaded-replies' ); ?> 
    4843 
    4944                    <?php endif; ?> 
     
    5449 
    5550        <tbody> 
    56              
     51 
    5752            <?php if ( ! bbp_show_lead_topic() ) : ?> 
    5853                 
     
    6257                 
    6358            <?php endif; ?> 
    64          
     59 
    6560        </tbody> 
     61 
    6662    </table> 
    67      
     63 
    6864    <ol class="replylist"> 
    69              
    70     <?php ucc_btr_list_replies(); ?> 
     65 
     66        <?php ucc_btr_list_replies(); ?> 
    7167 
    7268    </ol> 
  • bbpress-threaded-replies/trunk/templates/ucc-single-topic.php

    r496912 r601748  
    11<?php 
     2// Source: bbp-themes/bbp-twentyten/single-topic.php 
     3?> 
    24 
    3  
    4 if ( ! defined( 'ABSPATH' ) ) exit; 
    5  
    6  
    7 //  Source: bbpress/bbp-themes/bbp-twentyten/single-topic.php 
    8 ?> 
    95<?php get_header(); ?> 
    106 
     
    1713 
    1814                    <?php while ( have_posts() ) : the_post(); ?> 
    19 <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 
    20     <header class="entry-header"> 
    21         <h1 class="entry-title"><?php the_title(); ?></h1> 
    22     </header><!-- .entry-header --> 
    23  
    24     <div class="entry-content"> 
    2515 
    2616                        <div id="bbp-topic-wrapper-<?php bbp_topic_id(); ?>" class="bbp-topic-wrapper"> 
     17                            <h1 class="entry-title"><?php bbp_topic_title(); ?></h1> 
     18                            <div class="entry-content"> 
    2719 
    28                                 <?php include( 'bbpress/content-single-topic.php' ); ?> 
     20                                <?php include( 'bbpress/ucc-content-single-topic.php' ); ?> 
    2921 
     22                            </div> 
    3023                        </div><!-- #bbp-topic-wrapper-<?php bbp_topic_id(); ?> --> 
    31                      
    32     </div><!-- .entry-content --> 
    33  
    34     <footer class="entry-meta"> 
    35     </footer><!-- .entry-meta --> 
    36 </article><!-- #post- --> 
    3724 
    3825                    <?php endwhile; ?> 
     
    4734        </div><!-- #container --> 
    4835 
     36<?php get_sidebar(); ?> 
    4937<?php get_footer(); ?> 
Note: See TracChangeset for help on using the changeset viewer.