Skip to content

Commit 2850ab3

Browse files
author
nekorjira
committed
Fixes activation issue
Fixes "Fatal error: Using $this when not in object context"
1 parent e704c23 commit 2850ab3

File tree

5 files changed

+49
-25
lines changed

5 files changed

+49
-25
lines changed

ChangeLog.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# Changelog
22

3+
### 1.3.2 (03 mar 2015)
4+
* Fixes "Fatal error: Using $this when not in object context" upon activation in some installations.
5+
36
### 1.3.1 (09 feb 2015)
47
* Enhancement: earlier PC initialisation - props @Polfo
5-
* Updated readme files
8+
* Updated readme files.
69

710
### 1.3.0 (05 feb 2015)
811
* Enhancement: added configuration options - props @Polfo

README.txt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
44
Tags: development, debug, debugging
55
Requires at least: 3.6.0
66
Tested up to: 4.1
7-
Stable tag: 1.3.1
7+
Stable tag: 1.3.2
88
License: GPLv2 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -119,37 +119,40 @@ None yet.
119119

120120
== Changelog ==
121121

122-
= 1.3.1 (09 feb 2015) =
122+
= 1.3.2 =
123+
* Fixes "Fatal error: Using $this when not in object context" upon activation in some installations.
124+
125+
= 1.3.1 =
123126
* Enhancement: earlier PC initialisation - props @Polfo
124127
* Updated readme files
125128

126-
= 1.3.0 (05 feb 2015) =
129+
= 1.3.0 =
127130
* Enhancement: added configuration options - props @Polfo
128131
- Register PC class
129132
- Show Call Stack
130133
- Short Path Names
131134
* Fix: IP mask
132135

133-
= 1.2.3 (21 jan 2015) =
136+
= 1.2.3 =
134137

135138
* Fixes "Wrong PHP Console eval request signature" error when executing WordPress code from terminal, props @Polfo @barbushin
136139

137-
= 1.2.2 (15 jan 2015) =
140+
= 1.2.2 =
138141
* Bugfixes
139142
* Submission to WordPress.org plugins repository.
140143

141-
= 1.2.1 (12 dec 2014) =
144+
= 1.2.1 =
142145
* Fixed allowed IPs bug.
143146

144-
= 1.2.0 (11 dec 2014) =
147+
= 1.2.0 =
145148
* Updated dependencies and got rid of git submodules.
146149

147-
= 1.1.0 (07 nov 2014) =
150+
= 1.1.0 =
148151
* Added donation link/button.
149152
* PHP Console server is now instantiated later, allowing to catch all your theme functions too.
150153
* Included PHP Console server library as git submodule rather than a composer dependency.
151154

