Changeset 2219135
- Timestamp:
- 12/29/2019 05:14:25 AM (6 years ago)
- Location:
- wp-proxy/trunk
- Files:
-
- 3 edited
-
class-wp-proxy.php (modified) (15 diffs)
-
readme.txt (modified) (2 diffs)
-
wp-proxy.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-proxy/trunk/class-wp-proxy.php
r2218302 r2219135 30 30 /** 31 31 * WP_Proxy Construct 32 *33 * @var wp_proxy34 32 */ 35 33 public function __construct() { … … 54 52 add_action( 'admin_menu', array( $this, 'options_page' ) ); 55 53 add_action( 'admin_init', array( $this, 'register_settings' ) ); 54 add_action( 'admin_init', array( $this, 'wp_proxy_enable_or_disable' ) ); 55 add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 1000 ); 56 56 add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2 ); 57 57 add_filter( 'plugin_row_meta', array( $this, 'plugin_details_links' ), 10, 2 ); … … 107 107 if ( isset( $_POST['option_page'] ) && 'wp_proxy' === sanitize_text_field( wp_unslash( $_POST['option_page'] ) ) && isset( $_POST['_wpnonce'] ) ) { 108 108 if ( wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ), 'wp_proxy-options' ) ) { 109 $wp_proxy_options = $this->options; 109 110 if ( isset( $_POST['proxy_host'] ) ) { 110 111 $wp_proxy_options['proxy_host'] = sanitize_text_field( wp_unslash( $_POST['proxy_host'] ) ); … … 142 143 143 144 /** 145 * Enable or disable 146 * 147 * @since 1.3.4 148 */ 149 public function wp_proxy_enable_or_disable() { 150 // avoid invalid nonce. 151 if ( isset( $_GET['wp_proxy'] ) && check_admin_referer( 'wp-proxy-quick-set', 'wp-proxy-quick-set' ) ) { 152 $wp_proxy_options = $this->options; 153 if ( 'enable' === sanitize_text_field( wp_unslash( $_GET['wp_proxy'] ) ) ) { 154 $wp_proxy_options['enable'] = true; 155 } else { 156 $wp_proxy_options['enable'] = false; 157 } 158 update_option( 'wp_proxy_options', $wp_proxy_options ); 159 } 160 } 161 162 /** 144 163 * In plugins page show some links 145 164 * … … 171 190 } 172 191 return $links; 192 } 193 194 /** 195 * Admin bar menu 196 * 197 * @param mixed $wp_admin_bar admin_bar. 198 * @since 1.3.4 199 */ 200 public function admin_bar_menu( $wp_admin_bar ) { 201 if ( is_user_logged_in() && is_admin_bar_showing() && current_user_can( 'manage_options' ) ) { 202 $options = get_option( 'wp_proxy_options' ); 203 $url = admin_url( 'options-general.php?page=wp_proxy' ); 204 $wp_admin_bar->add_node( 205 array( 206 'id' => 'wp_proxy', 207 'title' => __( 'WP Proxy' ), 208 'href' => $url, 209 ) 210 ); 211 if ( $options['enable'] ) { 212 $wp_admin_bar->add_node( 213 array( 214 'id' => 'disable_wp_proxy', 215 'parent' => 'wp_proxy', 216 'title' => __( 'Disabled' ), 217 'href' => wp_nonce_url( add_query_arg( 'wp_proxy', 'disable' ), 'wp-proxy-quick-set', 'wp-proxy-quick-set' ), 218 ) 219 ); 220 } else { 221 $wp_admin_bar->add_node( 222 array( 223 'id' => 'enable_wp_proxy', 224 'parent' => 'wp_proxy', 225 'title' => __( 'Enabled' ), 226 'href' => wp_nonce_url( add_query_arg( 'wp_proxy', 'enable' ), 'wp-proxy-quick-set', 'wp-proxy-quick-set' ), 227 ) 228 ); 229 } 230 } 173 231 } 174 232 … … 217 275 add_settings_field( 218 276 'proxy_host', 219 esc_html__( 'Proxy Host', 'wp-proxy' ),277 __( 'Hostname' ), 220 278 array( $this, 'proxy_host_callback' ), 221 279 'wp_proxy', … … 224 282 add_settings_field( 225 283 'proxy_port', 226 esc_html__( 'Proxy Port', 'wp-proxy' ),284 __( 'Port' ), 227 285 array( $this, 'proxy_port_callback' ), 228 286 'wp_proxy', … … 231 289 add_settings_field( 232 290 'Username', 233 esc_html__( 'Proxy Username', 'wp-proxy' ),291 __( 'Username' ), 234 292 array( $this, 'proxy_username_callback' ), 235 293 'wp_proxy', … … 238 296 add_settings_field( 239 297 'password', 240 esc_html__( 'Proxy Password', 'wp-proxy' ),298 __( 'Password' ), 241 299 array( $this, 'proxy_password_callback' ), 242 300 'wp_proxy', … … 252 310 add_settings_field( 253 311 'enable', 254 esc_html__( 'Enable', 'wp-proxy' ),312 __( 'Enabled' ), 255 313 array( $this, 'proxy_enable_callback' ), 256 314 'wp_proxy', … … 290 348 public function proxy_host_callback() { 291 349 ?> 292 <input id="proxy_host" name="proxy_host" type="text" placeholder="<?php esc_html_e( ' proxy host', 'wp-proxy' ); ?>" value="<?php echo esc_html( $this->options['proxy_host'] ); ?>" autocomplete="off">350 <input id="proxy_host" name="proxy_host" type="text" placeholder="<?php esc_html_e( 'Hostname' ); ?>" value="<?php echo esc_html( $this->options['proxy_host'] ); ?>" autocomplete="off"> 293 351 <?php 294 352 } … … 301 359 public function proxy_port_callback() { 302 360 ?> 303 <input id="proxy_port" name="proxy_port" type="number" placeholder="<?php esc_html_e( ' proxy port', 'wp-proxy' ); ?>" value="<?php echo esc_html( $this->options['proxy_port'] ); ?>" autocomplete="off">361 <input id="proxy_port" name="proxy_port" type="number" placeholder="<?php esc_html_e( 'Port' ); ?>" value="<?php echo esc_html( $this->options['proxy_port'] ); ?>" autocomplete="off"> 304 362 <?php 305 363 } … … 312 370 public function proxy_username_callback() { 313 371 ?> 314 <input id="username" name="username" type="text" placeholder="<?php esc_html_e( ' username', 'wp-proxy' ); ?>" value="<?php echo esc_html( $this->options['username'] ); ?>" autocomplete="off">372 <input id="username" name="username" type="text" placeholder="<?php esc_html_e( 'Username' ); ?>" value="<?php echo esc_html( $this->options['username'] ); ?>" autocomplete="off"> 315 373 <?php 316 374 } … … 323 381 public function proxy_password_callback() { 324 382 ?> 325 <input id="password" name="password" type="password" placeholder="<?php esc_html_e( ' password', 'wp-proxy' ); ?>" value="<?php echo esc_html( $this->options['password'] ); ?>" autocomplete="off">383 <input id="password" name="password" type="password" placeholder="<?php esc_html_e( 'Password' ); ?>" value="<?php echo esc_html( $this->options['password'] ); ?>" autocomplete="off"> 326 384 <?php 327 385 } … … 347 405 <select name="enable" id="enable"> 348 406 <?php if ( $this->options['enable'] ) { ?> 349 <option value="yes" selected="selected"><?php esc_html_e( ' yes', 'wp-proxy' ); ?></option>350 <option value="no"><?php esc_html_e( ' no', 'wp-proxy' ); ?></option>407 <option value="yes" selected="selected"><?php esc_html_e( 'Yes' ); ?></option> 408 <option value="no"><?php esc_html_e( 'No' ); ?></option> 351 409 <?php } else { ?> 352 <option value="yes"><?php esc_html_e( ' yes', 'wp-proxy' ); ?></option>353 <option value="no" selected="selected"><?php esc_html_e( ' no', 'wp-proxy' ); ?></option>410 <option value="yes"><?php esc_html_e( 'Yes' ); ?></option> 411 <option value="no" selected="selected"><?php esc_html_e( 'No' ); ?></option> 354 412 <?php } ?> 355 413 </select> -
wp-proxy/trunk/readme.txt
r2218302 r2219135 5 5 Requires at least: 3.0.1 6 6 Tested up to: 5.3.2 7 Stable tag: 1.3. 37 Stable tag: 1.3.4 8 8 Requires PHP: 5.2.4 9 9 License: GPLv2 or later … … 31 31 32 32 == Changelog == 33 = 1.3.4 = 34 * use some default text-domain 35 * admin bar menu 36 37 = 1.3.3 = 38 * plugins page show links 33 39 34 40 = 1.3.2 = -
wp-proxy/trunk/wp-proxy.php
r2218302 r2219135 4 4 * Plugin URI: https://xn--vkuk.org/blog/wp-proxy 5 5 * Description: manage proxy for WordPress 6 * Version: 1.3. 36 * Version: 1.3.4 7 7 * Author: sleepm 8 8 * Text Domain: wp-proxy
Note: See TracChangeset
for help on using the changeset viewer.