| 1 |
<?php |
| 2 |
require_once(dirname(__FILE__) . '/admin-ui.php'); |
| 3 |
require_once(dirname(__FILE__) . '/magpiemocklink.class.php'); |
| 4 |
|
| 5 |
class FeedWordPressDiagnosticsPage extends FeedWordPressAdminPage { |
| 6 |
public function __construct() { |
| 7 |
// Set meta-box context name |
| 8 |
parent::__construct('feedwordpressdiagnosticspage'); |
| 9 |
$this->dispatch = 'feedwordpress_diagnostics'; |
| 10 |
$this->filename = __FILE__; |
| 11 |
|
| 12 |
$this->test_html = array(); |
| 13 |
add_action('feedwordpress_diagnostics_do_http_test', array($this, 'do_http_test'), 10, 1); |
| 14 |
} |
| 15 |
|
| 16 |
function has_link () { return false; } |
| 17 |
|
| 18 |
function display () { |
| 19 |
if (FeedWordPress::needs_upgrade()) : |
| 20 |
fwp_upgrade_page(); |
| 21 |
return; |
| 22 |
endif; |
| 23 |
|
| 24 |
// If this is a POST, validate source and user credentials |
| 25 |
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_diagnostics', /*capability=*/ 'manage_options'); |
| 26 |
|
| 27 |
if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') : |
| 28 |
$this->accept_POST($_POST); |
| 29 |
do_action('feedwordpress_admin_page_diagnostics_save', $_POST, $this); |
| 30 |
endif; |
| 31 |
|
| 32 |
//////////////////////////////////////////////// |
| 33 |
// Prepare settings page /////////////////////// |
| 34 |
//////////////////////////////////////////////// |
| 35 |
|
| 36 |
$this->display_update_notice_if_updated('Diagnostics'); |
| 37 |
|
| 38 |
$this->open_sheet('FeedWordPress Diagnostics'); |
| 39 |
?> |
| 40 |
<div id="post-body"> |
| 41 |
<?php |
| 42 |
$boxes_by_methods = array( |
| 43 |
'info_box' => __('Diagnostic Information'), |
| 44 |
'diagnostics_box' => __('Display Diagnostics'), |
| 45 |
'updates_box' => __('Diagnostic Messages'), |
| 46 |
'tests_box' => __('Diagnostic Tests'), |
| 47 |
); |
| 48 |
|
| 49 |
foreach ($boxes_by_methods as $method => $title) : |
| 50 |
add_meta_box( |
| 51 |
/*id=*/ 'feedwordpress_'.$method, |
| 52 |
/*title=*/ $title, |
| 53 |
/*callback=*/ array('FeedWordPressDiagnosticsPage', $method), |
| 54 |
/*page=*/ $this->meta_box_context(), |
| 55 |
/*context=*/ $this->meta_box_context() |
| 56 |
); |
| 57 |
endforeach; |
| 58 |
do_action('feedwordpress_admin_page_diagnostics_meta_boxes', $this); |
| 59 |
?> |
| 60 |
<div class="metabox-holder"> |
| 61 |
<?php |
| 62 |
do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this); |
| 63 |
?> |
| 64 |
</div> <!-- class="metabox-holder" --> |
| 65 |
</div> <!-- id="post-body" --> |
| 66 |
|
| 67 |
<?php |
| 68 |
$this->close_sheet(); |
| 69 |
} /* FeedWordPressDiagnosticsPage::display () */ |
| 70 |
|
| 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']); |
| 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']); |
| 83 |
|
| 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']); |
| 89 |
|
| 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']); |
| 93 |
else : |
| 94 |
delete_option('feedwordpress_diagnostics_persistent_errors_hours'); |
| 95 |
endif; |
| 96 |
|
| 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']; |
| 101 |
endif; |
| 102 |
|
| 103 |
update_option('feedwordpress_diagnostics_email_destination', $ded); |
| 104 |
else : |
| 105 |
delete_option('feedwordpress_diagnostics_email_destination'); |
| 106 |
endif; |
| 107 |
|
| 108 |
if (isset($post['feedwordpress_diagnostics_do'])) : |
| 109 |
foreach ($post['feedwordpress_diagnostics_do'] as $do => $value) : |
| 110 |
do_action('feedwordpress_diagnostics_do_'.$do, $post); |
| 111 |
endforeach; |
| 112 |
endif; |
| 113 |
|
| 114 |
$this->updated = true; // Default update message |
| 115 |
endif; |
| 116 |
} /* FeedWordPressDiagnosticsPage::accept_POST () */ |
| 117 |
|
| 118 |
static function info_box ($page, $box = NULL) { |
| 119 |
global $feedwordpress; |
| 120 |
global $wp_version; |
| 121 |
$link_category_id = FeedWordPress::link_category_id(); |
| 122 |
?> |
| 123 |
<table class="edit-form narrow"> |
| 124 |
<thead style="display: none"> |
| 125 |
<th scope="col">Topic</th> |
| 126 |
<th scope="col">Information</th> |
| 127 |
</thead> |
| 128 |
|
| 129 |
<tbody> |
| 130 |
<tr> |
| 131 |
<th scope="row">Version:</th> |
| 132 |
<td>You are using FeedWordPress version <strong><?php print FEEDWORDPRESS_VERSION; ?></strong>.</td> |
| 133 |
</tr> |
| 134 |
|
| 135 |
<tr> |
| 136 |
<th scope="row">Hosting Environment:</th> |
| 137 |
<td><ul style="margin-top: 0; padding-top: 0;"> |
| 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> |
| 142 |
<?php endif; ?> |
| 143 |
<?php if (function_exists('apache_get_version')) : ?> |
| 144 |
<li><sem>Web Server:</em> <?php print apache_get_version(); ?></li> |
| 145 |
<?php endif; ?> |
| 146 |
</ul> |
| 147 |
</td> |
| 148 |
</tr> |
| 149 |
|
| 150 |
<tr> |
| 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> |
| 156 |
<?php else : ?> |
| 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> |
| 161 |
<table> |
| 162 |
<tbody> |
| 163 |
<tr> |
| 164 |
<th scope="row">Message:</th> |
| 165 |
<td><?php print $link_category_id->get_error_message(); ?></td> |
| 166 |
</tr> |
| 167 |
<?php $data = $link_category_id->get_error_data(); if (!empty($data)) : ?> |
| 168 |
<tr> |
| 169 |
<th scope="row">Auxiliary Data:</th> |
| 170 |
<td><pre><?php print esc_html(MyPHP::val($link_category_id->get_error_data())); ?></pre></td> |
| 171 |
</tr> |
| 172 |
<?php endif; ?> |
| 173 |
</table> |
| 174 |
<?php endif; ?></td> |
| 175 |
</tr> |
| 176 |
|
| 177 |
<tr> |
| 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—keep it safe.</p></td> |
| 183 |
</tr> |
| 184 |
</table> |
| 185 |
|
| 186 |
<?php |
| 187 |
} /* FeedWordPressDiagnosticsPage::info_box () */ |
| 188 |
|
| 189 |
static function diagnostics_box ($page, $box = NULL) { |
| 190 |
$settings = array(); |
| 191 |
$settings['debug'] = (get_option('feedwordpress_debug')=='yes'); |
| 192 |
|
| 193 |
$diagnostics_output = get_option('feedwordpress_diagnostics_output', array()); |
| 194 |
|
| 195 |
$users = fwp_author_list(); |
| 196 |
|
| 197 |
$ded = get_option('feedwordpress_diagnostics_email_destination', 'admins'); |
| 198 |
|
| 199 |
if (preg_match('/^mailto:(.*)$/', $ded, $ref)) : |
| 200 |
$ded_addy = $ref[1]; |
| 201 |
else : |
| 202 |
$ded_addy = NULL; |
| 203 |
endif; |
| 204 |
|
| 205 |
// Hey ho, let's go... |
| 206 |
?> |
| 207 |
<table class="edit-form"> |
| 208 |
<tr style="vertical-align: top"> |
| 209 |
<th scope="row">Debugging mode:</th> |
| 210 |
<td><select name="feedwordpress_debug" size="1"> |
| 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 |
</select> |
| 214 |
|
| 215 |
<p>When debugging mode is <strong>ON</strong>, FeedWordPress displays many |
| 216 |
diagnostic error messages, warnings, and notices that are ordinarily suppressed, |
| 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> |
| 219 |
|
| 220 |
</td> |
| 221 |
</tr> |
| 222 |
<tr> |
| 223 |
<th scope="row">Diagnostics output:</th> |
| 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> |
| 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 |
<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 |
<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 |
<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> |
| 231 |
<?php foreach ($users as $id => $name) : ?> |
| 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 |
<?php endforeach; ?> |
| 234 |
<option value="mailto"<?php if (!is_null($ded_addy)) : ?> selected="selected"<?php endif; ?>>another e-mail address...</option> |
| 235 |
</select> |
| 236 |
<input type="email" id="diagnostics-email-destination-address" name="diagnostics_email_destination_address" value="<?php print $ded_addy; ?>" placeholder="email address" /></li> |
| 237 |
</ul></td> |
| 238 |
</tr> |
| 239 |
</table> |
| 240 |
|
| 241 |
<script type="text/javascript"> |
| 242 |
contextual_appearance( |
| 243 |
'diagnostics-email-destination', |
| 244 |
'diagnostics-email-destination-address', |
| 245 |
'diagnostics-email-destination-default', |
| 246 |
'mailto', |
| 247 |
'inline' |
| 248 |
); |
| 249 |
jQuery('#diagnostics-email-destination').change ( function () { |
| 250 |
contextual_appearance( |
| 251 |
'diagnostics-email-destination', |
| 252 |
'diagnostics-email-destination-address', |
| 253 |
'diagnostics-email-destination-default', |
| 254 |
'mailto', |
| 255 |
'inline' |
| 256 |
); |
| 257 |
} ); |
| 258 |
</script> |
| 259 |
<?php |
| 260 |
} /* FeedWordPressDiagnosticsPage::diagnostics_box () */ |
| 261 |
|
| 262 |
static function updates_box ($page, $box = NULL) { |
| 263 |
$hours = get_option('feedwordpress_diagnostics_persistent_errors_hours', 2); |
| 264 |
$fields = apply_filters('feedwordpress_diagnostics', array( |
| 265 |
'Update Diagnostics' => array( |
| 266 |
'update_schedule:check' => 'whenever a FeedWordPress checks in on the update schedule', |
| 267 |
'updated_feeds' => 'as each feed is checked for updates', |
| 268 |
'syndicated_posts' => 'as each syndicated post is added to the database', |
| 269 |
'feed_items' => 'as each syndicated item is considered on the feed', |
| 270 |
'memory_usage' => 'indicating how much memory was used', |
| 271 |
), |
| 272 |
'Feed Retrieval' => array( |
| 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', |
| 274 |
'updated_feeds:errors' => 'any time FeedWordPress encounters any errors while checking a feed for updates', |
| 275 |
'updated_feeds:http' => "displaying the raw HTTP data passed to and from the feed being checked for updates", |
| 276 |
), |
| 277 |
'Syndicated Post Details' => array( |
| 278 |
'feed_items:freshness' => 'as FeedWordPress decides whether to treat an item as a new post, an update, or a duplicate of an existing post', |
| 279 |
'feed_items:rejected' => 'when FeedWordPress rejects a post without syndicating it', |
| 280 |
'syndicated_posts:categories' => 'as categories, tags, and other terms are added on the post', |
| 281 |
'syndicated_posts:meta_data' => 'as syndication meta-data is added on the post', |
| 282 |
'syndicated_posts:do_pings' => 'when FeedWordPress holds or releases the pings WordPress sends out when new posts are created', |
| 283 |
), |
| 284 |
'Advanced Diagnostics' => array( |
| 285 |
'feed_items:freshness:reasons' => 'explaining the reason that a post was treated as an update to an existing post', |
| 286 |
'feed_items:freshness:sql' => 'when FeedWordPress issues the SQL query it uses to decide whether to treat items as new, updates, or duplicates', |
| 287 |
'syndicated_posts:categories:test' => 'as FeedWordPress checks for the familiarity of feed categories and tags', |
| 288 |
'syndicated_posts:static_meta_data' => 'providing meta-data about syndicated posts in the Edit Posts interface', |
| 289 |
), |
| 290 |
), $page); |
| 291 |
|
| 292 |
foreach ($fields as $section => $items) : |
| 293 |
foreach ($items as $key => $label) : |
| 294 |
$checked[$key] = ''; |
| 295 |
endforeach; |
| 296 |
endforeach; |
| 297 |
|
| 298 |
$diagnostics_show = get_option('feedwordpress_diagnostics_show', array()); |
| 299 |
if (is_array($diagnostics_show)) : foreach ($diagnostics_show as $thingy) : |
| 300 |
$checked[$thingy] = ' checked="checked"'; |
| 301 |
endforeach; endif; |
| 302 |
|
| 303 |
// Hey ho, let's go... |
| 304 |
?> |
| 305 |
<table class="edit-form"> |
| 306 |
<?php foreach ($fields as $section => $ul) : ?> |
| 307 |
<tr> |
| 308 |
<th scope="row"><?php print esc_html($section); ?>:</th> |
| 309 |
<td><p>Show a diagnostic message...</p> |
| 310 |
<ul class="options"> |
| 311 |
<?php foreach ($ul as $key => $label) : ?> |
| 312 |
<li><label><input |
| 313 |
type="checkbox" name="diagnostics_show[]" |
| 314 |
value="<?php print esc_html($key); ?>" |
| 315 |
<?php print $checked[$key]; ?> /> |
| 316 |
<?php print $label; ?></label></li> |
| 317 |
<?php endforeach; ?> |
| 318 |
</ul></td> |
| 319 |
</tr> |
| 320 |
<?php endforeach; ?> |
| 321 |
</table> |
| 322 |
<?php |
| 323 |
} /* FeedWordPressDiagnosticsPage::updates_box () */ |
| 324 |
|
| 325 |
static function tests_box ($page, $box = NULL) { |
| 326 |
$url = MyPHP::request('http_test_url'); |
| 327 |
$method = MyPHP::request('http_test_method'); |
| 328 |
$xpath = MyPHP::request('http_test_xpath'); |
| 329 |
|
| 330 |
$aMethods = array( |
| 331 |
'wp_remote_request', |
| 332 |
'FeedWordPie_File', |
| 333 |
'FeedWordPress::fetch', |
| 334 |
); |
| 335 |
?> |
| 336 |
<script type="text/javascript"> |
| 337 |
function clone_http_test_args_keyvalue_prototype () { |
| 338 |
var next = jQuery('#http-test-args').find('.http-test-args-keyvalue').length; |
| 339 |
var newRow = jQuery('#http-test-args-keyvalue-prototype').clone().attr('id', 'http-test-args-keyvalue-' + next); |
| 340 |
newRow.find('.http_test_args_key').attr('name', 'http_test_args_key['+next+']').val(''); |
| 341 |
newRow.find('.http_test_args_value').attr('name', 'http_test_args_value['+next+']').val(''); |
| 342 |
|
| 343 |
newRow.appendTo('#http-test-args'); |
| 344 |
return false; |
| 345 |
} |
| 346 |
</script> |
| 347 |
|
| 348 |
<table class="edit-form"> |
| 349 |
<tr> |
| 350 |
<th scope="row">HTTP:</th> |
| 351 |
<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;" /> |
| 352 |
<input type="submit" name="feedwordpress_diagnostics_do[http_test]" value="Test »" /></div> |
| 353 |
<div><select name="http_test_method" size="1"> |
| 354 |
<?php foreach ($aMethods as $sMethod) :?> |
| 355 |
<option value="<?php |
| 356 |
print esc_attr($sMethod); |
| 357 |
?>"<?php |
| 358 |
if ($method==$sMethod) : |
| 359 |
print ' selected="selected"'; |
| 360 |
endif; |
| 361 |
?>><?php |
| 362 |
print $sMethod; |
| 363 |
?></option> |
| 364 |
<?php endforeach; ?> |
| 365 |
</select></div> |
| 366 |
<table> |
| 367 |
<tr> |
| 368 |
<td> |
| 369 |
<div id="http-test-args"> |
| 370 |
<div id="http-test-args-keyvalue-prototype" class="http-test-args-keyvalue"><label>Args: |
| 371 |
<input type="text" class='http_test_args_key' name="http_test_args_key[0]" value="" placeholder="key" /></label> |
| 372 |
<label>= <input type="text" class='http_test_args_value' name="http_test_args_value[0]" value="" placeholder="value" /></label> |
| 373 |
</div> |
| 374 |
</div> |
| 375 |
</td> |
| 376 |
<td><a href="#http-test-args" onclick="return clone_http_test_args_keyvalue_prototype();">+ Add</a></td> |
| 377 |
</tr> |
| 378 |
</table> |
| 379 |
</td> |
| 380 |
</tr> |
| 381 |
|
| 382 |
<tr> |
| 383 |
<th>XPath:</th> |
| 384 |
<td><div><input type="text" name="http_test_xpath" value="<?php print esc_attr($xpath); ?>" placeholder="xpath-like query" /></div> |
| 385 |
<div><p>Leave blank to test HTTP, fill in to test a query.</p></div> |
| 386 |
</td> |
| 387 |
</tr> |
| 388 |
|
| 389 |
<?php if (isset($page->test_html['http_test'])) : ?> |
| 390 |
<tr> |
| 391 |
<th scope="row">RESULTS:</th> |
| 392 |
<td> |
| 393 |
<div>URL: <code><?php print esc_html($page->test_html['url']); ?></code></div> |
| 394 |
<div style="position: relative"> |
| 395 |
<div style="width: 100%; overflow: scroll; background-color: #eed"> |
| 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> |
| 397 |
</div> |
| 398 |
</div> |
| 399 |
</td> |
| 400 |
</tr> |
| 401 |
<?php endif; ?> |
| 402 |
</table> |
| 403 |
|
| 404 |
<?php |
| 405 |
} /* FeedWordPressDiagnosticsPage::tests_box () */ |
| 406 |
|
| 407 |
private $test_html; |
| 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']; |
| 411 |
|
| 412 |
$args = array(); |
| 413 |
if (isset($post['http_test_args_key'])) : |
| 414 |
foreach ($post['http_test_args_key'] as $idx => $name) : |
| 415 |
$name = trim($name); |
| 416 |
if (strlen($name) > 0) : |
| 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]; |
| 421 |
endif; |
| 422 |
|
| 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)) : |
| 427 |
$value = $json_value; |
| 428 |
endif; |
| 429 |
endif; |
| 430 |
endif; |
| 431 |
|
| 432 |
$args[$name] = $value; |
| 433 |
endif; |
| 434 |
endforeach; |
| 435 |
endif; |
| 436 |
|
| 437 |
switch ($post['http_test_method']) : |
| 438 |
case 'wp_remote_request' : |
| 439 |
$out = wp_remote_request($url, $args); |
| 440 |
break; |
| 441 |
case 'FeedWordPie_File' : |
| 442 |
$out = new FeedWordPie_File($url); |
| 443 |
break; |
| 444 |
case 'FeedWordPress::fetch' : |
| 445 |
$out = FeedWordPress::fetch($url); |
| 446 |
|
| 447 |
if (isset($post['http_test_xpath'])) : |
| 448 |
if (strlen($post['http_test_xpath']) > 0) : |
| 449 |
|
| 450 |
$xpath = $post['http_test_xpath']; |
| 451 |
|
| 452 |
if ( !is_wp_error($out) ) : |
| 453 |
$expr = new FeedWordPressParsedPostMeta($xpath); |
| 454 |
|
| 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; |
| 470 |
endif; |
| 471 |
endif; |
| 472 |
break; |
| 473 |
endswitch; |
| 474 |
|
| 475 |
$this->test_html['url'] = $url; |
| 476 |
$this->test_html['http_test'] = esc_html(MyPHP::val($out)); |
| 477 |
endif; |
| 478 |
} /* FeedWordPressDiagnosticsPage::do_http_test () */ |
| 479 |
|
| 480 |
} /* class FeedWordPressDiagnosticsPage */ |
| 481 |
|
| 482 |
$diagnosticsPage = new FeedWordPressDiagnosticsPage; |
| 483 |
$diagnosticsPage->display(); |
| 484 |
|
| 485 |
|