Changeset 6888 for sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php
- Timestamp:
- 03/19/2018 05:50:57 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php
r5931 r6888 69 69 // Edit quicktags for reply box 70 70 add_filter( 'bbp_get_quicktags_settings', array( $this, 'quicktags_settings' ) ); 71 72 // Limit pagination of the 'all-topics' view 73 add_filter( 'bbp_after_has_topics_parse_args', array( $this, 'has_topics_all_topics' ) ); 71 74 } 72 75 … … 143 146 ) { 144 147 $caps = array( 'do_not_allow' ); 145 } 148 } 146 149 147 150 break; … … 569 572 if ( ! in_array( $data['post_status'], array( 'pending', 'spam' ) ) ) { 570 573 return $data; 571 } 574 } 572 575 573 576 $topic_id = bbp_get_reply_topic_id( $data['ID'] ); … … 605 608 } 606 609 607 610 /** 608 611 * Remove tags from quicktags that don't work for the forums, such as img. 609 612 * 610 * @param array $settings 613 * @param array $settings quicktags settings array 611 614 * @return array 612 615 */ 613 function quicktags_settings( $settings ) {616 public function quicktags_settings( $settings ) { 614 617 615 618 $tags = explode( ',', $settings['buttons'] ); 616 619 $tags = array_diff( $tags, array('img') ); 617 620 $settings['buttons'] = implode( ',', $tags ); 618 621 619 622 return $settings; 620 623 } 624 625 /** 626 * Optimize the all-topics view by not fetching the found rows, and limiting it to 99 pages displayed. 627 * In the event the site has more than 99 pages, it's cached for a week, else a day. 628 * 629 * @link https://meta.trac.wordpress.org/ticket/3414 630 */ 631 public function has_topics_all_topics( $r ) { 632 if ( bbp_is_single_view() && 'all-topics' === bbp_get_view_id() ) { 633 if ( get_transient( __CLASS__ . '_total_all-topics' ) ) { 634 // We already know how many pages this site has. 635 $r['no_found_rows'] = true; 636 } 637 add_filter( 'bbp_topic_pagination', array( $this, 'forum_pagination_all_topics' ) ); 638 } 639 640 return $r; 641 } 642 643 public function forum_pagination_all_topics( $r ) { 644 $pages = get_transient( __CLASS__ . '_total_all-topics' ); 645 if ( ! $pages ) { 646 set_transient( __CLASS__ . '_total_all-topics', $r['total'], $r['total'] > 99 ? WEEK_IN_SECONDS : DAY_IN_SECONDS ); 647 } 648 649 $r['total'] = min( 99, $pages ); 650 651 return $r; 652 } 621 653 }
Note: See TracChangeset
for help on using the changeset viewer.