wp/wp-includes/class-wp-http-proxy.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
    37  * @link https://core.trac.wordpress.org/ticket/4011 Proxy support ticket in WordPress.
    37  * @link https://core.trac.wordpress.org/ticket/4011 Proxy support ticket in WordPress.
    38  * @link https://core.trac.wordpress.org/ticket/14636 Allow wildcard domains in WP_PROXY_BYPASS_HOSTS
    38  * @link https://core.trac.wordpress.org/ticket/14636 Allow wildcard domains in WP_PROXY_BYPASS_HOSTS
    39  *
    39  *
    40  * @since 2.8.0
    40  * @since 2.8.0
    41  */
    41  */
       
    42 #[AllowDynamicProperties]
    42 class WP_HTTP_Proxy {
    43 class WP_HTTP_Proxy {
    43 
    44 
    44 	/**
    45 	/**
    45 	 * Whether proxy connection should be used.
    46 	 * Whether proxy connection should be used.
    46 	 *
    47 	 *
    47 	 * Constants which control this behaviour:
    48 	 * Constants which control this behavior:
    48 	 *
    49 	 *
    49 	 * - `WP_PROXY_HOST`
    50 	 * - `WP_PROXY_HOST`
    50 	 * - `WP_PROXY_PORT`
    51 	 * - `WP_PROXY_PORT`
    51 	 *
    52 	 *
    52 	 * @since 2.8.0
    53 	 * @since 2.8.0
    58 	}
    59 	}
    59 
    60 
    60 	/**
    61 	/**
    61 	 * Whether authentication should be used.
    62 	 * Whether authentication should be used.
    62 	 *
    63 	 *
    63 	 * Constants which control this behaviour:
    64 	 * Constants which control this behavior:
    64 	 *
    65 	 *
    65 	 * - `WP_PROXY_USERNAME`
    66 	 * - `WP_PROXY_USERNAME`
    66 	 * - `WP_PROXY_PASSWORD`
    67 	 * - `WP_PROXY_PASSWORD`
    67 	 *
    68 	 *
    68 	 * @since 2.8.0
    69 	 * @since 2.8.0
   206 		static $bypass_hosts   = null;
   207 		static $bypass_hosts   = null;
   207 		static $wildcard_regex = array();
   208 		static $wildcard_regex = array();
   208 		if ( null === $bypass_hosts ) {
   209 		if ( null === $bypass_hosts ) {
   209 			$bypass_hosts = preg_split( '|,\s*|', WP_PROXY_BYPASS_HOSTS );
   210 			$bypass_hosts = preg_split( '|,\s*|', WP_PROXY_BYPASS_HOSTS );
   210 
   211 
   211 			if ( false !== strpos( WP_PROXY_BYPASS_HOSTS, '*' ) ) {
   212 			if ( str_contains( WP_PROXY_BYPASS_HOSTS, '*' ) ) {
   212 				$wildcard_regex = array();
   213 				$wildcard_regex = array();
   213 				foreach ( $bypass_hosts as $host ) {
   214 				foreach ( $bypass_hosts as $host ) {
   214 					$wildcard_regex[] = str_replace( '\*', '.+', preg_quote( $host, '/' ) );
   215 					$wildcard_regex[] = str_replace( '\*', '.+', preg_quote( $host, '/' ) );
   215 				}
   216 				}
   216 				$wildcard_regex = '/^(' . implode( '|', $wildcard_regex ) . ')$/i';
   217 				$wildcard_regex = '/^(' . implode( '|', $wildcard_regex ) . ')$/i';