@@ -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; |
@@ -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 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $this->options = $this->get_options(); |
74 | 74 | |
75 | 75 | // Bail out if PHP Console can't be found |
76 | - if ( ! class_exists( 'PhpConsole\Connector' ) ) { |
|
76 | + if ( ! class_exists('PhpConsole\Connector')) { |
|
77 | 77 | return; |
78 | 78 | } |
79 | 79 | |
@@ -81,15 +81,15 @@ discard block |
||
81 | 81 | // so all temporary data will be stored in $_SESSION. |
82 | 82 | // But there is some problem with frameworks like WordPress that override PHP session handler. |
83 | 83 | // PHP Console has alternative storage drivers for this - we will write to a temporary file: |
84 | - $phpcdir = dirname( __FILE__ ) . '/tmp'; |
|
85 | - $make_dir = wp_mkdir_p( $phpcdir ); |
|
84 | + $phpcdir = dirname(__FILE__).'/tmp'; |
|
85 | + $make_dir = wp_mkdir_p($phpcdir); |
|
86 | 86 | |
87 | - if ( $make_dir === true ) { |
|
87 | + if ($make_dir === true) { |
|
88 | 88 | |
89 | 89 | try { |
90 | - $storage = new PhpConsole\Storage\File( $phpcdir . '/' . md5( __FILE__ ) . '_pc.data' ); |
|
91 | - PhpConsole\Connector::setPostponeStorage( $storage ); |
|
92 | - } catch( \Exception $e ) { |
|
90 | + $storage = new PhpConsole\Storage\File($phpcdir.'/'.md5(__FILE__).'_pc.data'); |
|
91 | + PhpConsole\Connector::setPostponeStorage($storage); |
|
92 | + } catch (\Exception $e) { |
|
93 | 93 | // TODO $storage is under DOCUMENT_ROOT - it's insecure but did not find another solution in WP |
94 | 94 | // $this->print_notice_exception( $e ); |
95 | 95 | } |
@@ -100,35 +100,35 @@ discard block |
||
100 | 100 | $connector = PhpConsole\Connector::getInstance(); |
101 | 101 | |
102 | 102 | // Apply 'register' option to PHP Console |
103 | - if ( ! empty( $this->options['register'] ) && ! class_exists( 'PC', false ) ) { |
|
103 | + if ( ! empty($this->options['register']) && ! class_exists('PC', false)) { |
|
104 | 104 | // Only if PC not registered yet |
105 | 105 | try { |
106 | 106 | PhpConsole\Helper::register(); |
107 | - } catch( \Exception $e ) { |
|
108 | - $this->print_notice_exception( $e ); |
|
107 | + } catch (\Exception $e) { |
|
108 | + $this->print_notice_exception($e); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | 112 | // Apply 'stack' option to PHP Console |
113 | - if ( ! empty( $this->options['stack'] ) ) { |
|
113 | + if ( ! empty($this->options['stack'])) { |
|
114 | 114 | $connector->getDebugDispatcher()->detectTraceAndSource = true; |
115 | 115 | } |
116 | 116 | |
117 | 117 | // Apply 'short' option to PHP Console |
118 | - if ( ! empty( $this->options['short'] ) ) { |
|
118 | + if ( ! empty($this->options['short'])) { |
|
119 | 119 | try { |
120 | - $connector->setSourcesBasePath( $_SERVER['DOCUMENT_ROOT'] ); |
|
121 | - } catch ( \Exception $e ) { |
|
122 | - $this->print_notice_exception( $e ); |
|
120 | + $connector->setSourcesBasePath($_SERVER['DOCUMENT_ROOT']); |
|
121 | + } catch (\Exception $e) { |
|
122 | + $this->print_notice_exception($e); |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | 126 | // Translation |
127 | - add_action( 'plugins_loaded', array( $this, 'set_locale' ) ); |
|
127 | + add_action('plugins_loaded', array($this, 'set_locale')); |
|
128 | 128 | // Admin menu |
129 | - add_action( 'admin_menu', array( $this, 'register_settings_page' ) ); |
|
129 | + add_action('admin_menu', array($this, 'register_settings_page')); |
|
130 | 130 | // Delay further PHP Console initialisation to have more context during Remote PHP execution |
131 | - add_action( 'wp_loaded', array( $this, 'init' ) ); |
|
131 | + add_action('wp_loaded', array($this, 'init')); |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @return array |
141 | 141 | */ |
142 | 142 | protected function get_options() { |
143 | - return get_option( 'wp_php_console', array() ); |
|
143 | + return get_option('wp_php_console', array()); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
@@ -151,13 +151,13 @@ discard block |
||
151 | 151 | * @param \Exception $e Exception object |
152 | 152 | * @return void |
153 | 153 | */ |
154 | - protected function print_notice_exception( \Exception $e ) { |
|
154 | + protected function print_notice_exception(\Exception $e) { |
|
155 | 155 | |
156 | - add_action( 'admin_notices', function() use ( $e ) { |
|
156 | + add_action('admin_notices', function() use ($e) { |
|
157 | 157 | |
158 | 158 | ?> |
159 | 159 | <div class="error"> |
160 | - <p><?php echo $this->plugin_name . ': ' . $e->getMessage(); ?></p> |
|
160 | + <p><?php echo $this->plugin_name.': '.$e->getMessage(); ?></p> |
|
161 | 161 | </div> |
162 | 162 | <?php |
163 | 163 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | load_plugin_textdomain( |
176 | 176 | $this->plugin_slug, |
177 | 177 | false, |
178 | - dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
|
178 | + dirname(plugin_basename(__FILE__)).'/languages/' ); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | |
@@ -187,14 +187,14 @@ discard block |
||
187 | 187 | public function register_settings_page() { |
188 | 188 | |
189 | 189 | add_options_page( |
190 | - __( 'WP PHP Console', 'wp-php-console' ), |
|
191 | - __( 'WP PHP Console', 'wp-php-console' ), |
|
190 | + __('WP PHP Console', 'wp-php-console'), |
|
191 | + __('WP PHP Console', 'wp-php-console'), |
|
192 | 192 | 'manage_options', |
193 | 193 | $this->plugin_slug, |
194 | - array( $this, 'settings_page' ) |
|
194 | + array($this, 'settings_page') |
|
195 | 195 | ); |
196 | 196 | |
197 | - add_action( 'admin_init', array( $this, 'register_settings' ) ); |
|
197 | + add_action('admin_init', array($this, 'register_settings')); |
|
198 | 198 | |
199 | 199 | } |
200 | 200 | |
@@ -209,60 +209,60 @@ discard block |
||
209 | 209 | register_setting( |
210 | 210 | 'wp_php_console', |
211 | 211 | 'wp_php_console', |
212 | - array( $this, 'sanitize_field' ) |
|
212 | + array($this, 'sanitize_field') |
|
213 | 213 | ); |
214 | 214 | |
215 | 215 | add_settings_section( |
216 | 216 | 'wp_php_console', |
217 | - __( 'Settings', 'wp-php-console' ), |
|
218 | - array( $this, 'settings_info' ), |
|
217 | + __('Settings', 'wp-php-console'), |
|
218 | + array($this, 'settings_info'), |
|
219 | 219 | $this->plugin_slug |
220 | 220 | ); |
221 | 221 | |
222 | 222 | add_settings_field( |
223 | 223 | 'password', |
224 | - __( 'Password', 'wp-php-console' ), |
|
225 | - array( $this, 'password_field' ), |
|
224 | + __('Password', 'wp-php-console'), |
|
225 | + array($this, 'password_field'), |
|
226 | 226 | $this->plugin_slug, |
227 | 227 | 'wp_php_console' |
228 | 228 | ); |
229 | 229 | |
230 | 230 | add_settings_field( |
231 | 231 | 'ssl', |
232 | - __( 'Allow only on SSL', 'wp-php-console' ), |
|
233 | - array( $this, 'ssl_field' ), |
|
232 | + __('Allow only on SSL', 'wp-php-console'), |
|
233 | + array($this, 'ssl_field'), |
|
234 | 234 | $this->plugin_slug, |
235 | 235 | 'wp_php_console' |
236 | 236 | ); |
237 | 237 | |
238 | 238 | add_settings_field( |
239 | 239 | 'ip', |
240 | - __( 'Allowed IP Masks', 'wp-php-console' ), |
|
241 | - array( $this, 'ip_field' ), |
|
240 | + __('Allowed IP Masks', 'wp-php-console'), |
|
241 | + array($this, 'ip_field'), |
|
242 | 242 | $this->plugin_slug, |
243 | 243 | 'wp_php_console' |
244 | 244 | ); |
245 | 245 | |
246 | 246 | add_settings_field( |
247 | 247 | 'register', |
248 | - __( 'Register PC Class ', 'wp-php-console' ), |
|
249 | - array( $this, 'register_field' ), |
|
248 | + __('Register PC Class ', 'wp-php-console'), |
|
249 | + array($this, 'register_field'), |
|
250 | 250 | $this->plugin_slug, |
251 | 251 | 'wp_php_console' |
252 | 252 | ); |
253 | 253 | |
254 | 254 | add_settings_field( |
255 | 255 | 'stack', |
256 | - __( 'Show Call Stack', 'wp-php-console' ), |
|
257 | - array( $this, 'stack_field' ), |
|
256 | + __('Show Call Stack', 'wp-php-console'), |
|
257 | + array($this, 'stack_field'), |
|
258 | 258 | $this->plugin_slug, |
259 | 259 | 'wp_php_console' |
260 | 260 | ); |
261 | 261 | |
262 | 262 | add_settings_field( |
263 | 263 | 'short', |
264 | - __( 'Short Path Names', 'wp-php-console' ), |
|
265 | - array( $this, 'short_field' ), |
|
264 | + __('Short Path Names', 'wp-php-console'), |
|
265 | + array($this, 'short_field'), |
|
266 | 266 | $this->plugin_slug, |
267 | 267 | 'wp_php_console' |
268 | 268 | ); |
@@ -277,13 +277,13 @@ discard block |
||
277 | 277 | */ |
278 | 278 | public function password_field() { |
279 | 279 | |
280 | - printf ( |
|
280 | + printf( |
|
281 | 281 | '<input type="password" id="wp-php-console-password" name="wp_php_console[password]" value="%s" />', |
282 | - isset( $this->options['password'] ) ? esc_attr( $this->options['password'] ) : '' |
|
282 | + isset($this->options['password']) ? esc_attr($this->options['password']) : '' |
|
283 | 283 | ); |
284 | - echo '<label for="wp-php-console-ip">' . esc_html__( 'Required', 'wp-php-console' ) . '</label>'; |
|
284 | + echo '<label for="wp-php-console-ip">'.esc_html__('Required', 'wp-php-console').'</label>'; |
|
285 | 285 | echo '<br />'; |
286 | - echo '<small class="description">' . esc_html__( 'The password for the eval terminal. If empty, the plugin will not work.', 'wp-php-console' ) . '</small>'; |
|
286 | + echo '<small class="description">'.esc_html__('The password for the eval terminal. If empty, the plugin will not work.', 'wp-php-console').'</small>'; |
|
287 | 287 | |
288 | 288 | } |
289 | 289 | |
@@ -295,15 +295,15 @@ discard block |
||
295 | 295 | */ |
296 | 296 | public function ssl_field() { |
297 | 297 | |
298 | - $ssl = isset( $this->options['ssl'] ) ? esc_attr( $this->options['ssl']) : ''; |
|
298 | + $ssl = isset($this->options['ssl']) ? esc_attr($this->options['ssl']) : ''; |
|
299 | 299 | |
300 | - printf ( |
|
300 | + printf( |
|
301 | 301 | '<input type="checkbox" id="wp-php-console-ssl" name="wp_php_console[ssl]" value="1" %s /> ', |
302 | 302 | $ssl ? 'checked="checked"' : '' |
303 | 303 | ); |
304 | - echo '<label for="wp-php-console-ssl">' . esc_html__( 'Yes', 'wp-php-console' ) . '</label>'; |
|
304 | + echo '<label for="wp-php-console-ssl">'.esc_html__('Yes', 'wp-php-console').'</label>'; |
|
305 | 305 | echo '<br />'; |
306 | - echo '<small class="description">' . esc_html__( 'Tick this option if you want the eval terminal to work only on a SSL connection.', 'wp-php-console' ) . '</small>'; |
|
306 | + echo '<small class="description">'.esc_html__('Tick this option if you want the eval terminal to work only on a SSL connection.', 'wp-php-console').'</small>'; |
|
307 | 307 | |
308 | 308 | } |
309 | 309 | |
@@ -315,14 +315,14 @@ discard block |
||
315 | 315 | */ |
316 | 316 | public function ip_field() { |
317 | 317 | |
318 | - printf ( |
|
318 | + printf( |
|
319 | 319 | '<input type="text" class="regular-text" id="wp-php-console-ip" name="wp_php_console[ip]" value="%s" /> ', |
320 | - isset( $this->options['ip'] ) ? esc_attr( $this->options['ip']) : '' |
|
320 | + isset($this->options['ip']) ? esc_attr($this->options['ip']) : '' |
|
321 | 321 | ); |
322 | - echo '<label for="wp-php-console-ip">' . esc_html__( 'IP addresses (optional)', 'wp-php-console' ) . '</label>'; |
|
322 | + echo '<label for="wp-php-console-ip">'.esc_html__('IP addresses (optional)', 'wp-php-console').'</label>'; |
|
323 | 323 | echo '<br />'; |
324 | 324 | /* translators: VVV Varying Vagrant Vagrants default IP address */ |
325 | - 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>' ); |
|
325 | + 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>'); |
|
326 | 326 | |
327 | 327 | } |
328 | 328 | |
@@ -334,15 +334,15 @@ discard block |
||
334 | 334 | */ |
335 | 335 | public function register_field() { |
336 | 336 | |
337 | - $register = ! empty( $this->options['register'] ); |
|
337 | + $register = ! empty($this->options['register']); |
|
338 | 338 | |
339 | - printf ( |
|
339 | + printf( |
|
340 | 340 | '<input type="checkbox" id="wp-php-console-register" name="wp_php_console[register]" value="1" %s /> ', |
341 | 341 | $register ? 'checked="checked"' : '' |
342 | 342 | ); |
343 | - echo '<label for="wp-php-console-register">' . esc_html__( 'Yes', 'wp-php-console' ) . '</label>'; |
|
343 | + echo '<label for="wp-php-console-register">'.esc_html__('Yes', 'wp-php-console').'</label>'; |
|
344 | 344 | echo '<br />'; |
345 | - 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>'; |
|
345 | + 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>'; |
|
346 | 346 | |
347 | 347 | } |
348 | 348 | |
@@ -354,15 +354,15 @@ discard block |
||
354 | 354 | */ |
355 | 355 | public function stack_field() { |
356 | 356 | |
357 | - $stack = ! empty( $this->options['stack'] ); |
|
357 | + $stack = ! empty($this->options['stack']); |
|
358 | 358 | |
359 | - printf ( |
|
359 | + printf( |
|
360 | 360 | '<input type="checkbox" id="wp-php-console-stack" name="wp_php_console[stack]" value="1" %s /> ', |
361 | 361 | $stack ? 'checked="checked"' : '' |
362 | 362 | ); |
363 | - echo '<label for="wp-php-console-stack">' . esc_html__( 'Yes', 'wp-php-console' ) . '</label>'; |
|
363 | + echo '<label for="wp-php-console-stack">'.esc_html__('Yes', 'wp-php-console').'</label>'; |
|
364 | 364 | echo '<br />'; |
365 | - 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>'; |
|
365 | + 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>'; |
|
366 | 366 | |
367 | 367 | } |
368 | 368 | |
@@ -374,15 +374,15 @@ discard block |
||
374 | 374 | */ |
375 | 375 | public function short_field() { |
376 | 376 | |
377 | - $short = ! empty( $this->options['short'] ); |
|
377 | + $short = ! empty($this->options['short']); |
|
378 | 378 | |
379 | - printf ( |
|
379 | + printf( |
|
380 | 380 | '<input type="checkbox" id="wp-php-console-short" name="wp_php_console[short]" value="1" %s /> ', |
381 | 381 | $short ? 'checked="checked"' : '' |
382 | 382 | ); |
383 | - echo '<label for="wp-php-console-short">' . esc_html__( 'Yes', 'wp-php-console' ) . '</label>'; |
|
383 | + echo '<label for="wp-php-console-short">'.esc_html__('Yes', 'wp-php-console').'</label>'; |
|
384 | 384 | echo '<br />'; |
385 | - 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>'; |
|
385 | + 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>'; |
|
386 | 386 | |
387 | 387 | } |
388 | 388 | |
@@ -394,25 +394,25 @@ discard block |
||
394 | 394 | * @param string $input user input |
395 | 395 | * @return array sanitized inputs |
396 | 396 | */ |
397 | - public function sanitize_field( $input ) { |
|
397 | + public function sanitize_field($input) { |
|
398 | 398 | |
399 | 399 | $sanitized_input = array(); |
400 | 400 | |
401 | - if ( isset( $input['password'] ) ) { |
|
402 | - $sanitized_input['password'] = sanitize_text_field( $input['password'] ); |
|
401 | + if (isset($input['password'])) { |
|
402 | + $sanitized_input['password'] = sanitize_text_field($input['password']); |
|
403 | 403 | } |
404 | 404 | |
405 | - if ( isset( $input['ssl'] ) ) { |
|
406 | - $sanitized_input['ssl'] = ! empty( $input['ssl'] ) ? 1 : ''; |
|
405 | + if (isset($input['ssl'])) { |
|
406 | + $sanitized_input['ssl'] = ! empty($input['ssl']) ? 1 : ''; |
|
407 | 407 | } |
408 | 408 | |
409 | - if ( isset( $input['ip'] ) ) { |
|
410 | - $sanitized_input['ip'] = sanitize_text_field( $input['ip'] ); |
|
409 | + if (isset($input['ip'])) { |
|
410 | + $sanitized_input['ip'] = sanitize_text_field($input['ip']); |
|
411 | 411 | } |
412 | 412 | |
413 | - $sanitized_input['register'] = empty( $input['register'] ) ? '' : 1; |
|
414 | - $sanitized_input['stack'] = empty( $input['stack'] ) ? '' : 1; |
|
415 | - $sanitized_input['short'] = empty( $input['short'] ) ? '' : 1; |
|
413 | + $sanitized_input['register'] = empty($input['register']) ? '' : 1; |
|
414 | + $sanitized_input['stack'] = empty($input['stack']) ? '' : 1; |
|
415 | + $sanitized_input['short'] = empty($input['short']) ? '' : 1; |
|
416 | 416 | |
417 | 417 | return $sanitized_input; |
418 | 418 | } |
@@ -427,12 +427,12 @@ discard block |
||
427 | 427 | |
428 | 428 | ?> |
429 | 429 | <div class="wrap"> |
430 | - <h2><?php esc_html_e( 'WP PHP Console', 'wp-php-console' ); ?></h2> |
|
430 | + <h2><?php esc_html_e('WP PHP Console', 'wp-php-console'); ?></h2> |
|
431 | 431 | <hr /> |
432 | 432 | <form method="post" action="options.php"> |
433 | 433 | <?php |
434 | - settings_fields( 'wp_php_console' ); |
|
435 | - do_settings_sections( $this->plugin_slug ); |
|
434 | + settings_fields('wp_php_console'); |
|
435 | + do_settings_sections($this->plugin_slug); |
|
436 | 436 | submit_button(); |
437 | 437 | ?> |
438 | 438 | </form> |
@@ -452,14 +452,14 @@ discard block |
||
452 | 452 | |
453 | 453 | ?> |
454 | 454 | <p><?php /* translators: %s refers to 'PHP Console' Chrome extension, will print download link for the Chrome extension */ |
455 | - 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> |
|
455 | + 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> |
|
456 | 456 | <ol> |
457 | 457 | <li><?php /* translators: Install PHP Console extension for Google Chrome download link */ |
458 | - 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> |
|
459 | - <li><?php _e( 'Set a password for the eval terminal in the options below and hit <code>save changes</code>.', 'wp-php-console' ); ?></li> |
|
460 | - <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> |
|
461 | - <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> |
|
462 | - <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> |
|
458 | + 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> |
|
459 | + <li><?php _e('Set a password for the eval terminal in the options below and hit <code>save changes</code>.', 'wp-php-console'); ?></li> |
|
460 | + <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> |
|
461 | + <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> |
|
462 | + <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> |
|
463 | 463 | </ol> |
464 | 464 | <?php |
465 | 465 | |
@@ -474,73 +474,73 @@ discard block |
||
474 | 474 | public function init() { |
475 | 475 | |
476 | 476 | // Display admin notice and abort if no password has been set |
477 | - $password = isset( $this->options['password'] ) ? $this->options['password'] : ''; |
|
478 | - if ( ! $password ) { |
|
479 | - add_action( 'admin_notices', array( $this, 'password_notice' ) ); |
|
477 | + $password = isset($this->options['password']) ? $this->options['password'] : ''; |
|
478 | + if ( ! $password) { |
|
479 | + add_action('admin_notices', array($this, 'password_notice')); |
|
480 | 480 | return; // abort |
481 | 481 | } |
482 | 482 | |
483 | 483 | // Selectively remove slashes added by WordPress as expected by PhpConsole |
484 | - if ( isset( $_POST[PhpConsole\Connector::POST_VAR_NAME] ) ) { |
|
485 | - $_POST[ PhpConsole\Connector::POST_VAR_NAME ] = stripslashes_deep( $_POST[ PhpConsole\Connector::POST_VAR_NAME ] ); |
|
484 | + if (isset($_POST[PhpConsole\Connector::POST_VAR_NAME])) { |
|
485 | + $_POST[PhpConsole\Connector::POST_VAR_NAME] = stripslashes_deep($_POST[PhpConsole\Connector::POST_VAR_NAME]); |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | $connector = PhpConsole\Connector::getInstance(); |
489 | 489 | |
490 | 490 | try { |
491 | - $connector->setPassword( $password ); |
|
492 | - } catch ( \Exception $e ) { |
|
493 | - $this->print_notice_exception( $e ); |
|
491 | + $connector->setPassword($password); |
|
492 | + } catch (\Exception $e) { |
|
493 | + $this->print_notice_exception($e); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | // PhpConsole instance |
497 | 497 | $handler = PhpConsole\Handler::getInstance(); |
498 | - if ( PhpConsole\Handler::getInstance()->isStarted() !== true ) { |
|
498 | + if (PhpConsole\Handler::getInstance()->isStarted() !== true) { |
|
499 | 499 | try { |
500 | 500 | $handler->start(); |
501 | - } catch( \Exception $e ) { |
|
502 | - $this->print_notice_exception( $e ); |
|
501 | + } catch (\Exception $e) { |
|
502 | + $this->print_notice_exception($e); |
|
503 | 503 | } |
504 | 504 | } |
505 | 505 | |
506 | 506 | // Enable SSL-only mode |
507 | - $enableSslOnlyMode = isset( $this->options['ssl'] ) ? ( ! empty( $this->options['ssl'] ) ? $this->options['ssl'] : '' ) : ''; |
|
508 | - if ( $enableSslOnlyMode ) { |
|
507 | + $enableSslOnlyMode = isset($this->options['ssl']) ? ( ! empty($this->options['ssl']) ? $this->options['ssl'] : '') : ''; |
|
508 | + if ($enableSslOnlyMode) { |
|
509 | 509 | $connector->enableSslOnlyMode(); |
510 | 510 | } |
511 | 511 | |
512 | 512 | // Restrict IP addresses |
513 | - $allowedIpMasks = isset( $this->options['ip'] ) ? ( ! empty( $this->options['ip'] ) ? explode( ',', $this->options['ip'] ) : '' ) : ''; |
|
514 | - if ( is_array( $allowedIpMasks ) && ! empty( $allowedIpMasks ) ) { |
|
515 | - $connector->setAllowedIpMasks( (array) $allowedIpMasks ); |
|
513 | + $allowedIpMasks = isset($this->options['ip']) ? ( ! empty($this->options['ip']) ? explode(',', $this->options['ip']) : '') : ''; |
|
514 | + if (is_array($allowedIpMasks) && ! empty($allowedIpMasks)) { |
|
515 | + $connector->setAllowedIpMasks((array) $allowedIpMasks); |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | $evalProvider = $connector->getEvalDispatcher()->getEvalProvider(); |
519 | 519 | |
520 | 520 | try { |
521 | - $evalProvider->addSharedVar( 'uri', $_SERVER['REQUEST_URI'] ); |
|
522 | - } catch ( \Exception $e ) { |
|
523 | - $this->print_notice_exception( $e ); |
|
521 | + $evalProvider->addSharedVar('uri', $_SERVER['REQUEST_URI']); |
|
522 | + } catch (\Exception $e) { |
|
523 | + $this->print_notice_exception($e); |
|
524 | 524 | } |
525 | 525 | try { |
526 | - $evalProvider->addSharedVarReference( 'post', $_POST ); |
|
527 | - } catch ( \Exception $e ) { |
|
528 | - $this->print_notice_exception( $e ); |
|
526 | + $evalProvider->addSharedVarReference('post', $_POST); |
|
527 | + } catch (\Exception $e) { |
|
528 | + $this->print_notice_exception($e); |
|
529 | 529 | } |
530 | 530 | |
531 | - $openBaseDirs = array( ABSPATH, get_template_directory() ); |
|
531 | + $openBaseDirs = array(ABSPATH, get_template_directory()); |
|
532 | 532 | try { |
533 | - $evalProvider->addSharedVarReference( 'dirs', $openBaseDirs ); |
|
534 | - } catch ( \Exception $e ) { |
|
535 | - $this->print_notice_exception( $e ); |
|
533 | + $evalProvider->addSharedVarReference('dirs', $openBaseDirs); |
|
534 | + } catch (\Exception $e) { |
|
535 | + $this->print_notice_exception($e); |
|
536 | 536 | } |
537 | 537 | |
538 | - $evalProvider->setOpenBaseDirs( $openBaseDirs ); |
|
538 | + $evalProvider->setOpenBaseDirs($openBaseDirs); |
|
539 | 539 | |
540 | 540 | try { |
541 | 541 | $connector->startEvalRequestsListener(); |
542 | - } catch ( \Exception $e ) { |
|
543 | - $this->print_notice_exception( $e ); |
|
542 | + } catch (\Exception $e) { |
|
543 | + $this->print_notice_exception($e); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | } |
@@ -558,10 +558,10 @@ discard block |
||
558 | 558 | <div class="update-nag"> |
559 | 559 | <?php |
560 | 560 | |
561 | - $settings_page = esc_url( admin_url( 'options-general.php?page=wp-php-console' ) ); |
|
561 | + $settings_page = esc_url(admin_url('options-general.php?page=wp-php-console')); |
|
562 | 562 | |
563 | 563 | /* translators: Placeholders: %1$s - opening HTML <a> link tag; %2$s closing HTML </a> link tag */ |
564 | - 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>' ); |
|
564 | + 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>'); |
|
565 | 565 | |
566 | 566 | ?> |
567 | 567 | </div> |