Skip to content

Commit 63fc95f

Browse files
committed
updated PHP Console, PHP 5.4 check
1 parent 709bdef commit 63fc95f

29 files changed

+364
-132
lines changed

.gitignore

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
1-
### WP PHP Console .gitignore file
2-
3-
## OS crap
4-
.DS_Store
5-
.DS_Store?
6-
._*
7-
.Spotlight-V100
8-
.Trashes
9-
ehthumbs.db
10-
*[Tt]humbs.db
11-
*.Trashes
12-
us.stackdump
13-
14-
## IDE
1+
### IDE ###
152
# IntelliJ
163
.idea/
174
*.ipr
@@ -35,18 +22,26 @@ nb-configuration.xml
3522
*.sublime-workspace
3623
sftp-config.json
3724

38-
## Node
39-
node_modules
25+
### Node ###
26+
/node_modules
4027

41-
## Log files
28+
### Log files ###
4229
*.log
4330
error_log
4431
access_log
4532
.sass-cache
4633

47-
## Other
48-
*.back
49-
*.bak
50-
*.tmp
51-
temp
52-
tmp
34+
### OS crap ###
35+
.DS_Store
36+
.DS_Store?
37+
._*
38+
.Spotlight-V100
39+
.Trashes
40+
ehthumbs.db
41+
*[Tt]humbs.db
42+
*.Trashes
43+
us.stackdump
44+
45+
### Subversion ###
46+
.svn
47+
/svn

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
### 1.3.5 (10 jun 2015)
4+
* Updated PHP Console library to 3.1.3
5+
* PHP 5.4.0 is the minimum required version to activate the plugin
6+
37
### 1.3.3 (30 apr 2015)
48
* Supports WordPress 4.2
59

README.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
=== WP PHP Console ===
22
Contributors: nekojira
3-
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GSTFUY3LMCA5W
3+
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=P64V9NTEYFKDL
44
Tags: development, debug, debugging
55
Requires at least: 3.6.0
6-
Tested up to: 4.2.1
7-
Stable tag: 1.3.3
6+
Tested up to: 4.2.2
7+
Stable tag: 1.3.5
88
License: GPLv2 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -15,10 +15,11 @@ Use Chrome Dev Tools to debug your WordPress installation!
1515

