Ticket #3114: 3114.03.patch
File 3114.03.patch, 4.6 KB (added by , 8 years ago) |
---|
-
src/includes/common/ajax.php
76 76 // Disable content sniffing in browsers that support it 77 77 send_nosniff_header(); 78 78 79 // Everything is 200 OK. 80 status_header( 200 ); 81 79 82 // Perform custom bbPress ajax 80 83 do_action( 'bbp_ajax_' . $_REQUEST['action'] ); 81 84 -
src/includes/users/template.php
1204 1204 1205 1205 $url = esc_url( wp_nonce_url( add_query_arg( $query_args, $permalink ), 'toggle-favorite_' . $topic_id ) ); 1206 1206 $sub = $is_fav ? ' class="is-favorite"' : ''; 1207 $html = sprintf( '%s<span id="favorite-%d" %s><a href="%s" class="favorite-toggle" data-topic="%d" >%s</a></span>%s', $r['before'], $topic_id, $sub, $url, $topic_id, $text, $r['after'] );1207 $html = sprintf( '%s<span id="favorite-%d" %s><a href="%s" class="favorite-toggle" data-topic="%d" data-bbp-nonce="%s">%s</a></span>%s', $r['before'], $topic_id, $sub, $url, $topic_id, wp_create_nonce( 'toggle-favorite_' . $topic_id ), $text, $r['after'] ); 1208 1208 1209 1209 // Initial output is wrapped in a span, ajax output is hooked to this 1210 1210 if ( ! empty( $wrap ) ) { … … 1412 1412 1413 1413 $url = esc_url( wp_nonce_url( add_query_arg( $query_args, $permalink ), 'toggle-subscription_' . $forum_id ) ); 1414 1414 $sub = $is_subscribed ? ' class="is-subscribed"' : ''; 1415 $html = sprintf( '%s<span id="subscribe-%d" %s><a href="%s" class="subscription-toggle" data-forum="%d" >%s</a></span>%s', $r['before'], $forum_id, $sub, $url, $forum_id, $text, $r['after'] );1415 $html = sprintf( '%s<span id="subscribe-%d" %s><a href="%s" class="subscription-toggle" data-forum="%d" data-bbp-nonce="%s">%s</a></span>%s', $r['before'], $forum_id, $sub, $url, $forum_id, wp_create_nonce( 'toggle-subscription_' . $forum_id ), $text, $r['after'] ); 1416 1416 1417 1417 // Initial output is wrapped in a span, ajax output is hooked to this 1418 1418 if ( ! empty( $wrap ) ) { … … 1448 1448 1449 1449 $url = esc_url( wp_nonce_url( add_query_arg( $query_args, $permalink ), 'toggle-subscription_' . $topic_id ) ); 1450 1450 $sub = $is_subscribed ? ' class="is-subscribed"' : ''; 1451 $html = sprintf( '%s<span id="subscribe-%d" %s><a href="%s" class="subscription-toggle" data-topic="%d" >%s</a></span>%s', $r['before'], $topic_id, $sub, $url, $topic_id, $text, $r['after'] );1451 $html = sprintf( '%s<span id="subscribe-%d" %s><a href="%s" class="subscription-toggle" data-topic="%d" data-bbp-nonce="%s">%s</a></span>%s', $r['before'], $topic_id, $sub, $url, $topic_id, wp_create_nonce( 'toggle-subscription_' . $topic_id ), $text, $r['after'] ); 1452 1452 1453 1453 // Initial output is wrapped in a span, ajax output is hooked to this 1454 1454 if ( ! empty( $wrap ) ) { -
src/templates/default/js/forum.js
21 21 } 22 22 23 23 $( '#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 24 26 e.preventDefault(); 25 bbp_ajax_call( 'forum_subscription', $( this ).attr( 'data-forum' ), bbpForumJS.subs_nonce, '#subscription-toggle' );27 bbp_ajax_call( 'forum_subscription', $( this ).attr( 'data-forum' ), nonce, '#subscription-toggle' ); 26 28 } ); 27 29 } ); -
src/templates/default/js/topic.js
21 21 } 22 22 23 23 $( '#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 24 26 e.preventDefault(); 25 bbp_ajax_call( 'favorite', $( this ).attr( 'data-topic' ), bbpTopicJS.fav_nonce, '#favorite-toggle' );27 bbp_ajax_call( 'favorite', $( this ).attr( 'data-topic' ), nonce, '#favorite-toggle' ); 26 28 } ); 27 29 28 30 $( '#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 29 33 e.preventDefault(); 30 bbp_ajax_call( 'subscription', $( this ).attr( 'data-topic' ), bbpTopicJS.subs_nonce, '#subscription-toggle' );34 bbp_ajax_call( 'subscription', $( this ).attr( 'data-topic' ), nonce, '#subscription-toggle' ); 31 35 } ); 32 36 33 37 $( '.bbp-alert-outer' ).on( 'click', '.bbp-alert-close', function( e ) {