Skip to:
Content

bbPress.org

Ticket #2227: 2227.diff

File 2227.diff, 3.2 KB (added by imath, 13 years ago)
  • includes/topics/template-tags.php

     
    28932893        $sticky_statuses = array (
    28942894                'unstick' => $r['unstick_text'],
    28952895                'stick'   => $r['stick_text'],
    2896                 'super'   => $r['super_text'],
    2897         ); ?>
     2896        );
     2897        if( !empty( $r['super_text'] ) )
     2898                $sticky_statuses['super'] = $r['super_text']; ?>
    28982899
    28992900        <select name="<?php echo $select_id; ?>" id="<?php echo $select_id; ?>"<?php echo $tab; ?>>
    29002901
  • includes/extend/buddypress/group.php

     
    626626
    627627                                case false  :
    628628                                case 'page' :
     629                               
     630                                        // strip the super stickies from topic query
     631                                        add_filter( 'bbp_get_super_stickies', array( $this, 'strip_super_stickies_from_topic_query' ), 10, 1 );
     632                                       
     633                                        // unset the choice super sticky on topic form
     634                                        add_filter( 'bbp_after_topic_type_select_parse_args', array( $this, 'unset_super_sticky' ), 10, 1 );
    629635
    630636                                        // Query forums and show them if they exist
    631637                                        if ( bbp_forums() ) :
     
    651657                                /** Single Topic **********************************************/
    652658
    653659                                case $this->topic_slug :
     660                               
     661                                        // hide the 'to front' admin links
     662                                        add_filter( 'bbp_get_topic_stick_link', array( $this, 'hide_super_sticky_admin_link' ), 10, 2 );
    654663
    655664                                        // Get the topic
    656665                                        bbp_has_topics( array(
    657666                                                'name'           => bp_action_variable( $offset + 1 ),
    658                                                 'posts_per_page' => 1
     667                                                'posts_per_page' => 1,
     668                                                'show_stickies'  => false
    659669                                        ) );
    660670
    661671                                        // If no topic, 404
     
    675685
    676686                                        // Topic edit
    677687                                        if ( bp_action_variable( $offset + 2 ) == bbp_get_edit_rewrite_id() ) :
     688                                       
     689                                                // unset the choice super sticky on edit topic template
     690                                                add_filter( 'bbp_after_topic_type_select_parse_args', array( $this, 'unset_super_sticky' ), 10, 1 );
    678691
    679692                                                // Set the edit switches
    680693                                                $wp_query->bbp_is_edit       = true;
     
    763776                // Allow actions immediately after group forum output
    764777                do_action( 'bbp_after_group_forum_display' );
    765778        }
     779       
     780        /** Super sticky filters ***************************************************/
     781       
     782        /**
     783         * Strip super stickies from the topic query
     784         *
     785         * @param array $super the super stickies
     786         * @return array (empty)
     787         */
     788        public function strip_super_stickies_from_topic_query( $super ) {
     789                return array();
     790        }
     791       
     792        /**
     793         * Unset the type super sticky from topic type
     794         *
     795         * @param array $args
     796         * @return array $args ( - the super sticky choice )
     797         */
     798        public function unset_super_sticky( $args ) {
     799                unset( $args['super_text'] );
     800                return $args;
     801        }
     802       
     803        /**
     804         * Ugly preg_replace to hide the to front admin link
     805         *
     806         * @param str $retval
     807         * @param array $args
     808         * @return str $retval ( - the to front link )
     809         */
     810        public function hide_super_sticky_admin_link( $retval, $args ) {
     811                if( strpos( $retval, '(' ) )
     812                        $retval = preg_replace( '/(\(.+?)+(\))/i', '', $retval );
     813               
     814                return $retval;
     815        }
    766816
    767817        /** Redirect Helpers ******************************************************/
    768818