Changeset 2955
- Timestamp:
- 03/11/2011 07:42:17 AM (14 years ago)
- Location:
- branches/plugin
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-forum-template.php
r2952 r2955 1085 1085 1086 1086 /** 1087 * Output total post count of a forum 1088 * 1089 * @since bbPress (r2954) 1090 * 1091 * @param int $forum_id Optional. Forum id 1092 * @param bool $total_count Optional. To get the total count or normal count? 1093 * @uses bbp_get_forum_post_count() To get the forum post count 1094 */ 1095 function bbp_forum_post_count( $forum_id = 0, $total_count = true ) { 1096 echo bbp_get_forum_post_count( $forum_id, $total_count ); 1097 } 1098 /** 1099 * Return total post count of a forum 1100 * 1101 * @since bbPress (r2954) 1102 * 1103 * @param int $forum_id Optional. Forum id 1104 * @param bool $total_count Optional. To get the total count or normal 1105 * count? 1106 * @uses bbp_get_forum_id() To get the forum id 1107 * @uses get_post_meta() To get the forum post count 1108 * @uses apply_filters() Calls 'bbp_get_forum_post_count' with the 1109 * post count and forum id 1110 * @return int Forum post count 1111 */ 1112 function bbp_get_forum_post_count( $forum_id = 0, $total_count = true ) { 1113 $forum_id = bbp_get_forum_id( $forum_id ); 1114 $topics = bbp_get_forum_topic_count( $forum_id, $total_count ); 1115 $replies = get_post_meta( $forum_id, empty( $total_count ) ? '_bbp_reply_count' : '_bbp_total_reply_count', true ); 1116 1117 return apply_filters( 'bbp_get_forum_post_count', (int) $replies + (int) $topics, $forum_id ); 1118 } 1119 1120 /** 1087 1121 * Output total hidden topic count of a forum (hidden includes trashed and 1088 1122 * spammed topics) -
branches/plugin/bbp-includes/bbp-reply-template.php
r2952 r2955 56 56 global $wp_rewrite, $bbp; 57 57 58 // Show the topic above all of the replies 59 if ( bbp_show_lead_topic() ) { 60 61 $parent_args = array( 62 63 // Query only by post_parent 64 'post_parent' => bbp_get_topic_id(), 65 66 // Narrow query down to bbPress replies 67 'post_type' => bbp_get_reply_post_type() 68 ); 69 70 // Show the topic in the same loop as replies 71 } else { 72 73 $parent_args = array( 74 75 // Query by post meta instead of post_parent 76 'meta_key' => '_bbp_topic_id', 77 'meta_value' => bbp_get_topic_id(), 78 79 // Include both topic and reply in the loop 80 'post_type' => array( bbp_get_topic_post_type(), bbp_get_reply_post_type() ) 81 ); 82 83 // Manually set the post_parent variable 84 $post_parent = bbp_get_topic_id(); 85 } 86 87 // Default query args 58 88 $default = array( 59 // Narrow query down to bbPress topics60 'post_type' => bbp_get_reply_post_type(),61 62 // Forum ID63 'post_parent' => bbp_get_topic_id(),64 89 65 90 // 'author', 'date', 'title', 'modified', 'parent', rand', … … 81 106 'post_status' => ( !empty( $_GET['view'] ) && 'all' == $_GET['view'] && current_user_can( 'edit_others_replies' ) ) ? join( ',', array( 'publish', $bbp->spam_status_id, 'trash' ) ) : 'publish', 82 107 ); 108 109 // Merge the default args and parent args together 110 $default = array_merge( $parent_args, $default ); 83 111 84 112 // Set up topic variables … … 317 345 $topic_url = bbp_get_topic_permalink( $topic_id ); 318 346 $topic_replies = bbp_get_topic_reply_count( $topic_id ); 347 348 // Add hidden replies to count 319 349 if ( $count_hidden == true ) 320 350 $topic_replies += bbp_get_topic_hidden_reply_count( $topic_id ); 351 352 // Add 1 to the count if topic is included in reply loop 353 if ( !bbp_show_lead_topic() ) 354 $topic_replies++; 355 321 356 $reply_page = ceil( $topic_replies / get_option( '_bbp_replies_per_page', 15 ) ); 322 323 357 $reply_hash = !empty( $bbp->errors ) ? "#reply-{$reply_id}" : ''; 324 358 … … 326 360 if ( 1 >= $reply_page ) { 327 361 $url = trailingslashit( $topic_url ) . $reply_hash; 362 363 // Include pagination 328 364 } else { 365 366 // Pretty permalinks 329 367 if ( $wp_rewrite->using_permalinks() ) { 330 368 $url = trailingslashit( $topic_url ) . trailingslashit( "page/{$reply_page}" ) . $reply_hash; 369 370 // Yucky links 331 371 } else { 332 372 $url = add_query_arg( 'paged', $reply_page, $topic_url ) . $reply_hash; … … 1130 1170 global $bbp; 1131 1171 1132 if ( !bbp_is_topic() && !bbp_is_reply() )1133 return;1134 1135 1172 $defaults = array ( 1136 1173 'id' => 0, … … 1145 1182 $r['id'] = bbp_get_reply_id( (int) $r['id'] ); 1146 1183 1184 // If post is a topic, return the topic admin links instead 1185 if ( bbp_is_topic( $r['id'] ) ) 1186 return bbp_get_topic_admin_links( $args ); 1187 1188 // If post is not a reply, return 1189 if ( !bbp_is_reply( $r['id'] ) ) 1190 return; 1191 1192 // Make sure user can edit this reply 1193 if ( !current_user_can( 'edit_reply', $r['id'] ) ) 1194 return; 1195 1147 1196 // If topic is trashed, do not show admin links 1148 1197 if ( bbp_is_topic_trash( bbp_get_reply_topic_id( $r['id'] ) ) ) 1149 1198 return; 1150 1199 1151 if ( !current_user_can( 'edit_reply', $r['id'] ) ) 1152 return; 1153 1200 // If no links were passed, default to the standard 1154 1201 if ( empty( $r['links'] ) ) { 1155 1202 $r['links'] = array ( … … 1537 1584 $total = bbp_number_format( $bbp->reply_query->found_posts ); 1538 1585 1539 // Set return string 1540 if ( $total > 1 && (int) $from_num == (int) $to_num ) 1541 $retstr = sprintf( __( 'Viewing reply %1$s (of %2$s total)', 'bbpress' ), $from_num, $total ); 1542 elseif ( $total > 1 && empty( $to_num ) ) 1543 $retstr = sprintf( __( 'Viewing %1$s replies', 'bbpress' ), $total ); 1544 if ( $total > 1 && (int) $from_num != (int) $to_num ) 1545 $retstr = sprintf( __( 'Viewing %1$s replies - %2$s through %3$s (of %4$s total)', 'bbpress' ), $bbp->reply_query->post_count, $from_num, $to_num, $total ); 1546 else 1547 $retstr = sprintf( __( 'Viewing %1$s reply', 'bbpress' ), $total ); 1586 // We are not including the lead topic 1587 if ( bbp_show_lead_topic() ) { 1588 1589 // Set return string 1590 if ( $total > 1 && (int) $from_num == (int) $to_num ) 1591 $retstr = sprintf( __( 'Viewing reply %1$s (of %2$s total)', 'bbpress' ), $from_num, $total ); 1592 elseif ( $total > 1 && empty( $to_num ) ) 1593 $retstr = sprintf( __( 'Viewing %1$s replies', 'bbpress' ), $total ); 1594 elseif ( $total > 1 && (int) $from_num != (int) $to_num ) 1595 $retstr = sprintf( __( 'Viewing %1$s replies - %2$s through %3$s (of %4$s total)', 'bbpress' ), $bbp->reply_query->post_count, $from_num, $to_num, $total ); 1596 else 1597 $retstr = sprintf( __( 'Viewing %1$s reply', 'bbpress' ), $total ); 1598 1599 // We are including the lead topic 1600 } else { 1601 1602 // Set return string 1603 if ( $total > 1 && (int) $from_num == (int) $to_num ) 1604 $retstr = sprintf( __( 'Viewing post %1$s (of %2$s total)', 'bbpress' ), $from_num, $total ); 1605 elseif ( $total > 1 && empty( $to_num ) ) 1606 $retstr = sprintf( __( 'Viewing %1$s posts', 'bbpress' ), $total ); 1607 elseif ( $total > 1 && (int) $from_num != (int) $to_num ) 1608 $retstr = sprintf( __( 'Viewing %1$s posts - %2$s through %3$s (of %4$s total)', 'bbpress' ), $bbp->reply_query->post_count, $from_num, $to_num, $total ); 1609 elseif ( $total == 1 ) 1610 $retstr = sprintf( __( 'Viewing %1$s post', 'bbpress' ), $total ); 1611 } 1548 1612 1549 1613 // Filter and return -
branches/plugin/bbp-includes/bbp-topic-functions.php
r2952 r2955 453 453 454 454 // Forum topic meta 455 bbp_update_topic_forum_id ( $topic_id, $forum_id ); 455 bbp_update_topic_forum_id ( $topic_id, $forum_id ); 456 bbp_update_topic_topic_id ( $topic_id, $topic_id ); 456 457 457 458 // Update associated topic values if this is a new topic … … 1421 1422 1422 1423 /** 1424 * Update the topic's topic ID 1425 * 1426 * @since bbPress (r2954) 1427 * 1428 * @param int $topic_id Optional. Topic id to update 1429 * @param int $topic_id Optional. Reply id 1430 * @uses bbp_get_topic_id() To get the topic id 1431 * @uses bbp_get_topic_id() To get the topic id 1432 * @uses update_post_meta() To update the topic last topic id meta 1433 * @return bool True on success, false on failure 1434 */ 1435 function bbp_update_topic_topic_id( $topic_id = 0 ) { 1436 1437 // If it's a reply, then get the parent (topic id) 1438 $topic_id = bbp_get_topic_id( $topic_id ); 1439 1440 update_post_meta( $topic_id, '_bbp_topic_id', (int) $topic_id ); 1441 1442 return apply_filters( 'bbp_update_topic_topic_id', (int) $topic_id, $topic_id ); 1443 } 1444 1445 /** 1423 1446 * Adjust the total reply count of a topic 1424 1447 * -
branches/plugin/bbp-includes/bbp-topic-template.php
r2952 r2955 1464 1464 1465 1465 /** 1466 * Output total post count of a topic 1467 * 1468 * @since bbPress (r2954) 1469 * 1470 * @param int $topic_id Optional. Topic id 1471 * @uses bbp_get_topic_post_count() To get the topic post count 1472 */ 1473 function bbp_topic_post_count( $topic_id = 0 ) { 1474 echo bbp_get_topic_post_count( $topic_id ); 1475 } 1476 /** 1477 * Return total post count of a topic 1478 * 1479 * @since bbPress (r2954) 1480 * 1481 * @param int $topic_id Optional. Topic id 1482 * @uses bbp_get_topic_id() To get the topic id 1483 * @uses get_post_meta() To get the topic post count meta 1484 * @uses apply_filters() Calls 'bbp_get_topic_post_count' with the 1485 * post count and topic id 1486 * @return int post count 1487 */ 1488 function bbp_get_topic_post_count( $topic_id = 0 ) { 1489 $topic_id = bbp_get_topic_id( $topic_id ); 1490 $replies = get_post_meta( $topic_id, '_bbp_reply_count', true ); 1491 1492 return apply_filters( 'bbp_get_topic_post_count', (int) $replies + 1, $topic_id ); 1493 } 1494 1495 /** 1466 1496 * Output total hidden reply count of a topic (hidden includes trashed and 1467 1497 * spammed replies) -
branches/plugin/bbp-includes/bbp-update.php
r2946 r2955 103 103 update_option( '_bbp_db_version', '106' ); 104 104 } 105 106 // Add _bbp_topic_id meta to any existing topics 107 if ( 107 > (int) $db_version ) { 108 109 // Get all topic_id's 110 if ( $existing_topic_ids = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = %s", bbp_get_topic_post_type() ), ARRAY_N ) ) { 111 112 // Make sure query is not an error 113 if ( !is_wp_error( $existing_topic_ids ) ) { 114 115 // Add the topic meta to each topic 116 foreach( $existing_topic_ids as $topic_id ) 117 bbp_update_topic_topic_id ( $topic_id[0], $topic_id[0] ); 118 119 // Set the new DB version 120 update_option( '_bbp_db_version', '107' ); 121 } 122 } 123 } 105 124 } 106 125 add_action( 'init', 'bbp_update', 1 ); -
branches/plugin/bbp-themes/bbp-twentyten/bbpress/loop-forums.php
r2943 r2955 18 18 <th class="bbp-forum-info"><?php _e( 'Forum', 'bbpress' ); ?></th> 19 19 <th class="bbp-forum-topic-count"><?php _e( 'Topics', 'bbpress' ); ?></th> 20 <th class="bbp-forum- topic-replies"><?php _e( 'Replies', 'bbpress' ); ?></th>20 <th class="bbp-forum-reply-count"><?php bbp_show_lead_topic() ? _e( 'Replies', 'bbpress' ) : _e( 'Posts', 'bbpress' ); ?></th> 21 21 <th class="bbp-forum-freshness"><?php _e( 'Freshness', 'bbpress' ); ?></th> 22 22 </tr> … … 43 43 <td class="bbp-forum-topic-count"><?php bbp_forum_topic_count(); ?></td> 44 44 45 <td class="bbp-forum-reply-count"><?php bbp_ forum_reply_count(); ?></td>45 <td class="bbp-forum-reply-count"><?php bbp_show_lead_topic() ? bbp_forum_reply_count() : bbp_forum_post_count(); ?></td> 46 46 47 47 <td class="bbp-forum-freshness"> -
branches/plugin/bbp-themes/bbp-twentyten/bbpress/loop-replies.php
r2943 r2955 42 42 <a href="<?php bbp_reply_url(); ?>" title="<?php bbp_reply_title(); ?>">#</a> 43 43 44 <?php printf( __( ' Posted on%1$s at %2$s', 'bbpress' ), get_the_date(), esc_attr( get_the_time() ) ); ?>44 <?php printf( __( '%1$s at %2$s', 'bbpress' ), get_the_date(), esc_attr( get_the_time() ) ); ?> 45 45 46 46 <?php bbp_reply_admin_links(); ?> -
branches/plugin/bbp-themes/bbp-twentyten/bbpress/loop-topics.php
r2943 r2955 19 19 <th class="bbp-topic-title"><?php _e( 'Topic', 'bbpress' ); ?></th> 20 20 <th class="bbp-topic-voice-count"><?php _e( 'Voices', 'bbpress' ); ?></th> 21 <th class="bbp-topic-reply-count"><?php _e( 'Replies', 'bbpress' ); ?></th>21 <th class="bbp-topic-reply-count"><?php bbp_show_lead_topic() ? _e( 'Replies', 'bbpress' ) : _e( 'Posts', 'bbpress' ); ?></th> 22 22 <th class="bbp-topic-freshness"><?php _e( 'Freshness', 'bbpress' ); ?></th> 23 23 <?php if ( ( bbp_is_user_home() && ( bbp_is_favorites() || bbp_is_subscriptions() ) ) ) : ?><th class="bbp-topic-action"><?php _e( 'Remove', 'bbpress' ); ?></th><?php endif; ?> … … 50 50 <td class="bbp-topic-voice-count"><?php bbp_topic_voice_count(); ?></td> 51 51 52 <td class="bbp-topic-reply-count"><?php bbp_ topic_reply_count(); ?></td>52 <td class="bbp-topic-reply-count"><?php bbp_show_lead_topic() ? bbp_topic_reply_count() : bbp_topic_post_count(); ?></td> 53 53 54 54 <td class="bbp-topic-freshness"> -
branches/plugin/bbp-themes/bbp-twentyten/single-topic.php
r2943 r2955 29 29 <div id="ajax-response"></div> 30 30 31 <table class="bbp-topic" id="bbp-topic-<?php bbp_topic_id(); ?>"> 32 <thead> 33 <tr> 34 <th class="bbp-topic-author"><?php _e( 'Creator', 'bbpress' ); ?></th> 35 <th class="bbp-topic-content"> 31 <?php if ( bbp_show_lead_topic() ) : ?> 36 32 37 <?php _e( 'Topic', 'bbpress' ); ?> 33 <table class="bbp-topic" id="bbp-topic-<?php bbp_topic_id(); ?>"> 34 <thead> 35 <tr> 36 <th class="bbp-topic-author"><?php _e( 'Creator', 'bbpress' ); ?></th> 37 <th class="bbp-topic-content"> 38 38 39 <?php bbp_user_subscribe_link(); ?>39 <?php _e( 'Topic', 'bbpress' ); ?> 40 40 41 <?php bbp_user_favorites_link(); ?>41 <?php bbp_user_subscribe_link(); ?> 42 42 43 </th> 44 </tr> 45 </thead> 43 <?php bbp_user_favorites_link(); ?> 46 44 47 <tfoot>48 <tr>49 <td colspan="2">45 </th> 46 </tr> 47 </thead> 50 48 51 <?php bbp_topic_admin_links(); ?> 49 <tfoot> 50 <tr> 51 <td colspan="2"> 52 52 53 </td> 54 </tr> 55 </tfoot> 53 <?php bbp_topic_admin_links(); ?> 56 54 57 <tbody> 55 </td> 56 </tr> 57 </tfoot> 58 58 59 <tr class="bbp-topic-header"> 60 <td class="bbp-topic-author"><?php bbp_topic_author_link( array( 'type' => 'name' ) ); ?></td> 59 <tbody> 61 60 62 <t d class="bbp-topic-content">63 < a href="#bbp-topic-<?php bbp_topic_id(); ?>" title="<?php bbp_topic_title(); ?>">#</a>61 <tr class="bbp-topic-header"> 62 <td class="bbp-topic-author"><?php bbp_topic_author_link( array( 'type' => 'name' ) ); ?></td> 64 63 65 <?php printf( __( 'Posted on %1$s at %2$s', 'bbpress' ), get_the_date(), esc_attr( get_the_time() ) ); ?> 64 <td class="bbp-topic-content"> 65 <a href="#bbp-topic-<?php bbp_topic_id(); ?>" title="<?php bbp_topic_title(); ?>">#</a> 66 66 67 </td> 68 </tr> 67 <?php printf( __( 'Posted on %1$s at %2$s', 'bbpress' ), get_the_date(), esc_attr( get_the_time() ) ); ?> 69 68 70 <tr id="reply-<?php bbp_topic_id(); ?>" <?php post_class( 'bbp-forum-topic' ); ?>> 69 </td> 70 </tr> 71 71 72 <t d class="bbp-topic-author"><?php bbp_topic_author_link( array( 'type' => 'avatar' ) ); ?></td>72 <tr id="reply-<?php bbp_topic_id(); ?>" <?php post_class( 'bbp-forum-topic' ); ?>> 73 73 74 <td class="bbp-topic-content">74 <td class="bbp-topic-author"><?php bbp_topic_author_link( array( 'type' => 'avatar' ) ); ?></td> 75 75 76 < ?php bbp_topic_content(); ?>76 <td class="bbp-topic-content"> 77 77 78 </td>78 <?php bbp_topic_content(); ?> 79 79 80 </tr><!-- #bbp-topic-<?php bbp_topic_id(); ?> -->80 </td> 81 81 82 </tbody> 83 </table><!-- #bbp-topic-<?php bbp_topic_id(); ?> --> 82 </tr><!-- #bbp-topic-<?php bbp_topic_id(); ?> --> 83 84 </tbody> 85 </table><!-- #bbp-topic-<?php bbp_topic_id(); ?> --> 86 87 <?php endif; ?> 84 88 85 89 <?php endwhile; ?>
Note: See TracChangeset
for help on using the changeset viewer.