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

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