Completed
Push — master ( eefc26...1149e8 )
by Fulvio
08:09 queued 03:31
created
uninstall.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@
 block discarded – undo
12 12
  * @license   http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
13 13
  */
14 14
 
15
-if ( ! defined( 'ABSPATH' ) || ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
15
+if ( ! defined('ABSPATH') || ! defined('WP_UNINSTALL_PLUGIN')) {
16 16
 	exit;
17 17
 }
18 18
 
19
-delete_option( 'wp_php_console' );
19
+delete_option('wp_php_console');
Please login to merge, or discard this patch.
includes/Settings.php 1 patch
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 namespace WP_PHP_Console;
4 4
 
5
-defined( 'ABSPATH' ) or exit;
5
+defined('ABSPATH') or exit;
6 6
 
7 7
 /**
8 8
  * WP PHP Console settings handler.
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @param array $options plugin settings options
31 31
 	 */
32
-	public function __construct( array $options ) {
32
+	public function __construct(array $options) {
33 33
 
34
-		$this->page    = sanitize_title( strtolower( Plugin::NAME ) );
35
-		$this->option  = str_replace( '-', '_', $this->page );
34
+		$this->page    = sanitize_title(strtolower(Plugin::NAME));
35
+		$this->option  = str_replace('-', '_', $this->page);
36 36
 		$this->options = $options;
37 37
 
38
-		add_action( 'admin_menu', [ $this, 'register_settings_page' ] );
38
+		add_action('admin_menu', [$this, 'register_settings_page']);
39 39
 	}
40 40
 
41 41
 
@@ -49,14 +49,14 @@  discard block
 block discarded – undo
49 49
 	public function register_settings_page() {
50 50
 
51 51
 		add_options_page(
52
-			__( 'WP PHP Console', 'wp-php-console' ),
53
-			__( 'WP PHP Console', 'wp-php-console' ),
52
+			__('WP PHP Console', 'wp-php-console'),
53
+			__('WP PHP Console', 'wp-php-console'),
54 54
 			'manage_options',
55 55
 			$this->page,
56
-			[ $this, 'settings_page' ]
56
+			[$this, 'settings_page']
57 57
 		);
58 58
 
59
-		add_action( 'admin_init', [ $this, 'register_settings'  ] );
59
+		add_action('admin_init', [$this, 'register_settings']);
60 60
 	}
61 61
 
62 62
 
@@ -72,46 +72,46 @@  discard block
 block discarded – undo
72 72
 		register_setting(
73 73
 			$this->option,
74 74
 			$this->option,
75
-			[ $this, 'sanitize_field' ]
75
+			[$this, 'sanitize_field']
76 76
 		);
77 77
 
78 78
 		add_settings_section(
79 79
 			$this->option,
80
-			__( 'Settings', 'wp-php-console' ),
81
-			[ $this, 'settings_info' ],
80
+			__('Settings', 'wp-php-console'),
81
+			[$this, 'settings_info'],
82 82
 			$this->page
83 83
 		);
84 84
 
85 85
 		$settings_fields = [
86 86
 			'password' => [
87
-				 'label'    => esc_html__( 'Password',           'wp-php-console' ),
88
-				 'callback' => [ $this, 'password_field' ],
87
+				 'label'    => esc_html__('Password', 'wp-php-console'),
88
+				 'callback' => [$this, 'password_field'],
89 89
 			],
90 90
 			'ssl'      => [
91
-				 'label'    => esc_html__( 'Allow only on SSL',  'wp-php-console' ),
92
-				 'callback' => [ $this, 'ssl_field' ],
91
+				 'label'    => esc_html__('Allow only on SSL', 'wp-php-console'),
92
+				 'callback' => [$this, 'ssl_field'],
93 93
 			],
94 94
 			'ip' => [
95
-				 'label'    => esc_html__( 'Allowed IP Masks',   'wp-php-console' ),
96
-				 'callback' => [ $this, 'ip_field' ],
95
+				 'label'    => esc_html__('Allowed IP Masks', 'wp-php-console'),
96
+				 'callback' => [$this, 'ip_field'],
97 97
 			],
98 98
 			'register' => [
99
-				 'label'    => esc_html__( 'Register PC Class',  'wp-php-console' ),
100
-				 'callback' => [ $this, 'register_field' ],
99
+				 'label'    => esc_html__('Register PC Class', 'wp-php-console'),
100
+				 'callback' => [$this, 'register_field'],
101 101
 			],
102 102
 			'stack'    => [
103
-				 'label'    => esc_html__( 'Show Call Stack',    'wp-php-console' ),
104
-				 'callback' => [ $this, 'stack_field' ],
103
+				 'label'    => esc_html__('Show Call Stack', 'wp-php-console'),
104
+				 'callback' => [$this, 'stack_field'],
105 105
 			],
106 106
 			'short'    => [
107
-				 'label'    => esc_html__( 'Short Path Names',   'wp-php-console' ),
108
-				 'callback' => [ $this, 'short_field' ],
107
+				 'label'    => esc_html__('Short Path Names', 'wp-php-console'),
108
+				 'callback' => [$this, 'short_field'],
109 109
 			],
110 110
 		];
111 111
 
112
-		foreach ( $settings_fields as $key => $field ) {
112
+		foreach ($settings_fields as $key => $field) {
113 113
 			add_settings_field(
114
-				$this->page . '['. $key . ']',
114
+				$this->page.'['.$key.']',
115 115
 				$field['label'],
116 116
 				$field['callback'],
117 117
 				$this->page,
@@ -135,31 +135,31 @@  discard block
 block discarded – undo
135 135
 		?>
136 136
 		<p><?php printf(
137 137
 				/* translators: Placeholder: %s refers to the PHP Console library, pointing to its GitHub repository */
138
-				_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' ),
138
+				_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'),
139 139
 				'<a href="https://github.com/barbushin/php-console" target="_blank">PHP Console</a>'
140 140
 			);
141
-		?><br><?php esc_html_e( 'Usage instructions:', 'wp-php-console' ); ?></p>
141
+		?><br><?php esc_html_e('Usage instructions:', 'wp-php-console'); ?></p>
142 142
 		<ol>
143 143
 			<?php
144 144
 
145 145
 			$instructions = [
146 146
 				sprintf(
147 147
 					/* translators: Placeholder: %s represents the Google Chrome PHP Console extension download link */
148
-					_x( 'Make sure you have downloaded and installed %s.', 'PHP Console, the Chrome Extension', 'wp-php-console' ),
148
+					_x('Make sure you have downloaded and installed %s.', 'PHP Console, the Chrome Extension', 'wp-php-console'),
149 149
 					'<a target="_blank" href="https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef">PHP Console extension for Google Chrome</a>'
150 150
 				),
151
-				esc_html__( 'Set a password for the eval terminal in the options below and hit "Save Changes".', 'wp-php-console' ),
152
-				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' ),
153
-				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' ),
151
+				esc_html__('Set a password for the eval terminal in the options below and hit "Save Changes".', 'wp-php-console'),
152
+				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'),
153
+				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'),
154 154
 				sprintf(
155 155
 					/* translators: Placeholders: %1$s - PHP code snippet example, %2$s - Chrome javascript console shortcut */
156
-					__( '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' ),
156
+					__('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'),
157 157
 					'<code>debug(&#36;var, &#36;tag)</code>',
158 158
 					'<code>CTRL+SHIFT+J</code>'
159 159
 				),
160 160
 			];
161 161
 
162
-			foreach ( $instructions as $list_item ) :
162
+			foreach ($instructions as $list_item) :
163 163
 				?><li><?php echo $list_item; ?></li><?php
164 164
 			endforeach;
165 165
 
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
 	public function password_field() {
181 181
 
182 182
 		?>
183
-		<input type="password" id="wp-php-console-password" name="wp_php_console[password]" value="<?php echo esc_attr( $this->options['password'] ); ?>">
184
-		<label for="wp-php-console-password"><?php esc_html_e( 'Required', 'wp-php-console' ); ?></label><br>
185
-		<p class="description"><?php esc_html_e( 'The password for the eval terminal. If empty, the plugin will not work.', 'wp-php-console' ); ?></p>
183
+		<input type="password" id="wp-php-console-password" name="wp_php_console[password]" value="<?php echo esc_attr($this->options['password']); ?>">
184
+		<label for="wp-php-console-password"><?php esc_html_e('Required', 'wp-php-console'); ?></label><br>
185
+		<p class="description"><?php esc_html_e('The password for the eval terminal. If empty, the plugin will not work.', 'wp-php-console'); ?></p>
186 186
 		<?php
187 187
 	}
188 188
 
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
 	public function ssl_field() {
198 198
 
199 199
 		?>
200
-		<input type="checkbox" id="wp-php-console-ssl" name="wp_php_console[ssl]" value="1" <?php checked( (bool) $this->options['ssl'] ); ?> />
201
-		<label for="wp-php-console-ssl"><?php esc_html_e( 'Yes', 'wp-php-console' ); ?></label><br>
202
-		<p class="description"><?php esc_html_e( 'Tick this option if you want the eval terminal to work only on a SSL connection.', 'wp-php-console' ); ?></p>
200
+		<input type="checkbox" id="wp-php-console-ssl" name="wp_php_console[ssl]" value="1" <?php checked((bool) $this->options['ssl']); ?> />
201
+		<label for="wp-php-console-ssl"><?php esc_html_e('Yes', 'wp-php-console'); ?></label><br>
202
+		<p class="description"><?php esc_html_e('Tick this option if you want the eval terminal to work only on a SSL connection.', 'wp-php-console'); ?></p>
203 203
 		<?php
204 204
 	}
205 205
 
@@ -214,19 +214,19 @@  discard block
 block discarded – undo
214 214
 	public function ip_field() {
215 215
 
216 216
 		?>
217
-		<input type="text" class="regular-text" id="wp-php-console-ip" name="wp_php_console[ip]" value="<?php echo esc_attr( $this->options['ip'] ); ?>" />
218
-		<label for="wp-php-console-ip"><?php esc_html_e( 'IP addresses (optional)', 'wp-php-console' ); ?></label><br>
219
-		<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' ); ?><br>
217
+		<input type="text" class="regular-text" id="wp-php-console-ip" name="wp_php_console[ip]" value="<?php echo esc_attr($this->options['ip']); ?>" />
218
+		<label for="wp-php-console-ip"><?php esc_html_e('IP addresses (optional)', 'wp-php-console'); ?></label><br>
219
+		<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'); ?><br>
220 220
 			<ol>
221 221
 				<li><small><?php printf(
222 222
 						/* translators: Placeholders: %1$s - a single IP address, %2$s link to Varying Vagrant Vagrants project repository */
223
-						__( 'An IP address (for example %1$s, %2$s default IP address).', 'wp-php-console' ),
223
+						__('An IP address (for example %1$s, %2$s default IP address).', 'wp-php-console'),
224 224
 						'<code>192.168.50.4</code>',
225 225
 						'<a href="https://github.com/Varying-Vagrant-Vagrants/VVV">Varying Vagrant Vagrants</a>'
226 226
 					); ?></small></li>
227 227
 				<li><small><?php printf(
228 228
 						/* translators: Placeholders: %1$s a range of IP addresses, %2$s - comma separated IP addresses */
229
-						__( 'A range of addresses (%1$s) or multiple addresses, comma separated (%2$s).', 'wp-php-console' ),
229
+						__('A range of addresses (%1$s) or multiple addresses, comma separated (%2$s).', 'wp-php-console'),
230 230
 						'<code>192.168.*.*</code>',
231 231
 						'<code>192.168.10.25,192.168.10.28</code>'
232 232
 					); ?></small></li>
@@ -246,14 +246,14 @@  discard block
 block discarded – undo
246 246
 	public function register_field() {
247 247
 
248 248
 		?>
249
-		<input type="checkbox" id="wp-php-console-register" name="wp_php_console[register]" value="1" <?php checked( (bool) $this->options['register'] ); ?> />
250
-		<label for="wp-php-console-register"><?php esc_html_e( 'Yes', 'wp-php-console' ); ?></label><br>
249
+		<input type="checkbox" id="wp-php-console-register" name="wp_php_console[register]" value="1" <?php checked((bool) $this->options['register']); ?> />
250
+		<label for="wp-php-console-register"><?php esc_html_e('Yes', 'wp-php-console'); ?></label><br>
251 251
 		<p class="description"><?php
252
-			esc_html_e( 'Tick to register PC class in the global namespace.', 'wp-php-console' );
252
+			esc_html_e('Tick to register PC class in the global namespace.', 'wp-php-console');
253 253
 			echo '<br>';
254 254
 			printf(
255 255
 				/* translators: Placeholders: %1$s, %2$s and %3$s are PHP code snippets examples */
256
-				__( 'Allows to write %1$s or %2$s instructions in PHP to inspect %3$s in the JavaScript console.', 'wp-php-console' ),
256
+				__('Allows to write %1$s or %2$s instructions in PHP to inspect %3$s in the JavaScript console.', 'wp-php-console'),
257 257
 				'<code>PC::debug(&#36;var, &#36;tag)</code>',
258 258
 				'<code>PC::magic_tag(&#36;var)</code>',
259 259
 				'<code>&#36;var</code>'
@@ -272,9 +272,9 @@  discard block
 block discarded – undo
272 272
 	public function stack_field() {
273 273
 
274 274
 		?>
275
-		<input type="checkbox" id="wp-php-console-stack" name="wp_php_console[stack]" value="1" <?php checked( (bool) $this->options['stack'] ); ?> />
276
-		<label for="wp-php-console-stack"><?php esc_html_e( 'Yes', 'wp-php-console' ); ?></label><br />
277
-		<p class="description"><?php esc_html_e( 'Tick to see the full call stack when PHP Console writes to the browser JavaScript console.', 'wp-php-console' ); ?></p>
275
+		<input type="checkbox" id="wp-php-console-stack" name="wp_php_console[stack]" value="1" <?php checked((bool) $this->options['stack']); ?> />
276
+		<label for="wp-php-console-stack"><?php esc_html_e('Yes', 'wp-php-console'); ?></label><br />
277
+		<p class="description"><?php esc_html_e('Tick to see the full call stack when PHP Console writes to the browser JavaScript console.', 'wp-php-console'); ?></p>
278 278
 		<?php
279 279
 	}
280 280
 
@@ -289,14 +289,14 @@  discard block
 block discarded – undo
289 289
 	public function short_field() {
290 290
 
291 291
 		?>
292
-		<input type="checkbox" id="wp-php-console-short" name="wp_php_console[short]" value="1" <?php checked( (bool) $this->options['short'] ); ?> />
293
-		<label for="wp-php-console-short"><?php esc_html_e( 'Yes', 'wp-php-console' ); ?></label><br>
292
+		<input type="checkbox" id="wp-php-console-short" name="wp_php_console[short]" value="1" <?php checked((bool) $this->options['short']); ?> />
293
+		<label for="wp-php-console-short"><?php esc_html_e('Yes', 'wp-php-console'); ?></label><br>
294 294
 		<p class="description"><?php
295
-			esc_html_e( 'Tick to shorten the length of PHP Console error sources and traces paths in browser JavaScript console for better readability.', 'wp-php-console' );
295
+			esc_html_e('Tick to shorten the length of PHP Console error sources and traces paths in browser JavaScript console for better readability.', 'wp-php-console');
296 296
 			echo '<br>';
297 297
 			printf(
298 298
 				/* translators: Placeholders: %1$s - long server path, %2$s - shortened server path */
299
-				__( 'Paths like %1$s will be displayed as %2$s', 'wp-php-console' ),
299
+				__('Paths like %1$s will be displayed as %2$s', 'wp-php-console'),
300 300
 				'<code>/server/path/to/document/root/WP/wp-admin/admin.php:31</code>',
301 301
 				'<code>/WP/wp-admin/admin.php:31</code>'
302 302
 			); ?></p>
@@ -314,24 +314,24 @@  discard block
 block discarded – undo
314 314
 	 * @param array $option user input
315 315
 	 * @return array sanitized input
316 316
 	 */
317
-	public function sanitize_field( $option ) {
317
+	public function sanitize_field($option) {
318 318
 
319
-		$input = wp_parse_args( $option, [
319
+		$input = wp_parse_args($option, [
320 320
 			'ip'       => '',
321 321
 			'password' => '',
322 322
 			'register' => false,
323 323
 			'short'    => false,
324 324
 			'ssl'      => false,
325 325
 			'stack'    => false,
326
-		] );
326
+		]);
327 327
 
328 328
 		$sanitized_input = [
329
-			'ip'       => sanitize_text_field( $input['ip'] ),
330
-			'password' => sanitize_text_field( $input['password'] ),
331
-			'register' => ! empty( $input['register'] ),
332
-			'short'    => ! empty( $input['short'] ),
333
-			'ssl'      => ! empty( $input['ssl'] ),
334
-			'stack'    => ! empty( $input['stack'] ),
329
+			'ip'       => sanitize_text_field($input['ip']),
330
+			'password' => sanitize_text_field($input['password']),
331
+			'register' => ! empty($input['register']),
332
+			'short'    => ! empty($input['short']),
333
+			'ssl'      => ! empty($input['ssl']),
334
+			'stack'    => ! empty($input['stack']),
335 335
 		];
336 336
 
337 337
 		return $sanitized_input;
@@ -349,14 +349,14 @@  discard block
 block discarded – undo
349 349
 
350 350
 		?>
351 351
 		<div class="wrap">
352
-			<h2><?php esc_html_e( 'WP PHP Console', 'wp-php-console' ); ?></h2>
352
+			<h2><?php esc_html_e('WP PHP Console', 'wp-php-console'); ?></h2>
353 353
 			<hr />
354 354
 			<form method="post" action="options.php">
355 355
 				<?php
356 356
 
357
-				settings_fields( $this->option );
357
+				settings_fields($this->option);
358 358
 
359
-				do_settings_sections( $this->page );
359
+				do_settings_sections($this->page);
360 360
 
361 361
 				submit_button();
362 362
 
Please login to merge, or discard this patch.
includes/Plugin.php 1 patch
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
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.
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 	 */
62 62
 	private function set_debug_mode() {
63 63
 
64
-		@error_reporting( E_ALL );
64
+		@error_reporting(E_ALL);
65 65
 
66
-		foreach ( [ 'WP_DEBUG',	'WP_DEBUG_LOG', 'WP_DEBUG_DISPLAY', ] as $wp_debug_constant ) {
67
-			if ( ! defined( $wp_debug_constant ) ) {
68
-				define ( $wp_debug_constant, true );
66
+		foreach (['WP_DEBUG', 'WP_DEBUG_LOG', 'WP_DEBUG_DISPLAY', ] as $wp_debug_constant) {
67
+			if ( ! defined($wp_debug_constant)) {
68
+				define($wp_debug_constant, true);
69 69
 			}
70 70
 		}
71 71
 	}
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		load_plugin_textdomain(
93 93
 			'wp-php-console',
94 94
 			false,
95
-			dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/'
95
+			dirname(dirname(plugin_basename(__FILE__))).'/languages/'
96 96
 		);
97 97
 	}
98 98
 
@@ -104,17 +104,17 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	private function set_admin() {
106 106
 
107
-		if ( ! defined( 'DOING_AJAX' ) && is_admin() ) {
107
+		if ( ! defined('DOING_AJAX') && is_admin()) {
108 108
 
109 109
 			// add a settings link to the plugins admin screen
110
-			$plugin_name = str_replace( 'includes/class-', '', plugin_basename( __FILE__ ) );
111
-			add_filter( "plugin_action_links_{$plugin_name}", static function( $actions ) {
112
-				return array_merge( [
113
-					'<a href="' . esc_url( admin_url( 'options-general.php?page=wp-php-console' ) ) . '">' . __( 'Settings', 'wp-php-console' ) . '</a>',
114
-				], $actions );
110
+			$plugin_name = str_replace('includes/class-', '', plugin_basename(__FILE__));
111
+			add_filter("plugin_action_links_{$plugin_name}", static function($actions) {
112
+				return array_merge([
113
+					'<a href="'.esc_url(admin_url('options-general.php?page=wp-php-console')).'">'.__('Settings', 'wp-php-console').'</a>',
114
+				], $actions);
115 115
 			} );
116 116
 
117
-			new Settings( $this->options );
117
+			new Settings($this->options);
118 118
 		}
119 119
 	}
120 120
 
@@ -127,16 +127,16 @@  discard block
 block discarded – undo
127 127
 	private function set_hooks() {
128 128
 
129 129
 		// bail out if PHP Console can't be found
130
-		if ( ! class_exists( 'PhpConsole\Connector' ) ) {
130
+		if ( ! class_exists('PhpConsole\Connector')) {
131 131
 			return;
132 132
 		}
133 133
 
134 134
 		// handle translations
135
-		add_action( 'plugins_loaded', [ $this, 'set_locale' ] );
135
+		add_action('plugins_loaded', [$this, 'set_locale']);
136 136
 		// connect to PHP Console
137
-		add_action( 'init',           [ $this, 'connect' ], -1000 );
137
+		add_action('init', [$this, 'connect'], -1000);
138 138
 		// delay further PHP Console initialisation to have more context during Remote PHP execution
139
-		add_action( 'wp_loaded',      [ $this, 'init' ], -1000 );
139
+		add_action('wp_loaded', [$this, 'init'], -1000);
140 140
 	}
141 141
 
142 142
 
@@ -152,27 +152,27 @@  discard block
 block discarded – undo
152 152
 	public function connect() {
153 153
 
154 154
 		// workaround for avoiding headers already sent warnings
155
-		@error_reporting( E_ALL & ~E_WARNING );
155
+		@error_reporting(E_ALL & ~E_WARNING);
156 156
 
157
-		if ( ! @session_id() ) {
157
+		if ( ! @session_id()) {
158 158
 			@session_start();
159 159
 		}
160 160
 
161 161
 		$connected = true;
162 162
 
163
-		if ( ! $this->connector instanceof PhpConsole\Connector ) {
163
+		if ( ! $this->connector instanceof PhpConsole\Connector) {
164 164
 			try {
165 165
 				$this->connector = PhpConsole\Connector::getInstance();
166
-			} catch ( \Exception $e ) {
166
+			} catch (\Exception $e) {
167 167
 				$connected = false;
168 168
 			}
169 169
 		}
170 170
 
171 171
 		// restore error reporting
172
-		@error_reporting( E_ALL );
172
+		@error_reporting(E_ALL);
173 173
 
174 174
 		// apply PHP Console options
175
-		if ( $connected ) {
175
+		if ($connected) {
176 176
 			$this->apply_options();
177 177
 		}
178 178
 	}
@@ -187,16 +187,16 @@  discard block
 block discarded – undo
187 187
 	 */
188 188
 	protected function get_options() {
189 189
 
190
-		$options = get_option( 'wp_php_console', [] );
190
+		$options = get_option('wp_php_console', []);
191 191
 
192
-		return wp_parse_args( $options, [
192
+		return wp_parse_args($options, [
193 193
 			'ip'       => '',
194 194
 			'password' => '',
195 195
 			'register' => false,
196 196
 			'short'    => false,
197 197
 			'ssl'      => false,
198 198
 			'stack'    => false,
199
-		] );
199
+		]);
200 200
 	}
201 201
 
202 202
 
@@ -208,31 +208,31 @@  discard block
 block discarded – undo
208 208
 	private function apply_options() {
209 209
 
210 210
 		// bail out if not connected yet to PHP Console
211
-		if ( ! $this->connector instanceof PhpConsole\Connector ) {
211
+		if ( ! $this->connector instanceof PhpConsole\Connector) {
212 212
 			return;
213 213
 		}
214 214
 
215 215
 		// apply 'register' option to PHP Console...
216
-		if ( true === $this->options['register'] && ! class_exists( 'PC', false ) ) {
216
+		if (true === $this->options['register'] && ! class_exists('PC', false)) {
217 217
 			// ...only if PC not registered yet
218 218
 			try {
219 219
 				PhpConsole\Helper::register();
220
-			} catch( \Exception $e ) {
221
-				$this->print_notice_exception( $e );
220
+			} catch (\Exception $e) {
221
+				$this->print_notice_exception($e);
222 222
 			}
223 223
 		}
224 224
 
225 225
 		// apply 'stack' option to PHP Console
226
-		if ( true === $this->options['stack'] ) {
226
+		if (true === $this->options['stack']) {
227 227
 			$this->connector->getDebugDispatcher()->detectTraceAndSource = true;
228 228
 		}
229 229
 
230 230
 		// apply 'short' option to PHP Console
231
-		if ( true === $this->options['short'] ) {
231
+		if (true === $this->options['short']) {
232 232
 			try {
233
-				$this->connector->setSourcesBasePath( $_SERVER['DOCUMENT_ROOT'] );
234
-			} catch ( \Exception $e ) {
235
-				$this->print_notice_exception( $e );
233
+				$this->connector->setSourcesBasePath($_SERVER['DOCUMENT_ROOT']);
234
+			} catch (\Exception $e) {
235
+				$this->print_notice_exception($e);
236 236
 			}
237 237
 		}
238 238
 	}
@@ -248,100 +248,100 @@  discard block
 block discarded – undo
248 248
 	public function init() {
249 249
 
250 250
 		// get PHP Console extension password
251
-		$password = trim( $this->options['password'] );
251
+		$password = trim($this->options['password']);
252 252
 
253
-		if ( empty( $password ) ) {
253
+		if (empty($password)) {
254 254
 
255 255
 			// display admin notice and abort if no password has been set
256
-			add_action( 'admin_notices', [ $this, 'password_notice' ] );
256
+			add_action('admin_notices', [$this, 'password_notice']);
257 257
 			return;
258 258
 		}
259 259
 
260 260
 		// selectively remove slashes added by WordPress as expected by PHP Console
261
-		if ( array_key_exists( PhpConsole\Connector::POST_VAR_NAME, $_POST ) ) {
262
-			$_POST[ PhpConsole\Connector::POST_VAR_NAME ] = stripslashes_deep( $_POST[ PhpConsole\Connector::POST_VAR_NAME ] );
261
+		if (array_key_exists(PhpConsole\Connector::POST_VAR_NAME, $_POST)) {
262
+			$_POST[PhpConsole\Connector::POST_VAR_NAME] = stripslashes_deep($_POST[PhpConsole\Connector::POST_VAR_NAME]);
263 263
 		}
264 264
 
265 265
 		// get PHP Console instance if wasn't set yet
266
-		if ( ! $this->connector instanceof PhpConsole\Connector ) {
266
+		if ( ! $this->connector instanceof PhpConsole\Connector) {
267 267
 
268 268
 			// workaround for avoiding headers already sent warnings
269
-			@error_reporting( E_ALL & ~E_WARNING );
269
+			@error_reporting(E_ALL & ~E_WARNING);
270 270
 
271 271
 			try {
272 272
 				$this->connector = PhpConsole\Connector::getInstance();
273 273
 				$connected       = true;
274
-			} catch ( \Exception $e ) {
274
+			} catch (\Exception $e) {
275 275
 				$connected       = false;
276 276
 			}
277 277
 
278 278
 			// restore error reporting
279
-			@error_reporting( E_ALL );
279
+			@error_reporting(E_ALL);
280 280
 
281
-			if ( ! $connected ) {
281
+			if ( ! $connected) {
282 282
 				return;
283 283
 			}
284 284
 		}
285 285
 
286 286
 		// set PHP Console password
287 287
 		try {
288
-			$this->connector->setPassword( $password );
289
-		} catch ( \Exception $e ) {
290
-			$this->print_notice_exception( $e );
288
+			$this->connector->setPassword($password);
289
+		} catch (\Exception $e) {
290
+			$this->print_notice_exception($e);
291 291
 		}
292 292
 
293 293
 		// get PHP Console handler instance
294 294
 		$handler = PhpConsole\Handler::getInstance();
295 295
 
296
-		if ( true !== PhpConsole\Handler::getInstance()->isStarted() ) {
296
+		if (true !== PhpConsole\Handler::getInstance()->isStarted()) {
297 297
 			try {
298 298
 				$handler->start();
299
-			} catch( \Exception $e ) {
300
-				$this->print_notice_exception( $e );
299
+			} catch (\Exception $e) {
300
+				$this->print_notice_exception($e);
301 301
 				return;
302 302
 			}
303 303
 		}
304 304
 
305 305
 		// enable SSL-only mode
306
-		if ( true === $this->options['ssl'] ) {
306
+		if (true === $this->options['ssl']) {
307 307
 			$this->connector->enableSslOnlyMode();
308 308
 		}
309 309
 
310 310
 		// restrict IP addresses
311
-		$allowedIpMasks = ! empty( $this->options['ip'] ) ? explode( ',', $this->options['ip'] ) : '';
311
+		$allowedIpMasks = ! empty($this->options['ip']) ? explode(',', $this->options['ip']) : '';
312 312
 
313
-		if ( is_array( $allowedIpMasks ) && count( $allowedIpMasks ) > 0 ) {
314
-			$this->connector->setAllowedIpMasks( $allowedIpMasks );
313
+		if (is_array($allowedIpMasks) && count($allowedIpMasks) > 0) {
314
+			$this->connector->setAllowedIpMasks($allowedIpMasks);
315 315
 		}
316 316
 
317 317
 		$evalProvider = $this->connector->getEvalDispatcher()->getEvalProvider();
318 318
 
319 319
 		try {
320
-			$evalProvider->addSharedVar( 'uri', $_SERVER['REQUEST_URI'] );
321
-		} catch ( \Exception $e ) {
322
-			$this->print_notice_exception( $e );
320
+			$evalProvider->addSharedVar('uri', $_SERVER['REQUEST_URI']);
321
+		} catch (\Exception $e) {
322
+			$this->print_notice_exception($e);
323 323
 		}
324 324
 
325 325
 		try {
326
-			$evalProvider->addSharedVarReference( 'post', $_POST );
327
-		} catch ( \Exception $e ) {
328
-			$this->print_notice_exception( $e );
326
+			$evalProvider->addSharedVarReference('post', $_POST);
327
+		} catch (\Exception $e) {
328
+			$this->print_notice_exception($e);
329 329
 		}
330 330
 
331
-		$openBaseDirs = [ ABSPATH, get_template_directory() ];
331
+		$openBaseDirs = [ABSPATH, get_template_directory()];
332 332
 
333 333
 		try {
334
-			$evalProvider->addSharedVarReference( 'dirs', $openBaseDirs );
335
-		} catch ( \Exception $e ) {
336
-			$this->print_notice_exception( $e );
334
+			$evalProvider->addSharedVarReference('dirs', $openBaseDirs);
335
+		} catch (\Exception $e) {
336
+			$this->print_notice_exception($e);
337 337
 		}
338 338
 
339
-		$evalProvider->setOpenBaseDirs( $openBaseDirs );
339
+		$evalProvider->setOpenBaseDirs($openBaseDirs);
340 340
 
341 341
 		try {
342 342
 			$this->connector->startEvalRequestsListener();
343
-		} catch ( \Exception $e ) {
344
-			$this->print_notice_exception( $e );
343
+		} catch (\Exception $e) {
344
+			$this->print_notice_exception($e);
345 345
 		}
346 346
 	}
347 347
 
@@ -353,13 +353,13 @@  discard block
 block discarded – undo
353 353
 	 *
354 354
 	 * @param \Exception $e Exception object
355 355
 	 */
356
-	public function print_notice_exception( \Exception $e ) {
356
+	public function print_notice_exception(\Exception $e) {
357 357
 
358
-		add_action( 'admin_notices', static function() use ( $e ) {
358
+		add_action('admin_notices', static function() use ($e) {
359 359
 
360 360
 			?>
361 361
 			<div class="error">
362
-				<p><?php printf( '%1$s: %2$s', self::NAME, $e->getMessage() ); ?></p>
362
+				<p><?php printf('%1$s: %2$s', self::NAME, $e->getMessage()); ?></p>
363 363
 			</div>
364 364
 			<?php
365 365
 
@@ -383,9 +383,9 @@  discard block
 block discarded – undo
383 383
 		<div class="update-nag">
384 384
 			<p><?php printf(
385 385
 				/* translators: Placeholders: %1$s - WP PHP Console name, %2$s - opening HTML <a> link tag; %3$s closing HTML </a> link tag */
386
-				__( '%1$s: Please remember to %2$sset a password%3$s if you want to enable the terminal.', 'wp-php-console' ),
387
-				'<strong>' . self::NAME . '</strong>',
388
-				'<a href="' . esc_url( admin_url( 'options-general.php?page=wp-php-console' ) ) .'">',
386
+				__('%1$s: Please remember to %2$sset a password%3$s if you want to enable the terminal.', 'wp-php-console'),
387
+				'<strong>'.self::NAME.'</strong>',
388
+				'<a href="'.esc_url(admin_url('options-general.php?page=wp-php-console')).'">',
389 389
 				'</a>'
390 390
 			); ?></p>
391 391
 		</div>
Please login to merge, or discard this patch.
includes/Functions.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
  * @license   http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
13 13
  */
14 14
 
15
-defined( 'ABSPATH' ) or exit;
15
+defined('ABSPATH') or exit;
16 16
 
17 17
 
18 18
 /**
Please login to merge, or discard this patch.
wp-php-console.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
  * at this URL: http://www.gnu.org/licenses/gpl-3.0.html
41 41
  */
42 42
 
43
-defined( 'ABSPATH' ) or exit;
43
+defined('ABSPATH') or exit;
44 44
 
45 45
 /**
46 46
  * WP PHP Console loader.
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	protected function __construct() {
76 76
 
77
-		register_activation_hook( __FILE__, array( $this, 'activation_check' ) );
77
+		register_activation_hook(__FILE__, array($this, 'activation_check'));
78 78
 
79
-		add_action( 'admin_init',    array( $this, 'check_environment' ) );
80
-		add_action( 'admin_init',    array( $this, 'add_plugin_notices' ) );
81
-		add_action( 'admin_notices', array( $this, 'admin_notices' ), 15 );
79
+		add_action('admin_init', array($this, 'check_environment'));
80
+		add_action('admin_init', array($this, 'add_plugin_notices'));
81
+		add_action('admin_notices', array($this, 'admin_notices'), 15);
82 82
 
83 83
 		// if the environment check fails, initialize the plugin
84
-		if ( $this->is_environment_compatible() && $this->is_wp_compatible() ) {
84
+		if ($this->is_environment_compatible() && $this->is_wp_compatible()) {
85 85
 			$this->init_plugin();
86 86
 		}
87 87
 	}
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 */
95 95
 	public function __clone() {
96 96
 
97
-		_doing_it_wrong( __FUNCTION__, sprintf( 'You cannot clone instances of %s.', get_class( $this ) ), '1.5.4' );
97
+		_doing_it_wrong(__FUNCTION__, sprintf('You cannot clone instances of %s.', get_class($this)), '1.5.4');
98 98
 	}
99 99
 
100 100
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	public function __wakeup() {
107 107
 
108
-		_doing_it_wrong( __FUNCTION__, sprintf( 'You cannot unserialize instances of %s.', get_class( $this ) ), '1.5.4' );
108
+		_doing_it_wrong(__FUNCTION__, sprintf('You cannot unserialize instances of %s.', get_class($this)), '1.5.4');
109 109
 	}
110 110
 
111 111
 
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
 	private function init_plugin() {
120 120
 
121 121
 		// autoload plugin and vendor files
122
-		$loader = require_once( plugin_dir_path( __FILE__ ) . 'vendor/autoload.php' );
122
+		$loader = require_once(plugin_dir_path(__FILE__).'vendor/autoload.php');
123 123
 
124 124
 		// register plugin namespace with autoloader
125
-		$loader->addPsr4( 'WP_PHP_Console\\', __DIR__ . '/includes' );
125
+		$loader->addPsr4('WP_PHP_Console\\', __DIR__.'/includes');
126 126
 
127
-		require_once plugin_dir_path( __FILE__ ) . 'includes/Functions.php';
127
+		require_once plugin_dir_path(__FILE__).'includes/Functions.php';
128 128
 
129 129
 		wp_php_console();
130 130
 	}
@@ -141,11 +141,11 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	public function activation_check() {
143 143
 
144
-		if ( ! $this->is_environment_compatible() ) {
144
+		if ( ! $this->is_environment_compatible()) {
145 145
 
146 146
 			$this->deactivate_plugin();
147 147
 
148
-			wp_die( self::PLUGIN_NAME . ' could not be activated. ' . $this->get_environment_message() );
148
+			wp_die(self::PLUGIN_NAME.' could not be activated. '.$this->get_environment_message());
149 149
 		}
150 150
 	}
151 151
 
@@ -159,11 +159,11 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	public function check_environment() {
161 161
 
162
-		if ( ! $this->is_environment_compatible() && is_plugin_active( plugin_basename( __FILE__ ) ) ) {
162
+		if ( ! $this->is_environment_compatible() && is_plugin_active(plugin_basename(__FILE__))) {
163 163
 
164 164
 			$this->deactivate_plugin();
165 165
 
166
-			$this->add_admin_notice( 'bad_environment', 'error', self::PLUGIN_NAME . ' has been deactivated. ' . $this->get_environment_message() );
166
+			$this->add_admin_notice('bad_environment', 'error', self::PLUGIN_NAME.' has been deactivated. '.$this->get_environment_message());
167 167
 		}
168 168
 	}
169 169
 
@@ -177,14 +177,14 @@  discard block
 block discarded – undo
177 177
 	 */
178 178
 	public function add_plugin_notices() {
179 179
 
180
-		if ( ! $this->is_wp_compatible() ) {
180
+		if ( ! $this->is_wp_compatible()) {
181 181
 
182
-			$this->add_admin_notice( 'update_wordpress', 'error', sprintf(
182
+			$this->add_admin_notice('update_wordpress', 'error', sprintf(
183 183
 				'%s requires WordPress version %s or higher. Please %supdate WordPress &raquo;%s',
184
-				'<strong>' . self::PLUGIN_NAME . '</strong>',
184
+				'<strong>'.self::PLUGIN_NAME.'</strong>',
185 185
 				self::MINIMUM_WP_VERSION,
186
-				'<a href="' . esc_url( admin_url( 'update-core.php' ) ) . '">', '</a>'
187
-			) );
186
+				'<a href="'.esc_url(admin_url('update-core.php')).'">', '</a>'
187
+			));
188 188
 		}
189 189
 	}
190 190
 
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	private function is_wp_compatible() {
200 200
 		global $wp_version;
201 201
 
202
-		return version_compare( $wp_version, self::MINIMUM_WP_VERSION, '>=' );
202
+		return version_compare($wp_version, self::MINIMUM_WP_VERSION, '>=');
203 203
 	}
204 204
 
205 205
 
@@ -210,10 +210,10 @@  discard block
 block discarded – undo
210 210
 	 */
211 211
 	private function deactivate_plugin() {
212 212
 
213
-		deactivate_plugins( plugin_basename( __FILE__ ) );
213
+		deactivate_plugins(plugin_basename(__FILE__));
214 214
 
215
-		if ( isset( $_GET['activate'] ) ) {
216
-			unset( $_GET['activate'] );
215
+		if (isset($_GET['activate'])) {
216
+			unset($_GET['activate']);
217 217
 		}
218 218
 	}
219 219
 
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
 	 * @param string $class CSS class
228 228
 	 * @param string $message message content
229 229
 	 */
230
-	private function add_admin_notice( $slug, $class, $message ) {
230
+	private function add_admin_notice($slug, $class, $message) {
231 231
 
232
-		$this->notices[ $slug ] = array(
232
+		$this->notices[$slug] = array(
233 233
 			'class'   => $class,
234 234
 			'message' => $message
235 235
 		);
@@ -245,11 +245,11 @@  discard block
 block discarded – undo
245 245
 	 */
246 246
 	public function admin_notices() {
247 247
 
248
-		foreach ( (array) $this->notices as $notice_key => $notice ) :
248
+		foreach ((array) $this->notices as $notice_key => $notice) :
249 249
 
250 250
 			?>
251
-			<div class="<?php echo esc_attr( $notice['class'] ); ?>">
252
-				<p><?php echo wp_kses( $notice['message'], array( 'a' => array( 'href' => array() ) ) ); ?></p>
251
+			<div class="<?php echo esc_attr($notice['class']); ?>">
252
+				<p><?php echo wp_kses($notice['message'], array('a' => array('href' => array()))); ?></p>
253 253
 			</div>
254 254
 			<?php
255 255
 
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	 */
267 267
 	private function is_environment_compatible() {
268 268
 
269
-		return version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '>=' );
269
+		return version_compare(PHP_VERSION, self::MINIMUM_PHP_VERSION, '>=');
270 270
 	}
271 271
 
272 272
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 */
280 280
 	private function get_environment_message() {
281 281
 
282
-		return sprintf( 'The minimum PHP version required for this plugin is %1$s. You are running %2$s.', self::MINIMUM_PHP_VERSION, PHP_VERSION );
282
+		return sprintf('The minimum PHP version required for this plugin is %1$s. You are running %2$s.', self::MINIMUM_PHP_VERSION, PHP_VERSION);
283 283
 	}
284 284
 
285 285
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 	 */
295 295
 	public static function instance() {
296 296
 
297
-		if ( null === self::$instance ) {
297
+		if (null === self::$instance) {
298 298
 			self::$instance = new self();
299 299
 		}
300 300
 
Please login to merge, or discard this patch.