-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d9be60
commit 573d073
Showing
6 changed files
with
188 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<style type="text/css"> | ||
#wpadminbar { | ||
background-color: %s !important; | ||
} | ||
#wp-admin-bar-environment-notice { | ||
display: none; | ||
} | ||
#wpadminbar .ab-item, | ||
#wpadminbar a.ab-item, | ||
#wpadminbar > #wp-toolbar span.ab-label, | ||
#wpadminbar > #wp-toolbar span.noticon, | ||
.adminbar--environment-notice { | ||
color: #fff; | ||
} | ||
@media only screen and ( min-width: 800px ) { | ||
#wp-admin-bar-environment-notice { | ||
display: block; | ||
} | ||
#wp-admin-bar-environment-notice .ab-item { | ||
background-color: %s !important; | ||
} | ||
#wp-admin-bar-environment-notice:hover .ab-item { | ||
background-color: %s !important; | ||
color: #fff; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
/** | ||
* Admin Bar Runtime Configuration Parameters. | ||
* | ||
* @package KnowTheCode\Kint_PHP_Debugger | ||
* @since 1.2.1 | ||
* @author hellofromTonya | ||
* @link https://wordpress.org/plugins/kint-php-debugger/ | ||
* @license GNU-2.0+ | ||
*/ | ||
|
||
namespace KnowTheCode\Kint_PHP_Debugger; | ||
|
||
return array( | ||
'message' => 'KINT ACTIVE', | ||
'colors' => array( | ||
'admin_bar_background_color' => '#627f00', | ||
'message_background_color' => '#cb4b14', | ||
'message_hover_color' => '#1b202d', | ||
), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
/** | ||
* Admin functions to change the look of the admin bar when this plugin | ||
* is activated, i.e. to differentiate that we are in development mode. | ||
* | ||
* @package KnowTheCode\Kint_PHP_Debugger | ||
* @since 1.2.1 | ||
* @author hellofromTonya | ||
* @link https://wordpress.org/plugins/kint-php-debugger/ | ||
* @license GNU-2.0+ | ||
*/ | ||
|
||
namespace KnowTheCode\Kint_PHP_Debugger; | ||
|
||
add_filter( 'get_user_option_admin_color', __NAMESPACE__ . '\set_local_development_admin_color_scheme', 5 ); | ||
/** | ||
* Force different admin color scheme when this plugin is active. | ||
* | ||
* @since 1.2.1 | ||
* | ||
* @return string | ||
*/ | ||
function set_local_development_admin_color_scheme() { | ||
return 'coffee'; | ||
} | ||
|
||
add_action( 'admin_bar_menu', __NAMESPACE__ . '\add_admin_bar_notice', 9999 ); | ||
/** | ||
* Add an admin bar notice to alert user that they are in local development | ||
* and this plugin is activated. | ||
* | ||
* @since 1.2.1 | ||
* | ||
* @return void | ||
*/ | ||
function add_admin_bar_notice() { | ||
if ( ! is_admin_bar_showing() ) { | ||
return; | ||
} | ||
global $wp_admin_bar; | ||
|
||
$message = get_admin_bar_config( 'message' ); | ||
|
||
$admin_notice = array( | ||
'parent' => 'top-secondary', | ||
'id' => 'environment-notice', | ||
'title' => sprintf( '<span class="adminbar--environment-notice">%s</span>', $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; | ||
} |