Changeset 4944
- Timestamp:
- 05/23/2013 07:09:03 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/admin/metaboxes.php
r4902 r4944 401 401 $reply_topic_id = bbp_get_reply_topic_id( $post_id ); 402 402 $reply_forum_id = bbp_get_reply_forum_id( $post_id ); 403 $reply_to = bbp_get_reply_to( $post_id ); 403 404 404 405 // Allow individual manipulation of reply forum … … 436 437 </p> 437 438 439 <p> 440 <strong class="label"><?php _e( 'Reply To:', 'bbpress' ); ?></strong> 441 <label class="screen-reader-text" for="bbp_reply_to"><?php _e( 'Reply To', 'bbpress' ); ?></label> 442 <input name="bbp_reply_to" id="bbp_reply_to" type="text" value="<?php echo esc_attr( $reply_to ); ?>" /> 443 </p> 444 438 445 <?php 439 446 wp_nonce_field( 'bbp_reply_metabox_save', 'bbp_reply_metabox' ); -
trunk/includes/admin/replies.php
r4909 r4944 221 221 '<li>' . __( '<strong>Forum</strong> dropdown determines the parent forum that the reply belongs to. Select the forum, or leave the default (Use Forum of Topic) to post the reply in forum of the topic.', 'bbpress' ) . '</li>' . 222 222 '<li>' . __( '<strong>Topic</strong> determines the parent topic that the reply belongs to.', 'bbpress' ) . '</li>' . 223 '<li>' . __( '<strong>Reply To</strong> determines the threading of the reply.', 'bbpress' ) . '</li>' . 223 224 '</ul>' 224 225 ) ); … … 301 302 $topic_id = !empty( $_POST['parent_id'] ) ? (int) $_POST['parent_id'] : 0; 302 303 $forum_id = !empty( $_POST['bbp_forum_id'] ) ? (int) $_POST['bbp_forum_id'] : bbp_get_topic_forum_id( $topic_id ); 304 $reply_to = !empty( $_POST['bbp_reply_to'] ) ? (int) $_POST['bbp_reply_to'] : 0; 303 305 304 306 // Get reply author data … … 308 310 309 311 // Formally update the reply 310 bbp_update_reply( $reply_id, $topic_id, $forum_id, $anonymous_data, $author_id, $is_edit );312 bbp_update_reply( $reply_id, $topic_id, $forum_id, $anonymous_data, $author_id, $is_edit, $reply_to ); 311 313 312 314 // Allow other fun things to happen 313 do_action( 'bbp_reply_attributes_metabox_save', $reply_id, $topic_id, $forum_id );315 do_action( 'bbp_reply_attributes_metabox_save', $reply_id, $topic_id, $forum_id, $reply_to ); 314 316 do_action( 'bbp_author_metabox_save', $reply_id, $anonymous_data ); 315 317 -
trunk/includes/admin/settings.php
r4938 r4944 170 170 'sanitize_callback' => 'intval', 171 171 'args' => array() 172 ), 173 174 // Set reply threading level 175 '_bbp_thread_replies_depth' => array( 176 'title' => __( 'Thread replies to topics', 'bbpress' ), 177 'callback' => 'bbp_admin_setting_callback_thread_replies_depth', 178 'sanitize_callback' => 'intval', 179 'args' => array() 172 180 ) 173 181 ), … … 177 185 'bbp_settings_theme_compat' => array( 178 186 179 // Replies per page setting187 // Theme package setting 180 188 '_bbp_theme_package_id' => array( 181 189 'title' => __( 'Current Package', 'bbpress' ), … … 492 500 * Allow topic tags setting field 493 501 * 494 * @since bbPress (r ####)502 * @since bbPress (r4944) 495 503 * 496 504 * @uses checked() To display the checked attribute … … 501 509 <input id="_bbp_allow_topic_tags" name="_bbp_allow_topic_tags" type="checkbox" id="_bbp_allow_topic_tags" value="1" <?php checked( bbp_allow_topic_tags( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_allow_topic_tags' ); ?> /> 502 510 <label for="_bbp_allow_topic_tags"><?php _e( 'Allow topics to have tags', 'bbpress' ); ?></label> 511 512 <?php 513 } 514 515 /** 516 * Hierarchical reply maximum depth level setting field 517 * 518 * Replies will be threaded if depth is 2 or greater 519 * 520 * @since bbPress (r4944) 521 * 522 * @uses apply_filters() Calls 'bbp_thread_replies_depth_max' to set a 523 * maximum displayed level 524 * @uses selected() To display the selected attribute 525 */ 526 function bbp_admin_setting_callback_thread_replies_depth() { 527 528 // Set maximum depth for dropdown 529 $max_depth = (int) apply_filters( 'bbp_thread_replies_depth_max', 10 ); 530 $current_depth = bbp_thread_replies_depth(); ?> 531 532 <select id="_bbp_thread_replies_depth" name="_bbp_thread_replies_depth"> 533 <?php for ( $i = 0; $i <= $max_depth; $i++ ) : ?> 534 535 <option value="<?php echo esc_attr( $i ); ?>" <?php selected( $i, $current_depth ); ?>><?php echo esc_html( $i ); ?></option> 536 537 <?php endfor; ?> 538 </select> 539 540 <label for="_bbp_thread_replies_depth"><?php _e( 'levels deep', 'bbpress' ); ?></label> 503 541 504 542 <?php -
trunk/includes/common/classes.php
r4501 r4944 260 260 } 261 261 262 /** 263 * Create hierarchical list of bbPress replies. 264 * 265 * @package bbPress 266 * @subpackage Classes 267 * 268 * @since bbPress (r4944) 269 */ 270 class BBP_Walker_Reply extends Walker { 271 272 /** 273 * @see Walker::$tree_type 274 * 275 * @since bbPress (r4944) 276 * 277 * @var string 278 */ 279 var $tree_type = 'reply'; 280 281 /** 282 * @see Walker::$db_fields 283 * 284 * @since bbPress (r4944) 285 * 286 * @var array 287 */ 288 var $db_fields = array( 289 'parent' => 'reply_to', 290 'id' => 'ID' 291 ); 292 293 /** 294 * @see Walker::start_lvl() 295 * 296 * @since bbPress (r4944) 297 * 298 * @param string $output Passed by reference. Used to append additional content 299 * @param int $depth Depth of reply 300 * @param array $args Uses 'style' argument for type of HTML list 301 */ 302 public function start_lvl( &$output = '', $depth = 0, $args = array() ) { 303 bbpress()->reply_query->reply_depth = $depth + 1; 304 305 switch ( $args['style'] ) { 306 case 'div': 307 break; 308 case 'ol': 309 echo "<ol class='bbp-threaded-replies'>\n"; 310 break; 311 case 'ul': 312 default: 313 echo "<ul class='bbp-threaded-replies'>\n"; 314 break; 315 } 316 } 317 318 /** 319 * @see Walker::end_lvl() 320 * 321 * @since bbPress (r4944) 322 * 323 * @param string $output Passed by reference. Used to append additional content 324 * @param int $depth Depth of reply 325 * @param array $args Will only append content if style argument value is 'ol' or 'ul' 326 */ 327 public function end_lvl( &$output = '', $depth = 0, $args = array() ) { 328 bbpress()->reply_query->reply_depth = (int) $depth + 1; 329 330 switch ( $args['style'] ) { 331 case 'div': 332 break; 333 case 'ol': 334 echo "</ol>\n"; 335 break; 336 case 'ul': 337 default: 338 echo "</ul>\n"; 339 break; 340 } 341 } 342 343 /** 344 * @since bbPress (r4944) 345 */ 346 public function display_element( $element = false, &$children_elements = array(), $max_depth = 0, $depth = 0, $args = array(), &$output = '' ) { 347 348 if ( empty( $element ) ) 349 return; 350 351 // Get element's id 352 $id_field = $this->db_fields['id']; 353 $id = $element->$id_field; 354 355 // Display element 356 parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); 357 358 // If we're at the max depth and the current element still has children, loop over those 359 // and display them at this level to prevent them being orphaned to the end of the list. 360 if ( ( $max_depth <= (int) $depth + 1 ) && isset( $children_elements[$id] ) ) { 361 foreach ( $children_elements[$id] as $child ) { 362 $this->display_element( $child, $children_elements, $max_depth, $depth, $args, $output ); 363 } 364 unset( $children_elements[$id] ); 365 } 366 } 367 368 /** 369 * @see Walker:start_el() 370 * 371 * @since bbPress (r4944) 372 */ 373 public function start_el( &$output = '', $reply = false, $depth = 0, $args = array(), $id = 0 ) { 374 375 // Set up reply 376 $depth++; 377 bbpress()->reply_query->reply_depth = $depth; 378 bbpress()->reply_query->post = $reply; 379 bbpress()->current_reply_id = $reply->ID; 380 381 // Check for a callback and use it if specified 382 if ( !empty( $args['callback'] ) ) { 383 call_user_func( $args['callback'], $reply, $args, $depth ); 384 return; 385 } 386 387 // Style for div or list element 388 if ( 'div' === $args['style'] ) { 389 $tag = 'div'; 390 } else { 391 $tag = 'li'; 392 } ?> 393 394 <<?php echo $tag ?>> 395 396 <?php bbp_get_template_part( 'loop', 'single-reply' ); ?> 397 398 </<?php echo $tag ?>> 399 400 <?php 401 } 402 403 /** 404 * @since bbPress (r4944) 405 */ 406 public function end_el( &$output = '', $reply = false, $depth = 0, $args = array() ) { 407 408 // Check for a callback and use it if specified 409 if ( !empty( $args['end-callback'] ) ) { 410 call_user_func( $args['end-callback'], $reply, $args, $depth ); 411 return; 412 } 413 414 // Style for div or list element 415 if ( !empty( $args['style'] ) && ( 'div' === $args['style'] ) ) { 416 echo "</div>\n"; 417 } else { 418 echo "</li>\n"; 419 } 420 } 421 } 262 422 endif; // class_exists check -
trunk/includes/common/template-tags.php
r4935 r4944 1583 1583 <input type="hidden" name="bbp_reply_title" id="bbp_reply_title" value="<?php bbp_reply_title(); ?>" /> 1584 1584 <input type="hidden" name="bbp_reply_id" id="bbp_reply_id" value="<?php bbp_reply_id(); ?>" /> 1585 <input type="hidden" name="bbp_reply_to" id="bbp_reply_to" value="<?php bbp_form_reply_to(); ?>" /> 1585 1586 <input type="hidden" name="action" id="bbp_post_action" value="bbp-edit-reply" /> 1586 1587 … … 1594 1595 <input type="hidden" name="bbp_reply_title" id="bbp_reply_title" value="<?php printf( __( 'Reply To: %s', 'bbpress' ), bbp_get_topic_title() ); ?>" /> 1595 1596 <input type="hidden" name="bbp_topic_id" id="bbp_topic_id" value="<?php bbp_topic_id(); ?>" /> 1597 <input type="hidden" name="bbp_reply_to" id="bbp_reply_to" value="<?php bbp_form_reply_to(); ?>" /> 1596 1598 <input type="hidden" name="action" id="bbp_post_action" value="bbp-new-reply" /> 1597 1599 -
trunk/includes/core/actions.php
r4918 r4944 182 182 183 183 // New/Edit Reply 184 add_action( 'bbp_new_reply', 'bbp_update_reply', 10, 6);185 add_action( 'bbp_edit_reply', 'bbp_update_reply', 10, 6);184 add_action( 'bbp_new_reply', 'bbp_update_reply', 10, 7 ); 185 add_action( 'bbp_edit_reply', 'bbp_update_reply', 10, 7 ); 186 186 187 187 // Before Delete/Trash/Untrash Reply -
trunk/includes/core/options.php
r4932 r4944 35 35 '_bbp_enable_subscriptions' => 1, // Subscriptions 36 36 '_bbp_allow_topic_tags' => 1, // Topic Tags 37 '_bbp_thread_replies_depth' => 0, // Thread replies depth 37 38 '_bbp_allow_anonymous' => 0, // Allow anonymous posting 38 39 '_bbp_allow_global_access' => 1, // Users from all sites can post … … 225 226 function bbp_allow_topic_tags( $default = 1 ) { 226 227 return (bool) apply_filters( 'bbp_allow_topic_tags', (bool) get_option( '_bbp_allow_topic_tags', $default ) ); 228 } 229 230 /** 231 * Are replies threaded 232 * 233 * @since bbPress (r4944) 234 * 235 * @param bool $default Optional. Default value true 236 * @uses apply_filters() Calls 'bbp_thread_replies' with the calculated value and 237 * the thread replies depth 238 * @uses get_option() To get thread replies option 239 * @return bool Are replies threaded? 240 */ 241 function bbp_thread_replies() { 242 $depth = bbp_thread_replies_depth(); 243 $retval = (bool) ( $depth > 1 ); 244 245 return (bool) apply_filters( 'bbp_thread_replies', $retval, $depth ); 246 } 247 248 /** 249 * Maximum reply thread depth 250 * 251 * @since bbPress (r4944) 252 * 253 * @param int $default Thread replies depth 254 * @uses apply_filters() Calls 'bbp_thread_replies_depth' with the option value and 255 * the default depth 256 * @uses get_option() To get the thread replies depth 257 * @return int Thread replies depth 258 */ 259 function bbp_thread_replies_depth( $default = 1 ) { 260 return (int) apply_filters( 'bbp_thread_replies_depth', (int) get_option( '_bbp_thread_replies_depth', $default ) ); 227 261 } 228 262 -
trunk/includes/replies/functions.php
r4906 r4944 98 98 * @uses wp_insert_post() To insert the reply 99 99 * @uses do_action() Calls 'bbp_new_reply' with the reply id, topic id, forum 100 * id, anonymous data and reply author 100 * id, anonymous data, reply author, edit (false), and 101 * the reply to id 101 102 * @uses bbp_get_reply_url() To get the paginated url to the reply 102 103 * @uses wp_safe_redirect() To redirect to the reply url … … 117 118 118 119 // Define local variable(s) 119 $topic_id = $forum_id = $reply_author = $anonymous_data = 0;120 $topic_id = $forum_id = $reply_author = $anonymous_data = $reply_to = 0; 120 121 $reply_title = $reply_content = $terms = ''; 121 122 … … 195 196 } 196 197 } 198 199 /** Reply To **************************************************************/ 200 201 // Handle Reply To of the reply; $_REQUEST for non-JS submissions 202 if ( isset( $_REQUEST['bbp_reply_to'] ) ) { 203 $reply_to = (int) $_REQUEST['bbp_reply_to']; 204 } 205 206 $reply_to = bbp_get_reply_id( $reply_to ); 197 207 198 208 /** Unfiltered HTML *******************************************************/ … … 365 375 /** Update counts, etc... *********************************************/ 366 376 367 do_action( 'bbp_new_reply', $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author );377 do_action( 'bbp_new_reply', $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author, false, $reply_to ); 368 378 369 379 /** Additional Actions (After Save) ***********************************/ … … 422 432 * @uses bbp_get_reply_topic_id() To get the reply topic id 423 433 * @uses bbp_get_topic_forum_id() To get the topic forum id 434 * @uses bbp_get_reply_to() To get the reply to id 424 435 * @uses do_action() Calls 'bbp_edit_reply' with the reply id, topic id, forum 425 * id, anonymous data, reply author and bool true (for edit) 436 * id, anonymous data, reply author, bool true (for edit), 437 * and the reply to id 426 438 * @uses bbp_get_reply_url() To get the paginated url to the reply 427 439 * @uses wp_safe_redirect() To redirect to the reply url … … 501 513 502 514 $forum_id = bbp_get_topic_forum_id( $topic_id ); 515 516 /** Reply To **************************************************************/ 517 518 $reply_to = bbp_get_reply_to( $reply_id ); 503 519 504 520 // Forum exists … … 661 677 662 678 // Update counts, etc... 663 do_action( 'bbp_edit_reply', $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author , true /* Is edit */);679 do_action( 'bbp_edit_reply', $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author , true, $reply_to ); 664 680 665 681 /** Additional Actions (After Save) ***********************************/ … … 703 719 * @param int $author_id Author id 704 720 * @param bool $is_edit Optional. Is the post being edited? Defaults to false. 721 * @param int $reply_to Optional. Reply to id 705 722 * @uses bbp_get_reply_id() To get the reply id 706 723 * @uses bbp_get_topic_id() To get the topic id … … 719 736 * @uses bbp_update_reply_forum_id() To update the reply forum id 720 737 * @uses bbp_update_reply_topic_id() To update the reply topic id 738 * @uses bbp_update_reply_to() To update the reply to id 721 739 * @uses bbp_update_reply_walker() To update the reply's ancestors' counts 722 740 */ 723 function bbp_update_reply( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $author_id = 0, $is_edit = false ) {741 function bbp_update_reply( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $author_id = 0, $is_edit = false, $reply_to = 0 ) { 724 742 725 743 // Validate the ID's passed from 'bbp_new_reply' action … … 727 745 $topic_id = bbp_get_topic_id( $topic_id ); 728 746 $forum_id = bbp_get_forum_id( $forum_id ); 747 $reply_to = bbp_get_reply_id( $reply_to ); 729 748 730 749 // Bail if there is no reply … … 790 809 bbp_update_reply_forum_id( $reply_id, $forum_id ); 791 810 bbp_update_reply_topic_id( $reply_id, $topic_id ); 811 bbp_update_reply_to ( $reply_id, $reply_to ); 792 812 793 813 // Update associated topic values if this is a new reply … … 1027 1047 } 1028 1048 1049 /* 1050 * Update the reply's meta data with its reply to id 1051 * 1052 * @since bbPress (r4944) 1053 * 1054 * @param int $reply_id Reply id to update 1055 * @param int $reply_to Optional. Reply to id 1056 * @uses bbp_get_reply_id() To get the reply id 1057 * @uses update_post_meta() To update the reply to meta 1058 * @uses apply_filters() Calls 'bbp_update_reply_to' with the reply id and 1059 * and reply to id 1060 * @return bool Reply's parent reply id 1061 */ 1062 function bbp_update_reply_to( $reply_id = 0, $reply_to = 0 ) { 1063 1064 // Validation 1065 $reply_id = bbp_get_reply_id( $reply_id ); 1066 $reply_to = bbp_get_reply_id( $reply_to ); 1067 1068 // Return if no reply 1069 if ( empty( $reply_id ) ) 1070 return; 1071 1072 // Return if no reply to 1073 if ( empty( $reply_to ) ) 1074 return; 1075 1076 // Set the reply to 1077 update_post_meta( $reply_id, '_bbp_reply_to', $reply_to ); 1078 1079 return (int) apply_filters( 'bbp_update_reply_to', (int) $reply_to, $reply_id ); 1080 } 1081 1029 1082 /** 1030 1083 * Update the revision log of the reply … … 1287 1340 $freshness = $move_reply->post_date; 1288 1341 1342 // Get the reply to 1343 $parent = bbp_get_reply_to( $move_reply->ID ); 1344 1345 // Fix orphaned children 1346 $children = get_posts( array( 1347 'post_type' => bbp_get_reply_post_type(), 1348 'meta_key' => '_bbp_reply_to', 1349 'meta_value' => $move_reply->ID, 1350 ) ); 1351 foreach ( $children as $child ) 1352 bbp_update_reply_to( $child->ID, $parent ); 1353 1354 // Remove reply_to from moved reply 1355 delete_post_meta( $move_reply->ID, '_bbp_reply_to' ); 1356 1289 1357 // It is a new topic and we need to set some default metas to make 1290 1358 // the topic display in bbp_has_topics() list … … 2073 2141 return (int) $reply_position; 2074 2142 } 2143 2144 /** Hierarchical Replies ******************************************************/ 2145 2146 /** 2147 * List replies 2148 * 2149 * @since bbPress (r4944) 2150 */ 2151 function bbp_list_replies( $args = array() ) { 2152 2153 // Reset the reply depth 2154 bbpress()->reply_query->reply_depth = 0; 2155 2156 // In reply loop 2157 bbpress()->reply_query->in_the_loop = true; 2158 2159 $r = bbp_parse_args( $args, array( 2160 'walker' => null, 2161 'max_depth' => bbp_thread_replies_depth(), 2162 'style' => 'ul', 2163 'callback' => null, 2164 'end_callback' => null, 2165 'page' => 1, 2166 'per_page' => -1 2167 ), 'list_replies' ); 2168 2169 // Get replies to loop through in $_replies 2170 $walker = new BBP_Walker_Reply; 2171 $walker->paged_walk( bbpress()->reply_query->posts, $r['max_depth'], $r['page'], $r['per_page'], $r ); 2172 2173 bbpress()->max_num_pages = $walker->max_pages; 2174 bbpress()->reply_query->in_the_loop = false; 2175 } -
trunk/includes/replies/template-tags.php
r4924 r4944 69 69 70 70 // Other defaults 71 $default_reply_search = !empty( $_REQUEST['rs'] ) ? $_REQUEST['rs'] : false; 72 $default_post_parent = ( bbp_is_single_topic() ) ? bbp_get_topic_id() : 'any'; 73 $default_post_type = ( bbp_is_single_topic() && bbp_show_lead_topic() ) ? bbp_get_reply_post_type() : array( bbp_get_topic_post_type(), bbp_get_reply_post_type() ); 71 $default_reply_search = !empty( $_REQUEST['rs'] ) ? $_REQUEST['rs'] : false; 72 $default_post_parent = ( bbp_is_single_topic() ) ? bbp_get_topic_id() : 'any'; 73 $default_post_type = ( bbp_is_single_topic() && bbp_show_lead_topic() ) ? bbp_get_reply_post_type() : array( bbp_get_topic_post_type(), bbp_get_reply_post_type() ); 74 $default_thread_replies = (bool) ( bbp_is_single_topic() && bbp_thread_replies() ); 74 75 75 76 // Default query args … … 81 82 'orderby' => 'date', // Sorted by date 82 83 'order' => 'ASC', // Oldest to newest 84 'hierarchical' => $default_thread_replies, // Hierarchical replies 83 85 'ignore_sticky_posts' => true, // Stickies not supported 84 86 's' => $default_reply_search, // Maybe search … … 114 116 $r = bbp_parse_args( $args, $default, 'has_replies' ); 115 117 118 // Set posts_per_page value if replies are threaded 119 $replies_per_page = $r['posts_per_page']; 120 if ( true === $r['hierarchical'] ) { 121 $r['posts_per_page'] = -1; 122 } 123 116 124 // Get bbPress 117 125 $bbp = bbpress(); … … 121 129 122 130 // Add pagination values to query object 123 $bbp->reply_query->posts_per_page = $r ['posts_per_page'];131 $bbp->reply_query->posts_per_page = $replies_per_page; 124 132 $bbp->reply_query->paged = $r['paged']; 125 133 … … 130 138 if ( bbp_is_single_topic() ) { 131 139 $bbp->reply_query->is_single = true; 140 } 141 142 // Only add reply to if query returned results 143 if ( (int) $bbp->reply_query->found_posts ) { 144 145 // Get reply to for each reply 146 foreach ( $bbp->reply_query->posts as &$post ) { 147 148 // Check for reply post type 149 if ( bbp_get_reply_post_type() === $post->post_type ) { 150 $reply_to = bbp_get_reply_to( $post->ID ); 151 152 // Make sure it's a reply to a reply 153 if ( empty( $reply_to ) || ( bbp_get_reply_topic_id( $post->ID ) == $reply_to ) ) { 154 $reply_to = 0; 155 } 156 157 // Add reply_to to the post object so we can walk it later 158 $post->reply_to = $reply_to; 159 } 160 } 132 161 } 133 162 … … 162 191 } 163 192 164 // Add pagination to query object 165 $bbp->reply_query->pagination_links = paginate_links( 166 apply_filters( 'bbp_replies_pagination', array( 193 // Figure out total pages 194 if ( true === $r['hierarchical'] ) { 195 $walker = new BBP_Walker_Reply; 196 $total_pages = ceil( (int) $walker->get_number_of_root_elements( $bbp->reply_query->posts ) / (int) $replies_per_page ); 197 } else { 198 $total_pages = ceil( (int) $bbp->reply_query->found_posts / (int) $replies_per_page ); 199 200 // Add pagination to query object 201 $bbp->reply_query->pagination_links = paginate_links( apply_filters( 'bbp_replies_pagination', array( 167 202 'base' => $base, 168 203 'format' => '', 169 'total' => ceil( (int) $bbp->reply_query->found_posts / (int) $r['posts_per_page'] ),204 'total' => $total_pages, 170 205 'current' => (int) $bbp->reply_query->paged, 171 206 'prev_text' => is_rtl() ? '→' : '←', … … 173 208 'mid_size' => 1, 174 209 'add_args' => ( bbp_get_view_all() ) ? array( 'view' => 'all' ) : false 175 ) ) 176 ); 177 178 // Remove first page from pagination179 if ( $wp_rewrite->using_permalinks() ) {180 $bbp->reply_query->pagination_links = str_replace( $wp_rewrite->pagination_base . '/1/', '', $bbp->reply_query->pagination_links );181 } else {182 $bbp->reply_query->pagination_links = str_replace( '&paged=1', '', $bbp->reply_query->pagination_links );210 ) ) ); 211 212 // Remove first page from pagination 213 if ( $wp_rewrite->using_permalinks() ) { 214 $bbp->reply_query->pagination_links = str_replace( $wp_rewrite->pagination_base . '/1/', '', $bbp->reply_query->pagination_links ); 215 } else { 216 $bbp->reply_query->pagination_links = str_replace( '&paged=1', '', $bbp->reply_query->pagination_links ); 217 } 183 218 } 184 219 } … … 387 422 $reply_id = bbp_get_reply_id ( $reply_id ); 388 423 $topic_id = bbp_get_reply_topic_id( $reply_id ); 389 $reply_page = ceil( (int) bbp_get_reply_position( $reply_id, $topic_id ) / (int) bbp_get_replies_per_page() ); 424 425 // Hierarchical reply page 426 if ( bbp_thread_replies() ) { 427 $reply_page = 1; 428 429 // Standard reply page 430 } else { 431 $reply_page = ceil( (int) bbp_get_reply_position( $reply_id, $topic_id ) / (int) bbp_get_replies_per_page() ); 432 } 433 390 434 $reply_hash = '#post-' . $reply_id; 391 435 $topic_link = bbp_get_topic_permalink( $topic_id, $redirect_to ); … … 1378 1422 1379 1423 /** 1424 * Output the reply's ancestor reply id 1425 * 1426 * @since bbPress (r4944) 1427 * 1428 * @param int $reply_id Optional. Reply id 1429 * @uses bbp_get_reply_ancestor_id() To get the reply's ancestor id 1430 */ 1431 function bbp_reply_ancestor_id( $reply_id = 0 ) { 1432 echo bbp_get_reply_ancestor_id( $reply_id ); 1433 } 1434 /** 1435 * Return the reply's ancestor reply id 1436 * 1437 * @since bbPress (r4944) 1438 * 1439 * @param in $reply_id Reply id 1440 * @uses bbp_get_reply_id() To get the reply id 1441 */ 1442 function bbp_get_reply_ancestor_id( $reply_id = 0 ) { 1443 1444 // Validation 1445 $reply_id = bbp_get_reply_id( $reply_id ); 1446 if ( empty( $reply_id ) ) 1447 return false; 1448 1449 // Find highest reply ancestor 1450 $ancestor_id = $reply_id; 1451 while ( $parent_id = bbp_get_reply_to( $ancestor_id ) ) { 1452 if ( empty( $parent_id ) || ( $parent_id === $ancestor_id ) || ( bbp_get_reply_topic_id( $reply_id ) === $parent_id ) || ( $parent_id == $reply_id ) ) { 1453 break; 1454 } 1455 $ancestor_id = $parent_id; 1456 } 1457 1458 return (int) $ancestor_id; 1459 } 1460 1461 /** 1462 * Output the reply to id of a reply 1463 * 1464 * @since bbPress (r4944) 1465 * 1466 * @param int $reply_id Optional. Reply id 1467 * @uses bbp_get_reply_to() To get the reply to id 1468 */ 1469 function bbp_reply_to( $reply_id = 0 ) { 1470 echo bbp_get_reply_to( $reply_id ); 1471 } 1472 /** 1473 * Return the reply to id of a reply 1474 * 1475 * @since bbPress (r4944) 1476 * 1477 * @param int $reply_id Optional. Reply id 1478 * @uses bbp_get_reply_id() To get the reply id 1479 * @uses get_post_meta() To get the reply to id 1480 * @uses apply_filters() Calls 'bbp_get_reply_to' with the reply to id and 1481 * reply id 1482 * @return int Reply's reply to id 1483 */ 1484 function bbp_get_reply_to( $reply_id = 0 ) { 1485 1486 // Assume there is no reply_to set 1487 $reply_to = 0; 1488 1489 // Check that reply_id is valid 1490 if ( $reply_id = bbp_get_reply_id( $reply_id ) ) 1491 1492 // Get reply_to value 1493 $reply_to = (int) get_post_meta( $reply_id, '_bbp_reply_to', true ); 1494 1495 return (int) apply_filters( 'bbp_get_reply_to', $reply_to, $reply_id ); 1496 } 1497 1498 /** 1499 * Output the link for the reply to 1500 * 1501 * @since bbPress (r4944) 1502 * 1503 * @param array $args 1504 * @uses bbp_get_reply_to_link() To get the reply to link 1505 */ 1506 function bbp_reply_to_link( $args = array() ) { 1507 echo bbp_get_reply_to_link( $args ); 1508 } 1509 1510 /** 1511 * Return the link for a reply to a reply 1512 * 1513 * @since bbPress (r4944) 1514 * 1515 * @param array $args Arguments 1516 * @uses bbp_current_user_can_access_create_reply_form() To check permissions 1517 * @uses bbp_get_reply_id() To validate the reply id 1518 * @uses bbp_get_reply() To get the reply 1519 * @uses apply_filters() Calls 'bbp_get_reply_to_link' with the formatted link, 1520 * the arguments array, and the reply 1521 * @return string Link for a reply to a reply 1522 */ 1523 function bbp_get_reply_to_link( $args = array() ) { 1524 1525 // Parse arguments against default values 1526 $r = bbp_parse_args( $args, array( 1527 'id' => 0, 1528 'link_before' => '', 1529 'link_after' => '', 1530 'reply_text' => __( 'Reply', 'bbpress' ), 1531 'depth' => 0, 1532 'add_below' => 'post', 1533 'respond_id' => 'new-reply-' . bbp_get_topic_id(), 1534 ), 'get_reply_to_link' ); 1535 1536 $reply = bbp_get_reply( bbp_get_reply_id( (int) $r['id'] ) ); 1537 1538 // Bail if no reply or user cannot reply 1539 if ( empty( $reply ) || ! bbp_current_user_can_access_create_reply_form() ) 1540 return; 1541 1542 // Build the URI and return value 1543 $uri = remove_query_arg( array( 'bbp_reply_to' ) ); 1544 $uri = add_query_arg( array( 'bbp_reply_to' => $reply->ID ) ); 1545 $uri = esc_url( wp_nonce_url( $uri, 'respond_id_' . $reply->ID ) ); 1546 $uri = $uri . '#new-post'; 1547 $onclick = 'return addReply.moveForm("' . $r['add_below'] . '-' . $reply->ID . '","' . $reply->ID . '","' . $r['respond_id'] . '","' . $reply->post_parent . '")'; 1548 $r['uri'] = $uri; 1549 $retval = $r['link_before'] . '<a href="' . $r['uri'] . '" class="bbp-reply-to-link" onclick=' . "'{$onclick}' >" . $r['reply_text'] . '</a>' . $r['link_after']; 1550 1551 return apply_filters( 'bbp_get_reply_to_link', $retval, $r, $args ); 1552 } 1553 1554 /** 1555 * Output the reply to a reply cancellation link 1556 * 1557 * @since bbPress (r4944) 1558 * 1559 * @uses bbp_get_cancel_reply_to_link() To get the reply cancellation link 1560 */ 1561 function bbp_cancel_reply_to_link( $text = '' ) { 1562 echo bbp_get_cancel_reply_to_link( $text ); 1563 } 1564 /** 1565 * Return the cancellation link for a reply to a reply 1566 * 1567 * @since bbPress (r4944) 1568 * 1569 * @param string $text The cancel text 1570 * @uses apply_filters() Calls 'bbp_get_cancel_reply_to_link' with the cancellation 1571 * link and the cancel text 1572 * @return string The cancellation link 1573 */ 1574 function bbp_get_cancel_reply_to_link( $text = '' ) { 1575 1576 // Bail if not hierarchical or editing a reply 1577 if ( ! bbp_thread_replies() || bbp_is_reply_edit() ) { 1578 return; 1579 } 1580 1581 // Set default text 1582 if ( empty( $text ) ) { 1583 $text = __( 'Cancel', 'bbpress' ); 1584 } 1585 1586 $reply_to = isset( $_GET['bbp_reply_to'] ) ? (int) $_GET['bbp_reply_to'] : 0; 1587 1588 // Set visibility 1589 $style = !empty( $reply_to ) ? '' : ' style="display:none;"'; 1590 $link = esc_url( remove_query_arg( array( 'bbp_reply_to', '_wpnonce' ) ) ) . '#post-' . $reply_to; 1591 $retval = '<a rel="nofollow" id="bbp-cancel-reply-to-link" href="' . $link . '"' . $style . '>' . $text . '</a>'; 1592 1593 return apply_filters( 'bbp_get_cancel_reply_to_link', $retval, $link, $text ); 1594 } 1595 1596 /** 1380 1597 * Output the numeric position of a reply within a topic 1381 1598 * … … 1517 1734 'trash' => bbp_get_reply_trash_link( $r ), 1518 1735 'spam' => bbp_get_reply_spam_link ( $r ), 1736 'reply' => bbp_get_reply_to_link ( $r ) 1519 1737 ), $r['id'] ); 1520 1738 } … … 2012 2230 $total = bbp_number_format( $total_int ); 2013 2231 2232 // We are threading replies 2233 if ( bbp_thread_replies() ) { 2234 $walker = new BBP_Walker_Reply; 2235 $threads = (int) $walker->get_number_of_root_elements( $bbp->reply_query->posts ); 2236 2237 // Adjust for topic 2238 $threads--; 2239 $retstr = sprintf( _n( 'Viewing %1$s reply thread', 'Viewing %1$s reply threads', $threads, 'bbbpress' ), bbp_number_format( $threads ) ); 2240 2014 2241 // We are not including the lead topic 2015 if ( bbp_show_lead_topic() ) {2242 } elseif ( bbp_show_lead_topic() ) { 2016 2243 2017 2244 // Several replies in a topic with a single page … … 2109 2336 2110 2337 /** 2338 * Output the value of the reply to field 2339 * 2340 * @since bbPress (r4944) 2341 * 2342 * @uses bbp_get_form_reply_to() To get value of the reply to field 2343 */ 2344 function bbp_form_reply_to() { 2345 echo bbp_get_form_reply_to(); 2346 } 2347 2348 /** 2349 * Return the value of reply to field 2350 * 2351 * @since bbPress (r4944) 2352 * 2353 * @uses bbp_get_reply_id() To validate the reply to 2354 * @uses apply_filters() Calls 'bbp_get_form_reply_to' with the reply to 2355 * @return string Value of reply to field 2356 */ 2357 function bbp_get_form_reply_to() { 2358 2359 // Set initial value 2360 $reply_to = 0; 2361 2362 // Get $_REQUEST data 2363 if ( isset( $_REQUEST['bbp_reply_to'] ) ) { 2364 $reply_to = (int) $_REQUEST['bbp_reply_to']; 2365 } 2366 2367 // If empty, get from meta 2368 if ( empty( $reply_to ) ) { 2369 $reply_to = bbp_get_reply_to(); 2370 } 2371 2372 // Validate 2373 $reply_to = bbp_get_reply_id( $reply_to ); 2374 2375 return (int) apply_filters( 'bbp_get_form_reply_to', $reply_to ); 2376 } 2377 2378 /** 2111 2379 * Output checked value of reply log edit field 2112 2380 * -
trunk/includes/topics/functions.php
r4903 r4944 1260 1260 bbp_update_reply_forum_id( $reply->ID, bbp_get_topic_forum_id( $destination_topic->ID ) ); 1261 1261 1262 // Adjust reply to values 1263 $reply_to = bbp_get_reply_to( $reply->ID ); 1264 if ( empty( $reply_to ) ) { 1265 bbp_update_reply_to( $reply->ID, $source_topic->ID ); 1266 } 1267 1262 1268 // Do additional actions per merged reply 1263 1269 do_action( 'bbp_merged_topic_reply', $reply->ID, $destination_topic->ID ); … … 1593 1599 } 1594 1600 1601 // Save reply ids 1602 $reply_ids = array(); 1603 1595 1604 // Change the post_parent of each reply to the destination topic id 1596 1605 foreach ( $replies as $reply ) { … … 1612 1621 wp_update_post( $postarr ); 1613 1622 1623 // Gather reply ids 1624 $reply_ids[] = $reply->ID; 1625 1614 1626 // Adjust reply meta values 1615 1627 bbp_update_reply_topic_id( $reply->ID, $destination_topic->ID ); 1616 1628 bbp_update_reply_forum_id( $reply->ID, bbp_get_topic_forum_id( $destination_topic->ID ) ); 1617 1629 1630 // Adjust reply to values 1631 $reply_to = bbp_get_reply_to( $reply->ID ); 1632 1633 // Not a reply to a reply that moved over 1634 if ( !in_array( $reply_to, $reply_ids ) ) { 1635 bbp_update_reply_to( $reply->ID, 0 ); 1636 } 1637 1638 // New topic from reply can't be a reply to 1639 if ( ( $from_reply->ID == $destination_topic->ID && $from_reply->ID == $reply_to ) ) { 1640 bbp_update_reply_to( $reply->ID, 0 ); 1641 } 1642 1618 1643 // Do additional actions per split reply 1619 1644 do_action( 'bbp_split_topic_reply', $reply->ID, $destination_topic->ID ); 1645 } 1646 1647 // Remove reply to from new topic 1648 if ( $from_reply->ID == $destination_topic->ID ) { 1649 delete_post_meta( $from_reply->ID, '_bbp_reply_to' ); 1620 1650 } 1621 1651 -
trunk/includes/topics/template-tags.php
r4935 r4944 789 789 global $wp_rewrite; 790 790 791 // Bail if threading replies 792 if ( bbp_thread_replies() ) { 793 return; 794 } 795 791 796 // Parse arguments against default values 792 797 $r = bbp_parse_args( $args, array( -
trunk/templates/default/bbpress-functions.php
r4872 r4944 180 180 } 181 181 182 // Topic favorite/subscribe182 // Topic-specific scripts 183 183 if ( bbp_is_single_topic() ) { 184 185 // Topic favorite/unsubscribe 184 186 wp_enqueue_script( 'bbpress-topic', $this->url . 'js/topic.js', array( 'jquery' ), $this->version ); 187 188 // Hierarchical replies 189 if ( bbp_thread_replies() ) { 190 wp_enqueue_script( 'bbpress-reply', $this->url . 'js/reply.js', array(), $this->version ); 191 } 185 192 } 186 193 -
trunk/templates/default/bbpress/form-reply.php
r4733 r4944 143 143 <?php do_action( 'bbp_theme_before_reply_form_submit_button' ); ?> 144 144 145 <?php bbp_cancel_reply_to_link(); ?> 146 145 147 <button type="submit" tabindex="<?php bbp_tab_index(); ?>" id="bbp_reply_submit" name="bbp_reply_submit" class="button submit"><?php _e( 'Submit', 'bbpress' ); ?></button> 146 148 -
trunk/templates/default/bbpress/loop-replies.php
r4733 r4944 40 40 <li class="bbp-body"> 41 41 42 <?php while ( bbp_replies() ) : bbp_the_reply();?>42 <?php if ( bbp_thread_replies() ) : ?> 43 43 44 <?php bbp_ get_template_part( 'loop', 'single-reply'); ?>44 <?php bbp_list_replies(); ?> 45 45 46 <?php endwhile; ?> 46 <?php else : ?> 47 48 <?php while ( bbp_replies() ) : bbp_the_reply(); ?> 49 50 <?php bbp_get_template_part( 'loop', 'single-reply' ); ?> 51 52 <?php endwhile; ?> 53 54 <?php endif; ?> 47 55 48 56 </li><!-- .bbp-body --> -
trunk/templates/default/css/bbpress-rtl.css
r4889 r4944 64 64 margin: 0; 65 65 padding: 0; 66 } 67 68 #bbpress-forums ul.bbp-threaded-replies { 69 margin-right: 50px; 66 70 } 67 71 … … 351 355 } 352 356 357 /* =Reply to 358 -------------------------------------------------------------- */ 359 360 #bbpress-forums div.bbp-reply-to { 361 margin-right: 130px; 362 padding: 12px 0px 12px 12px; 363 text-align: left; 364 } 365 366 #bbpress-forums div#bbp-cancel-reply-to { 367 text-align: left; 368 } 369 353 370 /* =Breadcrumb and Tags 354 371 -------------------------------------------------------------- */ -
trunk/templates/default/css/bbpress.css
r4889 r4944 65 65 padding: 0; 66 66 } 67 68 #bbpress-forums ul.bbp-threaded-replies { 69 margin-left: 50px; 70 } 67 71 68 72 #bbpress-forums li { … … 351 355 } 352 356 357 /* =Reply to 358 -------------------------------------------------------------- */ 359 360 #bbpress-forums div.bbp-reply-to { 361 margin-left: 130px; 362 padding: 12px 12px 12px 0; 363 text-align: right; 364 } 365 366 #bbpress-forums div#bbp-cancel-reply-to { 367 text-align: right; 368 } 369 353 370 /* =Breadcrumb and Tags 354 371 -------------------------------------------------------------- */
Note: See TracChangeset
for help on using the changeset viewer.