| 1 |
<?php |
| 2 |
require_once(dirname(__FILE__) . '/admin-ui.php'); |
| 3 |
|
| 4 |
################################################################################ |
| 5 |
## ADMIN MENU ADD-ONS: implement Dashboard management pages #################### |
| 6 |
################################################################################ |
| 7 |
|
| 8 |
define('FWP_UPDATE_CHECKED', 'Update Checked'); |
| 9 |
define('FWP_UNSUB_CHECKED', 'Unsubscribe'); |
| 10 |
define('FWP_DELETE_CHECKED', 'Delete'); |
| 11 |
define('FWP_RESUB_CHECKED', 'Re-subscribe'); |
| 12 |
define('FWP_SYNDICATE_NEW', 'Add →'); |
| 13 |
|
| 14 |
class FeedWordPressSyndicationPage extends FeedWordPressAdminPage { |
| 15 |
function FeedWordPressSyndicationPage () { |
| 16 |
FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpresssyndication', /*link=*/ NULL); |
| 17 |
|
| 18 |
// No over-arching form element |
| 19 |
$this->dispatch = NULL; |
| 20 |
$this->filename = __FILE__; |
| 21 |
} /* FeedWordPressSyndicationPage constructor */ |
| 22 |
|
| 23 |
function has_link () { return false; } |
| 24 |
|
| 25 |
var $_sources = NULL; |
| 26 |
|
| 27 |
function sources ($visibility = 'Y') { |
| 28 |
if (is_null($this->_sources)) : |
| 29 |
$links = FeedWordPress::syndicated_links(array("hide_invisible" => false)); |
| 30 |
$this->_sources = array("Y" => array(), "N" => array()); |
| 31 |
foreach ($links as $link) : |
| 32 |
$this->_sources[$link->link_visible][] = $link; |
| 33 |
endforeach; |
| 34 |
endif; |
| 35 |
$ret = ( |
| 36 |
array_key_exists($visibility, $this->_sources) |
| 37 |
? $this->_sources[$visibility] |
| 38 |
: $this->_sources |
| 39 |
); |
| 40 |
return $ret; |
| 41 |
} /* FeedWordPressSyndicationPage::sources() */ |
| 42 |
|
| 43 |
function visibility_toggle () { |
| 44 |
$sources = $this->sources('*'); |
| 45 |
|
| 46 |
$defaultVisibility = 'Y'; |
| 47 |
if ((count($this->sources('N')) > 0) |
| 48 |
and (count($this->sources('Y'))==0)) : |
| 49 |
$defaultVisibility = 'N'; |
| 50 |
endif; |
| 51 |
|
| 52 |
$visibility = ( |
| 53 |
isset($_REQUEST['visibility']) |
| 54 |
? $_REQUEST['visibility'] |
| 55 |
: $defaultVisibility |
| 56 |
); |
| 57 |
|
| 58 |
return $visibility; |
| 59 |
} /* FeedWordPressSyndicationPage::visibility_toggle() */ |
| 60 |
|
| 61 |
function show_inactive () { |
| 62 |
return ($this->visibility_toggle() == 'N'); |
| 63 |
} |
| 64 |
|
| 65 |
function updates_requested () { |
| 66 |
global $wpdb; |
| 67 |
|
| 68 |
if (isset($_POST['update']) or isset($_POST['action']) or isset($_POST['update_uri'])) : |
| 69 |
// Only do things with side-effects for HTTP POST or command line |
| 70 |
$fwp_update_invoke = 'post'; |
| 71 |
else : |
| 72 |
$fwp_update_invoke = 'get'; |
| 73 |
endif; |
| 74 |
|
| 75 |
$update_set = array(); |
| 76 |
if ($fwp_update_invoke != 'get') : |
| 77 |
if (isset($_POST['link_ids']) and is_array($_POST['link_ids']) and ($_POST['action']==FWP_UPDATE_CHECKED)) : |
| 78 |
$targets = $wpdb->get_results(" |
| 79 |
SELECT * FROM $wpdb->links |
| 80 |
WHERE link_id IN (".implode(",",$_POST['link_ids']).") |
| 81 |
"); |
| 82 |
if (is_array($targets)) : |
| 83 |
foreach ($targets as $target) : |
| 84 |
$update_set[] = $target->link_rss; |
| 85 |
endforeach; |
| 86 |
else : // This should never happen |
| 87 |
FeedWordPress::critical_bug('fwp_syndication_manage_page::targets', $targets, __LINE__); |
| 88 |
endif; |
| 89 |
elseif (isset($_POST['update_uri'])) : |
| 90 |
$targets = $_POST['update_uri']; |
| 91 |
if (!is_array($targets)) : |
| 92 |
$targets = array($targets); |
| 93 |
endif; |
| 94 |
$update_set = $targets; |
| 95 |
endif; |
| 96 |
endif; |
| 97 |
return $update_set; |
| 98 |
} |
| 99 |
|
| 100 |
function display () { |
| 101 |
global $wpdb; |
| 102 |
|
| 103 |
if (FeedWordPress::needs_upgrade()) : |
| 104 |
fwp_upgrade_page(); |
| 105 |
return; |
| 106 |
endif; |
| 107 |
|
| 108 |
?> |
| 109 |
<?php |
| 110 |
$cont = true; |
| 111 |
$dispatcher = array( |
| 112 |
"feedfinder" => 'fwp_feedfinder_page', |
| 113 |
FWP_SYNDICATE_NEW => 'fwp_feedfinder_page', |
| 114 |
"switchfeed" => 'fwp_switchfeed_page', |
| 115 |
FWP_UNSUB_CHECKED => 'fwp_multidelete_page', |
| 116 |
FWP_DELETE_CHECKED => 'fwp_multidelete_page', |
| 117 |
'Unsubscribe' => 'fwp_multidelete_page', |
| 118 |
FWP_RESUB_CHECKED => 'fwp_multiundelete_page', |
| 119 |
); |
| 120 |
if (isset($_REQUEST['action']) and isset($dispatcher[$_REQUEST['action']])) : |
| 121 |
$method = $dispatcher[$_REQUEST['action']]; |
| 122 |
$cont = call_user_func($method); |
| 123 |
endif; |
| 124 |
|
| 125 |
if ($cont): |
| 126 |
?> |
| 127 |
<style type="text/css"> |
| 128 |
.heads-up { |
| 129 |
background-color: #d0d0d0; |
| 130 |
color: black; |
| 131 |
padding: 1.0em; |
| 132 |
margin: 0.5em 4.0em !important; |
| 133 |
} |
| 134 |
.update-form.with-donation { |
| 135 |
margin-right: 50%; |
| 136 |
min-height: 255px; |
| 137 |
} |
| 138 |
.donation-form, .donation-thanks { |
| 139 |
background-color: #ffffcc; |
| 140 |
text-align: left; |
| 141 |
padding: 0.5em 0.5em; |
| 142 |
border-left: thin dashed #777777; |
| 143 |
font-size: 70%; |
| 144 |
position: absolute; |
| 145 |
top: 0; bottom: 0; right: 0; left: auto; |
| 146 |
width: 50%; |
| 147 |
} |
| 148 |
.donation-thanks { |
| 149 |
background-color: #ccffcc; |
| 150 |
} |
| 151 |
.donation-thanks .signature { |
| 152 |
text-align: right; |
| 153 |
font-style: italic; |
| 154 |
} |
| 155 |
.donation-form h4, .donation-thanks h4 { |
| 156 |
font-size: 10px; |
| 157 |
text-align: center; |
| 158 |
border-bottom: 1px solid #777777; |
| 159 |
margin: 0px; |
| 160 |
} |
| 161 |
.donation-form .donate { |
| 162 |
text-align: center; |
| 163 |
} |
| 164 |
.donation-form .sod-off { |
| 165 |
padding-top: 0.5em; |
| 166 |
margin-top: 0.5em; |
| 167 |
border-top: thin solid #777777; |
| 168 |
} |
| 169 |
.feed-missing { |
| 170 |
background-color:#FFFFD0; |
| 171 |
} |
| 172 |
.unsubscribed tr { |
| 173 |
background-color: #FFE0E0; |
| 174 |
} |
| 175 |
.unsubscribed tr.alternate { |
| 176 |
background-color: #FFF0F0; |
| 177 |
} |
| 178 |
tr.feed-error { |
| 179 |
background-color: #FFFFD0; |
| 180 |
} |
| 181 |
</style> |
| 182 |
<?php |
| 183 |
$links = $this->sources('Y'); |
| 184 |
$potential_updates = (!$this->show_inactive() and (count($this->sources('Y')) > 0)); |
| 185 |
|
| 186 |
$this->open_sheet('Syndicated Sites'); |
| 187 |
?> |
| 188 |
<div id="post-body"> |
| 189 |
<?php |
| 190 |
if ($potential_updates |
| 191 |
or (count($this->updates_requested()) > 0)) : |
| 192 |
fwp_add_meta_box( |
| 193 |
/*id=*/ 'feedwordpress_update_box', |
| 194 |
/*title=*/ __('Update feeds now'), |
| 195 |
/*callback=*/ 'fwp_syndication_manage_page_update_box', |
| 196 |
/*page=*/ $this->meta_box_context(), |
| 197 |
/*context =*/ $this->meta_box_context() |
| 198 |
); |
| 199 |
endif; |
| 200 |
fwp_add_meta_box( |
| 201 |
/*id=*/ 'feedwordpress_feeds_box', |
| 202 |
/*title=*/ __('Syndicated sources'), |
| 203 |
/*callback=*/ 'fwp_syndication_manage_page_links_box', |
| 204 |
/*page=*/ $this->meta_box_context(), |
| 205 |
/*context =*/ $this->meta_box_context() |
| 206 |
); |
| 207 |
if (FeedWordPressCompatibility::test_version(0, FWP_SCHEMA_25)) : |
| 208 |
fwp_add_meta_box( |
| 209 |
/*id=*/ 'feedwordpress_add_feed_box', |
| 210 |
/*title=*/ 'Add a new syndicated source', |
| 211 |
/*callback=*/ 'fwp_syndication_manage_page_add_feed_box', |
| 212 |
/*page=*/ $this->meta_box_context(), |
| 213 |
/*context=*/ $this->meta_box_context() |
| 214 |
); |
| 215 |
endif; |
| 216 |
|
| 217 |
do_action('feedwordpress_admin_page_syndication_meta_boxes', $this); |
| 218 |
?> |
| 219 |
<div class="metabox-holder"> |
| 220 |
<?php |
| 221 |
fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this); |
| 222 |
?> |
| 223 |
</div> <!-- class="metabox-holder" --> |
| 224 |
</div> <!-- id="post-body" --> |
| 225 |
|
| 226 |
<?php $this->close_sheet(/*dispatch=*/ NULL); ?> |
| 227 |
|
| 228 |
<div style="display: none"> |
| 229 |
<div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug --> |
| 230 |
</div> |
| 231 |
<?php |
| 232 |
endif; |
| 233 |
} /* FeedWordPressSyndicationPage::display () */ |
| 234 |
|
| 235 |
function bleg_thanks ($page, $box = NULL) { |
| 236 |
?> |
| 237 |
<div class="donation-thanks"> |
| 238 |
<h4>Thank you!</h4> |
| 239 |
<p><strong>Thank you</strong> for your contribution to <a href="http://feedwordpress.radgeek.com/">FeedWordPress</a> development. |
| 240 |
Your generous gifts make ongoing support and development for |
| 241 |
FeedWordPress possible.</p> |
| 242 |
<p>If you have any questions about FeedWordPress, or if there |
| 243 |
is anything I can do to help make FeedWordPress more useful for |
| 244 |
you, please <a href="http://feedwordpress.radgeek.com/contact">contact me</a> |
| 245 |
and let me know what you're thinking about.</p> |
| 246 |
<p class="signature">—<a href="http://radgeek.com/">Charles Johnson</a>, Developer, <a href="http://feedwordpress.radgeek.com/">FeedWordPress</a>.</p> |
| 247 |
</div> |
| 248 |
<?php |
| 249 |
} /* FeedWordPressSyndicationPage::bleg_thanks () */ |
| 250 |
|
| 251 |
function bleg_box ($page, $box = NULL) { |
| 252 |
?> |
| 253 |
<div class="donation-form"> |
| 254 |
<h4>Keep FeedWordPress improving</h4> |
| 255 |
<form action="https://www.paypal.com/cgi-bin/webscr" accept-charset="UTF-8" method="post"><div> |
| 256 |
<p><a href="http://feedwordpress.radgeek.com/">FeedWordPress</a> makes syndication |
| 257 |
simple and empowers you to stream content from all over the web into your |
| 258 |
WordPress hub. That's got to be worth a few lattes. If you're finding FWP useful, |
| 259 |
<a href="http://feedwordpress.radgeek.com/donate/">a modest gift</a> |
| 260 |
is the best way to support steady progress on development, enhancements, |
| 261 |
support, and documentation.</p> |
| 262 |
<div class="donate"> |
| 263 |
<input type="hidden" name="business" value="commerce@radgeek.com" /> |
| 264 |
<input type="hidden" name="cmd" value="_xclick" /> |
| 265 |
<input type="hidden" name="item_name" value="FeedWordPress donation" /> |
| 266 |
<input type="hidden" name="no_shipping" value="1" /> |
| 267 |
<input type="hidden" name="return" value="<?php bloginfo('url'); ?>/wp-admin/admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>&paid=yes" /> |
| 268 |
<input type="hidden" name="currency_code" value="USD" /> |
| 269 |
<input type="hidden" name="notify_url" value="http://feedwordpress.radgeek.com/ipn/donation" /> |
| 270 |
<input type="hidden" name="custom" value="1" /> |
| 271 |
<input type="image" name="submit" src="https://www.paypal.com/en_GB/i/btn/btn_donate_SM.gif" alt="Donate through PayPal" /> |
| 272 |
</div> |
| 273 |
</div></form> |
| 274 |
|
| 275 |
<p>You can make a gift online (or |
| 276 |
<a href="http://feedwordpress.radgeek.com/donation">set up an automatic |
| 277 |
regular donation</a>) using an existing PayPal account or any major credit card.</p> |
| 278 |
|
| 279 |
<div class="sod-off"> |
| 280 |
<form style="text-align: center" action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>" method="POST"><div> |
| 281 |
<input class="button-primary" type="submit" name="maybe_later" value="Maybe Later" /> |
| 282 |
<input class="button-secondary" type="submit" name="go_away" value="Dismiss" /> |
| 283 |
</div></form> |
| 284 |
</div> |
| 285 |
</div> <!-- class="donation-form" --> |
| 286 |
<?php |
| 287 |
} /* FeedWordPressSyndicationPage::bleg_box () */ |
| 288 |
|
| 289 |
/** |
| 290 |
* Override the default display of a save-settings button and replace |
| 291 |
* it with nothing. |
| 292 |
*/ |
| 293 |
function interstitial () { |
| 294 |
/* NOOP */ |
| 295 |
} /* FeedWordPressSyndicationPage::interstitial() */ |
| 296 |
} /* class FeedWordPressSyndicationPage */ |
| 297 |
|
| 298 |
function fwp_dashboard_update_if_requested ($object) { |
| 299 |
global $wpdb; |
| 300 |
|
| 301 |
$update_set = $object->updates_requested(); |
| 302 |
|
| 303 |
if (count($update_set) > 0) : |
| 304 |
shuffle($update_set); // randomize order for load balancing purposes... |
| 305 |
|
| 306 |
$feedwordpress = new FeedWordPress; |
| 307 |
add_action('feedwordpress_check_feed', 'update_feeds_mention'); |
| 308 |
add_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3); |
| 309 |
|
| 310 |
$crash_dt = (int) get_option('feedwordpress_update_time_limit'); |
| 311 |
if ($crash_dt > 0) : |
| 312 |
$crash_ts = time() + $crash_dt; |
| 313 |
else : |
| 314 |
$crash_ts = NULL; |
| 315 |
endif; |
| 316 |
|
| 317 |
echo "<div class=\"update-results\">\n"; |
| 318 |
echo "<ul>\n"; |
| 319 |
$tdelta = NULL; |
| 320 |
foreach ($update_set as $uri) : |
| 321 |
if (!is_null($crash_ts) and (time() > $crash_ts)) : |
| 322 |
echo "<li><p><strong>Further updates postponed:</strong> update time limit of ".$crash_dt." second".(($crash_dt==1)?"":"s")." exceeded.</p></li>"; |
| 323 |
break; |
| 324 |
endif; |
| 325 |
|
| 326 |
if ($uri == '*') : $uri = NULL; endif; |
| 327 |
$delta = $feedwordpress->update($uri, $crash_ts); |
| 328 |
if (!is_null($delta)) : |
| 329 |
if (is_null($tdelta)) : |
| 330 |
$tdelta = $delta; |
| 331 |
else : |
| 332 |
$tdelta['new'] += $delta['new']; |
| 333 |
$tdelta['updated'] += $delta['updated']; |
| 334 |
endif; |
| 335 |
else : |
| 336 |
echo "<li><p><strong>Error:</strong> There was a problem updating <a href=\"$uri\">$uri</a></p></li>\n"; |
| 337 |
endif; |
| 338 |
endforeach; |
| 339 |
echo "</ul>\n"; |
| 340 |
|
| 341 |
if (!is_null($tdelta)) : |
| 342 |
$mesg = array(); |
| 343 |
if (isset($delta['new'])) : $mesg[] = ' '.$tdelta['new'].' new posts were syndicated'; endif; |
| 344 |
if (isset($delta['updated'])) : $mesg[] = ' '.$tdelta['updated'].' existing posts were updated'; endif; |
| 345 |
echo "<p>Update complete.".implode(' and', $mesg)."</p>"; |
| 346 |
echo "\n"; flush(); |
| 347 |
endif; |
| 348 |
echo "</div> <!-- class=\"updated\" -->\n"; |
| 349 |
endif; |
| 350 |
} |
| 351 |
|
| 352 |
function fwp_syndication_manage_page_add_feed_box ($object = NULL, $box = NULL) { |
| 353 |
?> |
| 354 |
<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>" method="post"> |
| 355 |
<div> |
| 356 |
<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?> |
| 357 |
<label for="add-uri">Website or feed:</label> |
| 358 |
<input type="text" name="lookup" id="add-uri" value="URI" size="64" /> |
| 359 |
<input type="hidden" name="action" value="feedfinder" /> |
| 360 |
</div> |
| 361 |
<div class="submit"><input type="submit" value="<?php print FWP_SYNDICATE_NEW; ?>" /></div> |
| 362 |
</form> |
| 363 |
<?php |
| 364 |
} |
| 365 |
|
| 366 |
define('FEEDWORDPRESS_BLEG_MAYBE_LATER_OFFSET', (60 /*sec/min*/ * 60 /*min/hour*/ * 24 /*hour/day*/ * 31 /*days*/)); |
| 367 |
define('FEEDWORDPRESS_BLEG_ALREADY_PAID_OFFSET', (60 /*sec/min*/ * 60 /*min/hour*/ * 24 /*hour/day*/ * 183 /*days*/)); |
| 368 |
function fwp_syndication_manage_page_update_box ($object = NULL, $box = NULL) { |
| 369 |
$bleg_box_hidden = null; |
| 370 |
if (isset($_POST['maybe_later'])) : |
| 371 |
$bleg_box_hidden = time() + FEEDWORDPRESS_BLEG_MAYBE_LATER_OFFSET; |
| 372 |
elseif (isset($_REQUEST['paid']) and $_REQUEST['paid']) : |
| 373 |
$bleg_box_hidden = time() + FEEDWORDPRESS_BLEG_ALREADY_PAID_OFFSET; |
| 374 |
elseif (isset($_POST['go_away'])) : |
| 375 |
$bleg_box_hidden = 'permanent'; |
| 376 |
endif; |
| 377 |
|
| 378 |
if (!is_null($bleg_box_hidden)) : |
| 379 |
update_option('feedwordpress_bleg_box_hidden', $bleg_box_hidden); |
| 380 |
else : |
| 381 |
$bleg_box_hidden = get_option('feedwordpress_bleg_box_hidden'); |
| 382 |
endif; |
| 383 |
?> |
| 384 |
<?php |
| 385 |
$bleg_box_ready = (!$bleg_box_hidden or (is_numeric($bleg_box_hidden) and $bleg_box_hidden < time())); |
| 386 |
if (isset($_REQUEST['paid']) and $_REQUEST['paid']) : |
| 387 |
$object->bleg_thanks($subject, $box); |
| 388 |
elseif ($bleg_box_ready) : |
| 389 |
$object->bleg_box($object, $box); |
| 390 |
endif; |
| 391 |
?> |
| 392 |
|
| 393 |
<form |
| 394 |
action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>" |
| 395 |
method="POST" |
| 396 |
class="update-form<?php if ($bleg_box_ready) : ?> with-donation<?php endif; ?>" |
| 397 |
> |
| 398 |
<div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div> |
| 399 |
<p>Check currently scheduled feeds for new and updated posts.</p> |
| 400 |
|
| 401 |
<?php |
| 402 |
fwp_dashboard_update_if_requested($object); |
| 403 |
|
| 404 |
if (!get_option('feedwordpress_automatic_updates')) : |
| 405 |
?> |
| 406 |
<p class="heads-up"><strong>Note:</strong> Automatic updates are currently turned |
| 407 |
<strong>off</strong>. New posts from your feeds will not be syndicated |
| 408 |
until you manually check for them here. You can turn on automatic |
| 409 |
updates under <a href="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/feeds-page.php">Feed & Update Settings<a></a>.</p> |
| 410 |
<?php |
| 411 |
endif; |
| 412 |
?> |
| 413 |
|
| 414 |
<div class="submit"><?php if ($object->show_inactive()) : ?> |
| 415 |
<?php foreach ($object->updates_requested() as $req) : ?> |
| 416 |
<input type="hidden" name="update_uri[]" value="<?php print esc_html($req); ?>" /> |
| 417 |
<?php endforeach; ?> |
| 418 |
<?php else : ?> |
| 419 |
<input type="hidden" name="update_uri" value="*" /> |
| 420 |
<?php endif; ?> |
| 421 |
<input class="button-primary" type="submit" name="update" value="Update" /></div> |
| 422 |
|
| 423 |
<br style="clear: both" /> |
| 424 |
</form> |
| 425 |
<?php |
| 426 |
} /* function fwp_syndication_manage_page_update_box () */ |
| 427 |
|
| 428 |
function fwp_syndication_manage_page_links_table_rows ($links, $visible = 'Y') { |
| 429 |
global $fwp_path; |
| 430 |
|
| 431 |
$subscribed = ('Y' == strtoupper($visible)); |
| 432 |
if ($subscribed or (count($links) > 0)) : |
| 433 |
?> |
| 434 |
<table class="widefat<?php if (!$subscribed) : ?> unsubscribed<?php endif; ?>"> |
| 435 |
<thead> |
| 436 |
<tr> |
| 437 |
<th class="check-column" scope="col"><input type="checkbox" /></th> |
| 438 |
<th scope="col"><?php _e('Name'); ?></th> |
| 439 |
<th scope="col"><?php _e('Feed'); ?></th> |
| 440 |
<th scope="col"><?php _e('Updated'); ?></th> |
| 441 |
</tr> |
| 442 |
</thead> |
| 443 |
|
| 444 |
<tbody> |
| 445 |
<?php |
| 446 |
$alt_row = true; |
| 447 |
if (count($links) > 0): |
| 448 |
foreach ($links as $link): |
| 449 |
$trClass = array(); |
| 450 |
|
| 451 |
// Prep: Get last updated timestamp |
| 452 |
$sLink = new SyndicatedLink($link->link_id); |
| 453 |
if (!is_null($sLink->setting('update/last'))) : |
| 454 |
$lastUpdated = fwp_time_elapsed($sLink->setting('update/last')); |
| 455 |
else : |
| 456 |
$lastUpdated = __('None yet'); |
| 457 |
endif; |
| 458 |
|
| 459 |
// Prep: get last error timestamp, if any |
| 460 |
if (is_null($sLink->setting('update/error'))) : |
| 461 |
$errorsSince = ''; |
| 462 |
else : |
| 463 |
$trClass[] = 'feed-error'; |
| 464 |
|
| 465 |
$theError = unserialize($sLink->setting('update/error')); |
| 466 |
|
| 467 |
$errorsSince = "<div class=\"returning-errors\">" |
| 468 |
."<p><strong>Returning errors</strong> since " |
| 469 |
.fwp_time_elapsed($theError['since']) |
| 470 |
."</p>" |
| 471 |
."<p>Most recent (" |
| 472 |
.fwp_time_elapsed($theError['ts']) |
| 473 |
."):<br/><code>" |
| 474 |
.implode("</code><br/><code>", $theError['object']->get_error_messages()) |
| 475 |
."</code></p>" |
| 476 |
."</div>\n"; |
| 477 |
endif; |
| 478 |
|
| 479 |
$nextUpdate = "<div style='font-style:italic;size:0.9em'>Ready for next update "; |
| 480 |
if (isset($sLink->settings['update/ttl']) and is_numeric($sLink->settings['update/ttl'])) : |
| 481 |
if (isset($sLink->settings['update/timed']) and $sLink->settings['update/timed']=='automatically') : |
| 482 |
$next = $sLink->settings['update/last'] + ((int) $sLink->settings['update/ttl'] * 60); |
| 483 |
$nextUpdate .= fwp_time_elapsed($next); |
| 484 |
if (FEEDWORDPRESS_DEBUG) : $nextUpdate .= " [".(($next-time())/60)." minutes]"; endif; |
| 485 |
else : |
| 486 |
$nextUpdate .= "every ".$sLink->settings['update/ttl']." minute".(($sLink->settings['update/ttl']!=1)?"s":""); |
| 487 |
endif; |
| 488 |
else: |
| 489 |
$nextUpdate .= "as soon as possible"; |
| 490 |
endif; |
| 491 |
$nextUpdate .= "</div>"; |
| 492 |
|
| 493 |
unset($sLink); |
| 494 |
|
| 495 |
$alt_row = !$alt_row; |
| 496 |
|
| 497 |
if ($alt_row) : |
| 498 |
$trClass[] = 'alternate'; |
| 499 |
endif; |
| 500 |
?> |
| 501 |
<tr<?php echo ((count($trClass) > 0) ? ' class="'.implode(" ", $trClass).'"':''); ?>> |
| 502 |
<th class="check-column" scope="row"><input type="checkbox" name="link_ids[]" value="<?php echo $link->link_id; ?>" /></th> |
| 503 |
<?php |
| 504 |
$hrefPrefix = "admin.php?link_id={$link->link_id}&page=${fwp_path}/"; |
| 505 |
$caption = ( |
| 506 |
(strlen($link->link_rss) > 0) |
| 507 |
? __('Switch Feed') |
| 508 |
: $caption=__('Find Feed') |
| 509 |
); |
| 510 |
?> |
| 511 |
<td> |
| 512 |
<strong><a href="<?php print $hrefPrefix; ?>feeds-page.php"><?php print esc_html($link->link_name); ?></a></strong> |
| 513 |
<div class="row-actions"><?php if ($subscribed) : ?> |
| 514 |
<div><strong>Settings ></strong> |
| 515 |
<a href="<?php print $hrefPrefix; ?>feeds-page.php"><?php _e('Feed'); ?></a> |
| 516 |
| <a href="<?php print $hrefPrefix; ?>posts-page.php"><?php _e('Posts'); ?></a> |
| 517 |
| <a href="<?php print $hrefPrefix; ?>authors-page.php"><?php _e('Authors'); ?></a> |
| 518 |
| <a href="<?php print $hrefPrefix; ?>categories-page.php"><?php print htmlspecialchars(__('Categories'.FEEDWORDPRESS_AND_TAGS)); ?></a></div> |
| 519 |
<?php endif; ?> |
| 520 |
|
| 521 |
<div><strong>Actions ></strong> |
| 522 |
<?php if ($subscribed) : ?> |
| 523 |
<a href="<?php print $hrefPrefix; ?><?php echo basename(__FILE__); ?>&action=feedfinder"><?php echo $caption; ?></a> |
| 524 |
<?php else : ?> |
| 525 |
<a href="<?php print $hrefPrefix; ?><?php echo basename(__FILE__); ?>&action=<?php print FWP_RESUB_CHECKED; ?>"><?php _e('Re-subscribe'); ?></a> |
| 526 |
<?php endif; ?> |
| 527 |
| <a href="<?php print $hrefPrefix; ?><?php echo basename(__FILE__); ?>&action=Unsubscribe"><?php _e(($subscribed ? 'Unsubscribe' : 'Delete permanently')); ?></a> |
| 528 |
| <a href="<?php print esc_html($link->link_url); ?>"><?php _e('View')?></a></div> |
| 529 |
</div> |
| 530 |
</td> |
| 531 |
<?php if (strlen($link->link_rss) > 0): ?> |
| 532 |
<td><a href="<?php echo esc_html($link->link_rss); ?>"><?php echo esc_html(feedwordpress_display_url($link->link_rss, 32)); ?></a></td> |
| 533 |
<?php else: ?> |
| 534 |
<td class="feed-missing"><p><strong>no feed assigned</strong></p></td> |
| 535 |
<?php endif; ?> |
| 536 |
|
| 537 |
<td><?php print $lastUpdated; ?> |
| 538 |
<?php print $errorsSince; ?> |
| 539 |
<?php print $nextUpdate; ?> |
| 540 |
</td> |
| 541 |
</tr> |
| 542 |
<?php |
| 543 |
endforeach; |
| 544 |
else : |
| 545 |
?> |
| 546 |
<tr><td colspan="4"><p>There are no websites currently listed for syndication.</p></td></tr> |
| 547 |
<?php |
| 548 |
endif; |
| 549 |
?> |
| 550 |
</tbody> |
| 551 |
</table> |
| 552 |
<?php |
| 553 |
endif; |
| 554 |
} /* function fwp_syndication_manage_page_links_table_rows () */ |
| 555 |
|
| 556 |
function fwp_syndication_manage_page_links_subsubsub ($sources, $showInactive) { |
| 557 |
global $fwp_path; |
| 558 |
$hrefPrefix = "admin.php?page=${fwp_path}/".basename(__FILE__); |
| 559 |
?> |
| 560 |
<ul class="subsubsub"> |
| 561 |
<li><a <?php if (!$showInactive) : ?>class="current" <?php endif; ?>href="<?php print $hrefPrefix; ?>&visibility=Y">Subscribed |
| 562 |
<span class="count">(<?php print count($sources['Y']); ?>)</span></a></li> |
| 563 |
<?php if ($showInactive or (count($sources['N']) > 0)) : ?> |
| 564 |
<li><a <?php if ($showInactive) : ?>class="current" <?php endif; ?>href="<?php print $hrefPrefix; ?>&visibility=N">Inactive</a> |
| 565 |
<span class="count">(<?php print count($sources['N']); ?>)</span></a></li> |
| 566 |
<?php endif; ?> |
| 567 |
|
| 568 |
</ul> <!-- class="subsubsub" --> |
| 569 |
<?php |
| 570 |
} |
| 571 |
|
| 572 |
function fwp_syndication_manage_page_links_box ($object = NULL, $box = NULL) { |
| 573 |
global $fwp_path; |
| 574 |
|
| 575 |
$links = FeedWordPress::syndicated_links(array("hide_invisible" => false)); |
| 576 |
$sources = $object->sources('*'); |
| 577 |
|
| 578 |
$visibility = $object->visibility_toggle(); |
| 579 |
$showInactive = $object->show_inactive(); |
| 580 |
|
| 581 |
$hrefPrefix = "admin.php?page=${fwp_path}/".basename(__FILE__); |
| 582 |
?> |
| 583 |
<form id="syndicated-links" action="<?php print $hrefPrefix; ?>&visibility=<?php print $visibility; ?>" method="post"> |
| 584 |
<div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div> |
| 585 |
<?php |
| 586 |
if (count($sources[$visibility]) > 0) : |
| 587 |
fwp_syndication_manage_page_links_subsubsub($sources, $showInactive); |
| 588 |
endif; |
| 589 |
|
| 590 |
if ($showInactive) : ?> |
| 591 |
<p style="clear: both; font-size: smaller; font-style: italic">FeedWordPress used to syndicate |
| 592 |
posts from these sources, but you have unsubscribed from them.</p> |
| 593 |
<?php |
| 594 |
endif; |
| 595 |
?> |
| 596 |
|
| 597 |
<div class="tablenav"> |
| 598 |
<div class="alignright"> |
| 599 |
<label for="add-uri">New source:</label> |
| 600 |
<input type="text" name="lookup" id="add-uri" value="Website or feed URI" /> |
| 601 |
<?php FeedWordPressSettingsUI::magic_input_tip_js('add-uri'); ?> |
| 602 |
|
| 603 |
<input type="hidden" name="action" value="feedfinder" /> |
| 604 |
<input type="submit" class="button-secondary" name="action" value="<?php print FWP_SYNDICATE_NEW; ?>" /></div> |
| 605 |
|
| 606 |
<?php if (count($sources[$visibility]) > 0) : ?> |
| 607 |
<div class="alignleft"> |
| 608 |
<?php if ($showInactive) : ?> |
| 609 |
<input class="button-secondary" type="submit" name="action" value="<?php print FWP_RESUB_CHECKED; ?>" /> |
| 610 |
<input class="button-secondary" type="submit" name="action" value="<?php print FWP_DELETE_CHECKED; ?>" /> |
| 611 |
<?php else : ?> |
| 612 |
<input class="button-secondary" type="submit" name="action" value="<?php print FWP_UPDATE_CHECKED; ?>" /> |
| 613 |
<input class="button-secondary delete" type="submit" name="action" value="<?php print FWP_UNSUB_CHECKED; ?>" /> |
| 614 |
<?php endif ; ?> |
| 615 |
</div> |
| 616 |
|
| 617 |
<?php else : ?> |
| 618 |
<?php fwp_syndication_manage_page_links_subsubsub($sources, $showInactive); ?> |
| 619 |
<?php endif; ?> |
| 620 |
|
| 621 |
<br class="clear" /> |
| 622 |
</div> |
| 623 |
<br class="clear" /> |
| 624 |
|
| 625 |
<?php |
| 626 |
fwp_syndication_manage_page_links_table_rows($sources[$visibility], $visibility); |
| 627 |
?> |
| 628 |
</form> |
| 629 |
<?php |
| 630 |
} /* function fwp_syndication_manage_page_links_box() */ |
| 631 |
|
| 632 |
function fwp_feedfinder_page () { |
| 633 |
global $post_source; |
| 634 |
|
| 635 |
$post_source = 'feedwordpress_feeds'; |
| 636 |
|
| 637 |
// With action=feedfinder, this goes directly to the feedfinder page |
| 638 |
include_once(dirname(__FILE__) . '/feeds-page.php'); |
| 639 |
return false; |
| 640 |
} /* function fwp_feedfinder_page () */ |
| 641 |
|
| 642 |
function fwp_switchfeed_page () { |
| 643 |
global $wpdb, $wp_db_version; |
| 644 |
global $fwp_post; |
| 645 |
|
| 646 |
// If this is a POST, validate source and user credentials |
| 647 |
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_switchfeed', /*capability=*/ 'manage_links'); |
| 648 |
|
| 649 |
$changed = false; |
| 650 |
if (!isset($fwp_post['Cancel'])): |
| 651 |
if (isset($fwp_post['save_link_id']) and ($fwp_post['save_link_id']=='*')) : |
| 652 |
$changed = true; |
| 653 |
$link_id = FeedWordPress::syndicate_link($fwp_post['feed_title'], $fwp_post['feed_link'], $fwp_post['feed']); |
| 654 |
if ($link_id): |
| 655 |
$existingLink = new SyndicatedLink($link_id); |
| 656 |
?> |
| 657 |
<div class="updated"><p><a href="<?php print $fwp_post['feed_link']; ?>"><?php print esc_html($fwp_post['feed_title']); ?></a> |
| 658 |
has been added as a contributing site, using the feed at |
| 659 |
<<a href="<?php print $fwp_post['feed']; ?>"><?php print esc_html($fwp_post['feed']); ?></a>>. |
| 660 |
| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/feeds-page.php&link_id=<?php print $link_id; ?>">Configure settings</a>.</p></div> |
| 661 |
<?php else: ?> |
| 662 |
<div class="updated"><p>There was a problem adding the feed. [SQL: <?php echo esc_html(mysql_error()); ?>]</p></div> |
| 663 |
<?php endif; |
| 664 |
elseif (isset($fwp_post['save_link_id'])): |
| 665 |
$existingLink = new SyndicatedLink($fwp_post['save_link_id']); |
| 666 |
$changed = $existingLink->set_uri($fwp_post['feed']); |
| 667 |
|
| 668 |
if ($changed): |
| 669 |
$home = $existingLink->homepage(/*from feed=*/ false); |
| 670 |
$name = $existingLink->name(/*from feed=*/ false); |
| 671 |
?> |
| 672 |
<div class="updated"><p>Feed for <a href="<?php echo esc_html($home); ?>"><?php echo esc_html($name); ?></a> |
| 673 |
updated to <<a href="<?php echo esc_html($fwp_post['feed']); ?>"><?php echo esc_html($fwp_post['feed']); ?></a>>.</p></div> |
| 674 |
<?php |
| 675 |
endif; |
| 676 |
endif; |
| 677 |
endif; |
| 678 |
|
| 679 |
if (isset($existingLink)) : |
| 680 |
do_action('feedwordpress_admin_switchfeed', $fwp_post['feed'], $existingLink); |
| 681 |
endif; |
| 682 |
|
| 683 |
if (!$changed) : |
| 684 |
?> |
| 685 |
<div class="updated"><p>Nothing was changed.</p></div> |
| 686 |
<?php |
| 687 |
endif; |
| 688 |
return true; // Continue |
| 689 |
} |
| 690 |
|
| 691 |
function fwp_multiundelete_page () { |
| 692 |
global $wpdb; |
| 693 |
|
| 694 |
// If this is a POST, validate source and user credentials |
| 695 |
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links'); |
| 696 |
|
| 697 |
$link_ids = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array()); |
| 698 |
if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif; |
| 699 |
|
| 700 |
if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Undelete'): |
| 701 |
if (isset($GLOBALS['fwp_post']['link_action']) and is_array($GLOBALS['fwp_post']['link_action'])) : |
| 702 |
$actions = $GLOBALS['fwp_post']['link_action']; |
| 703 |
else : |
| 704 |
$actions = array(); |
| 705 |
endif; |
| 706 |
|
| 707 |
$do_it = array( |
| 708 |
'unhide' => array(), |
| 709 |
); |
| 710 |
|
| 711 |
foreach ($actions as $link_id => $what) : |
| 712 |
$do_it[$what][] = $link_id; |
| 713 |
endforeach; |
| 714 |
|
| 715 |
$alter = array(); |
| 716 |
if (count($do_it['unhide']) > 0) : |
| 717 |
$unhiddem = "(".implode(', ', $do_it['unhide']).")"; |
| 718 |
$alter[] = " |
| 719 |
UPDATE $wpdb->links |
| 720 |
SET link_visible = 'Y' |
| 721 |
WHERE link_id IN {$unhiddem} |
| 722 |
"; |
| 723 |
endif; |
| 724 |
|
| 725 |
$errs = array(); $success = array (); |
| 726 |
foreach ($alter as $sql) : |
| 727 |
$result = $wpdb->query($sql); |
| 728 |
if (!$result): |
| 729 |
$errs[] = mysql_error(); |
| 730 |
endif; |
| 731 |
endforeach; |
| 732 |
|
| 733 |
if (count($alter) > 0) : |
| 734 |
echo "<div class=\"updated\">\n"; |
| 735 |
if (count($errs) > 0) : |
| 736 |
echo "There were some problems processing your "; |
| 737 |
echo "re-subscribe request. [SQL: ".implode('; ', $errs)."]"; |
| 738 |
else : |
| 739 |
echo "Your re-subscribe request(s) have been processed."; |
| 740 |
endif; |
| 741 |
echo "</div>\n"; |
| 742 |
endif; |
| 743 |
|
| 744 |
return true; // Continue on to Syndicated Sites listing |
| 745 |
else : |
| 746 |
$targets = $wpdb->get_results(" |
| 747 |
SELECT * FROM $wpdb->links |
| 748 |
WHERE link_id IN (".implode(",",$link_ids).") |
| 749 |
"); |
| 750 |
?> |
| 751 |
<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> |
| 752 |
<div class="wrap"> |
| 753 |
<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?> |
| 754 |
<input type="hidden" name="action" value="<?php print FWP_RESUB_CHECKED; ?>" /> |
| 755 |
<input type="hidden" name="confirm" value="Undelete" /> |
| 756 |
|
| 757 |
<h2>Re-subscribe to Syndicated Links:</h2> |
| 758 |
<?php |
| 759 |
foreach ($targets as $link) : |
| 760 |
$subscribed = ('Y' == strtoupper($link->link_visible)); |
| 761 |
$link_url = esc_html($link->link_url); |
| 762 |
$link_name = esc_html($link->link_name); |
| 763 |
$link_description = esc_html($link->link_description); |
| 764 |
$link_rss = esc_html($link->link_rss); |
| 765 |
|
| 766 |
if (!$subscribed) : |
| 767 |
?> |
| 768 |
<fieldset> |
| 769 |
<legend><?php echo $link_name; ?></legend> |
| 770 |
<table class="editform" width="100%" cellspacing="2" cellpadding="5"> |
| 771 |
<tr><th scope="row" width="20%"><?php _e('Feed URI:') ?></th> |
| 772 |
<td width="80%"><a href="<?php echo $link_rss; ?>"><?php echo $link_rss; ?></a></td></tr> |
| 773 |
<tr><th scope="row" width="20%"><?php _e('Short description:') ?></th> |
| 774 |
<td width="80%"><?php echo $link_description; ?></span></td></tr> |
| 775 |
<tr><th width="20%" scope="row"><?php _e('Homepage:') ?></th> |
| 776 |
<td width="80%"><a href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td></tr> |
| 777 |
<tr style="vertical-align:top"><th width="20%" scope="row">Subscription <?php _e('Options') ?>:</th> |
| 778 |
<td width="80%"><ul style="margin:0; padding: 0; list-style: none"> |
| 779 |
<li><input type="radio" id="unhide-<?php echo $link->link_id; ?>" |
| 780 |
name="link_action[<?php echo $link->link_id; ?>]" value="unhide" checked="checked" /> |
| 781 |
<label for="unhide-<?php echo $link->link_id; ?>">Turn back on the subscription |
| 782 |
for this syndication source.</label></li> |
| 783 |
<li><input type="radio" id="nothing-<?php echo $link->link_id; ?>" |
| 784 |
name="link_action[<?php echo $link->link_id; ?>]" value="nothing" /> |
| 785 |
<label for="nothing-<?php echo $link->link_id; ?>">Leave this feed as it is. |
| 786 |
I changed my mind.</label></li> |
| 787 |
</ul> |
| 788 |
</table> |
| 789 |
</fieldset> |
| 790 |
<?php |
| 791 |
endif; |
| 792 |
endforeach; |
| 793 |
?> |
| 794 |
|
| 795 |
<div class="submit"> |
| 796 |
<input class="button-primary delete" type="submit" name="submit" value="<?php _e('Re-subscribe to selected feeds »') ?>" /> |
| 797 |
</div> |
| 798 |
</div> |
| 799 |
<?php |
| 800 |
return false; // Don't continue on to Syndicated Sites listing |
| 801 |
endif; |
| 802 |
} |
| 803 |
|
| 804 |
function fwp_multidelete_page () { |
| 805 |
global $wpdb; |
| 806 |
|
| 807 |
// If this is a POST, validate source and user credentials |
| 808 |
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links'); |
| 809 |
|
| 810 |
$link_ids = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array()); |
| 811 |
if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif; |
| 812 |
|
| 813 |
if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Delete'): |
| 814 |
if (isset($GLOBALS['fwp_post']['link_action']) and is_array($GLOBALS['fwp_post']['link_action'])) : |
| 815 |
$actions = $GLOBALS['fwp_post']['link_action']; |
| 816 |
else : |
| 817 |
$actions = array(); |
| 818 |
endif; |
| 819 |
|
| 820 |
$do_it = array( |
| 821 |
'hide' => array(), |
| 822 |
'nuke' => array(), |
| 823 |
'delete' => array(), |
| 824 |
); |
| 825 |
|
| 826 |
foreach ($actions as $link_id => $what) : |
| 827 |
$do_it[$what][] = $link_id; |
| 828 |
endforeach; |
| 829 |
|
| 830 |
$alter = array(); |
| 831 |
if (count($do_it['hide']) > 0) : |
| 832 |
$hidem = "(".implode(', ', $do_it['hide']).")"; |
| 833 |
$alter[] = " |
| 834 |
UPDATE $wpdb->links |
| 835 |
SET link_visible = 'N' |
| 836 |
WHERE link_id IN {$hidem} |
| 837 |
"; |
| 838 |
endif; |
| 839 |
|
| 840 |
if (count($do_it['nuke']) > 0) : |
| 841 |
$nukem = "(".implode(', ', $do_it['nuke']).")"; |
| 842 |
|
| 843 |
// Make a list of the items syndicated from this feed... |
| 844 |
$post_ids = $wpdb->get_col(" |
| 845 |
SELECT post_id FROM $wpdb->postmeta |
| 846 |
WHERE meta_key = 'syndication_feed_id' |
| 847 |
AND meta_value IN {$nukem} |
| 848 |
"); |
| 849 |
|
| 850 |
// ... and kill them all |
| 851 |
if (count($post_ids) > 0) : |
| 852 |
foreach ($post_ids as $post_id) : |
| 853 |
if (FeedWordPressCompatibility::test_version(FWP_SCHEMA_29)) : |
| 854 |
// Force scrubbing of deleted post |
| 855 |
// rather than sending to Trashcan |
| 856 |
wp_delete_post( |
| 857 |
/*postid=*/ $post_id, |
| 858 |
/*force_delete=*/ true |
| 859 |
); |
| 860 |
else : |
| 861 |
wp_delete_post($post_id); |
| 862 |
endif; |
| 863 |
endforeach; |
| 864 |
endif; |
| 865 |
|
| 866 |
$alter[] = " |
| 867 |
DELETE FROM $wpdb->links |
| 868 |
WHERE link_id IN {$nukem} |
| 869 |
"; |
| 870 |
endif; |
| 871 |
|
| 872 |
if (count($do_it['delete']) > 0) : |
| 873 |
$deletem = "(".implode(', ', $do_it['delete']).")"; |
| 874 |
|
| 875 |
// Make the items syndicated from this feed appear to be locally-authored |
| 876 |
$alter[] = " |
| 877 |
DELETE FROM $wpdb->postmeta |
| 878 |
WHERE meta_key = 'syndication_feed_id' |
| 879 |
AND meta_value IN {$deletem} |
| 880 |
"; |
| 881 |
|
| 882 |
// ... and delete the links themselves. |
| 883 |
$alter[] = " |
| 884 |
DELETE FROM $wpdb->links |
| 885 |
WHERE link_id IN {$deletem} |
| 886 |
"; |
| 887 |
endif; |
| 888 |
|
| 889 |
$errs = array(); $success = array (); |
| 890 |
foreach ($alter as $sql) : |
| 891 |
$result = $wpdb->query($sql); |
| 892 |
if (!$result): |
| 893 |
$errs[] = mysql_error(); |
| 894 |
endif; |
| 895 |
endforeach; |
| 896 |
|
| 897 |
if (count($alter) > 0) : |
| 898 |
echo "<div class=\"updated\">\n"; |
| 899 |
if (count($errs) > 0) : |
| 900 |
echo "There were some problems processing your "; |
| 901 |
echo "unsubscribe request. [SQL: ".implode('; ', $errs)."]"; |
| 902 |
else : |
| 903 |
echo "Your unsubscribe request(s) have been processed."; |
| 904 |
endif; |
| 905 |
echo "</div>\n"; |
| 906 |
endif; |
| 907 |
|
| 908 |
return true; // Continue on to Syndicated Sites listing |
| 909 |
else : |
| 910 |
$targets = $wpdb->get_results(" |
| 911 |
SELECT * FROM $wpdb->links |
| 912 |
WHERE link_id IN (".implode(",",$link_ids).") |
| 913 |
"); |
| 914 |
?> |
| 915 |
<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> |
| 916 |
<div class="wrap"> |
| 917 |
<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?> |
| 918 |
<input type="hidden" name="action" value="Unsubscribe" /> |
| 919 |
<input type="hidden" name="confirm" value="Delete" /> |
| 920 |
|
| 921 |
<h2>Unsubscribe from Syndicated Links:</h2> |
| 922 |
<?php foreach ($targets as $link) : |
| 923 |
$subscribed = ('Y' == strtoupper($link->link_visible)); |
| 924 |
$link_url = esc_html($link->link_url); |
| 925 |
$link_name = esc_html($link->link_name); |
| 926 |
$link_description = esc_html($link->link_description); |
| 927 |
$link_rss = esc_html($link->link_rss); |
| 928 |
?> |
| 929 |
<fieldset> |
| 930 |
<legend><?php echo $link_name; ?></legend> |
| 931 |
<table class="editform" width="100%" cellspacing="2" cellpadding="5"> |
| 932 |
<tr><th scope="row" width="20%"><?php _e('Feed URI:') ?></th> |
| 933 |
<td width="80%"><a href="<?php echo $link_rss; ?>"><?php echo $link_rss; ?></a></td></tr> |
| 934 |
<tr><th scope="row" width="20%"><?php _e('Short description:') ?></th> |
| 935 |
<td width="80%"><?php echo $link_description; ?></span></td></tr> |
| 936 |
<tr><th width="20%" scope="row"><?php _e('Homepage:') ?></th> |
| 937 |
<td width="80%"><a href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td></tr> |
| 938 |
<tr style="vertical-align:top"><th width="20%" scope="row">Subscription <?php _e('Options') ?>:</th> |
| 939 |
<td width="80%"><ul style="margin:0; padding: 0; list-style: none"> |
| 940 |
<?php if ($subscribed) : ?> |
| 941 |
<li><input type="radio" id="hide-<?php echo $link->link_id; ?>" |
| 942 |
name="link_action[<?php echo $link->link_id; ?>]" value="hide" checked="checked" /> |
| 943 |
<label for="hide-<?php echo $link->link_id; ?>">Turn off the subscription for this |
| 944 |
syndicated link<br/><span style="font-size:smaller">(Keep the feed information |
| 945 |
and all the posts from this feed in the database, but don't syndicate any |
| 946 |
new posts from the feed.)</span></label></li> |
| 947 |
<?php endif; ?> |
| 948 |
<li><input type="radio" id="nuke-<?php echo $link->link_id; ?>"<?php if (!$subscribed) : ?> checked="checked"<?php endif; ?> |
| 949 |
name="link_action[<?php echo $link->link_id; ?>]" value="nuke" /> |
| 950 |
<label for="nuke-<?php echo $link->link_id; ?>">Delete this syndicated link and all the |
| 951 |
posts that were syndicated from it</label></li> |
| 952 |
<li><input type="radio" id="delete-<?php echo $link->link_id; ?>" |
| 953 |
name="link_action[<?php echo $link->link_id; ?>]" value="delete" /> |
| 954 |
<label for="delete-<?php echo $link->link_id; ?>">Delete this syndicated link, but |
| 955 |
<em>keep</em> posts that were syndicated from it (as if they were authored |
| 956 |
locally).</label></li> |
| 957 |
<li><input type="radio" id="nothing-<?php echo $link->link_id; ?>" |
| 958 |
name="link_action[<?php echo $link->link_id; ?>]" value="nothing" /> |
| 959 |
<label for="nothing-<?php echo $link->link_id; ?>">Keep this feed as it is. I changed |
| 960 |
my mind.</label></li> |
| 961 |
</ul> |
| 962 |
</table> |
| 963 |
</fieldset> |
| 964 |
<?php endforeach; ?> |
| 965 |
|
| 966 |
<div class="submit"> |
| 967 |
<input class="delete" type="submit" name="submit" value="<?php _e('Unsubscribe from selected feeds »') ?>" /> |
| 968 |
</div> |
| 969 |
</div> |
| 970 |
<?php |
| 971 |
return false; // Don't continue on to Syndicated Sites listing |
| 972 |
endif; |
| 973 |
} |
| 974 |
|
| 975 |
$syndicationPage = new FeedWordPressSyndicationPage; |
| 976 |
$syndicationPage->display(); |
| 977 |
|
| 978 |
|