Skip to content

Commit 475e64f

Browse files
committed
add connector property
1 parent 1fc6403 commit 475e64f

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

includes/class-wp-php-console.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ class Plugin {
5959
*/
6060
protected $options = array();
6161

62+
/**
63+
* Instance of PHP Console connector object.
64+
*
65+
* @since 1.4.1
66+
* @access public
67+
* @var PhpConsole\Connector $connector Instance.
68+
*/
69+
public $connector = null;
70+
6271

6372
/**
6473
* Load plugin and connect to PHP Console.
@@ -136,7 +145,7 @@ private function connect() {
136145
}
137146

138147
// Perform PHP Console initialisation required asap for other code to be able to output to the JavaScript console
139-
$connector = PhpConsole\Connector::getInstance();
148+
$this->connector = PhpConsole\Connector::getInstance();
140149

141150
}
142151

@@ -171,13 +180,13 @@ private function apply_options() {
171180

172181
// Apply 'stack' option to PHP Console
173182
if ( ! empty( $this->options['stack'] ) ) {
174-
$connector->getDebugDispatcher()->detectTraceAndSource = true;
183+
$this->connector->getDebugDispatcher()->detectTraceAndSource = true;
175184
}
176185

177186
// Apply 'short' option to PHP Console
178187
if ( ! empty( $this->options['short'] ) ) {
179188
try {
180-
$connector->setSourcesBasePath( $_SERVER['DOCUMENT_ROOT'] );
189+
$this->connector->setSourcesBasePath( $_SERVER['DOCUMENT_ROOT'] );
181190
} catch ( \Exception $e ) {
182191
$this->print_notice_exception( $e );
183192
}
@@ -205,10 +214,10 @@ public function init() {
205214
$_POST[ PhpConsole\Connector::POST_VAR_NAME ] = stripslashes_deep( $_POST[ PhpConsole\Connector::POST_VAR_NAME ] );
206215
}
207216

208-
$connector = PhpConsole\Connector::getInstance();
217+
$this->connector = PhpConsole\Connector::getInstance();
209218

210219
try {
211-
$connector->setPassword( $password );
220+
$this->connector->setPassword( $password );
212221
} catch ( \Exception $e ) {
213222
$this->print_notice_exception( $e );
214223
}
@@ -228,17 +237,17 @@ public function init() {
228237
$enableSslOnlyMode = isset( $this->options['ssl'] ) ? ( ! empty( $this->options['ssl'] ) ? $this->options['ssl'] : '' ) : '';
229238

230239
if ( $enableSslOnlyMode ) {
231-
$connector->enableSslOnlyMode();
240+
$this->connector->enableSslOnlyMode();
232241
}
233242

234243
// Restrict IP addresses
235244
$allowedIpMasks = isset( $this->options['ip'] ) ? ( ! empty( $this->options['ip'] ) ? explode( ',', $this->options['ip'] ) : '' ) : '';
236245

237246
if ( is_array( $allowedIpMasks ) && ! empty( $allowedIpMasks ) ) {
238-
$connector->setAllowedIpMasks( (array) $allowedIpMasks );
247+
$this->connector->setAllowedIpMasks( (array) $allowedIpMasks );
239248
}
240249

241-
$evalProvider = $connector->getEvalDispatcher()->getEvalProvider();
250+
$evalProvider = $this->connector->getEvalDispatcher()->getEvalProvider();
242251

243252
try {
244253
$evalProvider->addSharedVar( 'uri', $_SERVER['REQUEST_URI'] );
@@ -263,7 +272,7 @@ public function init() {
263272
$evalProvider->setOpenBaseDirs( $openBaseDirs );
264273

265274
try {
266-
$connector->startEvalRequestsListener();
275+
$this->connector->startEvalRequestsListener();
267276
} catch ( \Exception $e ) {
268277
$this->print_notice_exception( $e );
269278
}

0 commit comments

Comments
 (0)