stats_print_wp_remote_error

Stats Print WP Remote Error.

Description

stats_print_wp_remote_error( $get, $url ); 

Parameters (2)

0. $get
The get.
1. $url
The url.

Usage

  1. if ( !function_exists( 'stats_print_wp_remote_error' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/modules/stats.php'; 
  3.  
  4. // The get. 
  5. $get = null; 
  6.  
  7. // The url. 
  8. $url = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = stats_print_wp_remote_error($get, $url); 
  12.  

Defined (1)

The function is defined in the following location(s).

/modules/stats.php  
  1. function stats_print_wp_remote_error( $get, $url ) { 
  2. $state_name = 'stats_remote_error_' . substr( md5( $url ), 0, 8 ); 
  3. $previous_error = Jetpack::state( $state_name ); 
  4. $error = md5( serialize( compact( 'get', 'url' ) ) ); 
  5. Jetpack::state( $state_name, $error ); 
  6. if ( $error !== $previous_error ) { 
  7. ?> 
  8. <div class="wrap"> 
  9. <p><?php _e( 'We were unable to get your stats just now. Please reload this page to try again.', jetpack ); ?></p> 
  10. </div> 
  11. <?php 
  12. return; 
  13. ?> 
  14. <div class="wrap"> 
  15. <p><?php printf( __( 'We were unable to get your stats just now. Please reload this page to try again. If thiserrorpersists, please <a href="%1$s">contact support</a>. In your report please include the information below.', jetpack ), 'http://support.wordpress.com/contact/?jetpack=needs-service' ); ?></p> 
  16. <pre> 
  17. User Agent: "<?php echo esc_html( $_SERVER['HTTP_USER_AGENT'] ); ?>" 
  18. Page URL: "http<?php echo (is_ssl()?'s':'') . '://' . esc_html( $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); ?>" 
  19. API URL: "<?php echo esc_url( $url ); ?>" 
  20. <?php 
  21. if ( is_wp_error( $get ) ) { 
  22. foreach ( $get->get_error_codes() as $code ) { 
  23. foreach ( $get->get_error_messages($code) as $message ) { 
  24. ?> 
  25. <?php print $code . ': "' . $message . '"' ?> 
  26.  
  27. <?php 
  28. } else { 
  29. $get_code = wp_remote_retrieve_response_code( $get ); 
  30. $content_length = strlen( wp_remote_retrieve_body( $get ) ); 
  31. ?> 
  32. Response code: "<?php print $get_code ?>" 
  33. Content length: "<?php print $content_length ?>" 
  34.  
  35. <?php 
  36. ?></pre> 
  37. </div> 
  38. <?php