PluginProbe
FeedWordPress / 2017.1004
FeedWordPress v2017.1004
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 +96 -327 trunk2017.1004 View file →
@@ -19,9 +19,9 @@
19 19 parent::__construct('feedwordpresspostspage', $link);
20 20 $this->dispatch = 'feedwordpress_admin_page_posts';
21 21 $this->filename = __FILE__;
22 22 $this->updatedPosts = new UpdatedPostsControl($this);
23 -
23 +
24 24 $this->pagenames = array(
25 25 'default' => 'Posts',
26 26 'settings-update' => 'Syndicated posts',
27 27 'open-sheet' => 'Syndicated Posts & Links',
@@ -27,141 +27,104 @@
27 27 'open-sheet' => 'Syndicated Posts & Links',
28 28 );
29 29 } /* FeedWordPressPostsPage constructor */
30 30
31 - function save_settings () {
31 + function save_settings ($post) {
32 32 // custom post settings
33 33 $custom_settings = $this->custom_post_settings();
34 34
35 - $posted_notes = FeedWordPress::post( 'notes', array(), 'text' );
36 - foreach ( $posted_notes as $mn ) :
37 - if ( isset( $mn['key0'] ) ) :
38 - $mn['key0'] = trim( $mn['key0'] );
39 - if ( strlen( $mn['key0'] ) > 0 ) :
40 - unset( $custom_settings[ $mn['key0'] ] ); // out with the old
35 + foreach ($post['notes'] as $mn) :
36 + if (isset($mn['key0'])) :
37 + $mn['key0'] = trim($mn['key0']);
38 + if (strlen($mn['key0']) > 0) :
39 + unset($custom_settings[$mn['key0']]); // out with the old
41 40 endif;
42 41 endif;
42 +
43 + if (isset($mn['key1'])) :
44 + $mn['key1'] = trim($mn['key1']);
43 45
44 - if ( isset( $mn['key1'] ) ) :
45 - $mn['key1'] = trim( $mn['key1'] );
46 -
47 - if ( ( $mn['action']=='update' ) and ( strlen( $mn['key1'] ) > 0 ) ) :
48 - $custom_settings[ $mn['key1'] ] = $mn['value']; // in with the new
46 + if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) :
47 + $custom_settings[$mn['key1']] = $mn['value']; // in with the new
49 48 endif;
50 49 endif;
51 50 endforeach;
52 51
53 - $this->updatedPosts->accept_POST();
52 + $this->updatedPosts->accept_POST($post);
54 53 if ($this->for_feed_settings()) :
55 - // $alter = array(); // this appears elsewhere, too, also unused, and possibly removed as well (gwyneth 20230920)
54 + $alter = array ();
56 55
57 56 $this->link->settings['postmeta'] = serialize($custom_settings);
58 57
59 - if ( ! is_null( FeedWordPress::post( 'resolve_relative', null ) ) ) :
60 - $this->link->settings['resolve relative'] = FeedWordPress::post( 'resolve_relative', null, 'text' );
58 + if (isset($post['resolve_relative'])) :
59 + $this->link->settings['resolve relative'] = $post['resolve_relative'];
61 60 endif;
62 - if ( ! is_null( FeedWordPress::post('munge_permalink', null, 'text' ) ) ) :
63 - $this->link->settings['munge permalink'] = FeedWordPress::post( 'munge_permalink', null, 'text' );
61 + if (isset($post['munge_permalink'])) :
62 + $this->link->settings['munge permalink'] = $post['munge_permalink'];
64 63 endif;
65 - if ( ! is_null( FeedWordPress::post('munge_comments_feed_links', null, 'text' ) ) ) :
66 - $this->link->settings['munge comments feed links'] = FeedWordPress::post( 'munge_comments_feed_links', null, 'text' );
64 + if (isset($post['munge_comments_feed_links'])) :
65 + $this->link->settings['munge comments feed links'] = $post['munge_comments_feed_links'];
67 66 endif;
68 67
69 68 // Post status, comment status, ping status
70 69 foreach (array('post', 'comment', 'ping') as $what) :
71 70 $sfield = "feed_{$what}_status";
72 - if ( ! is_null( FeedWordPress::post( $sfield, null, 'text' ) ) ) :
73 - $afield = sprintf( '%s status', $what );
74 - if ( FeedWordPress::post( $sfield, null, 'text' ) == 'site-default' ) :
75 - unset($this->link->settings[ $afield ]);
71 + if (isset($post[$sfield])) :
72 + if ($post[$sfield]=='site-default') :
73 + unset($this->link->settings["{$what} status"]);
76 74 else :
77 - $this->link->settings[ $afield ] = FeedWordPress::post( $sfield, null, 'text' );
75 + $this->link->settings["{$what} status"] = $post[$sfield];
78 76 endif;
79 77 endif;
80 78 endforeach;
81 -
82 - if ( ! is_null( FeedWordPress::post('syndicated_post_type', null, 'text' ) ) ) :
83 - if ( FeedWordPress::post( 'syndicated_post_type', null, 'text' ) == 'default' ) :
79 +
80 + if (isset($post['syndicated_post_type'])) :
81 + if ($post['syndicated_post_type']=='default') :
84 82 unset($this->link->settings['syndicated post type']);
85 83 else :
86 - $this->link->settings['syndicated post type'] = FeedWordPress::post( 'syndicated_post_type', null, 'text' );
84 + $this->link->settings['syndicated post type'] = $post['syndicated_post_type'];
87 85 endif;
88 86 endif;
89 87
90 88 else :
91 89 // update_option ...
92 - if ( ! is_null( FeedWordPress::post( 'feed_post_status', null ) ) ) :
93 -
94 - update_option('feedwordpress_syndicated_post_status', FeedWordPress::post( 'feed_post_status', null, 'text' ) );
95 -
90 + if (isset($post['feed_post_status'])) :
91 + update_option('feedwordpress_syndicated_post_status', $post['feed_post_status']);
96 92 endif;
97 93
98 94 update_option('feedwordpress_custom_settings', serialize($custom_settings));
99 95
100 - $sMungePermalink = FeedWordPress::post('munge_permalink', null, 'text' );
101 - $sUseAggregatorSourceData = FeedWordPress::post( 'use_aggregator_source_data', null, 'text' );
102 - $sFormattingFilters = FeedWordPress::post('formatting_filters', null, 'text' );
103 - $sFeedCommentStatus = FeedWordPress::post( 'feed_comment_status', '', 'text' );
104 - $sFeedPingStatus = FeedWordPress::post( 'feed_ping_status', '', 'text' );
105 - $sResolveRelative = FeedWordPress::post( 'resolve_relative', null, 'text' );
106 - $sMungeCommentsFeedLinks = FeedWordPress::post( 'munge_comments_feed_links', null, 'text' );
107 - $sSyndicatedPostType = FeedWordPress::post( 'syndicated_post_type', null, 'text' );
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']);
108 99
109 - update_option('feedwordpress_munge_permalink', $sMungePermalink);
110 - update_option('feedwordpress_use_aggregator_source_data', $sUseAggregatorSourceData);
111 - update_option('feedwordpress_formatting_filters', $sFormattingFilters);
112 -
113 - if ( ! is_null( $sResolveRelative ) ) :
114 - update_option('feedwordpress_resolve_relative', $sResolveRelative );
100 + if (isset($post['resolve_relative'])) :
101 + update_option('feedwordpress_resolve_relative', $post['resolve_relative']);
115 102 endif;
116 - if ( ! is_null( $sMungeCommentsFeedLinks ) ) :
117 - update_option('feedwordpress_munge_comments_feed_links', $sMungeCommentsFeedLinks );
103 + if (isset($post['munge_comments_feed_links'])) :
104 + update_option('feedwordpress_munge_comments_feed_links', $post['munge_comments_feed_links']);
118 105 endif;
119 -
120 - if ( $sFeedCommentStatus == 'open' ) :
106 + if (isset($_REQUEST['feed_comment_status']) and ($_REQUEST['feed_comment_status'] == 'open')) :
121 107 update_option('feedwordpress_syndicated_comment_status', 'open');
122 108 else :
123 109 update_option('feedwordpress_syndicated_comment_status', 'closed');
124 110 endif;
125 111
126 - if ( $sFeedPingStatus == 'open' ) :
112 + if (isset($_REQUEST['feed_ping_status']) and ($_REQUEST['feed_ping_status'] == 'open')) :
127 113 update_option('feedwordpress_syndicated_ping_status', 'open');
128 114 else :
129 115 update_option('feedwordpress_syndicated_ping_status', 'closed');
130 116 endif;
131 -
132 - if ( ! is_null( $sSyndicatedPostType ) ) :
133 - update_option('feedwordpress_syndicated_post_type', $sSyndicatedPostType );
117 +
118 + if (isset($post['syndicated_post_type'])) :
119 + update_option('feedwordpress_syndicated_post_type', $post['syndicated_post_type']);
134 120 endif;
135 121 endif;
136 -
137 - $boilerplate = FeedWordPress::post( 'boilerplate', array(), 'raw' );
138 - if ( count($boilerplate) > 0 ) :
139 - foreach ( $boilerplate as $index => $line) :
140 - if ( 0 == strlen( trim( $line['template'] ) ) ) :
141 - unset( $boilerplate[$index] );
142 - endif;
143 - endforeach;
144 -
145 - // Convert indexes to 0..(N-1) to avoid possible collisions
146 - $boilerplate = array_values( $boilerplate );
147 -
148 - if ($this->for_feed_settings()) :
149 - $this->link->settings['boilerplate rules'] = serialize( $boilerplate );
150 - $this->link->save_settings(/*reload=*/ true);
151 - else :
152 - update_option( 'feedwordpress_boilerplate', $boilerplate );
153 - endif;
154 - endif;
155 -
156 - $boilerplate_hook_order = FeedWordPress::post( 'boilerplate_hook_order', 10, 'text' );
157 - $this->update_setting('boilerplate hook order', intval( $boilerplate_hook_order ) );
158 -
159 - parent::save_settings();
122 + parent::save_settings($post);
160 123 }
161 124
162 125 /**
163 - * publication_box: Outputs "Publication" settings box.
126 + * Outputs "Publication" settings box.
164 127 *
165 128 * @since 2009.0713
166 129 * @param object $page of class FeedWordPressPostsPage tells us whether this is
167 130 * a page for one feed's settings or for global defaults
@@ -169,9 +132,9 @@
169 132 *
170 133 * @uses FeedWordPressPostsPage::these_posts_phrase()
171 134 * @uses FeedWordPress::syndicated_status()
172 135 * @uses SyndicatedLink::syndicated_status()
173 - */
136 + */
174 137 /*static*/ function publication_box ($page, $box = NULL) {
175 138 $thesePosts = $page->these_posts_phrase();
176 139 $postSelector = array(
177 140 'publish' => "Publish %s immediately",
@@ -183,9 +146,9 @@
183 146 foreach ($postSelector as $index => $value) :
184 147 $postSelector[$index] = sprintf(__($value), $thesePosts);
185 148 $labels[$index] = __(str_replace(' %s', '', strtolower(strtok($value, ';'))));
186 149 endforeach;
187 -
150 +
188 151 $params = array(
189 152 'input-name' => 'feed_post_status',
190 153 'setting-default' => NULL,
191 154 'global-setting-default' => 'publish',
@@ -194,9 +157,9 @@
194 157
195 158 // Hey ho, let's go...
196 159 ?>
197 160 <table id="syndicated-publication-form" class="edit-form narrow">
198 - <tr><th scope="row"><?php esc_html_e('New posts:'); ?></th>
161 + <tr><th scope="row"><?php _e('New posts:'); ?></th>
199 162 <td><?php
200 163 $this->setting_radio_control(
201 164 'post status', 'syndicated_post_status',
202 165 $postSelector, $params
@@ -205,23 +168,23 @@
205 168 </td></tr>
206 169
207 170 <?php $page->updatedPosts->display(); ?>
208 171 </table>
209 -
172 +
210 173 <?php
211 174 } /* FeedWordPressPostsPage::publication_box () */
212 -
175 +
213 176 /**
214 177 * Outputs "Formatting" settings box
215 178 *
216 179 * @since 2009.0713
217 - * @param FeedWordPressPostsPage $page of class FeedWordPressPostsPage tells us whether this is
218 - * a page for one feed's settings or for global defaults
180 + * @param object $page of class FeedWordPressPostsPage tells us whether this is
181 + * a page for one feed's settings or for global defaults
219 182 * @param array $box
220 183 *
221 - */
222 - function formatting_box( $page, $box = NULL ) {
223 - $thesePosts = $page->these_posts_phrase(); // result unused, why? (gwyneth 20230920)
184 + */
185 + function formatting_box ($page, $box = NULL) {
186 + $thesePosts = $page->these_posts_phrase();
224 187
225 188 if ($page->for_feed_settings()) :
226 189 $formatting_filters = null;
227 190 $url = preg_replace('|/+$|', '', $page->link->homepage());
@@ -230,9 +193,9 @@
230 193 $url = 'http://example.com';
231 194 endif;
232 195 ?>
233 196 <table class="edit-form narrow">
234 - <?php if ( !is_null($formatting_filters)) : ?>
197 + <?php if (!is_null($formatting_filters)) : ?>
235 198
236 199 <tr><th scope="row">Formatting filters:</th>
237 200 <td><select name="formatting_filters" size="1">
238 201 <option value="no"<?php echo ($formatting_filters!='yes')?' selected="selected"':''; ?>>Protect syndicated posts from formatting filters</option>
@@ -244,11 +207,11 @@
244 207 problem.</p>
245 208 </td></tr>
246 209
247 210 <?php endif; ?>
248 -
211 +
249 212 <tr><th scope="row">Relative URIs:</th>
250 - <td><p>If link or image in a syndicated post from <code><?php print esc_html($url); ?></code>
213 + <td><p>If link or image in a syndicated post from <code><?php print $url; ?></code>
251 214 refers to a partial URI like <code>/about</code>, where should
252 215 the syndicated copy point to?</p>
253 216
254 217 <?php
@@ -269,15 +232,15 @@
269 232 $this->setting_radio_control(
270 233 'resolve relative', 'resolve_relative',
271 234 $options, $params
272 235 );
273 - ?>
236 + ?>
274 237 </td></tr>
275 238
276 239 </table>
277 240 <?php
278 241 } /* FeedWordPressPostsPage::formatting_box() */
279 -
242 +
280 243 /**
281 244 * Output "Links" settings box
282 245 *
283 246 * @since 2009.0713
@@ -293,9 +256,9 @@
293 256 'no' => __('The local copy on this website'),
294 257 ),
295 258 );
296 259
297 - if ( ! $page->for_feed_settings()) :
260 + if (!$page->for_feed_settings()) :
298 261 $use_aggregator_source_data = get_option('feedwordpress_use_aggregator_source_data');
299 262 endif;
300 263 ?>
301 264 <table class="edit-form narrow">
@@ -300,9 +263,9 @@
300 263 ?>
301 264 <table class="edit-form narrow">
302 265 <tr><th scope="row">Permalinks point to:</th>
303 266 <td><?php
304 -
267 +
305 268 $params = array(
306 269 'setting-default' => 'default',
307 270 'global-setting-default' => 'yes',
308 271 'default-input-value' => 'default',
@@ -313,10 +276,10 @@
313 276 );
314 277 ?>
315 278
316 279 </td></tr>
317 -
318 - <?php if ( ! $page->for_feed_settings()) : ?>
280 +
281 + <?php if (!$page->for_feed_settings()) : ?>
319 282 <tr><th scope="row">Posts from aggregator feeds:</th>
320 283 <td><ul class="options">
321 284 <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 285 <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>
@@ -345,9 +308,9 @@
345 308 'comment' => array('label' => __('Comments'), 'accept' => 'Allow comments'),
346 309 'ping' => array('label' => __('Pings'), 'accept' => 'Accept pings'),
347 310 );
348 311 $onThesePosts = 'on '.$page->these_posts_phrase();
349 -
312 +
350 313 $mcflSettings = array(
351 314 "yes" => __('Point to comment feeds from the original website (when provided by the syndicated feed)'),
352 315 "no" => __('Point to local comment feeds on this website'),
353 316 );
@@ -370,9 +333,9 @@
370 333 'open' => sprintf(__("{$how['accept']} %s"), __($onThesePosts)),
371 334 'closed' => sprintf(__("Don't ".strtolower($how['accept'])." %s"), __($onThesePosts)),
372 335 );
373 336 $params[$what] = array(
374 - 'input-name' => "feed_{$what}_status",
337 + 'input-name' => "feed_${what}_status",
375 338 'setting-default' => NULL,
376 339 'global-setting-default' => FeedWordPress::syndicated_status($what, /*default=*/ 'closed'),
377 340 'labels' => array(
378 341 'open' => strtolower(__($how['accept'])),
@@ -384,22 +347,22 @@
384 347 // Hey ho, let's go...
385 348 ?>
386 349 <table class="edit-form narrow">
387 350 <?php foreach ($whatsits as $what => $how) : ?>
388 -
389 - <tr><th scope="row"><?php print esc_html($how['label']); ?>:</th>
351 +
352 + <tr><th scope="row"><?php print $how['label']; ?>:</th>
390 353 <td><?php
391 354 $this->setting_radio_control(
392 - "$what status", "syndicated_{$what}_status",
355 + "$what status", "syndicated_${what}_status",
393 356 $settings[$what], $params[$what]
394 357 );
395 358 ?></td></tr>
396 -
359 +
397 360 <?php endforeach; ?>
398 -
399 - <tr><th scope="row"><?php esc_html_e('Comment feeds'); ?></th>
361 +
362 + <tr><th scope="row"><?php _e('Comment feeds'); ?></th>
400 363 <td><p>When WordPress feeds and templates link to comments
401 - feeds for <?php print esc_html($page->these_posts_phrase()); ?>, the
364 + feeds for <?php print $page->these_posts_phrase(); ?>, the
402 365 URLs for the feeds should...</p>
403 366 <?php
404 367 $this->setting_radio_control(
405 368 "munge comments feed links", "munge_comments_feed_links",
@@ -409,9 +372,9 @@
409 372 </table>
410 373
411 374 <?php
412 375 } /* FeedWordPressPostsPage::comments_and_pings_box() */
413 -
376 +
414 377 /*static*/ function custom_post_settings ($page = NULL) {
415 378 if (is_null($page)) :
416 379 $page = $this;
417 380 endif;
@@ -424,23 +387,15 @@
424 387
425 388 if ($custom_settings and !is_array($custom_settings)) :
426 389 $custom_settings = unserialize($custom_settings);
427 390 endif;
428 -
429 - if ( !is_array($custom_settings)) :
391 +
392 + if (!is_array($custom_settings)) :
430 393 $custom_settings = array();
431 394 endif;
432 395
433 396 return $custom_settings;
434 397 } /* FeedWordPressPostsPage::custom_post_settings() */
435 -
436 - /*static*/ function custom_post_settings_box_tester_button ( $id, $page, $box = NULL ) {
437 -
438 - ?>
439 - <br/><button id="<?php print esc_attr( sprintf( 'xpath-test-%d', $id ) ); ?>" class="xpath-test">test expression</button>
440 - <?php
441 -
442 - }
443 398
444 399 /**
445 400 * Output "Custom Post Settings" settings box
446 401 *
@@ -462,16 +417,19 @@
462 417 </tr>
463 418
464 419 <?php
465 420 $i = 0;
466 - foreach ($custom_settings as $key => $value) :
421 + $testerButton = '<br/><button id="xpath-test-%d"'
422 + .'class="xpath-test"'
423 + .'>test expression</button>';
424 + foreach ($custom_settings as $key => $value) :
467 425 ?>
468 426 <tr style="vertical-align:top">
469 - <th width="30%" scope="row"><input type="hidden" name="notes[<?php echo esc_attr($i); ?>][key0]" value="<?php echo esc_html($key); ?>" />
470 - <input id="notes-<?php echo esc_attr( $i ); ?>-key" name="notes[<?php echo esc_attr( $i ); ?>][key1]" value="<?php echo esc_html($key); ?>" /></th>
471 - <td width="60%"><textarea rows="2" cols="40" id="notes-<?php echo esc_attr($i); ?>-value" name="notes[<?php echo esc_attr($i); ?>][value]"><?php echo esc_html($value); ?></textarea>
472 - <?php self::custom_post_settings_box_tester_button($i, $page, $box); ?></td>
473 - <td width="10%"><select name="notes[<?php echo esc_attr($i); ?>][action]">
427 + <th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo esc_html($key); ?>" />
428 + <input id="notes-<?php echo $i; ?>-key" name="notes[<?php echo $i; ?>][key1]" value="<?php echo esc_html($key); ?>" /></th>
429 + <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>
430 + <?php print sprintf($testerButton, $i); ?></td>
431 + <td width="10%"><select name="notes[<?php echo $i; ?>][action]">
474 432 <option value="update">save changes</option>
475 433 <option value="delete">delete this setting</option>
476 434 </select></td>
477 435 </tr>
@@ -481,10 +439,10 @@
481 439 endforeach;
482 440 ?>
483 441
484 442 <tr style="vertical-align: top">
485 - <th scope="row"><input type="text" size="10" name="notes[<?php echo esc_attr($i); ?>][key1]" value="" /></th>
486 - <td><textarea name="notes[<?php echo esc_attr($i); ?>][value]" rows="2" cols="40"></textarea><?php self::custom_post_settings_box_tester_button( $i, $page, $box ); ?>
443 + <th scope="row"><input type="text" size="10" name="notes[<?php echo $i; ?>][key1]" value="" /></th>
444 + <td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea><?php print sprintf($testerButton, $i); ?>
487 445 <p>Enter a text value, or a path to a data element from the syndicated item.<br/>
488 446 For data elements, you can use an XPath-like syntax wrapped in <code>$( ... )</code>.<br/>
489 447 <code>hello</code> = the text value <code><span style="background-color: #30FFA0;">hello</span></code><br/>
490 448 <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/>
@@ -489,9 +447,9 @@
489 447 <code>hello</code> = the text value <code><span style="background-color: #30FFA0;">hello</span></code><br/>
490 448 <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/>
491 449 <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>
492 450 </td>
493 - <td><em>add new setting...</em><input type="hidden" name="notes[<?php echo esc_attr($i); ?>][action]" value="update" /></td>
451 + <td><em>add new setting...</em><input type="hidden" name="notes[<?php echo $i; ?>][action]" value="update" /></td>
494 452 </tr>
495 453 </table>
496 454 </div> <!-- id="postcustomstuff" -->
497 455
@@ -498,12 +456,14 @@
498 456 <?php
499 457 } /* FeedWordPressPostsPage::custom_post_settings_box() */
500 458
501 459 function custom_post_types_box ($page, $box = NULL) {
502 - // local: syndicated post type // default NULL
460 + global $fwp_path;
461 +
462 + // local: syndicated post type // default NULL
503 463 // global: syndicated_post_type // default 'post'
504 464 // default-input-value => 'default'
505 -
465 +
506 466 // Get all custom post types
507 467 $post_types = get_post_types(array(
508 468 '_builtin' => false,
509 469 ), 'objects');
@@ -512,19 +472,19 @@
512 472 $ul['post'] = __('Normal WordPress posts');
513 473 foreach ($post_types as $post_type) :
514 474 $ul[$post_type->name] = __($post_type->labels->name);
515 475 endforeach;
516 -
476 +
517 477 $params = array(
518 478 'global-setting-default' => 'post',
519 479 'default-input-value' => 'default',
520 480 );
521 -
481 +
522 482 // Hey, ho, let's go...
523 483 ?>
524 484 <table class="edit-form narrow">
525 485 <tbody>
526 - <tr><th><?php esc_html_e('Custom Post Types:'); ?></th>
486 + <tr><th><?php _e('Custom Post Types:'); ?></th>
527 487 <td><p>Incoming syndicated posts should be stored in the
528 488 posts database as...</p>
529 489 <?php
530 490 $this->setting_radio_control(
@@ -536,212 +496,21 @@
536 496 </tbody>
537 497 </table>
538 498 <?php
539 499 } /* FeedWordPressPostsPage::custom_post_types_box() */
540 -
541 - public function boilerplate_box ($page, $box = NULL) {
542 - if ($page->for_feed_settings()) :
543 - $attrib = isset($page->link->settings['boilerplate rules'])
544 - ? unserialize($page->link->settings['boilerplate rules'])
545 - : [];
546 - $syndicatedPosts = 'this feed\'s posts';
547 - else :
548 - $attrib = get_option('feedwordpress_boilerplate');
549 - $syndicatedPosts = 'syndicated posts';
550 - endif;
551 - $hookOrder = intval($page->setting('boilerplate hook order', FEEDWORDPRESS_BOILERPLATE_DEFAULT_HOOK_ORDER));
552 -?>
553 - <style type="text/css">
554 - .boilerplate-help-box {
555 - float: right;
556 - width: 300px;
557 - border: 1px dotted #777;
558 - margin: 3px;
559 - padding: 5px;
560 - background-color: #f7f7f7;
561 - }
562 - .boilerplate-help-box dt {
563 - font-weight: bold;
564 - font-size: 85%;
565 - }
566 - .boilerplate-help-box dd {
567 - font-size: 80%; line-height: 100%; font-style: italic;
568 - padding-left: 1.5em;
569 - }
570 - .boilerplate-help-box code {
571 - font-size: inherit;
572 - font-style: normal;
573 - background-color: inherit;
574 - }
575 -
576 - .boilerplate-li {
577 - padding-bottom: 5px;
578 - margin-bottom: 5px;
579 - border-bottom: 1px dotted black;
580 - }
581 -
582 - </style>
583 -
584 - <div class="boilerplate-help-box">
585 - <p style="border-bottom: 1px dotted #777;">To remove boilerplate, just blank out the text box and leave it empty.</p>
586 -
587 - <p>Use shortcodes to include information about your source:</p>
588 - <dl>
589 - <dt><code>[source]</code></dt>
590 - <dd>A link to the source you syndicated the post from</dd>
591 -
592 - <dt><code>[source-name]</code></dt>
593 - <dd>Name of the source you syndicated the post from</dd>
594 -
595 - <dt><code>[source-url]</code></dt>
596 - <dd>URL of the source you syndicated the post from</dd>
597 -
598 - <dt><code>[original-link]text[/original-link]</code></dt>
599 - <dd>A link to the <em>original post</em> back on the source website,
600 - using <code>text</code> as the link text.</dd>
601 -
602 - <dt><code>[original-url]</code></dt>
603 - <dd>URL of the <em>original post</em> back on the source website</dd>
604 -
605 - <dt><code>[author]</code></dt>
606 - <dd>A link with the name of the author who wrote the post, linking to other posts by the same author</dd>
607 -
608 - <dt><code>[author-name]</code></dt>
609 - <dd>Name of the author who wrote the post</dd>
610 -
611 - <dt><code>[feed-setting key="setting-name"]</code></dt>
612 - <dd>Value of a custom feed setting (named <code>setting-name</code>) for the feed</dd>
613 - </dl>
614 - </div>
615 -
616 -<?php
617 - print "<ul>\n";
618 - if ( !is_array($attrib)) : $attrib = array(); endif;
619 -
620 - print '<input type="hidden" id="next-boilerplate-rule-index" name="next_boilerplate_rule_index" value="'.count($attrib).'" />';
621 -
622 - // In AJAX environment, this is a dummy rule that stays hidden. In a
623 - // non-AJAX environment, this provides a blank rule that we can fill in.
624 - $attrib['new'] = array(
625 - 'class' => array('hide-if-js'),
626 - 'placement' => 'before',
627 - 'element' => 'post',
628 - 'template' => '',
629 - );
630 -
631 - foreach ($attrib as $index => $line) :
632 - if (isset($line['template'])) :
633 - $selected['before'] = (($line['placement']=='before') ? ' selected="selected"' : '');
634 - $selected['after'] = (($line['placement']=='after') ? ' selected="selected"' : '');
635 - $selected['title'] = (($line['element']=='title') ? ' selected="selected"' : '');
636 - $selected['post'] = (($line['element']=='post') ? ' selected="selected"' : '');
637 - $selected['excerpt'] = (($line['element']=='excerpt') ? ' selected="selected"' : '');
638 -
639 - if ( !isset($line['class'])) : $line['class'] = array(); endif;
640 - $line['class'][] = 'boilerplate-li';
641 -?>
642 -
643 -<li id="boilerplate-<?php print esc_attr($index); ?>-li" class="<?php print esc_attr(implode(' ', $line['class'])); ?>">&raquo; <strong>Add</strong> <select id="boilerplate-<?php print esc_attr($index); ?>-placement" name="boilerplate[<?php print esc_attr($index); ?>][placement]" style="width: 8.0em">
644 -<option value="before"<?php fwp_selected_flag( $selected, 'before' ); ?>>before</option>
645 -<option value="after"<?php fwp_selected_flag( $selected, 'after' ); ?>>after</option>
646 -</select> the <select style="width: 8.0em" id="boilerplate-<?php print esc_attr($index); ?>-element" name="boilerplate[<?php print esc_attr($index); ?>][element]">
647 -<option value="title"<?php fwp_selected_flag($selected, 'title' ); ?>>title</option>
648 -<option value="post"<?php fwp_selected_flag( $selected, 'post' ); ?>>content</option>
649 -<option value="excerpt"<?php fwp_selected_flag( $selected, 'excerpt' ); ?>>excerpt</option>
650 -</select> of
651 -<?php print esc_html($syndicatedPosts); ?>: <textarea style="vertical-align: top; width: 40%;" rows="2" cols="30" class="boilerplate-template" id="boilerplate-<?php print esc_attr($index); ?>-template" name="boilerplate[<?php print esc_attr($index); ?>][template]"><?php print esc_html($line['template']); ?></textarea></li>
652 -<?php
653 - endif;
654 - endforeach;
655 -?>
656 - </ul>
657 - <br style="clear: both" />
658 -
659 - <script type="text/javascript">
660 - jQuery(document).ready( function($) {
661 - $('.boilerplate-template').blur( function() {
662 - if (this.value.length == 0) {
663 - var theLi = $('li:has(#'+this.id+")");
664 - theLi.hide('normal')
665 - }
666 - } );
667 -
668 - var addRuleLi = document.createElement('li');
669 - addRuleLi.innerHTML = '<strong style="vertical-align: middle; font-size: 110%">[+]</strong> <a style="font-variant: small-caps" id="add-new-boilerplate-rule" href="#">Add new boilerplate</a> ….';
670 - $('#boilerplate-new-li').after(addRuleLi);
671 -
672 - $('#add-new-boilerplate-rule').click( function() {
673 - // Get index counter
674 - var nextIndex = parseInt($('#next-boilerplate-rule-index').val());
675 -
676 - var newIdPrefix = 'boilerplate-'+nextIndex;
677 - var newNamePrefix = 'boilerplate['+nextIndex+']';
678 -
679 - var dummy = {};
680 - dummy['li'] = {'el': $('#boilerplate-new-li') }
681 - dummy['placement'] = {'el': $('#boilerplate-new-placement') };
682 - dummy['element'] = {'el': $('#boilerplate-new-element') };
683 - dummy['template'] = {'el': $('#boilerplate-new-template') };
684 -
685 - for (var element in dummy) {
686 - dummy[element]['save'] = {
687 - 'id': dummy[element]['el'].attr('id'),
688 - 'name': dummy[element]['el'].attr('name')
689 - };
690 - dummy[element]['el'].attr('id', newIdPrefix+'-'+element);
691 - dummy[element]['el'].attr('name', newNamePrefix+'['+element+']');
692 - }
693 -
694 - var newLi = $('#'+newIdPrefix+'-li').clone(/*events=*/ true);
695 - //newLi.attr('id', null);
696 - newLi.removeClass('hide-if-js');
697 - newLi.addClass('boilerplate-li');
698 - newLi.css('display', 'none');
699 -
700 - // Switch back
701 - for (var element in dummy) {
702 - dummy[element]['el'].attr('id', dummy[element]['save']['id']);
703 - dummy[element]['el'].attr('name', dummy[element]['save']['name']);
704 - }
705 -
706 - $('#boilerplate-new-li').before(newLi);
707 - newLi.show('normal');
708 -
709 - $('#next-boilerplate-rule-index').val(nextIndex+1);
710 -
711 - return false;
712 - } )
713 - } );
714 - </script>
715 -<?php
716 - if ($page->for_default_settings()) :
717 -?>
718 - <h3>Advanced Settings</h3>
719 - <table class="edit-form narrow">
720 - <tbody>
721 - <tr><th scope="row"><?php esc_html_e("Hook Order:") ?></th>
722 - <td><input type="number" name="boilerplate_hook_order" value="<?php print esc_attr($hookOrder); ?>" /></td></tr>
723 - </tbody>
724 - </table>
725 -<?php
726 - endif;
727 - } /* FeedWordPressPostsPage::boilerplate_box() */
728 -
500 +
729 501 function display () {
730 502 $this->boxes_by_methods = array(
731 503 'publication_box' => __('Syndicated Posts'),
732 504 'links_box' => __('Links'),
733 505 'formatting_box' => __('Formatting'),
734 - 'boilerplate_box' => ('Boilerplate / Credits'),
735 506 'comments_and_pings_box' => __('Comments & Pings'),
736 507 'custom_post_settings_box' => __('Custom Post Settings (to apply to each syndicated post)'),
737 508 'custom_post_types_box' => ('Custom Post Types (advanced database settings)'),
738 509 );
739 -
510 +
740 511 parent::display();
741 512 } /* FeedWordPressPostsPage::display () */
742 -
743 -
744 513 }
745 514
746 515 $postsPage = new FeedWordPressPostsPage;
747 516 $postsPage->display();