3
3
* Plugin Name: DustPress Debugger
4
4
* Plugin URI: https://github.com/devgeniem/dustpress-debugger
5
5
* Description: Provides handy ajaxified debugger tool for DustPress based themes.
6
- * Version: 1.1.2
6
+ * Version: 1.1.3
7
7
* Author: Geniem Oy / Miika Arponen & Ville Siltala
8
8
* Author URI: http://www.geniem.com
9
9
*/
27
27
class Debugger {
28
28
29
29
private static $ hash ;
30
+ private static $ data = [];
30
31
31
32
/**
32
33
* Add hooks if the user has correct capabilities.
@@ -46,7 +47,10 @@ public static function init() {
46
47
47
48
add_filter ( "dustpress/data " , array ( __CLASS__ , "set_hash " ) );
48
49
49
- add_action ( 'dustpress/data/after_render ' , array ( __CLASS__ , 'debugger ' ), 1 , 1 );
50
+ add_action ( 'dustpress/data/after_render ' , array ( __CLASS__ , 'debugger ' ), 100 , 1 );
51
+
52
+ // Register DustPress core helper hooks
53
+ add_filter ( 'dustpress/menu/data ' , array ( __CLASS__ , "gather_menu_helper_data " ) );
50
54
}
51
55
}
52
56
@@ -77,14 +81,17 @@ public static function set_hash( $data ) {
77
81
* @param string $hash The current data hash.
78
82
*/
79
83
public static function debugger ( $ data ) {
80
- $ data = apply_filters ( 'dustpress/debugger/data ' , $ data );
84
+
85
+ $ debugger_data = array_merge ( $ data , self ::$ data );
86
+
87
+ $ debugger_data = apply_filters ( 'dustpress/debugger/data ' , $ debugger_data );
81
88
82
89
// start session for data storing
83
90
if ( session_status () == PHP_SESSION_NONE ) {
84
91
session_start ();
85
92
}
86
93
87
- $ _SESSION [ self ::$ hash ] = $ data ;
94
+ $ _SESSION [ self ::$ hash ] = $ debugger_data ;
88
95
89
96
session_write_close ();
90
97
}
@@ -117,6 +124,37 @@ public static function get_debugger_data() {
117
124
wp_send_json ( $ output );
118
125
}
119
126
}
127
+
128
+ public static function gather_menu_helper_data ( $ data ) {
129
+ self ::set_debugger_data ( 'Menu ' , $ data );
130
+
131
+ return $ data ;
132
+ }
133
+
134
+ /**
135
+ * Gathers debug data from other sources than DustPress core.
136
+ */
137
+ public static function set_debugger_data ( $ key , $ data ) {
138
+ if ( empty ( $ key ) ) {
139
+ die ( 'You did not set a key for your debugging data collection. ' );
140
+ } else {
141
+ $ debug_data_block_name = dustpress ()->get_setting ( "debug_data_block_name " );
142
+
143
+ $ model_data = [];
144
+
145
+ if ( ! isset ( $ model_data [ $ debug_data_block_name ] ) ) {
146
+ $ model_data [ $ debug_data_block_name ] = [];
147
+ }
148
+
149
+ if ( ! isset ( $ model_data [ $ debug_data_block_name ][ $ key ] ) ) {
150
+ $ model_data [ $ debug_data_block_name ][ $ key ] = [];
151
+ }
152
+
153
+ $ model_data [ $ debug_data_block_name ][ $ key ][] = $ data ;
154
+ }
155
+
156
+ self ::$ data = array_merge ( self ::$ data , $ model_data );
157
+ }
120
158
}
121
159
122
160
add_action ( 'init ' , __NAMESPACE__ . '\\Debugger::init ' );
0 commit comments