WPCOM_JSON_API_Site_Settings_V1_2_Endpoint

The WordPress Core WPCOM JSON API Site Settings V1 2 Endpoint class.

Defined (1)

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

/json-endpoints/class.wpcom-json-api-site-settings-v1-2-endpoint.php  
  1. class WPCOM_JSON_API_Site_Settings_V1_2_Endpoint extends WPCOM_JSON_API_Site_Settings_Endpoint { 
  2.  
  3. public static $site_format = array( 
  4. 'ID' => '(int) Site ID',  
  5. 'name' => '(string) Title of site',  
  6. 'description' => '(string) Tagline or description of site',  
  7. 'URL' => '(string) Full URL to the site',  
  8. 'locale' => '(string) Locale code of the site',  
  9. 'settings' => '(array) An array of options/settings for the blog. Only viewable by users with post editing rights to the site.',  
  10. ); 
  11.  
  12.  
  13. function callback( $path = '', $blog_id = 0 ) { 
  14. add_filter( 'site_settings_endpoint_update_locale', array( $this, 'update_locale' ) ); 
  15. add_filter( 'site_settings_endpoint_get', array( $this, 'return_locale' ) ); 
  16. add_filter( 'site_settings_site_format', array( $this, 'site_format' ) ); 
  17. return parent::callback( $path, $blog_id ); 
  18.  
  19.  
  20. protected function get_locale( $key ) { 
  21. if ( 'locale' == $key ) { 
  22. if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { 
  23. return (string) get_blog_lang_code(); 
  24. } else { 
  25. return get_locale(); 
  26.  
  27. return false; 
  28.  
  29. public function return_locale( $settings ) { 
  30. return $settings + array( 'locale' => $this->get_locale( 'locale' ) ); 
  31.  
  32. public function update_locale( $value ) { 
  33. if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { 
  34. $lang_id = get_lang_id_by_code( $value ); 
  35. if ( ! empty( $lang_id ) ) { 
  36. if ( update_option( 'lang_id', $lang_id ) ) { 
  37. return true; 
  38. return false; 
  39.  
  40. public function site_format( $format ) { 
  41. return self::$site_format;