| 1 |
<?php |
| 2 |
require_once(dirname(__FILE__) . '/admin-ui.php'); |
| 3 |
require_once(dirname(__FILE__) . '/feedfinder.class.php'); |
| 4 |
|
| 5 |
################################################################################ |
| 6 |
## ADMIN MENU ADD-ONS: implement Dashboard management pages #################### |
| 7 |
################################################################################ |
| 8 |
|
| 9 |
define('FWP_UPDATE_CHECKED', 'Update Checked'); |
| 10 |
define('FWP_UNSUB_CHECKED', 'Unsubscribe'); |
| 11 |
define('FWP_DELETE_CHECKED', 'Delete'); |
| 12 |
define('FWP_RESUB_CHECKED', 'Re-subscribe'); |
| 13 |
define('FWP_SYNDICATE_NEW', 'Add →'); |
| 14 |
define('FWP_UNSUB_FULL', 'Unsubscribe from selected feeds →'); |
| 15 |
define('FWP_CANCEL_BUTTON', '× Cancel'); |
| 16 |
define('FWP_CHECK_FOR_UPDATES', 'Update'); |
| 17 |
|
| 18 |
class FeedWordPressSyndicationPage extends FeedWordPressAdminPage { |
| 19 |
function FeedWordPressSyndicationPage ($filename = NULL) { |
| 20 |
FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpresssyndication', /*link=*/ NULL); |
| 21 |
|
| 22 |
// No over-arching form element |
| 23 |
$this->dispatch = NULL; |
| 24 |
if (is_null($filename)) : |
| 25 |
$this->filename = __FILE__; |
| 26 |
else : |
| 27 |
$this->filename = $filename; |
| 28 |
endif; |
| 29 |
} /* FeedWordPressSyndicationPage constructor */ |
| 30 |
|
| 31 |
function has_link () { return false; } |
| 32 |
|
| 33 |
var $_sources = NULL; |
| 34 |
|
| 35 |
function sources ($visibility = 'Y') { |
| 36 |
if (is_null($this->_sources)) : |
| 37 |
$links = FeedWordPress::syndicated_links(array("hide_invisible" => false)); |
| 38 |
$this->_sources = array("Y" => array(), "N" => array()); |
| 39 |
foreach ($links as $link) : |
| 40 |
$this->_sources[$link->link_visible][] = $link; |
| 41 |
endforeach; |
| 42 |
endif; |
| 43 |
$ret = ( |
| 44 |
array_key_exists($visibility, $this->_sources) |
| 45 |
? $this->_sources[$visibility] |
| 46 |
: $this->_sources |
| 47 |
); |
| 48 |
return $ret; |
| 49 |
} /* FeedWordPressSyndicationPage::sources() */ |
| 50 |
|
| 51 |
function visibility_toggle () { |
| 52 |
$sources = $this->sources('*'); |
| 53 |
|
| 54 |
$defaultVisibility = 'Y'; |
| 55 |
if ((count($this->sources('N')) > 0) |
| 56 |
and (count($this->sources('Y'))==0)) : |
| 57 |
$defaultVisibility = 'N'; |
| 58 |
endif; |
| 59 |
|
| 60 |
$visibility = ( |
| 61 |
isset($_REQUEST['visibility']) |
| 62 |
? $_REQUEST['visibility'] |
| 63 |
: $defaultVisibility |
| 64 |
); |
| 65 |
|
| 66 |
return $visibility; |
| 67 |
} /* FeedWordPressSyndicationPage::visibility_toggle() */ |
| 68 |
|
| 69 |
function show_inactive () { |
| 70 |
return ($this->visibility_toggle() == 'N'); |
| 71 |
} |
| 72 |
|
| 73 |
function updates_requested () { |
| 74 |
global $wpdb; |
| 75 |
|
| 76 |
if (isset($_POST['update']) or isset($_POST['action']) or isset($_POST['update_uri'])) : |
| 77 |
// Only do things with side-effects for HTTP POST or command line |
| 78 |
$fwp_update_invoke = 'post'; |
| 79 |
else : |
| 80 |
$fwp_update_invoke = 'get'; |
| 81 |
endif; |
| 82 |
|
| 83 |
$update_set = array(); |
| 84 |
if ($fwp_update_invoke != 'get') : |
| 85 |
if (is_array(FeedWordPress::post('link_ids')) |
| 86 |
and (FeedWordPress::post('action')==FWP_UPDATE_CHECKED)) : |
| 87 |
$targets = $wpdb->get_results(" |
| 88 |
SELECT * FROM $wpdb->links |
| 89 |
WHERE link_id IN (".implode(",",$_POST['link_ids']).") |
| 90 |
"); |
| 91 |
if (is_array($targets)) : |
| 92 |
foreach ($targets as $target) : |
| 93 |
$update_set[] = $target->link_rss; |
| 94 |
endforeach; |
| 95 |
else : // This should never happen |
| 96 |
FeedWordPress::critical_bug('fwp_syndication_manage_page::targets', $targets, __LINE__, __FILE__); |
| 97 |
endif; |
| 98 |
elseif (!is_null(FeedWordPress::post('update_uri'))) : |
| 99 |
$targets = FeedWordPress::post('update_uri'); |
| 100 |
if (!is_array($targets)) : |
| 101 |
$targets = array($targets); |
| 102 |
endif; |
| 103 |
|
| 104 |
$first = each($targets); |
| 105 |
if (!is_numeric($first['key'])) : // URLs in keys |
| 106 |
$targets = array_keys($targets); |
| 107 |
endif; |
| 108 |
$update_set = $targets; |
| 109 |
endif; |
| 110 |
endif; |
| 111 |
return $update_set; |
| 112 |
} |
| 113 |
|
| 114 |
function accept_multiadd () { |
| 115 |
global $fwp_post; |
| 116 |
|
| 117 |
if (isset($fwp_post['cancel']) and $fwp_post['cancel']==__(FWP_CANCEL_BUTTON)) : |
| 118 |
return true; // Continue .... |
| 119 |
endif; |
| 120 |
|
| 121 |
// If this is a POST, validate source and user credentials |
| 122 |
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links'); |
| 123 |
|
| 124 |
$in = (isset($fwp_post['multilookup']) ? $fwp_post['multilookup'] : '') |
| 125 |
.(isset($fwp_post['opml_lookup']) ? $fwp_post['opml_lookup'] : ''); |
| 126 |
if (isset($fwp_post['confirm']) and $fwp_post['confirm']=='multiadd') : |
| 127 |
$chex = $fwp_post['multilookup']; |
| 128 |
$added = array(); $errors = array(); |
| 129 |
foreach ($chex as $feed) : |
| 130 |
if (isset($feed['add']) and $feed['add']=='yes') : |
| 131 |
// Then, add in the URL. |
| 132 |
$link_id = FeedWordPress::syndicate_link( |
| 133 |
$feed['title'], |
| 134 |
$feed['link'], |
| 135 |
$feed['url'] |
| 136 |
); |
| 137 |
if ($link_id and !is_wp_error($link_id)): |
| 138 |
$added[] = $link_id; |
| 139 |
else : |
| 140 |
$errors[] = array($feed['url'], $link_id); |
| 141 |
endif; |
| 142 |
endif; |
| 143 |
endforeach; |
| 144 |
|
| 145 |
print "<div class='updated'>\n"; |
| 146 |
print "<p>Added ".count($added)." new syndicated sources.</p>"; |
| 147 |
if (count($errors) > 0) : |
| 148 |
print "<p>FeedWordPress encountered errors trying to add the following sources:</p> |
| 149 |
<ul>\n"; |
| 150 |
foreach ($errors as $err) : |
| 151 |
$url = $err[0]; |
| 152 |
$short = esc_html(feedwordpress_display_url($url)); |
| 153 |
$url = esc_html($url); |
| 154 |
$wp = $err[1]; |
| 155 |
if (is_wp_error($err[1])) : |
| 156 |
$error = $err[1]; |
| 157 |
$mesg = " (<code>".$error->get_error_messages()."</code>)"; |
| 158 |
else : |
| 159 |
$mesg = ''; |
| 160 |
endif; |
| 161 |
print "<li><a href='$url'>$short</a>$mesg</li>\n"; |
| 162 |
endforeach; |
| 163 |
print "</ul>\n"; |
| 164 |
endif; |
| 165 |
print "</div>\n"; |
| 166 |
|
| 167 |
elseif (is_array($in) or strlen($in) > 0) : |
| 168 |
add_meta_box( |
| 169 |
/*id=*/ 'feedwordpress_multiadd_box', |
| 170 |
/*title=*/ __('Add Feeds'), |
| 171 |
/*callback=*/ array($this, 'multiadd_box'), |
| 172 |
/*page=*/ $this->meta_box_context(), |
| 173 |
/*context =*/ $this->meta_box_context() |
| 174 |
); |
| 175 |
endif; |
| 176 |
return true; // Continue... |
| 177 |
} |
| 178 |
|
| 179 |
function display_multiadd_line ($line) { |
| 180 |
$short_feed = esc_html(feedwordpress_display_url($line['feed'])); |
| 181 |
$feed = esc_html($line['feed']); |
| 182 |
$link = esc_html($line['link']); |
| 183 |
$title = esc_html($line['title']); |
| 184 |
$checked = $line['checked']; |
| 185 |
$i = esc_html($line['i']); |
| 186 |
|
| 187 |
print "<li><label><input type='checkbox' name='multilookup[$i][add]' value='yes' $checked /> |
| 188 |
$title</label> · <a href='$feed'>$short_feed</a>"; |
| 189 |
|
| 190 |
if (isset($line['extra'])) : |
| 191 |
print " · ".esc_html($line['extra']); |
| 192 |
endif; |
| 193 |
|
| 194 |
print "<input type='hidden' name='multilookup[$i][url]' value='$feed' /> |
| 195 |
<input type='hidden' name='multilookup[$i][link]' value='$link' /> |
| 196 |
<input type='hidden' name='multilookup[$i][title]' value='$title' /> |
| 197 |
</li>\n"; |
| 198 |
|
| 199 |
flush(); |
| 200 |
} |
| 201 |
|
| 202 |
function multiadd_box ($page, $box = NULL) { |
| 203 |
global $fwp_post; |
| 204 |
|
| 205 |
$localData = NULL; |
| 206 |
|
| 207 |
if (isset($_FILES['opml_upload']['name']) and |
| 208 |
(strlen($_FILES['opml_upload']['name']) > 0)) : |
| 209 |
$in = 'tag:localhost'; |
| 210 |
$localData = file_get_contents($_FILES['opml_upload']['tmp_name']); |
| 211 |
$merge_all = true; |
| 212 |
elseif (isset($fwp_post['multilookup'])) : |
| 213 |
$in = $fwp_post['multilookup']; |
| 214 |
$merge_all = false; |
| 215 |
elseif (isset($fwp_post['opml_lookup'])) : |
| 216 |
$in = $fwp_post['opml_lookup']; |
| 217 |
$merge_all = true; |
| 218 |
else : |
| 219 |
$in = ''; |
| 220 |
$merge_all = false; |
| 221 |
endif; |
| 222 |
|
| 223 |
if (strlen($in) > 0) : |
| 224 |
$lines = preg_split( |
| 225 |
"/\s+/", |
| 226 |
$in, |
| 227 |
/*no limit soldier*/ -1, |
| 228 |
PREG_SPLIT_NO_EMPTY |
| 229 |
); |
| 230 |
|
| 231 |
$i = 0; |
| 232 |
?> |
| 233 |
<form id="multiadd-form" action="<?php print $this->form_action(); ?>" method="post"> |
| 234 |
<div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?> |
| 235 |
<input type="hidden" name="multiadd" value="<?php print FWP_SYNDICATE_NEW; ?>" /> |
| 236 |
<input type="hidden" name="confirm" value="multiadd" /> |
| 237 |
|
| 238 |
<input type="hidden" name="multiadd" value="<?php print FWP_SYNDICATE_NEW; ?>" /> |
| 239 |
<input type="hidden" name="confirm" value="multiadd" /></div> |
| 240 |
|
| 241 |
<div id="multiadd-status"> |
| 242 |
<p><img src="<?php print esc_url ( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> |
| 243 |
Looking up feed information...</p> |
| 244 |
</div> |
| 245 |
|
| 246 |
<div id="multiadd-buttons"> |
| 247 |
<input type="submit" class="button" name="cancel" value="<?php _e(FWP_CANCEL_BUTTON); ?>" /> |
| 248 |
<input type="submit" class="button-primary" value="<?php print _e('Subscribe to selected sources →'); ?>" /> |
| 249 |
</div> |
| 250 |
|
| 251 |
<p><?php _e('Here are the feeds that FeedWordPress has discovered from the addresses that you provided. To opt out of a subscription, unmark the checkbox next to the feed.'); ?></p> |
| 252 |
|
| 253 |
<?php |
| 254 |
print "<ul id=\"multiadd-list\">\n"; flush(); |
| 255 |
foreach ($lines as $line) : |
| 256 |
$url = trim($line); |
| 257 |
if (strlen($url) > 0) : |
| 258 |
// First, use FeedFinder to check the URL. |
| 259 |
if (is_null($localData)) : |
| 260 |
$finder = new FeedFinder($url, /*verify=*/ false, /*fallbacks=*/ 1); |
| 261 |
else : |
| 262 |
$finder = new FeedFinder('tag:localhost', /*verify=*/ false, /*fallbacks=*/ 1); |
| 263 |
$finder->upload_data($localData); |
| 264 |
endif; |
| 265 |
|
| 266 |
$feeds = array_values( |
| 267 |
array_unique( |
| 268 |
$finder->find() |
| 269 |
) |
| 270 |
); |
| 271 |
|
| 272 |
$found = false; |
| 273 |
if (count($feeds) > 0) : |
| 274 |
foreach ($feeds as $feed) : |
| 275 |
$pie = FeedWordPress::fetch($feed); |
| 276 |
if (!is_wp_error($pie)) : |
| 277 |
$found = true; |
| 278 |
|
| 279 |
$short_feed = esc_html(feedwordpress_display_url($feed)); |
| 280 |
$feed = esc_html($feed); |
| 281 |
$title = esc_html($pie->get_title()); |
| 282 |
$checked = ' checked="checked"'; |
| 283 |
$link = esc_html($pie->get_link()); |
| 284 |
|
| 285 |
$this->display_multiadd_line(array( |
| 286 |
'feed' => $feed, |
| 287 |
'title' => $pie->get_title(), |
| 288 |
'link' => $pie->get_link(), |
| 289 |
'checked' => ' checked="checked"', |
| 290 |
'i' => $i, |
| 291 |
)); |
| 292 |
|
| 293 |
$i++; // Increment field counter |
| 294 |
|
| 295 |
if (!$merge_all) : // Break out after first find |
| 296 |
break; |
| 297 |
endif; |
| 298 |
endif; |
| 299 |
endforeach; |
| 300 |
endif; |
| 301 |
|
| 302 |
if (!$found) : |
| 303 |
$this->display_multiadd_line(array( |
| 304 |
'feed' => $url, |
| 305 |
'title' => feedwordpress_display_url($url), |
| 306 |
'extra' => " [FeedWordPress couldn't detect any feeds for this URL.]", |
| 307 |
'link' => NULL, |
| 308 |
'checked' => '', |
| 309 |
'i' => $i, |
| 310 |
)); |
| 311 |
$i++; // Increment field counter |
| 312 |
endif; |
| 313 |
endif; |
| 314 |
endforeach; |
| 315 |
print "</ul>\n"; |
| 316 |
?> |
| 317 |
</form> |
| 318 |
|
| 319 |
<script type="text/javascript"> |
| 320 |
jQuery(document).ready( function () { |
| 321 |
// Hide it now that we're done. |
| 322 |
jQuery('#multiadd-status').fadeOut(500 /*ms*/); |
| 323 |
} ); |
| 324 |
</script> |
| 325 |
<?php |
| 326 |
endif; |
| 327 |
|
| 328 |
$this->_sources = NULL; // Force reload of sources list |
| 329 |
return true; // Continue |
| 330 |
} |
| 331 |
|
| 332 |
function display () { |
| 333 |
global $wpdb; |
| 334 |
global $fwp_post; |
| 335 |
|
| 336 |
if (FeedWordPress::needs_upgrade()) : |
| 337 |
fwp_upgrade_page(); |
| 338 |
return; |
| 339 |
endif; |
| 340 |
|
| 341 |
?> |
| 342 |
<?php |
| 343 |
$cont = true; |
| 344 |
$dispatcher = array( |
| 345 |
"feedfinder" => 'fwp_feedfinder_page', |
| 346 |
FWP_SYNDICATE_NEW => 'fwp_feedfinder_page', |
| 347 |
"switchfeed" => 'fwp_switchfeed_page', |
| 348 |
FWP_UNSUB_CHECKED => 'multidelete_page', |
| 349 |
FWP_DELETE_CHECKED => 'multidelete_page', |
| 350 |
'Unsubscribe' => 'multidelete_page', |
| 351 |
FWP_RESUB_CHECKED => 'multiundelete_page', |
| 352 |
); |
| 353 |
if (isset($_REQUEST['action']) and isset($dispatcher[$_REQUEST['action']])) : |
| 354 |
$method = $dispatcher[$_REQUEST['action']]; |
| 355 |
if (method_exists($this, $method)) : |
| 356 |
$cont = $this->{$method}(); |
| 357 |
else : |
| 358 |
$cont = call_user_func($method); |
| 359 |
endif; |
| 360 |
elseif (isset($fwp_post['multiadd']) and $fwp_post['multiadd']==FWP_SYNDICATE_NEW) : |
| 361 |
$cont = $this->accept_multiadd($fwp_post); |
| 362 |
endif; |
| 363 |
|
| 364 |
if ($cont): |
| 365 |
$links = $this->sources('Y'); |
| 366 |
$potential_updates = (!$this->show_inactive() and (count($this->sources('Y')) > 0)); |
| 367 |
|
| 368 |
$this->open_sheet('Syndicated Sites'); |
| 369 |
?> |
| 370 |
<div id="post-body"> |
| 371 |
<?php |
| 372 |
if ($potential_updates |
| 373 |
or (count($this->updates_requested()) > 0)) : |
| 374 |
add_meta_box( |
| 375 |
/*id=*/ 'feedwordpress_update_box', |
| 376 |
/*title=*/ __('Update feeds now'), |
| 377 |
/*callback=*/ 'fwp_syndication_manage_page_update_box', |
| 378 |
/*page=*/ $this->meta_box_context(), |
| 379 |
/*context =*/ $this->meta_box_context() |
| 380 |
); |
| 381 |
endif; |
| 382 |
add_meta_box( |
| 383 |
/*id=*/ 'feedwordpress_feeds_box', |
| 384 |
/*title=*/ __('Syndicated sources'), |
| 385 |
/*callback=*/ array(&$this, 'syndicated_sources_box'), |
| 386 |
/*page=*/ $this->meta_box_context(), |
| 387 |
/*context =*/ $this->meta_box_context() |
| 388 |
); |
| 389 |
|
| 390 |
do_action('feedwordpress_admin_page_syndication_meta_boxes', $this); |
| 391 |
?> |
| 392 |
<div class="metabox-holder"> |
| 393 |
<?php |
| 394 |
fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this); |
| 395 |
?> |
| 396 |
</div> <!-- class="metabox-holder" --> |
| 397 |
</div> <!-- id="post-body" --> |
| 398 |
|
| 399 |
<?php $this->close_sheet(/*dispatch=*/ NULL); ?> |
| 400 |
|
| 401 |
<div style="display: none"> |
| 402 |
<div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug --> |
| 403 |
</div> |
| 404 |
<?php |
| 405 |
endif; |
| 406 |
} /* FeedWordPressSyndicationPage::display () */ |
| 407 |
|
| 408 |
function dashboard_box ($page, $box = NULL) { |
| 409 |
global $fwp_path; |
| 410 |
|
| 411 |
$links = FeedWordPress::syndicated_links(array("hide_invisible" => false)); |
| 412 |
$sources = $this->sources('*'); |
| 413 |
|
| 414 |
$visibility = 'Y'; |
| 415 |
$hrefPrefix = $this->form_action(); |
| 416 |
$activeHref = $hrefPrefix.'&visibility=Y'; |
| 417 |
$inactiveHref = $hrefPrefix.'&visibility=N'; |
| 418 |
|
| 419 |
$lastUpdate = get_option('feedwordpress_last_update_all', NULL); |
| 420 |
$automatic_updates = get_option('feedwordpress_automatic_updates', NULL); |
| 421 |
|
| 422 |
if ('init'==$automatic_updates) : |
| 423 |
$update_setting = 'automatically before page loads'; |
| 424 |
elseif ('shutdown'==$automatic_updates) : |
| 425 |
$update_setting = 'automatically after page loads'; |
| 426 |
else : |
| 427 |
$update_setting = 'using a cron job or manual check-ins'; |
| 428 |
endif; |
| 429 |
|
| 430 |
// Hey ho, let's go... |
| 431 |
?> |
| 432 |
<p class="info" style="margin-bottom: 0px; border-bottom: 1px dotted black;">Managed by <a href="http://feedwordpress.radgeek.com/">FeedWordPress</a> |
| 433 |
<?php print FEEDWORDPRESS_VERSION; ?>.</p> |
| 434 |
<?php if (FEEDWORDPRESS_BLEG) : ?> |
| 435 |
<div style="float: left; background: white; margin-top: 5px; margin-right: 5px;"><a href="<?php print $this->form_action(); ?>"><img src="<?php print esc_html(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></a></div> |
| 436 |
<p class="info" style="margin-top: 0px; font-style: italic; font-size: 75%; color: #666;">If you find this tool useful for your daily work, you can |
| 437 |
contribute to ongoing support and development with |
| 438 |
<a href="http://feedwordpress.radgeek.com/donate/">a modest donation</a>.</p> |
| 439 |
<br style="clear: left;" /> |
| 440 |
<?php endif; ?> |
| 441 |
|
| 442 |
<div class="feedwordpress-actions"> |
| 443 |
<h4>Updates</h4> |
| 444 |
<ul class="options"> |
| 445 |
<li><strong>Scheduled:</strong> <?php print $update_setting; ?> |
| 446 |
(<a href="<?php print $this->form_action('feeds-page.php'); ?>">change setting</a>)</li> |
| 447 |
|
| 448 |
<li><?php if (!is_null($lastUpdate)) : ?> |
| 449 |
<strong>Last checked:</strong> <?php print fwp_time_elapsed($lastUpdate); ?> |
| 450 |
<?php else : ?> |
| 451 |
<strong>Last checked:</strong> none yet |
| 452 |
<?php endif; ?> </li> |
| 453 |
|
| 454 |
</ul> |
| 455 |
</div> |
| 456 |
|
| 457 |
<div class="feedwordpress-stats"> |
| 458 |
<h4>Subscriptions</h4> |
| 459 |
<table> |
| 460 |
<tbody> |
| 461 |
<tr class="first"> |
| 462 |
<td class="first b b-active"><a href="<?php print esc_html($activeHref); ?>"><?php print count($sources['Y']); ?></a></td> |
| 463 |
<td class="t active"><a href="<?php print esc_html($activeHref); ?>">Active</a></td> |
| 464 |
</tr> |
| 465 |
|
| 466 |
<tr> |
| 467 |
<td class="b b-inactive"><a href="<?php print esc_html($inactiveHref); ?>"><?php print count($sources['N']); ?></a></td> |
| 468 |
<td class="t inactive"><a href="<?php print esc_html($inactiveHref); ?>">Inactive</a></td> |
| 469 |
</tr> |
| 470 |
</table> |
| 471 |
</div> |
| 472 |
|
| 473 |
<div id="add-single-uri"> |
| 474 |
<?php if (count($sources['Y']) > 0) : ?> |
| 475 |
<form id="check-for-updates" action="<?php print $this->form_action(); ?>" method="POST"> |
| 476 |
<div class="container"><input type="submit" class="button-primary" name"update" value="<?php print FWP_CHECK_FOR_UPDATES; ?>" /> |
| 477 |
<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?> |
| 478 |
<input type="hidden" name="update_uri" value="*" /></div> |
| 479 |
</form> |
| 480 |
<?php endif; ?> |
| 481 |
|
| 482 |
<form id="syndicated-links" action="<?php print $hrefPrefix; ?>&visibility=<?php print $visibility; ?>" method="post"> |
| 483 |
<div class="container"><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?> |
| 484 |
<label for="add-uri">Add: |
| 485 |
<input type="text" name="lookup" id="add-uri" placeholder="Source URL" |
| 486 |
value="Source URL" style="width: 55%;" /></label> |
| 487 |
|
| 488 |
<?php FeedWordPressSettingsUI::magic_input_tip_js('add-uri'); ?> |
| 489 |
|
| 490 |
<input style="vertical-align: middle;" type="image" src="<?php print WP_PLUGIN_URL.'/'.$fwp_path; ?>/plus.png" alt="<?php print FWP_SYNDICATE_NEW; ?>" name="action" value="<?php print FWP_SYNDICATE_NEW; ?>" /></div> |
| 491 |
</form> |
| 492 |
</div> <!-- id="add-single-uri" --> |
| 493 |
|
| 494 |
<br style="clear: both;" /> |
| 495 |
|
| 496 |
<?php |
| 497 |
} /* FeedWordPressSyndicationPage::dashboard_box () */ |
| 498 |
|
| 499 |
function syndicated_sources_box ($page, $box = NULL) { |
| 500 |
global $fwp_path; |
| 501 |
|
| 502 |
$links = FeedWordPress::syndicated_links(array("hide_invisible" => false)); |
| 503 |
$sources = $this->sources('*'); |
| 504 |
|
| 505 |
$visibility = $this->visibility_toggle(); |
| 506 |
$showInactive = $this->show_inactive(); |
| 507 |
|
| 508 |
$hrefPrefix = $this->form_action(); |
| 509 |
?> |
| 510 |
<div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div> |
| 511 |
<div class="tablenav"> |
| 512 |
|
| 513 |
<div id="add-multiple-uri" class="hide-if-js"> |
| 514 |
<form action="<?php print $hrefPrefix; ?>&visibility=<?php print $visibility; ?>" method="post"> |
| 515 |
<div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div> |
| 516 |
<h4>Add Multiple Sources</h4> |
| 517 |
<div>Enter one feed or website URL per line. If a URL links to a website which provides multiple feeds, FeedWordPress will use the first one listed.</div> |
| 518 |
<div><textarea name="multilookup" rows="8" cols="60" |
| 519 |
style="vertical-align: top"></textarea></div> |
| 520 |
<div style="border-top: 1px dotted black; padding-top: 10px"> |
| 521 |
<div class="alignright"><input type="submit" class="button-primary" name="multiadd" value="<?php print FWP_SYNDICATE_NEW; ?>" /></div> |
| 522 |
<div class="alignleft"><input type="button" class="button-secondary" name="action" value="<?php print FWP_CANCEL_BUTTON; ?>" id="turn-off-multiple-sources" /></div> |
| 523 |
</div> |
| 524 |
</form> |
| 525 |
</div> <!-- id="add-multiple-uri" --> |
| 526 |
|
| 527 |
<div id="upload-opml" style="float: right" class="hide-if-js"> |
| 528 |
<h4>Import source list</h4> |
| 529 |
<p>You can import a list of sources in OPML format, either by providing |
| 530 |
a URL for the OPML document, or by uploading a copy from your |
| 531 |
computer.</p> |
| 532 |
|
| 533 |
<form enctype="multipart/form-data" action="<?php print $hrefPrefix; ?>&visibility=<?php print $visibility; ?>" method="post"> |
| 534 |
<div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?><input type="hidden" name="MAX_FILE_SIZE" value="100000" /></div> |
| 535 |
<div style="clear: both"><label for="opml-lookup" style="float: left; width: 8.0em; margin-top: 5px;">From URL:</label> <input type="text" id="opml-lookup" name="opml_lookup" value="OPML document" /></div> |
| 536 |
<div style="clear: both"><label for="opml-upload" style="float: left; width: 8.0em; margin-top: 5px;">From file:</label> <input type="file" id="opml-upload" name="opml_upload" /></div> |
| 537 |
|
| 538 |
<div style="border-top: 1px dotted black; padding-top: 10px"> |
| 539 |
<div class="alignright"><input type="submit" class="button-primary" name="action" value="<?php print FWP_SYNDICATE_NEW; ?>" /></div> |
| 540 |
<div class="alignleft"><input type="button" class="button-secondary" name="action" value="<?php print FWP_CANCEL_BUTTON; ?>" id="turn-off-opml-upload" /></div> |
| 541 |
</div> |
| 542 |
</form> |
| 543 |
</div> <!-- id="upload-opml" --> |
| 544 |
|
| 545 |
<div id="add-single-uri" class="alignright"> |
| 546 |
<form id="syndicated-links" action="<?php print $hrefPrefix; ?>&visibility=<?php print $visibility; ?>" method="post"> |
| 547 |
<div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div> |
| 548 |
<ul class="subsubsub"> |
| 549 |
<li><label for="add-uri">New source:</label> |
| 550 |
<input type="text" name="lookup" id="add-uri" value="Website or feed URI" /> |
| 551 |
|
| 552 |
<?php FeedWordPressSettingsUI::magic_input_tip_js('add-uri'); FeedWordPressSettingsUI::magic_input_tip_js('opml-lookup'); ?> |
| 553 |
|
| 554 |
<input type="hidden" name="action" value="feedfinder" /> |
| 555 |
<input type="submit" class="button-secondary" name="action" value="<?php print FWP_SYNDICATE_NEW; ?>" /> |
| 556 |
<div style="text-align: right; margin-right: 2.0em"><a id="turn-on-multiple-sources" href="#add-multiple-uri"><img style="vertical-align: middle" src="<?php print WP_PLUGIN_URL.'/'.$fwp_path; ?>/down.png" alt="" /> add multiple</a> |
| 557 |
<span class="screen-reader-text"> or </span> |
| 558 |
<a id="turn-on-opml-upload" href="#upload-opml"><img src="<?php print WP_PLUGIN_URL.'/'.$fwp_path; ?>/plus.png" alt="" style="vertical-align: middle" /> import source list</a></div> |
| 559 |
</li> |
| 560 |
</ul> |
| 561 |
</form> |
| 562 |
</div> <!-- class="alignright" --> |
| 563 |
|
| 564 |
<div class="alignleft"> |
| 565 |
<?php |
| 566 |
if (count($sources[$visibility]) > 0) : |
| 567 |
fwp_syndication_manage_page_links_subsubsub($sources, $showInactive); |
| 568 |
endif; |
| 569 |
?> |
| 570 |
</div> <!-- class="alignleft" --> |
| 571 |
|
| 572 |
</div> <!-- class="tablenav" --> |
| 573 |
|
| 574 |
<form id="syndicated-links" action="<?php print $hrefPrefix; ?>&visibility=<?php print $visibility; ?>" method="post"> |
| 575 |
<div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div> |
| 576 |
|
| 577 |
<?php if ($showInactive) : ?> |
| 578 |
<div style="clear: right" class="alignright"> |
| 579 |
<p style="font-size: smaller; font-style: italic">FeedWordPress used to syndicate |
| 580 |
posts from these sources, but you have unsubscribed from them.</p> |
| 581 |
</div> |
| 582 |
<?php |
| 583 |
endif; |
| 584 |
?> |
| 585 |
|
| 586 |
<?php |
| 587 |
if (count($sources[$visibility]) > 0) : |
| 588 |
$this->display_button_bar($showInactive); |
| 589 |
else : |
| 590 |
?> |
| 591 |
<?php fwp_syndication_manage_page_links_subsubsub($sources, $showInactive); ?> |
| 592 |
<?php |
| 593 |
endif; |
| 594 |
|
| 595 |
fwp_syndication_manage_page_links_table_rows($sources[$visibility], $this, $visibility); |
| 596 |
$this->display_button_bar($showInactive); |
| 597 |
?> |
| 598 |
</form> |
| 599 |
<?php |
| 600 |
} /* FeedWordPressSyndicationPage::syndicated_sources_box() */ |
| 601 |
|
| 602 |
function display_button_bar ($showInactive) { |
| 603 |
?> |
| 604 |
<div style="clear: left" class="alignleft"> |
| 605 |
<?php if ($showInactive) : ?> |
| 606 |
<input class="button-secondary" type="submit" name="action" value="<?php print FWP_RESUB_CHECKED; ?>" /> |
| 607 |
<input class="button-secondary" type="submit" name="action" value="<?php print FWP_DELETE_CHECKED; ?>" /> |
| 608 |
<?php else : ?> |
| 609 |
<input class="button-secondary" type="submit" name="action" value="<?php print FWP_UPDATE_CHECKED; ?>" /> |
| 610 |
<input class="button-secondary delete" type="submit" name="action" value="<?php print FWP_UNSUB_CHECKED; ?>" /> |
| 611 |
<?php endif ; ?> |
| 612 |
</div> <!-- class="alignleft" --> |
| 613 |
|
| 614 |
<br class="clear" /> |
| 615 |
<?php |
| 616 |
} |
| 617 |
|
| 618 |
function bleg_thanks ($page, $box = NULL) { |
| 619 |
?> |
| 620 |
<div class="donation-thanks"> |
| 621 |
<h4>Thank you!</h4> |
| 622 |
<p><strong>Thank you</strong> for your contribution to <a href="http://feedwordpress.radgeek.com/">FeedWordPress</a> development. |
| 623 |
Your generous gifts make ongoing support and development for |
| 624 |
FeedWordPress possible.</p> |
| 625 |
<p>If you have any questions about FeedWordPress, or if there |
| 626 |
is anything I can do to help make FeedWordPress more useful for |
| 627 |
you, please <a href="http://feedwordpress.radgeek.com/contact">contact me</a> |
| 628 |
and let me know what you're thinking about.</p> |
| 629 |
<p class="signature">—<a href="http://radgeek.com/">Charles Johnson</a>, Developer, <a href="http://feedwordpress.radgeek.com/">FeedWordPress</a>.</p> |
| 630 |
</div> |
| 631 |
<?php |
| 632 |
} /* FeedWordPressSyndicationPage::bleg_thanks () */ |
| 633 |
|
| 634 |
function bleg_box ($page, $box = NULL) { |
| 635 |
?> |
| 636 |
<div class="donation-form"> |
| 637 |
<h4>Keep FeedWordPress improving</h4> |
| 638 |
<form action="https://www.paypal.com/cgi-bin/webscr" accept-charset="UTF-8" method="post"><div> |
| 639 |
<p><a href="http://feedwordpress.radgeek.com/">FeedWordPress</a> makes syndication |
| 640 |
simple and empowers you to stream content from all over the web into your |
| 641 |
WordPress hub. That's got to be worth a few lattes. If you're finding FWP useful, |
| 642 |
<a href="http://feedwordpress.radgeek.com/donate/">a modest gift</a> |
| 643 |
is the best way to support steady progress on development, enhancements, |
| 644 |
support, and documentation.</p> |
| 645 |
<div class="donate"> |
| 646 |
<input type="hidden" name="business" value="commerce@radgeek.com" /> |
| 647 |
<input type="hidden" name="cmd" value="_xclick" /> |
| 648 |
<input type="hidden" name="item_name" value="FeedWordPress donation" /> |
| 649 |
<input type="hidden" name="no_shipping" value="1" /> |
| 650 |
<input type="hidden" name="return" value="<?php print admin_url('admin.php'); ?>?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename($this->filename); ?>&paid=yes" /> |
| 651 |
<input type="hidden" name="currency_code" value="USD" /> |
| 652 |
<input type="hidden" name="notify_url" value="http://feedwordpress.radgeek.com/ipn/donation" /> |
| 653 |
<input type="hidden" name="custom" value="1" /> |
| 654 |
<input type="image" name="submit" src="https://www.paypal.com/en_GB/i/btn/btn_donate_SM.gif" alt="Donate through PayPal" /> |
| 655 |
</div> |
| 656 |
</div></form> |
| 657 |
|
| 658 |
<p>You can make a gift online (or |
| 659 |
<a href="http://feedwordpress.radgeek.com/donation">set up an automatic |
| 660 |
regular donation</a>) using an existing PayPal account or any major credit card.</p> |
| 661 |
|
| 662 |
<div class="sod-off"> |
| 663 |
<form style="text-align: center" action="<?php print $this->form_action(); ?>" method="POST"><div> |
| 664 |
<input class="button" type="submit" name="maybe_later" value="Maybe Later" /> |
| 665 |
<input class="button" type="submit" name="go_away" value="Dismiss" /> |
| 666 |
</div></form> |
| 667 |
</div> |
| 668 |
</div> <!-- class="donation-form" --> |
| 669 |
<?php |
| 670 |
} /* FeedWordPressSyndicationPage::bleg_box () */ |
| 671 |
|
| 672 |
/** |
| 673 |
* Override the default display of a save-settings button and replace |
| 674 |
* it with nothing. |
| 675 |
*/ |
| 676 |
function interstitial () { |
| 677 |
/* NOOP */ |
| 678 |
} /* FeedWordPressSyndicationPage::interstitial() */ |
| 679 |
|
| 680 |
function multidelete_page () { |
| 681 |
global $wpdb; |
| 682 |
global $fwp_post; |
| 683 |
|
| 684 |
// If this is a POST, validate source and user credentials |
| 685 |
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links'); |
| 686 |
|
| 687 |
if (isset($fwp_post['submit']) and $fwp_post['submit']==FWP_CANCEL_BUTTON) : |
| 688 |
return true; // Continue without further ado. |
| 689 |
endif; |
| 690 |
|
| 691 |
$link_ids = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array()); |
| 692 |
if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif; |
| 693 |
|
| 694 |
if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Delete'): |
| 695 |
if (isset($GLOBALS['fwp_post']['link_action']) and is_array($GLOBALS['fwp_post']['link_action'])) : |
| 696 |
$actions = $GLOBALS['fwp_post']['link_action']; |
| 697 |
else : |
| 698 |
$actions = array(); |
| 699 |
endif; |
| 700 |
|
| 701 |
$do_it = array( |
| 702 |
'hide' => array(), |
| 703 |
'nuke' => array(), |
| 704 |
'delete' => array(), |
| 705 |
); |
| 706 |
|
| 707 |
foreach ($actions as $link_id => $what) : |
| 708 |
$do_it[$what][] = $link_id; |
| 709 |
endforeach; |
| 710 |
|
| 711 |
$alter = array(); |
| 712 |
if (count($do_it['hide']) > 0) : |
| 713 |
$hidem = "(".implode(', ', $do_it['hide']).")"; |
| 714 |
$alter[] = " |
| 715 |
UPDATE $wpdb->links |
| 716 |
SET link_visible = 'N' |
| 717 |
WHERE link_id IN {$hidem} |
| 718 |
"; |
| 719 |
endif; |
| 720 |
|
| 721 |
if (count($do_it['nuke']) > 0) : |
| 722 |
$nukem = "(".implode(', ', $do_it['nuke']).")"; |
| 723 |
|
| 724 |
// Make a list of the items syndicated from this feed... |
| 725 |
$post_ids = $wpdb->get_col(" |
| 726 |
SELECT post_id FROM $wpdb->postmeta |
| 727 |
WHERE meta_key = 'syndication_feed_id' |
| 728 |
AND meta_value IN {$nukem} |
| 729 |
"); |
| 730 |
|
| 731 |
// ... and kill them all |
| 732 |
if (count($post_ids) > 0) : |
| 733 |
foreach ($post_ids as $post_id) : |
| 734 |
if (FeedWordPressCompatibility::test_version(FWP_SCHEMA_29)) : |
| 735 |
// Force scrubbing of deleted post |
| 736 |
// rather than sending to Trashcan |
| 737 |
wp_delete_post( |
| 738 |
/*postid=*/ $post_id, |
| 739 |
/*force_delete=*/ true |
| 740 |
); |
| 741 |
else : |
| 742 |
wp_delete_post($post_id); |
| 743 |
endif; |
| 744 |
endforeach; |
| 745 |
endif; |
| 746 |
|
| 747 |
$alter[] = " |
| 748 |
DELETE FROM $wpdb->links |
| 749 |
WHERE link_id IN {$nukem} |
| 750 |
"; |
| 751 |
endif; |
| 752 |
|
| 753 |
if (count($do_it['delete']) > 0) : |
| 754 |
$deletem = "(".implode(', ', $do_it['delete']).")"; |
| 755 |
|
| 756 |
// Make the items syndicated from this feed appear to be locally-authored |
| 757 |
$alter[] = " |
| 758 |
DELETE FROM $wpdb->postmeta |
| 759 |
WHERE meta_key = 'syndication_feed_id' |
| 760 |
AND meta_value IN {$deletem} |
| 761 |
"; |
| 762 |
|
| 763 |
// ... and delete the links themselves. |
| 764 |
$alter[] = " |
| 765 |
DELETE FROM $wpdb->links |
| 766 |
WHERE link_id IN {$deletem} |
| 767 |
"; |
| 768 |
endif; |
| 769 |
|
| 770 |
$errs = array(); $success = array (); |
| 771 |
foreach ($alter as $sql) : |
| 772 |
$result = $wpdb->query($sql); |
| 773 |
if (!$result): |
| 774 |
$errs[] = mysql_error(); |
| 775 |
endif; |
| 776 |
endforeach; |
| 777 |
|
| 778 |
if (count($alter) > 0) : |
| 779 |
echo "<div class=\"updated\">\n"; |
| 780 |
if (count($errs) > 0) : |
| 781 |
echo "There were some problems processing your "; |
| 782 |
echo "unsubscribe request. [SQL: ".implode('; ', $errs)."]"; |
| 783 |
else : |
| 784 |
echo "Your unsubscribe request(s) have been processed."; |
| 785 |
endif; |
| 786 |
echo "</div>\n"; |
| 787 |
endif; |
| 788 |
|
| 789 |
return true; // Continue on to Syndicated Sites listing |
| 790 |
else : |
| 791 |
$targets = $wpdb->get_results(" |
| 792 |
SELECT * FROM $wpdb->links |
| 793 |
WHERE link_id IN (".implode(",",$link_ids).") |
| 794 |
"); |
| 795 |
?> |
| 796 |
<form action="<?php print $this->form_action(); ?>" method="post"> |
| 797 |
<div class="wrap"> |
| 798 |
<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?> |
| 799 |
<input type="hidden" name="action" value="Unsubscribe" /> |
| 800 |
<input type="hidden" name="confirm" value="Delete" /> |
| 801 |
|
| 802 |
<h2>Unsubscribe from Syndicated Links:</h2> |
| 803 |
<?php foreach ($targets as $link) : |
| 804 |
$subscribed = ('Y' == strtoupper($link->link_visible)); |
| 805 |
$link_url = esc_html($link->link_url); |
| 806 |
$link_name = esc_html($link->link_name); |
| 807 |
$link_description = esc_html($link->link_description); |
| 808 |
$link_rss = esc_html($link->link_rss); |
| 809 |
?> |
| 810 |
<fieldset> |
| 811 |
<legend><?php echo $link_name; ?></legend> |
| 812 |
<table class="editform" width="100%" cellspacing="2" cellpadding="5"> |
| 813 |
<tr><th scope="row" width="20%"><?php _e('Feed URI:') ?></th> |
| 814 |
<td width="80%"><a href="<?php echo $link_rss; ?>"><?php echo $link_rss; ?></a></td></tr> |
| 815 |
<tr><th scope="row" width="20%"><?php _e('Short description:') ?></th> |
| 816 |
<td width="80%"><?php echo $link_description; ?></span></td></tr> |
| 817 |
<tr><th width="20%" scope="row"><?php _e('Homepage:') ?></th> |
| 818 |
<td width="80%"><a href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td></tr> |
| 819 |
<tr style="vertical-align:top"><th width="20%" scope="row">Subscription <?php _e('Options') ?>:</th> |
| 820 |
<td width="80%"><ul style="margin:0; padding: 0; list-style: none"> |
| 821 |
<?php if ($subscribed) : ?> |
| 822 |
<li><input type="radio" id="hide-<?php echo $link->link_id; ?>" |
| 823 |
name="link_action[<?php echo $link->link_id; ?>]" value="hide" checked="checked" /> |
| 824 |
<label for="hide-<?php echo $link->link_id; ?>">Turn off the subscription for this |
| 825 |
syndicated link<br/><span style="font-size:smaller">(Keep the feed information |
| 826 |
and all the posts from this feed in the database, but don't syndicate any |
| 827 |
new posts from the feed.)</span></label></li> |
| 828 |
<?php endif; ?> |
| 829 |
<li><input type="radio" id="nuke-<?php echo $link->link_id; ?>"<?php if (!$subscribed) : ?> checked="checked"<?php endif; ?> |
| 830 |
name="link_action[<?php echo $link->link_id; ?>]" value="nuke" /> |
| 831 |
<label for="nuke-<?php echo $link->link_id; ?>">Delete this syndicated link and all the |
| 832 |
posts that were syndicated from it</label></li> |
| 833 |
<li><input type="radio" id="delete-<?php echo $link->link_id; ?>" |
| 834 |
name="link_action[<?php echo $link->link_id; ?>]" value="delete" /> |
| 835 |
<label for="delete-<?php echo $link->link_id; ?>">Delete this syndicated link, but |
| 836 |
<em>keep</em> posts that were syndicated from it (as if they were authored |
| 837 |
locally).</label></li> |
| 838 |
<li><input type="radio" id="nothing-<?php echo $link->link_id; ?>" |
| 839 |
name="link_action[<?php echo $link->link_id; ?>]" value="nothing" /> |
| 840 |
<label for="nothing-<?php echo $link->link_id; ?>">Keep this feed as it is. I changed |
| 841 |
my mind.</label></li> |
| 842 |
</ul> |
| 843 |
</table> |
| 844 |
</fieldset> |
| 845 |
<?php endforeach; ?> |
| 846 |
|
| 847 |
<div class="submit"> |
| 848 |
<input type="submit" name="submit" value="<?php _e(FWP_CANCEL_BUTTON); ?>" /> |
| 849 |
<input class="delete" type="submit" name="submit" value="<?php _e(FWP_UNSUB_FULL) ?>" /> |
| 850 |
</div> |
| 851 |
</div> |
| 852 |
<?php |
| 853 |
return false; // Don't continue on to Syndicated Sites listing |
| 854 |
endif; |
| 855 |
} /* FeedWordPressSyndicationPage::multidelete_page() */ |
| 856 |
|
| 857 |
function multiundelete_page () { |
| 858 |
global $wpdb; |
| 859 |
|
| 860 |
// If this is a POST, validate source and user credentials |
| 861 |
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links'); |
| 862 |
|
| 863 |
$link_ids = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array()); |
| 864 |
if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif; |
| 865 |
|
| 866 |
if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Undelete'): |
| 867 |
if (isset($GLOBALS['fwp_post']['link_action']) and is_array($GLOBALS['fwp_post']['link_action'])) : |
| 868 |
$actions = $GLOBALS['fwp_post']['link_action']; |
| 869 |
else : |
| 870 |
$actions = array(); |
| 871 |
endif; |
| 872 |
|
| 873 |
$do_it = array( |
| 874 |
'unhide' => array(), |
| 875 |
); |
| 876 |
|
| 877 |
foreach ($actions as $link_id => $what) : |
| 878 |
$do_it[$what][] = $link_id; |
| 879 |
endforeach; |
| 880 |
|
| 881 |
$alter = array(); |
| 882 |
if (count($do_it['unhide']) > 0) : |
| 883 |
$unhiddem = "(".implode(', ', $do_it['unhide']).")"; |
| 884 |
$alter[] = " |
| 885 |
UPDATE $wpdb->links |
| 886 |
SET link_visible = 'Y' |
| 887 |
WHERE link_id IN {$unhiddem} |
| 888 |
"; |
| 889 |
endif; |
| 890 |
|
| 891 |
$errs = array(); $success = array (); |
| 892 |
foreach ($alter as $sql) : |
| 893 |
$result = $wpdb->query($sql); |
| 894 |
if (!$result): |
| 895 |
$errs[] = mysql_error(); |
| 896 |
endif; |
| 897 |
endforeach; |
| 898 |
|
| 899 |
if (count($alter) > 0) : |
| 900 |
echo "<div class=\"updated\">\n"; |
| 901 |
if (count($errs) > 0) : |
| 902 |
echo "There were some problems processing your "; |
| 903 |
echo "re-subscribe request. [SQL: ".implode('; ', $errs)."]"; |
| 904 |
else : |
| 905 |
echo "Your re-subscribe request(s) have been processed."; |
| 906 |
endif; |
| 907 |
echo "</div>\n"; |
| 908 |
endif; |
| 909 |
|
| 910 |
return true; // Continue on to Syndicated Sites listing |
| 911 |
else : |
| 912 |
$targets = $wpdb->get_results(" |
| 913 |
SELECT * FROM $wpdb->links |
| 914 |
WHERE link_id IN (".implode(",",$link_ids).") |
| 915 |
"); |
| 916 |
?> |
| 917 |
<form action="<?php print $this->form_action(); ?>" method="post"> |
| 918 |
<div class="wrap"> |
| 919 |
<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?> |
| 920 |
<input type="hidden" name="action" value="<?php print FWP_RESUB_CHECKED; ?>" /> |
| 921 |
<input type="hidden" name="confirm" value="Undelete" /> |
| 922 |
|
| 923 |
<h2>Re-subscribe to Syndicated Links:</h2> |
| 924 |
<?php |
| 925 |
foreach ($targets as $link) : |
| 926 |
$subscribed = ('Y' == strtoupper($link->link_visible)); |
| 927 |
$link_url = esc_html($link->link_url); |
| 928 |
$link_name = esc_html($link->link_name); |
| 929 |
$link_description = esc_html($link->link_description); |
| 930 |
$link_rss = esc_html($link->link_rss); |
| 931 |
|
| 932 |
if (!$subscribed) : |
| 933 |
?> |
| 934 |
<fieldset> |
| 935 |
<legend><?php echo $link_name; ?></legend> |
| 936 |
<table class="editform" width="100%" cellspacing="2" cellpadding="5"> |
| 937 |
<tr><th scope="row" width="20%"><?php _e('Feed URI:') ?></th> |
| 938 |
<td width="80%"><a href="<?php echo $link_rss; ?>"><?php echo $link_rss; ?></a></td></tr> |
| 939 |
<tr><th scope="row" width="20%"><?php _e('Short description:') ?></th> |
| 940 |
<td width="80%"><?php echo $link_description; ?></span></td></tr> |
| 941 |
<tr><th width="20%" scope="row"><?php _e('Homepage:') ?></th> |
| 942 |
<td width="80%"><a href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td></tr> |
| 943 |
<tr style="vertical-align:top"><th width="20%" scope="row">Subscription <?php _e('Options') ?>:</th> |
| 944 |
<td width="80%"><ul style="margin:0; padding: 0; list-style: none"> |
| 945 |
<li><input type="radio" id="unhide-<?php echo $link->link_id; ?>" |
| 946 |
name="link_action[<?php echo $link->link_id; ?>]" value="unhide" checked="checked" /> |
| 947 |
<label for="unhide-<?php echo $link->link_id; ?>">Turn back on the subscription |
| 948 |
for this syndication source.</label></li> |
| 949 |
<li><input type="radio" id="nothing-<?php echo $link->link_id; ?>" |
| 950 |
name="link_action[<?php echo $link->link_id; ?>]" value="nothing" /> |
| 951 |
<label for="nothing-<?php echo $link->link_id; ?>">Leave this feed as it is. |
| 952 |
I changed my mind.</label></li> |
| 953 |
</ul> |
| 954 |
</table> |
| 955 |
</fieldset> |
| 956 |
<?php |
| 957 |
endif; |
| 958 |
endforeach; |
| 959 |
?> |
| 960 |
|
| 961 |
<div class="submit"> |
| 962 |
<input class="button-primary delete" type="submit" name="submit" value="<?php _e('Re-subscribe to selected feeds »') ?>" /> |
| 963 |
</div> |
| 964 |
</div> |
| 965 |
<?php |
| 966 |
return false; // Don't continue on to Syndicated Sites listing |
| 967 |
endif; |
| 968 |
} /* FeedWordPressSyndicationPage::multiundelete_page() */ |
| 969 |
|
| 970 |
|
| 971 |
|
| 972 |
} /* class FeedWordPressSyndicationPage */ |
| 973 |
|
| 974 |
function fwp_dashboard_update_if_requested ($object) { |
| 975 |
global $wpdb; |
| 976 |
|
| 977 |
$update_set = $object->updates_requested(); |
| 978 |
|
| 979 |
if (count($update_set) > 0) : |
| 980 |
shuffle($update_set); // randomize order for load balancing purposes... |
| 981 |
|
| 982 |
$feedwordpress = new FeedWordPress; |
| 983 |
add_action('feedwordpress_check_feed', 'update_feeds_mention'); |
| 984 |
add_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3); |
| 985 |
|
| 986 |
$crash_ts = $feedwordpress->crash_ts(); |
| 987 |
|
| 988 |
echo "<div class=\"update-results\">\n"; |
| 989 |
echo "<ul>\n"; |
| 990 |
$tdelta = NULL; |
| 991 |
foreach ($update_set as $uri) : |
| 992 |
if (!is_null($crash_ts) and (time() > $crash_ts)) : |
| 993 |
echo "<li><p><strong>Further updates postponed:</strong> update time limit of ".$crash_dt." second".(($crash_dt==1)?"":"s")." exceeded.</p></li>"; |
| 994 |
break; |
| 995 |
endif; |
| 996 |
|
| 997 |
if ($uri == '*') : $uri = NULL; endif; |
| 998 |
$delta = $feedwordpress->update($uri, $crash_ts); |
| 999 |
if (!is_null($delta)) : |
| 1000 |
if (is_null($tdelta)) : |
| 1001 |
$tdelta = $delta; |
| 1002 |
else : |
| 1003 |
$tdelta['new'] += $delta['new']; |
| 1004 |
$tdelta['updated'] += $delta['updated']; |
| 1005 |
endif; |
| 1006 |
else : |
| 1007 |
$display_uri = esc_html(feedwordpress_display_url($uri)); |
| 1008 |
$uri = esc_html($uri); |
| 1009 |
echo "<li><p><strong>Error:</strong> There was a problem updating <code><a href=\"$uri\">${display_uri}</a></code></p></li>\n"; |
| 1010 |
endif; |
| 1011 |
endforeach; |
| 1012 |
echo "</ul>\n"; |
| 1013 |
|
| 1014 |
if (!is_null($tdelta)) : |
| 1015 |
$mesg = array(); |
| 1016 |
if (isset($delta['new'])) : $mesg[] = ' '.$tdelta['new'].' new posts were syndicated'; endif; |
| 1017 |
if (isset($delta['updated'])) : $mesg[] = ' '.$tdelta['updated'].' existing posts were updated'; endif; |
| 1018 |
echo "<p>Update complete.".implode(' and', $mesg)."</p>"; |
| 1019 |
echo "\n"; flush(); |
| 1020 |
endif; |
| 1021 |
echo "</div> <!-- class=\"updated\" -->\n"; |
| 1022 |
endif; |
| 1023 |
} |
| 1024 |
|
| 1025 |
define('FEEDWORDPRESS_BLEG_MAYBE_LATER_OFFSET', (60 /*sec/min*/ * 60 /*min/hour*/ * 24 /*hour/day*/ * 31 /*days*/)); |
| 1026 |
define('FEEDWORDPRESS_BLEG_ALREADY_PAID_OFFSET', (60 /*sec/min*/ * 60 /*min/hour*/ * 24 /*hour/day*/ * 183 /*days*/)); |
| 1027 |
function fwp_syndication_manage_page_update_box ($object = NULL, $box = NULL) { |
| 1028 |
$bleg_box_hidden = null; |
| 1029 |
if (isset($_POST['maybe_later'])) : |
| 1030 |
$bleg_box_hidden = time() + FEEDWORDPRESS_BLEG_MAYBE_LATER_OFFSET; |
| 1031 |
elseif (isset($_REQUEST['paid']) and $_REQUEST['paid']) : |
| 1032 |
$bleg_box_hidden = time() + FEEDWORDPRESS_BLEG_ALREADY_PAID_OFFSET; |
| 1033 |
elseif (isset($_POST['go_away'])) : |
| 1034 |
$bleg_box_hidden = 'permanent'; |
| 1035 |
endif; |
| 1036 |
|
| 1037 |
if (!is_null($bleg_box_hidden)) : |
| 1038 |
update_option('feedwordpress_bleg_box_hidden', $bleg_box_hidden); |
| 1039 |
else : |
| 1040 |
$bleg_box_hidden = get_option('feedwordpress_bleg_box_hidden'); |
| 1041 |
endif; |
| 1042 |
?> |
| 1043 |
<?php |
| 1044 |
$bleg_box_ready = (FEEDWORDPRESS_BLEG and ( |
| 1045 |
!$bleg_box_hidden |
| 1046 |
or (is_numeric($bleg_box_hidden) and $bleg_box_hidden < time()) |
| 1047 |
)); |
| 1048 |
|
| 1049 |
if (isset($_REQUEST['paid']) and $_REQUEST['paid']) : |
| 1050 |
$object->bleg_thanks($subject, $box); |
| 1051 |
elseif ($bleg_box_ready) : |
| 1052 |
$object->bleg_box($object, $box); |
| 1053 |
endif; |
| 1054 |
?> |
| 1055 |
|
| 1056 |
<form |
| 1057 |
action="<?php print $object->form_action(); ?>" |
| 1058 |
method="POST" |
| 1059 |
class="update-form<?php if ($bleg_box_ready) : ?> with-donation<?php endif; ?>" |
| 1060 |
> |
| 1061 |
<div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div> |
| 1062 |
<p>Check currently scheduled feeds for new and updated posts.</p> |
| 1063 |
|
| 1064 |
<?php |
| 1065 |
fwp_dashboard_update_if_requested($object); |
| 1066 |
|
| 1067 |
if (!get_option('feedwordpress_automatic_updates')) : |
| 1068 |
?> |
| 1069 |
<p class="heads-up"><strong>Note:</strong> Automatic updates are currently turned |
| 1070 |
<strong>off</strong>. New posts from your feeds will not be syndicated |
| 1071 |
until you manually check for them here. You can turn on automatic |
| 1072 |
updates under <a href="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/feeds-page.php">Feed & Update Settings<a></a>.</p> |
| 1073 |
<?php |
| 1074 |
endif; |
| 1075 |
?> |
| 1076 |
|
| 1077 |
<div class="submit"><?php if ($object->show_inactive()) : ?> |
| 1078 |
<?php foreach ($object->updates_requested() as $req) : ?> |
| 1079 |
<input type="hidden" name="update_uri[]" value="<?php print esc_html($req); ?>" /> |
| 1080 |
<?php endforeach; ?> |
| 1081 |
<?php else : ?> |
| 1082 |
<input type="hidden" name="update_uri" value="*" /> |
| 1083 |
<?php endif; ?> |
| 1084 |
<input class="button-primary" type="submit" name="update" value="<?php _e(FWP_CHECK_FOR_UPDATES); ?>" /></div> |
| 1085 |
|
| 1086 |
<br style="clear: both" /> |
| 1087 |
</form> |
| 1088 |
<?php |
| 1089 |
} /* function fwp_syndication_manage_page_update_box () */ |
| 1090 |
|
| 1091 |
function fwp_feedfinder_page () { |
| 1092 |
global $post_source, $fwp_post, $syndicationPage; |
| 1093 |
|
| 1094 |
if (isset($fwp_post['opml_lookup']) or isset($_FILES['opml_upload'])) : |
| 1095 |
$syndicationPage->accept_multiadd(); |
| 1096 |
return true; |
| 1097 |
else : |
| 1098 |
$post_source = 'feedwordpress_feeds'; |
| 1099 |
|
| 1100 |
// With action=feedfinder, this goes directly to the feedfinder page |
| 1101 |
include_once(dirname(__FILE__) . '/feeds-page.php'); |
| 1102 |
return false; |
| 1103 |
endif; |
| 1104 |
} /* function fwp_feedfinder_page () */ |
| 1105 |
|
| 1106 |
function fwp_switchfeed_page () { |
| 1107 |
global $wpdb, $wp_db_version; |
| 1108 |
global $fwp_post; |
| 1109 |
|
| 1110 |
// If this is a POST, validate source and user credentials |
| 1111 |
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_switchfeed', /*capability=*/ 'manage_links'); |
| 1112 |
|
| 1113 |
$changed = false; |
| 1114 |
if (!isset($fwp_post['Cancel'])): |
| 1115 |
if (isset($fwp_post['save_link_id']) and ($fwp_post['save_link_id']=='*')) : |
| 1116 |
$changed = true; |
| 1117 |
$link_id = FeedWordPress::syndicate_link($fwp_post['feed_title'], $fwp_post['feed_link'], $fwp_post['feed']); |
| 1118 |
if ($link_id): |
| 1119 |
$existingLink = new SyndicatedLink($link_id); |
| 1120 |
?> |
| 1121 |
<div class="updated"><p><a href="<?php print $fwp_post['feed_link']; ?>"><?php print esc_html($fwp_post['feed_title']); ?></a> |
| 1122 |
has been added as a contributing site, using the feed at |
| 1123 |
<<a href="<?php print $fwp_post['feed']; ?>"><?php print esc_html($fwp_post['feed']); ?></a>>. |
| 1124 |
| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/feeds-page.php&link_id=<?php print $link_id; ?>">Configure settings</a>.</p></div> |
| 1125 |
<?php else: ?> |
| 1126 |
<div class="updated"><p>There was a problem adding the feed. [SQL: <?php echo esc_html(mysql_error()); ?>]</p></div> |
| 1127 |
<?php endif; |
| 1128 |
elseif (isset($fwp_post['save_link_id'])): |
| 1129 |
$existingLink = new SyndicatedLink($fwp_post['save_link_id']); |
| 1130 |
$changed = $existingLink->set_uri($fwp_post['feed']); |
| 1131 |
|
| 1132 |
if ($changed): |
| 1133 |
$home = $existingLink->homepage(/*from feed=*/ false); |
| 1134 |
$name = $existingLink->name(/*from feed=*/ false); |
| 1135 |
?> |
| 1136 |
<div class="updated"><p>Feed for <a href="<?php echo esc_html($home); ?>"><?php echo esc_html($name); ?></a> |
| 1137 |
updated to <<a href="<?php echo esc_html($fwp_post['feed']); ?>"><?php echo esc_html($fwp_post['feed']); ?></a>>.</p></div> |
| 1138 |
<?php |
| 1139 |
endif; |
| 1140 |
endif; |
| 1141 |
endif; |
| 1142 |
|
| 1143 |
if (isset($existingLink)) : |
| 1144 |
do_action('feedwordpress_admin_switchfeed', $fwp_post['feed'], $existingLink); |
| 1145 |
endif; |
| 1146 |
|
| 1147 |
if (!$changed) : |
| 1148 |
?> |
| 1149 |
<div class="updated"><p>Nothing was changed.</p></div> |
| 1150 |
<?php |
| 1151 |
endif; |
| 1152 |
return true; // Continue |
| 1153 |
} |
| 1154 |
|
| 1155 |
|