Skip to:
Content

bbPress.org

Ticket #3114: 3114.no-ajax.patch

File 3114.no-ajax.patch, 1.6 KB (added by r-a-y, 8 years ago)
  • src/includes/extend/buddypress/groups.php

     
    138138                // Map group forum activity items to groups
    139139                add_filter( 'bbp_before_record_activity_parse_args', array( $this, 'map_activity_to_group' ) );
    140140
     141                // Add no-ajax for group subscription links
     142                add_filter( 'bbp_get_user_subscribe_link', array( $this, 'no_ajax_subscription_link' ) );
     143
    141144                /** Caps **************************************************************/
    142145
    143146                // Only add these filters if inside a group forum
     
    305308                remove_filter( 'bbp_map_meta_caps', array( $this, 'map_group_forum_meta_caps' ), 99, 4 );
    306309        }
    307310
     311        /**
     312         * For subscription links in groups, add 'no-ajax' marker.
     313         *
     314         * @since 2.6.0 bbPress (rXXXX)
     315         */
     316        public function no_ajax_subscription_link( $retval ) {
     317                if ( ! bp_is_group() ) {
     318                        return $retval;
     319                }
     320
     321                $retval = str_replace( '<a href', '<a data-no-ajax="1" href', $retval );
     322                return $retval;
     323        }
     324
    308325        /** Edit ******************************************************************/
    309326
    310327        /**
  • src/templates/default/js/topic.js

     
    2626        } );
    2727
    2828        $( '#subscription-toggle' ).on( 'click', 'span a.subscription-toggle', function( e ) {
     29                if ( $( this ).data( 'no-ajax' ) ) {
     30                        return;
     31                }
     32
    2933                e.preventDefault();
    3034                bbp_ajax_call( 'subscription', $( this ).attr( 'data-topic' ), bbpTopicJS.subs_nonce, '#subscription-toggle' );
    3135        } );