Code Duplication    Length = 10-11 lines in 4 locations

json-endpoints/class.wpcom-json-api-get-site-endpoint.php 1 location

@@ 465-475 (lines=11) @@
462
463
	}
464
465
	protected function process_locale( $key, $is_user_logged_in ) {
466
		if ( $is_user_logged_in && 'lang' == $key ) {
467
			if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
468
				if ( ! is_jetpack_site() ) {
469
					return (string) get_blog_lang_code();
470
				}
471
			}
472
			return (string) get_bloginfo( 'language' );
473
		}
474
		return false;
475
	}
476
477
	function force_http( $url, $scheme, $orig_scheme ) {
478
		return preg_replace('/^https:\/\//', 'http://', $url, 1 );

json-endpoints/class.wpcom-json-api-get-site-v1-2-endpoint.php 1 location

@@ 38-47 (lines=10) @@
35
	}
36
37
	//V1.2 renames lang to locale
38
	protected function process_locale( $key, $is_user_logged_in ) {
39
		if ( $is_user_logged_in && 'locale' == $key ) {
40
			if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
41
				if ( ! is_jetpack_site() ) {
42
					return (string) get_blog_lang_code();
43
				}
44
			}
45
		}
46
		return false;
47
	}
48
49
	public function site_format( $format ) {
50
		return self::$site_format;

json-endpoints/class.wpcom-json-api-site-settings-endpoint.php 1 location

@@ 233-243 (lines=11) @@
230
231
	}
232
233
	protected function get_locale( $key ) {
234
		if ( 'lang' == $key ) {
235
			if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
236
				return (string) get_blog_lang_code();
237
			} else {
238
				return get_locale();
239
			}
240
		}
241
242
		return false;
243
	}
244
245
246
	/**

json-endpoints/class.wpcom-json-api-site-settings-v1-2-endpoint.php 1 location

@@ 30-40 (lines=11) @@
27
	}
28
29
30
	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' ) );