PluginProbe
Adminimize / 1.11.7
Adminimize v1.11.7
1.11.14 1.11.13 1.11.1 1.11.10 1.11.11 1.11.12 1.11.2 1.11.3 1.11.4 1.11.5 1.11.6 1.11.7 1.11.8 1.11.9 1.3 1.4.7 1.6 1.7.12 1.7.13 1.7.14 1.7.15 1.7.16 1.7.17 1.7.18 1.7.19 All 53 releases
adminimize / inc-setup / DebugListener.php

DebugListener.php in Adminimize 1.11.7, at inc-setup/DebugListener.php

40 lines 829 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class DebugListener {
4
5 /**
6 * Store message and data for output.
7 *
8 * @var array
9 */
10 protected $data = array();
11
12 /**
13 * Set default message and set var.
14 *
15 * @param string $message Message about the data.
16 * @param mixed $data The data for debugging.
17 */
18 public function listen( $message, $data ) {
19 if ( ! $message ) {
20 $message = 'Debug in Console via Adminimize Plugin:';
21 }
22 $this->data = array( $message, $data );
23 }
24
25 /**
26 * Print the message and data inside the console of the browser.
27 */
28 public function dump() {
29 // Buffering.
30 ob_start();
31 $output = '';
32 foreach ( $this->data as $entry ) {
33 $output .= 'console.info(' . json_encode( $entry[0] ) . ');';
34 $output .= 'console.log(' . json_encode( $entry[1] ) . ');';
35 }
36
37 echo sprintf( '<script>%s</script>', $output );
38 }
39 }
40