Jetpack_JSON_API_Check_Capabilities_Endpoint

The Jetpack by WordPress.com Jetpack JSON API Check Capabilities Endpoint class.

Defined (1)

The class is defined in the following location(s).

/json-endpoints/jetpack/class.jetpack-json-api-check-capabilities-endpoint.php  
  1. class Jetpack_JSON_API_Check_Capabilities_Endpoint extends Jetpack_JSON_API_Modules_Endpoint { 
  2. // GET /sites/%s/me/capability 
  3. public function callback( $path = '', $_blog_id = 0 ) { 
  4. // Check minimum capability and blog membership first 
  5. if ( is_wp_error( $error = $this->validate_call( $_blog_id, 'read', false ) ) ) { 
  6. return $error; 
  7.  
  8. $args = $this->input(); 
  9.  
  10. if ( ! isset( $args['capability'] ) || empty( $args['capability'] ) ) { 
  11. return new WP_Error( 'missing_capability', __( 'You are required to specify a capability to check.', 'jetpack' ), 400 ); 
  12.  
  13. $capability = $args['capability']; 
  14. if ( is_array( $capability ) ) { 
  15. $results = array_map( 'current_user_can', $capability ); 
  16. return array_combine( $capability, $results ); 
  17. } else { 
  18. return current_user_can( $capability );