[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-core/js/ -> bp-api-request.js (source)

   1  /**
   2   * jQuery.ajax wrapper for BP REST API requests.
   3   *
   4   * @since  5.0.0
   5   * @deprecated 10.0.0
   6   * @output bp-core/js/bp-api-request.js
   7   */
   8  /* global bpApiSettings */
   9  window.bp = window.bp || {};
  10  
  11  ( function( wp, bp ) {
  12      // Bail if not set.
  13      if ( typeof bpApiSettings === 'undefined' ) {
  14          return;
  15      }
  16  
  17      bp.isRestEnabled = true;
  18  
  19      // Polyfill wp.apiRequest.
  20      bp.apiRequest = function( options ) {
  21          window.console.log( bpApiSettings.deprecatedWarning );
  22  
  23          var bpRequest;
  24  
  25          if ( ! options.dataType ) {
  26              options.dataType = 'json';
  27          }
  28  
  29          bpRequest = wp.apiRequest( options );
  30  
  31          return bpRequest.then( null, function( result ) {
  32              var errorObject = {
  33                  code: 'unexpected_error',
  34                  message: bpApiSettings.unexpectedError,
  35                  data: {
  36                      status: 404
  37                  }
  38              };
  39  
  40              if ( result && result.responseJSON ) {
  41                  errorObject = result.responseJSON;
  42              }
  43  
  44              return errorObject;
  45          } );
  46      };
  47  
  48  } )( window.wp || {}, window.bp );


Generated: Tue May 7 01:01:07 2024 Cross-referenced by PHPXref 0.7.1