@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * Domain Path: /languages |
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | -defined( 'ABSPATH' ) or exit; |
|
| 19 | +defined('ABSPATH') or exit; |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * WP PHP Console |
@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | |
| 44 | 44 | // Composer fallback for PHP < 5.3.0. |
| 45 | -if ( -1 === version_compare( PHP_VERSION, '5.3.0' ) ) { |
|
| 46 | - require_once dirname( __FILE__ ) . '/vendor/autoload_52.php'; |
|
| 45 | +if ( -1 === version_compare(PHP_VERSION, '5.3.0') ) { |
|
| 46 | + require_once dirname(__FILE__).'/vendor/autoload_52.php'; |
|
| 47 | 47 | } else { |
| 48 | - require_once dirname( __FILE__ ) . '/vendor/autoload.php'; |
|
| 48 | + require_once dirname(__FILE__).'/vendor/autoload.php'; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -55,18 +55,18 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | $this_plugin_checks = new WP_Requirements( |
| 57 | 57 | 'WP PHP Console', |
| 58 | - plugin_basename( __FILE__ ), |
|
| 58 | + plugin_basename(__FILE__), |
|
| 59 | 59 | array( |
| 60 | 60 | 'PHP' => '5.4.0', |
| 61 | 61 | ) |
| 62 | 62 | ); |
| 63 | 63 | |
| 64 | -if ( false === $this_plugin_checks->pass() ) { |
|
| 64 | +if (false === $this_plugin_checks->pass()) { |
|
| 65 | 65 | // Stop. |
| 66 | 66 | $this_plugin_checks->halt(); |
| 67 | 67 | return; |
| 68 | 68 | } else { |
| 69 | 69 | // Load the main class of this plugin. |
| 70 | - require_once dirname( __FILE__ ) . '/includes/class-wp-php-console.php'; |
|
| 70 | + require_once dirname(__FILE__).'/includes/class-wp-php-console.php'; |
|
| 71 | 71 | return new \WP_PHP_Console\Plugin(); |
| 72 | 72 | } |
@@ -137,7 +137,7 @@ |
||
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | } |
| 140 | - **/ |
|
| 140 | + **/ |
|
| 141 | 141 | |
| 142 | 142 | // Perform PHP Console initialisation required asap for other code to be able to output to the JavaScript console. |
| 143 | 143 | if ( ! $this->connector instanceof PhpConsole\Connector ) { |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | use PhpConsole; |
| 12 | 12 | |
| 13 | -defined( 'ABSPATH' ) or exit; |
|
| 13 | +defined('ABSPATH') or exit; |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * WP PHP Console main class. |
@@ -64,19 +64,19 @@ discard block |
||
| 64 | 64 | public function __construct() { |
| 65 | 65 | |
| 66 | 66 | // Translations. |
| 67 | - add_action( 'plugins_loaded', array( $this, 'set_locale' ) ); |
|
| 67 | + add_action('plugins_loaded', array($this, 'set_locale')); |
|
| 68 | 68 | |
| 69 | 69 | // Set options. |
| 70 | 70 | $this->options = $this->get_options(); |
| 71 | 71 | |
| 72 | 72 | // Load admin. |
| 73 | - if ( ! defined( 'DOING_AJAX' ) && is_admin() ) { |
|
| 74 | - require_once __DIR__ . '/class-wp-php-console-settings.php'; |
|
| 75 | - new Settings( $this->options ); |
|
| 73 | + if ( ! defined('DOING_AJAX') && is_admin()) { |
|
| 74 | + require_once __DIR__.'/class-wp-php-console-settings.php'; |
|
| 75 | + new Settings($this->options); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | // Bail out if PHP Console can't be found. |
| 79 | - if ( ! class_exists( 'PhpConsole\Connector' ) ) { |
|
| 79 | + if ( ! class_exists('PhpConsole\Connector')) { |
|
| 80 | 80 | return; |
| 81 | 81 | } |
| 82 | 82 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | $this->apply_options(); |
| 88 | 88 | |
| 89 | 89 | // Delay further PHP Console initialisation to have more context during Remote PHP execution. |
| 90 | - add_action( 'wp_loaded', array( $this, 'init' ) ); |
|
| 90 | + add_action('wp_loaded', array($this, 'init')); |
|
| 91 | 91 | |
| 92 | 92 | } |
| 93 | 93 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | load_plugin_textdomain( |
| 103 | 103 | 'wp-php-console', |
| 104 | 104 | false, |
| 105 | - dirname( plugin_basename( __FILE__ ) ) . '/languages/' |
|
| 105 | + dirname(plugin_basename(__FILE__)).'/languages/' |
|
| 106 | 106 | ); |
| 107 | 107 | |
| 108 | 108 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | **/ |
| 141 | 141 | |
| 142 | 142 | // Perform PHP Console initialisation required asap for other code to be able to output to the JavaScript console. |
| 143 | - if ( ! $this->connector instanceof PhpConsole\Connector ) { |
|
| 143 | + if ( ! $this->connector instanceof PhpConsole\Connector) { |
|
| 144 | 144 | $this->connector = PhpConsole\Connector::getInstance(); |
| 145 | 145 | } |
| 146 | 146 | |
@@ -155,16 +155,16 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | protected function get_options() { |
| 157 | 157 | |
| 158 | - $options = get_option( 'wp_php_console', array() ); |
|
| 158 | + $options = get_option('wp_php_console', array()); |
|
| 159 | 159 | |
| 160 | - return wp_parse_args( $options, array( |
|
| 160 | + return wp_parse_args($options, array( |
|
| 161 | 161 | 'ip' => '', |
| 162 | 162 | 'password' => '', |
| 163 | 163 | 'register' => false, |
| 164 | 164 | 'short' => false, |
| 165 | 165 | 'ssl' => false, |
| 166 | 166 | 'stack' => false, |
| 167 | - ) ); |
|
| 167 | + )); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | |
@@ -176,31 +176,31 @@ discard block |
||
| 176 | 176 | private function apply_options() { |
| 177 | 177 | |
| 178 | 178 | // Bail out if not connected yet to PHP Console. |
| 179 | - if ( ! $this->connector instanceof PhpConsole\Connector ) { |
|
| 179 | + if ( ! $this->connector instanceof PhpConsole\Connector) { |
|
| 180 | 180 | return; |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | // Apply 'register' option to PHP Console |
| 184 | - if ( true === $this->options['register'] && ! class_exists( 'PC', false ) ) { |
|
| 184 | + if (true === $this->options['register'] && ! class_exists('PC', false)) { |
|
| 185 | 185 | // Only if PC not registered yet |
| 186 | 186 | try { |
| 187 | 187 | PhpConsole\Helper::register(); |
| 188 | - } catch( \Exception $e ) { |
|
| 189 | - $this->print_notice_exception( $e ); |
|
| 188 | + } catch (\Exception $e) { |
|
| 189 | + $this->print_notice_exception($e); |
|
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | // Apply 'stack' option to PHP Console |
| 194 | - if ( true === $this->options['stack'] ) { |
|
| 194 | + if (true === $this->options['stack']) { |
|
| 195 | 195 | $this->connector->getDebugDispatcher()->detectTraceAndSource = true; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | // Apply 'short' option to PHP Console |
| 199 | - if ( true === $this->options['short'] ) { |
|
| 199 | + if (true === $this->options['short']) { |
|
| 200 | 200 | try { |
| 201 | - $this->connector->setSourcesBasePath( $_SERVER['DOCUMENT_ROOT'] ); |
|
| 202 | - } catch ( \Exception $e ) { |
|
| 203 | - $this->print_notice_exception( $e ); |
|
| 201 | + $this->connector->setSourcesBasePath($_SERVER['DOCUMENT_ROOT']); |
|
| 202 | + } catch (\Exception $e) { |
|
| 203 | + $this->print_notice_exception($e); |
|
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | |
@@ -217,78 +217,78 @@ discard block |
||
| 217 | 217 | // Set PHP Console extension password. |
| 218 | 218 | $password = $this->options['password']; |
| 219 | 219 | |
| 220 | - if ( ! $password ) { |
|
| 220 | + if ( ! $password) { |
|
| 221 | 221 | // Display admin notice and abort if no password has been set. |
| 222 | - add_action( 'admin_notices', array( $this, 'password_notice' ) ); |
|
| 222 | + add_action('admin_notices', array($this, 'password_notice')); |
|
| 223 | 223 | return; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | // Selectively remove slashes added by WordPress as expected by PhpConsole. |
| 227 | - if ( array_key_exists( PhpConsole\Connector::POST_VAR_NAME, $_POST ) ) { |
|
| 228 | - $_POST[ PhpConsole\Connector::POST_VAR_NAME ] = stripslashes_deep( $_POST[ PhpConsole\Connector::POST_VAR_NAME ] ); |
|
| 227 | + if (array_key_exists(PhpConsole\Connector::POST_VAR_NAME, $_POST)) { |
|
| 228 | + $_POST[PhpConsole\Connector::POST_VAR_NAME] = stripslashes_deep($_POST[PhpConsole\Connector::POST_VAR_NAME]); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - if ( ! $this->connector instanceof PhpConsole\Connector ) { |
|
| 231 | + if ( ! $this->connector instanceof PhpConsole\Connector) { |
|
| 232 | 232 | $this->connector = PhpConsole\Connector::getInstance(); |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | try { |
| 236 | - $this->connector->setPassword( $password ); |
|
| 237 | - } catch ( \Exception $e ) { |
|
| 238 | - $this->print_notice_exception( $e ); |
|
| 236 | + $this->connector->setPassword($password); |
|
| 237 | + } catch (\Exception $e) { |
|
| 238 | + $this->print_notice_exception($e); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | // PhpConsole instance. |
| 242 | 242 | $handler = PhpConsole\Handler::getInstance(); |
| 243 | 243 | |
| 244 | - if ( true !== PhpConsole\Handler::getInstance()->isStarted() ) { |
|
| 244 | + if (true !== PhpConsole\Handler::getInstance()->isStarted()) { |
|
| 245 | 245 | try { |
| 246 | 246 | $handler->start(); |
| 247 | - } catch( \Exception $e ) { |
|
| 248 | - $this->print_notice_exception( $e ); |
|
| 247 | + } catch (\Exception $e) { |
|
| 248 | + $this->print_notice_exception($e); |
|
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | // Enable SSL-only mode. |
| 253 | - if ( true === $this->options['ssl'] ) { |
|
| 253 | + if (true === $this->options['ssl']) { |
|
| 254 | 254 | $this->connector->enableSslOnlyMode(); |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | // Restrict IP addresses. |
| 258 | - $allowedIpMasks = ! empty( $this->options['ip'] ) ? explode( ',', $this->options['ip'] ) : ''; |
|
| 258 | + $allowedIpMasks = ! empty($this->options['ip']) ? explode(',', $this->options['ip']) : ''; |
|
| 259 | 259 | |
| 260 | - if ( is_array( $allowedIpMasks ) && count( $allowedIpMasks ) > 0 ) { |
|
| 261 | - $this->connector->setAllowedIpMasks( $allowedIpMasks ); |
|
| 260 | + if (is_array($allowedIpMasks) && count($allowedIpMasks) > 0) { |
|
| 261 | + $this->connector->setAllowedIpMasks($allowedIpMasks); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | $evalProvider = $this->connector->getEvalDispatcher()->getEvalProvider(); |
| 265 | 265 | |
| 266 | 266 | try { |
| 267 | - $evalProvider->addSharedVar( 'uri', $_SERVER['REQUEST_URI'] ); |
|
| 268 | - } catch ( \Exception $e ) { |
|
| 269 | - $this->print_notice_exception( $e ); |
|
| 267 | + $evalProvider->addSharedVar('uri', $_SERVER['REQUEST_URI']); |
|
| 268 | + } catch (\Exception $e) { |
|
| 269 | + $this->print_notice_exception($e); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | try { |
| 273 | - $evalProvider->addSharedVarReference( 'post', $_POST ); |
|
| 274 | - } catch ( \Exception $e ) { |
|
| 275 | - $this->print_notice_exception( $e ); |
|
| 273 | + $evalProvider->addSharedVarReference('post', $_POST); |
|
| 274 | + } catch (\Exception $e) { |
|
| 275 | + $this->print_notice_exception($e); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - $openBaseDirs = array( ABSPATH, get_template_directory() ); |
|
| 278 | + $openBaseDirs = array(ABSPATH, get_template_directory()); |
|
| 279 | 279 | |
| 280 | 280 | try { |
| 281 | - $evalProvider->addSharedVarReference( 'dirs', $openBaseDirs ); |
|
| 282 | - } catch ( \Exception $e ) { |
|
| 283 | - $this->print_notice_exception( $e ); |
|
| 281 | + $evalProvider->addSharedVarReference('dirs', $openBaseDirs); |
|
| 282 | + } catch (\Exception $e) { |
|
| 283 | + $this->print_notice_exception($e); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - $evalProvider->setOpenBaseDirs( $openBaseDirs ); |
|
| 286 | + $evalProvider->setOpenBaseDirs($openBaseDirs); |
|
| 287 | 287 | |
| 288 | 288 | try { |
| 289 | 289 | $this->connector->startEvalRequestsListener(); |
| 290 | - } catch ( \Exception $e ) { |
|
| 291 | - $this->print_notice_exception( $e ); |
|
| 290 | + } catch (\Exception $e) { |
|
| 291 | + $this->print_notice_exception($e); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | } |
@@ -300,13 +300,13 @@ discard block |
||
| 300 | 300 | * @since 1.4.0 |
| 301 | 301 | * @param \Exception $e Exception object |
| 302 | 302 | */ |
| 303 | - public function print_notice_exception( \Exception $e ) { |
|
| 303 | + public function print_notice_exception(\Exception $e) { |
|
| 304 | 304 | |
| 305 | - add_action( 'admin_notices', function() use ( $e ) { |
|
| 305 | + add_action('admin_notices', function() use ($e) { |
|
| 306 | 306 | |
| 307 | 307 | ?> |
| 308 | 308 | <div class="error"> |
| 309 | - <p><?php printf( '%1$s: %2$s', self::NAME, $e->getMessage() ); ?></p> |
|
| 309 | + <p><?php printf('%1$s: %2$s', self::NAME, $e->getMessage()); ?></p> |
|
| 310 | 310 | </div> |
| 311 | 311 | <?php |
| 312 | 312 | |
@@ -328,9 +328,9 @@ discard block |
||
| 328 | 328 | <?php |
| 329 | 329 | |
| 330 | 330 | /* translators: Placeholders: %1$s - WP Php Console name, %2$s - opening HTML <a> link tag; %3$s closing HTML </a> link tag */ |
| 331 | - printf( __( '%1$s: Please remember to %2$s set a password %3$s if you want to enable the terminal.', 'wp-php-console' ), |
|
| 332 | - '<strong>' . self::NAME . '</strong>', |
|
| 333 | - '<a href="' . esc_url( admin_url( 'options-general.php?page=wp-php-console' ) ) .'">', |
|
| 331 | + printf(__('%1$s: Please remember to %2$s set a password %3$s if you want to enable the terminal.', 'wp-php-console'), |
|
| 332 | + '<strong>'.self::NAME.'</strong>', |
|
| 333 | + '<a href="'.esc_url(admin_url('options-general.php?page=wp-php-console')).'">', |
|
| 334 | 334 | '</a>' |
| 335 | 335 | ); |
| 336 | 336 | |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | namespace WP_PHP_Console; |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) or exit; |
|
| 11 | +defined('ABSPATH') or exit; |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * WP PHP Console settings class. |
@@ -54,13 +54,13 @@ discard block |
||
| 54 | 54 | * @since 1.5.0 |
| 55 | 55 | * @param array $options Plugin settings options. |
| 56 | 56 | */ |
| 57 | - public function __construct( array $options ) { |
|
| 57 | + public function __construct(array $options) { |
|
| 58 | 58 | |
| 59 | - $this->page = sanitize_title( strtolower( Plugin::NAME ) ); |
|
| 60 | - $this->option = str_replace( '-', '_', $this->page ); |
|
| 59 | + $this->page = sanitize_title(strtolower(Plugin::NAME)); |
|
| 60 | + $this->option = str_replace('-', '_', $this->page); |
|
| 61 | 61 | $this->options = $options; |
| 62 | 62 | |
| 63 | - add_action( 'admin_menu', array( $this, 'register_settings_page' ) ); |
|
| 63 | + add_action('admin_menu', array($this, 'register_settings_page')); |
|
| 64 | 64 | |
| 65 | 65 | } |
| 66 | 66 | |
@@ -73,14 +73,14 @@ discard block |
||
| 73 | 73 | public function register_settings_page() { |
| 74 | 74 | |
| 75 | 75 | add_options_page( |
| 76 | - __( 'WP PHP Console', 'wp-php-console' ), |
|
| 77 | - __( 'WP PHP Console', 'wp-php-console' ), |
|
| 76 | + __('WP PHP Console', 'wp-php-console'), |
|
| 77 | + __('WP PHP Console', 'wp-php-console'), |
|
| 78 | 78 | 'manage_options', |
| 79 | 79 | $this->page, |
| 80 | - array( $this, 'settings_page' ) |
|
| 80 | + array($this, 'settings_page') |
|
| 81 | 81 | ); |
| 82 | 82 | |
| 83 | - add_action( 'admin_init', array( $this, 'register_settings' ) ); |
|
| 83 | + add_action('admin_init', array($this, 'register_settings')); |
|
| 84 | 84 | |
| 85 | 85 | } |
| 86 | 86 | |
@@ -95,46 +95,46 @@ discard block |
||
| 95 | 95 | register_setting( |
| 96 | 96 | $this->option, |
| 97 | 97 | $this->option, |
| 98 | - array( $this, 'sanitize_field' ) |
|
| 98 | + array($this, 'sanitize_field') |
|
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | 101 | add_settings_section( |
| 102 | 102 | $this->option, |
| 103 | - __( 'Settings', 'wp-php-console' ), |
|
| 104 | - array( $this, 'settings_info' ), |
|
| 103 | + __('Settings', 'wp-php-console'), |
|
| 104 | + array($this, 'settings_info'), |
|
| 105 | 105 | $this->page |
| 106 | 106 | ); |
| 107 | 107 | |
| 108 | 108 | $settings_fields = array( |
| 109 | 109 | 'password' => array( |
| 110 | - 'label' => esc_html__( 'Password', 'wp-php-console' ), |
|
| 111 | - 'callback' => array( $this, 'password_field' ), |
|
| 110 | + 'label' => esc_html__('Password', 'wp-php-console'), |
|
| 111 | + 'callback' => array($this, 'password_field'), |
|
| 112 | 112 | ), |
| 113 | 113 | 'ssl' => array( |
| 114 | - 'label' => esc_html__( 'Allow only on SSL', 'wp-php-console' ), |
|
| 115 | - 'callback' => array( $this, 'ssl_field' ), |
|
| 114 | + 'label' => esc_html__('Allow only on SSL', 'wp-php-console'), |
|
| 115 | + 'callback' => array($this, 'ssl_field'), |
|
| 116 | 116 | ), |
| 117 | 117 | 'ip' => array( |
| 118 | - 'label' => esc_html__( 'Allowed IP Masks', 'wp-php-console' ), |
|
| 119 | - 'callback' => array( $this, 'ip_field' ), |
|
| 118 | + 'label' => esc_html__('Allowed IP Masks', 'wp-php-console'), |
|
| 119 | + 'callback' => array($this, 'ip_field'), |
|
| 120 | 120 | ), |
| 121 | 121 | 'register' => array( |
| 122 | - 'label' => esc_html__( 'Register PC Class ', 'wp-php-console' ), |
|
| 123 | - 'callback' => array( $this, 'register_field' ), |
|
| 122 | + 'label' => esc_html__('Register PC Class ', 'wp-php-console'), |
|
| 123 | + 'callback' => array($this, 'register_field'), |
|
| 124 | 124 | ), |
| 125 | 125 | 'stack' => array( |
| 126 | - 'label' => esc_html__( 'Show Call Stack', 'wp-php-console' ), |
|
| 127 | - 'callback' => array( $this, 'stack_field' ), |
|
| 126 | + 'label' => esc_html__('Show Call Stack', 'wp-php-console'), |
|
| 127 | + 'callback' => array($this, 'stack_field'), |
|
| 128 | 128 | ), |
| 129 | 129 | 'short' => array( |
| 130 | - 'label' => esc_html__( 'Short Path Names', 'wp-php-console' ), |
|
| 131 | - 'callback' => array( $this, 'short_field' ), |
|
| 130 | + 'label' => esc_html__('Short Path Names', 'wp-php-console'), |
|
| 131 | + 'callback' => array($this, 'short_field'), |
|
| 132 | 132 | ), |
| 133 | 133 | ); |
| 134 | 134 | |
| 135 | - foreach ( $settings_fields as $key => $field ) { |
|
| 135 | + foreach ($settings_fields as $key => $field) { |
|
| 136 | 136 | add_settings_field( |
| 137 | - $this->page . '['. $key . ']', |
|
| 137 | + $this->page.'['.$key.']', |
|
| 138 | 138 | $field['label'], |
| 139 | 139 | $field['callback'], |
| 140 | 140 | $this->page, |
@@ -156,29 +156,29 @@ discard block |
||
| 156 | 156 | ?> |
| 157 | 157 | <p><?php |
| 158 | 158 | /* translators: %s refers to 'PHP Console' Chrome extension, will print download link for the Chrome extension */ |
| 159 | - printf( _x( 'This plugin allows you to use %s within your WordPress installation for testing, debugging and development purposes.', 'PHP Console, the Chrome Extension', 'wp-php-console' ), '<a href="https://github.com/barbushin/php-console" target="_blank">PHP Console</a>' ); ?> |
|
| 160 | - <br><?php esc_html_e( 'Usage instructions:', 'wp-php-console' ); ?> |
|
| 159 | + printf(_x('This plugin allows you to use %s within your WordPress installation for testing, debugging and development purposes.', 'PHP Console, the Chrome Extension', 'wp-php-console'), '<a href="https://github.com/barbushin/php-console" target="_blank">PHP Console</a>'); ?> |
|
| 160 | + <br><?php esc_html_e('Usage instructions:', 'wp-php-console'); ?> |
|
| 161 | 161 | </p> |
| 162 | 162 | <ol> |
| 163 | 163 | <?php |
| 164 | 164 | |
| 165 | 165 | $instructions = array( |
| 166 | 166 | /* translators: Install PHP Console extension for Google Chrome download link */ |
| 167 | - sprintf( _x( 'Make sure you have downloaded and installed %s.', 'PHP Console, the Chrome Extension', 'wp-php-console' ), |
|
| 167 | + sprintf(_x('Make sure you have downloaded and installed %s.', 'PHP Console, the Chrome Extension', 'wp-php-console'), |
|
| 168 | 168 | '<a target="_blank" href="https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef">PHP Console extension for Google Chrome</a>' |
| 169 | 169 | ), |
| 170 | - esc_html__( 'Set a password for the eval terminal in the options below and hit "Save Changes".', 'wp-php-console' ), |
|
| 171 | - 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' ), |
|
| 172 | - 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' ), |
|
| 170 | + esc_html__('Set a password for the eval terminal in the options below and hit "Save Changes".', 'wp-php-console'), |
|
| 171 | + 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'), |
|
| 172 | + 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'), |
|
| 173 | 173 | /* translators: %1$s - PHP code snippet example, %2$s - Chrome javascript console shortcut */ |
| 174 | - sprintf( __( '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' ), |
|
| 174 | + sprintf(__('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'), |
|
| 175 | 175 | '<code>debug($var, $tag)</code>', |
| 176 | 176 | '<code>CTRL+SHIFT+J</code>' |
| 177 | 177 | ), |
| 178 | 178 | ); |
| 179 | 179 | |
| 180 | - foreach ( $instructions as $list_item ) { |
|
| 181 | - echo '<li>' . $list_item . '</li>'; |
|
| 180 | + foreach ($instructions as $list_item) { |
|
| 181 | + echo '<li>'.$list_item.'</li>'; |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | ?> |
@@ -197,9 +197,9 @@ discard block |
||
| 197 | 197 | public function password_field() { |
| 198 | 198 | |
| 199 | 199 | ?> |
| 200 | - <input type="password" id="wp-php-console-password" name="wp_php_console[password]" value="<?php echo esc_attr( $this->options['password'] ); ?>"> |
|
| 201 | - <label for="wp-php-console-password"><?php esc_html_e( 'Required', 'wp-php-console' ); ?></label><br> |
|
| 202 | - <p class="description"><?php esc_html_e( 'The password for the eval terminal. If empty, the plugin will not work.', 'wp-php-console' ); ?></p> |
|
| 200 | + <input type="password" id="wp-php-console-password" name="wp_php_console[password]" value="<?php echo esc_attr($this->options['password']); ?>"> |
|
| 201 | + <label for="wp-php-console-password"><?php esc_html_e('Required', 'wp-php-console'); ?></label><br> |
|
| 202 | + <p class="description"><?php esc_html_e('The password for the eval terminal. If empty, the plugin will not work.', 'wp-php-console'); ?></p> |
|
| 203 | 203 | <?php |
| 204 | 204 | |
| 205 | 205 | } |
@@ -213,9 +213,9 @@ discard block |
||
| 213 | 213 | public function ssl_field() { |
| 214 | 214 | |
| 215 | 215 | ?> |
| 216 | - <input type="checkbox" id="wp-php-console-ssl" name="wp_php_console[ssl]" value="1" <?php checked( (bool) $this->options['ssl'] ); ?> /> |
|
| 217 | - <label for="wp-php-console-ssl"><?php esc_html_e( 'Yes', 'wp-php-console' ); ?></label><br> |
|
| 218 | - <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> |
|
| 216 | + <input type="checkbox" id="wp-php-console-ssl" name="wp_php_console[ssl]" value="1" <?php checked((bool) $this->options['ssl']); ?> /> |
|
| 217 | + <label for="wp-php-console-ssl"><?php esc_html_e('Yes', 'wp-php-console'); ?></label><br> |
|
| 218 | + <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> |
|
| 219 | 219 | <?php |
| 220 | 220 | |
| 221 | 221 | } |
@@ -229,19 +229,19 @@ discard block |
||
| 229 | 229 | public function ip_field() { |
| 230 | 230 | |
| 231 | 231 | ?> |
| 232 | - <input type="text" class="regular-text" id="wp-php-console-ip" name="wp_php_console[ip]" value="<?php echo esc_attr( $this->options['ip'] ); ?>" /> |
|
| 233 | - <label for="wp-php-console-ip"><?php esc_html_e( 'IP addresses (optional)', 'wp-php-console' ); ?></label><br> |
|
| 234 | - <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> |
|
| 232 | + <input type="text" class="regular-text" id="wp-php-console-ip" name="wp_php_console[ip]" value="<?php echo esc_attr($this->options['ip']); ?>" /> |
|
| 233 | + <label for="wp-php-console-ip"><?php esc_html_e('IP addresses (optional)', 'wp-php-console'); ?></label><br> |
|
| 234 | + <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> |
|
| 235 | 235 | <ol> |
| 236 | 236 | <li><small><?php |
| 237 | 237 | /* translators: Placeholders: %1$s - a single IP address, %2$s link to Varying Vagrant Vagrants repo */ |
| 238 | - printf( __( 'An IP address (for example %1$s, %2$s default IP address).' ), |
|
| 238 | + printf(__('An IP address (for example %1$s, %2$s default IP address).'), |
|
| 239 | 239 | '<code>192.168.50.4</code>', |
| 240 | 240 | '<a href="https://github.com/Varying-Vagrant-Vagrants/VVV">Varying Vagrant Vagrants</a>' |
| 241 | 241 | ); ?></small></li> |
| 242 | 242 | <li><small><?php |
| 243 | 243 | /* translators: Placeholders: %1$s a range of IP addresses, %2$s - comma separated IP addresses */ |
| 244 | - printf( __( 'A range of addresses (%1$s) or multiple addresses, comma separated (%2$s).', 'wp-php-console' ), |
|
| 244 | + printf(__('A range of addresses (%1$s) or multiple addresses, comma separated (%2$s).', 'wp-php-console'), |
|
| 245 | 245 | '<code>192.168.*.*</code>', |
| 246 | 246 | '<code>192.168.10.25,192.168.10.28</code>' |
| 247 | 247 | ); ?></small></li> |
@@ -260,13 +260,13 @@ discard block |
||
| 260 | 260 | public function register_field() { |
| 261 | 261 | |
| 262 | 262 | ?> |
| 263 | - <input type="checkbox" id="wp-php-console-register" name="wp_php_console[register]" value="1" <?php checked( (bool) $this->options['register'] ); ?> /> |
|
| 264 | - <label for="wp-php-console-register"><?php esc_html_e( 'Yes', 'wp-php-console' ); ?></label><br> |
|
| 263 | + <input type="checkbox" id="wp-php-console-register" name="wp_php_console[register]" value="1" <?php checked((bool) $this->options['register']); ?> /> |
|
| 264 | + <label for="wp-php-console-register"><?php esc_html_e('Yes', 'wp-php-console'); ?></label><br> |
|
| 265 | 265 | <p class="description"><?php |
| 266 | - esc_html_e( 'Tick to register PC class in the global namespace.', 'wp-php-console' ); |
|
| 266 | + esc_html_e('Tick to register PC class in the global namespace.', 'wp-php-console'); |
|
| 267 | 267 | echo '<br>'; |
| 268 | 268 | /* translators: Placeholders: PHP code snippets examples */ |
| 269 | - printf( __( 'Allows to write %1$s or %2$s instructions in PHP to inspect %3$s in the JavaScript console.', 'wp-php-console' ), |
|
| 269 | + printf(__('Allows to write %1$s or %2$s instructions in PHP to inspect %3$s in the JavaScript console.', 'wp-php-console'), |
|
| 270 | 270 | '<code>PC::debug($var, $tag)</code>', |
| 271 | 271 | '<code>PC::magic_tag($var)</code>', |
| 272 | 272 | '<code>$var</code>' |
@@ -284,9 +284,9 @@ discard block |
||
| 284 | 284 | public function stack_field() { |
| 285 | 285 | |
| 286 | 286 | ?> |
| 287 | - <input type="checkbox" id="wp-php-console-stack" name="wp_php_console[stack]" value="1" <?php checked( (bool) $this->options['stack'] ); ?> /> |
|
| 288 | - <label for="wp-php-console-stack"><?php esc_html_e( 'Yes', 'wp-php-console' ); ?></label><br /> |
|
| 289 | - <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> |
|
| 287 | + <input type="checkbox" id="wp-php-console-stack" name="wp_php_console[stack]" value="1" <?php checked((bool) $this->options['stack']); ?> /> |
|
| 288 | + <label for="wp-php-console-stack"><?php esc_html_e('Yes', 'wp-php-console'); ?></label><br /> |
|
| 289 | + <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> |
|
| 290 | 290 | <?php |
| 291 | 291 | |
| 292 | 292 | } |
@@ -300,13 +300,13 @@ discard block |
||
| 300 | 300 | public function short_field() { |
| 301 | 301 | |
| 302 | 302 | ?> |
| 303 | - <input type="checkbox" id="wp-php-console-short" name="wp_php_console[short]" value="1" <?php checked( (bool) $this->options['short'] ); ?> /> |
|
| 304 | - <label for="wp-php-console-short"><?php esc_html_e( 'Yes', 'wp-php-console' ); ?></label><br> |
|
| 303 | + <input type="checkbox" id="wp-php-console-short" name="wp_php_console[short]" value="1" <?php checked((bool) $this->options['short']); ?> /> |
|
| 304 | + <label for="wp-php-console-short"><?php esc_html_e('Yes', 'wp-php-console'); ?></label><br> |
|
| 305 | 305 | <p class="description"><?php |
| 306 | - 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' ); |
|
| 306 | + 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'); |
|
| 307 | 307 | echo '<br>'; |
| 308 | 308 | /* translators: %1$s - long server path, %2$s shortened server path */ |
| 309 | - printf( __( 'Paths like %1$s will be displayed as %2$s', 'wp-php-console' ), |
|
| 309 | + printf(__('Paths like %1$s will be displayed as %2$s', 'wp-php-console'), |
|
| 310 | 310 | '<code>/server/path/to/document/root/WP/wp-admin/admin.php:31</code>', |
| 311 | 311 | '<code>/WP/wp-admin/admin.php:31</code>' |
| 312 | 312 | ); ?></p> |
@@ -322,24 +322,24 @@ discard block |
||
| 322 | 322 | * @param array $field user input |
| 323 | 323 | * @return array sanitized input |
| 324 | 324 | */ |
| 325 | - public function sanitize_field( $field ) { |
|
| 325 | + public function sanitize_field($field) { |
|
| 326 | 326 | |
| 327 | - $input = wp_parse_args( $field, array( |
|
| 327 | + $input = wp_parse_args($field, array( |
|
| 328 | 328 | 'ip' => '', |
| 329 | 329 | 'password' => '', |
| 330 | 330 | 'register' => false, |
| 331 | 331 | 'short' => false, |
| 332 | 332 | 'ssl' => false, |
| 333 | 333 | 'stack' => false, |
| 334 | - ) ); |
|
| 334 | + )); |
|
| 335 | 335 | |
| 336 | 336 | $sanitized_input = array( |
| 337 | - 'ip' => sanitize_text_field( $input['ip'] ), |
|
| 338 | - 'password' => sanitize_text_field( $input['password'] ), |
|
| 339 | - 'register' => ! empty( $input['register'] ), |
|
| 340 | - 'short' => ! empty( $input['short'] ), |
|
| 341 | - 'ssl' => ! empty( $input['ssl'] ), |
|
| 342 | - 'stack' => ! empty( $input['stack'] ), |
|
| 337 | + 'ip' => sanitize_text_field($input['ip']), |
|
| 338 | + 'password' => sanitize_text_field($input['password']), |
|
| 339 | + 'register' => ! empty($input['register']), |
|
| 340 | + 'short' => ! empty($input['short']), |
|
| 341 | + 'ssl' => ! empty($input['ssl']), |
|
| 342 | + 'stack' => ! empty($input['stack']), |
|
| 343 | 343 | ); |
| 344 | 344 | |
| 345 | 345 | return $sanitized_input; |
@@ -355,14 +355,14 @@ discard block |
||
| 355 | 355 | |
| 356 | 356 | ?> |
| 357 | 357 | <div class="wrap"> |
| 358 | - <h2><?php esc_html_e( 'WP PHP Console', 'wp-php-console' ); ?></h2> |
|
| 358 | + <h2><?php esc_html_e('WP PHP Console', 'wp-php-console'); ?></h2> |
|
| 359 | 359 | <hr /> |
| 360 | 360 | <form method="post" action="options.php"> |
| 361 | 361 | <?php |
| 362 | 362 | |
| 363 | - settings_fields( $this->option ); |
|
| 363 | + settings_fields($this->option); |
|
| 364 | 364 | |
| 365 | - do_settings_sections( $this->page ); |
|
| 365 | + do_settings_sections($this->page); |
|
| 366 | 366 | |
| 367 | 367 | submit_button(); |
| 368 | 368 | |
@@ -7,8 +7,8 @@ |
||
| 7 | 7 | * @package WP_PHP_Console |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -if ( ! defined( 'ABSPATH' ) || ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
| 10 | +if ( ! defined('ABSPATH') || ! defined('WP_UNINSTALL_PLUGIN')) { |
|
| 11 | 11 | exit; |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -delete_option( 'wp_php_console' ); |
|
| 14 | +delete_option('wp_php_console'); |
|