Skip to content

Instantly share code, notes, and snippets.

@nathabonfim59
Forked from james2doyle/dd.php
Last active April 12, 2024 12:41
Show Gist options
  • Save nathabonfim59/6a03b8d45e2d2d2261c7d54c92d01f06 to your computer and use it in GitHub Desktop.
Save nathabonfim59/6a03b8d45e2d2d2261c7d54c92d01f06 to your computer and use it in GitHub Desktop.
A implementation of "dump and die" (dd) for WordPress
<?php
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly.
}
if (!function_exists('dd')) {
function dd($data)
{
ini_set("highlight.comment", "#969896; font-style: italic");
ini_set("highlight.default", "#FFFFFF");
ini_set("highlight.html", "#D16568");
ini_set("highlight.keyword", "#7FA3BC; font-weight: bold");
ini_set("highlight.string", "#F2C47E");
$output = highlight_string("<?php\n\n" . var_export($data, true), true);
echo "<div style=\"background-color: #1C1E21; padding: 1rem; overflow: visible;overflow-y: hidden;\">{$output}</div>";
die();
}
}
@nathabonfim59
Copy link
Author

Before:
image

After:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment