Skip to content

Commit 324f1d4

Browse files
author
Miika Arponen
committed
Added an overriding constant
1 parent a599018 commit 324f1d4

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
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

+28-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: DustPress Debugger
44
* Plugin URI: https://github.com/devgeniem/dustpress-debugger
55
* Description: Provides handy ajaxified debugger tool for DustPress based themes.
6-
* Version: 1.4.0
6+
* Version: 1.5.0-beta
77
* Author: Geniem Oy / Miika Arponen & Ville Siltala
88
* Author URI: http://www.geniem.com
99
*/
@@ -22,14 +22,28 @@ class Debugger {
2222
* Add hooks if the user has correct capabilities.
2323
*/
2424
public static function init() {
25-
if ( is_user_logged_in() && current_user_can( 'manage_options' ) ) {
25+
if (
26+
(
27+
is_user_logged_in() &&
28+
current_user_can( 'manage_options' )
29+
) ||
30+
(
31+
defined( 'DUSTPRESS_DEBUGGER_ALWAYS_ON' ) &&
32+
\DUSTPRESS_DEBUGGER_ALWAYS_ON === true
33+
) ) {
2634
// Register user option hooks
2735
add_action( 'show_user_profile', array( __CLASS__, 'profile_option') );
2836
add_action( 'edit_user_profile', array( __CLASS__, 'profile_option') );
2937
add_action( 'personal_options_update', array( __CLASS__, 'save_profile_option') );
3038
add_action( 'edit_user_profile_update', array( __CLASS__, 'save_profile_option') );
3139

32-
if ( get_the_author_meta( 'dustpress_debugger', get_current_user_id() ) ) {
40+
if (
41+
get_the_author_meta( 'dustpress_debugger', get_current_user_id() ) ||
42+
(
43+
defined( 'DUSTPRESS_DEBUGGER_ALWAYS_ON' ) &&
44+
\DUSTPRESS_DEBUGGER_ALWAYS_ON === true
45+
)
46+
) {
3347
// Register the debugger script
3448
wp_register_script( 'dustpress_debugger', plugin_dir_url( __FILE__ ) . 'js/dustpress-debugger.js', [ 'jquery' ], '1.3.1', true );
3549

@@ -62,7 +76,16 @@ public static function init() {
6276
}
6377

6478
public static function use_debugger() {
65-
if ( is_user_logged_in() && current_user_can( 'manage_options' ) && get_the_author_meta( 'dustpress_debugger', get_current_user_id() ) ) {
79+
if (
80+
(
81+
is_user_logged_in() &&
82+
current_user_can( 'manage_options' ) &&
83+
get_the_author_meta( 'dustpress_debugger', get_current_user_id() )
84+
) ||
85+
(
86+
defined( 'DUSTPRESS_DEBUGGER_ALWAYS_ON' ) &&
87+
\DUSTPRESS_DEBUGGER_ALWAYS_ON === true
88+
) ) {
6689
return true;
6790
}
6891
else {
@@ -147,7 +170,7 @@ public static function set_debugger_data( $key, $data ) {
147170
if ( empty( $key ) ) {
148171
die( 'You did not set a key for your debugging data collection.' );
149172
} else {
150-
$debug_data_block_name = dustpress()->get_setting( 'debug_data_block_name' );
173+
$debug_data_block_name = dustpress()->get_setting( 'debug_data_block_name' ) ?? 'Debug';
151174

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

0 commit comments

Comments
 (0)