152-
= 1.0.0 (06 nov 2014) =
155+
= 1.0.0 =
153156
* Added three options to set a custom password, enable on SSL only, authorized IP ranges.
154157
* First public release.
155158

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.1",
4+
"version": "1.3.2",
55
"keywords": [
66
"wordpress",
77
"debug",

lib/class-wp-php-console.php

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,10 @@ class WP_PHP_Console {
5454
public function __construct() {
5555

5656
$this->plugin_name = 'wp-php-console';
57-
$this->version = '1.3.1';
57+
$this->version = '1.3.2';
5858
$this->options = get_option( 'wp_php_console' );
5959

6060
// Perform PHP Console initialisation required asap for other code to be able to output to the JavaScript console
61-
6261
$connector = PhpConsole\Connector::getInstance();
6362

6463
// Apply 'register' option to PHP Console
@@ -87,6 +86,7 @@ public function __construct() {
8786
add_action( 'admin_menu', array( $this, 'register_settings_page' ) );
8887
// Delay further PHP Console initialisation to have more context during Remote PHP execution
8988
add_action( 'wp_loaded', array( $this, 'init' ) );
89+
9090
}
9191

9292
/**
@@ -117,6 +117,7 @@ public function register_settings_page() {
117117
);
118118

119119
add_action( 'admin_init', array( $this, 'register_settings' ) );
120+
120121
}
121122

122123
/**
@@ -203,6 +204,7 @@ public function password_field() {
203204
echo '<label for="wp-php-console-ip">' . __( 'Required', $this->plugin_name ) . '</label>';
204205
echo '<br />';
205206
echo '<small class="description">' . __( 'The password for eval terminal. If empty, the plugin will not work.', $this->plugin_name ) . '</small>';
207+
206208
}
207209

208210
/**
@@ -221,6 +223,7 @@ public function ssl_field() {
221223
echo '<label for="wp-php-console-ssl">' . __( 'Yes (optional)', $this->plugin_name ) . '</label>';
222224
echo '<br />';
223225
echo '<small class="description">' . __( 'Choose if you want the eval terminal to work only on a SSL connection.', $this->plugin_name ) . '</small>';
226+
224227
}
225228

226229
/**
@@ -237,6 +240,7 @@ public function ip_field() {
237240
echo '<label for="wp-php-console-ip">' . __( 'IP addresses (optional)', $this->plugin_name ) . '</label>';
238241
echo '<br />';
239242
echo '<small class="description">' . __( 'You may specify an IP address (e.g. 192.169.1.50), a range of addresses (192.168.*.*) or multiple addresses, comma separated (192.168.10.25,192.168.10.28) to grant access to eval terminal.', $this->plugin_name ) . '</small>';
243+
240244
}
241245

242246
/**
@@ -255,6 +259,7 @@ public function register_field() {
255259
echo '<label for="wp-php-console-register">' . __( 'Yes (optional)', $this->plugin_name ) . '</label>';
256260
echo '<br />';
257261
echo '<small class="description">' . __( 'Choose to register PC in the global namespace. Allows to write PC::debug($var, $tag) or PC::magic_tag($var) instructions in PHP to inspect $var in the JavaScript-console.', $this->plugin_name ) . '</small>';
262+
258263
}
259264

260265
/**
@@ -273,6 +278,7 @@ public function stack_field() {
273278
echo '<label for="wp-php-console-stack">' . __( 'Yes (optional)', $this->plugin_name ) . '</label>';
274279
echo '<br />';
275280
echo '<small class="description">' . __( 'Choose to also see the call stack when PHP Console writes to the browser\'s JavaScript-console.', $this->plugin_name ) . '</small>';
281+
276282
}
277283

278284
/**
@@ -291,6 +297,7 @@ public function short_field() {
291297
echo '<label for="wp-php-console-short">' . __( 'Yes (optional)', $this->plugin_name ) . '</label>';
292298
echo '<br />';
293299
echo '<small class="description">' . __( 'Choose to shorten PHP Console error sources and traces paths in browser\'s JavaScript-console. Paths like /server/path/to/document/root/WP/wp-admin/admin.php:31 will be displayed as /W/wp-admin/admin.php:31', $this->plugin_name ) . '</small>';
300+
294301
}
295302

296303
/**
@@ -386,20 +393,13 @@ public function init() {
386393

387394
// Display admin notice and abort if no password
388395
if ( ! $password ) {
389-
add_action('admin_notices', function() {
390-
?>
391-
<div class="update-nag">
392-
<?php _e( 'WP PHP Console plugin: Please enter a password in Settings / WP PHP Console for it to work.', $this->plugin_name ); ?>
393-
</div>
394-
<?php
395-
});
396+
add_action( 'admin_notices', array( $this, 'password_notice' ) );
396397
return; // abort
397398
}
398399

399400
// Selectively remove slashes added by WordPress as expected by PhpConsole
400-
if(isset($_POST[PhpConsole\Connector::POST_VAR_NAME])) {
401-
$_POST[PhpConsole\Connector::POST_VAR_NAME] = stripslashes_deep($_POST[PhpConsole\Connector::POST_VAR_NAME]);
402-
}
401+
if ( isset( $_POST[PhpConsole\Connector::POST_VAR_NAME] ) )
402+
$_POST[PhpConsole\Connector::POST_VAR_NAME] = stripslashes_deep( $_POST[PhpConsole\Connector::POST_VAR_NAME] );
403403

404404
$connector = PhpConsole\Connector::getInstance();
405405
$connector->setPassword( $password );
@@ -430,4 +430,22 @@ public function init() {
430430

431431
}
432432

433-
}
433+
/**
434+
* Admin password notice.
435+
* Prompts user to set a password for PHP Console upon plugin activation.
436+
*
437+
* @since 1.3.2
438+
*/
439+
public function password_notice() {
440+
441+
$link = admin_url( 'options-general.php?page=wp-php-console' );
442+
443+
?>
444+
<div class="update-nag">
445+
<?php printf( __( 'WP PHP Console: remember to %1$s set a password %2$s if you want to enable terminal.', $this->plugin_name ), '<a href="' . $link .'">', '</a>' ); ?>
446+
</div>
447+
<?php
448+
449+
}
450+
451+
}

wp-php-console.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Plugin Name: WP PHP Console
1010
* Plugin URI: https://github.com/nekojira/wp-php-console/
1111
* Description: An implementation of PHP Console for WordPress. Easily debug and trace PHP errors and warnings from your Chrome dev tools console using a Google Chrome extension.
12-
* Version: 1.3.1
12+
* Version: 1.3.2
1313
* Author: nekojira
1414
* Author URI: https://github.com/nekojira/
1515
* License: GPL-2.0+

0 commit comments

Comments
 (0)