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