@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | namespace WP_PHP_Console; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) or exit; |
|
17 | +defined('ABSPATH') or exit; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * WP PHP Console admin handler. |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | public function __construct() { |
33 | 33 | |
34 | 34 | // add plugin page row action links |
35 | - add_filter( 'plugin_action_links_wp-php-console/wp-php-console.php', static function( $actions ) { |
|
36 | - return array_merge( [ |
|
37 | - '<a href="' . esc_url( admin_url() ) . '">' . esc_html__( 'Settings', 'wp-php-console' ) . '</a>', |
|
38 | - '<a href="' . esc_url( Plugin::get_project_page_url() ) . '">' . esc_html__( 'GitHub', 'wp-php-console' ) . '</a>', |
|
39 | - '<a href="' . esc_url( Plugin::get_support_page_url() ) . '">' . esc_html__( 'Support', 'wp-php-console' ) . '</a>', |
|
40 | - '<a href="' . esc_url( Plugin::get_reviews_page_url() ) . '">' . esc_html__( 'Review', 'wp-php-console' ) . '</a>', |
|
41 | - ], $actions ); |
|
35 | + add_filter('plugin_action_links_wp-php-console/wp-php-console.php', static function($actions) { |
|
36 | + return array_merge([ |
|
37 | + '<a href="'.esc_url(admin_url()).'">'.esc_html__('Settings', 'wp-php-console').'</a>', |
|
38 | + '<a href="'.esc_url(Plugin::get_project_page_url()).'">'.esc_html__('GitHub', 'wp-php-console').'</a>', |
|
39 | + '<a href="'.esc_url(Plugin::get_support_page_url()).'">'.esc_html__('Support', 'wp-php-console').'</a>', |
|
40 | + '<a href="'.esc_url(Plugin::get_reviews_page_url()).'">'.esc_html__('Review', 'wp-php-console').'</a>', |
|
41 | + ], $actions); |
|
42 | 42 | } ); |
43 | 43 | |
44 | 44 | // init settings page |
45 | - if ( ! defined( 'DOING_AJAX' ) ) { |
|
45 | + if ( ! defined('DOING_AJAX')) { |
|
46 | 46 | new Admin\SettingsPage(); |
47 | 47 | } |
48 | 48 | } |
@@ -56,21 +56,21 @@ discard block |
||
56 | 56 | private static function output_admin_notices() { |
57 | 57 | |
58 | 58 | // display admin notice and abort if no password has been set |
59 | - add_action( 'admin_notices', static function() { |
|
60 | - if ( ! Settings::has_eval_terminal_password() ) : |
|
59 | + add_action('admin_notices', static function() { |
|
60 | + if ( ! Settings::has_eval_terminal_password()) : |
|
61 | 61 | ?> |
62 | 62 | <div class="update-nag"> |
63 | 63 | <p><?php printf( |
64 | 64 | /* translators: Placeholders: %1$s - WP PHP Console name, %2$s - opening HTML <a> link tag; %3$s closing HTML </a> link tag */ |
65 | - __( '%1$s: Please remember to %2$sset a password%3$s if you want to enable the terminal.', 'wp-php-console' ), |
|
66 | - '<strong>' . Plugin::NAME . '</strong>', |
|
67 | - '<a href="' . esc_url( admin_url( 'options-general.php?page=wp-php-console' ) ) .'">', |
|
65 | + __('%1$s: Please remember to %2$sset a password%3$s if you want to enable the terminal.', 'wp-php-console'), |
|
66 | + '<strong>'.Plugin::NAME.'</strong>', |
|
67 | + '<a href="'.esc_url(admin_url('options-general.php?page=wp-php-console')).'">', |
|
68 | 68 | '</a>' |
69 | 69 | ); ?></p> |
70 | 70 | </div> |
71 | 71 | <?php |
72 | 72 | endif; |
73 | - }, -1000 ); |
|
73 | + }, -1000); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | namespace WP_PHP_Console; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) or exit; |
|
17 | +defined('ABSPATH') or exit; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * WP PHP Console settings handler. |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public static function get_settings_key() { |
39 | 39 | |
40 | - return str_replace( '-', '_', Plugin::ID ); |
|
40 | + return str_replace('-', '_', Plugin::ID); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public static function get_settings() { |
52 | 52 | |
53 | - if ( empty( self::$options ) ) { |
|
53 | + if (empty(self::$options)) { |
|
54 | 54 | |
55 | 55 | self::$options = wp_parse_args( |
56 | - (array) get_option( self::get_settings_key(), [] ), |
|
56 | + (array) get_option(self::get_settings_key(), []), |
|
57 | 57 | [ |
58 | 58 | 'ip' => '', |
59 | 59 | 'password' => '', |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | $allowed_ips = self::get_settings()['ip']; |
82 | 82 | |
83 | - return ! empty( $allowed_ips['ip'] ) ? explode( ',', $allowed_ips['ip'] ) : []; |
|
83 | + return ! empty($allowed_ips['ip']) ? explode(',', $allowed_ips['ip']) : []; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | $password = self::get_eval_terminal_password(); |
110 | 110 | |
111 | - return is_string( $password ) && '' !== trim( $password ); |
|
111 | + return is_string($password) && '' !== trim($password); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public static function should_register_pc_class() { |
123 | 123 | |
124 | - return ! empty( self::get_settings()['register'] ); |
|
124 | + return ! empty(self::get_settings()['register']); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public static function should_use_ssl_only() { |
136 | 136 | |
137 | - return ! empty( self::get_settings()['ssl'] ); |
|
137 | + return ! empty(self::get_settings()['ssl']); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public static function should_show_call_stack() { |
149 | 149 | |
150 | - return ! empty( self::get_settings()['stack'] ); |
|
150 | + return ! empty(self::get_settings()['stack']); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public static function should_use_short_path_names() { |
162 | 162 | |
163 | - return ! empty( self::get_settings()['short'] ); |
|
163 | + return ! empty(self::get_settings()['short']); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | use WP_PHP_Console\Plugin; |
18 | 18 | use WP_PHP_Console\Settings; |
19 | 19 | |
20 | -defined( 'ABSPATH' ) or exit; |
|
20 | +defined('ABSPATH') or exit; |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * WP PHP Console settings page. |
@@ -44,12 +44,12 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function __construct() { |
46 | 46 | |
47 | - $this->page_id = str_replace( '-', '_', Plugin::ID ); |
|
47 | + $this->page_id = str_replace('-', '_', Plugin::ID); |
|
48 | 48 | $this->option_key = Settings::get_settings_key(); |
49 | 49 | $this->options = Settings::get_settings(); |
50 | 50 | |
51 | - add_action( 'admin_menu', function() { $this->register_settings_page(); } ); |
|
52 | - add_action( 'admin_init', function() { $this->register_settings(); } ); |
|
51 | + add_action('admin_menu', function() { $this->register_settings_page(); } ); |
|
52 | + add_action('admin_init', function() { $this->register_settings(); } ); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | Plugin::NAME, |
66 | 66 | 'manage_options', |
67 | 67 | $this->page_id, |
68 | - [ $this, 'output_settings_page' ] |
|
68 | + [$this, 'output_settings_page'] |
|
69 | 69 | ); |
70 | 70 | } |
71 | 71 | |
@@ -80,19 +80,19 @@ discard block |
||
80 | 80 | register_setting( |
81 | 81 | $this->option_key, |
82 | 82 | $this->option_key, |
83 | - [ $this, 'sanitize_field' ] |
|
83 | + [$this, 'sanitize_field'] |
|
84 | 84 | ); |
85 | 85 | |
86 | 86 | add_settings_section( |
87 | 87 | $this->option_key, |
88 | - __( 'Settings', 'wp-php-console' ), |
|
89 | - [ $this, 'output_settings_instructions' ], |
|
88 | + __('Settings', 'wp-php-console'), |
|
89 | + [$this, 'output_settings_instructions'], |
|
90 | 90 | $this->page_id |
91 | 91 | ); |
92 | 92 | |
93 | 93 | $settings_fields = [ |
94 | 94 | 'password' => [ |
95 | - 'label' => esc_html__( 'Password', 'wp-php-console' ), |
|
95 | + 'label' => esc_html__('Password', 'wp-php-console'), |
|
96 | 96 | 'args' => [ |
97 | 97 | 'id' => 'password', |
98 | 98 | 'type' => 'password', |
@@ -100,35 +100,35 @@ discard block |
||
100 | 100 | ] |
101 | 101 | ], |
102 | 102 | 'ssl' => [ |
103 | - 'label' => esc_html__( 'Allow only on SSL', 'wp-php-console' ), |
|
103 | + 'label' => esc_html__('Allow only on SSL', 'wp-php-console'), |
|
104 | 104 | 'args' => [ |
105 | 105 | 'id' => 'ssl', |
106 | 106 | 'type' => 'checkbox', |
107 | 107 | ] |
108 | 108 | ], |
109 | 109 | 'ip' => [ |
110 | - 'label' => esc_html__( 'Allowed IP Masks', 'wp-php-console' ), |
|
110 | + 'label' => esc_html__('Allowed IP Masks', 'wp-php-console'), |
|
111 | 111 | 'args' => [ |
112 | 112 | 'id' => 'ip', |
113 | 113 | 'type' => 'text', |
114 | 114 | ] |
115 | 115 | ], |
116 | 116 | 'register' => [ |
117 | - 'label' => esc_html__( 'Register PC Class', 'wp-php-console' ), |
|
117 | + 'label' => esc_html__('Register PC Class', 'wp-php-console'), |
|
118 | 118 | 'args' => [ |
119 | 119 | 'id' => 'register', |
120 | 120 | 'type' => 'checkbox', |
121 | 121 | ] |
122 | 122 | ], |
123 | 123 | 'stack' => [ |
124 | - 'label' => esc_html__( 'Show Call Stack', 'wp-php-console' ), |
|
124 | + 'label' => esc_html__('Show Call Stack', 'wp-php-console'), |
|
125 | 125 | 'args' => [ |
126 | 126 | 'id' => 'stack', |
127 | 127 | 'type' => 'checkbox', |
128 | 128 | ] |
129 | 129 | ], |
130 | 130 | 'short' => [ |
131 | - 'label' => esc_html__( 'Short Path Names', 'wp-php-console' ), |
|
131 | + 'label' => esc_html__('Short Path Names', 'wp-php-console'), |
|
132 | 132 | 'args' => [ |
133 | 133 | 'id' => 'short', |
134 | 134 | 'type' => 'checkbox', |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | ], |
137 | 137 | ]; |
138 | 138 | |
139 | - foreach ( $settings_fields as $key => $field ) { |
|
139 | + foreach ($settings_fields as $key => $field) { |
|
140 | 140 | add_settings_field( |
141 | - $this->page_id . '['. $key . ']', |
|
141 | + $this->page_id.'['.$key.']', |
|
142 | 142 | $field['label'], |
143 | - [ $this, 'output_input_field' ], |
|
143 | + [$this, 'output_input_field'], |
|
144 | 144 | $this->page_id, |
145 | 145 | $this->option_key, |
146 | 146 | $field['args'] |
@@ -163,32 +163,32 @@ discard block |
||
163 | 163 | ?> |
164 | 164 | <p><?php printf( |
165 | 165 | /* translators: Placeholder: %s refers to the PHP Console library, pointing to its GitHub repository */ |
166 | - _x( 'This plugin allows you to use %s within your WordPress installation for testing, debugging and development purposes.', 'PHP Console, the PHP Library', 'wp-php-console' ), |
|
167 | - '<a href="' . esc_url( Plugin::get_php_console_project_page_url() ) . '" target="_blank">PHP Console</a>' |
|
166 | + _x('This plugin allows you to use %s within your WordPress installation for testing, debugging and development purposes.', 'PHP Console, the PHP Library', 'wp-php-console'), |
|
167 | + '<a href="'.esc_url(Plugin::get_php_console_project_page_url()).'" target="_blank">PHP Console</a>' |
|
168 | 168 | ); |
169 | 169 | ?></p> |
170 | - <h4><?php esc_html_e( 'Usage instructions:', 'wp-php-console' ); ?></h4> |
|
170 | + <h4><?php esc_html_e('Usage instructions:', 'wp-php-console'); ?></h4> |
|
171 | 171 | <ol> |
172 | 172 | <?php |
173 | 173 | |
174 | 174 | $instructions = [ |
175 | 175 | sprintf( |
176 | 176 | /* translators: Placeholder: %s represents the Google Chrome PHP Console extension download link */ |
177 | - _x( 'Make sure you have downloaded and installed %s.', 'PHP Console, the Chrome Extension', 'wp-php-console' ), |
|
178 | - '<a target="_blank" href="' . esc_url( Plugin::get_php_console_chrome_extension_url() ) .'">PHP Console extension for Google Chrome</a>' |
|
177 | + _x('Make sure you have downloaded and installed %s.', 'PHP Console, the Chrome Extension', 'wp-php-console'), |
|
178 | + '<a target="_blank" href="'.esc_url(Plugin::get_php_console_chrome_extension_url()).'">PHP Console extension for Google Chrome</a>' |
|
179 | 179 | ), |
180 | - esc_html__( 'Set a password for the eval terminal in the options below and hit "Save Changes".', 'wp-php-console' ), |
|
181 | - esc_html__( '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' ), |
|
182 | - esc_html__( 'From the eval terminal you can execute any PHP or WordPress specific function, including functions from your plugins and active theme.', 'wp-php-console' ), |
|
180 | + esc_html__('Set a password for the eval terminal in the options below and hit "Save Changes".', 'wp-php-console'), |
|
181 | + esc_html__('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'), |
|
182 | + esc_html__('From the eval terminal you can execute any PHP or WordPress specific function, including functions from your plugins and active theme.', 'wp-php-console'), |
|
183 | 183 | sprintf( |
184 | 184 | /* translators: Placeholders: %1$s - PHP code snippet example, %2$s - Chrome javascript console shortcut */ |
185 | - __( 'In your PHP code, you can call PHP Console debug statements like %1$s to display PHP variables in the browser\'s JavaScript-console (e.g. %2$s) and optionally filter selected tags through the browser\'s Remote PHP Eval Terminal screen\'s "Ignore Debug options".', 'wp-php-console' ), |
|
185 | + __('In your PHP code, you can call PHP Console debug statements like %1$s to display PHP variables in the browser\'s JavaScript-console (e.g. %2$s) and optionally filter selected tags through the browser\'s Remote PHP Eval Terminal screen\'s "Ignore Debug options".', 'wp-php-console'), |
|
186 | 186 | '<code>debug($var, $tag)</code>', |
187 | 187 | '<code>CTRL+SHIFT+J</code>' |
188 | 188 | ), |
189 | 189 | ]; |
190 | 190 | |
191 | - foreach ( $instructions as $list_item ) : |
|
191 | + foreach ($instructions as $list_item) : |
|
192 | 192 | ?><li><?php echo $list_item; ?></li><?php |
193 | 193 | endforeach; |
194 | 194 | |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | * @param array $field field arguments |
208 | 208 | * @return string |
209 | 209 | */ |
210 | - private function get_field_id( array $field ) { |
|
210 | + private function get_field_id(array $field) { |
|
211 | 211 | |
212 | - return $this->page_id . '-' . $field['id']; |
|
212 | + return $this->page_id.'-'.$field['id']; |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
@@ -221,9 +221,9 @@ discard block |
||
221 | 221 | * @param array $field field arguments |
222 | 222 | * @return string |
223 | 223 | */ |
224 | - private function get_field_name( array $field ) { |
|
224 | + private function get_field_name(array $field) { |
|
225 | 225 | |
226 | - return str_replace( '-', '_', $this->page_id . '[' . $field['id'] . ']' ); |
|
226 | + return str_replace('-', '_', $this->page_id.'['.$field['id'].']'); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | |
@@ -235,9 +235,9 @@ discard block |
||
235 | 235 | * @param array $field field arguments |
236 | 236 | * @return int|string|bool |
237 | 237 | */ |
238 | - private function get_field_value( array $field ) { |
|
238 | + private function get_field_value(array $field) { |
|
239 | 239 | |
240 | - return $this->options[ $field['id'] ]; |
|
240 | + return $this->options[$field['id']]; |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
@@ -250,19 +250,19 @@ discard block |
||
250 | 250 | * |
251 | 251 | * @param array $args |
252 | 252 | */ |
253 | - public function output_input_field( array $args = [] ) { |
|
253 | + public function output_input_field(array $args = []) { |
|
254 | 254 | |
255 | - if ( empty( $args ) ) { |
|
255 | + if (empty($args)) { |
|
256 | 256 | return; |
257 | 257 | } |
258 | 258 | |
259 | - switch ( $args['type'] ) { |
|
259 | + switch ($args['type']) { |
|
260 | 260 | case 'password' : |
261 | 261 | case 'text' : |
262 | - $this->output_input_text_field( $args ); |
|
262 | + $this->output_input_text_field($args); |
|
263 | 263 | break; |
264 | 264 | case 'checkbox' : |
265 | - $this->output_checkbox_field( $args ); |
|
265 | + $this->output_checkbox_field($args); |
|
266 | 266 | break; |
267 | 267 | } |
268 | 268 | } |
@@ -275,23 +275,23 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @param array $args |
277 | 277 | */ |
278 | - private function output_input_text_field( $args = [] ) { |
|
278 | + private function output_input_text_field($args = []) { |
|
279 | 279 | |
280 | 280 | ?> |
281 | 281 | <label> |
282 | 282 | <input |
283 | - type="<?php echo isset( $args['type'] ) ? esc_attr( $args['type'] ) : 'text'; ?>" |
|
284 | - id="<?php echo esc_attr( $this->get_field_id( $args ) ); ?>" |
|
285 | - name="<?php echo esc_attr( $this->get_field_name( $args ) ); ?>" |
|
286 | - value="<?php echo esc_attr( $this->get_field_value( $args ) ); ?>" |
|
283 | + type="<?php echo isset($args['type']) ? esc_attr($args['type']) : 'text'; ?>" |
|
284 | + id="<?php echo esc_attr($this->get_field_id($args)); ?>" |
|
285 | + name="<?php echo esc_attr($this->get_field_name($args)); ?>" |
|
286 | + value="<?php echo esc_attr($this->get_field_value($args)); ?>" |
|
287 | 287 | > |
288 | - <?php if ( ! empty( $args['required'] ) ) : ?> |
|
289 | - <span style="color:red;" title="<?php esc_attr_e( 'Required', 'wp-php-console' ); ?>">*</span> |
|
288 | + <?php if ( ! empty($args['required'])) : ?> |
|
289 | + <span style="color:red;" title="<?php esc_attr_e('Required', 'wp-php-console'); ?>">*</span> |
|
290 | 290 | <?php endif; ?> |
291 | 291 | </label> |
292 | 292 | <?php |
293 | 293 | |
294 | - switch ( $args['id'] ) : |
|
294 | + switch ($args['id']) : |
|
295 | 295 | |
296 | 296 | case 'ip' : |
297 | 297 | $this->output_ip_field_instructions(); |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | private function output_password_field_instructions() { |
314 | 314 | |
315 | 315 | ?> |
316 | - <p class="description"><?php esc_html_e( 'The password for the eval terminal. If empty, the connector will not work.', 'wp-php-console' ); ?></p> |
|
316 | + <p class="description"><?php esc_html_e('The password for the eval terminal. If empty, the connector will not work.', 'wp-php-console'); ?></p> |
|
317 | 317 | <?php |
318 | 318 | } |
319 | 319 | |
@@ -326,17 +326,17 @@ discard block |
||
326 | 326 | private function output_ip_field_instructions() { |
327 | 327 | |
328 | 328 | ?> |
329 | - <p class="description"><?php esc_html_e( 'You may specify any of the following, to give access to specific IPs to the eval terminal:', 'wp-php-console' ); ?></p> |
|
329 | + <p class="description"><?php esc_html_e('You may specify any of the following, to give access to specific IPs to the eval terminal:', 'wp-php-console'); ?></p> |
|
330 | 330 | <ol> |
331 | 331 | <li><span class="description"><?php printf( |
332 | 332 | /* translators: Placeholders: %1$s - a single IP address, %2$s link to Varying Vagrant Vagrants project repository */ |
333 | - __( 'An IP address (for example %1$s, %2$s default IP address).', 'wp-php-console' ), |
|
333 | + __('An IP address (for example %1$s, %2$s default IP address).', 'wp-php-console'), |
|
334 | 334 | '<code>192.168.50.4</code>', |
335 | 335 | '<a href="https://github.com/Varying-Vagrant-Vagrants/VVV">Varying Vagrant Vagrants</a>' |
336 | 336 | ); ?></span></li> |
337 | 337 | <li><span class="description"><?php printf( |
338 | 338 | /* translators: Placeholders: %1$s a range of IP addresses, %2$s - comma separated IP addresses */ |
339 | - __( 'A range of addresses (%1$s) or multiple addresses, comma separated (%2$s).', 'wp-php-console' ), |
|
339 | + __('A range of addresses (%1$s) or multiple addresses, comma separated (%2$s).', 'wp-php-console'), |
|
340 | 340 | '<code>192.168.*.*</code>', |
341 | 341 | '<code>192.168.10.25,192.168.10.28</code>' |
342 | 342 | ); ?></span></li> |
@@ -352,23 +352,23 @@ discard block |
||
352 | 352 | * |
353 | 353 | * @param array $args |
354 | 354 | */ |
355 | - public function output_checkbox_field( array $args = [] ) { |
|
355 | + public function output_checkbox_field(array $args = []) { |
|
356 | 356 | |
357 | - $field_id = esc_attr( $this->get_field_id( $args ) ); |
|
357 | + $field_id = esc_attr($this->get_field_id($args)); |
|
358 | 358 | |
359 | 359 | ?> |
360 | 360 | <label> |
361 | 361 | <input |
362 | 362 | type="checkbox" |
363 | 363 | id="<?php echo $field_id; ?>" |
364 | - name="<?php echo esc_attr( $this->get_field_name( $args ) ); ?>" |
|
364 | + name="<?php echo esc_attr($this->get_field_name($args)); ?>" |
|
365 | 365 | value="1" |
366 | - <?php checked( (bool) $this->get_field_value( $args ) ); ?> |
|
367 | - ><?php esc_html_e( 'Yes', 'wp-php-console' ); ?> |
|
366 | + <?php checked((bool) $this->get_field_value($args)); ?> |
|
367 | + ><?php esc_html_e('Yes', 'wp-php-console'); ?> |
|
368 | 368 | </label> |
369 | 369 | <?php |
370 | 370 | |
371 | - switch ( $args['id'] ) : |
|
371 | + switch ($args['id']) : |
|
372 | 372 | |
373 | 373 | case 'register' : |
374 | 374 | $this->output_register_pc_class_field_instructions(); |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | private function output_ssl_field_instructions() { |
399 | 399 | |
400 | 400 | ?> |
401 | - <p class="description"><?php esc_html_e( 'Enable this option if you want the eval terminal to work only on a SSL connection.', 'wp-php-console' ); ?></p> |
|
401 | + <p class="description"><?php esc_html_e('Enable this option if you want the eval terminal to work only on a SSL connection.', 'wp-php-console'); ?></p> |
|
402 | 402 | <?php |
403 | 403 | } |
404 | 404 | |
@@ -412,11 +412,11 @@ discard block |
||
412 | 412 | |
413 | 413 | ?> |
414 | 414 | <p class="description"><?php |
415 | - esc_html_e( 'Enable to register PC class in the global namespace.', 'wp-php-console' ); |
|
415 | + esc_html_e('Enable to register PC class in the global namespace.', 'wp-php-console'); |
|
416 | 416 | echo '<br>'; |
417 | 417 | printf( |
418 | 418 | /* translators: Placeholders: %1$s, %2$s and %3$s are PHP code snippets examples */ |
419 | - __( 'Allows to write %1$s or %2$s instructions in PHP to inspect %3$s in the JavaScript console.', 'wp-php-console' ), |
|
419 | + __('Allows to write %1$s or %2$s instructions in PHP to inspect %3$s in the JavaScript console.', 'wp-php-console'), |
|
420 | 420 | '<code>PC::debug($var, $tag)</code>', |
421 | 421 | '<code>PC::magic_tag($var)</code>', |
422 | 422 | '<code>$var</code>' |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | private function output_show_call_stack_field_instructions() { |
434 | 434 | |
435 | 435 | ?> |
436 | - <p class="description"><?php esc_html_e( 'Enable to see the full call stack when PHP Console writes to the browser JavaScript console.', 'wp-php-console' ); ?></p> |
|
436 | + <p class="description"><?php esc_html_e('Enable to see the full call stack when PHP Console writes to the browser JavaScript console.', 'wp-php-console'); ?></p> |
|
437 | 437 | <?php |
438 | 438 | } |
439 | 439 | |
@@ -447,11 +447,11 @@ discard block |
||
447 | 447 | |
448 | 448 | ?> |
449 | 449 | <p class="description"><?php |
450 | - esc_html_e( 'Enable to shorten the length of PHP Console error sources and traces paths in browser JavaScript console for better readability.', 'wp-php-console' ); |
|
450 | + esc_html_e('Enable to shorten the length of PHP Console error sources and traces paths in browser JavaScript console for better readability.', 'wp-php-console'); |
|
451 | 451 | echo '<br>'; |
452 | 452 | printf( |
453 | 453 | /* translators: Placeholders: %1$s - long server path, %2$s - shortened server path */ |
454 | - __( 'Paths like %1$s will be displayed as %2$s', 'wp-php-console' ), |
|
454 | + __('Paths like %1$s will be displayed as %2$s', 'wp-php-console'), |
|
455 | 455 | '<code>/server/path/to/document/root/WP/wp-admin/admin.php:31</code>', |
456 | 456 | '<code>/WP/wp-admin/admin.php:31</code>' |
457 | 457 | ); ?></p> |
@@ -469,24 +469,24 @@ discard block |
||
469 | 469 | * @param array $option user input |
470 | 470 | * @return array sanitized input |
471 | 471 | */ |
472 | - public function sanitize_field( $option ) { |
|
472 | + public function sanitize_field($option) { |
|
473 | 473 | |
474 | - $input = wp_parse_args( $option, [ |
|
474 | + $input = wp_parse_args($option, [ |
|
475 | 475 | 'ip' => '', |
476 | 476 | 'password' => '', |
477 | 477 | 'register' => false, |
478 | 478 | 'short' => false, |
479 | 479 | 'ssl' => false, |
480 | 480 | 'stack' => false, |
481 | - ] ); |
|
481 | + ]); |
|
482 | 482 | |
483 | 483 | $sanitized_input = [ |
484 | - 'ip' => sanitize_text_field( $input['ip'] ), |
|
485 | - 'password' => sanitize_text_field( $input['password'] ), |
|
486 | - 'register' => ! empty( $input['register'] ), |
|
487 | - 'short' => ! empty( $input['short'] ), |
|
488 | - 'ssl' => ! empty( $input['ssl'] ), |
|
489 | - 'stack' => ! empty( $input['stack'] ), |
|
484 | + 'ip' => sanitize_text_field($input['ip']), |
|
485 | + 'password' => sanitize_text_field($input['password']), |
|
486 | + 'register' => ! empty($input['register']), |
|
487 | + 'short' => ! empty($input['short']), |
|
488 | + 'ssl' => ! empty($input['ssl']), |
|
489 | + 'stack' => ! empty($input['stack']), |
|
490 | 490 | ]; |
491 | 491 | |
492 | 492 | return $sanitized_input; |
@@ -509,9 +509,9 @@ discard block |
||
509 | 509 | <form method="post" action="options.php"> |
510 | 510 | <?php |
511 | 511 | |
512 | - settings_fields( $this->option_key ); |
|
512 | + settings_fields($this->option_key); |
|
513 | 513 | |
514 | - do_settings_sections( $this->page_id ); |
|
514 | + do_settings_sections($this->page_id); |
|
515 | 515 | |
516 | 516 | submit_button(); |
517 | 517 |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | |
17 | 17 | use PhpConsole; |
18 | 18 | |
19 | -defined( 'ABSPATH' ) or exit; |
|
19 | +defined('ABSPATH') or exit; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * WP PHP Console main class. |
@@ -47,32 +47,32 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function __construct() { |
49 | 49 | |
50 | - @error_reporting( E_ALL ); |
|
50 | + @error_reporting(E_ALL); |
|
51 | 51 | |
52 | - foreach ( [ 'WP_DEBUG', 'WP_DEBUG_LOG', 'WP_DEBUG_DISPLAY', ] as $wp_debug_constant ) { |
|
53 | - if ( ! defined( $wp_debug_constant ) ) { |
|
54 | - define ( $wp_debug_constant, true ); |
|
52 | + foreach (['WP_DEBUG', 'WP_DEBUG_LOG', 'WP_DEBUG_DISPLAY', ] as $wp_debug_constant) { |
|
53 | + if ( ! defined($wp_debug_constant)) { |
|
54 | + define($wp_debug_constant, true); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | 58 | // handle translations |
59 | - add_action( 'plugins_loaded', static function() { |
|
59 | + add_action('plugins_loaded', static function() { |
|
60 | 60 | load_plugin_textdomain( |
61 | 61 | 'wp-php-console', |
62 | 62 | false, |
63 | - dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' |
|
63 | + dirname(dirname(plugin_basename(__FILE__))).'/languages/' |
|
64 | 64 | ); |
65 | 65 | } ); |
66 | 66 | |
67 | - if ( class_exists( 'PhpConsole\Connector' ) ) { |
|
67 | + if (class_exists('PhpConsole\Connector')) { |
|
68 | 68 | // connect to PHP Console |
69 | - add_action( 'init', [ $this, 'connect' ], -1000 ); |
|
69 | + add_action('init', [$this, 'connect'], -1000); |
|
70 | 70 | // delay further PHP Console initialisation to have more context during Remote PHP execution |
71 | - add_action( 'wp_loaded', [ $this, 'init' ], -1000 ); |
|
71 | + add_action('wp_loaded', [$this, 'init'], -1000); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | // load admin |
75 | - if ( is_admin() ) { |
|
75 | + if (is_admin()) { |
|
76 | 76 | new Admin(); |
77 | 77 | } |
78 | 78 | } |
@@ -91,27 +91,27 @@ discard block |
||
91 | 91 | public function connect() { |
92 | 92 | |
93 | 93 | // workaround for avoiding headers already sent warnings |
94 | - @error_reporting( E_ALL & ~E_WARNING ); |
|
94 | + @error_reporting(E_ALL & ~E_WARNING); |
|
95 | 95 | |
96 | - if ( ! @session_id() ) { |
|
96 | + if ( ! @session_id()) { |
|
97 | 97 | @session_start(); |
98 | 98 | } |
99 | 99 | |
100 | 100 | $connected = true; |
101 | 101 | |
102 | - if ( ! $this->connector instanceof PhpConsole\Connector ) { |
|
102 | + if ( ! $this->connector instanceof PhpConsole\Connector) { |
|
103 | 103 | try { |
104 | 104 | $this->connector = PhpConsole\Connector::getInstance(); |
105 | - } catch ( \Exception $e ) { |
|
105 | + } catch (\Exception $e) { |
|
106 | 106 | $connected = false; |
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
110 | 110 | // restore error reporting |
111 | - @error_reporting( E_ALL ); |
|
111 | + @error_reporting(E_ALL); |
|
112 | 112 | |
113 | 113 | // apply PHP Console options |
114 | - if ( $connected ) { |
|
114 | + if ($connected) { |
|
115 | 115 | $this->apply_options(); |
116 | 116 | } |
117 | 117 | } |
@@ -125,31 +125,31 @@ discard block |
||
125 | 125 | private function apply_options() { |
126 | 126 | |
127 | 127 | // bail out if not connected yet to PHP Console |
128 | - if ( ! $this->connector instanceof PhpConsole\Connector ) { |
|
128 | + if ( ! $this->connector instanceof PhpConsole\Connector) { |
|
129 | 129 | return; |
130 | 130 | } |
131 | 131 | |
132 | 132 | // apply 'register' option to PHP Console... |
133 | - if ( Settings::should_register_pc_class() && ! class_exists( 'PC', false ) ) { |
|
133 | + if (Settings::should_register_pc_class() && ! class_exists('PC', false)) { |
|
134 | 134 | // ...only if PC not registered yet |
135 | 135 | try { |
136 | 136 | PhpConsole\Helper::register(); |
137 | - } catch( \Exception $e ) { |
|
138 | - $this->print_notice_exception( $e ); |
|
137 | + } catch (\Exception $e) { |
|
138 | + $this->print_notice_exception($e); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
142 | 142 | // apply 'stack' option to PHP Console |
143 | - if ( Settings::should_show_call_stack() ) { |
|
143 | + if (Settings::should_show_call_stack()) { |
|
144 | 144 | $this->connector->getDebugDispatcher()->detectTraceAndSource = true; |
145 | 145 | } |
146 | 146 | |
147 | 147 | // apply 'short' option to PHP Console |
148 | - if ( Settings::should_use_short_path_names() ) { |
|
148 | + if (Settings::should_use_short_path_names()) { |
|
149 | 149 | try { |
150 | - $this->connector->setSourcesBasePath( $_SERVER['DOCUMENT_ROOT'] ); |
|
151 | - } catch ( \Exception $e ) { |
|
152 | - $this->print_notice_exception( $e ); |
|
150 | + $this->connector->setSourcesBasePath($_SERVER['DOCUMENT_ROOT']); |
|
151 | + } catch (\Exception $e) { |
|
152 | + $this->print_notice_exception($e); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | } |
@@ -165,95 +165,95 @@ discard block |
||
165 | 165 | public function init() { |
166 | 166 | |
167 | 167 | // bail if no password is set to connect with PHP Console |
168 | - if ( ! Settings::has_eval_terminal_password() ) { |
|
168 | + if ( ! Settings::has_eval_terminal_password()) { |
|
169 | 169 | return; |
170 | 170 | } |
171 | 171 | |
172 | 172 | // selectively remove slashes added by WordPress as expected by PHP Console |
173 | - if ( array_key_exists( PhpConsole\Connector::POST_VAR_NAME, $_POST ) ) { |
|
174 | - $_POST[ PhpConsole\Connector::POST_VAR_NAME ] = stripslashes_deep( $_POST[ PhpConsole\Connector::POST_VAR_NAME ] ); |
|
173 | + if (array_key_exists(PhpConsole\Connector::POST_VAR_NAME, $_POST)) { |
|
174 | + $_POST[PhpConsole\Connector::POST_VAR_NAME] = stripslashes_deep($_POST[PhpConsole\Connector::POST_VAR_NAME]); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | // get PHP Console instance if wasn't set yet |
178 | - if ( ! $this->connector instanceof PhpConsole\Connector ) { |
|
178 | + if ( ! $this->connector instanceof PhpConsole\Connector) { |
|
179 | 179 | |
180 | 180 | // workaround for avoiding headers already sent warnings |
181 | - @error_reporting( E_ALL & ~E_WARNING ); |
|
181 | + @error_reporting(E_ALL & ~E_WARNING); |
|
182 | 182 | |
183 | 183 | try { |
184 | 184 | $this->connector = PhpConsole\Connector::getInstance(); |
185 | 185 | $connected = true; |
186 | - } catch ( \Exception $e ) { |
|
186 | + } catch (\Exception $e) { |
|
187 | 187 | $connected = false; |
188 | 188 | } |
189 | 189 | |
190 | 190 | // restore error reporting |
191 | - @error_reporting( E_ALL ); |
|
191 | + @error_reporting(E_ALL); |
|
192 | 192 | |
193 | - if ( ! $connected ) { |
|
193 | + if ( ! $connected) { |
|
194 | 194 | return; |
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
198 | 198 | // set PHP Console password |
199 | 199 | try { |
200 | - $this->connector->setPassword( Settings::get_eval_terminal_password() ); |
|
201 | - } catch ( \Exception $e ) { |
|
202 | - $this->print_notice_exception( $e ); |
|
200 | + $this->connector->setPassword(Settings::get_eval_terminal_password()); |
|
201 | + } catch (\Exception $e) { |
|
202 | + $this->print_notice_exception($e); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | // get PHP Console handler instance |
206 | 206 | $handler = PhpConsole\Handler::getInstance(); |
207 | 207 | |
208 | - if ( true !== PhpConsole\Handler::getInstance()->isStarted() ) { |
|
208 | + if (true !== PhpConsole\Handler::getInstance()->isStarted()) { |
|
209 | 209 | try { |
210 | 210 | $handler->start(); |
211 | - } catch( \Exception $e ) { |
|
212 | - $this->print_notice_exception( $e ); |
|
211 | + } catch (\Exception $e) { |
|
212 | + $this->print_notice_exception($e); |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
217 | 217 | // enable SSL-only mode |
218 | - if ( Settings::should_use_ssl_only() ) { |
|
218 | + if (Settings::should_use_ssl_only()) { |
|
219 | 219 | $this->connector->enableSslOnlyMode(); |
220 | 220 | } |
221 | 221 | |
222 | 222 | // restrict IP addresses |
223 | 223 | $allowedIpMasks = Settings::get_allowed_ip_masks(); |
224 | 224 | |
225 | - if ( count( $allowedIpMasks ) > 0 ) { |
|
226 | - $this->connector->setAllowedIpMasks( $allowedIpMasks ); |
|
225 | + if (count($allowedIpMasks) > 0) { |
|
226 | + $this->connector->setAllowedIpMasks($allowedIpMasks); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | $evalProvider = $this->connector->getEvalDispatcher()->getEvalProvider(); |
230 | 230 | |
231 | 231 | try { |
232 | - $evalProvider->addSharedVar( 'uri', $_SERVER['REQUEST_URI'] ); |
|
233 | - } catch ( \Exception $e ) { |
|
234 | - $this->print_notice_exception( $e ); |
|
232 | + $evalProvider->addSharedVar('uri', $_SERVER['REQUEST_URI']); |
|
233 | + } catch (\Exception $e) { |
|
234 | + $this->print_notice_exception($e); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | try { |
238 | - $evalProvider->addSharedVarReference( 'post', $_POST ); |
|
239 | - } catch ( \Exception $e ) { |
|
240 | - $this->print_notice_exception( $e ); |
|
238 | + $evalProvider->addSharedVarReference('post', $_POST); |
|
239 | + } catch (\Exception $e) { |
|
240 | + $this->print_notice_exception($e); |
|
241 | 241 | } |
242 | 242 | |
243 | - $openBaseDirs = [ ABSPATH, get_template_directory() ]; |
|
243 | + $openBaseDirs = [ABSPATH, get_template_directory()]; |
|
244 | 244 | |
245 | 245 | try { |
246 | - $evalProvider->addSharedVarReference( 'dirs', $openBaseDirs ); |
|
247 | - } catch ( \Exception $e ) { |
|
248 | - $this->print_notice_exception( $e ); |
|
246 | + $evalProvider->addSharedVarReference('dirs', $openBaseDirs); |
|
247 | + } catch (\Exception $e) { |
|
248 | + $this->print_notice_exception($e); |
|
249 | 249 | } |
250 | 250 | |
251 | - $evalProvider->setOpenBaseDirs( $openBaseDirs ); |
|
251 | + $evalProvider->setOpenBaseDirs($openBaseDirs); |
|
252 | 252 | |
253 | 253 | try { |
254 | 254 | $this->connector->startEvalRequestsListener(); |
255 | - } catch ( \Exception $e ) { |
|
256 | - $this->print_notice_exception( $e ); |
|
255 | + } catch (\Exception $e) { |
|
256 | + $this->print_notice_exception($e); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
@@ -265,12 +265,12 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @param \Exception $e Exception object |
267 | 267 | */ |
268 | - private function print_notice_exception( \Exception $e ) { |
|
268 | + private function print_notice_exception(\Exception $e) { |
|
269 | 269 | |
270 | - add_action( 'admin_notices', static function() use ( $e ) { |
|
270 | + add_action('admin_notices', static function() use ($e) { |
|
271 | 271 | ?> |
272 | 272 | <div class="error"> |
273 | - <p><?php printf( '%1$s: %2$s', self::NAME, $e->getMessage() ); ?></p> |
|
273 | + <p><?php printf('%1$s: %2$s', self::NAME, $e->getMessage()); ?></p> |
|
274 | 274 | </div> |
275 | 275 | <?php |
276 | 276 | } ); |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | */ |
287 | 287 | public static function get_plugin_path() { |
288 | 288 | |
289 | - return untrailingslashit( dirname( __DIR__ ) ); |
|
289 | + return untrailingslashit(dirname(__DIR__)); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | */ |
298 | 298 | public static function get_plugin_vendor_path() { |
299 | 299 | |
300 | - return self::get_plugin_path() . '/vendor'; |
|
300 | + return self::get_plugin_path().'/vendor'; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 |