From 573d07393a5ffffddf3e2be88a3b5f26692eb953 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Wed, 6 Mar 2019 17:26:12 -0600 Subject: [PATCH] Added "KINT ACTIVE" on admin bar. --- assets/css/admin-bar.php | 32 +++++++++++++ config/admin-bar.php | 21 +++++++++ plugin.php | 29 ++++++++---- readme.txt | 25 ++++++---- screenshot-3.png | Bin 0 -> 10092 bytes src/admin-color.php | 97 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 188 insertions(+), 16 deletions(-) create mode 100644 assets/css/admin-bar.php create mode 100644 config/admin-bar.php create mode 100644 screenshot-3.png create mode 100644 src/admin-color.php diff --git a/assets/css/admin-bar.php b/assets/css/admin-bar.php new file mode 100644 index 0000000..74d6650 --- /dev/null +++ b/assets/css/admin-bar.php @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/config/admin-bar.php b/config/admin-bar.php new file mode 100644 index 0000000..b290be7 --- /dev/null +++ b/config/admin-bar.php @@ -0,0 +1,21 @@ + 'KINT ACTIVE', + 'colors' => array( + 'admin_bar_background_color' => '#627f00', + 'message_background_color' => '#cb4b14', + 'message_hover_color' => '#1b202d', + ), +); diff --git a/plugin.php b/plugin.php index 100377f..d60f7f0 100644 --- a/plugin.php +++ b/plugin.php @@ -2,26 +2,39 @@ /** * Kint PHP Debugger - a modern and powerful PHP debugging helper * - * @package Know_The_Code\Kint_PHP_Debugger + * @package KnowTheCode\Kint_PHP_Debugger * @author hellofromTonya * @license dual license GPL-2.0+ & MIT (Kint is licensed MIT) - * @link https://knowthecode.io/ + * @link https://wordpress.org/plugins/kint-php-debugger/ * * @wordpress-plugin * Plugin Name: Kint PHP Debugger * Plugin URI: https://github.com/KnowTheCode/kint-php-debugger * Description: Kint is a a modern and powerful PHP debugging helper, which requires zero-setup and replaces var_dump(), print_r() and debug_backtrace(). This plugin is a wrapper for Kint. - * Version: 1.2.0 + * Version: 1.2.1 * Author: hellofromTonya - * Author URI: https://knowthecode.io/ + * Author URI: https://KnowTheCode.io/ * Text Domain: wpkint * Requires WP: 3.5 * Requires PHP: 5.3 */ -namespace Know_The_Code\Kint_PHP_Debugger; +namespace KnowTheCode\Kint_PHP_Debugger; -$pathto_kint = trailingslashit( __DIR__ ) . 'src/kint-php/kint/Kint.class.php'; +// Bail out if Kint already exists. +if ( class_exists( 'Kint' ) ) { + return; +} -if ( ! class_exists( 'Kint' ) && is_readable( $pathto_kint ) ) { - require_once $pathto_kint; +/** + * Gets the plugin's root directory. + * + * @since 1.2.1 + * + * @return string + */ +function _get_plugin_root_dir() { + return __DIR__; } + +require_once __DIR__ . '/src/kint-php/kint/Kint.class.php'; +require_once __DIR__ . '/src/admin-color.php'; diff --git a/readme.txt b/readme.txt index 4daaa3c..048c55f 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://hellofromtonya.com Tags: debug, debugger, kint, var_dump, print_r, backtrace, trace, debug_backtrace Requires at least: 3.5 Tested up to: 5.1 -Stable tag: 1.2.0 +Stable tag: 1.2.1 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -22,18 +22,18 @@ Some handy tools just for the PHP Developer: * `d( $var );` to render a collapsible UI container which displays your variable data in "the most informative way" * `ddd( $var );` same as d() except that it also executes `die()` to halt execution. -See the [screenshot 1](http://wordpress.org/extend/plugins/kint-php-debugger/screenshots/) for more details. -Here are some variations of d() to give you the display you want: +Here are some variations of `d()` to give you the display you want: -* '~d( $var );' outputs in plain text format. -* '+d( $var );' disregards depth level limits and outputs everything -* '!d( $var );' shows expanded rich output -* '-d( $var );' attempts to ob_clean() the previous output (dump something inside of HTML) +* `~d( $var );` outputs in plain text format. +* `+d( $var );` disregards depth level limits and outputs everything +* `!d( $var );` shows expanded rich output +* `-d( $var );` attempts to ob_clean() the previous output (dump something inside of HTML) = Profiler = Kint even includes a naïve profiler, which can help you analyze which blocks of code take longer than others: + `Kint::dump( microtime() ); // just pass microtime() sleep( 1 ); Kint::dump( microtime(), 'after sleep(1)' ); @@ -42,6 +42,10 @@ ddd( microtime(), 'final call, after sleep(2)' );` See [screenshot 2](http://wordpress.org/extend/plugins/kint-php-debugger/screenshots/) for what is rendered out in your browser. +== Admin Bar == + +"KINT ACTIVE" indicator displays in the WordPress admin bar to alert you when the plugin is active. + == Installation == = From your WordPress dashboard = @@ -83,10 +87,15 @@ Deactivate and delete this plugin. == Screenshots == 1. An example of what gets rendered in the browser when using 'd( $var )'. -2. Profiler example from Kint. +2. Profile example from Kint. +3. "KINT ACTIVE" indicator in the WordPress admin bar. == ChangeLog == += Version 1.2.1 = + +* Added "KINT ACTIVE" indicator to the WordPress admin bar to alert the plugin is activated. + = Version 1.2.0 = * Excluded Composer files. diff --git a/screenshot-3.png b/screenshot-3.png new file mode 100644 index 0000000000000000000000000000000000000000..5ea9bf097a73db0fc9ca8067643f31e3d2b3e75c GIT binary patch literal 10092 zcmeHsRa9L;(k`wcKp<#>yB*x!-Gc=8pa++O2X}XO2rj{$1cJMJaCbX!I5(M@JO8Y8 z*InyA+{f7udv*6$UsYG_-L-pHN2n^xV4xA9!N9;^$jM5o!@$5g{%HrHApN-~e-Rag zfkA7qmXJ`DlaL@&bp~2m+gZTC$VQ~3BCBc~;SKe8&k{4=5`l1vwdo6xRYC7l;t}4- zN27}M#WL0OMix@Q9ei=u8q2s86|)URrU`Po&G34;fPY&U@^AC4%A`rTAe5Ik&Q+ua5D z5hg;~bp+(ehg+*+F8hiwkKZ4zJe(c)E*+R|)kVKPw z+~A}gzy8HZJ9fR8k$$PF0y8D6?a7`*uLu`V75ivSSVcvJ>4n{o=ffQrcj?+y!^Dyl zbIBHrUtCh1y)PUb^X@f~_6W#_L&cXdMuj?g&raEiuR>z#o7A^i%$>1IDP=p|9D3uC7 zrB5s$#YG(-Ud@}7>=e4&;z>3QUjG_iYVqF(&IE}sx@(u^d=pzzEE#5M@;bdf(PcjX zxMA|g2baD=`;&JGx4AT6g&x6Bb09y@n#zoTOSj+KJmEYIT;__H@vH0HxQO^4=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m8_53srw)qKeB_HNos=i~KlzKn z(&!%6l~o=2{U;_D>YlZX8M=>p&OW5r%Qs_WK)r{Z8G}J0t~2 zLOc6nVNgAO-U|Zw?hP{>usrS1(0Pl5a0m?@f4DMCms^ggq_7<=NL^jA{m1H7igFuF z33bU5fF9Q3XULa$S_i$7hW4d!&##JviU|)Hv6P3sPpMxo*p$^7D~88+_=WZ$SbH4= zq!xnoA8l4&2?N7CJzT*FJ?VsWPhOXIhsZgQZ2;IJ&)DK_J>542}91NQOw7 zW*&@MW*TtJQ0L1h*el@j{jIf!{PCXnllY*>)#9R6#y38mYA(`#Vv;w^6n55=J>AgD zBk5p>3j8bNjG3#pHYZ;CCWo1b%l23*PyW8Ncyx>mGBeX2qX1{g?=9lcb?eK4ei)$* zU~lw*L$a`V>83U58skLU^SN6@DZ^ArfL%c{x7;&*6^N>%(F<-XMwp)2CglSmgqD@% zmzIlm7wE<~%DI8eRbMOTPvW}_C>-U|lrz0hvmd#{bKw1!bTS42IWc%=ocKPjab6%! zf&0ra`eY%|r}_&9!+X@*I~S(ca!+85(9+nuoS>@NrCaO`z{au6fobjLQvEV~M_!)v zd=7n{FGSwzt*u+MzoB_$R}gbpc-=|5vMjec^4eRcbJ347&KI$Xq4vk&A};L_B^(g+~;g#3R6dZ~>TUv&LaHms*^W&YMkn^9TeT9lIS|JF5o z$>DGv!$fB>{%T*M5rzFP@ZXU9_htC+GWh?T8KB5lN?H=Fr2;&Ej~V5plqGA#jlcdc D@gf7* literal 0 HcmV?d00001 diff --git a/src/admin-color.php b/src/admin-color.php new file mode 100644 index 0000000..b7a75db --- /dev/null +++ b/src/admin-color.php @@ -0,0 +1,97 @@ + 'top-secondary', + 'id' => 'environment-notice', + 'title' => sprintf( '%s', $message ), + ); + + $wp_admin_bar->add_menu( $admin_notice ); +} + +add_action( 'admin_head', __NAMESPACE__ . '\render_admin_bar_css', 9999 ); +add_action( 'wp_head', __NAMESPACE__ . '\render_admin_bar_css', 9999 ); +/** + * Render the admin bar CSS. + * + * @since 1.2.1 + * + * @return void + */ +function render_admin_bar_css() { + if ( ! is_admin_bar_showing() ) { + return; + } + + ob_start(); + + include _get_plugin_root_dir() . '/assets/css/admin-bar.php'; + + $css_pattern = ob_get_clean(); + + vprintf( $css_pattern, get_admin_bar_config( 'colors' ) ); +} + +/** + * Get the admin bar's runtime configuration parameter(s). + * + * @since 1.2.1 + * + * @param string $parameter + * + * @return array|mixed + */ +function get_admin_bar_config( $parameter = '' ) { + static $config = array(); + + if ( ! $config ) { + $config = include _get_plugin_root_dir() . '/config/admin-bar.php'; + } + + if ( $parameter && isset( $config[ $parameter ] ) ) { + return $config[ $parameter ]; + } + + return $config; +}