wp_http_supports example



    // Allow for WP_AUTO_UPDATE_CORE to specify beta/RC/development releases.     if ( defined( 'WP_AUTO_UPDATE_CORE' )
        && in_array( WP_AUTO_UPDATE_CORE, array( 'beta', 'rc', 'development', 'branch-development' ), true )
    ) {
        $query['channel'] = WP_AUTO_UPDATE_CORE;
    }

    $url      = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, '', '&' );
    $http_url = $url;
    $ssl      = wp_http_supports( array( 'ssl' ) );

    if ( $ssl ) {
        $url = set_url_scheme( $url, 'https' );
    }

    $doing_cron = wp_doing_cron();

    $options = array(
        'timeout'    => $doing_cron ? 30 : 3,
        'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
        'headers'    => array(
            
<?php echo esc_attr( get_option('wordpress_api_key') ); ?>" class="<?php echo esc_attr( 'regular-text code ' . $akismet_user->status ); ?>"></span> </div> </div> <?php endif; ?> <?php if ( isset( $_GET['ssl_status'] ) ) : ?> <div class="akismet-settings__row"> <div class="akismet-settings__row-text"> <h3 class="akismet-settings__row-title"><?php esc_html_e( 'SSL status', 'akismet' ); ?></h3> <div class="akismet-settings__row-description"> <?php if ( ! wp_http_supports( array( 'ssl' ) ) ) : ?> <strong><?php esc_html_e( 'Disabled.', 'akismet' ); ?></strong> <?php esc_html_e( 'Your Web server cannot make SSL requests; contact your Web host and ask them to add support for SSL requests.', 'akismet' ); ?> <?php else : ?> <?php $ssl_disabled = get_option( 'akismet_ssl_disabled' ); ?> <?php if ( $ssl_disabled ) : ?> <strong><?php esc_html_e( 'Temporarily disabled.', 'akismet' ); ?></strong> <?php esc_html_e( 'Akismet encountered a problem with a previous SSL request and disabled it temporarily. It will begin using SSL for requests again shortly.', 'akismet' ); ?> <?php else : ?> <strong><?php esc_html_e( 'Enabled.', 'akismet' ); ?></strong> <?php esc_html_e( 'All systems functional.', 'akismet' ); ?>
if ( ! $location_search && $cached_events ) {
            return $cached_events;
        }

        // Include an unmodified $wp_version.         require ABSPATH . WPINC . '/version.php';

        $api_url                    = 'http://api.wordpress.org/events/1.0/';
        $request_args               = $this->get_request_args( $location_search$timezone );
        $request_args['user-agent'] = 'WordPress/' . $wp_version . '; ' . home_url( '/' );

        if ( wp_http_supports( array( 'ssl' ) ) ) {
            $api_url = set_url_scheme( $api_url, 'https' );
        }

        $response       = wp_remote_get( $api_url$request_args );
        $response_code  = wp_remote_retrieve_response_code( $response );
        $response_body  = json_decode( wp_remote_retrieve_body( $response ), true );
        $response_error = null;

        if ( is_wp_error( $response ) ) {
            $response_error = $response;
        } elseif ( 200 !== $response_code ) {
            
$url = 'http://api.wordpress.org/plugins/info/1.2/';
        $url = add_query_arg(
            array(
                'action'  => $action,
                'request' => $args,
            ),
            $url
        );

        $http_url = $url;
        $ssl      = wp_http_supports( array( 'ssl' ) );
        if ( $ssl ) {
            $url = set_url_scheme( $url, 'https' );
        }

        $http_args = array(
            'timeout'    => 15,
            'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
        );
        $request   = wp_remote_get( $url$http_args );

        if ( $ssl && is_wp_error( $request ) ) {
            
$transient_key = $this->get_transient_key( $query_args );

        /* * Use network-wide transient to improve performance. The locale is the only site * configuration that affects the response, and it's included in the transient key. */
        $raw_patterns = get_site_transient( $transient_key );

        if ( ! $raw_patterns ) {
            $api_url = 'http://api.wordpress.org/patterns/1.0/?' . build_query( $query_args );
            if ( wp_http_supports( array( 'ssl' ) ) ) {
                $api_url = set_url_scheme( $api_url, 'https' );
            }

            /* * Default to a short TTL, to mitigate cache stampedes on high-traffic sites. * This assumes that most errors will be short-lived, e.g., packet loss that causes the * first request to fail, but a follow-up one will succeed. The value should be high * enough to avoid stampedes, but low enough to not interfere with users manually * re-trying a failed request. */
            $cache_ttl      = 5;
            

function get_core_checksums( $version$locale ) {
    $http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), '', '&' );
    $url      = $http_url;

    $ssl = wp_http_supports( array( 'ssl' ) );

    if ( $ssl ) {
        $url = set_url_scheme( $url, 'https' );
    }

    $options = array(
        'timeout' => wp_doing_cron() ? 30 : 3,
    );

    $response = wp_remote_get( $url$options );

    
if ( false === $response ) {
        // Include an unmodified $wp_version.         require ABSPATH . WPINC . '/version.php';

        $url     = 'http://api.wordpress.org/core/browse-happy/1.1/';
        $options = array(
            'body'       => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),
            'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
        );

        if ( wp_http_supports( array( 'ssl' ) ) ) {
            $url = set_url_scheme( $url, 'https' );
        }

        $response = wp_remote_post( $url$options );

        if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
            return false;
        }

        /** * Response should be an array with: * 'platform' - string - A user-friendly platform name, if it can be determined * 'name' - string - A user-friendly browser name * 'version' - string - The version of the browser the user is using * 'current_version' - string - The most recent version of the browser * 'upgrade' - boolean - Whether the browser needs an upgrade * 'insecure' - boolean - Whether the browser is deemed insecure * 'update_url' - string - The url to visit to upgrade * 'img_src' - string - An image representing the browser * 'img_src_ssl' - string - An image (over SSL) representing the browser */
if ( ! $res ) {
        $url = 'http://api.wordpress.org/themes/info/1.2/';
        $url = add_query_arg(
            array(
                'action'  => $action,
                'request' => $args,
            ),
            $url
        );

        $http_url = $url;
        $ssl      = wp_http_supports( array( 'ssl' ) );
        if ( $ssl ) {
            $url = set_url_scheme( $url, 'https' );
        }

        $http_args = array(
            'timeout'    => 15,
            'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
        );
        $request   = wp_remote_get( $url$http_args );

        if ( $ssl && is_wp_error( $request ) ) {
            
$debug[ 'AKISMET__PLUGIN_DIR' ] = AKISMET__PLUGIN_DIR;
        $debug[ 'SITE_URL' ]            = site_url();
        $debug[ 'HOME_URL' ]            = home_url();
        
        $servers = get_option('akismet_available_servers');
        if ( (time() - get_option('akismet_connectivity_time') < $cache_timeout) && $servers !== false ) {
            $servers = self::check_server_ip_connectivity();
            update_option('akismet_available_servers', $servers);
            update_option('akismet_connectivity_time', time());
        }

        if ( wp_http_supports( array( 'ssl' ) ) ) {
            $response = wp_remote_get( 'https://rest.akismet.com/1.1/test' );
        }
        else {
            $response = wp_remote_get( 'http://rest.akismet.com/1.1/test' );
        }

        $debug[ 'gethostbynamel' ]  = function_exists('gethostbynamel') ? 'exists' : 'not here';
        $debug[ 'Servers' ]         = $servers;
        $debug[ 'Test Connection' ] = $response;
        
        Akismet::log( $debug );
        
        


    $results = get_site_transient( 'wordpress_credits_' . $locale );

    if ( ! is_array( $results )
        || str_contains( $version, '-' )
        || ( isset( $results['data']['version'] ) && ! str_starts_with( $version$results['data']['version'] ) )
    ) {
        $url     = "http://api.wordpress.org/core/credits/1.1/?version={$version}&locale={$locale}";
        $options = array( 'user-agent' => 'WordPress/' . $version . '; ' . home_url( '/' ) );

        if ( wp_http_supports( array( 'ssl' ) ) ) {
            $url = set_url_scheme( $url, 'https' );
        }

        $response = wp_remote_get( $url$options );

        if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
            return false;
        }

        $results = json_decode( wp_remote_retrieve_body( $response ), true );

        

function wp_check_php_version() {
    $version = PHP_VERSION;
    $key     = md5( $version );

    $response = get_site_transient( 'php_check_' . $key );

    if ( false === $response ) {
        $url = 'http://api.wordpress.org/core/serve-happy/1.0/';

        if ( wp_http_supports( array( 'ssl' ) ) ) {
            $url = set_url_scheme( $url, 'https' );
        }

        $url = add_query_arg( 'php_version', $version$url );

        $response = wp_remote_get( $url );

        if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
            return false;
        }

        
// Check if SSL requests were disabled fewer than X hours ago.         $ssl_disabled = get_option( 'akismet_ssl_disabled' );

        if ( $ssl_disabled && $ssl_disabled < ( time() - 60 * 60 * 24 ) ) { // 24 hours             $ssl_disabled = false;
            delete_option( 'akismet_ssl_disabled' );
        }
        else if ( $ssl_disabled ) {
            do_action( 'akismet_ssl_disabled' );
        }

        if ( ! $ssl_disabled && ( $ssl = wp_http_supports( array( 'ssl' ) ) ) ) {
            $akismet_url = set_url_scheme( $akismet_url, 'https' );

            do_action( 'akismet_https_request_pre' );
        }

        $response = wp_remote_post( $akismet_url$http_args );

        Akismet::log( compact( 'akismet_url', 'http_args', 'response' ) );

        if ( $ssl && is_wp_error( $response ) ) {
            do_action( 'akismet_https_request_failure', $response );

            
'label' => __( 'Security' ),
                'color' => 'blue',
            ),
            'description' => sprintf(
                '<p>%s</p>',
                __( 'Securely communicating between servers are needed for transactions such as fetching files, conducting sales on store sites, and much more.' )
            ),
            'actions'     => '',
            'test'        => 'ssl_support',
        );

        $supports_https = wp_http_supports( array( 'ssl' ) );

        if ( $supports_https ) {
            $result['status'] = 'good';

            $result['label'] = __( 'Your site can communicate securely with other services' );
        } else {
            $result['status'] = 'critical';

            $result['label'] = __( 'Your site is unable to communicate securely with other services' );

            $result['description'] .= sprintf(
                
if ( ! $popular_importers ) {
        $url     = add_query_arg(
            array(
                'locale'  => $locale,
                'version' => $wp_version,
            ),
            'http://api.wordpress.org/core/importers/1.1/'
        );
        $options = array( 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ) );

        if ( wp_http_supports( array( 'ssl' ) ) ) {
            $url = set_url_scheme( $url, 'https' );
        }

        $response          = wp_remote_get( $url$options );
        $popular_importers = json_decode( wp_remote_retrieve_body( $response ), true );

        if ( is_array( $popular_importers ) ) {
            set_site_transient( $cache_key$popular_importers, 2 * DAY_IN_SECONDS );
        } else {
            $popular_importers = false;
        }
    }

    $res = apply_filters( 'translations_api', false, $type$args );

    if ( false === $res ) {
        $url      = 'http://api.wordpress.org/translations/' . $type . '/1.0/';
        $http_url = $url;
        $ssl      = wp_http_supports( array( 'ssl' ) );
        if ( $ssl ) {
            $url = set_url_scheme( $url, 'https' );
        }

        $options = array(
            'timeout' => 3,
            'body'    => array(
                'wp_version' => $wp_version,
                'locale'     => get_locale(),
                'version'    => $args['version'], // Version of plugin, theme or core.             ),
        );
Home | Imprint | This part of the site doesn't use cookies.