| 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.4.1 |
| 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 |
class_exists( 'WPConsole\WPConsole' ) || require_once __DIR__ . '/vendor/autoload.php'; |
| 17 |
|
| 18 |
if ( version_compare( PHP_VERSION, '8.0.0', '>=' ) ) { |
| 19 |
require_once __DIR__ . '/compat/php-8.0/nikic/php-parser/lib/PhpParser/NodeAbstract.php'; |
| 20 |
require_once __DIR__ . '/compat/php-8.0/nikic/php-parser/lib/PhpParser/Comment.php'; |
| 21 |
require_once __DIR__ . '/compat/php-8.0/psy/psysh/src/CodeCleaner/UseStatementPass.php'; |
| 22 |
require_once __DIR__ . '/compat/php-8.0/psy/psysh/src/VarDumper/Dumper.php'; |
| 23 |
require_once __DIR__ . '/compat/php-8.0/symfony/var-dumper/Cloner/Data.php'; |
| 24 |
require_once __DIR__ . '/compat/php-8.0/symfony/var-dumper/Dumper/HtmlDumper.php'; |
| 25 |
} |
| 26 |
|
| 27 |
use WPConsole\Core\Console\VarDumper\VarDumper; |
| 28 |
use WPConsole\WPConsole; |
| 29 |
|
| 30 |
define( 'WP_CONSOLE_FILE', __FILE__ ); |
| 31 |
define( 'WP_CONSOLE_ABSPATH', dirname( WP_CONSOLE_FILE ) ); |
| 32 |
|
| 33 |
/** |
| 34 |
* An override version of Symfony's dump function |
| 35 |
* |
| 36 |
* @since 1.0.0 |
| 37 |
* |
| 38 |
* @param mixed $var |
| 39 |
* @param mixed $moreVars |
| 40 |
* |
| 41 |
* @return mixed |
| 42 |
*/ |
| 43 |
function _dump( $var, ...$moreVars ) { |
| 44 |
VarDumper::dump($var); |
| 45 |
|
| 46 |
foreach ( $moreVars as $v ) { |
| 47 |
VarDumper::dump( $v ); |
| 48 |
} |
| 49 |
|
| 50 |
if ( 1 < func_num_args() ) { |
| 51 |
return func_get_args(); |
| 52 |
} |
| 53 |
|
| 54 |
return $var; |
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* Plugin main instance |
| 59 |
* |
| 60 |
* Returns the main instance of WPConsole to |
| 61 |
* prevent the need to use globals. |
| 62 |
* |
| 63 |
* @since 1.0.0 |
| 64 |
* |
| 65 |
* @return \WPConsole |
| 66 |
*/ |
| 67 |
function wp_console() { |
| 68 |
return WPConsole::instance(); |
| 69 |
} |
| 70 |
|
| 71 |
// Initialize plugin for the first time. |
| 72 |
wp_console(); |
| 73 |
|