-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebugbar.php
77 lines (50 loc) · 2.33 KB
/
debugbar.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
namespace aw2\debugbar;
use DebugBar\StandardDebugBar;
function setup(){
$debugbar=\aw2_library::get('debugbar.instance');
if(!empty($debugbar))return $debugbar;
require_once AWESOME_PATH.'/vendor/autoload.php';
//use DebugBar\StandardDebugBar;
$debugbar = new StandardDebugBar();
\aw2_library::set('debugbar.instance',$debugbar);
return $debugbar;
}
\aw2_library::add_service('debugbar.head','Generate Scripts for DebugBar',['namespace'=>__NAMESPACE__]);
function head($atts,$content=null,$shortcode){
if(\aw2_library::get('debug_config.active')!=='yes')return;
if(\aw2_library::get('debug_config.output')!=='debugbar')return;
$debugbar=setup();
$debugbarRenderer = $debugbar->getJavascriptRenderer();
$debugbarRenderer->setOptions(["base_url"=>plugin_dir_url( __DIR__ )."vendor/maximebf/debugbar/src/DebugBar/Resources"]);
return $debugbarRenderer->renderHead();
}
\aw2_library::add_service('debugbar.html','Add a message',['namespace'=>__NAMESPACE__]);
function html($atts,$content=null,$shortcode=null){
if(\aw2_library::get('debug_config.active')!=='yes')return;
if(\aw2_library::get('debug_config.output')!=='debugbar')return;
extract(\aw2_library::shortcode_atts( array(
'channel'=>'messages'
), $atts, 'dump' ) );
$debugbar=setup();
$debugbar[$channel]->addMessage($content);
}
\aw2_library::add_service('debugbar.render','Generate Scripts for DebugBar',['namespace'=>__NAMESPACE__]);
function render($atts,$content=null,$shortcode=null){
if(\aw2_library::get('debug_config.active')!=='yes')return;
if(\aw2_library::get('debug_config.output')!=='debugbar')return;
$debugbar=setup();
$debugbarRenderer = $debugbar->getJavascriptRenderer();
return $debugbarRenderer->render();
}
\aw2_library::add_service('debugbar.ajax_render','Generate Scripts for DebugBar',['namespace'=>__NAMESPACE__]);
function ajax_render($atts,$content=null,$shortcode=null){
if(\aw2_library::get('debug_config.active')!=='yes')return;
if(\aw2_library::get('debug_config.output')!=='debugbar')return;
$debugbar=setup();
$debugbarRenderer = $debugbar->getJavascriptRenderer();
$reply= $debugbarRenderer->render(false);
$reply=str_replace('<script type="text/javascript">','<script type="spa/axn" axn=core.run_script>',$reply);
//$reply='<script type="spa/axn" axn=core.run_script>console.log("hero hero")</script>';
return $reply;
}