Skip to:
Content

bbPress.org

Changeset 6541


Ignore:
Timestamp:
06/13/2017 07:38:48 PM (8 years ago)
Author:
johnjamesjacoby
Message:

BuddyPress: Continuation of r6538.

  • Prefer data attributes
  • Stop passing around localized nonces

Props r-a-y. Fixes #3114.

Location:
trunk/src/templates/default
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/templates/default/bbpress-functions.php

    r6498 r6541  
    225225     * @uses bbp_is_single_forum() To check if it's the forum page
    226226     * @uses bbp_is_single_topic() To check if it's the topic page
    227      * @uses is_user_logged_in() To check if user is logged in
    228      * @uses bbp_get_current_user_id() To get the current user id
    229      * @uses bbp_get_forum_id() To get the forum id
    230      * @uses bbp_get_topic_id() To get the topic id
    231      * @uses bbp_get_favorites_permalink() To get the favorites permalink
    232      * @uses bbp_is_user_favorite() To check if the topic is in user's favorites
    233      * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
    234      * @uses bbp_is_user_subscribed() To check if the user is subscribed to topic
    235      * @uses bbp_get_topic_permalink() To get the topic permalink
    236227     * @uses wp_localize_script() To localize the script
    237228     */
     
    244235                'bbp_ajaxurl'        => bbp_get_ajax_url(),
    245236                'generic_ajax_error' => esc_html__( 'Something went wrong. Refresh your browser and try again.', 'bbpress' ),
    246                 'is_user_logged_in'  => is_user_logged_in(),
    247                 'subs_nonce'         => wp_create_nonce( 'toggle-subscription_' . get_the_ID() )
    248237            ) );
    249238
     
    254243                'bbp_ajaxurl'        => bbp_get_ajax_url(),
    255244                'generic_ajax_error' => esc_html__( 'Something went wrong. Refresh your browser and try again.', 'bbpress' ),
    256                 'is_user_logged_in'  => is_user_logged_in(),
    257                 'fav_nonce'          => wp_create_nonce( 'toggle-favorite_' .     get_the_ID() ),
    258                 'subs_nonce'         => wp_create_nonce( 'toggle-subscription_' . get_the_ID() )
    259245            ) );
    260246        }
  • trunk/src/templates/default/js/forum.js

    r6540 r6541  
    2222
    2323    $( '#subscription-toggle' ).on( 'click', 'span a.subscription-toggle', function( e ) {
    24         var nonce = ( bbpForumJS.forum_id === 0 ) ? $( this ).data( 'bbp-nonce' ) : bbpForumJS.subs_nonce;
    25 
    2624        e.preventDefault();
    27         bbp_ajax_call( 'forum_subscription', $( this ).attr( 'data-forum' ), nonce, '#subscription-toggle' );
     25        bbp_ajax_call( 'forum_subscription', $( this ).attr( 'data-forum' ), $( this ).data( 'bbp-nonce' ), '#subscription-toggle' );
    2826    } );
    2927} );
  • trunk/src/templates/default/js/topic.js

    r6540 r6541  
    2222
    2323    $( '#favorite-toggle' ).on( 'click', 'span a.favorite-toggle', function( e ) {
    24         var nonce = ( bbpTopicJS.topic_id === 0 ) ? $( this ).data( 'bbp-nonce' ) : bbpTopicJS.fav_nonce;
    25 
    2624        e.preventDefault();
    27         bbp_ajax_call( 'favorite', $( this ).attr( 'data-topic' ), nonce, '#favorite-toggle' );
     25        bbp_ajax_call( 'favorite', $( this ).attr( 'data-topic' ), $( this ).data( 'bbp-nonce' ), '#favorite-toggle' );
    2826    } );
    2927
    3028    $( '#subscription-toggle' ).on( 'click', 'span a.subscription-toggle', function( e ) {
    31         var nonce = ( bbpTopicJS.topic_id === 0 ) ? $( this ).data( 'bbp-nonce' ) : bbpTopicJS.subs_nonce;
    32 
    3329        e.preventDefault();
    34         bbp_ajax_call( 'subscription', $( this ).attr( 'data-topic' ), nonce, '#subscription-toggle' );
     30        bbp_ajax_call( 'subscription', $( this ).attr( 'data-topic' ), $( this ).data( 'bbp-nonce' ), '#subscription-toggle' );
    3531    } );
    3632
Note: See TracChangeset for help on using the changeset viewer.