PluginProbe
FeedWordPress / 2009.1111
FeedWordPress v2009.1111
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 | posts-page.php +146 -255 2010.05282009.1111 View file →
@@ -1,11 +1,9 @@
1 1 <?php
2 2 require_once(dirname(__FILE__) . '/admin-ui.php');
3 -require_once(dirname(__FILE__) . '/updatedpostscontrol.class.php');
4 3
5 4 class FeedWordPressPostsPage extends FeedWordPressAdminPage {
6 5 var $link = NULL;
7 - var $updatedPosts = NULL;
8 6
9 7 /**
10 8 * Construct the posts page object.
11 9 *
@@ -14,107 +12,10 @@
14 12 function FeedWordPressPostsPage ($link = NULL) {
15 13 FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpresspostspage', $link);
16 14 $this->dispatch = 'feedwordpress_posts_settings';
17 15 $this->filename = __FILE__;
18 - $this->updatedPosts = new UpdatedPostsControl($this);
19 16 } /* FeedWordPressPostsPage constructor */
20 17
21 - function accept_POST ($post) {
22 - global $wpdb;
23 -
24 - // User mashed a Save Changes button
25 - if (isset($post['save']) or isset($post['submit'])) :
26 - // custom post settings
27 - $custom_settings = $this->custom_post_settings();
28 -
29 - foreach ($post['notes'] as $mn) :
30 - $mn['key0'] = trim($mn['key0']);
31 - $mn['key1'] = trim($mn['key1']);
32 -
33 - if (strlen($mn['key0']) > 0) :
34 - unset($custom_settings[$mn['key0']]); // out with the old
35 - endif;
36 -
37 - if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) :
38 - $custom_settings[$mn['key1']] = $mn['value']; // in with the new
39 - endif;
40 - endforeach;
41 -
42 - $this->updatedPosts->accept_POST($post);
43 - if ($this->for_feed_settings()) :
44 - $alter = array ();
45 -
46 - $this->link->settings['postmeta'] = serialize($custom_settings);
47 -
48 - if (isset($post['resolve_relative'])) :
49 - $this->link->settings['resolve relative'] = $post['resolve_relative'];
50 - endif;
51 - if (isset($post['munge_permalink'])) :
52 - $this->link->settings['munge permalink'] = $post['munge_permalink'];
53 - endif;
54 - if (isset($post['munge_comments_feed_links'])) :
55 - $this->link->settings['munge comments feed links'] = $post['munge_comments_feed_links'];
56 - endif;
57 -
58 - // Post status, comment status, ping status
59 - foreach (array('post', 'comment', 'ping') as $what) :
60 - $sfield = "feed_{$what}_status";
61 - if (isset($post[$sfield])) :
62 - if ($post[$sfield]=='site-default') :
63 - unset($this->link->settings["{$what} status"]);
64 - else :
65 - $this->link->settings["{$what} status"] = $post[$sfield];
66 - endif;
67 - endif;
68 - endforeach;
69 -
70 - // Save settings
71 - $this->link->save_settings(/*reload=*/ true);
72 - $this->updated = true;
73 -
74 - // Reset, reload
75 - $link_id = $this->link->id;
76 - unset($this->link);
77 - $this->link = new SyndicatedLink($link_id);
78 - else :
79 - // update_option ...
80 - if (isset($post['feed_post_status'])) :
81 - update_option('feedwordpress_syndicated_post_status', $post['feed_post_status']);
82 - endif;
83 -
84 - update_option('feedwordpress_custom_settings', serialize($custom_settings));
85 -
86 - update_option('feedwordpress_munge_permalink', $_REQUEST['munge_permalink']);
87 - update_option('feedwordpress_use_aggregator_source_data', $_REQUEST['use_aggregator_source_data']);
88 - update_option('feedwordpress_formatting_filters', $_REQUEST['formatting_filters']);
89 -
90 - if (isset($post['resolve_relative'])) :
91 - update_option('feedwordpress_resolve_relative', $post['resolve_relative']);
92 - endif;
93 - if (isset($post['munge_comments_feed_links'])) :
94 - update_option('feedwordpress_munge_comments_feed_links', $post['munge_comments_feed_links']);
95 - endif;
96 - if (isset($_REQUEST['feed_comment_status']) and ($_REQUEST['feed_comment_status'] == 'open')) :
97 - update_option('feedwordpress_syndicated_comment_status', 'open');
98 - else :
99 - update_option('feedwordpress_syndicated_comment_status', 'closed');
100 - endif;
101 -
102 - if (isset($_REQUEST['feed_ping_status']) and ($_REQUEST['feed_ping_status'] == 'open')) :
103 - update_option('feedwordpress_syndicated_ping_status', 'open');
104 - else :
105 - update_option('feedwordpress_syndicated_ping_status', 'closed');
106 - endif;
107 -
108 - $this->updated = true;
109 - endif;
110 -
111 - // Probably a "Go" button for the drop-down
112 - else :
113 - $this->updated = false;
114 - endif;
115 - }
116 -
117 18 /**
118 19 * Outputs "Publication" settings box.
119 20 *
120 21 * @since 2009.0713
@@ -125,8 +26,10 @@
125 26 * @uses FeedWordPressPostsPage::these_posts_phrase()
126 27 * @uses FeedWordPress::syndicated_status()
127 28 * @uses SyndicatedLink::syndicated_status()
128 29 * @uses SyndicatedPost::use_api()
30 + * @uses fwp_option_box_opener()
31 + * @uses fwp_option_box_closer()
129 32 */
130 33 /*static*/ function publication_box ($page, $box = NULL) {
131 34 global $fwp_path;
132 35
@@ -141,10 +44,8 @@
141 44 );
142 45 if (SyndicatedPost::use_api('post_status_pending')) :
143 46 $setting['pending'] = array('label' => "Hold %s for review; mark as Pending", 'checked' => '');
144 47 endif;
145 -
146 -
147 48 if ($page->for_feed_settings()) :
148 49 $href = $fwp_path.'/'.basename(__FILE__);
149 50 $currently = str_replace('%s', '', strtolower(strtok($setting[$post_status_global]['label'], ';')));
150 51 $setting['site-default'] = array('label' => "Use <a href=\"admin.php?page=${href}\">site-wide setting</a>", 'checked' => '');
@@ -178,9 +79,9 @@
178 79 #syndicated-publication-form td { width: 73%; vertical-align: top; }
179 80 </style>
180 81
181 82 <table id="syndicated-publication-form" class="form-table" cellspacing="2" cellpadding="5">
182 - <tr><th scope="row"><?php _e('New posts:'); ?></th>
83 + <tr><th scope="row">Status for new posts:</th>
183 84 <td><ul class="options">
184 85 <?php foreach ($selector as $code => $li) : ?>
185 86 <li><label><input type="radio" name="feed_post_status"
186 87 value="<?php print $code; ?>"<?php print $li['checked']; ?> />
@@ -187,10 +88,8 @@
187 88 <?php print str_replace('%s', $thesePosts, $li['label']); ?></label></li>
188 89 <?php endforeach; ?>
189 90 </ul></td>
190 91 </tr>
191 -
192 - <?php $page->updatedPosts->display(); ?>
193 92 </table>
194 93
195 94 <?php
196 95 } /* FeedWordPressPostsPage::publication_box () */
@@ -202,61 +101,25 @@
202 101 * @param object $page of class FeedWordPressPostsPage tells us whether this is
203 102 * a page for one feed's settings or for global defaults
204 103 * @param array $box
205 104 *
105 + * @uses fwp_option_box_opener()
106 + * @uses fwp_option_box_closer()
206 107 */
207 108 function formatting_box ($page, $box = NULL) {
208 - global $fwp_path;
209 - $thesePosts = $page->these_posts_phrase();
210 - $global_resolve_relative = get_option('feedwordpress_resolve_relative', 'yes');
211 - if ($page->for_feed_settings()) :
212 - $formatting_filters = null;
213 - $resolve_relative = $page->link->setting('resolve relative', NULL, 'default');
214 - $url = preg_replace('|/+$|', '', $page->link->homepage());
215 - $setting = array(
216 - 'yes' => __('resolve relative URIs'),
217 - 'no' => __('leave relative URIs unresolved'),
218 - );
219 - $href = $fwp_path.'/'.basename(__FILE__);
220 - else :
221 - $formatting_filters = get_option('feedwordpress_formatting_filters', 'no');
222 - $resolve_relative = $global_resolve_relative;
223 - $url = 'http://example.com';
224 - endif;
109 + $formatting_filters = get_option('feedwordpress_formatting_filters');
225 110 ?>
226 111 <table class="form-table" cellspacing="2" cellpadding="5">
227 - <?php if (!is_null($formatting_filters)) : ?>
228 -
229 - <tr><th scope="row">Formatting filters:</th>
230 - <td><select name="formatting_filters" size="1">
231 - <option value="no"<?php echo ($formatting_filters!='yes')?' selected="selected"':''; ?>>Protect syndicated posts from formatting filters</option>
232 - <option value="yes"<?php echo ($formatting_filters=='yes')?' selected="selected"':''; ?>>Expose syndicated posts to formatting filters</option>
233 - </select>
234 - <p class="setting-description">If you have trouble getting plugins to work that are supposed to insert
235 - elements after posts (like relevant links or a social networking
236 - <q>Share This</q> button), try changing this option to see if it fixes your
237 - problem.</p>
238 - </td></tr>
239 -
240 - <?php endif; ?>
241 -
242 - <tr><th scope="row">Relative URIs:</th>
243 - <td>If link or image in a syndicated post from <code><?php print $url; ?></code>
244 - refers to a partial URI like <code>/about</code>, where should
245 - the syndicated copy point to?</p>
246 -
247 - <ul>
248 - <?php if ($page->for_feed_settings()) : ?>
249 - <li><p><label><input type="radio" name="resolve_relative" value='default' <?php echo ($resolve_relative=='default')?' checked="checked"':''; ?>/> Use <a href="admin.php?page=<?php print $href; ?>">site-wide setting</a><br/>
250 - <small style="margin-left: 2.0em;">Currently: <strong><?php print $setting[$global_resolve_relative]; ?></strong></small></label></p></li>
251 - <?php endif; ?>
252 - <li><p><label><input type="radio" name="resolve_relative" value="yes"<?php echo ($resolve_relative!='no' and $resolve_relative!='default')?' checked="checked"':''; ?>/> Resolve the URI so it points to <code><?php print $url; ?></code><br/>
253 - <small style="margin-left: 2.0em;"><code>/contact</code> is rewritten as <code><?php print $url; ?>/contact</code></label></small></p></li>
254 - <li><p><label><input type="radio" name="resolve_relative" value="no"<?php echo ($resolve_relative=='no')?' checked="checked"':''; ?>/> Leave relative URIs unchanged, so they point to this site<br/>
255 - <small style="margin-left: 2.0em;"><code>/contact</code> is left as <code>/contact</code></small></label></li>
256 - </ul>
112 + <tr><th scope="row">Formatting filters:</th>
113 + <td><select name="formatting_filters" size="1">
114 + <option value="no"<?php echo ($formatting_filters!='yes')?' selected="selected"':''; ?>>Protect syndicated posts from formatting filters</option>
115 + <option value="yes"<?php echo ($formatting_filters=='yes')?' selected="selected"':''; ?>>Expose syndicated posts to formatting filters</option>
116 + </select>
117 + <p class="setting-description">If you have trouble getting plugins to work that are supposed to insert
118 + elements after posts (like relevant links or a social networking
119 + <q>Share This</q> button), try changing this option to see if it fixes your
120 + problem.</p>
257 121 </td></tr>
258 -
259 122 </table>
260 123 <?php
261 124 } /* FeedWordPressPostsPage::formatting_box() */
262 125
@@ -267,38 +130,23 @@
267 130 * @param object $page of class FeedWordPressPostsPage tells us whether this is
268 131 * a page for one feed's settings or for global defaults
269 132 * @param array $box
270 133 *
134 + * @uses fwp_option_box_opener()
135 + * @uses fwp_option_box_closer()
271 136 */
272 137 /*static*/ function links_box ($page, $box = NULL) {
273 - $setting = array(
274 - 'munge_permalink' => array(
275 - 'yes' => 'the copy on the original website',
276 - 'no' => 'the local copy on this website',
277 - ),
278 - );
279 -
280 - $global_munge_permalink = get_option('feedwordpress_munge_permalink');
281 - if ($page->for_feed_settings()) :
282 - $munge_permalink = $page->link->setting('munge permalink', NULL);
283 - else :
284 - $munge_permalink = $global_munge_permalink;
285 - $use_aggregator_source_data = get_option('feedwordpress_use_aggregator_source_data');
286 - endif;
287 -
138 + $munge_permalink = get_option('feedwordpress_munge_permalink');
139 + $use_aggregator_source_data = get_option('feedwordpress_use_aggregator_source_data');
288 140 ?>
289 141 <table class="form-table" cellspacing="2" cellpadding="5">
290 - <tr><th scope="row">Permalinks point to:</th>
291 - <td><ul class="options">
292 - <?php if ($page->for_feed_settings()) : ?>
293 - <li><label><input type="radio" name="munge_permalink" value="default"<?php echo ($munge_permalink!='yes' and $munge_permalink != 'no')?' checked="checked"':''; ?>/> use site-wide setting (currently <?php print $setting['munge_permalink'][$global_munge_permalink]; ?>)</label></li>
294 - <?php endif; ?>
295 - <li><label><input type="radio" name="munge_permalink" value="yes"<?php echo ($munge_permalink=='yes')?' checked="checked"':''; ?>><?php print $setting['munge_permalink']['yes']; ?></label></li>
296 - <li><label><input type="radio" name="munge_permalink" value="no"<?php echo ($munge_permalink=='no')?' checked="checked"':''; ?>><?php print $setting['munge_permalink']['no']; ?></label></li>
297 - </ul></td>
142 + <tr><th scope="row">Permalinks:</th>
143 + <td><select name="munge_permalink" size="1">
144 + <option value="yes"<?php echo ($munge_permalink=='yes')?' selected="selected"':''; ?>>point to the copy on the original website</option>
145 + <option value="no"<?php echo ($munge_permalink=='no')?' selected="selected"':''; ?>>point to the local copy on this website</option>
146 + </select></td>
298 147 </tr>
299 148
300 - <?php if (!$page->for_feed_settings()) : ?>
301 149 <tr><th scope="row">Posts from aggregator feeds:</th>
302 150 <td><ul class="options">
303 151 <li><label><input type="radio" name="use_aggregator_source_data" value="no"<?php echo ($use_aggregator_source_data!="yes")?' checked="checked"':''; ?>> Give the aggregator itself as the source of posts from an aggregator feed.</label></li>
304 152 <li><label><input type="radio" name="use_aggregator_source_data" value="yes"<?php echo ($use_aggregator_source_data=="yes")?' checked="checked"':''; ?>> Give the original source of the post as the source, not the aggregator.</label></li>
@@ -306,9 +154,8 @@
306 154 <p class="setting-description">Some feeds (for example, those produced by FeedWordPress) aggregate content from several different sources, and include information about the original source of the post.
307 155 This setting controls what FeedWordPress will give as the source of posts from
308 156 such an aggregator feed.</p>
309 157 </td></tr>
310 - <?php endif; ?>
311 158 </table>
312 159
313 160 <?php
314 161 } /* FeedWordPressPostsPage::links_box() */
@@ -320,12 +167,12 @@
320 167 * @param object $page of class FeedWordPressPostsPage tells us whether this is
321 168 * a page for one feed's settings or for global defaults
322 169 * @param array $box
323 170 *
171 + * @uses fwp_option_box_opener()
172 + * @uses fwp_option_box_closer()
324 173 */
325 174 /*static*/ function comments_and_pings_box ($page, $box = NULL) {
326 - global $fwp_path;
327 -
328 175 $setting = array();
329 176 $selector = array();
330 177
331 178 $whatsits = array(
@@ -333,26 +180,8 @@
333 180 'ping' => array('label' => __('Pings'), 'accept' => 'Accept pings'),
334 181 );
335 182 $onThesePosts = 'on '.$page->these_posts_phrase();
336 183
337 - $selected = array(
338 - 'munge_comments_feed_links' => array('yes' => '', 'no' => '')
339 - );
340 -
341 - $globalMungeCommentsFeedLinks = get_option('feedwordpress_munge_comments_feed_links', 'yes');
342 - if ($page->for_feed_settings()) :
343 - $selected['munge_comments_feed_links']['default'] = '';
344 -
345 - $sel = $page->link->setting('munge comments feed links', NULL, 'default');
346 - else :
347 - $sel = $globalMungeCommentsFeedLinks;
348 - endif;
349 - $selected['munge_comments_feed_links'][$sel] = ' checked="checked"';
350 -
351 - if ($globalMungeCommentsFeedLinks != 'no') : $siteWide = __('comment feeds from the original website');
352 - else : $siteWide = __('local comment feeds on this website');
353 - endif;
354 -
355 184 foreach ($whatsits as $what => $how) :
356 185 $whatsits[$what]['default'] = FeedWordPress::syndicated_status($what, /*default=*/ 'closed');
357 186
358 187 // Set up array for selector
@@ -398,46 +227,13 @@
398 227 <?php print trim(str_replace('%s', $onThesePosts, $li['label'])); ?></label></li>
399 228 <?php endforeach; ?>
400 229 </ul></td></tr>
401 230 <?php endforeach; ?>
402 - <tr><th scope="row"><?php _e('Comment feeds'); ?></th>
403 - <td><p>When WordPress feeds and templates link to comments
404 - feeds for <?php print $page->these_posts_phrase(); ?>, the
405 - URLs for the feeds should...</p>
406 - <ul class="options">
407 - <?php if ($page->for_feed_settings()) : ?>
408 - <li><label><input type="radio" name="munge_comments_feed_links" value="default"<?php print $selected['munge_comments_feed_links']['default']; ?> /> Use <a href="admin.php?page=<?php print $href; ?>">site-wide setting</a> (currently: <strong><?php _e($siteWide); ?></strong>)</label></li>
409 - <?php endif; ?>
410 - <li><label><input type="radio" name="munge_comments_feed_links" value="yes"<?php print $selected['munge_comments_feed_links']['yes']; ?> /> <?php _e('Point to comment feeds from the original website (when provided by the syndicated feed)'); ?></label></li>
411 - <li><label><input type="radio" name="munge_comments_feed_links" value="no"<?php print $selected['munge_comments_feed_links']['no']; ?> /> <?php _e('Point to local comment feeds on this website'); ?></label></li>
412 - </ul></td></tr>
413 231 </table>
414 232
415 233 <?php
416 234 } /* FeedWordPressPostsPage::comments_and_pings_box() */
417 235
418 - /*static*/ function custom_post_settings ($page = NULL) {
419 - if (is_null($page)) :
420 - $page = $this;
421 - endif;
422 -
423 - if ($page->for_feed_settings()) :
424 - $custom_settings = $page->link->settings["postmeta"];
425 - else :
426 - $custom_settings = get_option('feedwordpress_custom_settings');
427 - endif;
428 -
429 - if ($custom_settings and !is_array($custom_settings)) :
430 - $custom_settings = unserialize($custom_settings);
431 - endif;
432 -
433 - if (!is_array($custom_settings)) :
434 - $custom_settings = array();
435 - endif;
436 -
437 - return $custom_settings;
438 - } /* FeedWordPressPostsPage::custom_post_settings() */
439 -
440 236 /**
441 237 * Output "Custom Post Settings" settings box
442 238 *
443 239 * @since 2009.0713
@@ -443,14 +239,35 @@
443 239 * @since 2009.0713
444 240 * @param object $page of class FeedWordPressPostsPage tells us whether this is
445 241 * a page for one feed's settings or for global defaults
446 242 * @param array $box
243 + *
244 + * @uses fwp_option_box_opener()
245 + * @uses fwp_option_box_closer()
447 246 */
448 247 /*static*/ function custom_post_settings_box ($page, $box = NULL) {
449 - $custom_settings = FeedWordPressPostsPage::custom_post_settings($page);
248 + if ($page->for_feed_settings()) :
249 + $custom_settings = $page->link->settings["postmeta"];
250 + if ($custom_settings and !is_array($custom_settings)) :
251 + $custom_settings = unserialize($custom_settings);
252 + endif;
253 +
254 + if (!is_array($custom_settings)) :
255 + $custom_settings = array();
256 + endif;
257 + else :
258 + $custom_settings = get_option('feedwordpress_custom_settings');
259 + if ($custom_settings and !is_array($custom_settings)) :
260 + $custom_settings = unserialize($custom_settings);
261 + endif;
262 +
263 + if (!is_array($custom_settings)) :
264 + $custom_settings = array();
265 + endif;
266 + endif;
267 +
450 268 ?>
451 269 <div id="postcustomstuff">
452 - <p>Custom fields can be used to add extra metadata to a post that you can <a href="http://codex.wordpress.org/Using_Custom_Fields">use in your theme</a>.</p>
453 270 <table id="meta-list" cellpadding="3">
454 271 <tr>
455 272 <th>Key</th>
456 273 <th>Value</th>
@@ -461,11 +278,11 @@
461 278 $i = 0;
462 279 foreach ($custom_settings as $key => $value) :
463 280 ?>
464 281 <tr style="vertical-align:top">
465 - <th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo esc_html($key); ?>" />
466 - <input id="notes-<?php echo $i; ?>-key" name="notes[<?php echo $i; ?>][key1]" value="<?php echo esc_html($key); ?>" /></th>
467 - <td width="60%"><textarea rows="2" cols="40" id="notes-<?php echo $i; ?>-value" name="notes[<?php echo $i; ?>][value]"><?php echo esc_html($value); ?></textarea></td>
282 + <th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo wp_specialchars($key, 'both'); ?>" />
283 + <input id="notes-<?php echo $i; ?>-key" name="notes[<?php echo $i; ?>][key1]" value="<?php echo wp_specialchars($key, 'both'); ?>" /></th>
284 + <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>
468 285 <td width="10%"><select name="notes[<?php echo $i; ?>][action]">
469 286 <option value="update">save changes</option>
470 287 <option value="delete">delete this setting</option>
471 288 </select></td>
@@ -475,17 +292,11 @@
475 292 $i++;
476 293 endforeach;
477 294 ?>
478 295
479 - <tr style="vertical-align: top">
296 + <tr>
480 297 <th scope="row"><input type="text" size="10" name="notes[<?php echo $i; ?>][key1]" value="" /></th>
481 - <td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea>
482 - <p>Enter a text value, or a path to a data element from the syndicated item.<br/>
483 - For data elements, you can use an XPath-like syntax wrapped in <code>$( ... )</code>.<br/>
484 - <code>hello</code> = the text value <code><span style="background-color: #30FFA0;">hello</span></code><br/>
485 - <code>$(author/email)</code> = the contents of <code>&lt;author&gt;&lt;email&gt;<span style="background-color: #30FFA0">...</span>&lt;/email&gt;&lt;/author&gt;</code><br/>
486 - <code>$(media:content/@url)</code> = the contents of <code>&lt;media:content url="<span style="background-color: #30FFA0">...</span>"&gt;...&lt;/media:content&gt;</code></p>
487 - </td>
298 + <td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea></td>
488 299 <td><em>add new setting...</em><input type="hidden" name="notes[<?php echo $i; ?>][action]" value="update" /></td>
489 300 </tr>
490 301 </table>
491 302 </div> <!-- id="postcustomstuff" -->
@@ -495,38 +306,112 @@
495 306 }
496 307
497 308 function fwp_posts_page () {
498 309 global $wpdb, $wp_db_version;
499 - global $fwp_post;
500 -
310 +
501 311 if (FeedWordPress::needs_upgrade()) :
502 312 fwp_upgrade_page();
503 313 return;
504 314 endif;
505 315
506 - // If this is a POST, validate source and user credentials
507 316 FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_posts_settings', /*capability=*/ 'manage_links');
508 317
509 318 $link = FeedWordPressAdminPage::submitted_link();
510 -
319 + $link_id = $link->id;
511 320 $postsPage = new FeedWordPressPostsPage($link);
512 321
513 322 $mesg = null;
514 323
515 324 ////////////////////////////////////////////////
516 - // Process POST request, if any ////////////////
325 + // Process POST request, if any /////////////////
517 326 ////////////////////////////////////////////////
518 - if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') :
519 - $postsPage->accept_POST($fwp_post);
520 - do_action('feedwordpress_admin_page_posts_save', $fwp_post, $postsPage);
327 + if (isset($GLOBALS['fwp_post']['save']) or isset($GLOBALS['fwp_post']['submit'])) :
328 + // custom post settings
329 + foreach ($GLOBALS['fwp_post']['notes'] as $mn) :
330 + $mn['key0'] = trim($mn['key0']);
331 + $mn['key1'] = trim($mn['key1']);
332 +
333 + if (strlen($mn['key0']) > 0) :
334 + unset($custom_settings[$mn['key0']]); // out with the old
335 + endif;
336 +
337 + if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) :
338 + $custom_settings[$mn['key1']] = $mn['value']; // in with the new
339 + endif;
340 + endforeach;
341 +
342 + if (is_object($link) and $link->found()) :
343 + $alter = array ();
344 +
345 + $link->settings['postmeta'] = serialize($custom_settings);
346 +
347 + // Post status, comment status, ping status
348 + foreach (array('post', 'comment', 'ping') as $what) :
349 + $sfield = "feed_{$what}_status";
350 + if (isset($GLOBALS['fwp_post'][$sfield])) :
351 + if ($GLOBALS['fwp_post'][$sfield]=='site-default') :
352 + unset($link->settings["{$what} status"]);
353 + else :
354 + $link->settings["{$what} status"] = $GLOBALS['fwp_post'][$sfield];
355 + endif;
356 + endif;
357 + endforeach;
358 +
359 + $alter[] = "link_notes = '".$wpdb->escape($link->settings_to_notes())."'";
360 +
361 + $alter_set = implode(", ", $alter);
362 +
363 + // issue update query
364 + $result = $wpdb->query("
365 + UPDATE $wpdb->links
366 + SET $alter_set
367 + WHERE link_id='$link_id'
368 + ");
369 + $updated_link = true;
370 +
371 + // reload link information from DB
372 + if (function_exists('clean_bookmark_cache')) :
373 + clean_bookmark_cache($link_id);
374 + endif;
375 + $link =& new SyndicatedLink($link_id);
376 + else :
377 + // update_option ...
378 + if (isset($GLOBALS['fwp_post']['feed_post_status'])) :
379 + update_option('feedwordpress_syndicated_post_status', $GLOBALS['fwp_post']['feed_post_status']);
380 + endif;
381 +
382 + update_option('feedwordpress_custom_settings', serialize($custom_settings));
383 +
384 + update_option('feedwordpress_munge_permalink', $_REQUEST['munge_permalink']);
385 + update_option('feedwordpress_use_aggregator_source_data', $_REQUEST['use_aggregator_source_data']);
386 + update_option('feedwordpress_formatting_filters', $_REQUEST['formatting_filters']);
387 +
388 + if (isset($_REQUEST['feed_comment_status']) and ($_REQUEST['feed_comment_status'] == 'open')) :
389 + update_option('feedwordpress_syndicated_comment_status', 'open');
390 + else :
391 + update_option('feedwordpress_syndicated_comment_status', 'closed');
392 + endif;
393 +
394 + if (isset($_REQUEST['feed_ping_status']) and ($_REQUEST['feed_ping_status'] == 'open')) :
395 + update_option('feedwordpress_syndicated_ping_status', 'open');
396 + else :
397 + update_option('feedwordpress_syndicated_ping_status', 'closed');
398 + endif;
399 +
400 + $updated_link = true;
401 + endif;
402 +
403 + do_action('feedwordpress_admin_page_posts_save', $GLOBALS['fwp_post'], $postsPage);
404 + else :
405 + $updated_link = false;
521 406 endif;
522 407
523 408 $postsPage->ajax_interface_js();
524 409
525 - if ($postsPage->updated) : ?>
410 + if ($updated_link) : ?>
526 411 <div class="updated"><p>Syndicated posts settings updated.</p></div>
527 412 <?php elseif (!is_null($mesg)) : ?>
528 -<div class="updated"><p><?php print esc_html($mesg); ?></p></div>
413 +<div class="updated"><p><?php print wp_specialchars($mesg, 1); ?></p></div>
529 414 <?php endif; ?>
530 415
531 416 <?php
532 417 $links = FeedWordPress::syndicated_links();
@@ -539,14 +424,20 @@
539 424 </style>
540 425 <div id="post-body">
541 426 <?php
542 427 $boxes_by_methods = array(
543 - 'publication_box' => __('Syndicated Posts'),
428 + 'publication_box' => __('Publication'),
429 + 'formatting_box' => __('Formatting'),
544 430 'links_box' => __('Links'),
545 - 'formatting_box' => __('Formatting'),
546 431 'comments_and_pings_box' => __('Comments & Pings'),
547 432 'custom_post_settings_box' => __('Custom Post Settings (to apply to each syndicated post)'),
548 433 );
434 +
435 +// Feed-level settings don't exist for these.
436 +if ($postsPage->for_feed_settings()) :
437 + unset($boxes_by_methods['formatting_box']);
438 + unset($boxes_by_methods['links_box']);
439 +endif;
549 440
550 441 foreach ($boxes_by_methods as $method => $title) :
551 442 fwp_add_meta_box(
552 443 /*id=*/ 'feedwordpress_'.$method,