| @@ 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. |
|
| @@ 6258-6289 (lines=32) @@ | ||
| 6255 | * @param array $response |
|
| 6256 | * @return array Array of the local urls, wpcom urls, and error code |
|
| 6257 | */ |
|
| 6258 | public static function get_sync_error_idc_option( $response = array() ) { |
|
| 6259 | // Since the local options will hit the database directly, store the values |
|
| 6260 | // in a transient to allow for autoloading and caching on subsequent views. |
|
| 6261 | $local_options = get_transient( 'jetpack_idc_local' ); |
|
| 6262 | if ( false === $local_options ) { |
|
| 6263 | $local_options = array( |
|
| 6264 | 'home' => Functions::home_url(), |
|
| 6265 | 'siteurl' => Functions::site_url(), |
|
| 6266 | ); |
|
| 6267 | set_transient( 'jetpack_idc_local', $local_options, MINUTE_IN_SECONDS ); |
|
| 6268 | } |
|
| 6269 | ||
| 6270 | $options = array_merge( $local_options, $response ); |
|
| 6271 | ||
| 6272 | $returned_values = array(); |
|
| 6273 | foreach ( $options as $key => $option ) { |
|
| 6274 | if ( 'error_code' === $key ) { |
|
| 6275 | $returned_values[ $key ] = $option; |
|
| 6276 | continue; |
|
| 6277 | } |
|
| 6278 | ||
| 6279 | if ( is_wp_error( $normalized_url = self::normalize_url_protocol_agnostic( $option ) ) ) { |
|
| 6280 | continue; |
|
| 6281 | } |
|
| 6282 | ||
| 6283 | $returned_values[ $key ] = $normalized_url; |
|
| 6284 | } |
|
| 6285 | ||
| 6286 | set_transient( 'jetpack_idc_option', $returned_values, MINUTE_IN_SECONDS ); |
|
| 6287 | ||
| 6288 | return $returned_values; |
|
| 6289 | } |
|
| 6290 | ||
| 6291 | /** |
|
| 6292 | * Returns the value of the jetpack_sync_idc_optin filter, or constant. |
|