-
Notifications
You must be signed in to change notification settings - Fork 6
/
wp-laravel-dd.php
executable file
·69 lines (60 loc) · 2 KB
/
wp-laravel-dd.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* The plugin bootstrap file
*
* This file is read by WordPress to generate the plugin information in the plugin
* admin area. This file also includes all of the dependencies used by the plugin,
* registers the activation and deactivation functions, and defines a function
* that starts the plugin.
*
* @link https://peterhegman.com/
* @since 1.0.0
* @package Wp_Laravel_Dd
*
* @wordpress-plugin
* Plugin Name: Laravel DD for Wordpress
* Plugin URI:
* Description: Use Laravel's dd() (die dump) function in your Wordpress projects
* Version: 1.0.1
* Author: Peter Hegman
* Author URI: https://peterhegman.com/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: wp-laravel-dd
* Domain Path: /languages
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
//Autoload Composer packages
require __DIR__ . '/vendor/autoload.php';
// If we haven't loaded this plugin from Composer we need to add our own autoloader
if (!class_exists('PeterHegman\Dumper')) {
// Get a reference to our PSR-4 Autoloader function that we can use to add our
$autoloader = require_once('autoload.php');
// Use the autoload function to setup our class mapping
$autoloader('PeterHegman\\', __DIR__ . '/src/PeterHegman/');
}
/**
* Disable Wordpress emoji's as they mess with the var-dumper
*/
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
if (! function_exists('dd')) {
/**
* Dump the passed variables and end the script.
*
* @param mixed
* @return void
*/
function dd()
{
array_map(function ($x) {
(new PeterHegman\Dumper)->dump($x);
}, func_get_args());
die(1);
}
}