Changeset 4506
- Timestamp:
- 11/24/2012 08:10:34 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/topics/template-tags.php
r4363 r4506 85 85 global $wp_rewrite; 86 86 87 /** Defaults **************************************************************/ 88 87 89 // What are the default allowed statuses (based on user caps) 88 90 if ( bbp_get_view_all() ) { … … 117 119 $default['taxonomy'] = bbp_get_topic_tag_tax_id(); 118 120 } 119 $bbp_t = bbp_parse_args( $args, $default, 'has_topics' ); 120 121 // Extract the query variables 122 extract( $bbp_t ); 121 122 /** Setup *****************************************************************/ 123 124 // Parse arguments with default values 125 $r = bbp_parse_args( $args, $default, 'has_topics' ); 123 126 124 127 // Get bbPress … … 126 129 127 130 // Call the query 128 $bbp->topic_query = new WP_Query( $ bbp_t);131 $bbp->topic_query = new WP_Query( $r ); 129 132 130 133 // Set post_parent back to 0 if originally set to 'any' 131 if ( 'any' == $ bbp_t['post_parent'] )132 $ bbp_t['post_parent'] = $post_parent = 0;134 if ( 'any' == $r['post_parent'] ) 135 $r['post_parent'] = $post_parent = 0; 133 136 134 137 // Limited the number of pages shown 135 if ( !empty( $max_num_pages ) ) 136 $bbp->topic_query->max_num_pages = $max_num_pages; 138 if ( !empty( $r['max_num_pages'] ) ) 139 $bbp->topic_query->max_num_pages = $r['max_num_pages']; 140 141 /** Stickies **************************************************************/ 137 142 138 143 // Put sticky posts at the top of the posts array 139 if ( !empty( $ show_stickies ) && $paged<= 1 ) {144 if ( !empty( $r['show_stickies'] ) && $r['paged'] <= 1 ) { 140 145 141 146 // Get super stickies and stickies in this forum 142 147 $stickies = bbp_get_super_stickies(); 143 $stickies = !empty( $ post_parent ) ? array_merge( $stickies, bbp_get_stickies( $post_parent) ) : $stickies;148 $stickies = !empty( $r['post_parent'] ) ? array_merge( $stickies, bbp_get_stickies( $r['post_parent'] ) ) : $stickies; 144 149 $stickies = array_unique( $stickies ); 145 150 … … 175 180 176 181 // If any posts have been excluded specifically, Ignore those that are sticky. 177 if ( !empty( $stickies ) && !empty( $ post__not_in) ) {178 $stickies = array_diff( $stickies, $ post__not_in);182 if ( !empty( $stickies ) && !empty( $r['post__not_in'] ) ) { 183 $stickies = array_diff( $stickies, $r['post__not_in'] ); 179 184 } 180 185 … … 223 228 224 229 // If no limit to posts per page, set it to the current post_count 225 if ( -1 == $ posts_per_page)226 $ posts_per_page= $bbp->topic_query->post_count;230 if ( -1 == $r['posts_per_page'] ) 231 $r['posts_per_page'] = $bbp->topic_query->post_count; 227 232 228 233 // Add pagination values to query object 229 $bbp->topic_query->posts_per_page = $ posts_per_page;230 $bbp->topic_query->paged = $ paged;234 $bbp->topic_query->posts_per_page = $r['posts_per_page']; 235 $bbp->topic_query->paged = $r['paged']; 231 236 232 237 // Only add pagination if query returned results … … 234 239 235 240 // Limit the number of topics shown based on maximum allowed pages 236 if ( ( !empty( $ max_num_pages) ) && $bbp->topic_query->found_posts > $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count )241 if ( ( !empty( $r['max_num_pages'] ) ) && $bbp->topic_query->found_posts > $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count ) 237 242 $bbp->topic_query->found_posts = $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count; 238 243 … … 289 294 'base' => $base, 290 295 'format' => '', 291 'total' => $ posts_per_page == $bbp->topic_query->found_posts ? 1 : ceil( (int) $bbp->topic_query->found_posts / (int) $posts_per_page),296 'total' => $r['posts_per_page'] == $bbp->topic_query->found_posts ? 1 : ceil( (int) $bbp->topic_query->found_posts / (int) $r['posts_per_page'] ), 292 297 'current' => (int) $bbp->topic_query->paged, 293 298 'prev_text' => '←', … … 297 302 298 303 // Add pagination to query object 299 $bbp->topic_query->pagination_links = paginate_links 304 $bbp->topic_query->pagination_links = paginate_links( $bbp_topic_pagination ); 300 305 301 306 // Remove first page from pagination … … 730 735 global $wp_rewrite; 731 736 732 $ defaults =array(737 $r = bbp_parse_args( $args, array( 733 738 'topic_id' => bbp_get_topic_id(), 734 739 'before' => '<span class="bbp-topic-pagination">', 735 740 'after' => '</span>', 736 ); 737 $r = bbp_parse_args( $args, $defaults, 'get_topic_pagination' ); 738 extract( $r ); 741 ), 'get_topic_pagination' ); 739 742 740 743 // If pretty permalinks are enabled, make our pagination pretty 741 if ( $wp_rewrite->using_permalinks() ) 742 $base = trailingslashit( get_permalink( $topic_id ) ) . user_trailingslashit( $wp_rewrite->pagination_base . '/%#%/' ); 743 else 744 $base = add_query_arg( 'paged', '%#%', get_permalink( $topic_id ) ); 744 if ( $wp_rewrite->using_permalinks() ) { 745 $base = trailingslashit( get_permalink( $r['topic_id'] ) ) . user_trailingslashit( $wp_rewrite->pagination_base . '/%#%/' ); 746 } else { 747 $base = add_query_arg( 'paged', '%#%', get_permalink( $r['topic_id'] ) ); 748 } 745 749 746 750 // Get total and add 1 if topic is included in the reply loop 747 $total = bbp_get_topic_reply_count( $ topic_id, true );751 $total = bbp_get_topic_reply_count( $r['topic_id'], true ); 748 752 749 753 // Bump if topic is in loop … … 775 779 776 780 // Add before and after to pagination links 777 $pagination_links = $ before . $pagination_links . $after;781 $pagination_links = $r['before'] . $pagination_links . $r['after']; 778 782 } 779 783 … … 1315 1319 */ 1316 1320 function bbp_get_topic_author_link( $args = '' ) { 1317 $defaults = array ( 1321 1322 // Parse arguments against default values 1323 $r = bbp_parse_args( $args, array( 1318 1324 'post_id' => 0, 1319 1325 'link_title' => '', … … 1322 1328 'sep' => ' ', 1323 1329 'show_role' => false 1324 ); 1325 $r = bbp_parse_args( $args, $defaults, 'get_topic_author_link' ); 1326 extract( $r ); 1330 ), 'get_topic_author_link' ); 1327 1331 1328 1332 // Used as topic_id … … 1330 1334 $topic_id = bbp_get_topic_id( $args ); 1331 1335 } else { 1332 $topic_id = bbp_get_topic_id( $ post_id);1336 $topic_id = bbp_get_topic_id( $r['post_id'] ); 1333 1337 } 1334 1338 … … 1337 1341 1338 1342 // Tweak link title if empty 1339 if ( empty( $ link_title) ) {1343 if ( empty( $r['link_title'] ) ) { 1340 1344 $link_title = sprintf( !bbp_is_topic_anonymous( $topic_id ) ? __( 'View %s\'s profile', 'bbpress' ) : __( 'Visit %s\'s website', 'bbpress' ), bbp_get_topic_author_display_name( $topic_id ) ); 1341 1345 } 1342 1346 1343 $ link_title = !empty( $link_title ) ? ' title="' . $link_title. '"' : '';1344 $author_url = bbp_get_topic_author_url( $topic_id );1345 $anonymous = bbp_is_topic_anonymous( $topic_id );1346 $author_links = array();1347 $r['link_title'] = !empty( $r['link_title'] ) ? ' title="' . $r['link_title'] . '"' : ''; 1348 $author_url = bbp_get_topic_author_url( $topic_id ); 1349 $anonymous = bbp_is_topic_anonymous( $topic_id ); 1350 $author_links = array(); 1347 1351 1348 1352 // Get avatar 1349 if ( 'avatar' == $ type || 'both' == $type) {1350 $author_links['avatar'] = bbp_get_topic_author_avatar( $topic_id, $ size);1353 if ( 'avatar' == $r['type'] || 'both' == $r['type'] ) { 1354 $author_links['avatar'] = bbp_get_topic_author_avatar( $topic_id, $r['size'] ); 1351 1355 } 1352 1356 1353 1357 // Get display name 1354 if ( 'name' == $ type || 'both' == $type) {1358 if ( 'name' == $r['type'] || 'both' == $r['type'] ) { 1355 1359 $author_links['name'] = bbp_get_topic_author_display_name( $topic_id ); 1356 1360 } 1357 1361 1358 1362 // Link class 1359 $link_class = ' class="bbp-author-' . $ type. '"';1363 $link_class = ' class="bbp-author-' . $r['type'] . '"'; 1360 1364 1361 1365 // Add links if not anonymous … … 1368 1372 } 1369 1373 1370 if ( true === $ show_role) {1374 if ( true === $r['show_role'] ) { 1371 1375 $author_link[] = bbp_get_topic_author_role( array( 'topic_id' => $topic_id ) ); 1372 1376 } 1373 1377 1374 $author_link = join( $ sep, $author_link );1378 $author_link = join( $r['sep'], $author_link ); 1375 1379 1376 1380 // No links if anonymous 1377 1381 } else { 1378 $author_link = join( $ sep, $author_links );1382 $author_link = join( $r['sep'], $author_links ); 1379 1383 } 1380 1384 … … 1510 1514 */ 1511 1515 function bbp_get_topic_author_role( $args = array() ) { 1512 $defaults = array( 1516 1517 // Parse arguments against default values 1518 $r = bbp_parse_args( $args, array( 1513 1519 'topic_id' => 0, 1514 1520 'class' => 'bbp-author-role', 1515 1521 'before' => '', 1516 1522 'after' => '' 1517 ); 1518 $args = bbp_parse_args( $args, $defaults, 'get_topic_author_role' ); 1519 extract( $args, EXTR_SKIP ); 1523 ), 'get_topic_author_role' ); 1520 1524 1521 1525 $topic_id = bbp_get_topic_id( $topic_id ); 1522 1526 $role = bbp_get_user_display_role( bbp_get_topic_author_id( $topic_id ) ); 1523 $author_role = sprintf( '%1$s<div class="%2$s">%3$s</div>%4$s', $ before, $class, $role, $after);1524 1525 return apply_filters( 'bbp_get_topic_author_role', $author_role, $ args);1527 $author_role = sprintf( '%1$s<div class="%2$s">%3$s</div>%4$s', $r['before'], $r['class'], $role, $r['after'] ); 1528 1529 return apply_filters( 'bbp_get_topic_author_role', $author_role, $r ); 1526 1530 } 1527 1531 … … 2057 2061 return; 2058 2062 2059 $defaults = array( 2063 // Parse arguments against default values 2064 $r = bbp_parse_args( $args, array( 2060 2065 'before' => '<div class="bbp-topic-tags"><p>' . __( 'Tagged:', 'bbpress' ) . ' ', 2061 2066 'sep' => ', ', 2062 2067 'after' => '</p></div>' 2063 ); 2064 $r = bbp_parse_args( $args, $defaults, 'get_topic_tag_list' ); 2065 extract( $r ); 2068 ), 'get_topic_tag_list' ); 2066 2069 2067 2070 $topic_id = bbp_get_topic_id( $topic_id ); … … 2075 2078 // If terms exist, explode them and compile the return value 2076 2079 if ( !empty( $terms ) ) { 2077 $terms = implode( $ sep, $terms );2078 $retval = $ before . $terms . $after;2080 $terms = implode( $r['sep'], $terms ); 2081 $retval = $r['before'] . $terms . $r['after']; 2079 2082 2080 2083 // No terms so return emty string … … 2085 2088 // Topic is not spam so display a clickable term list 2086 2089 } else { 2087 $retval = get_the_term_list( $topic_id, bbp_get_topic_tag_tax_id(), $ before, $sep, $after);2090 $retval = get_the_term_list( $topic_id, bbp_get_topic_tag_tax_id(), $r['before'], $r['sep'], $r['after'] ); 2088 2091 } 2089 2092 … … 2255 2258 */ 2256 2259 function bbp_get_topic_edit_link( $args = '' ) { 2257 $defaults = array ( 2260 2261 // Parse arguments against default values 2262 $r = bbp_parse_args( $args, array( 2258 2263 'id' => 0, 2259 2264 'link_before' => '', 2260 2265 'link_after' => '', 2261 2266 'edit_text' => __( 'Edit', 'bbpress' ) 2262 ); 2263 $r = bbp_parse_args( $args, $defaults, 'get_topic_edit_link' ); 2264 extract( $r ); 2265 2266 $topic = bbp_get_topic( bbp_get_topic_id( (int) $id ) ); 2267 ), 'get_topic_edit_link' ); 2268 2269 $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 2267 2270 2268 2271 // Bypass check if user has caps … … 2276 2279 2277 2280 // Get uri 2278 $uri = bbp_get_topic_edit_url( $ id);2281 $uri = bbp_get_topic_edit_url( $r['id'] ); 2279 2282 2280 2283 // Bail if no uri … … 2282 2285 return; 2283 2286 2284 $retval = $ link_before . '<a href="' . $uri . '">' . $edit_text . '</a>' . $link_after;2285 2286 return apply_filters( 'bbp_get_topic_edit_link', $retval, $ args);2287 $retval = $r['link_before'] . '<a href="' . $uri . '">' . $r['edit_text'] . '</a>' . $r['link_after']; 2288 2289 return apply_filters( 'bbp_get_topic_edit_link', $retval, $r ); 2287 2290 } 2288 2291 … … 2379 2382 function bbp_get_topic_trash_link( $args = '' ) { 2380 2383 2381 $defaults = array ( 2384 // Parse arguments against default values 2385 $r = bbp_parse_args( $args, array( 2382 2386 'id' => 0, 2383 2387 'link_before' => '', … … 2387 2391 'restore_text' => __( 'Restore', 'bbpress' ), 2388 2392 'delete_text' => __( 'Delete', 'bbpress' ) 2389 ); 2390 $r = bbp_parse_args( $args, $defaults, 'get_topic_trash_link' ); 2391 extract( $r ); 2393 ), 'get_topic_trash_link' ); 2392 2394 2393 2395 $actions = array(); 2394 $topic = bbp_get_topic( bbp_get_topic_id( (int) $ id) );2396 $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 2395 2397 2396 2398 if ( empty( $topic ) || !current_user_can( 'delete_topic', $topic->ID ) ) { … … 2399 2401 2400 2402 if ( bbp_is_topic_trash( $topic->ID ) ) { 2401 $actions['untrash'] = '<a title="' . esc_attr__( 'Restore this item from the Trash', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_topic_trash', 'sub_action' => 'untrash', 'topic_id' => $topic->ID ) ), 'untrash-' . $topic->post_type . '_' . $topic->ID ) ) . '">' . esc_html( $r estore_text) . '</a>';2403 $actions['untrash'] = '<a title="' . esc_attr__( 'Restore this item from the Trash', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_topic_trash', 'sub_action' => 'untrash', 'topic_id' => $topic->ID ) ), 'untrash-' . $topic->post_type . '_' . $topic->ID ) ) . '">' . esc_html( $r['restore_text'] ) . '</a>'; 2402 2404 } elseif ( EMPTY_TRASH_DAYS ) { 2403 $actions['trash'] = '<a title="' . esc_attr__( 'Move this item to the Trash', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_topic_trash', 'sub_action' => 'trash', 'topic_id' => $topic->ID ) ), 'trash-' . $topic->post_type . '_' . $topic->ID ) ) . '">' . esc_html( $ trash_text) . '</a>';2405 $actions['trash'] = '<a title="' . esc_attr__( 'Move this item to the Trash', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_topic_trash', 'sub_action' => 'trash', 'topic_id' => $topic->ID ) ), 'trash-' . $topic->post_type . '_' . $topic->ID ) ) . '">' . esc_html( $r['trash_text'] ) . '</a>'; 2404 2406 } 2405 2407 2406 2408 if ( bbp_is_topic_trash( $topic->ID ) || !EMPTY_TRASH_DAYS ) { 2407 $actions['delete'] = '<a title="' . esc_attr__( 'Delete this item permanently', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_topic_trash', 'sub_action' => 'delete', 'topic_id' => $topic->ID ) ), 'delete-' . $topic->post_type . '_' . $topic->ID ) ) . '" onclick="return confirm(\'' . esc_js( __( 'Are you sure you want to delete that permanently?', 'bbpress' ) ) . '\' );">' . esc_html( $ delete_text) . '</a>';2409 $actions['delete'] = '<a title="' . esc_attr__( 'Delete this item permanently', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_topic_trash', 'sub_action' => 'delete', 'topic_id' => $topic->ID ) ), 'delete-' . $topic->post_type . '_' . $topic->ID ) ) . '" onclick="return confirm(\'' . esc_js( __( 'Are you sure you want to delete that permanently?', 'bbpress' ) ) . '\' );">' . esc_html( $r['delete_text'] ) . '</a>'; 2408 2410 } 2409 2411 2410 2412 // Process the admin links 2411 $retval = $ link_before . implode( $sep, $actions ) . $link_after;2412 2413 return apply_filters( 'bbp_get_topic_trash_link', $retval, $ args);2413 $retval = $r['link_before'] . implode( $r['sep'], $actions ) . $r['link_after']; 2414 2415 return apply_filters( 'bbp_get_topic_trash_link', $retval, $r ); 2414 2416 } 2415 2417 … … 2449 2451 */ 2450 2452 function bbp_get_topic_close_link( $args = '' ) { 2451 $defaults = array ( 2453 2454 // Parse arguments against default values 2455 $r = bbp_parse_args( $args, array( 2452 2456 'id' => 0, 2453 2457 'link_before' => '', … … 2456 2460 'close_text' => _x( 'Close', 'Topic Status', 'bbpress' ), 2457 2461 'open_text' => _x( 'Open', 'Topic Status', 'bbpress' ) 2458 ); 2459 $r = bbp_parse_args( $args, $defaults, 'get_topic_close_link' ); 2460 extract( $r ); 2461 2462 $topic = bbp_get_topic( bbp_get_topic_id( (int) $id ) ); 2462 ), 'get_topic_close_link' ); 2463 2464 $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 2463 2465 2464 2466 if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) 2465 2467 return; 2466 2468 2467 $display = bbp_is_topic_open( $topic->ID ) ? $ close_text : $open_text;2469 $display = bbp_is_topic_open( $topic->ID ) ? $r['close_text'] : $r['open_text']; 2468 2470 $uri = add_query_arg( array( 'action' => 'bbp_toggle_topic_close', 'topic_id' => $topic->ID ) ); 2469 2471 $uri = esc_url( wp_nonce_url( $uri, 'close-topic_' . $topic->ID ) ); 2470 $retval = $ link_before . '<a href="' . $uri . '">' . $display . '</a>' . $link_after;2471 2472 return apply_filters( 'bbp_get_topic_close_link', $retval, $ args);2472 $retval = $r['link_before'] . '<a href="' . $uri . '">' . $display . '</a>' . $r['link_after']; 2473 2474 return apply_filters( 'bbp_get_topic_close_link', $retval, $r ); 2473 2475 } 2474 2476 … … 2510 2512 */ 2511 2513 function bbp_get_topic_stick_link( $args = '' ) { 2512 $defaults = array ( 2514 2515 // Parse argmuntes against default values 2516 $r = bbp_parse_args( $args, array( 2513 2517 'id' => 0, 2514 2518 'link_before' => '', … … 2517 2521 'unstick_text' => __( 'Unstick', 'bbpress' ), 2518 2522 'super_text' => __( 'to front', 'bbpress' ), 2519 ); 2520 $r = bbp_parse_args( $args, $defaults, 'get_topic_stick_link' ); 2521 extract( $r ); 2522 2523 $topic = bbp_get_topic( bbp_get_topic_id( (int) $id ) ); 2523 ), 'get_topic_stick_link' ); 2524 2525 $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 2524 2526 2525 2527 if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) … … 2531 2533 $stick_uri = esc_url( wp_nonce_url( $stick_uri, 'stick-topic_' . $topic->ID ) ); 2532 2534 2533 $stick_display = true == $is_sticky ? $ unstick_text : $stick_text;2535 $stick_display = true == $is_sticky ? $r['unstick_text'] : $r['stick_text']; 2534 2536 $stick_display = '<a href="' . $stick_uri . '">' . $stick_display . '</a>'; 2535 2537 … … 2538 2540 $super_uri = esc_url( wp_nonce_url( $super_uri, 'stick-topic_' . $topic->ID ) ); 2539 2541 2540 $super_display = ' (<a href="' . $super_uri . '">' . $ super_text. '</a>)';2542 $super_display = ' (<a href="' . $super_uri . '">' . $r['super_text'] . '</a>)'; 2541 2543 } else { 2542 2544 $super_display = ''; … … 2544 2546 2545 2547 // Combine the HTML into 1 string 2546 $retval = $ link_before . $stick_display . $super_display . $link_after;2547 2548 return apply_filters( 'bbp_get_topic_stick_link', $retval, $ args);2548 $retval = $r['link_before'] . $stick_display . $super_display . $r['link_after']; 2549 2550 return apply_filters( 'bbp_get_topic_stick_link', $retval, $r ); 2549 2551 } 2550 2552 … … 2581 2583 */ 2582 2584 function bbp_get_topic_merge_link( $args = '' ) { 2583 $defaults = array ( 2585 2586 // Parse arguments against default values 2587 $r = bbp_parse_args( $args, array( 2584 2588 'id' => 0, 2585 2589 'link_before' => '', 2586 2590 'link_after' => '', 2587 2591 'merge_text' => __( 'Merge', 'bbpress' ), 2588 ); 2589 $r = bbp_parse_args( $args, $defaults, 'get_topic_merge_link' ); 2590 extract( $r ); 2591 2592 $topic = bbp_get_topic( bbp_get_topic_id( (int) $id ) ); 2592 ), 'get_topic_merge_link' ); 2593 2594 $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 2593 2595 2594 2596 if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) … … 2596 2598 2597 2599 $uri = esc_url( add_query_arg( array( 'action' => 'merge' ), bbp_get_topic_edit_url( $topic->ID ) ) ); 2598 $retval = $ link_before . '<a href="' . $uri . '">' . $merge_text . '</a>' . $link_after;2600 $retval = $r['link_before'] . '<a href="' . $uri . '">' . $r['merge_text'] . '</a>' . $r['link_after']; 2599 2601 2600 2602 return apply_filters( 'bbp_get_topic_merge_link', $retval, $args ); … … 2636 2638 */ 2637 2639 function bbp_get_topic_spam_link( $args = '' ) { 2638 $defaults = array ( 2640 2641 // Parse arguments against default values 2642 $r = bbp_parse_args( $args, array( 2639 2643 'id' => 0, 2640 2644 'link_before' => '', … … 2643 2647 'spam_text' => __( 'Spam', 'bbpress' ), 2644 2648 'unspam_text' => __( 'Unspam', 'bbpress' ) 2645 ); 2646 $r = bbp_parse_args( $args, $defaults, 'get_topic_spam_link' ); 2647 extract( $r ); 2648 2649 $topic = bbp_get_topic( bbp_get_topic_id( (int) $id ) ); 2649 ), 'get_topic_spam_link' ); 2650 2651 $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 2650 2652 2651 2653 if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) 2652 2654 return; 2653 2655 2654 $display = bbp_is_topic_spam( $topic->ID ) ? $ unspam_text : $spam_text;2656 $display = bbp_is_topic_spam( $topic->ID ) ? $r['unspam_text'] : $r['spam_text']; 2655 2657 $uri = add_query_arg( array( 'action' => 'bbp_toggle_topic_spam', 'topic_id' => $topic->ID ) ); 2656 2658 $uri = esc_url( wp_nonce_url( $uri, 'spam-topic_' . $topic->ID ) ); 2657 $retval = $ link_before . '<a href="' . $uri . '">' . $display . '</a>' . $link_after;2658 2659 return apply_filters( 'bbp_get_topic_spam_link', $retval, $ args);2659 $retval = $r['link_before'] . '<a href="' . $uri . '">' . $display . '</a>' . $r['link_after']; 2660 2661 return apply_filters( 'bbp_get_topic_spam_link', $retval, $r ); 2660 2662 } 2661 2663 … … 2803 2805 function bbp_topic_type_select( $args = '' ) { 2804 2806 2805 $defaults = array ( 2807 // Parse arguments against default values 2808 $r = bbp_parse_args( $args, array( 2806 2809 'unstick_text' => __( 'Normal', 'bbpress' ), 2807 2810 'stick_text' => __( 'Sticky', 'bbpress' ), … … 2810 2813 'tab' => bbp_get_tab_index(), 2811 2814 'topic_id' => 0 2812 ); 2813 $r = bbp_parse_args( $args, $defaults, 'topic_type_select' ); 2814 extract( $r ); 2815 ), 'topic_type_select' ); 2815 2816 2816 2817 // Edit topic … … 2821 2822 2822 2823 // Post value is passed 2823 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST[ $select_id] ) ) {2824 $sticky_current = $_POST[ $select_id];2824 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST[ $r['select_id'] ] ) ) { 2825 $sticky_current = $_POST[ $r['select_id'] ]; 2825 2826 2826 2827 // Topic is super sticky … … 2837 2838 2838 2839 // Post value is passed 2839 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST[ $select_id] ) ) {2840 $sticky_current = $_POST[ $select_id];2840 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST[ $r['select_id'] ] ) ) { 2841 $sticky_current = $_POST[ $r['select_id'] ]; 2841 2842 2842 2843 // Default to unstick … … 2848 2849 // Used variables 2849 2850 $tab = !empty( $tab ) ? ' tabindex="' . $tab . '"' : ''; 2850 $select_id = esc_attr( $ select_id);2851 $select_id = esc_attr( $r['select_id'] ); 2851 2852 $sticky_statuses = array ( 2852 'unstick' => $ unstick_text,2853 'stick' => $ stick_text,2854 'super' => $ super_text,2853 'unstick' => $r['unstick_text'], 2854 'stick' => $r['stick_text'], 2855 'super' => $r['super_text'], 2855 2856 ); ?> 2856 2857 … … 2859 2860 <?php foreach ( $sticky_statuses as $sticky_status => $label ) : ?> 2860 2861 2861 <option value="<?php echo $sticky_status; ?>"<?php selected( $sticky_current, $sticky_status ); ?>><?php echo $label; ?></option>2862 <option value="<?php echo esc_attr( $sticky_status ); ?>"<?php selected( $sticky_current, $sticky_status ); ?>><?php echo esc_html( $label ); ?></option> 2862 2863 2863 2864 <?php endforeach; ?> … … 2905 2906 function bbp_get_single_topic_description( $args = '' ) { 2906 2907 2907 // Default arguments2908 $ defaults = array(2908 // Parse argmuents against default values 2909 $r = bbp_parse_args( $args, array( 2909 2910 'topic_id' => 0, 2910 2911 'before' => '<div class="bbp-template-notice info"><p class="bbp-topic-description">', 2911 2912 'after' => '</p></div>', 2912 2913 'size' => 14 2913 ); 2914 $r = bbp_parse_args( $args, $defaults, 'get_single_topic_description' ); 2915 extract( $r ); 2914 ), 'get_single_topic_description' ); 2916 2915 2917 2916 // Validate topic_id 2918 $topic_id = bbp_get_topic_id( $ topic_id);2917 $topic_id = bbp_get_topic_id( $r['topic_id'] ); 2919 2918 2920 2919 // Unhook the 'view all' query var adder … … 2922 2921 2923 2922 // Build the topic description 2924 $voice_count = bbp_get_topic_voice_count ( $topic_id ); 2925 $reply_count = bbp_get_topic_replies_link ( $topic_id ); 2926 $time_since = bbp_get_topic_freshness_link( $topic_id ); 2923 $vc_int = bbp_get_topic_voice_count ( $topic_id, true ); 2924 $voice_count = bbp_get_topic_voice_count ( $topic_id, false ); 2925 $reply_count = bbp_get_topic_replies_link ( $topic_id ); 2926 $time_since = bbp_get_topic_freshness_link( $topic_id ); 2927 2927 2928 2928 // Singular/Plural 2929 $voice_count = sprintf( _n( '%s voice', '%s voices', $v oice_count, 'bbpress' ), $voice_count );2929 $voice_count = sprintf( _n( '%s voice', '%s voices', $vc_int, 'bbpress' ), $voice_count ); 2930 2930 2931 2931 // Topic has replies 2932 2932 $last_reply = bbp_get_topic_last_active_id( $topic_id ); 2933 2933 if ( !empty( $last_reply ) ) { 2934 $last_updated_by = bbp_get_author_link( array( 'post_id' => $last_reply, 'size' => $ size) );2934 $last_updated_by = bbp_get_author_link( array( 'post_id' => $last_reply, 'size' => $r['size'] ) ); 2935 2935 $retstr = sprintf( __( 'This topic contains %1$s, has %2$s, and was last updated by %3$s %4$s.', 'bbpress' ), $reply_count, $voice_count, $last_updated_by, $time_since ); 2936 2936 … … 2948 2948 2949 2949 // Combine the elements together 2950 $retstr = $ before . $retstr . $after;2950 $retstr = $r['before'] . $retstr . $r['after']; 2951 2951 2952 2952 // Return filtered result 2953 return apply_filters( 'bbp_get_single_topic_description', $retstr, $ args);2953 return apply_filters( 'bbp_get_single_topic_description', $retstr, $r ); 2954 2954 } 2955 2955 … … 3234 3234 function bbp_get_topic_tag_description( $args = array() ) { 3235 3235 3236 $defaults = array( 3236 // Parse arguments against default values 3237 $r = bbp_parse_args( $args, array( 3237 3238 'before' => '<div class="bbp-topic-tag-description"><p>', 3238 3239 'after' => '</p></div>', 3239 3240 'tag' => '' 3240 ); 3241 $r = bbp_parse_args( $args, $defaults, 'get_topic_tag_description' ); 3242 extract( $r ); 3241 ), 'get_topic_tag_description' ); 3243 3242 3244 3243 // Get the term 3245 if ( ! empty( $ tag) ) {3246 $term = get_term_by( 'slug', $ tag, bbp_get_topic_tag_tax_id() );3244 if ( ! empty( $r['tag'] ) ) { 3245 $term = get_term_by( 'slug', $r['tag'], bbp_get_topic_tag_tax_id() ); 3247 3246 } else { 3248 $tag 3249 $ args['tag'] = $tag;3250 $term 3247 $tag = get_query_var( 'term' ); 3248 $r['tag'] = $tag; 3249 $term = get_queried_object(); 3251 3250 } 3252 3251 3253 3252 // Add before and after if description exists 3254 3253 if ( !empty( $term->description ) ) { 3255 $retval = $ before . $term->description . $after;3254 $retval = $r['before'] . $term->description . $r['after']; 3256 3255 3257 3256 // No description, no HTML … … 3260 3259 } 3261 3260 3262 return apply_filters( 'bbp_get_topic_tag_description', $retval, $ args);3261 return apply_filters( 'bbp_get_topic_tag_description', $retval, $r ); 3263 3262 } 3264 3263 … … 3287 3286 3288 3287 // Get _POST data 3289 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_topic_title'] ) ) 3288 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_topic_title'] ) ) { 3290 3289 $topic_title = $_POST['bbp_topic_title']; 3291 3290 3292 3291 // Get edit data 3293 elseif ( bbp_is_topic_edit() )3292 } elseif ( bbp_is_topic_edit() ) { 3294 3293 $topic_title = bbp_get_global_post_field( 'post_title', 'raw' ); 3295 3294 3296 3295 // No data 3297 else3296 } else { 3298 3297 $topic_title = ''; 3298 } 3299 3299 3300 3300 return apply_filters( 'bbp_get_form_topic_title', esc_attr( $topic_title ) ); … … 3323 3323 3324 3324 // Get _POST data 3325 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_topic_content'] ) ) 3325 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_topic_content'] ) ) { 3326 3326 $topic_content = $_POST['bbp_topic_content']; 3327 3327 3328 3328 // Get edit data 3329 elseif ( bbp_is_topic_edit() )3329 } elseif ( bbp_is_topic_edit() ) { 3330 3330 $topic_content = bbp_get_global_post_field( 'post_content', 'raw' ); 3331 3331 3332 3332 // No data 3333 else3333 } else { 3334 3334 $topic_content = ''; 3335 } 3335 3336 3336 3337 return apply_filters( 'bbp_get_form_topic_content', esc_textarea( $topic_content ) ); … … 3452 3453 3453 3454 // Get _POST data 3454 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_forum_id'] ) ) 3455 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_forum_id'] ) ) { 3455 3456 $topic_forum = $_POST['bbp_forum_id']; 3456 3457 3457 3458 // Get edit data 3458 elseif ( bbp_is_topic_edit() )3459 } elseif ( bbp_is_topic_edit() ) { 3459 3460 $topic_forum = bbp_get_topic_forum_id(); 3460 3461 3461 3462 // No data 3462 else3463 } else { 3463 3464 $topic_forum = 0; 3465 } 3464 3466 3465 3467 return apply_filters( 'bbp_get_form_topic_forum', esc_attr( $topic_forum ) ); … … 3546 3548 3547 3549 // Get _POST data 3548 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_log_topic_edit'] ) ) 3550 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_log_topic_edit'] ) ) { 3549 3551 $topic_revision = $_POST['bbp_log_topic_edit']; 3550 3552 3551 3553 // No data 3552 else3554 } else { 3553 3555 $topic_revision = 1; 3556 } 3554 3557 3555 3558 return apply_filters( 'bbp_get_form_topic_log_edit', checked( $topic_revision, true, false ) ); … … 3578 3581 3579 3582 // Get _POST data 3580 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_topic_edit_reason'] ) ) 3583 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_topic_edit_reason'] ) ) { 3581 3584 $topic_edit_reason = $_POST['bbp_topic_edit_reason']; 3582 3585 3583 3586 // No data 3584 else3587 } else { 3585 3588 $topic_edit_reason = ''; 3589 } 3586 3590 3587 3591 return apply_filters( 'bbp_get_form_topic_edit_reason', esc_attr( $topic_edit_reason ) );
Note: See TracChangeset
for help on using the changeset viewer.