Changeset 4549
- Timestamp:
- 12/06/2012 09:40:15 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/core/actions.php
r4522 r4549 270 270 * 2. Accessing private or hidden content (forums/topics/replies) 271 271 * 3. Editing forums, topics, replies, users, and tags 272 * 4. bbPress specific AJAX requests 272 273 */ 273 274 add_action( 'bbp_template_redirect', 'bbp_forum_enforce_blocked', -1 ); … … 289 290 add_action( 'bbp_template_redirect', 'bbp_favorites_handler', 1 ); 290 291 add_action( 'bbp_template_redirect', 'bbp_subscriptions_handler', 1 ); 292 add_action( 'bbp_template_redirect', 'bbp_do_ajax', 1 ); 291 293 add_action( 'bbp_template_redirect', 'bbp_check_user_edit', 10 ); 292 294 add_action( 'bbp_template_redirect', 'bbp_check_forum_edit', 10 ); -
trunk/templates/default/bbpress-functions.php
r4543 r4549 85 85 /** Scripts ***********************************************************/ 86 86 87 add_action( 'bbp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); // Enqueue theme CSS 88 add_action( 'bbp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); // Enqueue theme JS 89 add_filter( 'bbp_enqueue_scripts', array( $this, 'localize_topic_script' ) ); // Enqueue theme script localization 90 add_action( 'bbp_head', array( $this, 'head_scripts' ) ); // Output some extra JS in the <head> 91 add_action( 'wp_ajax_dim-favorite', array( $this, 'ajax_favorite' ) ); // Handles the ajax favorite/unfavorite 92 add_action( 'wp_ajax_dim-subscription', array( $this, 'ajax_subscription' ) ); // Handles the ajax subscribe/unsubscribe 93 add_action( 'wp_ajax_nopriv_dim-favorite', array( $this, 'ajax_favorite' ) ); // Handles the ajax favorite/unfavorite 94 add_action( 'wp_ajax_nopriv_dim-subscription', array( $this, 'ajax_subscription' ) ); // Handles the ajax subscribe/unsubscribe 87 add_action( 'bbp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); // Enqueue theme CSS 88 add_action( 'bbp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); // Enqueue theme JS 89 add_filter( 'bbp_enqueue_scripts', array( $this, 'localize_topic_script' ) ); // Enqueue theme script localization 90 add_action( 'bbp_head', array( $this, 'head_scripts' ) ); // Output some extra JS in the <head> 91 add_action( 'bbp_ajax_favorite', array( $this, 'ajax_favorite' ) ); // Handles the ajax favorite/unfavorite 92 add_action( 'bbp_ajax_subscription', array( $this, 'ajax_subscription' ) ); // Handles the ajax subscribe/unsubscribe 95 93 96 94 /** Template Wrappers *************************************************/ … … 179 177 // Topic favorite/subscribe 180 178 if ( bbp_is_single_topic() ) { 181 wp_enqueue_script( 'bbpress-topic', $this->url . 'js/topic.js', array( 'jquery' ), $this->version , true);179 wp_enqueue_script( 'bbpress-topic', $this->url . 'js/topic.js', array( 'jquery' ), $this->version ); 182 180 } 183 181 … … 198 196 */ 199 197 public function head_scripts() { 200 ?> 198 199 // Bail if no extra JS is needed 200 if ( ! bbp_is_single_user_edit() && ! bbp_use_wp_editor() ) 201 return; ?> 201 202 202 203 <script type="text/javascript"> 203 204 /* <![CDATA[ */ 204 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php' ); ?>';205 206 205 <?php if ( bbp_is_single_user_edit() ) : ?> 207 206 if ( window.location.hash == '#password' ) { … … 264 263 265 264 wp_localize_script( 'bbpress-topic', 'bbpTopicJS', array( 266 ' ajaxurl' => admin_url( 'admin-ajax.php', ( is_ssl() ? 'https' : 'http' )),265 'bbp_ajaxurl' => bbp_get_ajax_url(), 267 266 'generic_ajax_error' => __( 'Something went wrong. Refresh your browser and try again.', 'bbpress' ), 268 267 'is_user_logged_in' => is_user_logged_in(), -
trunk/templates/default/js/topic.js
r4543 r4549 8 8 }; 9 9 10 $.post( bbpTopicJS. ajaxurl, $data, function ( response ) {10 $.post( bbpTopicJS.bbp_ajaxurl, $data, function ( response ) { 11 11 if ( response.success ) { 12 12 $( update_selector ).html( response.content ); … … 22 22 $( '#favorite-toggle' ).on( 'click', 'span a.favorite-toggle', function( e ) { 23 23 e.preventDefault(); 24 bbp_ajax_call( ' dim-favorite', $( this ).attr( 'data-topic' ), bbpTopicJS.fav_nonce, '#favorite-toggle' );24 bbp_ajax_call( 'favorite', $( this ).attr( 'data-topic' ), bbpTopicJS.fav_nonce, '#favorite-toggle' ); 25 25 } ); 26 26 27 27 $( '#subscription-toggle' ).on( 'click', 'span a.subscription-toggle', function( e ) { 28 28 e.preventDefault(); 29 bbp_ajax_call( ' dim-subscription', $( this ).attr( 'data-topic' ), bbpTopicJS.subs_nonce, '#subscription-toggle' );29 bbp_ajax_call( 'subscription', $( this ).attr( 'data-topic' ), bbpTopicJS.subs_nonce, '#subscription-toggle' ); 30 30 } ); 31 31 } ); -
trunk/templates/default/js/topic.min.js
r4543 r4549 1 jQuery(document).ready(function(b){function a(g,d,f,c){var e={action:g,id:d,nonce:f};b.post(bbpTopicJS. ajaxurl,e,function(h){if(h.success){b(c).html(h.content)}else{if(!h.content){h.content=bbpTopicJS.generic_ajax_error}alert(h.content)}})}b("#favorite-toggle").on("click","span a.favorite-toggle",function(c){c.preventDefault();a("dim-favorite",b(this).attr("data-topic"),bbpTopicJS.fav_nonce,"#favorite-toggle")});b("#subscription-toggle").on("click","span a.subscription-toggle",function(c){c.preventDefault();a("dim-subscription",b(this).attr("data-topic"),bbpTopicJS.subs_nonce,"#subscription-toggle")})});1 jQuery(document).ready(function(b){function a(g,d,f,c){var e={action:g,id:d,nonce:f};b.post(bbpTopicJS.bbp_ajaxurl,e,function(h){if(h.success){b(c).html(h.content)}else{if(!h.content){h.content=bbpTopicJS.generic_ajax_error}alert(h.content)}})}b("#favorite-toggle").on("click","span a.favorite-toggle",function(c){c.preventDefault();a("dim-favorite",b(this).attr("data-topic"),bbpTopicJS.fav_nonce,"#favorite-toggle")});b("#subscription-toggle").on("click","span a.subscription-toggle",function(c){c.preventDefault();a("dim-subscription",b(this).attr("data-topic"),bbpTopicJS.subs_nonce,"#subscription-toggle")})});
Note: See TracChangeset
for help on using the changeset viewer.