Automattic /
jetpack
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * WARNING: This file is distributed verbatim in Jetpack. |
||
| 4 | * There should be nothing WordPress.com specific in this file. |
||
| 5 | * |
||
| 6 | * @hide-in-jetpack |
||
| 7 | * @autounit api site-settings |
||
| 8 | */ |
||
| 9 | |||
| 10 | class WPCOM_JSON_API_Site_Settings_V1_2_endpoint extends WPCOM_JSON_API_Site_Settings_Endpoint { |
||
| 11 | |||
| 12 | public static $site_format = array( |
||
| 13 | 'ID' => '(int) Site ID', |
||
| 14 | 'name' => '(string) Title of site', |
||
| 15 | 'description' => '(string) Tagline or description of site', |
||
| 16 | 'URL' => '(string) Full URL to the site', |
||
| 17 | 'locale' => '(string) Locale code of the site', |
||
| 18 | 'settings' => '(array) An array of options/settings for the blog. Only viewable by users with post editing rights to the site.', |
||
| 19 | ); |
||
| 20 | |||
| 21 | |||
| 22 | function callback( $path = '', $blog_id = 0 ) { |
||
| 23 | add_filter( 'site_settings_endpoint_update_locale', array( $this, 'update_locale' ) ); |
||
| 24 | add_filter( 'site_settings_endpoint_get', array( $this, 'return_locale' ) ); |
||
| 25 | add_filter( 'site_settings_site_format', array( $this, 'site_format' ) ); |
||
| 26 | return parent::callback( $path, $blog_id ); |
||
| 27 | } |
||
| 28 | |||
| 29 | |||
| 30 | View Code Duplication | protected function get_locale( $key ) { |
|
| 31 | if ( 'locale' == $key ) { |
||
| 32 | if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { |
||
| 33 | return (string) get_blog_lang_code(); |
||
| 34 | } else { |
||
| 35 | return get_locale(); |
||
| 36 | } |
||
| 37 | } |
||
| 38 | |||
| 39 | return false; |
||
| 40 | } |
||
| 41 | |||
| 42 | public function return_locale( $settings ) { |
||
| 43 | return $settings + array( 'locale' => $this->get_locale( 'locale' ) ); |
||
| 44 | } |
||
| 45 | |||
| 46 | public function update_locale( $value ) { |
||
| 47 | if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { |
||
| 48 | $lang_id = get_lang_id_by_code( $value ); |
||
| 49 | if ( ! empty( $lang_id ) ) { |
||
| 50 | if ( update_option( 'lang_id', $lang_id ) ) { |
||
| 51 | return true; |
||
| 52 | } |
||
| 53 | } |
||
| 54 | } |
||
| 55 | return false; |
||
| 56 | } |
||
| 57 | |||
| 58 | public function site_format( $format ) { |
||
|
0 ignored issues
–
show
|
|||
| 59 | return self::$site_format; |
||
| 60 | } |
||
| 61 | } |
||
| 62 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.