-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass-debug-bar-cookies.php
60 lines (55 loc) · 1.33 KB
/
class-debug-bar-cookies.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
<?php
/**
* Debug Bar Cookies Panel
*/
class Debug_Bar_Cookies extends Debug_Bar_Panel {
protected $cookies = array();
function init() {
$this->title( 'Cookies' );
}
function prerender() {
$this->set_visible( true );
}
function debug_bar_classes( $classes ) {
return $classes;
}
function render() {
$this->cookies = $_COOKIE;
echo '<div id="debug-bar-cookies">';
echo '<table>';
echo '<thead>';
echo '<tr>';
echo '<th>Type</th>';
echo '<th>Path</th>';
echo '<th>Name</th>';
echo '<th>Value</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
foreach ( $this->cookies as $key => $value ) {
echo '<tr>';
echo '<td>Server</td>';
echo '<td>/</td>';
echo '<td>' . esc_html( $key ) . '</td>';
echo '<td>' . esc_html( $value ) . '</td>';
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
echo '</div>';
echo <<<HTML
<script>
dbCookiesTable = document.getElementById('debug-bar-cookies').getElementsByTagName('tbody')[0];
var cookieRow = dbCookiesTable.insertRow();
var cookieType = cookieRow.insertCell();
var cookiePath = cookieRow.insertCell();
var cookieName = cookieRow.insertCell();
var cookieValue = cookieRow.insertCell();
cookieType.innerHTML = "Client";
cookiePath.innerHTML = "/";
cookieName.innerHTML = "TestCookie";
cookieValue.innerHTML = "It works!";
</script>
HTML;
}
}