PluginProbe
FeedWordPress / 2020.0118
FeedWordPress v2020.0118
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
← All changes | diagnostics-page.php +119 -183 trunk2020.0118 View file →
@@ -1,7 +1,6 @@
1 1 <?php
2 2 require_once(dirname(__FILE__) . '/admin-ui.php');
3 -require_once(dirname(__FILE__) . '/magpiemocklink.class.php');
4 3
5 4 class FeedWordPressDiagnosticsPage extends FeedWordPressAdminPage {
6 5 public function __construct() {
7 6 // Set meta-box context name
@@ -24,10 +23,10 @@
24 23 // If this is a POST, validate source and user credentials
25 24 FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_diagnostics', /*capability=*/ 'manage_options');
26 25
27 26 if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') :
28 - $this->accept_POST();
29 - do_action('feedwordpress_admin_page_diagnostics_save', null, $this);
27 + $this->accept_POST($_POST);
28 + do_action('feedwordpress_admin_page_diagnostics_save', $_POST, $this);
30 29 endif;
31 30
32 31 ////////////////////////////////////////////////
33 32 // Prepare settings page ///////////////////////
@@ -41,9 +40,9 @@
41 40 <?php
42 41 $boxes_by_methods = array(
43 42 'info_box' => __('Diagnostic Information'),
44 43 'diagnostics_box' => __('Display Diagnostics'),
45 - 'updates_box' => __('Diagnostic Messages'),
44 + 'updates_box' => __('Updates'),
46 45 'tests_box' => __('Diagnostic Tests'),
47 46 );
48 47
49 48 foreach ($boxes_by_methods as $method => $title) :
@@ -67,46 +66,48 @@
67 66 <?php
68 67 $this->close_sheet();
69 68 } /* FeedWordPressDiagnosticsPage::display () */
70 69
71 - public function do_requested () {
72 - return ( ! is_null( self::what_requested() ) );
73 - }
70 + function accept_POST ($post) {
71 + if (isset($post['submit'])
72 + or isset($post['save'])
73 + or isset($post['feedwordpress_diagnostics_do'])) :
74 + update_option('feedwordpress_debug', $post['feedwordpress_debug']);
75 + update_option('feedwordpress_secret_key', $post['feedwordpress_secret_key']);
74 76
75 - public function what_requested () {
76 - return FeedWordPress::post( 'feedwordpress_diagnostics_do' );
77 - }
77 + if (!isset($post['diagnostics_output'])
78 + or !is_array($post['diagnostics_output'])) :
79 + $post['diagnostics_output'] = array();
80 + endif;
81 + update_option('feedwordpress_diagnostics_output', $post['diagnostics_output']);
78 82
79 - function accept_POST () {
80 - if ( self::save_requested() || self::do_requested() ) :
83 + if (!isset($post['diagnostics_show'])
84 + or !is_array($post['diagnostics_show'])) :
85 + $post['diagnostics_show'] = array();
86 + endif;
87 + update_option('feedwordpress_diagnostics_show', $post['diagnostics_show']);
81 88
82 - update_option( 'feedwordpress_debug', FeedWordPress::post( 'feedwordpress_debug' ) );
83 - update_option( 'feedwordpress_secret_key', FeedWordPress::post( 'feedwordpress_secret_key' ) );
84 -
85 - update_option( 'feedwordpress_diagnostics_output', FeedWordPress::post( 'diagnostics_output' ) );
86 - update_option( 'feedwordpress_diagnostics_show', FeedWordPress::post( 'diagnostics_show' ) );
87 -
88 - if ( FeedWordPress::post( 'diagnostics_show' )
89 - and in_array( 'updated_feeds:errors:persistent', FeedWordPress::post( 'diagnostics_show' ) ) ) :
90 - update_option('feedwordpress_diagnostics_persistent_errors_hours', (int) FeedWordPress::post( 'diagnostics_persistent_error_hours' ) );
89 + if ($post['diagnostics_show']
90 + and in_array('updated_feeds:errors:persistent', $post['diagnostics_show'])) :
91 + update_option('feedwordpress_diagnostics_persistent_errors_hours', (int) $post['diagnostics_persistent_error_hours']);
91 92 else :
92 - delete_option( 'feedwordpress_diagnostics_persistent_errors_hours' );
93 + delete_option('feedwordpress_diagnostics_persistent_errors_hours');
93 94 endif;
94 95
95 - if ( in_array( 'email', FeedWordPress::post( 'diagnostics_output' ) ) ) :
96 - $ded = FeedWordPress::post('diagnostics_email_destination' );
97 - if ( 'mailto' == $ded ) :
98 - $ded .= ':' . FeedWordPress::post('diagnostics_email_destination_address' );
96 + if (in_array('email', $post['diagnostics_output'])) :
97 + $ded = $post['diagnostics_email_destination'];
98 + if ('mailto'==$ded) :
99 + $ded .= ':'.$post['diagnostics_email_destination_address'];
99 100 endif;
100 101
101 - update_option( 'feedwordpress_diagnostics_email_destination', $ded );
102 + update_option('feedwordpress_diagnostics_email_destination', $ded);
102 103 else :
103 - delete_option( 'feedwordpress_diagnostics_email_destination' );
104 + delete_option('feedwordpress_diagnostics_email_destination');
104 105 endif;
105 106
106 - if ( self::do_requested() ) :
107 - foreach ( self::what_requested() as $do => $value) :
108 - do_action( 'feedwordpress_diagnostics_do_'.$do );
107 + if (isset($post['feedwordpress_diagnostics_do'])) :
108 + foreach ($post['feedwordpress_diagnostics_do'] as $do => $value) :
109 + do_action('feedwordpress_diagnostics_do_'.$do, $post);
109 110 endforeach;
110 111 endif;
111 112
112 113 $this->updated = true; // Default update message
@@ -125,49 +126,47 @@
125 126 </thead>
126 127
127 128 <tbody>
128 129 <tr>
129 - <th scope="row"><?php esc_html_e( 'Version:' ); ?></th>
130 - <td><?php esc_html_e( 'You are using FeedWordPress version' ); ?> <strong><?php print esc_html( FEEDWORDPRESS_VERSION ); ?></strong>.</td>
130 + <th scope="row">Version:</th>
131 + <td>You are using FeedWordPress version <strong><?php print FEEDWORDPRESS_VERSION; ?></strong>.</td>
131 132 </tr>
132 133
133 134 <tr>
134 - <th scope="row"><?php esc_html_e( 'Hosting Environment:' ); ?></th>
135 + <th scope="row">Hosting Environment:</th>
135 136 <td><ul style="margin-top: 0; padding-top: 0;">
136 - <li><em>WordPress:</em> <?php esc_html_e( 'version' ); ?> <?php print esc_html( $wp_version ); ?></li>
137 - <li><em>SimplePie:</em> <?php esc_html_e( 'version' ); ?> <?php print esc_html( SIMPLEPIE_VERSION ); ?></li>
138 - <?php if ( function_exists( 'phpversion' ) ) : ?>
139 - <li><em><?php esc_html_e( 'PHP:' ); ?></em> <?php esc_html_e( 'version' ); ?> <?php print esc_html( phpversion() ); ?></li>
137 + <li><em>WordPress:</em> version <?php print $wp_version; ?></li>
138 + <?php if (function_exists('phpversion')) : ?>
139 + <li><em>PHP:</em> version <?php print phpversion(); ?></li>
140 140 <?php endif; ?>
141 - <?php if ( function_exists( 'apache_get_version' ) ) : ?>
142 - <li><em><?php esc_html_e( 'Web Server:' ); ?></em> <?php print esc_html( apache_get_version() ); ?></li>
141 + <?php if (function_exists('apache_get_version')) : ?>
142 + <li><sem>Web Server:</em> <?php print apache_get_version(); ?></li>
143 143 <?php endif; ?>
144 - <?php if ( ! empty( $_SERVER['SERVER_SIGNATURE'] ) ) : ?>
145 - <li><em><?php esc_html_e( 'Web Server signature:' ); ?></em> <?php print esc_html( $_SERVER['SERVER_SIGNATURE'] ); ?></li>
146 - <?php endif; ?>
147 - <li><em><?php esc_html_e( 'Hosted on:' ); ?></em> <?php print esc_html( php_uname( 'a' ) ); ?></li>
148 144 </ul>
149 145 </td>
150 146 </tr>
151 147
152 148 <tr>
153 - <th scope="row"><?php esc_html_e( 'Link Category:' ); ?></th>
154 - <td><?php if ( ! is_wp_error( $link_category_id ) ) :
155 - $term = get_term( $link_category_id, 'link_category' );
156 - ?><p><?php esc_html_e( 'Syndicated feeds are kept in link category' ); ?> #<?php print esc_html( $term->term_id ); ?>, <strong><?php print esc_html( $term->name ); ?></strong>.</p>
149 + <th scope="row">Link Category:</th>
150 + <td><?php if (!is_wp_error($link_category_id)) :
151 + $term = get_term($link_category_id, 'link_category');
152 + ?><p>Syndicated feeds are
153 + kept in link category #<?php print $term->term_id; ?>, <strong><?php print $term->name; ?></strong>.</p>
157 154 <?php else : ?>
158 - <p><strong><?php esc_html_e( 'FeedWordPress has been unable to set up a valid Link Category for syndicated feeds.' ); ?></strong> <?php esc_html_e( 'Attempting to set one up returned an' ); ?>
159 - <code><?php $link_category_id->get_error_code(); ?></code> <?php esc_html_e( 'error with this additional data:' ); ?></p>
155 + <p><strong>FeedWordPress has been unable to set up a valid Link Category
156 + for syndicated feeds.</strong> Attempting to set one up returned an
157 + <code><?php $link_category_id->get_error_code(); ?></code> error with this
158 + additional data:</p>
160 159 <table>
161 160 <tbody>
162 161 <tr>
163 - <th scope="row"><?php esc_html_e( 'Message:' ); ?></th>
164 - <td><?php print esc_html( $link_category_id->get_error_message() ); ?></td>
162 + <th scope="row">Message:</th>
163 + <td><?php print $link_category_id->get_error_message(); ?></td>
165 164 </tr>
166 - <?php $data = $link_category_id->get_error_data(); if ( ! empty( $data ) ) : ?>
165 + <?php $data = $link_category_id->get_error_data(); if (!empty($data)) : ?>
167 166 <tr>
168 - <th scope="row"><?php esc_html_e( 'Auxiliary Data:' ); ?></th>
169 - <td><pre><?php print esc_html( MyPHP::val( $link_category_id->get_error_data() ) ); ?></pre></td>
167 + <th scope="row">Auxiliary Data:</th>
168 + <td><pre><?php print esc_html(MyPHP::val($link_category_id->get_error_data())); ?></pre></td>
170 169 </tr>
171 170 <?php endif; ?>
172 171 </table>
173 172 <?php endif; ?></td>
@@ -173,11 +172,13 @@
173 172 <?php endif; ?></td>
174 173 </tr>
175 174
176 175 <tr>
177 - <th scope="row"><?php esc_html_e('Secret Key:'); ?></th>
178 - <td><input type="text" name="feedwordpress_secret_key" value="<?php print esc_attr( $feedwordpress->secret_key() ); ?>" />
179 - <p class="setting-description"><?php esc_html_e( 'This is used to control access to some diagnostic testing functions. You can change it to any string you want, but only tell it to people you trust to help you troubleshoot your FeedWordPress installation. Keep it secret&mdash;keep it safe.' ); ?></p></td>
176 + <th scope="row"><?php _e('Secret Key:'); ?></th>
177 + <td><input type="text" name="feedwordpress_secret_key" value="<?php print esc_attr($feedwordpress->secret_key()); ?>" />
178 + <p class="setting-description">This is used to control access to some diagnostic testing functions. You can change it to any string you want,
179 + but only tell it to people you trust to help you troubleshoot your
180 + FeedWordPress installation. Keep it secret&#8212;keep it safe.</p></td>
180 181 </tr>
181 182 </table>
182 183
183 184 <?php
@@ -182,22 +183,19 @@
182 183
183 184 <?php
184 185 } /* FeedWordPressDiagnosticsPage::info_box () */
185 186
186 - static function diagnostics_box( $page, $box = NULL ) {
187 + static function diagnostics_box ($page, $box = NULL) {
187 188 $settings = array();
188 - $settings['debug'] = ( get_option( 'feedwordpress_debug' ) == 'yes' );
189 + $settings['debug'] = (get_option('feedwordpress_debug')=='yes');
189 190
190 - $diagnostics_output = get_option( 'feedwordpress_diagnostics_output', array() );
191 - if ( ! is_array( $diagnostics_output ) ) {
192 - $diagnostics_output = array( $diagnostics_output );
193 - }
194 -
191 + $diagnostics_output = get_option('feedwordpress_diagnostics_output', array());
192 +
195 193 $users = fwp_author_list();
196 194
197 - $ded = get_option( 'feedwordpress_diagnostics_email_destination', 'admins' );
195 + $ded = get_option('feedwordpress_diagnostics_email_destination', 'admins');
198 196
199 - if (preg_match( '/^mailto:(.*)$/', $ded, $ref ) ) :
197 + if (preg_match('/^mailto:(.*)$/', $ded, $ref)) :
200 198 $ded_addy = $ref[1];
201 199 else :
202 200 $ded_addy = NULL;
203 201 endif;
@@ -205,18 +203,18 @@
205 203 // Hey ho, let's go...
206 204 ?>
207 205 <table class="edit-form">
208 206 <tr style="vertical-align: top">
209 -<th scope="row"><?php esc_html_e( 'Debugging mode:' ); ?></th>
207 +<th scope="row">Debugging mode:</th>
210 208 <td><select name="feedwordpress_debug" size="1">
211 -<option value="yes"<?php echo ( $settings['debug'] ? ' selected="selected"' : '' ); ?>><?php esc_html_e( 'on' ); ?></option>
212 -<option value="no"<?php echo ( $settings['debug'] ? '' : ' selected="selected"' ); ?>><?php esc_html_e( 'off' ); ?></option>
209 +<option value="yes"<?php echo ($settings['debug'] ? ' selected="selected"' : ''); ?>>on</option>
210 +<option value="no"<?php echo ($settings['debug'] ? '' : ' selected="selected"'); ?>>off</option>
213 211 </select>
214 212
215 -<p><?php esc_html_e( 'When debugging mode is <strong>ON</strong>, FeedWordPress displays many
213 +<p>When debugging mode is <strong>ON</strong>, FeedWordPress displays many
216 214 diagnostic error messages, warnings, and notices that are ordinarily suppressed,
217 215 and turns off all caching of feeds. Use with caution: this setting is useful for
218 -testing but absolutely inappropriate for a production server.' ); ?></p>
216 +testing but absolutely inappropriate for a production server.</p>
219 217
220 218 </td>
221 219 </tr>
222 220 <tr>
@@ -221,20 +219,20 @@
221 219 </tr>
222 220 <tr>
223 221 <th scope="row">Diagnostics output:</th>
224 222 <td><ul class="options">
225 -<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>
223 +<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>
226 224 <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>
227 225 <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>
228 226 <li><input type="checkbox" name="diagnostics_output[]" value="echo_in_cronjob" <?php print (in_array('echo_in_cronjob', $diagnostics_output) ? ' checked="checked"' : ''); ?> /> Echo to output when they are issued during an update cron job</label></li>
229 227 <li><input type="checkbox" name="diagnostics_output[]" value="email" <?php print (in_array('email', $diagnostics_output) ? ' checked="checked"' : ''); ?> /> Send a daily email digest to:</label> <select name="diagnostics_email_destination" id="diagnostics-email-destination" size="1">
230 -<option value="admins"<?php if ( 'admins' == $ded ) : ?> selected="selected"<?php endif; ?>>the site administrators</option>
228 +<option value="admins"<?php if ('admins'==$ded) : ?> selected="selected"<?php endif; ?>>the site administrators</option>
231 229 <?php foreach ($users as $id => $name) : ?>
232 230 <option value="user:<?php print (int) $id; ?>"<?php if (sprintf('user:%d', (int) $id)==$ded) : ?> selected="selected"<?php endif; ?>><?php print esc_html($name); ?></option>
233 231 <?php endforeach; ?>
234 -<option value="mailto"<?php if ( !is_null($ded_addy)) : ?> selected="selected"<?php endif; ?>>another e-mail address...</option>
232 +<option value="mailto"<?php if (!is_null($ded_addy)) : ?> selected="selected"<?php endif; ?>>another e-mail address...</option>
235 233 </select>
236 -<input type="email" id="diagnostics-email-destination-address" name="diagnostics_email_destination_address" value="<?php print esc_attr( $ded_addy ); ?>" placeholder="email address" /></li>
234 +<input type="email" id="diagnostics-email-destination-address" name="diagnostics_email_destination_address" value="<?php print $ded_addy; ?>" placeholder="email address" /></li>
237 235 </ul></td>
238 236 </tr>
239 237 </table>
240 238
@@ -245,9 +243,9 @@
245 243 'diagnostics-email-destination-default',
246 244 'mailto',
247 245 'inline'
248 246 );
249 - jQuery( '#diagnostics-email-destination' ).change ( function () {
247 + jQuery('#diagnostics-email-destination').change ( function () {
250 248 contextual_appearance(
251 249 'diagnostics-email-destination',
252 250 'diagnostics-email-destination-address',
253 251 'diagnostics-email-destination-default',
@@ -258,38 +256,26 @@
258 256 </script>
259 257 <?php
260 258 } /* FeedWordPressDiagnosticsPage::diagnostics_box () */
261 259
262 - /**
263 - * Shows the box for the many possible update options.
264 - *
265 - * @param type $page description
266 - * @param type $box description
267 - *
268 - * @return void description
269 - */
270 260 static function updates_box ($page, $box = NULL) {
271 - $hours = get_option( 'feedwordpress_diagnostics_persistent_errors_hours', 2 );
272 - $fields = apply_filters( 'feedwordpress_diagnostics', array(
261 + $hours = get_option('feedwordpress_diagnostics_persistent_errors_hours', 2);
262 + $fields = apply_filters('feedwordpress_diagnostics', array(
273 263 'Update Diagnostics' => array(
274 264 'update_schedule:check' => 'whenever a FeedWordPress checks in on the update schedule',
275 265 'updated_feeds' => 'as each feed is checked for updates',
266 + 'updated_feeds:errors:persistent' => 'when attempts to update a feed have resulted in errors</label> <label>for at least <input type="number" min="1" max="360" step="1" name="diagnostics_persistent_error_hours" value="'.$hours.'" /> hours',
267 + 'updated_feeds:errors' => 'any time FeedWordPress encounters any errors while checking a feed for updates',
268 + 'updated_feeds:http' => "displaying the raw HTTP data passed to and from the feed being checked for updates",
276 269 'syndicated_posts' => 'as each syndicated post is added to the database',
277 270 'feed_items' => 'as each syndicated item is considered on the feed',
278 271 'memory_usage' => 'indicating how much memory was used',
279 272 ),
280 - // Note: the embedded HTML gets filtered out, so this might require some refactoring. (gwyneth 20230917)
281 - 'Feed Retrieval' => array(
282 - 'updated_feeds:errors:persistent' => 'when attempts to update a feed have resulted in errors</label> <label>for at least <input type="number" min="1" max="360" step="1" name="diagnostics_persistent_error_hours" value="'.$hours.'" /> hours',
283 - 'updated_feeds:errors' => 'any time FeedWordPress encounters any errors while checking a feed for updates',
284 - 'updated_feeds:http' => "displaying the raw HTTP data passed to and from the feed being checked for updates",
285 - ),
286 273 'Syndicated Post Details' => array(
287 274 'feed_items:freshness' => 'as FeedWordPress decides whether to treat an item as a new post, an update, or a duplicate of an existing post',
288 275 'feed_items:rejected' => 'when FeedWordPress rejects a post without syndicating it',
289 276 'syndicated_posts:categories' => 'as categories, tags, and other terms are added on the post',
290 277 'syndicated_posts:meta_data' => 'as syndication meta-data is added on the post',
291 - 'syndicated_posts:do_pings' => 'when FeedWordPress holds or releases the pings WordPress sends out when new posts are created',
292 278 ),
293 279 'Advanced Diagnostics' => array(
294 280 'feed_items:freshness:reasons' => 'explaining the reason that a post was treated as an update to an existing post',
295 281 'feed_items:freshness:sql' => 'when FeedWordPress issues the SQL query it uses to decide whether to treat items as new, updates, or duplicates',
@@ -295,18 +281,18 @@
295 281 'feed_items:freshness:sql' => 'when FeedWordPress issues the SQL query it uses to decide whether to treat items as new, updates, or duplicates',
296 282 'syndicated_posts:categories:test' => 'as FeedWordPress checks for the familiarity of feed categories and tags',
297 283 'syndicated_posts:static_meta_data' => 'providing meta-data about syndicated posts in the Edit Posts interface',
298 284 ),
299 - ), $page );
285 + ), $page);
300 286
301 - foreach ( $fields as $section => $items ) :
302 - foreach ( $items as $key => $label ) :
287 + foreach ($fields as $section => $items) :
288 + foreach ($items as $key => $label) :
303 289 $checked[$key] = '';
304 290 endforeach;
305 291 endforeach;
306 292
307 - $diagnostics_show = get_option( 'feedwordpress_diagnostics_show', array() );
308 - if ( is_array( $diagnostics_show ) ) : foreach ( $diagnostics_show as $thingy ) :
293 + $diagnostics_show = get_option('feedwordpress_diagnostics_show', array());
294 + if (is_array($diagnostics_show)) : foreach ($diagnostics_show as $thingy) :
309 295 $checked[$thingy] = ' checked="checked"';
310 296 endforeach; endif;
311 297
312 298 // Hey ho, let's go...
@@ -314,16 +300,16 @@
314 300 <table class="edit-form">
315 301 <?php foreach ($fields as $section => $ul) : ?>
316 302 <tr>
317 303 <th scope="row"><?php print esc_html($section); ?>:</th>
318 - <td><p><?php esc_html_e( 'Show a diagnostic message...' ); ?></p>
304 + <td><p>Show a diagnostic message...</p>
319 305 <ul class="options">
320 306 <?php foreach ($ul as $key => $label) : ?>
321 307 <li><label><input
322 308 type="checkbox" name="diagnostics_show[]"
323 - value="<?php print esc_html( $key ); ?>"
324 - <?php fwp_selected_flag( $checked, $key, "checked" ); ?> />
325 - <?php print esc_html( $label ); ?></label></li>
309 + value="<?php print esc_html($key); ?>"
310 + <?php print $checked[$key]; ?> />
311 + <?php print $label; ?></label></li>
326 312 <?php endforeach; ?>
327 313 </ul></td>
328 314 </tr>
329 315 <?php endforeach; ?>
@@ -331,17 +317,8 @@
331 317 <?php
332 318 } /* FeedWordPressDiagnosticsPage::updates_box () */
333 319
334 320 static function tests_box ($page, $box = NULL) {
335 - $url = FeedWordPress::param( 'http_test_url' );
336 - $method = FeedWordPress::param( 'http_test_method' );
337 - $xpath = FeedWordPress::param( 'http_test_xpath' );
338 -
339 - $aMethods = array(
340 - 'wp_remote_request',
341 - 'FeedWordPie_File',
342 - 'FeedWordPress::fetch',
343 - );
344 321 ?>
345 322 <script type="text/javascript">
346 323 function clone_http_test_args_keyvalue_prototype () {
347 324 var next = jQuery('#http-test-args').find('.http-test-args-keyvalue').length;
@@ -356,34 +333,25 @@
356 333
357 334 <table class="edit-form">
358 335 <tr>
359 336 <th scope="row">HTTP:</th>
360 - <td><div><input type="url" name="http_test_url" value="<?php print esc_attr($url);?>" placeholder="http://www.example.com/" size="127" style="width: 80%; max-width: 80.0em;" />
337 + <td><div><input type="url" name="http_test_url" value="" placeholder="http://www.example.com/" size="127" style="width: 80%; max-width: 80.0em;" />
361 338 <input type="submit" name="feedwordpress_diagnostics_do[http_test]" value="Test &raquo;" /></div>
362 339 <div><select name="http_test_method" size="1">
363 - <?php foreach ($aMethods as $sMethod) :?>
364 - <option value="<?php
365 - print esc_attr($sMethod);
366 - ?>"<?php
367 - if ($method==$sMethod) :
368 - print ' selected="selected"';
369 - endif;
370 - ?>><?php
371 - print esc_html( $sMethod );
372 - ?></option>
373 - <?php endforeach; ?>
340 + <option value="wp_remote_request">wp_remote_request</option>
341 + <option value="FeedWordPress_File">FeedWordPress_File</option>
374 342 </select></div>
375 343 <table>
376 344 <tr>
377 345 <td>
378 346 <div id="http-test-args">
379 - <div id="http-test-args-keyvalue-prototype" class="http-test-args-keyvalue"><label><?php esc_html_e( 'Args' ); ?>:
347 + <div id="http-test-args-keyvalue-prototype" class="http-test-args-keyvalue"><label>Args:
380 348 <input type="text" class='http_test_args_key' name="http_test_args_key[0]" value="" placeholder="key" /></label>
381 349 <label>= <input type="text" class='http_test_args_value' name="http_test_args_value[0]" value="" placeholder="value" /></label>
382 350 </div>
383 351 </div>
384 352 </td>
385 - <td><a href="#http-test-args" onclick="return clone_http_test_args_keyvalue_prototype();"><span class="dashicons dashicons-plus fwp-no-underline"></span> <?php esc_html_e( 'Add' ); ?></a></td>
353 + <td><a href="#http-test-args" onclick="return clone_http_test_args_keyvalue_prototype();">+ Add</a></td>
386 354 </tr>
387 355 </table>
388 356 </td>
389 357 </tr>
@@ -389,21 +357,21 @@
389 357 </tr>
390 358
391 359 <tr>
392 360 <th>XPath:</th>
393 - <td><div><input type="text" name="http_test_xpath" value="<?php print esc_attr($xpath); ?>" placeholder="xpath-like query" /></div>
394 - <div><p><?php esc_html_e( 'Leave blank to test HTTP, fill in to test a query.' ); ?></p></div>
361 + <td><div><input type="text" name="http_test_xpath" value="" placeholder="xpath-like query" /></div>
362 + <div><p>Leave blank to test HTTP, fill in to test a query.</p></div>
395 363 </td>
396 364 </tr>
397 -
365 +
398 366 <?php if (isset($page->test_html['http_test'])) : ?>
399 367 <tr>
400 - <th scope="row"><?php esc_html_e( 'RESULTS:' ); ?></th>
368 + <th scope="row">RESULTS:</th>
401 369 <td>
402 370 <div>URL: <code><?php print esc_html($page->test_html['url']); ?></code></div>
403 371 <div style="position: relative">
404 372 <div style="width: 100%; overflow: scroll; background-color: #eed">
405 - <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -o-pre-wrap;"><?php print esc_html($page->test_html['http_test']); ?></pre>
373 + <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -o-pre-wrap;"><?php print $page->test_html['http_test']; ?></pre>
406 374 </div>
407 375 </div>
408 376 </td>
409 377 </tr>
@@ -413,80 +381,48 @@
413 381 <?php
414 382 } /* FeedWordPressDiagnosticsPage::tests_box () */
415 383
416 384 private $test_html;
417 - public function do_http_test () {
418 - $url = FeedWordPress::post( 'http_test_url' );
419 - $method = FeedWordPress::post( 'http_test_method' );
420 - if ( ! ( is_null( $url ) || is_null( $method ) ) ) :
385 + public function do_http_test ($post) {
386 + if (isset($post['http_test_url']) and isset($post['http_test_method'])) :
387 + $url = $post['http_test_url'];
421 388
422 389 $args = array();
423 - $keys = FeedWordPress::post( 'http_test_args_key' );
424 - if ( ! is_null( $keys ) ) :
425 - foreach ( $keys as $idx => $name ) :
390 + if (isset($post['http_test_args_key'])) :
391 + foreach ($post['http_test_args_key'] as $idx => $name) :
426 392 $name = trim($name);
427 393 if (strlen($name) > 0) :
428 - $values = FeedWordPress::post('http_test_args_value', array() );
429 -
430 - $value = null;
431 - if ( isset( $values[ $idx ] ) ) :
432 - $value = $values[$idx];
394 + $value = NULL;
395 + if (isset($post['http_test_args_value'])
396 + and isset($post['http_test_args_value'][$idx])) :
397 + $value = $post['http_test_args_value'][$idx];
433 398 endif;
434 399
435 - if ( preg_match('/^javascript:(.*)$/i', $value, $refs) ) :
436 - if ( function_exists('json_decode') ) :
437 - $json_value = json_decode( $refs[1] );
438 - if ( ! is_null($json_value) ) :
400 + if (preg_match('/^javascript:(.*)$/i', $value, $refs)) :
401 + if (function_exists('json_decode')) :
402 + $json_value = json_decode($refs[1]);
403 + if (!is_null($json_value)) :
439 404 $value = $json_value;
440 405 endif;
441 406 endif;
442 407 endif;
443 408
444 - $args[ $name ] = $value;
409 + $args[$name] = $value;
445 410 endif;
446 411 endforeach;
447 412 endif;
448 413
449 - switch ( $method ) :
414 + switch ($post['http_test_method']) :
450 415 case 'wp_remote_request' :
451 416 $out = wp_remote_request($url, $args);
452 - unset( $out[ 'http_response' ] );
453 417 break;
454 - case 'FeedWordPie_File' :
455 - $out = new FeedWordPie_File($url);
418 + case 'FeedWordPress_File' :
419 + $out = new FeedWordPress_File($url);
456 420 break;
457 - case 'FeedWordPress::fetch' :
458 - $out = FeedWordPress::fetch($url);
459 -
460 - $s_xpath = FeedWordPress::post( 'http_test_xpath', '' );
461 - if ( strlen( $s_xpath ) > 0 ) :
462 -
463 - $xpath = FeedWordPress::post( 'http_test_xpath' );
464 -
465 - if ( !is_wp_error($out) ) :
466 - $expr = new FeedWordPressParsedPostMeta($xpath);
467 -
468 - $feed = new MagpieMockLink( $out, $url );
469 - $posts = $feed->live_posts();
470 -
471 - $post = new SyndicatedPost($posts[0], $feed);
472 - $meta = $expr->do_substitutions($post);
473 -
474 - $out = array(
475 - "post_title" => $post->entry->get_title(),
476 - "post_link" => $post->permalink(),
477 - "guid" => $post->guid(),
478 - "expression" => $xpath,
479 - "results" => $meta,
480 - "pie" => $out,
481 - );
482 - endif;
483 - endif;
484 - break;
485 421 endswitch;
486 -
487 - $this->test_html['url'] = $url;
488 - $this->test_html['http_test'] = esc_html( MyPHP::val($out) );
422 +
423 + $this->test_html['url'] = $url;
424 + $this->test_html['http_test'] = esc_html(MyPHP::val($out));
489 425 endif;
490 426 } /* FeedWordPressDiagnosticsPage::do_http_test () */
491 427
492 428 } /* class FeedWordPressDiagnosticsPage */