Skip to:
Content

bbPress.org

Changeset 4809


Ignore:
Timestamp:
03/15/2013 10:07:35 AM (13 years ago)
Author:
johnjamesjacoby
Message:

Hide super sticky related output from group forums. Props imath. Fixes #2227.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/extend/buddypress/group.php

    r4791 r4809  
    33/**
    44 * bbPress BuddyPress Group Extension Class
     5 *
     6 * This file is responsible for connecting bbPress to BuddyPress's Groups
     7 * Component. It's a great example of how to perform both simple and advanced
     8 * techniques to manipulate bbPress's default output.
    59 *
    610 * @package bbPress
     
    628632                case 'page' :
    629633
     634                    // Strip the super stickies from topic query
     635                    add_filter( 'bbp_get_super_stickies',                 array( $this, 'no_super_stickies'  ), 10, 1 );
     636
     637                    // Unset the super sticky option on topic form
     638                    add_filter( 'bbp_after_topic_type_select_parse_args', array( $this, 'unset_super_sticky' ), 10, 1 );
     639
    630640                    // Query forums and show them if they exist
    631641                    if ( bbp_forums() ) :
     
    653663                case $this->topic_slug :
    654664
     665                    // hide the 'to front' admin links
     666                    add_filter( 'bbp_get_topic_stick_link', array( $this, 'hide_super_sticky_admin_link' ), 10, 2 );
     667
    655668                    // Get the topic
    656669                    bbp_has_topics( array(
    657670                        'name'           => bp_action_variable( $offset + 1 ),
    658                         'posts_per_page' => 1
     671                        'posts_per_page' => 1,
     672                        'show_stickies'  => false
    659673                    ) );
    660674
     
    676690                    // Topic edit
    677691                    if ( bp_action_variable( $offset + 2 ) == bbp_get_edit_rewrite_id() ) :
     692
     693                        // Unset the super sticky link on edit topic template
     694                        add_filter( 'bbp_after_topic_type_select_parse_args', array( $this, 'unset_super_sticky' ), 10, 1 );
    678695
    679696                        // Set the edit switches
     
    763780        // Allow actions immediately after group forum output
    764781        do_action( 'bbp_after_group_forum_display' );
     782    }
     783
     784    /** Super sticky filters ***************************************************/
     785
     786    /**
     787     * Strip super stickies from the topic query
     788     *
     789     * @since bbPress (r4810)
     790     * @access private
     791     * @param array $super the super sticky post ID's
     792     * @return array (empty)
     793     */
     794    public function no_super_stickies( $super = array() ) {
     795        $super = array();
     796        return $super;
     797    }
     798
     799    /**
     800     * Unset the type super sticky from topic type
     801     *
     802     * @since bbPress (r4810)
     803     * @access private
     804     * @param array $args
     805     * @return array $args without the to-front link
     806     */
     807    public function unset_super_sticky( $args = array() ) {
     808        unset( $args['super_text'] );
     809        return $args;
     810    }
     811
     812    /**
     813     * Ugly preg_replace to hide the to front admin link
     814     *
     815     * @since bbPress (r4810)
     816     * @access private
     817     * @param string $retval
     818     * @param array $args
     819     * @return string $retval without the to-front link
     820     */
     821    public function hide_super_sticky_admin_link( $retval = '', $args = array() ) {
     822        if ( strpos( $retval, '(' ) ) {
     823            $retval = preg_replace( '/(\(.+?)+(\))/i', '', $retval );
     824        }
     825
     826        return $retval;
    765827    }
    766828
Note: See TracChangeset for help on using the changeset viewer.