-
Notifications
You must be signed in to change notification settings - Fork 63
/
inspectpostmeta.class.php
67 lines (60 loc) · 1.72 KB
/
inspectpostmeta.class.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
<?php
/*
* Inspect Post Meta
* Creates a post widget to help you inspect some meta fields for posts
* Version: 2010.1104
* Author: Charles Johnson
* Author URI: http://projects.radgeek.com
*/
class InspectPostMeta {
public function __construct ($in_hook = true) {
add_action('add_meta_boxes', array($this, 'add_meta_boxes'), 10, 2);
} /* InspectPostMeta::__construct () */
function add_meta_boxes ($post_type, $post) {
add_meta_box(
/*id=*/ 'inspect_post_guid_box',
/*title=*/ 'Post GUID and Meta Data',
/*callback=*/ array($this, 'meta_box'),
/*page=*/ $post_type,
/*context=*/ 'normal',
/*priority=*/ 'default'
);
}
function meta_box () {
global $post;
?>
<table>
<tbody>
<tr>
<th style="text-align: left" scope="row">ID:</th>
<td><code><?php print esc_html($post->ID); ?></code></td>
</tr>
<tr>
<th style="text-align: left" scope="row">GUID:</th>
<td><code><?php print esc_html($post->guid); ?></code></td>
</tr>
<tr>
<th colspan="2" style="text-align: center"><h4>Custom Fields</h4></th>
</tr>
<?php
$custom = get_post_custom($post->ID);
if (count($custom) > 0) :
foreach ($custom as $key => $values) :
$idx = 1;
foreach ($values as $value) :
print "<tr><th style='text-align: left' scope='row'>".esc_html($key);
if ($idx > 1) :
print esc_html( sprintf( '[%d]', intval( $idx ) ) );
endif;
print ":</th> ";
print "<td><pre><code>".esc_html($value)."</code></pre>";
print "</td></tr>\n";
$idx++;
endforeach;
endforeach;
else :
print "<tr><td colspan='2'><p><em>No custom fields for this post.</em></p></td></tr>\n";
endif;
print "</table>\n";
} /* InspectPostMeta::meta_box() */
} /* class InspectPostMeta */