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