1616
> PHP Console allows you to handle PHP errors & exceptions, dump variables, execute PHP code remotely and many other things using [Google Chrome extension PHP Console](https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef) and [PHP Console server library](https://github.com/barbushin/php-console).
1717

18-
This implementation of PHP Console allows you to test any WordPress specific function or class (including those introduced by your active theme and plugins!) from a terminal and inspect results, catch error and warnings with call stack trace straight from the Chrome JavaScript console. In other words, besides debugging, you can execute PHP or WordPress specific PHP code straight from the terminal and print PHP variables straight in Chrome Dev Tools JavaScript console rather than your HTML document, cluttering the page.
18+
This implementation of PHP Console offers yet another tool to make it more easy to test on the fly any WordPress specific function or class (including those introduced by your active theme and plugins!) from a terminal and inspect results, catch errors and warnings with call stack trace straight from the Chrome JavaScript console. In other words, besides debugging, you can execute PHP or WordPress-specific PHP code straight from the terminal and print PHP variables in Chrome Dev Tools JavaScript console as if it were Javascript. It's very handy to keep everything in one place.
1919

2020
For support and pull requests, please refer to [WP PHP Console Github repo](https://github.com/nekojira/wp-php-console) and read the instructions there - thank you.
2121

22+
2223
== Installation ==
2324

2425
1. First, install [Google Chrome extension PHP Console](https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef) from the [Chrome WebStore](https://chrome.google.com/webstore/search/php%20console?_category=extensions).
@@ -117,8 +118,13 @@ or
117118

118119
None yet.
119120

121+
120122
== Changelog ==
121123

124+
= 1.3.5 =
125+
* Updated PHP Console library to 3.1.3
126+
* Made PHP 5.4.0 the minimum required version to activate the plugin
127+
122128
= 1.3.3 =
123129
* Supports WordPress 4.2
124130

@@ -162,5 +168,8 @@ None yet.
162168

163169
== Upgrade Notice ==
164170

171+
= 1.3.5 =
172+
PHP 5.4.0 is the minimum PHP required version to run this plugin.
173+
165174
= 1.0.0 =
166175
First public release.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "nekojira/wp-php-console",
33
"description": "A WordPress implementation of PHP Console.",
4-
"version": "1.3.3",
4+
"version": "1.3.5",
55
"keywords": [
66
"wordpress",
77
"debug",

composer.lock

Lines changed: 10 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

languages/index.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
// Silence is golden

lib/class-wp-php-console.php

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@
77
* @since 1.0.0
88
*
99
* @package WP_PHP_Console
10-
* @subpackage WP_PHP_Console/lib
1110
*/
1211

12+
if ( ! defined( 'WPINC' ) ) {
13+
exit; // Exit if accessed directly
14+
}
15+
1316
/**
1417
* WP PHP Console.
1518
*
1619
* @since 1.0.0
1720
* @package WP_PHP_Console
18-
* @subpackage WP_PHP_Console/lib
1921
*/
20-
2122
class WP_PHP_Console {
2223

2324
/**
@@ -54,7 +55,7 @@ class WP_PHP_Console {
5455
public function __construct() {
5556

5657
$this->plugin_name = 'wp-php-console';
57-
$this->version = '1.3.3';
58+
$this->version = '1.3.5';
5859
$this->options = get_option( 'wp_php_console' );
5960

6061
// Perform PHP Console initialisation required asap for other code to be able to output to the JavaScript console
@@ -316,19 +317,20 @@ public function sanitize_field( $input ) {
316317

317318
$sanitized_input = array();
318319

319-
if ( isset( $input['password'] ) )
320+
if ( isset( $input['password'] ) ) {
320321
$sanitized_input['password'] = sanitize_text_field( $input['password'] );
322+
}
321323

322-
if ( isset( $input['ssl'] ) )
324+
if ( isset( $input['ssl'] ) ) {
323325
$sanitized_input['ssl'] = ! empty( $input['ssl'] ) ? 1 : '';
326+
}
324327

325-
if ( isset( $input['ip'] ) )
328+
if ( isset( $input['ip'] ) ) {
326329
$sanitized_input['ip'] = sanitize_text_field( $input['ip'] );
330+
}
327331

328332
$sanitized_input['register'] = empty( $input['register'] ) ? '' : 1;
329-
330333
$sanitized_input['stack' ] = empty( $input['stack' ] ) ? '' : 1;
331-
332334
$sanitized_input['short' ] = empty( $input['short'] ) ? '' : 1;
333335

334336
return $sanitized_input;
@@ -385,8 +387,9 @@ public function settings_info() {
385387
*/
386388
public function init() {
387389

388-
if ( ! class_exists( 'PhpConsole\Connector' ) )
390+
if ( ! class_exists( 'PhpConsole\Connector' ) ) {
389391
return;
392+
}
390393

391394
$options = $this->options;
392395

@@ -399,23 +402,27 @@ public function init() {
399402
}
400403

401404
// Selectively remove slashes added by WordPress as expected by PhpConsole
402-
if ( isset( $_POST[PhpConsole\Connector::POST_VAR_NAME] ) )
403-
$_POST[PhpConsole\Connector::POST_VAR_NAME] = stripslashes_deep( $_POST[PhpConsole\Connector::POST_VAR_NAME] );
405+
if ( isset( $_POST[PhpConsole\Connector::POST_VAR_NAME] ) ) {
406+
$_POST[ PhpConsole\Connector::POST_VAR_NAME ] = stripslashes_deep( $_POST[ PhpConsole\Connector::POST_VAR_NAME ] );
407+
}
404408

405409
$connector = PhpConsole\Connector::getInstance();
406410
$connector->setPassword( $password );
407411

408412
$handler = PhpConsole\Handler::getInstance();
409-
if ( PhpConsole\Handler::getInstance()->isStarted() != true )
413+
if ( PhpConsole\Handler::getInstance()->isStarted() != true ) {
410414
$handler->start();
415+
}
411416

412417
$enableSslOnlyMode = isset( $options['ssl'] ) ? ( ! empty( $options['ssl'] ) ? $options['ssl'] : '' ) : '';
413-
if ( $enableSslOnlyMode == true )
418+
if ( $enableSslOnlyMode == true ) {
414419
$connector->enableSslOnlyMode();
420+
}
415421

416422
$allowedIpMasks = isset( $options['ip'] ) ? ( ! empty( $options['ip'] ) ? explode( ',', $options['ip'] ) : '' ) : '';
417-
if ( is_array( $allowedIpMasks ) && ! empty( $allowedIpMasks ) )
423+
if ( is_array( $allowedIpMasks ) && ! empty( $allowedIpMasks ) ) {
418424
$connector->setAllowedIpMasks( (array) $allowedIpMasks );
425+
}
419426

420427
$evalProvider = $connector->getEvalDispatcher()->getEvalProvider();
421428

@@ -425,7 +432,7 @@ public function init() {
425432
// $evalProvider->disableFileAccessByOpenBaseDir();
426433
$openBaseDirs = array( ABSPATH, get_template_directory() );
427434
$evalProvider->addSharedVarReference( 'dirs', $openBaseDirs );
428-
$evalProvider->setOpenBaseDirs( $openBaseDirs );
435+
$evalProvider->setOpenBaseDirs( $openBaseDirs );
429436

430437
$connector->startEvalRequestsListener();
431438

lib/index.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
// Silence is golden

vendor/composer/ClassLoader.php

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ class ClassLoader
5454
private $useIncludePath = false;
5555
private $classMap = array();
5656

57+
private $classMapAuthoritative = false;
58+
5759
public function getPrefixes()
5860
{
5961
if (!empty($this->prefixesPsr0)) {
@@ -248,6 +250,27 @@ public function getUseIncludePath()
248250
return $this->useIncludePath;
249251
}
250252

253+
/**
254+
* Turns off searching the prefix and fallback directories for classes
255+
* that have not been registered with the class map.
256+
*
257+
* @param bool $classMapAuthoritative
258+
*/
259+
public function setClassMapAuthoritative($classMapAuthoritative)
260+
{
261+
$this->classMapAuthoritative = $classMapAuthoritative;
262+
}
263+
264+
/**
265+
* Should class lookup fail if not found in the current class map?
266+
*
267+
* @return bool
268+
*/
269+
public function isClassMapAuthoritative()
270+
{
271+
return $this->classMapAuthoritative;
272+
}
273+
251274
/**
252275
* Registers this instance as an autoloader.
253276
*
@@ -299,6 +322,9 @@ public function findFile($class)
299322
if (isset($this->classMap[$class])) {
300323
return $this->classMap[$class];
301324
}
325+
if ($this->classMapAuthoritative) {
326+
return false;
327+
}
302328

303329
$file = $this->findFileWithExtension($class, '.php');
304330

@@ -325,7 +351,7 @@ private function findFileWithExtension($class, $ext)
325351
foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
326352
if (0 === strpos($class, $prefix)) {
327353
foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
328-
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
354+
if (is_file($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
329355
return $file;
330356
}
331357
}
@@ -335,7 +361,7 @@ private function findFileWithExtension($class, $ext)
335361

336362
// PSR-4 fallback dirs
337363
foreach ($this->fallbackDirsPsr4 as $dir) {
338-
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
364+
if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
339365
return $file;
340366
}
341367
}
@@ -354,7 +380,7 @@ private function findFileWithExtension($class, $ext)
354380
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
355381
if (0 === strpos($class, $prefix)) {
356382
foreach ($dirs as $dir) {
357-
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
383+
if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
358384
return $file;
359385
}
360386
}
@@ -364,7 +390,7 @@ private function findFileWithExtension($class, $ext)
364390

365391
// PSR-0 fallback dirs
366392
foreach ($this->fallbackDirsPsr0 as $dir) {
367-
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
393+
if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
368394
return $file;
369395
}
370396
}

0 commit comments

Comments
 (0)