@@ 349-381 (lines=33) @@ | ||
346 | * @since 4.4.0 |
|
347 | * @since 5.4.0 Add transient since home/siteurl retrieved directly from DB. |
|
348 | */ |
|
349 | public static function get_sync_error_idc_option( $response = array() ) { |
|
350 | // Since the local options will hit the database directly, store the values |
|
351 | // in a transient to allow for autoloading and caching on subsequent views. |
|
352 | $local_options = get_transient( 'jetpack_idc_local' ); |
|
353 | if ( false === $local_options ) { |
|
354 | $local_options = array( |
|
355 | 'home' => Functions::home_url(), |
|
356 | 'siteurl' => Functions::site_url(), |
|
357 | ); |
|
358 | set_transient( 'jetpack_idc_local', $local_options, MINUTE_IN_SECONDS ); |
|
359 | } |
|
360 | ||
361 | $options = array_merge( $local_options, $response ); |
|
362 | ||
363 | $returned_values = array(); |
|
364 | foreach ( $options as $key => $option ) { |
|
365 | if ( 'error_code' === $key ) { |
|
366 | $returned_values[ $key ] = $option; |
|
367 | continue; |
|
368 | } |
|
369 | ||
370 | $normalized_url = self::normalize_url_protocol_agnostic( $option ); |
|
371 | if ( is_wp_error( $normalized_url ) ) { |
|
372 | continue; |
|
373 | } |
|
374 | ||
375 | $returned_values[ $key ] = $normalized_url; |
|
376 | } |
|
377 | ||
378 | set_transient( 'jetpack_idc_option', $returned_values, MINUTE_IN_SECONDS ); |
|
379 | ||
380 | return $returned_values; |
|
381 | } |
|
382 | ||
383 | /** |
|
384 | * Returns the value of the jetpack_sync_idc_optin filter, or constant. |
@@ 6291-6322 (lines=32) @@ | ||
6288 | * @param array $response |
|
6289 | * @return array Array of the local urls, wpcom urls, and error code |
|
6290 | */ |
|
6291 | public static function get_sync_error_idc_option( $response = array() ) { |
|
6292 | // Since the local options will hit the database directly, store the values |
|
6293 | // in a transient to allow for autoloading and caching on subsequent views. |
|
6294 | $local_options = get_transient( 'jetpack_idc_local' ); |
|
6295 | if ( false === $local_options ) { |
|
6296 | $local_options = array( |
|
6297 | 'home' => Functions::home_url(), |
|
6298 | 'siteurl' => Functions::site_url(), |
|
6299 | ); |
|
6300 | set_transient( 'jetpack_idc_local', $local_options, MINUTE_IN_SECONDS ); |
|
6301 | } |
|
6302 | ||
6303 | $options = array_merge( $local_options, $response ); |
|
6304 | ||
6305 | $returned_values = array(); |
|
6306 | foreach ( $options as $key => $option ) { |
|
6307 | if ( 'error_code' === $key ) { |
|
6308 | $returned_values[ $key ] = $option; |
|
6309 | continue; |
|
6310 | } |
|
6311 | ||
6312 | if ( is_wp_error( $normalized_url = self::normalize_url_protocol_agnostic( $option ) ) ) { |
|
6313 | continue; |
|
6314 | } |
|
6315 | ||
6316 | $returned_values[ $key ] = $normalized_url; |
|
6317 | } |
|
6318 | ||
6319 | set_transient( 'jetpack_idc_option', $returned_values, MINUTE_IN_SECONDS ); |
|
6320 | ||
6321 | return $returned_values; |
|
6322 | } |
|
6323 | ||
6324 | /** |
|
6325 | * Returns the value of the jetpack_sync_idc_optin filter, or constant. |