PluginProbe
WP Console – WordPress PHP Console powered by PsySH / 2.5.0
WP Console – WordPress PHP Console powered by PsySH v2.5.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.5.0, at wp-console.php

68 lines 1.5 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.5.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 are depends on the supported PHP version by PsySH.
18 $version = version_compare( PHP_VERSION, '8.0', '>=' ) ? 'php-8.0' :'php-7.4';
19 require_once __DIR__ . '/lib/' . $version . '/vendor/autoload.php';
20 }
21
22 use WPConsole\Core\Console\VarDumper\VarDumper;
23 use WPConsole\WPConsole;
24
25 define( 'WP_CONSOLE_FILE', __FILE__ );
26 define( 'WP_CONSOLE_ABSPATH', dirname( WP_CONSOLE_FILE ) );
27
28 /**
29 * An override version of Symfony's dump function
30 *
31 * @since 1.0.0
32 *
33 * @param mixed $var
34 * @param mixed $moreVars
35 *
36 * @return mixed
37 */
38 function _dump( $var, ...$moreVars ) {
39 VarDumper::dump($var);
40
41 foreach ( $moreVars as $v ) {
42 VarDumper::dump( $v );
43 }
44
45 if ( 1 < func_num_args() ) {
46 return func_get_args();
47 }
48
49 return $var;
50 }
51
52 /**
53 * Plugin main instance
54 *
55 * Returns the main instance of WPConsole to
56 * prevent the need to use globals.
57 *
58 * @since 1.0.0
59 *
60 * @return \WPConsole
61 */
62 function wp_console() {
63 return WPConsole::instance();
64 }
65
66 // Initialize plugin for the first time.
67 wp_console();
68