-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdebug-bar-timber.php
40 lines (33 loc) · 1.38 KB
/
debug-bar-timber.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
<?php
/*
Plugin Name: Timber Debug Bar
Plugin URI: https://github.com/upstatement/debug-bar-timber/
Description: Adds Timber render to the debug bar. Requires the debug bar plugin.
Author: Jared Nova + Upstatement
Version: 1.1.8
Author URI: https://upstatement.com/
*/
add_filter('debug_bar_panels', static function($panels) {
require_once('class-debug-bar-timber.php');
$panels[] = new Debug_Bar_Timber();
return $panels;
});
// bail early if Timber class does not exist
// useful when you switch themes to non timber based themes (ie. twentytwentyone) for debugging etc.
if ( !class_exists('Timber') ) {
return;
}
add_action('init', static function() {
if ( !class_exists('Debug_Bar') ) {
$class = 'error';
$url = admin_url('plugin-install.php?tab=plugin-information&plugin=debug-bar&TB_iframe=true&width=772&height=300');
$text = "In order to use the Timber Debug Bar, you need to install and activate the <a href='$url' class='thickbox'>WordPress Debug Bar</a> Plugin";
add_action( 'admin_notices', static function() use ( $text, $class ) {
echo '<div class="'.$class.'"><p>'.$text.'</p></div>';
}, 1 );
}
});
function tdb_enqueue_styles() {
wp_enqueue_style( 'dbt', plugins_url( "timber-debug-bar.css", __FILE__ ), [], '20200710' );
}
add_action( 'wp_enqueue_scripts', 'tdb_enqueue_styles', 99 );