| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: WP Console |
| 4 |
* Plugin URI: https://github.com/ediamin/wp-console |
| 5 |
* Description: An in-browser PHP console for WordPress powered by PsySH |
| 6 |
* Version: 2.6.0 |
| 7 |
* Author: Edi Amin |
| 8 |
* Author URI: https://github.com/ediamin |
| 9 |
* Text Domain: wp-console |
| 10 |
* Domain Path: /languages/ |
| 11 |
*/ |
| 12 |
|
| 13 |
// Do not call the file directly. |
| 14 |
defined( 'ABSPATH' ) || exit; |
| 15 |
|
| 16 |
if ( ! class_exists( 'WPConsole\WPConsole' ) ) { |
| 17 |
// Supported PHP versions depend on the supported PHP version by PsySH. |
| 18 |
$version = 'php-7.4'; |
| 19 |
if ( version_compare( PHP_VERSION, '8.4', '>=' ) ) { |
| 20 |
$version = 'php-8.4'; |
| 21 |
} elseif ( version_compare( PHP_VERSION, '8.0', '>=' ) ) { |
| 22 |
$version = 'php-8.0'; |
| 23 |
} |
| 24 |
|
| 25 |
require_once __DIR__ . '/lib/' . $version . '/vendor/autoload.php'; |
| 26 |
} |
| 27 |
|
| 28 |
use WPConsole\Core\Console\VarDumper\VarDumper; |
| 29 |
use WPConsole\WPConsole; |
| 30 |
|
| 31 |
define( 'WP_CONSOLE_FILE', __FILE__ ); |
| 32 |
define( 'WP_CONSOLE_ABSPATH', dirname( WP_CONSOLE_FILE ) ); |
| 33 |
|
| 34 |
/** |
| 35 |
* An override version of Symfony's dump function |
| 36 |
* |
| 37 |
* @since 1.0.0 |
| 38 |
* |
| 39 |
* @param mixed $var |
| 40 |
* @param mixed $moreVars |
| 41 |
* |
| 42 |
* @return mixed |
| 43 |
*/ |
| 44 |
function _dump( $var, ...$moreVars ) { |
| 45 |
VarDumper::dump($var); |
| 46 |
|
| 47 |
foreach ( $moreVars as $v ) { |
| 48 |
VarDumper::dump( $v ); |
| 49 |
} |
| 50 |
|
| 51 |
if ( 1 < func_num_args() ) { |
| 52 |
return func_get_args(); |
| 53 |
} |
| 54 |
|
| 55 |
return $var; |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* Plugin main instance |
| 60 |
* |
| 61 |
* Returns the main instance of WPConsole to |
| 62 |
* prevent the need to use globals. |
| 63 |
* |
| 64 |
* @since 1.0.0 |
| 65 |
* |
| 66 |
* @return \WPConsole |
| 67 |
*/ |
| 68 |
function wp_console() { |
| 69 |
return WPConsole::instance(); |
| 70 |
} |
| 71 |
|
| 72 |
// Initialize plugin for the first time. |
| 73 |
wp_console(); |
| 74 |
|