PluginProbe
FeedWordPress / 2012.1212
FeedWordPress v2012.1212
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 +248 -306 2010.05282012.1212 View file →
@@ -10,109 +10,117 @@
10 10 * Construct the posts page object.
11 11 *
12 12 * @param mixed $link An object of class {@link SyndicatedLink} if created for one feed's settings, NULL if created for global default settings
13 13 */
14 - function FeedWordPressPostsPage ($link = NULL) {
14 + function FeedWordPressPostsPage ($link = -1) {
15 + if (is_numeric($link) and -1 == $link) :
16 + $link = FeedWordPressAdminPage::submitted_link();
17 + endif;
18 +
15 19 FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpresspostspage', $link);
16 - $this->dispatch = 'feedwordpress_posts_settings';
20 + $this->dispatch = 'feedwordpress_admin_page_posts';
17 21 $this->filename = __FILE__;
18 22 $this->updatedPosts = new UpdatedPostsControl($this);
23 +
24 + $this->pagenames = array(
25 + 'default' => 'Posts',
26 + 'settings-update' => 'Syndicated posts',
27 + 'open-sheet' => 'Syndicated Posts & Links',
28 + );
19 29 } /* FeedWordPressPostsPage constructor */
20 30
21 - function accept_POST ($post) {
22 - global $wpdb;
31 + function save_settings ($post) {
32 + // custom post settings
33 + $custom_settings = $this->custom_post_settings();
23 34
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) :
35 + foreach ($post['notes'] as $mn) :
36 + if (isset($mn['key0'])) :
30 37 $mn['key0'] = trim($mn['key0']);
31 - $mn['key1'] = trim($mn['key1']);
32 -
33 38 if (strlen($mn['key0']) > 0) :
34 39 unset($custom_settings[$mn['key0']]); // out with the old
35 40 endif;
41 + endif;
36 42
43 + if (isset($mn['key1'])) :
44 + $mn['key1'] = trim($mn['key1']);
45 +
37 46 if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) :
38 47 $custom_settings[$mn['key1']] = $mn['value']; // in with the new
39 48 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;
49 + endif;
50 + endforeach;
57 51
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;
52 + $this->updatedPosts->accept_POST($post);
53 + if ($this->for_feed_settings()) :
54 + $alter = array ();
69 55
70 - // Save settings
71 - $this->link->save_settings(/*reload=*/ true);
72 - $this->updated = true;
56 + $this->link->settings['postmeta'] = serialize($custom_settings);
73 57
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;
58 + if (isset($post['resolve_relative'])) :
59 + $this->link->settings['resolve relative'] = $post['resolve_relative'];
60 + endif;
61 + if (isset($post['munge_permalink'])) :
62 + $this->link->settings['munge permalink'] = $post['munge_permalink'];
63 + endif;
64 + if (isset($post['munge_comments_feed_links'])) :
65 + $this->link->settings['munge comments feed links'] = $post['munge_comments_feed_links'];
66 + endif;
83 67
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']);
68 + // Post status, comment status, ping status
69 + foreach (array('post', 'comment', 'ping') as $what) :
70 + $sfield = "feed_{$what}_status";
71 + if (isset($post[$sfield])) :
72 + if ($post[$sfield]=='site-default') :
73 + unset($this->link->settings["{$what} status"]);
74 + else :
75 + $this->link->settings["{$what} status"] = $post[$sfield];
76 + endif;
92 77 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');
78 + endforeach;
79 +
80 + if (isset($post['syndicated_post_type'])) :
81 + if ($post['syndicated_post_type']=='default') :
82 + unset($this->link->settings['syndicated post type']);
98 83 else :
99 - update_option('feedwordpress_syndicated_comment_status', 'closed');
84 + $this->link->settings['syndicated post type'] = $post['syndicated_post_type'];
100 85 endif;
86 + endif;
101 87
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;
88 + else :
89 + // update_option ...
90 + if (isset($post['feed_post_status'])) :
91 + update_option('feedwordpress_syndicated_post_status', $post['feed_post_status']);
109 92 endif;
110 93
111 - // Probably a "Go" button for the drop-down
112 - else :
113 - $this->updated = false;
114 - endif;
94 + update_option('feedwordpress_custom_settings', serialize($custom_settings));
95 +
96 + update_option('feedwordpress_munge_permalink', $_REQUEST['munge_permalink']);
97 + update_option('feedwordpress_use_aggregator_source_data', $_REQUEST['use_aggregator_source_data']);
98 + update_option('feedwordpress_formatting_filters', $_REQUEST['formatting_filters']);
99 +
100 + if (isset($post['resolve_relative'])) :
101 + update_option('feedwordpress_resolve_relative', $post['resolve_relative']);
102 + endif;
103 + if (isset($post['munge_comments_feed_links'])) :
104 + update_option('feedwordpress_munge_comments_feed_links', $post['munge_comments_feed_links']);
105 + endif;
106 + if (isset($_REQUEST['feed_comment_status']) and ($_REQUEST['feed_comment_status'] == 'open')) :
107 + update_option('feedwordpress_syndicated_comment_status', 'open');
108 + else :
109 + update_option('feedwordpress_syndicated_comment_status', 'closed');
110 + endif;
111 +
112 + if (isset($_REQUEST['feed_ping_status']) and ($_REQUEST['feed_ping_status'] == 'open')) :
113 + update_option('feedwordpress_syndicated_ping_status', 'open');
114 + else :
115 + update_option('feedwordpress_syndicated_ping_status', 'closed');
116 + endif;
117 +
118 + if (isset($post['syndicated_post_type'])) :
119 + update_option('feedwordpress_syndicated_post_type', $post['syndicated_post_type']);
120 + endif;
121 + endif;
122 + parent::save_settings($post);
115 123 }
116 124
117 125 /**
118 126 * Outputs "Publication" settings box.
@@ -127,68 +135,39 @@
127 135 * @uses SyndicatedLink::syndicated_status()
128 136 * @uses SyndicatedPost::use_api()
129 137 */
130 138 /*static*/ function publication_box ($page, $box = NULL) {
131 - global $fwp_path;
132 -
133 - $post_status_global = FeedWordPress::syndicated_status('post', /*default=*/ 'publish');
134 139 $thesePosts = $page->these_posts_phrase();
135 -
136 - // Set up array for selector
137 - $setting = array(
138 - 'publish' => array ('label' => "Publish %s immediately", 'checked' => ''),
139 - 'draft' => array('label' => "Save %s as drafts", 'checked' => ''),
140 - 'private' => array('label' => "Save %s as private posts", 'checked' => ''),
140 + $postSelector = array(
141 + 'publish' => "Publish %s immediately",
142 + 'pending' => "Hold %s for review; mark as Pending",
143 + 'draft' => "Save %s as drafts",
144 + 'private' => "Save %s as private posts",
141 145 );
142 - if (SyndicatedPost::use_api('post_status_pending')) :
143 - $setting['pending'] = array('label' => "Hold %s for review; mark as Pending", 'checked' => '');
144 - endif;
146 + $labels = array();
147 + foreach ($postSelector as $index => $value) :
148 + $postSelector[$index] = sprintf(__($value), $thesePosts);
149 + $labels[$index] = __(str_replace(' %s', '', strtolower(strtok($value, ';'))));
150 + endforeach;
151 +
152 + $params = array(
153 + 'input-name' => 'feed_post_status',
154 + 'setting-default' => NULL,
155 + 'global-setting-default' => 'publish',
156 + 'labels' => $labels,
157 + );
145 158
146 -
147 - if ($page->for_feed_settings()) :
148 - $href = $fwp_path.'/'.basename(__FILE__);
149 - $currently = str_replace('%s', '', strtolower(strtok($setting[$post_status_global]['label'], ';')));
150 - $setting['site-default'] = array('label' => "Use <a href=\"admin.php?page=${href}\">site-wide setting</a>", 'checked' => '');
151 - $setting['site-default']['label'] .= " (currently: <strong>${currently}</strong>)";
152 -
153 - $checked = $page->link->syndicated_status('post', 'site-default', /*fallback=*/ false);
154 - else :
155 - $checked = $post_status_global;
156 - endif;
157 -
158 - // Re-order appropriately
159 - $selector = array();
160 - $order = array(
161 - 'site-default',
162 - 'publish',
163 - 'pending',
164 - 'draft',
165 - 'private',
166 - );
167 - foreach ($order as $line) :
168 - if (isset($setting[$line])) :
169 - $selector[$line] = $setting[$line];
170 - endif;
171 - endforeach;
172 - $selector[$checked]['checked'] = ' checked="checked"';
173 -
174 159 // Hey ho, let's go...
175 160 ?>
176 - <style type="text/css">
177 - #syndicated-publication-form th { width: 27%; vertical-align: top; }
178 - #syndicated-publication-form td { width: 73%; vertical-align: top; }
179 - </style>
180 -
181 - <table id="syndicated-publication-form" class="form-table" cellspacing="2" cellpadding="5">
161 + <table id="syndicated-publication-form" class="edit-form narrow">
182 162 <tr><th scope="row"><?php _e('New posts:'); ?></th>
183 - <td><ul class="options">
184 - <?php foreach ($selector as $code => $li) : ?>
185 - <li><label><input type="radio" name="feed_post_status"
186 - value="<?php print $code; ?>"<?php print $li['checked']; ?> />
187 - <?php print str_replace('%s', $thesePosts, $li['label']); ?></label></li>
188 - <?php endforeach; ?>
189 - </ul></td>
190 - </tr>
163 + <td><?php
164 + $this->setting_radio_control(
165 + 'post status', 'syndicated_post_status',
166 + $postSelector, $params
167 + );
168 + ?>
169 + </td></tr>
191 170
192 171 <?php $page->updatedPosts->display(); ?>
193 172 </table>
194 173
@@ -204,27 +183,19 @@
204 183 * @param array $box
205 184 *
206 185 */
207 186 function formatting_box ($page, $box = NULL) {
208 - global $fwp_path;
209 187 $thesePosts = $page->these_posts_phrase();
210 - $global_resolve_relative = get_option('feedwordpress_resolve_relative', 'yes');
188 +
211 189 if ($page->for_feed_settings()) :
212 190 $formatting_filters = null;
213 - $resolve_relative = $page->link->setting('resolve relative', NULL, 'default');
214 191 $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 192 else :
221 193 $formatting_filters = get_option('feedwordpress_formatting_filters', 'no');
222 - $resolve_relative = $global_resolve_relative;
223 194 $url = 'http://example.com';
224 195 endif;
225 196 ?>
226 - <table class="form-table" cellspacing="2" cellpadding="5">
197 + <table class="edit-form narrow">
227 198 <?php if (!is_null($formatting_filters)) : ?>
228 199
229 200 <tr><th scope="row">Formatting filters:</th>
230 201 <td><select name="formatting_filters" size="1">
@@ -239,22 +210,32 @@
239 210
240 211 <?php endif; ?>
241 212
242 213 <tr><th scope="row">Relative URIs:</th>
243 - <td>If link or image in a syndicated post from <code><?php print $url; ?></code>
214 + <td><p>If link or image in a syndicated post from <code><?php print $url; ?></code>
244 215 refers to a partial URI like <code>/about</code>, where should
245 216 the syndicated copy point to?</p>
246 217
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>
218 + <?php
219 + $options = array(
220 + 'yes' => 'Resolve the URI so it points to <code>'.$url.'</code><br/><small style="margin-left: 2.0em;"><code>/contact</code> is rewritten as <code>'.$url.'/contact</code></small>',
221 + 'no' => 'Leave relative URIs unchanged, so they point to this site<br/><small style="margin-left: 2.0em;"><code>/contact</code> is left as <code>/contact</code></small>',
222 + );
223 + $params = array(
224 + 'setting-default' => 'default',
225 + 'global-setting-default' => 'yes',
226 + 'labels' => array(
227 + 'yes' => __('resolve relative URIs'),
228 + 'no' => __('leave relative URIs unresolved'),
229 + ),
230 + 'default-input-value' => 'default',
231 + );
232 +
233 + $this->setting_radio_control(
234 + 'resolve relative', 'resolve_relative',
235 + $options, $params
236 + );
237 + ?>
257 238 </td></tr>
258 239
259 240 </table>
260 241 <?php
@@ -271,33 +252,34 @@
271 252 */
272 253 /*static*/ function links_box ($page, $box = NULL) {
273 254 $setting = array(
274 255 'munge_permalink' => array(
275 - 'yes' => 'the copy on the original website',
276 - 'no' => 'the local copy on this website',
256 + 'yes' => __('The copy on the original website'),
257 + 'no' => __('The local copy on this website'),
277 258 ),
278 259 );
279 260
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;
261 + if (!$page->for_feed_settings()) :
285 262 $use_aggregator_source_data = get_option('feedwordpress_use_aggregator_source_data');
286 263 endif;
287 -
288 264 ?>
289 - <table class="form-table" cellspacing="2" cellpadding="5">
265 + <table class="edit-form narrow">
290 266 <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>
298 - </tr>
267 + <td><?php
299 268
269 + $params = array(
270 + 'setting-default' => 'default',
271 + 'global-setting-default' => 'yes',
272 + 'default-input-value' => 'default',
273 + );
274 + $this->setting_radio_control(
275 + 'munge permalink', 'munge_permalink',
276 + $setting['munge_permalink'], $params
277 + );
278 + ?>
279 +
280 + </td></tr>
281 +
300 282 <?php if (!$page->for_feed_settings()) : ?>
301 283 <tr><th scope="row">Posts from aggregator feeds:</th>
302 284 <td><ul class="options">
303 285 <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>
@@ -322,95 +304,73 @@
322 304 * @param array $box
323 305 *
324 306 */
325 307 /*static*/ function comments_and_pings_box ($page, $box = NULL) {
326 - global $fwp_path;
327 -
328 - $setting = array();
329 - $selector = array();
330 -
331 308 $whatsits = array(
332 309 'comment' => array('label' => __('Comments'), 'accept' => 'Allow comments'),
333 310 'ping' => array('label' => __('Pings'), 'accept' => 'Accept pings'),
334 311 );
335 312 $onThesePosts = 'on '.$page->these_posts_phrase();
336 -
337 - $selected = array(
338 - 'munge_comments_feed_links' => array('yes' => '', 'no' => '')
313 +
314 + $mcflSettings = array(
315 + "yes" => __('Point to comment feeds from the original website (when provided by the syndicated feed)'),
316 + "no" => __('Point to local comment feeds on this website'),
339 317 );
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;
318 + $mcflParams = array(
319 + 'setting-default' => 'default',
320 + 'global-setting-default' => 'yes',
321 + 'labels' => array(
322 + 'yes' => __('comment feeds from the original website'),
323 + 'no' => __('local comment feeds on this website')
324 + ),
325 + 'default-input-value' => 'default',
326 + );
354 327
328 + $settings = array(); $params = array();
355 329 foreach ($whatsits as $what => $how) :
356 330 $whatsits[$what]['default'] = FeedWordPress::syndicated_status($what, /*default=*/ 'closed');
357 331
358 332 // Set up array for selector
359 - $setting = array(
360 - 'open' => array ('label' => "{$how['accept']} %s", 'checked' => ''),
361 - 'closed' => array('label' => "Don't ".strtolower($how['accept'])." %s", 'checked' => ''),
333 + $settings[$what] = array(
334 + 'open' => sprintf(__("{$how['accept']} %s"), __($onThesePosts)),
335 + 'closed' => sprintf(__("Don't ".strtolower($how['accept'])." %s"), __($onThesePosts)),
362 336 );
363 - if ($page->for_feed_settings()) :
364 - $href = $fwp_path.'/'.basename(__FILE__);
365 - $currently = trim(str_replace('%s', '', strtolower(strtok($setting[$whatsits[$what]['default']]['label'], ';'))));
366 - $setting['site-default'] = array('label' => "Use <a href=\"admin.php?page=${href}\">site-wide setting</a>", 'checked' => '');
367 - $setting['site-default']['label'] .= " (currently: <strong>${currently}</strong>)";
368 -
369 - $checked = $page->link->syndicated_status($what, 'site-default', /*fallback=*/ false);
370 - else :
371 - $checked = $whatsits[$what]['default'];
372 - endif;
373 -
374 - // Re-order appropriately
375 - $selector[$what] = array();
376 - $order = array(
377 - 'site-default',
378 - 'open',
379 - 'closed',
337 + $params[$what] = array(
338 + 'input-name' => "feed_${what}_status",
339 + 'setting-default' => NULL,
340 + 'global-setting-default' => FeedWordPress::syndicated_status($what, /*default=*/ 'closed'),
341 + 'labels' => array(
342 + 'open' => strtolower(__($how['accept'])),
343 + 'closed' => strtolower(__("Don't ".$how['accept'])),
344 + ),
380 345 );
381 - foreach ($order as $line) :
382 - if (isset($setting[$line])) :
383 - $selector[$what][$line] = $setting[$line];
384 - endif;
385 - endforeach;
386 - $selector[$what][$checked]['checked'] = ' checked="checked"';
387 346 endforeach;
388 347
389 348 // Hey ho, let's go...
390 349 ?>
391 - <table class="form-table" cellspacing="2" cellpadding="5">
350 + <table class="edit-form narrow">
392 351 <?php foreach ($whatsits as $what => $how) : ?>
352 +
393 353 <tr><th scope="row"><?php print $how['label']; ?>:</th>
394 - <td><ul class="options">
395 - <?php foreach ($selector[$what] as $code => $li) : ?>
396 - <li><label><input type="radio" name="feed_<?php print $what; ?>_status"
397 - value="<?php print $code; ?>"<?php print $li['checked']; ?> />
398 - <?php print trim(str_replace('%s', $onThesePosts, $li['label'])); ?></label></li>
399 - <?php endforeach; ?>
400 - </ul></td></tr>
354 + <td><?php
355 + $this->setting_radio_control(
356 + "$what status", "syndicated_${what}_status",
357 + $settings[$what], $params[$what]
358 + );
359 + ?></td></tr>
360 +
401 361 <?php endforeach; ?>
362 +
402 363 <tr><th scope="row"><?php _e('Comment feeds'); ?></th>
403 364 <td><p>When WordPress feeds and templates link to comments
404 365 feeds for <?php print $page->these_posts_phrase(); ?>, the
405 366 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>
367 + <?php
368 + $this->setting_radio_control(
369 + "munge comments feed links", "munge_comments_feed_links",
370 + $mcflSettings, $mcflParams
371 + );
372 + ?></td></tr>
413 373 </table>
414 374
415 375 <?php
416 376 } /* FeedWordPressPostsPage::comments_and_pings_box() */
@@ -420,9 +380,9 @@
420 380 $page = $this;
421 381 endif;
422 382
423 383 if ($page->for_feed_settings()) :
424 - $custom_settings = $page->link->settings["postmeta"];
384 + $custom_settings = $page->link->setting("postmeta", NULL, array());
425 385 else :
426 386 $custom_settings = get_option('feedwordpress_custom_settings');
427 387 endif;
428 388
@@ -490,83 +450,65 @@
490 450 </table>
491 451 </div> <!-- id="postcustomstuff" -->
492 452
493 453 <?php
494 - } /* FeedWordPressPostsPage::custom_post_settings_box() */
495 -}
454 + } /* FeedWordPressPostsPage::custom_post_settings_box() */
496 455
497 -function fwp_posts_page () {
498 - global $wpdb, $wp_db_version;
499 - global $fwp_post;
456 + function custom_post_types_box ($page, $box = NULL) {
457 + global $fwp_path;
458 +
459 + // local: syndicated post type // default NULL
460 + // global: syndicated_post_type // default 'post'
461 + // default-input-value => 'default'
462 +
463 + // Get all custom post types
464 + $post_types = get_post_types(array(
465 + '_builtin' => false,
466 + ), 'objects');
500 467
501 - if (FeedWordPress::needs_upgrade()) :
502 - fwp_upgrade_page();
503 - return;
504 - endif;
505 -
506 - // If this is a POST, validate source and user credentials
507 - FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_posts_settings', /*capability=*/ 'manage_links');
508 -
509 - $link = FeedWordPressAdminPage::submitted_link();
510 -
511 - $postsPage = new FeedWordPressPostsPage($link);
512 -
513 - $mesg = null;
514 -
515 - ////////////////////////////////////////////////
516 - // Process POST request, if any ////////////////
517 - ////////////////////////////////////////////////
518 - if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') :
519 - $postsPage->accept_POST($fwp_post);
520 - do_action('feedwordpress_admin_page_posts_save', $fwp_post, $postsPage);
521 - endif;
468 + $ul = array();
469 + $ul['post'] = __('Normal WordPress posts');
470 + foreach ($post_types as $post_type) :
471 + $ul[$post_type->name] = __($post_type->labels->name);
472 + endforeach;
473 +
474 + $params = array(
475 + 'global-setting-default' => 'post',
476 + 'default-input-value' => 'default',
477 + );
478 +
479 + // Hey, ho, let's go...
480 + ?>
481 + <table class="edit-form narrow">
482 + <tbody>
483 + <tr><th><?php _e('Custom Post Types:'); ?></th>
484 + <td><p>Incoming syndicated posts should be stored in the
485 + posts database as...</p>
486 + <?php
487 + $this->setting_radio_control(
488 + 'syndicated post type', 'syndicated_post_type',
489 + $ul, $params
490 + );
491 + ?>
492 + </td></tr>
493 + </tbody>
494 + </table>
495 + <?php
496 + } /* FeedWordPressPostsPage::custom_post_types_box() */
522 497
523 - $postsPage->ajax_interface_js();
524 -
525 - if ($postsPage->updated) : ?>
526 -<div class="updated"><p>Syndicated posts settings updated.</p></div>
527 -<?php elseif (!is_null($mesg)) : ?>
528 -<div class="updated"><p><?php print esc_html($mesg); ?></p></div>
529 -<?php endif; ?>
530 -
531 -<?php
532 - $links = FeedWordPress::syndicated_links();
533 - $postsPage->open_sheet('Syndicated Posts & Links');
534 -?>
535 -<style type="text/css">
536 - table.edit-form th, table.form-table th { width: 27%; vertical-align: top; }
537 - table.edit-form td, table.form-table td { width: 73%; vertical-align: top; }
538 - ul.options { margin: 0; padding: 0; list-style: none; }
539 -</style>
540 -<div id="post-body">
541 -<?php
542 -$boxes_by_methods = array(
543 - 'publication_box' => __('Syndicated Posts'),
544 - 'links_box' => __('Links'),
545 - 'formatting_box' => __('Formatting'),
546 - 'comments_and_pings_box' => __('Comments & Pings'),
547 - 'custom_post_settings_box' => __('Custom Post Settings (to apply to each syndicated post)'),
548 -);
549 -
550 - foreach ($boxes_by_methods as $method => $title) :
551 - fwp_add_meta_box(
552 - /*id=*/ 'feedwordpress_'.$method,
553 - /*title=*/ $title,
554 - /*callback=*/ array('FeedWordPressPostsPage', $method),
555 - /*page=*/ $postsPage->meta_box_context(),
556 - /*context=*/ $postsPage->meta_box_context()
498 + function display () {
499 + $this->boxes_by_methods = array(
500 + 'publication_box' => __('Syndicated Posts'),
501 + 'links_box' => __('Links'),
502 + 'formatting_box' => __('Formatting'),
503 + 'comments_and_pings_box' => __('Comments & Pings'),
504 + 'custom_post_settings_box' => __('Custom Post Settings (to apply to each syndicated post)'),
505 + 'custom_post_types_box' => ('Custom Post Types (advanced database settings)'),
557 506 );
558 - endforeach;
559 - do_action('feedwordpress_admin_page_posts_meta_boxes', $postsPage);
560 -?>
561 - <div class="metabox-holder">
562 -<?php
563 - fwp_do_meta_boxes($postsPage->meta_box_context(), $postsPage->meta_box_context(), $postsPage);
564 -?>
565 - </div> <!-- class="metabox-holder" -->
566 -</div> <!-- id="post-body" -->
567 -<?php
568 - $postsPage->close_sheet();
569 -} /* function fwp_posts_page () */
507 +
508 + parent::display();
509 + } /* FeedWordPressPostsPage::display () */
510 +}
570 511
571 - fwp_posts_page();
512 + $postsPage = new FeedWordPressPostsPage;
513 + $postsPage->display();
572 514