WPCOM_JSON_API_Get_Option_Endpoint

The WordPress Core WPCOM JSON API Get Option Endpoint class.

Defined (1)

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

/json-endpoints/jetpack/class.wpcom-json-api-get-option-endpoint.php  
  1. class WPCOM_JSON_API_Get_Option_Endpoint extends Jetpack_JSON_API_Endpoint { 
  2.  
  3. protected $needed_capabilities = 'manage_options'; 
  4.  
  5. public $option_name; 
  6. public $site_option; 
  7.  
  8. function result() { 
  9. if ( $this->site_option ) { 
  10. return array( 'option_value' => get_site_option( $this->option_name ) ); 
  11. return array( 'option_value' => get_option( $this->option_name ) ); 
  12.  
  13. function validate_input( $object ) { 
  14. $query_args = $this->query_args(); 
  15. $this->option_name = isset( $query_args['option_name'] ) ? $query_args['option_name'] : false; 
  16. if ( ! $this->option_name ) { 
  17. return new WP_Error( 'option_name_not_set', __( 'You must specify an option_name', 'jetpack' ) ); 
  18. $this->site_option = isset( $query_args['site_option'] ) ? $query_args['site_option'] : false; 
  19.  
  20. require_once JETPACK__PLUGIN_DIR . '/sync/class.jetpack-sync-defaults.php'; 
  21. /** 
  22. * Filter the list of options that are manageable via the JSON API. 
  23. * @module json-api 
  24. * @since 3.8.2 
  25. * @param array The default list of site options. 
  26. * @param bool Is the option a site option. 
  27. */ 
  28. if ( ! in_array( $this->option_name, apply_filters( 'jetpack_options_whitelist', Jetpack_Sync_Defaults::$default_options_whitelist, $this->site_option ) ) ) { 
  29. return new WP_Error( 'option_name_not_in_whitelist', __( 'You must specify a whitelisted option_name', 'jetpack' ) ); 
  30. return true;