Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (8 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-simplepie-file.php

    r41162 r42343  
    3333     *                                      connection or not. Default false.
    3434     */
    35     public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) {
    36         $this->url = $url;
    37         $this->timeout = $timeout;
     35    public function __construct( $url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false ) {
     36        $this->url       = $url;
     37        $this->timeout   = $timeout;
    3838        $this->redirects = $redirects;
    39         $this->headers = $headers;
     39        $this->headers   = $headers;
    4040        $this->useragent = $useragent;
    4141
    4242        $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE;
    4343
    44         if ( preg_match('/^http(s)?:\/\//i', $url) ) {
     44        if ( preg_match( '/^http(s)?:\/\//i', $url ) ) {
    4545            $args = array(
    46                 'timeout' => $this->timeout,
     46                'timeout'     => $this->timeout,
    4747                'redirection' => $this->redirects,
    4848            );
    4949
    50             if ( !empty($this->headers) )
     50            if ( ! empty( $this->headers ) ) {
    5151                $args['headers'] = $this->headers;
     52            }
    5253
    53             if ( SIMPLEPIE_USERAGENT != $this->useragent ) //Use default WP user agent unless custom has been specified
     54            if ( SIMPLEPIE_USERAGENT != $this->useragent ) { //Use default WP user agent unless custom has been specified
    5455                $args['user-agent'] = $this->useragent;
     56            }
    5557
    56             $res = wp_safe_remote_request($url, $args);
     58            $res = wp_safe_remote_request( $url, $args );
    5759
    58             if ( is_wp_error($res) ) {
    59                 $this->error = 'WP HTTP Error: ' . $res->get_error_message();
     60            if ( is_wp_error( $res ) ) {
     61                $this->error   = 'WP HTTP Error: ' . $res->get_error_message();
    6062                $this->success = false;
    6163            } else {
    62                 $this->headers = wp_remote_retrieve_headers( $res );
    63                 $this->body = wp_remote_retrieve_body( $res );
     64                $this->headers     = wp_remote_retrieve_headers( $res );
     65                $this->body        = wp_remote_retrieve_body( $res );
    6466                $this->status_code = wp_remote_retrieve_response_code( $res );
    6567            }
    6668        } else {
    67             $this->error = '';
     69            $this->error   = '';
    6870            $this->success = false;
    6971        }
Note: See TracChangeset for help on using the changeset viewer.