PluginProbe
FeedWordPress / 2010.0531
FeedWordPress v2010.0531
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
feedwordpress / diagnostics-page.php

diagnostics-page.php in FeedWordPress 2010.0531, at diagnostics-page.php

170 lines 6.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 require_once(dirname(__FILE__) . '/admin-ui.php');
3
4 class FeedWordPressDiagnosticsPage extends FeedWordPressAdminPage {
5 function FeedWordPressDiagnosticsPage () {
6 // Set meta-box context name
7 FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpressdiagnosticspage');
8 $this->dispatch = 'feedwordpress_diagnostics';
9 $this->filename = __FILE__;
10 }
11
12 function has_link () { return false; }
13
14 function display () {
15 global $wpdb, $wp_db_version, $fwp_path;
16 global $fwp_post;
17
18 if (FeedWordPress::needs_upgrade()) :
19 fwp_upgrade_page();
20 return;
21 endif;
22
23 // If this is a POST, validate source and user credentials
24 FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_diagnostics', /*capability=*/ 'manage_options');
25
26 if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') :
27 $this->accept_POST($fwp_post);
28 do_action('feedwordpress_admin_page_diagnostics_save', $GLOBALS['fwp_post'], $this);
29 endif;
30
31 ////////////////////////////////////////////////
32 // Prepare settings page ///////////////////////
33 ////////////////////////////////////////////////
34
35 $this->display_update_notice_if_updated('Diagnostics');
36
37 $this->open_sheet('FeedWordPress Diagnostics');
38 ?>
39 <div id="post-body">
40 <?php
41 $boxes_by_methods = array(
42 'diagnostics_box' => __('Diagnostics'),
43 'updates_box' => __('Updates'),
44 );
45
46 foreach ($boxes_by_methods as $method => $title) :
47 fwp_add_meta_box(
48 /*id=*/ 'feedwordpress_'.$method,
49 /*title=*/ $title,
50 /*callback=*/ array('FeedWordPressDiagnosticsPage', $method),
51 /*page=*/ $this->meta_box_context(),
52 /*context=*/ $this->meta_box_context()
53 );
54 endforeach;
55 do_action('feedwordpress_admin_page_diagnostics_meta_boxes', $this);
56 ?>
57 <div class="metabox-holder">
58 <?php
59 fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this);
60 ?>
61 </div> <!-- class="metabox-holder" -->
62 </div> <!-- id="post-body" -->
63
64 <?php
65 $this->close_sheet();
66 } /* FeedWordPressDiagnosticsPage::display () */
67
68 function accept_POST ($post) {
69 if (isset($post['submit'])
70 or isset($post['save'])) :
71 update_option('feedwordpress_update_logging', $post['update_logging']);
72 update_option('feedwordpress_debug', $post['feedwordpress_debug']);
73
74 if (!isset($post['diagnostics_output'])
75 or !is_array($post['diagnostics_output'])) :
76 $post['diagnostics_output'] = array();
77 endif;
78 update_option('feedwordpress_diagnostics_output', $post['diagnostics_output']);
79
80 if (!isset($post['diagnostics_show'])
81 or !is_array($post['diagnostics_show'])) :
82 $post['diagnostics_show'] = array();
83 endif;
84 update_option('feedwordpress_diagnostics_show', $post['diagnostics_show']);
85
86 $this->updated = true; // Default update message
87 endif;
88 } /* FeedWordPressDiagnosticsPage::accept_POST () */
89
90 /*static*/ function diagnostics_box ($page, $box = NULL) {
91 $settings = array();
92 $settings['update_logging'] = (get_option('feedwordpress_update_logging')=='yes');
93 $settings['debug'] = (get_option('feedwordpress_debug')=='yes');
94
95 $diagnostics_output = get_option('feedwordpress_diagnostics_output', array());
96
97 // Hey ho, let's go...
98 ?>
99 <table class="editform" width="100%" cellspacing="2" cellpadding="5">
100 <tr style="vertical-align: top">
101 <th width="33%" scope="row">Logging:</th>
102 <td width="67%"><select name="update_logging" size="1">
103 <option value="yes"<?php echo ($settings['update_logging'] ?' selected="selected"':''); ?>>log updates, new posts, and updated posts in PHP logs</option>
104 <option value="no"<?php echo ($settings['update_logging'] ?'':' selected="selected"'); ?>>don't log updates</option>
105 </select></td>
106 </tr>
107 <tr style="vertical-align: top">
108 <th width="33%" scope="row">Debugging mode:</th>
109 <td width="67%"><select name="feedwordpress_debug" size="1">
110 <option value="yes"<?php echo ($settings['debug'] ? ' selected="selected"' : ''); ?>>on</option>
111 <option value="no"<?php echo ($settings['debug'] ? '' : ' selected="selected"'); ?>>off</option>
112 </select>
113 <p>When debugging mode is <strong>ON</strong>, FeedWordPress displays many diagnostic error messages,
114 warnings, and notices that are ordinarily suppressed, and turns off all caching of feeds. Use with
115 caution: this setting is absolutely inappropriate for a production server.</p>
116 </td>
117 </tr>
118 <tr style="vertical-align: top">
119 <th width="33%" scope="row">Diagnostics output:</th>
120 <td width="67%"><ul class="options">
121 <li><input type="checkbox" name="diagnostics_output[]" value="error_log" <?php print (in_array('error_log', $diagnostics_output) ? ' checked="checked"' : ''); ?> /> Log in PHP error logs</label></li>
122 <li><input type="checkbox" name="diagnostics_output[]" value="admin_footer" <?php print (in_array('admin_footer', $diagnostics_output) ? ' checked="checked"' : ''); ?> /> Display in WordPress admin footer</label></li>
123 <li><input type="checkbox" name="diagnostics_output[]" value="echo" <?php print (in_array('echo', $diagnostics_output) ? ' checked="checked"' : ''); ?> /> Echo in web browser as they are issued</label></li>
124 </ul></td>
125 </tr>
126 </table>
127 <?php
128 } /* FeedWordPressDiagnosticsPage::diagnostics_box () */
129
130 /*static*/ function updates_box ($page, $box = NULL) {
131 $checked = array(
132 'updated_feeds' => '',
133 "syndicated_posts" => '', 'syndicated_posts:meta_data' => '',
134 'feed_items' => ''
135 );
136
137 $diagnostics_show = get_option('feedwordpress_diagnostics_show', array());
138 if (is_array($diagnostics_show)) : foreach ($diagnostics_show as $thingy) :
139 $checked[$thingy] = ' checked="checked"';
140 endforeach; endif;
141
142 // Hey ho, let's go...
143 ?>
144 <table class="editform" width="100%" cellspacing="2" cellpadding="5">
145 <tr style="vertical-align: top">
146 <th width="33%" scope="row">Update diagnostics:</th>
147 <td width="67%">
148 <p>Show a diagnostic message...</p>
149 <ul class="options">
150 <li><label><input type="checkbox" name="diagnostics_show[]" value="updated_feeds" <?php print $checked['updated_feeds']; ?> /> as each feed checked for updates</label></li>
151 <li><label><input type="checkbox" name="diagnostics_show[]" value="syndicated_posts" <?php print $checked['syndicated_posts']; ?> /> as each syndicated post is added to the database</label></li>
152 <li><label><input type="checkbox" name="diagnostics_show[]" value="feed_items" <?php print $checked['feed_items']; ?> /> as each syndicated item is considered on the feed</label></li>
153 </ul></td>
154 </tr>
155 <tr style="vertical-align: top">
156 <th width="33%" scope="row">Syndicated post details:</th>
157 <td><p>Show a diagnostic message...</p>
158 <ul class="options">
159 <li><label><input type="checkbox" name="diagnostics_show[]" value="syndicated_posts:meta_data" <?php print $checked['syndicated_posts:meta_data']; ?> /> as syndication meta-data is added on the post</label></li>
160 </ul></td>
161 </tr>
162 </table>
163 <?php
164 } /* FeedWordPressDiagnosticsPage::updates_box () */
165 } /* class FeedWordPressDiagnosticsPage */
166
167 $diagnosticsPage = new FeedWordPressDiagnosticsPage;
168 $diagnosticsPage->display();
169
170