Changeset 5443 for trunk/src/includes/topics/template.php
- Timestamp:
- 07/11/2014 09:57:54 PM (12 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/topics/template.php (modified) (52 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/topics/template.php
r5434 r5443 145 145 146 146 // Other defaults 147 $default_topic_search = ! empty( $_REQUEST['ts'] ) ? $_REQUEST['ts'] : false;147 $default_topic_search = ! empty( $_REQUEST['ts'] ) ? $_REQUEST['ts'] : false; 148 148 $default_show_stickies = (bool) ( bbp_is_single_forum() || bbp_is_topic_archive() ) && ( false === $default_topic_search ); 149 149 $default_post_parent = bbp_is_single_forum() ? bbp_get_forum_id() : 'any'; … … 211 211 212 212 // Limited the number of pages shown 213 if ( ! empty( $r['max_num_pages'] ) ) {213 if ( ! empty( $r['max_num_pages'] ) ) { 214 214 $bbp->topic_query->max_num_pages = $r['max_num_pages']; 215 215 } … … 218 218 219 219 // Put sticky posts at the top of the posts array 220 if ( ! empty( $r['show_stickies'] ) && $r['paged'] <= 1 ) {220 if ( ! empty( $r['show_stickies'] ) && $r['paged'] <= 1 ) { 221 221 222 222 // Get super stickies and stickies in this forum … … 224 224 225 225 // Get stickies for current forum 226 if ( ! empty( $r['post_parent'] ) ) {226 if ( ! empty( $r['post_parent'] ) ) { 227 227 $stickies = array_merge( $stickies, bbp_get_stickies( $r['post_parent'] ) ); 228 228 } … … 232 232 233 233 // We have stickies 234 if ( is_array( $stickies ) && ! empty( $stickies ) ) {234 if ( is_array( $stickies ) && ! empty( $stickies ) ) { 235 235 236 236 // Start the offset at -1 so first sticky is at correct 0 offset … … 273 273 274 274 // If any posts have been excluded specifically, Ignore those that are sticky. 275 if ( ! empty( $stickies ) && !empty( $r['post__not_in'] ) ) {275 if ( ! empty( $stickies ) && ! empty( $r['post__not_in'] ) ) { 276 276 $stickies = array_diff( $stickies, $r['post__not_in'] ); 277 277 } 278 278 279 279 // Fetch sticky posts that weren't in the query results 280 if ( ! empty( $stickies ) ) {280 if ( ! empty( $stickies ) ) { 281 281 282 282 // Query to use in get_posts to get sticky posts … … 311 311 // Get all stickies 312 312 $sticky_posts = get_posts( $sticky_query ); 313 if ( ! empty( $sticky_posts ) ) {313 if ( ! empty( $sticky_posts ) ) { 314 314 315 315 // Get a count of the visible stickies … … 343 343 344 344 // Limit the number of topics shown based on maximum allowed pages 345 if ( ( ! empty( $r['max_num_pages'] ) ) && $bbp->topic_query->found_posts > $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count ) {345 if ( ( ! empty( $r['max_num_pages'] ) ) && $bbp->topic_query->found_posts > $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count ) { 346 346 $bbp->topic_query->found_posts = $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count; 347 347 } … … 490 490 491 491 // Easy empty checking 492 if ( ! empty( $topic_id ) && is_numeric( $topic_id ) ) {492 if ( ! empty( $topic_id ) && is_numeric( $topic_id ) ) { 493 493 $bbp_topic_id = $topic_id; 494 494 495 495 // Currently inside a topic loop 496 } elseif ( ! empty( $bbp->topic_query->in_the_loop ) && isset( $bbp->topic_query->post->ID ) ) {496 } elseif ( ! empty( $bbp->topic_query->in_the_loop ) && isset( $bbp->topic_query->post->ID ) ) { 497 497 $bbp_topic_id = $bbp->topic_query->post->ID; 498 498 499 499 // Currently inside a search loop 500 } elseif ( ! empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_topic( $bbp->search_query->post->ID ) ) {500 } elseif ( ! empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_topic( $bbp->search_query->post->ID ) ) { 501 501 $bbp_topic_id = $bbp->search_query->post->ID; 502 502 503 503 // Currently viewing/editing a topic, likely alone 504 } elseif ( ( bbp_is_single_topic() || bbp_is_topic_edit() ) && ! empty( $bbp->current_topic_id ) ) {504 } elseif ( ( bbp_is_single_topic() || bbp_is_topic_edit() ) && ! empty( $bbp->current_topic_id ) ) { 505 505 $bbp_topic_id = $bbp->current_topic_id; 506 506 … … 600 600 601 601 // Use the redirect address 602 if ( ! empty( $redirect_to ) ) {602 if ( ! empty( $redirect_to ) ) { 603 603 $topic_permalink = esc_url_raw( $redirect_to ); 604 604 … … 674 674 // Set root text to page title 675 675 $page = bbp_get_page_by_path( bbp_get_topic_archive_slug() ); 676 if ( ! empty( $page ) ) {676 if ( ! empty( $page ) ) { 677 677 $title = get_the_title( $page->ID ); 678 678 … … 770 770 } 771 771 772 if ( ! empty( $length ) && ( $excerpt_length > $length ) ) {772 if ( ! empty( $length ) && ( $excerpt_length > $length ) ) { 773 773 $excerpt = substr( $excerpt, 0, $length - 1 ); 774 774 $excerpt .= '…'; … … 808 808 809 809 // 4 days, 4 hours ago 810 if ( ! empty( $humanize ) ) {811 $gmt_s = ! empty( $gmt ) ? 'U' : 'G';810 if ( ! empty( $humanize ) ) { 811 $gmt_s = ! empty( $gmt ) ? 'U' : 'G'; 812 812 $date = get_post_time( $gmt_s, $gmt, $topic_id ); 813 813 $time = false; // For filter below … … 885 885 886 886 // Bump if topic is in loop 887 if ( ! bbp_show_lead_topic() ) {887 if ( ! bbp_show_lead_topic() ) { 888 888 $total++; 889 889 } … … 903 903 // Add pagination to query object 904 904 $pagination_links = paginate_links( $pagination ); 905 if ( ! empty( $pagination_links ) ) {905 if ( ! empty( $pagination_links ) ) { 906 906 907 907 // Remove first page from pagination … … 977 977 $revision_log = bbp_get_topic_raw_revision_log( $topic_id ); 978 978 979 if ( empty( $topic_id ) || empty( $revision_log ) || ! is_array( $revision_log ) ) {979 if ( empty( $topic_id ) || empty( $revision_log ) || ! is_array( $revision_log ) ) { 980 980 return false; 981 981 } … … 1003 1003 1004 1004 $r .= "\t" . '<li id="bbp-topic-revision-log-' . esc_attr( $topic_id ) . '-item-' . esc_attr( $revision->ID ) . '" class="bbp-topic-revision-log-item">' . "\n"; 1005 if ( ! empty( $reason ) ) {1005 if ( ! empty( $reason ) ) { 1006 1006 $r .= "\t\t" . sprintf( __( 'This topic was modified %1$s by %2$s. Reason: %3$s', 'bbpress' ), esc_html( $since ), $author, esc_html( $reason ) ) . "\n"; 1007 1007 } else { … … 1115 1115 */ 1116 1116 function bbp_is_topic_open( $topic_id = 0 ) { 1117 return ! bbp_is_topic_closed( $topic_id );1117 return ! bbp_is_topic_closed( $topic_id ); 1118 1118 } 1119 1119 … … 1154 1154 $stickies = bbp_get_stickies( $forum_id ); 1155 1155 1156 if ( in_array( $topic_id, $stickies ) || ( ! empty( $check_super ) && bbp_is_topic_super_sticky( $topic_id ) ) ) {1156 if ( in_array( $topic_id, $stickies ) || ( ! empty( $check_super ) && bbp_is_topic_super_sticky( $topic_id ) ) ) { 1157 1157 return true; 1158 1158 } … … 1242 1242 $retval = false; 1243 1243 1244 if ( ! bbp_get_topic_author_id( $topic_id ) ) {1244 if ( ! bbp_get_topic_author_id( $topic_id ) ) { 1245 1245 $retval = true; 1246 1246 … … 1292 1292 $topic_id = bbp_get_topic_id( $topic_id ); 1293 1293 1294 if ( ! bbp_is_topic_anonymous( $topic_id ) ) {1294 if ( ! bbp_is_topic_anonymous( $topic_id ) ) { 1295 1295 $author = get_the_author_meta( 'display_name', bbp_get_topic_author_id( $topic_id ) ); 1296 1296 } else { … … 1363 1363 1364 1364 // Check for anonymous user 1365 if ( ! bbp_is_topic_anonymous( $topic_id ) ) {1365 if ( ! bbp_is_topic_anonymous( $topic_id ) ) { 1366 1366 1367 1367 // Get the author ID … … 1427 1427 1428 1428 $topic_id = bbp_get_topic_id( $topic_id ); 1429 if ( ! empty( $topic_id ) ) {1430 if ( ! bbp_is_topic_anonymous( $topic_id ) ) {1429 if ( ! empty( $topic_id ) ) { 1430 if ( ! bbp_is_topic_anonymous( $topic_id ) ) { 1431 1431 $author_avatar = get_avatar( bbp_get_topic_author_id( $topic_id ), $size ); 1432 1432 } else { … … 1490 1490 1491 1491 // Topic ID is good 1492 if ( ! empty( $topic_id ) ) {1492 if ( ! empty( $topic_id ) ) { 1493 1493 1494 1494 // Get some useful topic information … … 1506 1506 1507 1507 // Setup title and author_links array 1508 $link_title = ! empty( $link_title ) ? ' title="' . esc_attr( $link_title ) . '"' : '';1508 $link_title = ! empty( $link_title ) ? ' title="' . esc_attr( $link_title ) . '"' : ''; 1509 1509 $author_links = array(); 1510 1510 … … 1582 1582 1583 1583 // Check for anonymous user or non-existant user 1584 if ( ! bbp_is_topic_anonymous( $topic_id ) && bbp_user_has_profile( bbp_get_topic_author_id( $topic_id ) ) ) {1584 if ( ! bbp_is_topic_anonymous( $topic_id ) && bbp_user_has_profile( bbp_get_topic_author_id( $topic_id ) ) ) { 1585 1585 $author_url = bbp_get_user_profile_url( bbp_get_topic_author_id( $topic_id ) ); 1586 1586 } else { … … 1627 1627 1628 1628 // Not anonymous user 1629 if ( ! bbp_is_topic_anonymous( $topic_id ) ) {1629 if ( ! bbp_is_topic_anonymous( $topic_id ) ) { 1630 1630 1631 1631 // Use topic author email address 1632 1632 $user_id = bbp_get_topic_author_id( $topic_id ); 1633 1633 $user = get_userdata( $user_id ); 1634 $author_email = ! empty( $user->user_email ) ? $user->user_email : '';1634 $author_email = ! empty( $user->user_email ) ? $user->user_email : ''; 1635 1635 1636 1636 // Anonymous … … 1815 1815 if ( empty( $last_active ) ) { 1816 1816 $reply_id = bbp_get_topic_last_reply_id( $topic_id ); 1817 if ( ! empty( $reply_id ) ) {1817 if ( ! empty( $reply_id ) ) { 1818 1818 $last_active = get_post_field( 'post_date', $reply_id ); 1819 1819 } else { … … 1822 1822 } 1823 1823 1824 $last_active = ! empty( $last_active ) ? bbp_get_time_since( bbp_convert_date( $last_active ) ) : '';1824 $last_active = ! empty( $last_active ) ? bbp_get_time_since( bbp_convert_date( $last_active ) ) : ''; 1825 1825 1826 1826 // Return the time since … … 2037 2037 $reply_id = bbp_get_topic_last_reply_id( $topic_id ); 2038 2038 2039 if ( ! empty( $reply_id ) && ( $reply_id !== $topic_id ) ) {2039 if ( ! empty( $reply_id ) && ( $reply_id !== $topic_id ) ) { 2040 2040 $reply_url = bbp_get_reply_url( $reply_id ); 2041 2041 } else { … … 2079 2079 $time_since = bbp_get_topic_last_active_time( $topic_id ); 2080 2080 2081 if ( ! empty( $time_since ) ) {2081 if ( ! empty( $time_since ) ) { 2082 2082 $anchor = '<a href="' . esc_url( $link_url ) . '" title="' . esc_attr( $title ) . '">' . esc_html( $time_since ) . '</a>'; 2083 2083 } else { … … 2137 2137 2138 2138 // This forum has hidden topics 2139 if ( ! empty( $deleted ) && current_user_can( 'edit_others_replies' ) ) {2139 if ( ! empty( $deleted ) && current_user_can( 'edit_others_replies' ) ) { 2140 2140 2141 2141 // Extra text … … 2332 2332 2333 2333 // If terms exist, explode them and compile the return value 2334 if ( ! empty( $terms ) ) {2334 if ( ! empty( $terms ) ) { 2335 2335 $terms = implode( $r['sep'], $terms ); 2336 2336 $retval = $r['before'] . $terms . $r['after']; … … 2520 2520 2521 2521 // Bypass check if user has caps 2522 if ( ! current_user_can( 'edit_others_topics' ) ) {2522 if ( ! current_user_can( 'edit_others_topics' ) ) { 2523 2523 2524 2524 // User cannot edit or it is past the lock time 2525 if ( empty( $topic ) || ! current_user_can( 'edit_topic', $topic->ID ) || bbp_past_edit_lock( $topic->post_date_gmt ) ) {2525 if ( empty( $topic ) || ! current_user_can( 'edit_topic', $topic->ID ) || bbp_past_edit_lock( $topic->post_date_gmt ) ) { 2526 2526 return; 2527 2527 } … … 2648 2648 $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 2649 2649 2650 if ( empty( $topic ) || ! current_user_can( 'delete_topic', $topic->ID ) ) {2650 if ( empty( $topic ) || ! current_user_can( 'delete_topic', $topic->ID ) ) { 2651 2651 return; 2652 2652 } … … 2658 2658 } 2659 2659 2660 if ( bbp_is_topic_trash( $topic->ID ) || ! EMPTY_TRASH_DAYS ) {2660 if ( bbp_is_topic_trash( $topic->ID ) || ! empty_TRASH_DAYS ) { 2661 2661 $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' ) ) . '\' );" class="bbp-topic-delete-link">' . $r['delete_text'] . '</a>'; 2662 2662 } … … 2716 2716 $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 2717 2717 2718 if ( empty( $topic ) || ! current_user_can( 'moderate', $topic->ID ) ) {2718 if ( empty( $topic ) || ! current_user_can( 'moderate', $topic->ID ) ) { 2719 2719 return; 2720 2720 } … … 2778 2778 $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 2779 2779 2780 if ( empty( $topic ) || ! current_user_can( 'moderate', $topic->ID ) ) {2780 if ( empty( $topic ) || ! current_user_can( 'moderate', $topic->ID ) ) { 2781 2781 return; 2782 2782 } … … 2848 2848 $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 2849 2849 2850 if ( empty( $topic ) || ! current_user_can( 'moderate', $topic->ID ) ) {2850 if ( empty( $topic ) || ! current_user_can( 'moderate', $topic->ID ) ) { 2851 2851 return; 2852 2852 } … … 2906 2906 $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 2907 2907 2908 if ( empty( $topic ) || ! current_user_can( 'moderate', $topic->ID ) ) {2908 if ( empty( $topic ) || ! current_user_can( 'moderate', $topic->ID ) ) { 2909 2909 return; 2910 2910 } … … 3003 3003 $from_num = bbp_number_format( $start_num ); 3004 3004 $to_num = bbp_number_format( ( $start_num + ( $bbp->topic_query->posts_per_page - 1 ) > $bbp->topic_query->found_posts ) ? $bbp->topic_query->found_posts : $start_num + ( $bbp->topic_query->posts_per_page - 1 ) ); 3005 $total_int = (int) ! empty( $bbp->topic_query->found_posts ) ? $bbp->topic_query->found_posts : $bbp->topic_query->post_count;3005 $total_int = (int) ! empty( $bbp->topic_query->found_posts ) ? $bbp->topic_query->found_posts : $bbp->topic_query->post_count; 3006 3006 $total = bbp_number_format( $total_int ); 3007 3007 … … 3062 3062 3063 3063 // Bail if not viewing a topic 3064 if ( ! bbp_is_single_topic() ) {3064 if ( ! bbp_is_single_topic() ) { 3065 3065 return; 3066 3066 } … … 3182 3182 3183 3183 // Used variables 3184 $tab = ! empty( $r['tab'] ) ? ' tabindex="' . (int) $r['tab'] . '"' : '';3184 $tab = ! empty( $r['tab'] ) ? ' tabindex="' . (int) $r['tab'] . '"' : ''; 3185 3185 3186 3186 // Start an output buffer, we'll finish it after the select loop … … 3348 3348 // Topic has replies 3349 3349 $last_reply = bbp_get_topic_last_reply_id( $topic_id ); 3350 if ( ! empty( $last_reply ) ) {3350 if ( ! empty( $last_reply ) ) { 3351 3351 $last_updated_by = bbp_get_author_link( array( 'post_id' => $last_reply, 'size' => $r['size'] ) ); 3352 3352 $retstr = sprintf( esc_html__( '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 ); … … 3465 3465 3466 3466 // Add before and after if description exists 3467 if ( ! empty( $term->term_id ) ) {3467 if ( ! empty( $term->term_id ) ) { 3468 3468 $retval = $term->term_id; 3469 3469 … … 3509 3509 3510 3510 // Add before and after if description exists 3511 if ( ! empty( $term->name ) ) {3511 if ( ! empty( $term->name ) ) { 3512 3512 $retval = $term->name; 3513 3513 … … 3553 3553 3554 3554 // Add before and after if description exists 3555 if ( ! empty( $term->slug ) ) {3555 if ( ! empty( $term->slug ) ) { 3556 3556 $retval = $term->slug; 3557 3557 … … 3597 3597 3598 3598 // Add before and after if description exists 3599 if ( ! empty( $term->term_id ) ) {3599 if ( ! empty( $term->term_id ) ) { 3600 3600 $retval = get_term_link( $term, bbp_get_topic_tag_tax_id() ); 3601 3601 … … 3642 3642 3643 3643 // Add before and after if description exists 3644 if ( ! empty( $term->term_id ) ) {3644 if ( ! empty( $term->term_id ) ) { 3645 3645 3646 3646 $bbp = bbpress(); … … 3705 3705 3706 3706 // Add before and after if description exists 3707 if ( ! empty( $term->description ) ) {3707 if ( ! empty( $term->description ) ) { 3708 3708 $retval = $r['before'] . $term->description . $r['after']; 3709 3709 … … 3845 3845 3846 3846 // Topic exists 3847 if ( ! empty( $topic_id ) ) {3847 if ( ! empty( $topic_id ) ) { 3848 3848 3849 3849 // Topic is spammed so display pre-spam terms … … 3874 3874 3875 3875 // Set the return value 3876 $topic_tags = ( ! empty( $new_terms ) ) ? implode( ', ', $new_terms ) : '';3876 $topic_tags = ( ! empty( $new_terms ) ) ? implode( ', ', $new_terms ) : ''; 3877 3877 3878 3878 // No data
Note: See TracChangeset
for help on using the changeset viewer.