Skip to content

Commit c7e88e7

Browse files
author
Miika Arponen
committed
Added a constant to make DustPress Debugger to be always on
2 parents afc2e29 + 324f1d4 commit c7e88e7

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ DustPress Debugger is a WordPress plugin which displays the data loaded by your
77
- Plugin url: https://github.com/devgeniem/dustpress-debugger
88
- Tags: dustpress, wordpress, plugins, dustjs, dust.js
99
- Requires at least: 4.2.0
10-
- Tested up to: 4.5.2
10+
- Tested up to: 5.3.0
1111
- License: GPL-3.0
1212
- License URI: http://www.gnu.org/licenses/gpl-3.0.html
1313

@@ -38,6 +38,8 @@ OR add it into your `composer.json`:
3838

3939
To enable the debugger go to the WordPress dashboard and activate the plugin. After activation users with with the `manage_options` capability can enable the debugger on the user profile page by checking the `DustPress Debugger enabled` checkbox.
4040

41+
You can also activate the debugger on any user by defining `DUSTPRESS_DEBUGGER_ALWAYS_ON` constant in your project. This will override the manual settings, so it is not recommended to use this setting in production!
42+
4143
## Usage
4244

4345
The debugger prints out a toggle button on the bottom of your page. Clicking the button opens the debugger overlay view. In the debugger view you can:

plugin.php

+30-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Plugin Name: DustPress Debugger
55
* Plugin URI: https://github.com/devgeniem/dustpress-debugger
66
* Description: Provides handy ajaxified debugger tool for DustPress based themes.
7-
* Version: 1.5.2
7+
* Version: 1.5.3
88
* Author: Geniem Oy / Miika Arponen & Ville Siltala
99
* Author URI: http://www.geniem.com
1010
*/
@@ -23,16 +23,29 @@ class Debugger
2323
/**
2424
* Add hooks if the user has correct capabilities.
2525
*/
26-
public static function init()
27-
{
28-
if (is_user_logged_in() && current_user_can('manage_options')) {
26+
public static function init() {
27+
if (
28+
(
29+
is_user_logged_in() &&
30+
current_user_can( 'manage_options' )
31+
) ||
32+
(
33+
defined( 'DUSTPRESS_DEBUGGER_ALWAYS_ON' ) &&
34+
\DUSTPRESS_DEBUGGER_ALWAYS_ON === true
35+
) ) {
2936
// Register user option hooks
3037
add_action('show_user_profile', array(__CLASS__, 'profile_option'));
3138
add_action('edit_user_profile', array(__CLASS__, 'profile_option'));
3239
add_action('personal_options_update', array(__CLASS__, 'save_profile_option'));
3340
add_action('edit_user_profile_update', array(__CLASS__, 'save_profile_option'));
3441

35-
if (get_the_author_meta('dustpress_debugger', get_current_user_id())) {
42+
if (
43+
get_the_author_meta( 'dustpress_debugger', get_current_user_id() ) ||
44+
(
45+
defined( 'DUSTPRESS_DEBUGGER_ALWAYS_ON' ) &&
46+
\DUSTPRESS_DEBUGGER_ALWAYS_ON === true
47+
)
48+
) {
3649
// Register the debugger script
3750
wp_register_script('dustpress_debugger', plugin_dir_url(__FILE__) . 'js/dustpress-debugger.js', ['jquery'], '1.5.2', true);
3851

@@ -66,9 +79,17 @@ public static function init()
6679
}
6780
}
6881

69-
public static function use_debugger()
70-
{
71-
if (is_user_logged_in() && current_user_can('manage_options') && get_the_author_meta('dustpress_debugger', get_current_user_id())) {
82+
public static function use_debugger() {
83+
if (
84+
(
85+
is_user_logged_in() &&
86+
current_user_can( 'manage_options' ) &&
87+
get_the_author_meta( 'dustpress_debugger', get_current_user_id() )
88+
) ||
89+
(
90+
defined( 'DUSTPRESS_DEBUGGER_ALWAYS_ON' ) &&
91+
\DUSTPRESS_DEBUGGER_ALWAYS_ON === true
92+
) ) {
7293
return true;
7394
} else {
7495
return false;
@@ -157,7 +178,7 @@ public static function set_debugger_data($key, $data)
157178
if (empty($key)) {
158179
die('You did not set a key for your debugging data collection.');
159180
} else {
160-
$debug_data_block_name = dustpress()->get_setting('debug_data_block_name');
181+
$debug_data_block_name = dustpress()->get_setting( 'debug_data_block_name' ) ?? 'Debug';
161182

162183
if (!isset(self::$data['Debugs'])) {
163184
self::$data['Debugs'] = [];

0 commit comments

Comments
 (0)