@@ -18,7 +18,7 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class WpunitTester extends \Codeception\Actor |
| 20 | 20 | { |
| 21 | - use _generated\WpunitTesterActions; |
|
| 21 | + use _generated\WpunitTesterActions; |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * Define custom actions here |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class UnitTester extends \Codeception\Actor |
| 20 | 20 | { |
| 21 | - use _generated\UnitTesterActions; |
|
| 21 | + use _generated\UnitTesterActions; |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * Define custom actions here |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class AcceptanceTester extends \Codeception\Actor |
| 20 | 20 | { |
| 21 | - use _generated\AcceptanceTesterActions; |
|
| 21 | + use _generated\AcceptanceTesterActions; |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * Define custom actions here |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class FunctionalTester extends \Codeception\Actor |
| 20 | 20 | { |
| 21 | - use _generated\FunctionalTesterActions; |
|
| 21 | + use _generated\FunctionalTesterActions; |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * Define custom actions here |
@@ -1,23 +1,23 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class AdminTestCest { |
|
| 3 | +class AdminTestCest { |
|
| 4 | 4 | |
| 5 | 5 | |
| 6 | - public function TestPluginActivationDeactivation( AcceptanceTester $I ) { |
|
| 6 | + public function TestPluginActivationDeactivation(AcceptanceTester $I) { |
|
| 7 | 7 | |
| 8 | - $I->wantTo( 'See if WP PHP Console is listed in the Plugins page.' ); |
|
| 8 | + $I->wantTo('See if WP PHP Console is listed in the Plugins page.'); |
|
| 9 | 9 | |
| 10 | 10 | $I->loginAsAdmin(); |
| 11 | 11 | $I->amOnPluginsPage(); |
| 12 | 12 | |
| 13 | - $I->seePluginInstalled( 'wp-php-console' ); |
|
| 13 | + $I->seePluginInstalled('wp-php-console'); |
|
| 14 | 14 | |
| 15 | - $I->wantTo( 'Deactivate and reactivate WP PHP Console.' ); |
|
| 15 | + $I->wantTo('Deactivate and reactivate WP PHP Console.'); |
|
| 16 | 16 | |
| 17 | - $I->deactivatePlugin( 'wp-php-console' ); |
|
| 18 | - $I->seePluginDeactivated( 'wp-php-console' ); |
|
| 19 | - $I->activatePlugin( 'wp-php-console' ); |
|
| 20 | - $I->seePluginActivated( 'wp-php-console' ); |
|
| 17 | + $I->deactivatePlugin('wp-php-console'); |
|
| 18 | + $I->seePluginDeactivated('wp-php-console'); |
|
| 19 | + $I->activatePlugin('wp-php-console'); |
|
| 20 | + $I->seePluginActivated('wp-php-console'); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! defined( 'ABSPATH' ) || ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
| 3 | +if ( ! defined('ABSPATH') || ! defined('WP_UNINSTALL_PLUGIN')) { |
|
| 4 | 4 | exit; |
| 5 | 5 | } |
| 6 | 6 | |
| 7 | -delete_option( 'wp_php_console' ); |
|
| 7 | +delete_option('wp_php_console'); |
|
@@ -2,7 +2,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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($var, $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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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($var, $tag)</code>', |
| 258 | 258 | '<code>PC::magic_tag($var)</code>', |
| 259 | 259 | '<code>$var</code>' |
@@ -272,9 +272,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -37,13 +37,13 @@ discard block |
||
| 37 | 37 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 38 | 38 | */ |
| 39 | 39 | |
| 40 | -defined( 'ABSPATH' ) or exit; |
|
| 40 | +defined('ABSPATH') or exit; |
|
| 41 | 41 | |
| 42 | 42 | // composer fallback for PHP < 5.3.0 |
| 43 | -if ( -1 === version_compare( PHP_VERSION, '5.3.0' ) ) { |
|
| 44 | - require_once dirname( __FILE__ ) . '/vendor/autoload_52.php'; |
|
| 43 | +if ( -1 === version_compare(PHP_VERSION, '5.3.0') ) { |
|
| 44 | + require_once dirname(__FILE__).'/vendor/autoload_52.php'; |
|
| 45 | 45 | } else { |
| 46 | - require_once dirname( __FILE__ ) . '/vendor/autoload.php'; |
|
| 46 | + require_once dirname(__FILE__).'/vendor/autoload.php'; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -56,18 +56,18 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | $this_plugin_checks = new WP_Requirements( |
| 58 | 58 | 'WP PHP Console', |
| 59 | - plugin_basename( __FILE__ ), |
|
| 59 | + plugin_basename(__FILE__), |
|
| 60 | 60 | array( |
| 61 | 61 | 'PHP' => '5.6.0', |
| 62 | 62 | ) |
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | -if ( false === $this_plugin_checks->pass() ) { |
|
| 65 | +if (false === $this_plugin_checks->pass()) { |
|
| 66 | 66 | // Stop. |
| 67 | 67 | $this_plugin_checks->halt(); |
| 68 | 68 | return; |
| 69 | 69 | } else { |
| 70 | 70 | // Load the main class of this plugin. |
| 71 | - require_once dirname( __FILE__ ) . '/includes/class-wp-php-console.php'; |
|
| 71 | + require_once dirname(__FILE__).'/includes/class-wp-php-console.php'; |
|
| 72 | 72 | return new \WP_PHP_Console\Plugin(); |
| 73 | 73 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use PhpConsole; |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) or exit; |
|
| 7 | +defined('ABSPATH') or exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * WP PHP Console main class. |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | public function __construct() { |
| 37 | 37 | |
| 38 | 38 | // handle translations |
| 39 | - add_action( 'plugins_loaded', [ $this, 'set_locale' ] ); |
|
| 39 | + add_action('plugins_loaded', [$this, 'set_locale']); |
|
| 40 | 40 | |
| 41 | 41 | // set options |
| 42 | 42 | $this->options = $this->get_options(); |
@@ -45,14 +45,14 @@ discard block |
||
| 45 | 45 | $this->set_admin(); |
| 46 | 46 | |
| 47 | 47 | // bail out if PHP Console can't be found |
| 48 | - if ( ! class_exists( 'PhpConsole\Connector' ) ) { |
|
| 48 | + if ( ! class_exists('PhpConsole\Connector')) { |
|
| 49 | 49 | return; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // connect to PHP Console |
| 53 | - add_action( 'init', [ $this, 'connect' ], -1000 ); |
|
| 53 | + add_action('init', [$this, 'connect'], -1000); |
|
| 54 | 54 | // delay further PHP Console initialisation to have more context during Remote PHP execution |
| 55 | - add_action( 'wp_loaded', [ $this, 'init' ], -1000 ); |
|
| 55 | + add_action('wp_loaded', [$this, 'init'], -1000); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | load_plugin_textdomain( |
| 67 | 67 | 'wp-php-console', |
| 68 | 68 | false, |
| 69 | - dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' |
|
| 69 | + dirname(dirname(plugin_basename(__FILE__))).'/languages/' |
|
| 70 | 70 | ); |
| 71 | 71 | } |
| 72 | 72 | |
@@ -78,20 +78,20 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | private function set_admin() { |
| 80 | 80 | |
| 81 | - if ( ! defined( 'DOING_AJAX' ) && is_admin() ) { |
|
| 81 | + if ( ! defined('DOING_AJAX') && is_admin()) { |
|
| 82 | 82 | |
| 83 | 83 | // add a settings link to the plugins admin screen |
| 84 | - $plugin_name = str_replace( 'includes/class-', '', plugin_basename( __FILE__ ) ); |
|
| 85 | - add_filter( "plugin_action_links_{$plugin_name}", static function( $actions ) { |
|
| 86 | - return array_merge( [ |
|
| 87 | - '<a href="' . esc_url( admin_url( 'options-general.php?page=wp-php-console' ) ) . '">' . __( 'Settings', 'wp-php-console' ) . '</a>', |
|
| 88 | - ], $actions ); |
|
| 84 | + $plugin_name = str_replace('includes/class-', '', plugin_basename(__FILE__)); |
|
| 85 | + add_filter("plugin_action_links_{$plugin_name}", static function($actions) { |
|
| 86 | + return array_merge([ |
|
| 87 | + '<a href="'.esc_url(admin_url('options-general.php?page=wp-php-console')).'">'.__('Settings', 'wp-php-console').'</a>', |
|
| 88 | + ], $actions); |
|
| 89 | 89 | } ); |
| 90 | 90 | |
| 91 | 91 | // init settings |
| 92 | - require_once __DIR__ . '/class-wp-php-console-settings.php'; |
|
| 92 | + require_once __DIR__.'/class-wp-php-console-settings.php'; |
|
| 93 | 93 | |
| 94 | - new Settings( $this->options ); |
|
| 94 | + new Settings($this->options); |
|
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
@@ -107,14 +107,14 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function connect() { |
| 109 | 109 | |
| 110 | - if ( ! @session_id() ) { |
|
| 110 | + if ( ! @session_id()) { |
|
| 111 | 111 | @session_start(); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if ( ! $this->connector instanceof PhpConsole\Connector ) { |
|
| 114 | + if ( ! $this->connector instanceof PhpConsole\Connector) { |
|
| 115 | 115 | try { |
| 116 | 116 | $this->connector = PhpConsole\Connector::getInstance(); |
| 117 | - } catch ( \Exception $e ) { |
|
| 117 | + } catch (\Exception $e) { |
|
| 118 | 118 | return; |
| 119 | 119 | } |
| 120 | 120 | } |
@@ -133,16 +133,16 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | protected function get_options() { |
| 135 | 135 | |
| 136 | - $options = get_option( 'wp_php_console', [] ); |
|
| 136 | + $options = get_option('wp_php_console', []); |
|
| 137 | 137 | |
| 138 | - return wp_parse_args( $options, [ |
|
| 138 | + return wp_parse_args($options, [ |
|
| 139 | 139 | 'ip' => '', |
| 140 | 140 | 'password' => '', |
| 141 | 141 | 'register' => false, |
| 142 | 142 | 'short' => false, |
| 143 | 143 | 'ssl' => false, |
| 144 | 144 | 'stack' => false, |
| 145 | - ] ); |
|
| 145 | + ]); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | |
@@ -154,31 +154,31 @@ discard block |
||
| 154 | 154 | private function apply_options() { |
| 155 | 155 | |
| 156 | 156 | // bail out if not connected yet to PHP Console |
| 157 | - if ( ! $this->connector instanceof PhpConsole\Connector ) { |
|
| 157 | + if ( ! $this->connector instanceof PhpConsole\Connector) { |
|
| 158 | 158 | return; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | // apply 'register' option to PHP Console... |
| 162 | - if ( true === $this->options['register'] && ! class_exists( 'PC', false ) ) { |
|
| 162 | + if (true === $this->options['register'] && ! class_exists('PC', false)) { |
|
| 163 | 163 | // ...only if PC not registered yet |
| 164 | 164 | try { |
| 165 | 165 | PhpConsole\Helper::register(); |
| 166 | - } catch( \Exception $e ) { |
|
| 167 | - $this->print_notice_exception( $e ); |
|
| 166 | + } catch (\Exception $e) { |
|
| 167 | + $this->print_notice_exception($e); |
|
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | // apply 'stack' option to PHP Console |
| 172 | - if ( true === $this->options['stack'] ) { |
|
| 172 | + if (true === $this->options['stack']) { |
|
| 173 | 173 | $this->connector->getDebugDispatcher()->detectTraceAndSource = true; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | // apply 'short' option to PHP Console |
| 177 | - if ( true === $this->options['short'] ) { |
|
| 177 | + if (true === $this->options['short']) { |
|
| 178 | 178 | try { |
| 179 | - $this->connector->setSourcesBasePath( $_SERVER['DOCUMENT_ROOT'] ); |
|
| 180 | - } catch ( \Exception $e ) { |
|
| 181 | - $this->print_notice_exception( $e ); |
|
| 179 | + $this->connector->setSourcesBasePath($_SERVER['DOCUMENT_ROOT']); |
|
| 180 | + } catch (\Exception $e) { |
|
| 181 | + $this->print_notice_exception($e); |
|
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | } |
@@ -194,89 +194,89 @@ discard block |
||
| 194 | 194 | public function init() { |
| 195 | 195 | |
| 196 | 196 | // get PHP Console extension password |
| 197 | - $password = trim( $this->options['password'] ); |
|
| 197 | + $password = trim($this->options['password']); |
|
| 198 | 198 | |
| 199 | - if ( empty( $password ) ) { |
|
| 199 | + if (empty($password)) { |
|
| 200 | 200 | |
| 201 | 201 | // display admin notice and abort if no password has been set |
| 202 | - add_action( 'admin_notices', [ $this, 'password_notice' ] ); |
|
| 202 | + add_action('admin_notices', [$this, 'password_notice']); |
|
| 203 | 203 | return; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | // selectively remove slashes added by WordPress as expected by PHP Console |
| 207 | - if ( array_key_exists( PhpConsole\Connector::POST_VAR_NAME, $_POST ) ) { |
|
| 208 | - $_POST[ PhpConsole\Connector::POST_VAR_NAME ] = stripslashes_deep( $_POST[ PhpConsole\Connector::POST_VAR_NAME ] ); |
|
| 207 | + if (array_key_exists(PhpConsole\Connector::POST_VAR_NAME, $_POST)) { |
|
| 208 | + $_POST[PhpConsole\Connector::POST_VAR_NAME] = stripslashes_deep($_POST[PhpConsole\Connector::POST_VAR_NAME]); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | // get PHP Console instance if wasn't set yet |
| 212 | - if ( ! $this->connector instanceof PhpConsole\Connector ) { |
|
| 212 | + if ( ! $this->connector instanceof PhpConsole\Connector) { |
|
| 213 | 213 | |
| 214 | 214 | try { |
| 215 | 215 | $this->connector = PhpConsole\Connector::getInstance(); |
| 216 | - } catch ( \Exception $e ) { |
|
| 216 | + } catch (\Exception $e) { |
|
| 217 | 217 | return; |
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | // set PHP Console password |
| 222 | 222 | try { |
| 223 | - $this->connector->setPassword( $password ); |
|
| 224 | - } catch ( \Exception $e ) { |
|
| 225 | - $this->print_notice_exception( $e ); |
|
| 223 | + $this->connector->setPassword($password); |
|
| 224 | + } catch (\Exception $e) { |
|
| 225 | + $this->print_notice_exception($e); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | // get PHP Console handler instance |
| 229 | 229 | $handler = PhpConsole\Handler::getInstance(); |
| 230 | 230 | |
| 231 | - if ( true !== PhpConsole\Handler::getInstance()->isStarted() ) { |
|
| 231 | + if (true !== PhpConsole\Handler::getInstance()->isStarted()) { |
|
| 232 | 232 | try { |
| 233 | 233 | $handler->start(); |
| 234 | - } catch( \Exception $e ) { |
|
| 235 | - $this->print_notice_exception( $e ); |
|
| 234 | + } catch (\Exception $e) { |
|
| 235 | + $this->print_notice_exception($e); |
|
| 236 | 236 | return; |
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | // enable SSL-only mode |
| 241 | - if ( true === $this->options['ssl'] ) { |
|
| 241 | + if (true === $this->options['ssl']) { |
|
| 242 | 242 | $this->connector->enableSslOnlyMode(); |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | // restrict IP addresses |
| 246 | - $allowedIpMasks = ! empty( $this->options['ip'] ) ? explode( ',', $this->options['ip'] ) : ''; |
|
| 246 | + $allowedIpMasks = ! empty($this->options['ip']) ? explode(',', $this->options['ip']) : ''; |
|
| 247 | 247 | |
| 248 | - if ( is_array( $allowedIpMasks ) && count( $allowedIpMasks ) > 0 ) { |
|
| 249 | - $this->connector->setAllowedIpMasks( $allowedIpMasks ); |
|
| 248 | + if (is_array($allowedIpMasks) && count($allowedIpMasks) > 0) { |
|
| 249 | + $this->connector->setAllowedIpMasks($allowedIpMasks); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | $evalProvider = $this->connector->getEvalDispatcher()->getEvalProvider(); |
| 253 | 253 | |
| 254 | 254 | try { |
| 255 | - $evalProvider->addSharedVar( 'uri', $_SERVER['REQUEST_URI'] ); |
|
| 256 | - } catch ( \Exception $e ) { |
|
| 257 | - $this->print_notice_exception( $e ); |
|
| 255 | + $evalProvider->addSharedVar('uri', $_SERVER['REQUEST_URI']); |
|
| 256 | + } catch (\Exception $e) { |
|
| 257 | + $this->print_notice_exception($e); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | try { |
| 261 | - $evalProvider->addSharedVarReference( 'post', $_POST ); |
|
| 262 | - } catch ( \Exception $e ) { |
|
| 263 | - $this->print_notice_exception( $e ); |
|
| 261 | + $evalProvider->addSharedVarReference('post', $_POST); |
|
| 262 | + } catch (\Exception $e) { |
|
| 263 | + $this->print_notice_exception($e); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - $openBaseDirs = [ ABSPATH, get_template_directory() ]; |
|
| 266 | + $openBaseDirs = [ABSPATH, get_template_directory()]; |
|
| 267 | 267 | |
| 268 | 268 | try { |
| 269 | - $evalProvider->addSharedVarReference( 'dirs', $openBaseDirs ); |
|
| 270 | - } catch ( \Exception $e ) { |
|
| 271 | - $this->print_notice_exception( $e ); |
|
| 269 | + $evalProvider->addSharedVarReference('dirs', $openBaseDirs); |
|
| 270 | + } catch (\Exception $e) { |
|
| 271 | + $this->print_notice_exception($e); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - $evalProvider->setOpenBaseDirs( $openBaseDirs ); |
|
| 274 | + $evalProvider->setOpenBaseDirs($openBaseDirs); |
|
| 275 | 275 | |
| 276 | 276 | try { |
| 277 | 277 | $this->connector->startEvalRequestsListener(); |
| 278 | - } catch ( \Exception $e ) { |
|
| 279 | - $this->print_notice_exception( $e ); |
|
| 278 | + } catch (\Exception $e) { |
|
| 279 | + $this->print_notice_exception($e); |
|
| 280 | 280 | } |
| 281 | 281 | } |
| 282 | 282 | |
@@ -288,13 +288,13 @@ discard block |
||
| 288 | 288 | * |
| 289 | 289 | * @param \Exception $e Exception object |
| 290 | 290 | */ |
| 291 | - public function print_notice_exception( \Exception $e ) { |
|
| 291 | + public function print_notice_exception(\Exception $e) { |
|
| 292 | 292 | |
| 293 | - add_action( 'admin_notices', static function() use ( $e ) { |
|
| 293 | + add_action('admin_notices', static function() use ($e) { |
|
| 294 | 294 | |
| 295 | 295 | ?> |
| 296 | 296 | <div class="error"> |
| 297 | - <p><?php printf( '%1$s: %2$s', self::NAME, $e->getMessage() ); ?></p> |
|
| 297 | + <p><?php printf('%1$s: %2$s', self::NAME, $e->getMessage()); ?></p> |
|
| 298 | 298 | </div> |
| 299 | 299 | <?php |
| 300 | 300 | |
@@ -318,9 +318,9 @@ discard block |
||
| 318 | 318 | <div class="update-nag"> |
| 319 | 319 | <p><?php printf( |
| 320 | 320 | /* translators: Placeholders: %1$s - WP Php Console name, %2$s - opening HTML <a> link tag; %3$s closing HTML </a> link tag */ |
| 321 | - __( '%1$s: Please remember to %2$sset a password%3$s if you want to enable the terminal.', 'wp-php-console' ), |
|
| 322 | - '<strong>' . self::NAME . '</strong>', |
|
| 323 | - '<a href="' . esc_url( admin_url( 'options-general.php?page=wp-php-console' ) ) .'">', |
|
| 321 | + __('%1$s: Please remember to %2$sset a password%3$s if you want to enable the terminal.', 'wp-php-console'), |
|
| 322 | + '<strong>'.self::NAME.'</strong>', |
|
| 323 | + '<a href="'.esc_url(admin_url('options-general.php?page=wp-php-console')).'">', |
|
| 324 | 324 | '</a>' |
| 325 | 325 | ); ?></p> |
| 326 | 326 | </div> |