PluginProbe
FeedWordPress / 2010.0528
FeedWordPress v2010.0528
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
← All changes | syndication.php +397 -968 2008.10302010.0528 View file →
@@ -7,15 +7,201 @@
7 7
8 8 if (fwp_test_wp_version(0, FWP_SCHEMA_25)) :
9 9 define('FWP_UPDATE_CHECKED', 'Update Checked Links');
10 10 define('FWP_UNSUB_CHECKED', 'Unsubscribe from Checked Links');
11 - define('FWP_SYNDICATE_NEW', 'Syndicate »');
11 + define('FWP_SYNDICATE_NEW', 'Syndicate ...');
12 12 else :
13 13 define('FWP_UPDATE_CHECKED', 'Update Checked');
14 14 define('FWP_UNSUB_CHECKED', 'Unsubscribe');
15 - define('FWP_SYNDICATE_NEW', 'Syndicate »');
15 + define('FWP_SYNDICATE_NEW', 'Syndicate ...');
16 16 endif;
17 17
18 +class FeedWordPressSyndicationPage extends FeedWordPressAdminPage {
19 + function FeedWordPressSyndicationPage () {
20 + FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpresssyndication', /*link=*/ NULL);
21 +
22 + // No over-arching form element
23 + $this->dispatch = NULL;
24 + $this->filename = __FILE__;
25 + } /* FeedWordPressSyndicationPage constructor */
26 +
27 + function has_link () { return false; }
28 +
29 + function display () {
30 + global $wpdb;
31 +
32 + if (FeedWordPress::needs_upgrade()) :
33 + fwp_upgrade_page();
34 + return;
35 + endif;
36 +
37 + ?>
38 + <?php $cont = true;
39 + if (isset($_REQUEST['action'])):
40 + if ($_REQUEST['action'] == 'feedfinder' or $_REQUEST['action']==FWP_SYNDICATE_NEW) : $cont = fwp_feedfinder_page();
41 + elseif ($_REQUEST['action'] == 'switchfeed') : $cont = fwp_switchfeed_page();
42 + elseif ($_REQUEST['action'] == FWP_UNSUB_CHECKED or $_REQUEST['action'] == 'Unsubscribe') : $cont = fwp_multidelete_page();
43 + endif;
44 + endif;
45 +
46 + if ($cont):
47 + ?>
48 + <style type="text/css">
49 + .heads-up {
50 + background-color: #d0d0d0;
51 + color: black;
52 + padding: 1.0em;
53 + margin: 0.5em 4.0em !important;
54 + }
55 + .update-form.with-donation {
56 + margin-right: 50%;
57 + min-height: 255px;
58 + }
59 + .donation-form, .donation-thanks {
60 + background-color: #ffffcc;
61 + text-align: left;
62 + padding: 0.5em 0.5em;
63 + border-left: thin dashed #777777;
64 + font-size: 70%;
65 + position: absolute;
66 + top: 0; bottom: 0; right: 0; left: auto;
67 + width: 50%;
68 + }
69 + .donation-thanks {
70 + background-color: #ccffcc;
71 + }
72 + .donation-thanks .signature {
73 + text-align: right;
74 + font-style: italic;
75 + }
76 + .donation-form h4, .donation-thanks h4 {
77 + font-size: 10px;
78 + text-align: center;
79 + border-bottom: 1px solid #777777;
80 + margin: 0px;
81 + }
82 + .donation-form .donate {
83 + text-align: center;
84 + }
85 + .donation-form .sod-off {
86 + padding-top: 0.5em;
87 + margin-top: 0.5em;
88 + border-top: thin solid #777777;
89 + }
90 + </style>
91 + <?php
92 + $links = FeedWordPress::syndicated_links();
93 + $this->open_sheet('Syndicated Sites');
94 + ?>
95 + <div id="post-body">
96 + <?php
97 + if ($links) :
98 + fwp_add_meta_box(
99 + /*id=*/ 'feedwordpress_update_box',
100 + /*title=*/ __('Update feeds now'),
101 + /*callback=*/ 'fwp_syndication_manage_page_update_box',
102 + /*page=*/ $this->meta_box_context(),
103 + /*context =*/ $this->meta_box_context()
104 + );
105 + endif;
106 + fwp_add_meta_box(
107 + /*id=*/ 'feedwordpress_feeds_box',
108 + /*title=*/ __('Syndicated sources'),
109 + /*callback=*/ 'fwp_syndication_manage_page_links_box',
110 + /*page=*/ $this->meta_box_context(),
111 + /*context =*/ $this->meta_box_context()
112 + );
113 + if (FeedWordPressCompatibility::test_version(0, FWP_SCHEMA_25)) :
114 + fwp_add_meta_box(
115 + /*id=*/ 'feedwordpress_add_feed_box',
116 + /*title=*/ 'Add a new syndicated source',
117 + /*callback=*/ 'fwp_syndication_manage_page_add_feed_box',
118 + /*page=*/ $this->meta_box_context(),
119 + /*context=*/ $this->meta_box_context()
120 + );
121 + endif;
122 +
123 + do_action('feedwordpress_admin_page_syndication_meta_boxes', $this);
124 + ?>
125 + <div class="metabox-holder">
126 + <?php
127 + fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this);
128 + ?>
129 + </div> <!-- class="metabox-holder" -->
130 + </div> <!-- id="post-body" -->
131 +
132 + <?php $this->close_sheet(/*dispatch=*/ NULL); ?>
133 +
134 + <div style="display: none">
135 + <div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug -->
136 + </div>
137 + <?php
138 + endif;
139 + } /* FeedWordPressSyndicationPage::display () */
140 +
141 + function bleg_thanks ($page, $box = NULL) {
142 + ?>
143 + <div class="donation-thanks">
144 + <h4>Thank you!</h4>
145 + <p><strong>Thank you</strong> for your contribution to <a href="http://feedwordpress.radgeek.com/">FeedWordPress</a> development.
146 + Your generous gifts make ongoing support and development for
147 + FeedWordPress possible.</p>
148 + <p>If you have any questions about FeedWordPress, or if there
149 + is anything I can do to help make FeedWordPress more useful for
150 + you, please <a href="http://feedwordpress.radgeek.com/contact">contact me</a>
151 + and let me know what you're thinking about.</p>
152 + <p class="signature">&#8212;<a href="http://radgeek.com/">Charles Johnson</a>, Developer, <a href="http://feedwordpress.radgeek.com/">FeedWordPress</a>.</p>
153 + </div>
154 + <?php
155 + } /* FeedWordPressSyndicationPage::bleg_thanks () */
156 +
157 + function bleg_box ($page, $box = NULL) {
158 + ?>
159 +<div class="donation-form">
160 +<h4>Keep FeedWordPress improving</h4>
161 +<form action="https://www.paypal.com/cgi-bin/webscr" accept-charset="UTF-8" method="post"><div>
162 +<p><a href="http://feedwordpress.radgeek.com/">FeedWordPress</a> makes syndication
163 +simple and empowers you to stream content from all over the web into your
164 +WordPress hub. That's got to be worth a few lattes. If you're finding FWP useful,
165 +<a href="http://feedwordpress.radgeek.com/donation/">a modest gift</a>
166 +is the best way to support steady progress on development, enhancements,
167 +support, and documentation.</p>
168 +<div class="donate">
169 +<input type="hidden" name="business" value="commerce@radgeek.com" />
170 +<input type="hidden" name="cmd" value="_xclick" />
171 +<input type="hidden" name="item_name" value="FeedWordPress donation" />
172 +<input type="hidden" name="no_shipping" value="1" />
173 +<input type="hidden" name="return" value="<?php bloginfo('url'); ?>/wp-admin/admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>&amp;paid=yes" />
174 +<input type="hidden" name="currency_code" value="USD" />
175 +<input type="hidden" name="notify_url" value="http://feedwordpress.radgeek.com/ipn/donation" />
176 +<input type="hidden" name="custom" value="1" />
177 +<input type="image" name="submit" src="https://www.paypal.com/en_GB/i/btn/btn_donate_SM.gif" alt="Donate through PayPal" />
178 +</div>
179 +</div></form>
180 +
181 +<p>You can make a gift online (or
182 +<a href="http://feedwordpress.radgeek.com/donation">set up an automatic
183 +regular donation</a>) using an existing PayPal account or any major credit card.</p>
184 +
185 +<div class="sod-off">
186 +<form style="text-align: center" action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>" method="POST"><div>
187 +<input class="button-primary" type="submit" name="maybe_later" value="Maybe Later" />
188 +<input class="button-secondary" type="submit" name="go_away" value="Dismiss" />
189 +</div></form>
190 +</div>
191 +</div> <!-- class="donation-form" -->
192 + <?php
193 + } /* FeedWordPressSyndicationPage::bleg_box () */
194 +
195 + /**
196 + * Override the default display of a save-settings button and replace
197 + * it with nothing.
198 + */
199 + function interstitial () {
200 + /* NOOP */
201 + } /* FeedWordPressSyndicationPage::interstitial() */
202 +} /* class FeedWordPressSyndicationPage */
203 +
18 204 function fwp_dashboard_update_if_requested () {
19 205 global $wpdb;
20 206
21 207 if (isset($_POST['update']) or isset($_POST['action']) or isset($_POST['update_uri'])) :
@@ -40,13 +226,21 @@
40 226 elseif (isset($_POST['update_uri'])) :
41 227 $update_set[] = $_POST['update_uri'];
42 228 endif;
43 229
44 -
230 + shuffle($update_set); // randomize order for load balancing purposes...
45 231 if ($fwp_update_invoke != 'get' and count($update_set) > 0) : // Only do things with side-effects for HTTP POST or command line
46 - $feedwordpress =& new FeedWordPress;
232 + $feedwordpress = new FeedWordPress;
47 233 add_action('feedwordpress_check_feed', 'update_feeds_mention');
48 -
234 + add_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3);
235 +
236 + $crash_dt = (int) get_option('feedwordpress_update_time_limit');
237 + if ($crash_dt > 0) :
238 + $crash_ts = time() + $crash_dt;
239 + else :
240 + $crash_ts = NULL;
241 + endif;
242 +
49 243 if (fwp_test_wp_version(FWP_SCHEMA_25)) :
50 244 echo "<div class=\"youare\">\n";
51 245 else :
52 246 echo "<div class=\"updated\">\n";
@@ -53,10 +247,15 @@
53 247 endif;
54 248 echo "<ul>\n";
55 249 $tdelta = NULL;
56 250 foreach ($update_set as $uri) :
251 + if (!is_null($crash_ts) and (time() > $crash_ts)) :
252 + echo "<li><p><strong>Further updates postponed:</strong> update time limit of ".$crash_dt." second".(($crash_dt==1)?"":"s")." exceeded.</p></li>";
253 + break;
254 + endif;
255 +
57 256 if ($uri == '*') : $uri = NULL; endif;
58 - $delta = $feedwordpress->update($uri);
257 + $delta = $feedwordpress->update($uri, $crash_ts);
59 258 if (!is_null($delta)) :
60 259 if (is_null($tdelta)) :
61 260 $tdelta = $delta;
62 261 else :
@@ -76,92 +275,91 @@
76 275 echo "<p>Update complete.".implode(' and', $mesg)."</p>";
77 276 echo "\n"; flush();
78 277 endif;
79 278 echo "</div> <!-- class=\"updated\" -->\n";
80 - elseif (fwp_test_wp_version(FWP_SCHEMA_25)) :
81 -?>
82 - <p class="youare">Check currently scheduled feeds for new and updated posts.</p>
83 -<?php
84 279 endif;
85 280 }
86 281
87 -function fwp_syndication_manage_page () {
88 - global $wpdb;
282 +function fwp_syndication_manage_page_add_feed_box ($object = NULL, $box = NULL) {
283 + ?>
284 + <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>" method="post">
285 + <div>
286 + <?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?>
287 + <label for="add-uri">Website or feed:</label>
288 + <input type="text" name="lookup" id="add-uri" value="URI" size="64" />
289 + <input type="hidden" name="action" value="feedfinder" />
290 + </div>
291 + <div class="submit"><input type="submit" value="<?php print FWP_SYNDICATE_NEW; ?>" /></div>
292 + </form>
293 + <?php
294 +}
89 295
90 - if (FeedWordPress::needs_upgrade()) :
91 - fwp_upgrade_page();
92 - return;
296 +define('FEEDWORDPRESS_BLEG_MAYBE_LATER_OFFSET', (60 /*sec/min*/ * 60 /*min/hour*/ * 24 /*hour/day*/ * 31 /*days*/));
297 +define('FEEDWORDPRESS_BLEG_ALREADY_PAID_OFFSET', (60 /*sec/min*/ * 60 /*min/hour*/ * 24 /*hour/day*/ * 183 /*days*/));
298 +function fwp_syndication_manage_page_update_box ($object = NULL, $box = NULL) {
299 + $bleg_box_hidden = null;
300 + if (isset($_POST['maybe_later'])) :
301 + $bleg_box_hidden = time() + FEEDWORDPRESS_BLEG_MAYBE_LATER_OFFSET;
302 + elseif (isset($_REQUEST['paid']) and $_REQUEST['paid']) :
303 + $bleg_box_hidden = time() + FEEDWORDPRESS_BLEG_ALREADY_PAID_OFFSET;
304 + elseif (isset($_POST['go_away'])) :
305 + $bleg_box_hidden = 'permanent';
93 306 endif;
94 307
308 + if (!is_null($bleg_box_hidden)) :
309 + update_option('feedwordpress_bleg_box_hidden', $bleg_box_hidden);
310 + else :
311 + $bleg_box_hidden = get_option('feedwordpress_bleg_box_hidden');
312 + endif;
95 313 ?>
96 -<?php $cont = true;
97 -if (isset($_REQUEST['action'])):
98 - if ($_REQUEST['action'] == 'feedfinder' or $_REQUEST['action'] == FWP_SYNDICATE_NEW) : $cont = fwp_feedfinder_page();
99 - elseif ($_REQUEST['action'] == 'switchfeed') : $cont = fwp_switchfeed_page();
100 - elseif ($_REQUEST['action'] == 'linkedit') : $cont = fwp_linkedit_page();
101 - elseif ($_REQUEST['action'] == FWP_UNSUB_CHECKED or $_REQUEST['action'] == 'Unsubscribe') : $cont = fwp_multidelete_page();
314 + <?php
315 + $bleg_box_ready = (!$bleg_box_hidden or (is_numeric($bleg_box_hidden) and $bleg_box_hidden < time()));
316 + if (isset($_REQUEST['paid']) and $_REQUEST['paid']) :
317 + $object->bleg_thanks($subject, $box);
318 + elseif ($bleg_box_ready) :
319 + $object->bleg_box($object, $box);
102 320 endif;
103 -endif;
321 + ?>
104 322
105 -if ($cont):
106 -?>
107 -<?php
108 - $links = FeedWordPress::syndicated_links();
323 + <form
324 + action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>"
325 + method="POST"
326 + class="update-form<?php if ($bleg_box_ready) : ?> with-donation<?php endif; ?>"
327 + >
328 + <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
329 + <p>Check currently scheduled feeds for new and updated posts.</p>
109 330
110 - if (fwp_test_wp_version(0, FWP_SCHEMA_25)) :
111 - fwp_dashboard_update_if_requested();
112 - endif;
331 + <?php
332 + fwp_dashboard_update_if_requested();
113 333
114 - if ($links): // only display Update panel if there are some links to update....
334 + if (!get_option('feedwordpress_automatic_updates')) :
115 335 ?>
116 - <form action="" method="POST">
117 - <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
118 - <div class="wrap">
119 - <div id="rightnow">
120 - <h3 class="reallynow"><span>Update feeds now</span>
121 - <input type="hidden" name="update_uri" value="*" /><input style="float: right; border: none;" class="rbutton" type="submit" name="update" value="Update" />
122 - <br class="clear"/></h3>
123 - <?php else : ?>
124 - <div class="wrap">
125 - <h2>Update feeds now</h2>
126 - <?php endif; ?>
127 -
128 - <?php
129 - if (fwp_test_wp_version(FWP_SCHEMA_25)) :
130 - fwp_dashboard_update_if_requested();
131 - else :
132 -?>
133 -<p>Check currently scheduled feeds for new and updated posts.</p>
134 -<?php
336 + <p class="heads-up"><strong>Note:</strong> Automatic updates are currently turned
337 + <strong>off</strong>. New posts from your feeds will not be syndicated
338 + until you manually check for them here. You can turn on automatic
339 + updates under <a href="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/feeds-page.php">Feed &amp; Update Settings<a></a>.</p>
340 + <?php
135 341 endif;
136 342 ?>
137 343
138 -<?php if (!get_option('feedwordpress_automatic_updates')) : ?>
139 - <p class="youhave"><strong>Note:</strong> Automatic updates are currently turned
140 - <strong>off</strong>. New posts from your feeds will not be syndicated
141 - until you manually check for them here. You can turn on automatic
142 - updates under <a href="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/syndication-options.php">Syndication
143 - Options</a>.</p>
144 -<?php endif; ?>
145 -
146 - <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
147 - <div class="submit"><input type="hidden" name="update_uri" value="*" /><input type="submit" name="update" value="Update" /></div>
148 - <?php endif; ?>
149 -
150 - <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
344 + <div class="submit"><input type="hidden" name="update_uri" value="*" /><input class="button-primary" type="submit" name="update" value="Update" /></div>
345 +
346 + <?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
347 + <br style="clear: both" />
348 + <?php /* elseif (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) :
151 349 </div> <!-- id="rightnow" -->
152 - <?php endif; ?>
153 - </div> <!-- class="wrap" -->
350 + <?php */ endif; ?>
154 351 </form>
155 352 <?php
156 - endif;
353 +} /* function fwp_syndication_manage_page_update_box () */
354 +
355 +function fwp_syndication_manage_page_links_box ($object = NULL, $box = NULL) {
356 + $links = FeedWordPress::syndicated_links();
157 357 ?>
358 + <form id="syndicated-links" action="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/<?php echo basename(__FILE__); ?>" method="post">
359 + <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
158 360
159 - <div class="wrap">
160 - <form id="syndicated-links" action="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/<?php echo basename(__FILE__); ?>" method="post">
161 - <h2>Syndicated Sites</h2>
162 -<?php $alt_row = true;
163 - if ($links): ?>
361 +<?php $alt_row = true; ?>
164 362
165 363 <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
166 364 <div class="tablenav">
167 365 <div class="alignright">
@@ -166,32 +364,19 @@
166 364 <div class="tablenav">
167 365 <div class="alignright">
168 366 <label for="add-uri">Add new source:</label>
169 367 <input type="text" name="lookup" id="add-uri" value="Website or feed URI" />
170 -<script type="text/javascript">
171 -jQuery(document).ready( function () {
172 - var addUri = jQuery("#add-uri");
173 - var box = addUri.get(0);
174 - if (box.value==box.defaultValue) { addUri.addClass('form-input-tip'); }
175 - addUri.focus(function() {
176 - if ( this.value == this.defaultValue )
177 - jQuery(this).val( '' ).removeClass( 'form-input-tip' );
178 - });
179 - addUri.blur(function() {
180 - if ( this.value == '' )
181 - jQuery(this).val( this.defaultValue ).addClass( 'form-input-tip' );
182 - });
368 + <?php FeedWordPressSettingsUI::magic_input_tip_js('add-uri'); ?>
183 369
184 -} );
185 -</script>
186 -
187 370 <input type="hidden" name="action" value="feedfinder" />
188 371 <input type="submit" class="button-secondary" name="action" value="<?php print FWP_SYNDICATE_NEW; ?>" /></div>
189 372
373 +<?php if (count($links) > 0) : ?>
190 374 <div class="alignleft">
191 375 <input class="button-secondary" type="submit" name="action" value="<?php print FWP_UPDATE_CHECKED; ?>" />
192 376 <input class="button-secondary delete" type="submit" class="delete" name="action" value="<?php print FWP_UNSUB_CHECKED; ?>" />
193 377 </div>
378 +<?php endif; ?>
194 379
195 380 <br class="clear" />
196 381 </div>
197 382 <br class="clear" />
@@ -201,929 +386,171 @@
201 386 <table width="100%" cellpadding="3" cellspacing="3">
202 387 <?php endif; ?>
203 388 <thead>
204 389 <tr>
205 - <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : $span = 3; ?>
206 - <th class="check-column" scope="col"><input type="checkbox" <?php if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_26)) : ?>onclick="checkAll(document.getElementById('syndicated-links'));"<?php endif; ?> /></th>
207 - <?php else : $span = 4; ?>
208 - <?php endif; ?>
209 -<th width="20%" scope="col"><?php _e('Name'); ?></th>
210 -<th width="40%" scope="col"><?php _e('Feed'); ?></th>
211 -<th class="action-links" scope="col" colspan="<?php print $span; ?>"><?php _e('Action'); ?></th>
390 +<th class="check-column" scope="col"><?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
391 +<input type="checkbox" <?php if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_26)) : ?>onclick="checkAll(document.getElementById('syndicated-links'));"<?php endif; ?> />
392 +<?php endif; ?></th>
393 +<th scope="col"><?php _e('Name'); ?></th>
394 +<th scope="col"><?php _e('Feed'); ?></th>
395 +<th scope="col"><?php _e('Updated'); ?></th>
212 396 </tr>
213 397 </thead>
214 398
215 399 <tbody>
216 -<?php foreach ($links as $link):
400 +<?php if (count($links) > 0): foreach ($links as $link):
217 401 $alt_row = !$alt_row; ?>
218 402 <tr<?php echo ($alt_row?' class="alternate"':''); ?>>
219 - <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
220 403 <th class="check-column" scope="row"><input type="checkbox" name="link_ids[]" value="<?php echo $link->link_id; ?>" /></th>
221 - <?php endif; ?>
222 -
223 -<td><a href="<?php echo wp_specialchars($link->link_url, 'both'); ?>"><?php echo wp_specialchars($link->link_name, 'both'); ?></a></td>
224 -<?php
225 - if (strlen($link->link_rss) > 0):
226 - $caption='Switch Feed';
227 - $uri_bits = parse_url($link->link_rss);
228 - $uri_bits['host'] = preg_replace('/^www\./i', '', $uri_bits['host']);
229 - $display_uri =
230 - (isset($uri_bits['user'])?$uri_bits['user'].'@':'')
231 - .(isset($uri_bits['host'])?$uri_bits['host']:'')
232 - .(isset($uri_bits['port'])?':'.$uri_bits['port']:'')
233 - .(isset($uri_bits['path'])?$uri_bits['path']:'')
234 - .(isset($uri_bits['query'])?'?'.$uri_bits['query']:'');
235 - if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'&#8230;'; endif;
236 -?>
237 - <td>
238 - <strong><a href="<?php echo wp_specialchars($link->link_rss, 'both'); ?>"><?php echo wp_specialchars($display_uri, 'both'); ?></a></strong></td>
239 404 <?php
240 - else:
241 - $caption='Find Feed';
405 + if (strlen($link->link_rss) > 0):
406 + $caption=__('Switch Feed');
407 + else :
408 + $caption=__('Find Feed');
409 + endif;
242 410 ?>
411 +<td>
412 +<strong><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/feeds-page.php&amp;link_id=<?php echo $link->link_id; ?>"><?php echo esc_html($link->link_name); ?></a></strong>
413 +<div class="row-actions"><div><strong>Settings &gt;</strong>
414 +<a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/feeds-page.php&amp;link_id=<?php echo $link->link_id; ?>"><?php _e('Feed'); ?></a>
415 +| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/posts-page.php&amp;link_id=<?php echo $link->link_id; ?>"><?php _e('Posts'); ?></a>
416 +| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/authors-page.php&amp;link_id=<?php echo $link->link_id; ?>"><?php _e('Authors'); ?></a>
417 +| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/categories-page.php&amp;link_id=<?php echo $link->link_id; ?>"><?php print htmlspecialchars(__('Categories'.FEEDWORDPRESS_AND_TAGS)); ?></a></div>
418 +<div><strong>Actions &gt;</strong>
419 +<a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=feedfinder"><?php echo $caption; ?></a>
420 +| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=Unsubscribe"><?php _e('Unsubscribe'); ?></a>
421 +| <a href="<?php echo esc_html($link->link_url); ?>"><?php _e('View')?></a></div>
422 +</div>
423 +</td>
424 + <?php if (strlen($link->link_rss) > 0): ?>
425 + <td><a href="<?php echo esc_html($link->link_rss); ?>"><?php echo esc_html(feedwordpress_display_url($link->link_rss, 32)); ?></a></td>
426 + <?php else: ?>
243 427 <td style="background-color:#FFFFD0"><p><strong>no
244 428 feed assigned</strong></p></td>
429 + <?php endif; ?>
430 +
431 + <td><?php
432 + $sLink = new SyndicatedLink($link->link_id);
433 + if (isset($sLink->settings['update/last'])) :
434 + print fwp_time_elapsed($sLink->settings['update/last']);
435 + else :
436 + _e('None yet');
437 + endif;
438 +
439 + print "<div style='font-style:italic;size:0.9em'>Ready for next update ";
440 + if (isset($sLink->settings['update/ttl']) and is_numeric($sLink->settings['update/ttl'])) :
441 + if (isset($sLink->settings['update/timed']) and $sLink->settings['update/timed']=='automatically') :
442 + $next = $sLink->settings['update/last'] + ((int) $sLink->settings['update/ttl'] * 60);
443 + print fwp_time_elapsed($next);
444 + if (FEEDWORDPRESS_DEBUG) : print " [".(($next-time())/60)." minutes]"; endif;
445 + else :
446 + echo "every ".$sLink->settings['update/ttl']." minute".(($sLink->settings['update/ttl']!=1)?"s":"");
447 + endif;
448 + else:
449 + echo "as soon as possible";
450 + endif;
451 + unset($sLink);
452 + print "</div>";
453 +?>
454 + </td>
455 + </tr>
245 456 <?php
246 - endif;
457 + endforeach;
458 + else :
247 459 ?>
248 - <td><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=linkedit" class="edit"><?php _e('Edit')?></a></td>
249 - <td><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=feedfinder" class="edit"><?php echo $caption; ?></a></td>
250 - <td><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=Unsubscribe" class="delete"><?php _e('Unsubscribe'); ?></a></td>
251 - <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
252 - <td><input type="checkbox" name="link_ids[]" value="<?php echo $link->link_id; ?>" /></td>
460 +<tr><td colspan="<?php print $span+2; ?>"><p>There are no websites currently listed for syndication.</p></td></tr>
253 461 <?php
254 - endif;
255 - echo "\n\t</tr>";
256 - endforeach;
462 + endif;
257 463 ?>
258 464 </tbody>
259 465 </table>
260 466
261 - <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
262 - <br/><hr/>
263 - <div class="submit"><input type="submit" class="delete" name="action" value="<?php print FWP_UNSUB_CHECKED; ?>" />
264 - <input type="submit" name="action" value="<?php print FWP_UPDATE_CHECKED; ?>" /></div>
265 - <?php endif; ?>
467 +<?php if (count($links) > 0 and fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
468 +<br/><hr/>
469 +<div class="submit"><input type="submit" class="delete" name="action" value="<?php print FWP_UNSUB_CHECKED; ?>" />
470 +<input type="submit" name="action" value="<?php print FWP_UPDATE_CHECKED; ?>" /></div>
471 +<?php endif; ?>
266 472
267 -
268 -<?php
269 - else:
270 -?>
271 -
272 -<p>There are no websites currently listed for syndication.</p>
273 -
274 -<?php endif; ?>
275 -
276 473 </form>
277 -
278 - </div> <!-- class="wrap" -->
279 -
280 - <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
281 - <div class="wrap">
282 - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
283 - <h2>Add a new syndicated site:</h2>
284 - <div>
285 - <label for="add-uri">Website or newsfeed:</label>
286 - <input type="text" name="lookup" id="add-uri" value="URI" size="64" />
287 - <input type="hidden" name="action" value="feedfinder" />
288 - </div>
289 - <div class="submit"><input type="submit" value="Syndicate &raquo;" /></div>
290 - </form>
291 - </div> <!-- class="wrap" -->
292 - <?php endif; ?>
293 -
294 -<div style="display: none">
295 -<div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug -->
296 -</div>
297 474 <?php
298 -endif;
299 -}
475 +} /* function fwp_syndication_manage_page_links_box() */
300 476
301 477 function fwp_feedfinder_page () {
302 - global $wpdb;
478 + global $post_source;
479 +
480 + $post_source = 'feedwordpress_feeds';
481 +
482 + // With action=feedfinder, this goes directly to the feedfinder page
483 + include_once(dirname(__FILE__) . '/feeds-page.php');
484 + return false;
485 +} /* function fwp_feedfinder_page () */
303 486
304 - $lookup = (isset($_REQUEST['lookup'])?$_REQUEST['lookup']:NULL);
305 -
306 - if (isset($_REQUEST['link_id']) and ($_REQUEST['link_id']!=0)):
307 - $link_id = $_REQUEST['link_id'];
308 - if (!is_numeric($link_id)) : FeedWordPress::critical_bug('fwp_feedfinder_page::link_id', $link_id, __LINE__); endif;
309 -
310 - $link = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id='".$wpdb->escape($link_id)."'");
311 - if (is_object($link)):
312 - if (is_null($lookup)) $lookup = $link->link_url;
313 - $name = wp_specialchars($link->link_name, 'both');
314 - else:
315 - die (__("Cheatin' uh ?"));
316 - endif;
317 - else:
318 - $name = "New Syndicated Feed";
319 - $link_id = 0;
320 - endif;
321 -?>
322 - <div class="wrap">
323 - <h2>Feed Finder: <?php echo $name; ?></h2>
324 -<?php
325 - $f =& new FeedFinder($lookup);
326 - $feeds = $f->find();
327 - if (count($feeds) > 0):
328 - foreach ($feeds as $key => $f):
329 - $rss = fetch_rss($f);
330 - if ($rss):
331 - $feed_title = isset($rss->channel['title'])?$rss->channel['title']:$rss->channel['link'];
332 - $feed_link = isset($rss->channel['link'])?$rss->channel['link']:'';
333 -?>
334 - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
335 - <fieldset style="clear: both">
336 - <legend><?php echo $rss->feed_type; ?> <?php echo $rss->feed_version; ?> feed</legend>
337 -
338 - <?php if ($link_id===0): ?>
339 - <input type="hidden" name="feed_title" value="<?php echo wp_specialchars($feed_title, 'both'); ?>" />
340 - <input type="hidden" name="feed_link" value="<?php echo wp_specialchars($feed_link, 'both'); ?>" />
341 - <?php endif; ?>
342 -
343 - <input type="hidden" name="link_id" value="<?php echo $link_id; ?>" />
344 - <input type="hidden" name="feed" value="<?php echo wp_specialchars($f, 'both'); ?>" />
345 - <input type="hidden" name="action" value="switchfeed" />
346 -
347 - <div>
348 - <div style="float:right; background-color:#D0D0D0; color: black; width:45%; font-size:70%; border-left: 1px dotted #A0A0A0; padding-left: 0.5em; margin-left: 1.0em">
349 -<?php if (count($rss->items) > 0): ?>
350 - <?php $item = $rss->items[0]; ?>
351 - <h3>Sample Item</h3>
352 - <ul>
353 - <li><strong>Title:</strong> <a href="<?php echo $item['link']; ?>"><?php echo $item['title']; ?></a></li>
354 - <li><strong>Date:</strong> <?php echo isset($item['date_timestamp']) ? date('d-M-y g:i:s a', $item['date_timestamp']) : 'unknown'; ?></li>
355 - </ul>
356 - <div class="entry">
357 - <?php echo (isset($item['content']['encoded'])?$item['content']['encoded']:$item['description']); ?>
358 - </div>
359 -<?php else: ?>
360 - <h3>No Items</h3>
361 - <p>FeedWordPress found no posts on this feed.</p>
362 -<?php endif; ?>
363 - </div>
364 -
365 - <div>
366 - <h3>Feed Information</h3>
367 - <ul>
368 - <li><strong>Website:</strong> <a href="<?php echo $feed_link; ?>"><?php echo is_null($feed_title)?'<em>Unknown</em>':$feed_title; ?></a></li>
369 - <li><strong>Feed URI:</strong> <a href="<?php echo wp_specialchars($f, 'both'); ?>"><?php echo wp_specialchars($f, 'both'); ?></a> (<a title="Check feed &lt;<?php echo wp_specialchars($f, 'both'); ?>&gt; for validity" href="http://feedvalidator.org/check.cgi?url=<?php echo urlencode($f); ?>">validate</a>)</li>
370 - <li><strong>Encoding:</strong> <?php echo isset($rss->encoding)?wp_specialchars($rss->encoding, 'both'):"<em>Unknown</em>"; ?></li>
371 - <li><strong>Description:</strong> <?php echo isset($rss->channel['description'])?wp_specialchars($rss->channel['description'], 'both'):"<em>Unknown</em>"; ?></li>
372 - </ul>
373 - <div class="submit"><input type="submit" name="Use" value="&laquo; Use this feed" /></div>
374 - <div class="submit"><input type="submit" name="Cancel" value="&laquo; Cancel" /></div>
375 - </div>
376 - </div>
377 - </fieldset>
378 - </form>
379 -<?php endif;
380 - endforeach;
381 - else:
382 - echo "<p><strong>no feed found</strong></p>";
383 - endif;
384 -?>
385 - </div>
386 -
387 - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
388 - <div class="wrap">
389 - <h2>Use another feed</h2>
390 - <div><label>Feed:</label>
391 - <input type="text" name="lookup" value="URI" />
392 - <input type="hidden" name="link_id" value="<?php echo $link_id; ?>" />
393 - <input type="hidden" name="action" value="feedfinder" /></div>
394 - <div class="submit"><input type="submit" value="Use this feed &raquo;" /></div>
395 - </div>
396 - </form>
397 -<?php
398 - return false; // Don't continue
399 -}
400 -
401 487 function fwp_switchfeed_page () {
402 488 global $wpdb, $wp_db_version;
489 + global $fwp_post;
403 490
404 - check_admin_referer();
405 - if (!isset($_REQUEST['Cancel'])):
406 - if (!current_user_can('manage_links')):
407 - die (__("Cheatin' uh ?"));
408 - elseif (isset($_REQUEST['link_id']) and ($_REQUEST['link_id']==0)):
409 - $link_id = FeedWordPress::syndicate_link($_REQUEST['feed_title'], $_REQUEST['feed_link'], $_REQUEST['feed']);
410 - if ($link_id): ?>
411 -<div class="updated"><p><a href="<?php echo $_REQUEST['feed_link']; ?>"><?php echo wp_specialchars($_REQUEST['feed_title'], 'both'); ?></a>
412 -has been added as a contributing site, using the newsfeed at &lt;<a href="<?php echo $_REQUEST['feed']; ?>"><?php echo wp_specialchars($_REQUEST['feed'], 'both'); ?></a>&gt;.</p></div>
491 + // If this is a POST, validate source and user credentials
492 + FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_switchfeed', /*capability=*/ 'manage_links');
493 +
494 + $changed = false;
495 + if (!isset($fwp_post['Cancel'])):
496 + if (isset($fwp_post['save_link_id']) and ($fwp_post['save_link_id']=='*')) :
497 + $changed = true;
498 + $link_id = FeedWordPress::syndicate_link($fwp_post['feed_title'], $fwp_post['feed_link'], $fwp_post['feed']);
499 + if ($link_id):
500 + $existingLink = new SyndicatedLink($link_id);
501 + ?>
502 +<div class="updated"><p><a href="<?php print $fwp_post['feed_link']; ?>"><?php print esc_html($fwp_post['feed_title']); ?></a>
503 +has been added as a contributing site, using the feed at
504 +&lt;<a href="<?php print $fwp_post['feed']; ?>"><?php print esc_html($fwp_post['feed']); ?></a>&gt;.
505 +| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/feeds-page.php&amp;link_id=<?php print $link_id; ?>">Configure settings</a>.</p></div>
413 506 <?php else: ?>
414 -<div class="updated"><p>There was a problem adding the newsfeed. [SQL: <?php echo wp_specialchars(mysql_error(), 'both'); ?>]</p></div>
507 +<div class="updated"><p>There was a problem adding the feed. [SQL: <?php echo esc_html(mysql_error()); ?>]</p></div>
415 508 <?php endif;
416 - elseif (isset($_REQUEST['link_id'])):
417 - // Update link_rss
418 - $result = $wpdb->query("
419 - UPDATE $wpdb->links
420 - SET
421 - link_rss = '".$wpdb->escape($_REQUEST['feed'])."'
422 - WHERE link_id = '".$wpdb->escape($_REQUEST['link_id'])."'
423 - ");
424 -
425 - if ($result):
426 - $result = $wpdb->get_row("
427 - SELECT link_name, link_url FROM $wpdb->links
428 - WHERE link_id = '".$wpdb->escape($_REQUEST['link_id'])."'
429 - ");
430 - ?>
431 -<div class="updated"><p>Feed for <a href="<?php echo $result->link_url; ?>"><?php echo wp_specialchars($result->link_name, 'both'); ?></a>
432 -updated to &lt;<a href="<?php echo $_REQUEST['feed']; ?>"><?php echo wp_specialchars($_REQUEST['feed'], 'both'); ?></a>&gt;.</p></div>
433 - <?php else: ?>
434 -<div class="updated"><p>Nothing was changed.</p></div>
435 - <?php endif;
436 - endif;
437 - endif;
438 - return true; // Continue
439 -}
509 + elseif (isset($fwp_post['save_link_id'])):
510 + $existingLink = new SyndicatedLink($fwp_post['save_link_id']);
511 + $changed = $existingLink->set_uri($fwp_post['feed']);
440 512
441 -function fwp_linkedit_page () {
442 - global $wpdb, $wp_db_version;
443 -
444 - check_admin_referer(); // Make sure we arrived here from the Dashboard
445 -
446 - $special_settings = array ( /* Regular expression syntax is OK here */
447 - 'cats',
448 - 'cat_split',
449 - 'hardcode name',
450 - 'hardcode url',
451 - 'hardcode description',
452 - 'hardcode categories', /* Deprecated */
453 - 'post status',
454 - 'comment status',
455 - 'ping status',
456 - 'unfamiliar author',
457 - 'unfamliar categories', /* Deprecated */
458 - 'unfamiliar category',
459 - 'map authors',
460 - 'tags',
461 - 'update/.*',
462 - 'feed/.*',
463 - 'link/.*',
464 - );
465 -
466 - if (!current_user_can('manage_links')) :
467 - die (__("Cheatin' uh ?"));
468 - elseif (isset($_REQUEST['feedfinder'])) :
469 - return fwp_feedfinder_page(); // re-route to Feed Finder page
470 - else :
471 - $link_id = (int) $_REQUEST['link_id'];
472 - $link =& new SyndicatedLink($link_id);
473 -
474 - if ($link->found()) :
475 - if (isset($GLOBALS['fwp_post']['save'])) :
476 - $alter = array ();
477 -
478 - $meta = $link->settings;
479 - //if (isset($meta['cats'])):
480 - // $meta['cats'] = preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, $meta['cats']);
481 - //endif;
482 -
483 - // custom feed settings first
484 - foreach ($GLOBALS['fwp_post']['notes'] as $mn) :
485 - $mn['key0'] = trim($mn['key0']);
486 - $mn['key1'] = trim($mn['key1']);
487 - if (preg_match("\007^(("
488 - .implode(')|(',$special_settings)
489 - ."))$\007i",
490 - $mn['key1'])) :
491 - $mn['key1'] = 'user/'.$mn['key1'];
492 - endif;
493 -
494 - if (strlen($mn['key0']) > 0) :
495 - unset($meta[$mn['key0']]); // out with the old
496 - endif;
497 -
498 - if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) :
499 - $meta[$mn['key1']] = $mn['value']; // in with the new
500 - endif;
501 - endforeach;
502 -
503 - // now stuff through the web form
504 - // hardcoded feed info
505 - if (isset($GLOBALS['fwp_post']['hardcode_name'])) :
506 - $meta['hardcode name'] = $GLOBALS['fwp_post']['hardcode_name'];
507 - if (FeedWordPress::affirmative($meta, 'hardcode name')) :
508 - $alter[] = "link_name = '".$wpdb->escape($GLOBALS['fwp_post']['name'])."'";
509 - endif;
510 - endif;
511 - if (isset($GLOBALS['fwp_post']['hardcode_description'])) :
512 - $meta['hardcode description'] = $GLOBALS['fwp_post']['hardcode_description'];
513 - if (FeedWordPress::affirmative($meta, 'hardcode description')) :
514 - $alter[] = "link_description = '".$wpdb->escape($GLOBALS['fwp_post']['description'])."'";
515 - endif;
516 - endif;
517 - if (isset($GLOBALS['fwp_post']['hardcode_url'])) :
518 - $meta['hardcode url'] = $GLOBALS['fwp_post']['hardcode_url'];
519 - if (FeedWordPress::affirmative($meta, 'hardcode url')) :
520 - $alter[] = "link_url = '".$wpdb->escape($GLOBALS['fwp_post']['linkurl'])."'";
521 - endif;
522 - endif;
523 -
524 - // Update scheduling
525 - if (isset($GLOBALS['fwp_post']['update_schedule'])) :
526 - $meta['update/hold'] = $GLOBALS['fwp_post']['update_schedule'];
527 - endif;
528 -
529 - // Categories
530 - if (isset($GLOBALS['fwp_post']['post_category'])) :
531 - $meta['cats'] = array();
532 - foreach ($GLOBALS['fwp_post']['post_category'] as $cat_id) :
533 - $meta['cats'][] = '{#'.$cat_id.'}';
534 - endforeach;
535 - else :
536 - unset($meta['cats']);
537 - endif;
538 -
539 - // Tags
540 - if (isset($GLOBALS['fwp_post']['tags_input'])) :
541 - $meta['tags'] = array();
542 - foreach (explode(',', $GLOBALS['fwp_post']['tags_input']) as $tag) :
543 - $meta['tags'][] = trim($tag);
544 - endforeach;
545 - endif;
546 -
547 - // Post status, comment status, ping status
548 - foreach (array('post', 'comment', 'ping') as $what) :
549 - $sfield = "feed_{$what}_status";
550 - if (isset($GLOBALS['fwp_post'][$sfield])) :
551 - if ($GLOBALS['fwp_post'][$sfield]=='site-default') :
552 - unset($meta["{$what} status"]);
553 - else :
554 - $meta["{$what} status"] = $GLOBALS['fwp_post'][$sfield];
555 - endif;
556 - endif;
557 - endforeach;
558 -
559 - // Unfamiliar author, unfamiliar categories
560 - foreach (array("author", "category") as $what) :
561 - $sfield = "unfamiliar_{$what}";
562 - if (isset($GLOBALS['fwp_post'][$sfield])) :
563 - if ('site-default'==$GLOBALS['fwp_post'][$sfield]) :
564 - unset($meta["unfamiliar {$what}"]);
565 - elseif ('newuser'==$GLOBALS['fwp_post'][$sfield]) :
566 - $newuser_name = trim($GLOBALS['fwp_post']["{$sfield}_newuser"]);
567 - if (strlen($newuser_name) > 0) :
568 - $userdata = array();
569 - $userdata['ID'] = NULL;
570 -
571 - $userdata['user_login'] = sanitize_user($newuser_name);
572 - $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
573 -
574 - $userdata['user_nicename'] = sanitize_title($newuser_name);
575 - $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
576 -
577 - $userdata['display_name'] = $wpdb->escape($newuser_name);
578 -
579 - $newuser_id = wp_insert_user($userdata);
580 - if (is_numeric($newuser_id)) :
581 - $meta["unfamiliar {$what}"] = $newuser_id;
582 - else :
583 - // TODO: Add some error detection and reporting
584 - endif;
585 - else :
586 - // TODO: Add some error reporting
587 - endif;
588 - else :
589 - $meta["unfamiliar {$what}"] = $GLOBALS['fwp_post'][$sfield];
590 - endif;
591 - endif;
592 - endforeach;
593 -
594 - // Handle author mapping rules
595 - if (isset($GLOBALS['fwp_post']['author_rules_name']) and isset($GLOBALS['fwp_post']['author_rules_action'])) :
596 - unset($meta['map authors']);
597 - foreach ($GLOBALS['fwp_post']['author_rules_name'] as $key => $name) :
598 - // Normalize for case and whitespace
599 - $name = strtolower(trim($name));
600 - $author_action = strtolower(trim($GLOBALS['fwp_post']['author_rules_action'][$key]));
601 -
602 - if (strlen($name) > 0) :
603 - if ('newuser' == $author_action) :
604 - $newuser_name = trim($GLOBALS['fwp_post']['author_rules_newuser'][$key]);
605 - if (strlen($newuser_name) > 0) :
606 - $userdata = array();
607 - $userdata['ID'] = NULL;
608 -
609 - $userdata['user_login'] = sanitize_user($newuser_name);
610 - $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
611 -
612 - $userdata['user_nicename'] = sanitize_title($newuser_name);
613 - $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
614 -
615 - $userdata['display_name'] = $wpdb->escape($newuser_name);
616 -
617 - $newuser_id = wp_insert_user($userdata);
618 - if (is_numeric($newuser_id)) :
619 - $meta['map authors']['name'][$name] = $newuser_id;
620 - else :
621 - // TODO: Add some error detection and reporting
622 - endif;
623 - else :
624 - // TODO: Add some error reporting
625 - endif;
626 - else :
627 - $meta['map authors']['name'][$name] = $author_action;
628 - endif;
629 - endif;
630 - endforeach;
631 - endif;
632 -
633 - if (isset($GLOBALS['fwp_post']['add_author_rule_name']) and isset($GLOBALS['fwp_post']['add_author_rule_action'])) :
634 - $name = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_name']));
635 - $author_action = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_action']));
636 - if (strlen($name) > 0) :
637 - if ('newuser' == $author_action) :
638 - $newuser_name = trim($GLOBALS['fwp_post']['add_author_rule_newuser']);
639 - if (strlen($newuser_name) > 0) :
640 - $userdata = array();
641 - $userdata['ID'] = NULL;
642 -
643 - $userdata['user_login'] = sanitize_user($newuser_name);
644 - $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
645 -
646 - $userdata['user_nicename'] = sanitize_title($newuser_name);
647 - $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
648 -
649 - $userdata['display_name'] = $wpdb->escape($newuser_name);
650 -
651 - $newuser_id = wp_insert_user($userdata);
652 - if (is_numeric($newuser_id)) :
653 - $meta['map authors']['name'][$name] = $newuser_id;
654 - else :
655 - // TODO: Add some error detection and reporting
656 - endif;
657 - else :
658 - // TODO: Add some error reporting
659 - endif;
660 - else :
661 - $meta['map authors']['name'][$name] = $author_action;
662 - endif;
663 - endif;
664 - endif;
665 -
666 - if (isset($GLOBALS['fwp_post']['cat_split'])) :
667 - if (strlen(trim($GLOBALS['fwp_post']['cat_split'])) > 0) :
668 - $meta['cat_split'] = trim($GLOBALS['fwp_post']['cat_split']);
669 - else :
670 - unset($meta['cat_split']);
671 - endif;
672 - endif;
673 -
674 - if (is_array($meta['cats'])) :
675 - $meta['cats'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $meta['cats']);
676 - endif;
677 - if (is_array($meta['tags'])) :
678 - $meta['tags'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $meta['tags']);
679 - endif;
680 -
681 - // Collapse the author mapping rule structure back into a flat string
682 - if (isset($meta['map authors'])) :
683 - $ma = array();
684 - foreach ($meta['map authors'] as $rule_type => $author_rules) :
685 - foreach ($author_rules as $author_name => $author_action) :
686 - $ma[] = $rule_type."\n".$author_name."\n".$author_action;
687 - endforeach;
688 - endforeach;
689 - $meta['map authors'] = implode("\n\n", $ma);
690 - endif;
691 -
692 - $notes = '';
693 - foreach ($meta as $key => $value) :
694 - $notes .= $key . ": ". addcslashes($value, "\0..\37".'\\') . "\n";
695 - endforeach;
696 - $alter[] = "link_notes = '".$wpdb->escape($notes)."'";
697 -
698 - $alter_set = implode(", ", $alter);
699 -
700 - // issue update query
701 - $result = $wpdb->query("
702 - UPDATE $wpdb->links
703 - SET $alter_set
704 - WHERE link_id='$link_id'
705 - ");
706 - $updated_link = true;
707 -
708 - // reload link information from DB
709 - $link =& new SyndicatedLink($link_id);
710 - else :
711 - $updated_link = false;
513 + if ($changed):
514 + $home = $existingLink->homepage(/*from feed=*/ false);
515 + $name = $existingLink->name(/*from feed=*/ false);
516 + ?>
517 +<div class="updated"><p>Feed for <a href="<?php echo esc_html($home); ?>"><?php echo esc_html($name); ?></a>
518 +updated to &lt;<a href="<?php echo esc_html($fwp_post['feed']); ?>"><?php echo esc_html($fwp_post['feed']); ?></a>&gt;.</p></div>
519 + <?php
712 520 endif;
713 -
714 - $db_link = $link->link;
715 - $link_url = wp_specialchars($db_link->link_url, 1);
716 - $link_name = wp_specialchars($db_link->link_name, 1);
717 - $link_description = wp_specialchars($db_link->link_description, 'both');
718 - $link_notes = wp_specialchars($db_link->link_notes, 'both');
719 - $link_rss_uri = wp_specialchars($db_link->link_rss, 'both');
720 -
721 - $meta = $link->settings;
722 - $post_status_global = get_option('feedwordpress_syndicated_post_status');
723 - $comment_status_global = get_option('feedwordpress_syndicated_comment_status');
724 - $ping_status_global = get_option('feedwordpress_syndicated_ping_status');
725 -
726 - $status['post'] = array('publish' => '', 'private' => '', 'draft' => '', 'site-default' => '');
727 - if (SyndicatedPost::use_api('post_status_pending')) :
728 - $status['post']['pending'] = '';
729 - endif;
730 -
731 - $status['comment'] = array('open' => '', 'closed' => '', 'site-default' => '');
732 - $status['ping'] = array('open' => '', 'closed' => '', 'site-default' => '');
733 -
734 - foreach (array('post', 'comment', 'ping') as $what) :
735 - if (isset($meta["{$what} status"])) :
736 - $status[$what][$meta["{$what} status"]] = ' checked="checked"';
737 - else :
738 - $status[$what]['site-default'] = ' checked="checked"';
739 - endif;
740 - endforeach;
741 -
742 - $unfamiliar['author'] = array ('create' => '','default' => '','filter' => '');
743 - $unfamiliar['category'] = array ('create'=>'','tag' => '','default'=>'','filter'=>'');
744 -
745 - foreach (array('author', 'category') as $what) :
746 - if (is_string($meta["unfamiliar {$what}"]) and
747 - array_key_exists($meta["unfamiliar {$what}"], $unfamiliar[$what])) :
748 - $key = $meta["unfamiliar {$what}"];
749 - else:
750 - $key = 'site-default';
751 - endif;
752 - $unfamiliar[$what][$key] = ' checked="checked"';
753 - endforeach;
754 -
755 - if (is_array($meta['cats'])) : $cats = $meta['cats'];
756 - else : $cats = array();
757 - endif;
758 -
759 - $dogs = SyndicatedPost::category_ids($cats, /*unfamiliar=*/ NULL);
760 - else :
761 - die( __('Link not found.') );
762 521 endif;
522 + endif;
763 523
764 - ?>
765 -<script type="text/javascript">
766 - function flip_hardcode (item) {
767 - ed=document.getElementById('basics-'+item+'-edit');
768 - view=document.getElementById('basics-'+item+'-view');
769 -
770 - o = document.getElementById('basics-hardcode-'+item);
771 - if (o.value=='yes') { ed.style.display='inline'; view.style.display='none'; }
772 - else { ed.style.display='none'; view.style.display='inline'; }
773 - }
774 - function flip_newuser (item) {
775 - rollup=document.getElementById(item);
776 - newuser=document.getElementById(item+'-newuser');
777 - sitewide=document.getElementById(item+'-default');
778 - if (rollup) {
779 - if ('newuser'==rollup.value) {
780 - if (newuser) newuser.style.display='block';
781 - if (sitewide) sitewide.style.display='none';
782 - } else if ('site-default'==rollup.value) {
783 - if (newuser) newuser.style.display='none';
784 - if (sitewide) sitewide.style.display='block';
785 - } else {
786 - if (newuser) newuser.style.display='none';
787 - if (sitewide) sitewide.style.display='none';
788 - }
789 - }
790 - }
791 -</script>
792 -
793 -<?php if ($updated_link) : ?>
794 -<div class="updated"><p>Syndicated feed settings updated.</p></div>
795 -<?php endif; ?>
796 -
797 -<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
798 -<div class="wrap">
799 -<input type="hidden" name="link_id" value="<?php echo $link_id; ?>" />
800 -<input type="hidden" name="action" value="linkedit" />
801 -<input type="hidden" name="save" value="link" />
802 -
803 -<h2>Edit a syndicated feed:</h2>
804 -<div id="poststuff">
805 -<?php fwp_linkedit_single_submit($status); ?>
806 -
807 -<div id="post-body">
808 -<?php fwp_option_box_opener('Feed Information', 'feedinformationdiv'); ?>
809 - <table class="editform" width="100%" cellspacing="2" cellpadding="5">
810 - <tr>
811 - <th scope="row" width="20%"><?php _e('Feed URI:') ?></th>
812 - <td width="60%"><a href="<?php echo wp_specialchars($link_rss_uri, 'both'); ?>"><?php echo $link_rss_uri; ?></a>
813 - (<a href="<?php echo FEEDVALIDATOR_URI; ?>?url=<?php echo urlencode($link_rss_uri); ?>"
814 - title="Check feed &lt;<?php echo wp_specialchars($link_rss_uri, 'both'); ?>&gt; for validity">validate</a>)
815 - </td>
816 - <td width="20%"><input type="submit" name="feedfinder" value="switch &rarr;" style="font-size:smaller" /></td>
817 - </tr>
818 - <tr>
819 - <th scope="row" width="20%"><?php _e('Link Name:') ?></th>
820 - <td width="60%"><input type="text" id="basics-name-edit" name="name"
821 - value="<?php echo $link_name; ?>" style="width: 95%" />
822 - <span id="basics-name-view"><strong><?php echo $link_name; ?></strong></span>
823 - </td>
824 - <td>
825 - <select id="basics-hardcode-name" onchange="flip_hardcode('name')" name="hardcode_name">
826 - <option value="no" <?php echo $link->hardcode('name')?'':'selected="selected"'; ?>>update automatically</option>
827 - <option value="yes" <?php echo $link->hardcode('name')?'selected="selected"':''; ?>>edit manually</option>
828 - </select>
829 - </td>
830 - </tr>
831 - <tr>
832 - <th scope="row" width="20%"><?php _e('Short description:') ?></th>
833 - <td width="60%">
834 - <input id="basics-description-edit" type="text" name="description" value="<?php echo $link_description; ?>" style="width: 95%" />
835 - <span id="basics-description-view"><strong><?php echo $link_description; ?></strong></span>
836 - </td>
837 - <td>
838 - <select id="basics-hardcode-description" onchange="flip_hardcode('description')"
839 - name="hardcode_description">
840 - <option value="no" <?php echo $link->hardcode('description')?'':'selected="selected"'; ?>>update automatically</option>
841 - <option value="yes" <?php echo $link->hardcode('description')?'selected="selected"':''; ?>>edit manually</option>
842 - </select></td>
843 - </tr>
844 - <tr>
845 - <th width="20%" scope="row"><?php _e('Homepage:') ?></th>
846 - <td width="60%">
847 - <input id="basics-url-edit" type="text" name="linkurl" value="<?php echo $link_url; ?>" style="width: 95%;" />
848 - <a id="basics-url-view" href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td>
849 - <td>
850 - <select id="basics-hardcode-url" onchange="flip_hardcode('url')" name="hardcode_url">
851 - <option value="no"<?php echo $link->hardcode('url')?'':' selected="selected"'; ?>>update automatically</option>
852 - <option value="yes"<?php echo $link->hardcode('url')?' selected="selected"':''; ?>>edit manually</option>
853 - </select></td></tr>
524 + if (isset($existingLink)) :
525 + do_action('feedwordpress_admin_switchfeed', $fwp_post['feed'], $existingLink);
526 + endif;
854 527
855 - <tr>
856 - <th width="20%"><?php _e('Last update') ?>:</th>
857 - <td colspan="2"><?php
858 - if (isset($meta['update/last'])) :
859 - echo strftime('%x %X', $meta['update/last'])." ";
860 - else :
861 - echo " none yet";
862 - endif;
863 - ?></td></tr>
864 - <tr><th width="20%">Next update:</th>
865 - <td colspan="2"><?php
866 - $holdem = (isset($meta['update/hold']) ? $meta['update/hold'] : 'scheduled');
867 - ?>
868 - <select name="update_schedule">
869 - <option value="scheduled"<?php echo ($holdem=='scheduled')?' selected="selected"':''; ?>>update on schedule <?php
870 - echo " (";
871 - if (isset($meta['update/ttl']) and is_numeric($meta['update/ttl'])) :
872 - if (isset($meta['update/timed']) and $meta['update/timed']=='automatically') :
873 - echo 'next: ';
874 - $next = $meta['update/last'] + ((int) $meta['update/ttl'] * 60);
875 - if (strftime('%x', time()) != strftime('%x', $next)) :
876 - echo strftime('%x', $next)." ";
877 - endif;
878 - echo strftime('%X', $meta['update/last']+((int) $meta['update/ttl']*60));
879 - else :
880 - echo "every ".$meta['update/ttl']." minute".(($meta['update/ttl']!=1)?"s":"");
881 - endif;
882 - else:
883 - echo "next scheduled update";
884 - endif;
885 - echo ")";
886 - ?></option>
887 - <option value="next"<?php echo ($holdem=='next')?' selected="selected"':''; ?>>update ASAP</option>
888 - <option value="ping"<?php echo ($holdem=='ping')?' selected="selected"':''; ?>>update only when pinged</option>
889 - </select></tr>
890 - </table>
891 -<?php fwp_option_box_closer(); ?>
892 -
893 -<script type="text/javascript">
894 -flip_hardcode('name');
895 -flip_hardcode('description');
896 -flip_hardcode('url');
897 -</script>
898 -
899 -<?php fwp_linkedit_periodic_submit(); ?>
900 -
901 -<?php
902 -if (!(isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25)) :
903 - fwp_option_box_opener('Syndicated Posts', 'syndicatedpostsdiv', 'postbox');
904 -?>
905 -<table class="editform" width="75%" cellspacing="2" cellpadding="5">
906 -<tr><th width="27%" scope="row" style="vertical-align:top">Publication:</th>
907 -<td width="73%" style="vertical-align:top"><ul style="margin:0; list-style:none">
908 -<li><label><input type="radio" name="feed_post_status" value="site-default"
909 -<?php echo $status['post']['site-default']; ?> /> Use site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a>
910 -(currently: <strong><?php echo ($post_status_global ? $post_status_global : 'publish'); ?></strong>)</label></li>
911 -<li><label><input type="radio" name="feed_post_status" value="publish"
912 -<?php echo $status['post']['publish']; ?> /> Publish posts from this feed immediately</label></li>
913 -
914 -<?php if (SyndicatedPost::use_api('post_status_pending')) : ?>
915 -<li><label><input type="radio" name="feed_post_status" value="pending"
916 -<?php echo $status['post']['pending']; ?>/> Hold posts from this feed for review; mark as Pending</label></li>
917 -<?php endif; ?>
918 -
919 -<li><label><input type="radio" name="feed_post_status" value="draft"
920 -<?php echo $status['post']['draft']; ?> /> Save posts from this feed as drafts</label></li>
921 -<li><label><input type="radio" name="feed_post_status" value="private"
922 -<?php echo $status['post']['private']; ?> /> Save posts from this feed as private posts</label></li>
923 -</ul></td>
924 -</tr>
925 -</table>
926 -<?php
927 - fwp_option_box_closer();
928 - fwp_linkedit_periodic_submit();
929 -endif;
930 -
931 - fwp_option_box_opener(__('Categories'), 'categorydiv', 'postbox');
932 - fwp_category_box($dogs, 'all syndicated posts from this feed');
933 -?>
934 -<table>
935 -<tr>
936 -<th width="20%" scope="row" style="vertical-align:top">Unfamiliar categories:</th>
937 -<td width="80%"><p>When one of the categories on a syndicated post is a category that FeedWordPress has not encountered before ...</p>
938 -
939 -<ul style="margin: 0; list-style:none">
940 -<li><label><input type="radio" name="unfamiliar_category" value="site-default"<?php echo $unfamiliar['category']['site-default']; ?> /> use the site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a>
941 -(currently <strong><?php echo FeedWordPress::on_unfamiliar('category'); ?></strong>)</label></li>
942 -<li><label><input type="radio" name="unfamiliar_category" value="create"<?php echo $unfamiliar['category']['create']; ?> /> create a new category</label></li>
943 -<li><label><input type="radio" name="unfamiliar_category" value="tag"<?php echo $unfamiliar['category']['tag']; ?>/> create a new tag</label></li>
944 -<li><label><input type="radio" name="unfamiliar_category" value="default"<?php echo $unfamiliar['category']['default']; ?> /> don't create new categories or tags</label></li>
945 -<li><label><input type="radio" name="unfamiliar_category" value="filter"<?php echo $unfamiliar['category']['filter']; ?> /> don't create new categories or tags and don't syndicate posts unless they match at least one familiar category</label></li>
946 -</ul></td>
947 -</tr>
948 -
949 -<tr>
950 -<th width="20%" scope="row" style="vertical-align:top">Multiple categories:</th>
951 -<td width="80%">
952 -<input type="text" size="20" id="cat_split" name="cat_split" value="<?php if (isset($meta['cat_split'])) : echo htmlspecialchars($meta['cat_split']); endif; ?>" /><br/>
953 -Enter a <a href="http://us.php.net/manual/en/reference.pcre.pattern.syntax.php">Perl-compatible regular expression</a> here if the feed provides multiple
954 -categories in a single category element. The regular expression should match
955 -the characters used to separate one category from the next. If the feed uses
956 -spaces (like <a href="http://del.icio.us/">del.icio.us</a>), use the pattern "\s".
957 -If the feed does not provide multiple categories in a single element, leave this
958 -blank.</td>
959 -</tr>
960 -</table>
961 -<?php
962 - fwp_option_box_closer();
963 - fwp_linkedit_periodic_submit();
964 -
965 -if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25) :
966 - fwp_tags_box($meta['tags']);
967 - fwp_linkedit_periodic_submit();
968 -endif; ?>
969 -
970 -<?php fwp_option_box_opener('Syndicated Authors', 'authordiv', 'postbox'); ?>
971 -<?php $authorlist = fwp_author_list(); ?>
972 -<table>
973 -<tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">For posts by authors that haven't been syndicated before:</th></tr>
974 -<tr>
975 - <th style="text-align: left">Posts by new authors</th>
976 - <td>
977 - <select id="unfamiliar-author" name="unfamiliar_author" onchange="flip_newuser('unfamiliar-author');">
978 - <option value="site-default"<?php if (!isset($meta['unfamiliar author'])) : ?>selected="selected"<?php endif; ?>>are handled using site-wide settings</option>
979 - <option value="create"<?php if ('create'==$meta['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>create a new author account</option>
980 - <?php foreach ($authorlist as $author_id => $author_name) : ?>
981 - <option value="<?php echo $author_id; ?>"<?php if ($author_id==$meta['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>are assigned to <?php echo $author_name; ?></option>
982 - <?php endforeach; ?>
983 - <option value="newuser">will be assigned to a new user...</option>
984 - <option value="filter"<?php if ('filter'==$meta['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>get filtered out</option>
985 - </select>
986 - </td>
987 - <td>
988 - <div id="unfamiliar-author-default">Site-wide settings can be set in <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a></div>
989 - <div id="unfamiliar-author-newuser">named <input type="text" name="unfamiliar_author_newuser" value="" /></div>
990 - </td>
991 -</tr>
992 -
993 -<tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">For posts by specific authors. Blank out a name to delete the rule.</th></tr>
994 -
995 -<?php if (isset($meta['map authors'])) : $i=0; foreach ($meta['map authors'] as $author_rules) : foreach ($author_rules as $author_name => $author_action) : $i++; ?>
996 -<tr>
997 - <th style="text-align: left">Posts by <input type="text" name="author_rules_name[]" value="<?php echo htmlspecialchars($author_name); ?>" /></th>
998 - <td>
999 - <select id="author-rules-<?php echo $i; ?>" name="author_rules_action[]" onchange="flip_newuser('author-rules-<?php echo $i; ?>');">
1000 - <?php foreach ($authorlist as $local_author_id => $local_author_name) : ?>
1001 - <option value="<?php echo $local_author_id; ?>"<?php if ($local_author_id==$author_action) : echo ' selected="selected"'; endif; ?>>are assigned to <?php echo $local_author_name; ?></option>
1002 - <?php endforeach; ?>
1003 - <option value="newuser">will be assigned to a new user...</option>
1004 - <option value="filter"<?php if ('filter'==$author_action) : echo ' selected="selected"'; endif; ?>>get filtered out</option>
1005 - </select>
1006 - </td>
1007 - <td><div id="author-rules-<?php echo $i; ?>-newuser">named <input type="text" name="author_rules_newuser[]" value="" /></div></td>
1008 -</tr>
1009 -<?php endforeach; endforeach; endif; ?>
1010 -
1011 -<tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">Fill in to set up a new rule:</th></tr>
1012 -
1013 -<tr>
1014 - <th style="text-align: left">Posts by <input type="text" name="add_author_rule_name" /></th>
1015 - <td>
1016 - <select id="add-author-rule" name="add_author_rule_action" onchange="flip_newuser('add-author-rule');">
1017 - <?php foreach ($authorlist as $author_id => $author_name) : ?>
1018 - <option value="<?php echo $author_id; ?>">are assigned to <?php echo $author_name; ?></option>
1019 - <?php endforeach; ?>
1020 - <option value="newuser">will be assigned to a new user...</option>
1021 - <option value="filter">get filtered out</option>
1022 - </select>
1023 - </td>
1024 - <td><div id="add-author-rule-newuser">named <input type="text" name="add_author_rule_newuser" value="" /></div></td>
1025 -</tr>
1026 -
1027 -</table>
1028 -<?php fwp_option_box_closer(); ?>
1029 -
1030 -<script>
1031 - flip_newuser('unfamiliar-author');
1032 -<?php for ($j=1; $j<=$i; $j++) : ?>
1033 - flip_newuser('author-rules-<?php echo $j; ?>');
1034 -<?php endfor; ?>
1035 - flip_newuser('add-author-rule');
1036 -</script>
1037 -
1038 -<?php
1039 - fwp_linkedit_periodic_submit();
1040 - fwp_option_box_opener('Comments & Pings', 'commentstatusdiv', 'postbox');
1041 -?>
1042 -<table class="editform" width="75%" cellspacing="2" cellpadding="5">
1043 -<tr><th width="27%" scope="row" style="vertical-align:top"><?php print __('Comments'); ?>:</th>
1044 -<td width="73%"><ul style="margin:0; list-style:none">
1045 -<li><label><input type="radio" name="feed_comment_status" value="site-default"
1046 -<?php echo $status['comment']['site-default']; ?> /> Use site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a>
1047 -(currently: <strong><?php echo ($comment_status_global ? $comment_status_global : 'closed'); ?>)</strong></label></li>
1048 -<li><label><input type="radio" name="feed_comment_status" value="open"
1049 -<?php echo $status['comment']['open']; ?> /> Allow comments on syndicated posts from this feed</label></li>
1050 -<li><label><input type="radio" name="feed_comment_status" value="closed"
1051 -<?php echo $status['comment']['closed']; ?> /> Don't allow comments on syndicated posts from this feed</label></li>
1052 -</ul></td></tr>
1053 -
1054 -<tr><th width="27%" scope="row" style="vertical-align:top"><?php print __('Pings'); ?>:</th>
1055 -<td width="73%"><ul style="margin:0; list-style:none">
1056 -<li><label><input type="radio" name="feed_ping_status" value="site-default"
1057 -<?php echo $status['ping']['site-default']; ?> /> Use site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a>
1058 -(currently: <strong><?php echo ($ping_status_global ? $ping_status_global : 'closed'); ?>)</strong></label></li>
1059 -<li><label><input type="radio" name="feed_ping_status" value="open"
1060 -<?php echo $status['ping']['open']; ?> /> Accept pings on syndicated posts from this feed</label></li>
1061 -<li><label><input type="radio" name="feed_ping_status" value="closed"
1062 -<?php echo $status['ping']['closed']; ?> /> Don't accept pings on syndicated posts from this feed</label></li>
1063 -</ul></td></tr>
1064 -
1065 -</table>
1066 -<?php fwp_option_box_closer(); ?>
1067 -<?php fwp_linkedit_periodic_submit(); ?>
1068 -
1069 -<?php fwp_option_box_opener('Custom Settings (for use in templates)', 'postcustom', 'postbox'); ?>
1070 -<div id="postcustomstuff">
1071 -<table id="meta-list" cellpadding="3">
1072 - <tr>
1073 - <th>Key</th>
1074 - <th>Value</th>
1075 - <th>Action</th>
1076 - </tr>
1077 -
1078 -<?php
1079 - $i = 0;
1080 - foreach ($meta as $key => $value) :
1081 - if (!preg_match("\007^((".implode(')|(', $special_settings)."))$\007i", $key)) :
1082 -?>
1083 - <tr style="vertical-align:top">
1084 - <th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo wp_specialchars($key, 'both'); ?>" />
1085 - <input id="notes-<?php echo $i; ?>-key" name="notes[<?php echo $i; ?>][key1]" value="<?php echo wp_specialchars($key, 'both'); ?>" /></th>
1086 - <td width="60%"><textarea rows="2" cols="40" id="notes-<?php echo $i; ?>-value" name="notes[<?php echo $i; ?>][value]"><?php echo wp_specialchars($value, 'both'); ?></textarea></td>
1087 - <td width="10%"><select name="notes[<?php echo $i; ?>][action]">
1088 - <option value="update">save changes</option>
1089 - <option value="delete">delete this setting</option>
1090 - </select></td>
1091 - </tr>
1092 -<?php
1093 - $i++;
1094 - endif;
1095 - endforeach;
1096 -?>
1097 - <tr>
1098 - <th scope="row"><input type="text" size="10" name="notes[<?php echo $i; ?>][key1]" value="" /></th>
1099 - <td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea></td>
1100 - <td><em>add new setting...</em><input type="hidden" name="notes[<?php echo $i; ?>][action]" value="update" /></td>
1101 - </tr>
1102 -</table>
1103 -<?php fwp_option_box_closer(); ?>
1104 -
1105 -<?php fwp_linkedit_periodic_submit(); ?>
1106 -</div> <!-- id="post-body" -->
1107 -</div> <!-- id="poststuff" -->
1108 -</div>
1109 - <?php
528 + if (!$changed) :
529 + ?>
530 +<div class="updated"><p>Nothing was changed.</p></div>
531 + <?php
1110 532 endif;
1111 - return false; // Don't continue
533 + return true; // Continue
1112 534 }
1113 535
1114 536 function fwp_multidelete_page () {
1115 537 global $wpdb;
1116 538
1117 - check_admin_referer(); // Make sure the referers are kosher
539 + // If this is a POST, validate source and user credentials
540 + FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links');
1118 541
1119 542 $link_ids = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array());
1120 543 if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif;
1121 544
1122 - if (!current_user_can('manage_links')):
1123 - die (__("Cheatin' uh ?"));
1124 - elseif (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Delete'):
1125 - foreach ($GLOBALS['fwp_post']['link_action'] as $link_id => $what) :
545 + if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Delete'):
546 + if (isset($GLOBALS['fwp_post']['link_action']) and is_array($GLOBALS['fwp_post']['link_action'])) :
547 + $actions = $GLOBALS['fwp_post']['link_action'];
548 + else :
549 + $actions = array();
550 + endif;
551 +
552 + foreach ($actions as $link_id => $what) :
1126 553 $do_it[$what][] = $link_id;
1127 554 endforeach;
1128 555
1129 556 $alter = array();
@@ -1203,17 +630,18 @@
1203 630 ");
1204 631 ?>
1205 632 <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
1206 633 <div class="wrap">
634 +<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?>
1207 635 <input type="hidden" name="action" value="Unsubscribe" />
1208 636 <input type="hidden" name="confirm" value="Delete" />
1209 637
1210 638 <h2>Unsubscribe from Syndicated Links:</h2>
1211 639 <?php foreach ($targets as $link) :
1212 - $link_url = wp_specialchars($link->link_url, 1);
1213 - $link_name = wp_specialchars($link->link_name, 1);
1214 - $link_description = wp_specialchars($link->link_description, 'both');
1215 - $link_rss = wp_specialchars($link->link_rss, 'both');
640 + $link_url = esc_html($link->link_url);
641 + $link_name = esc_html($link->link_name);
642 + $link_description = esc_html($link->link_description);
643 + $link_rss = esc_html($link->link_rss);
1216 644 ?>
1217 645 <fieldset>
1218 646 <legend><?php echo $link_name; ?></legend>
1219 647 <table class="editform" width="100%" cellspacing="2" cellpadding="5">
@@ -1257,6 +685,7 @@
1257 685 return false; // Don't continue on to Syndicated Sites listing
1258 686 endif;
1259 687 }
1260 688
1261 - fwp_syndication_manage_page();
689 + $syndicationPage = new FeedWordPressSyndicationPage;
690 + $syndicationPage->display();
1262 691