@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | use PhpConsole; |
12 | 12 | |
13 | -if ( ! defined( 'WPINC' ) ) { |
|
13 | +if ( ! defined('WPINC')) { |
|
14 | 14 | exit; // Exit if accessed directly |
15 | 15 | } |
16 | 16 | |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | $this->plugin_slug = 'WP PHP Console'; |
70 | 70 | $this->plugin_slug = 'wp-php-console'; |
71 | 71 | $this->version = '1.4.0'; |
72 | - $this->options = get_option( 'wp_php_console' ); |
|
72 | + $this->options = get_option('wp_php_console'); |
|
73 | 73 | |
74 | - if ( ! class_exists( 'PhpConsole\Connector' ) ) { |
|
74 | + if ( ! class_exists('PhpConsole\Connector')) { |
|
75 | 75 | return; |
76 | 76 | } |
77 | 77 | |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | // so all temporary data will be stored in $_SESSION. |
80 | 80 | // But there is some problem with frameworks like WordPress that override PHP session handler. |
81 | 81 | // PHP Console has alternative storage drivers for this - we will write to a temporary file: |
82 | - $phpcdir = dirname( __FILE__ ) . '/tmp'; |
|
83 | - $make_dir = wp_mkdir_p( $phpcdir ); |
|
82 | + $phpcdir = dirname(__FILE__).'/tmp'; |
|
83 | + $make_dir = wp_mkdir_p($phpcdir); |
|
84 | 84 | |
85 | - if ( $make_dir === true ) { |
|
85 | + if ($make_dir === true) { |
|
86 | 86 | PhpConsole\Connector::setPostponeStorage( |
87 | - new PhpConsole\Storage\File( $phpcdir . '/' . md5( __FILE__ ) . '_pc.data', false ) |
|
87 | + new PhpConsole\Storage\File($phpcdir.'/'.md5(__FILE__).'_pc.data', false) |
|
88 | 88 | ); |
89 | 89 | } |
90 | 90 | |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | $connector = PhpConsole\Connector::getInstance(); |
93 | 93 | |
94 | 94 | // Apply 'register' option to PHP Console |
95 | - if ( ! empty( $this->options['register'] ) ) { |
|
96 | - if ( ! class_exists( 'PC', false ) ) { |
|
95 | + if ( ! empty($this->options['register'])) { |
|
96 | + if ( ! class_exists('PC', false)) { |
|
97 | 97 | // Only if PC not registered yet |
98 | 98 | PhpConsole\Helper::register( ); |
99 | 99 | } |
@@ -101,21 +101,21 @@ discard block |
||
101 | 101 | } |
102 | 102 | |
103 | 103 | // Apply 'stack' option to PHP Console |
104 | - if ( ! empty( $this->options['stack'] ) ) { |
|
104 | + if ( ! empty($this->options['stack'])) { |
|
105 | 105 | $connector->getDebugDispatcher()->detectTraceAndSource = true; |
106 | 106 | } |
107 | 107 | |
108 | 108 | // Apply 'short' option to PHP Console |
109 | - if ( ! empty( $this->options['short'] ) ) { |
|
110 | - $connector->setSourcesBasePath( $_SERVER['DOCUMENT_ROOT'] ); |
|
109 | + if ( ! empty($this->options['short'])) { |
|
110 | + $connector->setSourcesBasePath($_SERVER['DOCUMENT_ROOT']); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | // Translation |
114 | - add_action( 'plugins_loaded', array( $this, 'set_locale' ) ); |
|
114 | + add_action('plugins_loaded', array($this, 'set_locale')); |
|
115 | 115 | // Admin menu |
116 | - add_action( 'admin_menu', array( $this, 'register_settings_page' ) ); |
|
116 | + add_action('admin_menu', array($this, 'register_settings_page')); |
|
117 | 117 | // Delay further PHP Console initialisation to have more context during Remote PHP execution |
118 | - add_action( 'wp_loaded', array( $this, 'init' ) ); |
|
118 | + add_action('wp_loaded', array($this, 'init')); |
|
119 | 119 | |
120 | 120 | } |
121 | 121 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | load_plugin_textdomain( |
131 | 131 | $this->plugin_slug, |
132 | 132 | false, |
133 | - dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
|
133 | + dirname(plugin_basename(__FILE__)).'/languages/' ); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | |
@@ -142,14 +142,14 @@ discard block |
||
142 | 142 | public function register_settings_page() { |
143 | 143 | |
144 | 144 | add_options_page( |
145 | - __( 'WP PHP Console', 'wp-php-console' ), |
|
146 | - __( 'WP PHP Console', 'wp-php-console' ), |
|
145 | + __('WP PHP Console', 'wp-php-console'), |
|
146 | + __('WP PHP Console', 'wp-php-console'), |
|
147 | 147 | 'manage_options', |
148 | 148 | $this->plugin_slug, |
149 | - array( $this, 'settings_page' ) |
|
149 | + array($this, 'settings_page') |
|
150 | 150 | ); |
151 | 151 | |
152 | - add_action( 'admin_init', array( $this, 'register_settings' ) ); |
|
152 | + add_action('admin_init', array($this, 'register_settings')); |
|
153 | 153 | |
154 | 154 | } |
155 | 155 | |
@@ -164,60 +164,60 @@ discard block |
||
164 | 164 | register_setting( |
165 | 165 | 'wp_php_console', |
166 | 166 | 'wp_php_console', |
167 | - array( $this, 'sanitize_field' ) |
|
167 | + array($this, 'sanitize_field') |
|
168 | 168 | ); |
169 | 169 | |
170 | 170 | add_settings_section( |
171 | 171 | 'wp_php_console', |
172 | - __( 'Settings', 'wp-php-console' ), |
|
173 | - array( $this, 'settings_info' ), |
|
172 | + __('Settings', 'wp-php-console'), |
|
173 | + array($this, 'settings_info'), |
|
174 | 174 | $this->plugin_slug |
175 | 175 | ); |
176 | 176 | |
177 | 177 | add_settings_field( |
178 | 178 | 'password', |
179 | - __( 'Password', 'wp-php-console' ), |
|
180 | - array( $this, 'password_field' ), |
|
179 | + __('Password', 'wp-php-console'), |
|
180 | + array($this, 'password_field'), |
|
181 | 181 | $this->plugin_slug, |
182 | 182 | 'wp_php_console' |
183 | 183 | ); |
184 | 184 | |
185 | 185 | add_settings_field( |
186 | 186 | 'ssl', |
187 | - __( 'Allow only on SSL', 'wp-php-console' ), |
|
188 | - array( $this, 'ssl_field' ), |
|
187 | + __('Allow only on SSL', 'wp-php-console'), |
|
188 | + array($this, 'ssl_field'), |
|
189 | 189 | $this->plugin_slug, |
190 | 190 | 'wp_php_console' |
191 | 191 | ); |
192 | 192 | |
193 | 193 | add_settings_field( |
194 | 194 | 'ip', |
195 | - __( 'Allowed IP Masks', 'wp-php-console' ), |
|
196 | - array( $this, 'ip_field' ), |
|
195 | + __('Allowed IP Masks', 'wp-php-console'), |
|
196 | + array($this, 'ip_field'), |
|
197 | 197 | $this->plugin_slug, |
198 | 198 | 'wp_php_console' |
199 | 199 | ); |
200 | 200 | |
201 | 201 | add_settings_field( |
202 | 202 | 'register', |
203 | - __( 'Register PC Class ', 'wp-php-console' ), |
|
204 | - array( $this, 'register_field' ), |
|
203 | + __('Register PC Class ', 'wp-php-console'), |
|
204 | + array($this, 'register_field'), |
|
205 | 205 | $this->plugin_slug, |
206 | 206 | 'wp_php_console' |
207 | 207 | ); |
208 | 208 | |
209 | 209 | add_settings_field( |
210 | 210 | 'stack', |
211 | - __( 'Show Call Stack', 'wp-php-console' ), |
|
212 | - array( $this, 'stack_field' ), |
|
211 | + __('Show Call Stack', 'wp-php-console'), |
|
212 | + array($this, 'stack_field'), |
|
213 | 213 | $this->plugin_slug, |
214 | 214 | 'wp_php_console' |
215 | 215 | ); |
216 | 216 | |
217 | 217 | add_settings_field( |
218 | 218 | 'short', |
219 | - __( 'Short Path Names', 'wp-php-console' ), |
|
220 | - array( $this, 'short_field' ), |
|
219 | + __('Short Path Names', 'wp-php-console'), |
|
220 | + array($this, 'short_field'), |
|
221 | 221 | $this->plugin_slug, |
222 | 222 | 'wp_php_console' |
223 | 223 | ); |
@@ -232,13 +232,13 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function password_field() { |
234 | 234 | |
235 | - printf ( |
|
235 | + printf( |
|
236 | 236 | '<input type="password" id="wp-php-console-password" name="wp_php_console[password]" value="%s" />', |
237 | - isset( $this->options['password'] ) ? esc_attr( $this->options['password'] ) : '' |
|
237 | + isset($this->options['password']) ? esc_attr($this->options['password']) : '' |
|
238 | 238 | ); |
239 | - echo '<label for="wp-php-console-ip">' . esc_html__( 'Required', 'wp-php-console' ) . '</label>'; |
|
239 | + echo '<label for="wp-php-console-ip">'.esc_html__('Required', 'wp-php-console').'</label>'; |
|
240 | 240 | echo '<br />'; |
241 | - echo '<small class="description">' . __( 'The password for the eval terminal. If empty, the plugin will not work.', 'wp-php-console' ) . '</small>'; |
|
241 | + echo '<small class="description">'.__('The password for the eval terminal. If empty, the plugin will not work.', 'wp-php-console').'</small>'; |
|
242 | 242 | |
243 | 243 | } |
244 | 244 | |
@@ -250,15 +250,15 @@ discard block |
||
250 | 250 | */ |
251 | 251 | public function ssl_field() { |
252 | 252 | |
253 | - $ssl = isset( $this->options['ssl'] ) ? esc_attr( $this->options['ssl']) : ''; |
|
253 | + $ssl = isset($this->options['ssl']) ? esc_attr($this->options['ssl']) : ''; |
|
254 | 254 | |
255 | - printf ( |
|
255 | + printf( |
|
256 | 256 | '<input type="checkbox" id="wp-php-console-ssl" name="wp_php_console[ssl]" value="1" %s /> ', |
257 | 257 | $ssl ? 'checked="checked"' : '' |
258 | 258 | ); |
259 | - echo '<label for="wp-php-console-ssl">' . esc_html__( 'Yes', 'wp-php-console' ) . '</label>'; |
|
259 | + echo '<label for="wp-php-console-ssl">'.esc_html__('Yes', 'wp-php-console').'</label>'; |
|
260 | 260 | echo '<br />'; |
261 | - echo '<small class="description">' . __( 'Tick this option if you want the eval terminal to work only on a SSL connection.', 'wp-php-console' ) . '</small>'; |
|
261 | + echo '<small class="description">'.__('Tick this option if you want the eval terminal to work only on a SSL connection.', 'wp-php-console').'</small>'; |
|
262 | 262 | |
263 | 263 | } |
264 | 264 | |
@@ -270,14 +270,14 @@ discard block |
||
270 | 270 | */ |
271 | 271 | public function ip_field() { |
272 | 272 | |
273 | - printf ( |
|
273 | + printf( |
|
274 | 274 | '<input type="text" class="regular-text" id="wp-php-console-ip" name="wp_php_console[ip]" value="%s" /> ', |
275 | - isset( $this->options['ip'] ) ? esc_attr( $this->options['ip']) : '' |
|
275 | + isset($this->options['ip']) ? esc_attr($this->options['ip']) : '' |
|
276 | 276 | ); |
277 | - echo '<label for="wp-php-console-ip">' . esc_html__( 'IP addresses (optional)', 'wp-php-console' ) . '</label>'; |
|
277 | + echo '<label for="wp-php-console-ip">'.esc_html__('IP addresses (optional)', 'wp-php-console').'</label>'; |
|
278 | 278 | echo '<br />'; |
279 | 279 | // translators VVV Varying Vagrant Vagrants default IP address |
280 | - printf ( __( '<small class="description">' . __( 'You may specify an IP address (e.g. <code>192.168.50.4</code>, %s default IP address), a range of addresses (<code>192.168.*.*</code>) or multiple addresses, comma separated (<code>192.168.10.25,192.168.10.28</code>) to grant access to the eval terminal.', 'wp-php-console' ) . '</small>' ), '<a href="https://github.com/Varying-Vagrant-Vagrants/VVV">Varying Vagrant Vagrants</a>' ); |
|
280 | + printf(__('<small class="description">'.__('You may specify an IP address (e.g. <code>192.168.50.4</code>, %s default IP address), a range of addresses (<code>192.168.*.*</code>) or multiple addresses, comma separated (<code>192.168.10.25,192.168.10.28</code>) to grant access to the eval terminal.', 'wp-php-console').'</small>'), '<a href="https://github.com/Varying-Vagrant-Vagrants/VVV">Varying Vagrant Vagrants</a>'); |
|
281 | 281 | |
282 | 282 | } |
283 | 283 | |
@@ -289,15 +289,15 @@ discard block |
||
289 | 289 | */ |
290 | 290 | public function register_field() { |
291 | 291 | |
292 | - $register = ! empty( $this->options['register'] ); |
|
292 | + $register = ! empty($this->options['register']); |
|
293 | 293 | |
294 | - printf ( |
|
294 | + printf( |
|
295 | 295 | '<input type="checkbox" id="wp-php-console-register" name="wp_php_console[register]" value="1" %s /> ', |
296 | 296 | $register ? 'checked="checked"' : '' |
297 | 297 | ); |
298 | - echo '<label for="wp-php-console-register">' . esc_html__( 'Yes', 'wp-php-console' ) . '</label>'; |
|
298 | + echo '<label for="wp-php-console-register">'.esc_html__('Yes', 'wp-php-console').'</label>'; |
|
299 | 299 | echo '<br />'; |
300 | - echo '<small class="description">' . __( 'Choose to register PC in the global namespace. Allows to write <code>PC::debug($var, $tag)</code> or <code>PC::magic_tag($var)</code> instructions in PHP to inspect <code>$var</code> in the JavaScript console.', 'wp-php-console' ) . '</small>'; |
|
300 | + echo '<small class="description">'.__('Choose to register PC in the global namespace. Allows to write <code>PC::debug($var, $tag)</code> or <code>PC::magic_tag($var)</code> instructions in PHP to inspect <code>$var</code> in the JavaScript console.', 'wp-php-console').'</small>'; |
|
301 | 301 | |
302 | 302 | } |
303 | 303 | |
@@ -309,15 +309,15 @@ discard block |
||
309 | 309 | */ |
310 | 310 | public function stack_field() { |
311 | 311 | |
312 | - $stack = ! empty( $this->options['stack'] ); |
|
312 | + $stack = ! empty($this->options['stack']); |
|
313 | 313 | |
314 | - printf ( |
|
314 | + printf( |
|
315 | 315 | '<input type="checkbox" id="wp-php-console-stack" name="wp_php_console[stack]" value="1" %s /> ', |
316 | 316 | $stack ? 'checked="checked"' : '' |
317 | 317 | ); |
318 | - echo '<label for="wp-php-console-stack">' . esc_html__( 'Yes', 'wp-php-console' ) . '</label>'; |
|
318 | + echo '<label for="wp-php-console-stack">'.esc_html__('Yes', 'wp-php-console').'</label>'; |
|
319 | 319 | echo '<br />'; |
320 | - echo '<small class="description">' . __( "Choose to also see the call stack when PHP Console writes to the browser's JavaScript-console.", 'wp-php-console' ) . '</small>'; |
|
320 | + echo '<small class="description">'.__("Choose to also see the call stack when PHP Console writes to the browser's JavaScript-console.", 'wp-php-console').'</small>'; |
|
321 | 321 | |
322 | 322 | } |
323 | 323 | |
@@ -329,15 +329,15 @@ discard block |
||
329 | 329 | */ |
330 | 330 | public function short_field() { |
331 | 331 | |
332 | - $short = ! empty( $this->options['short'] ); |
|
332 | + $short = ! empty($this->options['short']); |
|
333 | 333 | |
334 | - printf ( |
|
334 | + printf( |
|
335 | 335 | '<input type="checkbox" id="wp-php-console-short" name="wp_php_console[short]" value="1" %s /> ', |
336 | 336 | $short ? 'checked="checked"' : '' |
337 | 337 | ); |
338 | - echo '<label for="wp-php-console-short">' . esc_html__( 'Yes', 'wp-php-console' ) . '</label>'; |
|
338 | + echo '<label for="wp-php-console-short">'.esc_html__('Yes', 'wp-php-console').'</label>'; |
|
339 | 339 | echo '<br />'; |
340 | - echo '<small class="description">' . __( "Choose to shorten PHP Console error sources and traces paths in browser's JavaScript-console. Paths like <code>/server/path/to/document/root/WP/wp-admin/admin.php:31</code> will be displayed as <code>/W/wp-admin/admin.php:31</code>", 'wp-php-console' ) . '</small>'; |
|
340 | + echo '<small class="description">'.__("Choose to shorten PHP Console error sources and traces paths in browser's JavaScript-console. Paths like <code>/server/path/to/document/root/WP/wp-admin/admin.php:31</code> will be displayed as <code>/W/wp-admin/admin.php:31</code>", 'wp-php-console').'</small>'; |
|
341 | 341 | |
342 | 342 | } |
343 | 343 | |
@@ -349,25 +349,25 @@ discard block |
||
349 | 349 | * @param string $input user input |
350 | 350 | * @return array sanitized inputs |
351 | 351 | */ |
352 | - public function sanitize_field( $input ) { |
|
352 | + public function sanitize_field($input) { |
|
353 | 353 | |
354 | 354 | $sanitized_input = array(); |
355 | 355 | |
356 | - if ( isset( $input['password'] ) ) { |
|
357 | - $sanitized_input['password'] = sanitize_text_field( $input['password'] ); |
|
356 | + if (isset($input['password'])) { |
|
357 | + $sanitized_input['password'] = sanitize_text_field($input['password']); |
|
358 | 358 | } |
359 | 359 | |
360 | - if ( isset( $input['ssl'] ) ) { |
|
361 | - $sanitized_input['ssl'] = ! empty( $input['ssl'] ) ? 1 : ''; |
|
360 | + if (isset($input['ssl'])) { |
|
361 | + $sanitized_input['ssl'] = ! empty($input['ssl']) ? 1 : ''; |
|
362 | 362 | } |
363 | 363 | |
364 | - if ( isset( $input['ip'] ) ) { |
|
365 | - $sanitized_input['ip'] = sanitize_text_field( $input['ip'] ); |
|
364 | + if (isset($input['ip'])) { |
|
365 | + $sanitized_input['ip'] = sanitize_text_field($input['ip']); |
|
366 | 366 | } |
367 | 367 | |
368 | - $sanitized_input['register'] = empty( $input['register'] ) ? '' : 1; |
|
369 | - $sanitized_input['stack'] = empty( $input['stack'] ) ? '' : 1; |
|
370 | - $sanitized_input['short'] = empty( $input['short'] ) ? '' : 1; |
|
368 | + $sanitized_input['register'] = empty($input['register']) ? '' : 1; |
|
369 | + $sanitized_input['stack'] = empty($input['stack']) ? '' : 1; |
|
370 | + $sanitized_input['short'] = empty($input['short']) ? '' : 1; |
|
371 | 371 | |
372 | 372 | return $sanitized_input; |
373 | 373 | } |
@@ -382,12 +382,12 @@ discard block |
||
382 | 382 | |
383 | 383 | ?> |
384 | 384 | <div class="wrap"> |
385 | - <h2><?php esc_html_e( 'WP PHP Console', 'wp-php-console' ); ?></h2> |
|
385 | + <h2><?php esc_html_e('WP PHP Console', 'wp-php-console'); ?></h2> |
|
386 | 386 | <hr /> |
387 | 387 | <form method="post" action="options.php"> |
388 | 388 | <?php |
389 | - settings_fields( 'wp_php_console' ); |
|
390 | - do_settings_sections( $this->plugin_slug ); |
|
389 | + settings_fields('wp_php_console'); |
|
390 | + do_settings_sections($this->plugin_slug); |
|
391 | 391 | submit_button(); |
392 | 392 | ?> |
393 | 393 | </form> |
@@ -407,14 +407,14 @@ discard block |
||
407 | 407 | |
408 | 408 | ?> |
409 | 409 | <p><?php // Translators: %s refers to 'PHP Console' Chrome extension, will print download link for the Chrome extension |
410 | - printf( _x( 'This plugin allows you to use %s within your WordPress installation for testing, debugging and development purposes.<br/>Usage instructions:', 'PHP Console, the Chrome Extension', 'wp-php-console' ), '<a href="https://github.com/barbushin/php-console" target="_blank">PHP Console</a>' ); ?></p> |
|
410 | + printf(_x('This plugin allows you to use %s within your WordPress installation for testing, debugging and development purposes.<br/>Usage instructions:', 'PHP Console, the Chrome Extension', 'wp-php-console'), '<a href="https://github.com/barbushin/php-console" target="_blank">PHP Console</a>'); ?></p> |
|
411 | 411 | <ol> |
412 | 412 | <li><?php // Translators: Install PHP Console extension for Google Chrome download link |
413 | - printf( _x( 'Make sure you have downloaded and installed %s.', 'PHP Console, the Chrome Extension', 'wp-php-console' ), '<a target="_blank" href="https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef">PHP Console extension for Google Chrome</a>' ); ?></li> |
|
414 | - <li><?php _e( 'Set a password for the eval terminal in the options below and hit <code>save changes</code>.', 'wp-php-console' ); ?></li> |
|
415 | - <li><?php _e( 'Reload any page of your installation and click on the key icon in your Chrome browser address bar, enter your password and access the terminal.', 'wp-php-console' ); ?></li> |
|
416 | - <li><?php _e( 'From the eval terminal you can execute any PHP or WordPress specific function, including functions from your plugins and active theme.', 'wp-php-console' ); ?></li> |
|
417 | - <li><?php _e( "In your PHP code, you can call PHP Console debug statements like <code>debug($var, $tag)</code> to display PHP variables in the browser's JavaScript-console (<code>Ctrl Shift J </code>) and optionally filter selected tags through the browser's Remote PHP Eval Terminal screen's Ignore Debug options.", 'wp-php-console' ); ?></li> |
|
413 | + printf(_x('Make sure you have downloaded and installed %s.', 'PHP Console, the Chrome Extension', 'wp-php-console'), '<a target="_blank" href="https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef">PHP Console extension for Google Chrome</a>'); ?></li> |
|
414 | + <li><?php _e('Set a password for the eval terminal in the options below and hit <code>save changes</code>.', 'wp-php-console'); ?></li> |
|
415 | + <li><?php _e('Reload any page of your installation and click on the key icon in your Chrome browser address bar, enter your password and access the terminal.', 'wp-php-console'); ?></li> |
|
416 | + <li><?php _e('From the eval terminal you can execute any PHP or WordPress specific function, including functions from your plugins and active theme.', 'wp-php-console'); ?></li> |
|
417 | + <li><?php _e("In your PHP code, you can call PHP Console debug statements like <code>debug($var, $tag)</code> to display PHP variables in the browser's JavaScript-console (<code>Ctrl Shift J </code>) and optionally filter selected tags through the browser's Remote PHP Eval Terminal screen's Ignore Debug options.", 'wp-php-console'); ?></li> |
|
418 | 418 | </ol> |
419 | 419 | <?php |
420 | 420 | |
@@ -429,47 +429,47 @@ discard block |
||
429 | 429 | public function init() { |
430 | 430 | |
431 | 431 | // Display admin notice and abort if no password has been set |
432 | - $password = isset( $this->options['password'] ) ? $this->options['password'] : ''; |
|
433 | - if ( ! $password ) { |
|
434 | - add_action( 'admin_notices', array( $this, 'password_notice' ) ); |
|
432 | + $password = isset($this->options['password']) ? $this->options['password'] : ''; |
|
433 | + if ( ! $password) { |
|
434 | + add_action('admin_notices', array($this, 'password_notice')); |
|
435 | 435 | return; // abort |
436 | 436 | } |
437 | 437 | |
438 | 438 | // Selectively remove slashes added by WordPress as expected by PhpConsole |
439 | - if ( isset( $_POST[PhpConsole\Connector::POST_VAR_NAME] ) ) { |
|
440 | - $_POST[ PhpConsole\Connector::POST_VAR_NAME ] = stripslashes_deep( $_POST[ PhpConsole\Connector::POST_VAR_NAME ] ); |
|
439 | + if (isset($_POST[PhpConsole\Connector::POST_VAR_NAME])) { |
|
440 | + $_POST[PhpConsole\Connector::POST_VAR_NAME] = stripslashes_deep($_POST[PhpConsole\Connector::POST_VAR_NAME]); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | $connector = PhpConsole\Connector::getInstance(); |
444 | - $connector->setPassword( $password ); |
|
444 | + $connector->setPassword($password); |
|
445 | 445 | |
446 | 446 | // PhpConsole instance |
447 | 447 | $handler = PhpConsole\Handler::getInstance(); |
448 | - if ( PhpConsole\Handler::getInstance()->isStarted() != true ) { |
|
448 | + if (PhpConsole\Handler::getInstance()->isStarted() != true) { |
|
449 | 449 | $handler->start(); |
450 | 450 | } |
451 | 451 | |
452 | 452 | // Enable SSL-only mode |
453 | - $enableSslOnlyMode = isset( $this->options['ssl'] ) ? ( ! empty( $this->options['ssl'] ) ? $this->options['ssl'] : '' ) : ''; |
|
454 | - if ( $enableSslOnlyMode ) { |
|
453 | + $enableSslOnlyMode = isset($this->options['ssl']) ? ( ! empty($this->options['ssl']) ? $this->options['ssl'] : '') : ''; |
|
454 | + if ($enableSslOnlyMode) { |
|
455 | 455 | $connector->enableSslOnlyMode(); |
456 | 456 | } |
457 | 457 | |
458 | 458 | // Restrict IP addresses |
459 | - $allowedIpMasks = isset( $this->options['ip'] ) ? ( ! empty( $this->options['ip'] ) ? explode( ',', $this->options['ip'] ) : '' ) : ''; |
|
460 | - if ( is_array( $allowedIpMasks ) && ! empty( $allowedIpMasks ) ) { |
|
461 | - $connector->setAllowedIpMasks( (array) $allowedIpMasks ); |
|
459 | + $allowedIpMasks = isset($this->options['ip']) ? ( ! empty($this->options['ip']) ? explode(',', $this->options['ip']) : '') : ''; |
|
460 | + if (is_array($allowedIpMasks) && ! empty($allowedIpMasks)) { |
|
461 | + $connector->setAllowedIpMasks((array) $allowedIpMasks); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | $evalProvider = $connector->getEvalDispatcher()->getEvalProvider(); |
465 | 465 | |
466 | - $evalProvider->addSharedVar( 'uri', $_SERVER['REQUEST_URI'] ); |
|
467 | - $evalProvider->addSharedVarReference( 'post', $_POST ); |
|
466 | + $evalProvider->addSharedVar('uri', $_SERVER['REQUEST_URI']); |
|
467 | + $evalProvider->addSharedVarReference('post', $_POST); |
|
468 | 468 | |
469 | 469 | // $evalProvider->disableFileAccessByOpenBaseDir(); |
470 | - $openBaseDirs = array( ABSPATH, get_template_directory() ); |
|
471 | - $evalProvider->addSharedVarReference( 'dirs', $openBaseDirs ); |
|
472 | - $evalProvider->setOpenBaseDirs( $openBaseDirs ); |
|
470 | + $openBaseDirs = array(ABSPATH, get_template_directory()); |
|
471 | + $evalProvider->addSharedVarReference('dirs', $openBaseDirs); |
|
472 | + $evalProvider->setOpenBaseDirs($openBaseDirs); |
|
473 | 473 | |
474 | 474 | $connector->startEvalRequestsListener(); |
475 | 475 | |
@@ -484,11 +484,11 @@ discard block |
||
484 | 484 | */ |
485 | 485 | public function password_notice() { |
486 | 486 | |
487 | - $settings_page = esc_url( admin_url( 'options-general.php?page=wp-php-console' ) ); |
|
487 | + $settings_page = esc_url(admin_url('options-general.php?page=wp-php-console')); |
|
488 | 488 | |
489 | 489 | ?> |
490 | 490 | <div class="update-nag"> |
491 | - <?php printf( $this->plugin_name . ': ' . __( 'Please remember to %1$s set a password %2$s if you want to enable terminal.', 'wp-php-console' ), '<a href="' . $settings_page .'">', '</a>' ); ?> |
|
491 | + <?php printf($this->plugin_name.': '.__('Please remember to %1$s set a password %2$s if you want to enable terminal.', 'wp-php-console'), '<a href="'.$settings_page.'">', '</a>'); ?> |
|
492 | 492 | </div> |
493 | 493 | <?php |
494 | 494 |
@@ -7,8 +7,8 @@ |
||
7 | 7 | * @package WP_PHP_Console |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
10 | +if ( ! defined('WP_UNINSTALL_PLUGIN')) { |
|
11 | 11 | exit; // If uninstall not called from WordPress, then exit. |
12 | 12 | } |
13 | 13 | |
14 | -delete_option( 'wp_php_console' ); |
|
14 | +delete_option('wp_php_console'); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * Domain Path: /languages |
17 | 17 | */ |
18 | 18 | |
19 | -if ( ! defined( 'WPINC' ) ) { |
|
19 | +if ( ! defined('WPINC')) { |
|
20 | 20 | exit; |
21 | 21 | } |
22 | 22 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | |
46 | 46 | // Composer fallback for PHP < 5.3.0. |
47 | -if ( version_compare( PHP_VERSION, '5.3.0' ) === -1 ) { |
|
47 | +if (version_compare(PHP_VERSION, '5.3.0') === -1) { |
|
48 | 48 | include_once 'vendor/autoload_52.php'; |
49 | 49 | } else { |
50 | 50 | include_once 'vendor/autoload.php'; |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | */ |
58 | 58 | $this_plugin_checks = new WP_Requirements( |
59 | 59 | 'WP PHP Console', |
60 | - plugin_basename( __FILE__ ), |
|
60 | + plugin_basename(__FILE__), |
|
61 | 61 | array( |
62 | 62 | 'PHP' => '5.4.0', |
63 | 63 | ) |
64 | 64 | ); |
65 | 65 | |
66 | -if ( $this_plugin_checks->pass() === false ) { |
|
66 | +if ($this_plugin_checks->pass() === false) { |
|
67 | 67 | // Stop. |
68 | 68 | $this_plugin_checks->halt(); |
69 | 69 | return; |