Changeset 12419
- Timestamp:
- 07/30/2019 12:02:30 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/js/bp-api-request.js
r12405 r12419 17 17 18 18 // Polyfill wp.apiRequest if WordPress < 4.9 19 bp.apiRequest = wp.apiRequest || function( options ) { 20 var url = bpApiSettings.root; 21 22 if ( options.path ) { 23 url = url + options.path.replace( /^\//, '' ); 19 bp.apiRequest = function( options ) { 20 if ( ! options.dataType ) { 21 options.dataType = 'json'; 24 22 } 25 23 26 options.url = url; 27 options.beforeSend = function( xhr ) { 28 xhr.setRequestHeader( 'X-WP-Nonce', bpApiSettings.nonce ); 29 }; 24 // WordPress is >= 4.9.0. 25 if ( wp.apiRequest ) { 26 return wp.apiRequest( options ); 30 27 31 return $.ajax( options ); 28 // WordPress is < 4.9.0. 29 } else { 30 var url = bpApiSettings.root; 31 32 if ( options.path ) { 33 url = url + options.path.replace( /^\//, '' ); 34 } 35 36 options.url = url; 37 options.beforeSend = function( xhr ) { 38 xhr.setRequestHeader( 'X-WP-Nonce', bpApiSettings.nonce ); 39 }; 40 41 return $.ajax( options ); 42 } 32 43 }; 33 44
Note: See TracChangeset
for help on using the changeset viewer.