Changeset 2308925
- Timestamp:
- 05/20/2020 03:54:06 PM (6 years ago)
- Location:
- wp-proxy
- Files:
-
- 3 edited
- 6 copied
-
tags/1.3.8 (copied) (copied from wp-proxy/trunk)
-
tags/1.3.8/LICENSE (copied) (copied from wp-proxy/trunk/LICENSE)
-
tags/1.3.8/class-wp-proxy.php (copied) (copied from wp-proxy/trunk/class-wp-proxy.php) (11 diffs)
-
tags/1.3.8/languages (copied) (copied from wp-proxy/trunk/languages)
-
tags/1.3.8/readme.txt (copied) (copied from wp-proxy/trunk/readme.txt) (2 diffs)
-
tags/1.3.8/wp-proxy.php (copied) (copied from wp-proxy/trunk/wp-proxy.php) (1 diff)
-
trunk/class-wp-proxy.php (modified) (11 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/wp-proxy.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-proxy/tags/1.3.8/class-wp-proxy.php
r2236894 r2308925 37 37 $this->options = $options; 38 38 if ( $options['enable'] ) { 39 add_filter( ' pre_http_request', array( $this, 'pre_http_request' ), 100, 2 );39 add_filter( 'http_request_args', array( $this, 'http_request_args' ), 100, 2 ); 40 40 add_filter( 'pre_http_send_through_proxy', array( $this, 'send_through_proxy' ), 10, 4 ); 41 41 defined( 'WP_PROXY_HOST' ) ? '' : define( 'WP_PROXY_HOST', $options['proxy_host'] ); … … 47 47 defined( 'WP_PROXY_PASSWORD' ) ? '' : define( 'WP_PROXY_PASSWORD', $options['password'] ); 48 48 } 49 add_action( 'http_api_curl', array( $this, 'curl_before_send' ), 100, 3 ); 49 50 } 50 51 } else { … … 97 98 $options['username'] = ''; 98 99 $options['password'] = ''; 100 $options['type'] = ''; 99 101 $options['enable'] = false; 100 102 return $options; … … 129 131 $wp_proxy_options['password'] = sanitize_text_field( wp_unslash( $_POST['password'] ) ); 130 132 } 133 if ( isset( $_POST['type'] ) ) { 134 $wp_proxy_options['type'] = sanitize_text_field( wp_unslash( $_POST['type'] ) ); 135 } 131 136 if ( isset( $_POST['domains'] ) ) { 132 137 $wp_proxy_options['domains'] = str_replace( ' ', "\n", sanitize_text_field( wp_unslash( $_POST['domains'] ) ) ); … … 166 171 * In plugins page show some links 167 172 * 168 * @param array $links links.169 * @param string $file file.173 * @param array $links 174 * @param string $file 170 175 * @since 1.3.2 171 176 */ … … 180 185 * In plugins page show some links 181 186 * 182 * @param array $links links.183 * @param string $file file.187 * @param array $links 188 * @param string $file 184 189 * @since 1.3.2 185 190 */ … … 198 203 * Admin bar menu 199 204 * 200 * @param mixed $wp_admin_bar admin_bar.205 * @param mixed $wp_admin_bar 201 206 * @since 1.3.4 202 207 */ … … 237 242 * Set request arg 238 243 * 239 * @param array $parsed_args args.240 * @param string $url url.241 */ 242 public function pre_http_request( $parsed_args, $url ) {244 * @param array $parsed_args 245 * @param string $url 246 */ 247 public function http_request_args( $parsed_args, $url ) { 243 248 if ( $this->send_through_proxy( null, $url, $url, '' ) ) { 244 249 $parsed_args['timeout'] = $parsed_args['timeout'] + 1200; … … 249 254 250 255 /** 256 * Set proxy type 257 * 258 * @param resource $handle 259 * @param array $request 260 * @param string $url 261 * @since 1.3.8 262 */ 263 public function curl_before_send( $handle, $request, $url ) { 264 if ( $this->send_through_proxy( null, $url, $url, '' ) ) { 265 if ( 'SOCKS5' === $this->options['type'] ) { 266 curl_setopt( $handle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5 ); 267 } elseif ( 'SOCKS4' === $this->options['type'] ) { 268 curl_setopt( $handle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4 ); 269 } elseif ( 'SOCKS4A' === $this->options['type'] ) { 270 curl_setopt( $handle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4A ); 271 } 272 } 273 } 274 275 /** 251 276 * Check URL 252 277 * 253 * @param string $null null.254 * @param string $url url.255 * @param bool $check check result.256 * @param string $home site home.278 * @param string $null 279 * @param string $url 280 * @param bool $check 281 * @param string $home 257 282 * @since 1.0 258 283 */ … … 319 344 __( 'Password' ), 320 345 array( $this, 'proxy_password_callback' ), 346 'wp_proxy', 347 'wp_proxy_config' 348 ); 349 add_settings_field( 350 'type', 351 __( 'Type' ), 352 array( $this, 'proxy_type_callback' ), 321 353 'wp_proxy', 322 354 'wp_proxy_config' … … 407 439 408 440 /** 441 * Show proxy type field 442 * 443 * @since 1.3.8 444 */ 445 public function proxy_type_callback() { 446 ?> 447 <select name="type" id="type" autocomplete="off"> 448 <option value="" <?php selected( $this->options['type'], '', true ); ?>>http</option> 449 <option value="SOCKS5" <?php selected( $this->options['type'], 'SOCKS5', true ); ?>>socks5</option> 450 <option value="SOCKS4" <?php selected( $this->options['type'], 'SOCKS4', true ); ?>>socks4</option> 451 <option value="SOCKS4A" <?php selected( $this->options['type'], 'SOCKS4A', true ); ?>>socks4a</option> 452 </select> 453 <?php 454 } 455 456 /** 409 457 * Show domains field 410 458 * -
wp-proxy/tags/1.3.8/readme.txt
r2236894 r2308925 3 3 Donate link: https://xn--vkuk.org/blog/wp-proxy 4 4 Tags: proxy 5 Requires at least: 3.0.16 Tested up to: 5. 3.27 Stable tag: 1.3. 68 Requires PHP: 5. 2.45 Requires at least: 5.0.0 6 Tested up to: 5.4.1 7 Stable tag: 1.3.8 8 Requires PHP: 5.0.0 9 9 License: GPLv2 or later 10 10 … … 32 32 == Changelog == 33 33 34 = 1.3.8 = 35 support proxy type: http(default), socks5, socks4, socks4a. ps: if use curl as request transport. 36 37 = 1.3.7 = 38 fix http_request_args. (我傻了) 39 34 40 = 1.3.6 = 35 41 fix pre_http_request filter. thanks lcufrankw -
wp-proxy/tags/1.3.8/wp-proxy.php
r2236894 r2308925 4 4 * Plugin URI: https://xn--vkuk.org/blog/wp-proxy 5 5 * Description: manage proxy for WordPress 6 * Version: 1.3. 66 * Version: 1.3.8 7 7 * Author: sleepm 8 8 * Author URI: https://xn--vkuk.org/blog/ -
wp-proxy/trunk/class-wp-proxy.php
r2236894 r2308925 37 37 $this->options = $options; 38 38 if ( $options['enable'] ) { 39 add_filter( ' pre_http_request', array( $this, 'pre_http_request' ), 100, 2 );39 add_filter( 'http_request_args', array( $this, 'http_request_args' ), 100, 2 ); 40 40 add_filter( 'pre_http_send_through_proxy', array( $this, 'send_through_proxy' ), 10, 4 ); 41 41 defined( 'WP_PROXY_HOST' ) ? '' : define( 'WP_PROXY_HOST', $options['proxy_host'] ); … … 47 47 defined( 'WP_PROXY_PASSWORD' ) ? '' : define( 'WP_PROXY_PASSWORD', $options['password'] ); 48 48 } 49 add_action( 'http_api_curl', array( $this, 'curl_before_send' ), 100, 3 ); 49 50 } 50 51 } else { … … 97 98 $options['username'] = ''; 98 99 $options['password'] = ''; 100 $options['type'] = ''; 99 101 $options['enable'] = false; 100 102 return $options; … … 129 131 $wp_proxy_options['password'] = sanitize_text_field( wp_unslash( $_POST['password'] ) ); 130 132 } 133 if ( isset( $_POST['type'] ) ) { 134 $wp_proxy_options['type'] = sanitize_text_field( wp_unslash( $_POST['type'] ) ); 135 } 131 136 if ( isset( $_POST['domains'] ) ) { 132 137 $wp_proxy_options['domains'] = str_replace( ' ', "\n", sanitize_text_field( wp_unslash( $_POST['domains'] ) ) ); … … 166 171 * In plugins page show some links 167 172 * 168 * @param array $links links.169 * @param string $file file.173 * @param array $links 174 * @param string $file 170 175 * @since 1.3.2 171 176 */ … … 180 185 * In plugins page show some links 181 186 * 182 * @param array $links links.183 * @param string $file file.187 * @param array $links 188 * @param string $file 184 189 * @since 1.3.2 185 190 */ … … 198 203 * Admin bar menu 199 204 * 200 * @param mixed $wp_admin_bar admin_bar.205 * @param mixed $wp_admin_bar 201 206 * @since 1.3.4 202 207 */ … … 237 242 * Set request arg 238 243 * 239 * @param array $parsed_args args.240 * @param string $url url.241 */ 242 public function pre_http_request( $parsed_args, $url ) {244 * @param array $parsed_args 245 * @param string $url 246 */ 247 public function http_request_args( $parsed_args, $url ) { 243 248 if ( $this->send_through_proxy( null, $url, $url, '' ) ) { 244 249 $parsed_args['timeout'] = $parsed_args['timeout'] + 1200; … … 249 254 250 255 /** 256 * Set proxy type 257 * 258 * @param resource $handle 259 * @param array $request 260 * @param string $url 261 * @since 1.3.8 262 */ 263 public function curl_before_send( $handle, $request, $url ) { 264 if ( $this->send_through_proxy( null, $url, $url, '' ) ) { 265 if ( 'SOCKS5' === $this->options['type'] ) { 266 curl_setopt( $handle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5 ); 267 } elseif ( 'SOCKS4' === $this->options['type'] ) { 268 curl_setopt( $handle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4 ); 269 } elseif ( 'SOCKS4A' === $this->options['type'] ) { 270 curl_setopt( $handle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4A ); 271 } 272 } 273 } 274 275 /** 251 276 * Check URL 252 277 * 253 * @param string $null null.254 * @param string $url url.255 * @param bool $check check result.256 * @param string $home site home.278 * @param string $null 279 * @param string $url 280 * @param bool $check 281 * @param string $home 257 282 * @since 1.0 258 283 */ … … 319 344 __( 'Password' ), 320 345 array( $this, 'proxy_password_callback' ), 346 'wp_proxy', 347 'wp_proxy_config' 348 ); 349 add_settings_field( 350 'type', 351 __( 'Type' ), 352 array( $this, 'proxy_type_callback' ), 321 353 'wp_proxy', 322 354 'wp_proxy_config' … … 407 439 408 440 /** 441 * Show proxy type field 442 * 443 * @since 1.3.8 444 */ 445 public function proxy_type_callback() { 446 ?> 447 <select name="type" id="type" autocomplete="off"> 448 <option value="" <?php selected( $this->options['type'], '', true ); ?>>http</option> 449 <option value="SOCKS5" <?php selected( $this->options['type'], 'SOCKS5', true ); ?>>socks5</option> 450 <option value="SOCKS4" <?php selected( $this->options['type'], 'SOCKS4', true ); ?>>socks4</option> 451 <option value="SOCKS4A" <?php selected( $this->options['type'], 'SOCKS4A', true ); ?>>socks4a</option> 452 </select> 453 <?php 454 } 455 456 /** 409 457 * Show domains field 410 458 * -
wp-proxy/trunk/readme.txt
r2236894 r2308925 3 3 Donate link: https://xn--vkuk.org/blog/wp-proxy 4 4 Tags: proxy 5 Requires at least: 3.0.16 Tested up to: 5. 3.27 Stable tag: 1.3. 68 Requires PHP: 5. 2.45 Requires at least: 5.0.0 6 Tested up to: 5.4.1 7 Stable tag: 1.3.8 8 Requires PHP: 5.0.0 9 9 License: GPLv2 or later 10 10 … … 32 32 == Changelog == 33 33 34 = 1.3.8 = 35 support proxy type: http(default), socks5, socks4, socks4a. ps: if use curl as request transport. 36 37 = 1.3.7 = 38 fix http_request_args. (我傻了) 39 34 40 = 1.3.6 = 35 41 fix pre_http_request filter. thanks lcufrankw -
wp-proxy/trunk/wp-proxy.php
r2236894 r2308925 4 4 * Plugin URI: https://xn--vkuk.org/blog/wp-proxy 5 5 * Description: manage proxy for WordPress 6 * Version: 1.3. 66 * Version: 1.3.8 7 7 * Author: sleepm 8 8 * Author URI: https://xn--vkuk.org/blog/
Note: See TracChangeset
for help on using the changeset viewer.