Code Duplication    Length = 32-33 lines in 2 locations

projects/plugins/jetpack/class.jetpack.php 1 location

@@ 6288-6319 (lines=32) @@
6285
	 * @param array $response
6286
	 * @return array Array of the local urls, wpcom urls, and error code
6287
	 */
6288
	public static function get_sync_error_idc_option( $response = array() ) {
6289
		// Since the local options will hit the database directly, store the values
6290
		// in a transient to allow for autoloading and caching on subsequent views.
6291
		$local_options = get_transient( 'jetpack_idc_local' );
6292
		if ( false === $local_options ) {
6293
			$local_options = array(
6294
				'home'    => Functions::home_url(),
6295
				'siteurl' => Functions::site_url(),
6296
			);
6297
			set_transient( 'jetpack_idc_local', $local_options, MINUTE_IN_SECONDS );
6298
		}
6299
6300
		$options = array_merge( $local_options, $response );
6301
6302
		$returned_values = array();
6303
		foreach ( $options as $key => $option ) {
6304
			if ( 'error_code' === $key ) {
6305
				$returned_values[ $key ] = $option;
6306
				continue;
6307
			}
6308
6309
			if ( is_wp_error( $normalized_url = self::normalize_url_protocol_agnostic( $option ) ) ) {
6310
				continue;
6311
			}
6312
6313
			$returned_values[ $key ] = $normalized_url;
6314
		}
6315
6316
		set_transient( 'jetpack_idc_option', $returned_values, MINUTE_IN_SECONDS );
6317
6318
		return $returned_values;
6319
	}
6320
6321
	/**
6322
	 * Returns the value of the jetpack_sync_idc_optin filter, or constant.

projects/packages/identity-crisis/src/class-identity-crisis.php 1 location

@@ 353-385 (lines=33) @@
350
	 * @return array Array of the local urls, wpcom urls, and error code.
351
	 * @since 1.0.0
352
	 */
353
	public static function get_sync_error_idc_option( $response = array() ) {
354
		// Since the local options will hit the database directly, store the values
355
		// in a transient to allow for autoloading and caching on subsequent views.
356
		$local_options = get_transient( 'jetpack_idc_local' );
357
		if ( false === $local_options ) {
358
			$local_options = array(
359
				'home'    => Functions::home_url(),
360
				'siteurl' => Functions::site_url(),
361
			);
362
			set_transient( 'jetpack_idc_local', $local_options, MINUTE_IN_SECONDS );
363
		}
364
365
		$options = array_merge( $local_options, $response );
366
367
		$returned_values = array();
368
		foreach ( $options as $key => $option ) {
369
			if ( 'error_code' === $key ) {
370
				$returned_values[ $key ] = $option;
371
				continue;
372
			}
373
374
			$normalized_url = self::normalize_url_protocol_agnostic( $option );
375
			if ( is_wp_error( $normalized_url ) ) {
376
				continue;
377
			}
378
379
			$returned_values[ $key ] = $normalized_url;
380
		}
381
382
		set_transient( 'jetpack_idc_option', $returned_values, MINUTE_IN_SECONDS );
383
384
		return $returned_values;
385
	}
386
387
	/**
388
	 * Returns the value of the jetpack_sync_idc_optin filter, or constant.