PluginProbe
WP Console – WordPress PHP Console powered by PsySH / 2.4.0
WP Console – WordPress PHP Console powered by PsySH v2.4.0
trunk 2.4.0 2.4.1 2.5.0 2.5.1 2.6.0
wp-console / wp-console.php

wp-console.php in WP Console – WordPress PHP Console powered by PsySH 2.4.0, at wp-console.php

72 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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.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 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/VarDumper/Dumper.php';
22 require_once __DIR__ . '/compat/php-8.0/symfony/var-dumper/Cloner/Data.php';
23 require_once __DIR__ . '/compat/php-8.0/symfony/var-dumper/Dumper/HtmlDumper.php';
24 }
25
26 use WPConsole\Core\Console\VarDumper\VarDumper;
27 use WPConsole\WPConsole;
28
29 define( 'WP_CONSOLE_FILE', __FILE__ );
30 define( 'WP_CONSOLE_ABSPATH', dirname( WP_CONSOLE_FILE ) );
31
32 /**
33 * An override version of Symfony's dump function
34 *
35 * @since 1.0.0
36 *
37 * @param mixed $var
38 * @param mixed $moreVars
39 *
40 * @return mixed
41 */
42 function _dump( $var, ...$moreVars ) {
43 VarDumper::dump($var);
44
45 foreach ( $moreVars as $v ) {
46 VarDumper::dump( $v );
47 }
48
49 if ( 1 < func_num_args() ) {
50 return func_get_args();
51 }
52
53 return $var;
54 }
55
56 /**
57 * Plugin main instance
58 *
59 * Returns the main instance of WPConsole to
60 * prevent the need to use globals.
61 *
62 * @since 1.0.0
63 *
64 * @return \WPConsole
65 */
66 function wp_console() {
67 return WPConsole::instance();
68 }
69
70 // Initialize plugin for the first time.
71 wp_console();
72