WP_Site_Health::get_test_dotorg_communication() – Test if the site can communicate with WordPress.org.

You appear to be a bot. Output may be restricted

Description

Tests if the site can communicate with WordPress.org.

Usage

$array = WP_Site_Health::get_test_dotorg_communication();

Parameters

Returns

array The test results.

Source

File name: wordpress/wp-admin/includes/class-wp-site-health.php
Lines:

1 to 56 of 56
  public function get_test_dotorg_communication() {
    $result = array(
      'label'       => __( 'Can communicate with WordPress.org' ),
      'status'      => '',
      'badge'       => array(
        'label' => __( 'Security' ),
        'color' => 'blue',
      ),
      'description' => sprintf(
        '<p>%s</p>',
        __( 'Communicating with the WordPress servers is used to check for new versions, and to both install and update WordPress core, themes or plugins.' )
      ),
      'actions'     => '',
      'test'        => 'dotorg_communication',
    );

    $wp_dotorg = wp_remote_get(
      'https://api.wordpress.org',
      array(
        'timeout' => 10,
      )
    );
    if ( ! is_wp_error( $wp_dotorg ) ) {
      $result['status'] = 'good';
    } else {
      $result['status'] = 'critical';

      $result['label'] = __( 'Could not reach WordPress.org' );

      $result['description'] .= sprintf(
        '<p>%s</p>',
        sprintf(
          '<span class="error"><span class="screen-reader-text">%s</span></span> %s',
          /* translators: Hidden accessibility text. */
          __( 'Error' ),
          sprintf(
            /* translators: 1: The IP address WordPress.org resolves to. 2: The error returned by the lookup. */
            __( 'Your site is unable to reach WordPress.org at %1$s, and returned the error: %2$s' ),
            gethostbyname( 'api.wordpress.org' ),
            $wp_dotorg->get_error_message()
          )
        )
      );

      $result['actions'] = sprintf(
        '<p><a href="%s" target="_blank" rel="noopener">%s <span class="screen-reader-text">%s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
        /* translators: Localized Support reference. */
        esc_url( __( 'https://wordpress.org/support' ) ),
        __( 'Get help resolving this issue.' ),
        /* translators: Hidden accessibility text. */
        __( '(opens in a new tab)' )
      );
    }

    return $result;
  }
 

 View on GitHub View on Trac