Code Duplication    Length = 32-33 lines in 2 locations

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

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

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.