@@ 355-387 (lines=33) @@ | ||
352 | * @since 4.4.0 |
|
353 | * @since 5.4.0 Add transient since home/siteurl retrieved directly from DB. |
|
354 | */ |
|
355 | public static function get_sync_error_idc_option( $response = array() ) { |
|
356 | // Since the local options will hit the database directly, store the values |
|
357 | // in a transient to allow for autoloading and caching on subsequent views. |
|
358 | $local_options = get_transient( 'jetpack_idc_local' ); |
|
359 | if ( false === $local_options ) { |
|
360 | $local_options = array( |
|
361 | 'home' => Functions::home_url(), |
|
362 | 'siteurl' => Functions::site_url(), |
|
363 | ); |
|
364 | set_transient( 'jetpack_idc_local', $local_options, MINUTE_IN_SECONDS ); |
|
365 | } |
|
366 | ||
367 | $options = array_merge( $local_options, $response ); |
|
368 | ||
369 | $returned_values = array(); |
|
370 | foreach ( $options as $key => $option ) { |
|
371 | if ( 'error_code' === $key ) { |
|
372 | $returned_values[ $key ] = $option; |
|
373 | continue; |
|
374 | } |
|
375 | ||
376 | $normalized_url = self::normalize_url_protocol_agnostic( $option ); |
|
377 | if ( is_wp_error( $normalized_url ) ) { |
|
378 | continue; |
|
379 | } |
|
380 | ||
381 | $returned_values[ $key ] = $normalized_url; |
|
382 | } |
|
383 | ||
384 | set_transient( 'jetpack_idc_option', $returned_values, MINUTE_IN_SECONDS ); |
|
385 | ||
386 | return $returned_values; |
|
387 | } |
|
388 | ||
389 | /** |
|
390 | * Returns the value of the jetpack_sync_idc_optin filter, or constant. |
@@ 6315-6346 (lines=32) @@ | ||
6312 | * @param array $response |
|
6313 | * @return array Array of the local urls, wpcom urls, and error code |
|
6314 | */ |
|
6315 | public static function get_sync_error_idc_option( $response = array() ) { |
|
6316 | // Since the local options will hit the database directly, store the values |
|
6317 | // in a transient to allow for autoloading and caching on subsequent views. |
|
6318 | $local_options = get_transient( 'jetpack_idc_local' ); |
|
6319 | if ( false === $local_options ) { |
|
6320 | $local_options = array( |
|
6321 | 'home' => Functions::home_url(), |
|
6322 | 'siteurl' => Functions::site_url(), |
|
6323 | ); |
|
6324 | set_transient( 'jetpack_idc_local', $local_options, MINUTE_IN_SECONDS ); |
|
6325 | } |
|
6326 | ||
6327 | $options = array_merge( $local_options, $response ); |
|
6328 | ||
6329 | $returned_values = array(); |
|
6330 | foreach ( $options as $key => $option ) { |
|
6331 | if ( 'error_code' === $key ) { |
|
6332 | $returned_values[ $key ] = $option; |
|
6333 | continue; |
|
6334 | } |
|
6335 | ||
6336 | if ( is_wp_error( $normalized_url = self::normalize_url_protocol_agnostic( $option ) ) ) { |
|
6337 | continue; |
|
6338 | } |
|
6339 | ||
6340 | $returned_values[ $key ] = $normalized_url; |
|
6341 | } |
|
6342 | ||
6343 | set_transient( 'jetpack_idc_option', $returned_values, MINUTE_IN_SECONDS ); |
|
6344 | ||
6345 | return $returned_values; |
|
6346 | } |
|
6347 | ||
6348 | /** |
|
6349 | * Returns the value of the jetpack_sync_idc_optin filter, or constant. |