| @@ -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,97 +27,90 @@ | ||
| 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 | - | |
| 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' ); | |
| 108 | - | |
| 95 | + | |
| 96 | + $sMungePermalink = sanitize_text_field($_REQUEST['munge_permalink']); | |
| 97 | + $sUseAggregatorSourceData = sanitize_text_field($_REQUEST['use_aggregator_source_data']); | |
| 98 | + $sFormattingFilters = sanitize_text_field($_REQUEST['formatting_filters']); | |
| 99 | + $sFeedCommentStatus = (isset($_REQUEST['feed_comment_status']) ? sanitize_text_field($_REQUEST['feed_comment_status']) : ''); | |
| 100 | + $sFeedPingStatus = (isset($_REQUEST['feed_ping_status']) ? sanitize_text_field($_REQUEST['feed_ping_status']) : ''); | |
| 101 | + | |
| 109 | 102 | update_option('feedwordpress_munge_permalink', $sMungePermalink); |
| 110 | 103 | update_option('feedwordpress_use_aggregator_source_data', $sUseAggregatorSourceData); |
| 111 | 104 | update_option('feedwordpress_formatting_filters', $sFormattingFilters); |
| 112 | 105 | |
| 113 | - if ( ! is_null( $sResolveRelative ) ) : | |
| 114 | - update_option('feedwordpress_resolve_relative', $sResolveRelative ); | |
| 106 | + if (isset($post['resolve_relative'])) : | |
| 107 | + update_option('feedwordpress_resolve_relative', $post['resolve_relative']); | |
| 115 | 108 | endif; |
| 116 | - if ( ! is_null( $sMungeCommentsFeedLinks ) ) : | |
| 117 | - update_option('feedwordpress_munge_comments_feed_links', $sMungeCommentsFeedLinks ); | |
| 109 | + if (isset($post['munge_comments_feed_links'])) : | |
| 110 | + update_option('feedwordpress_munge_comments_feed_links', $post['munge_comments_feed_links']); | |
| 118 | 111 | endif; |
| 119 | - | |
| 112 | + | |
| 120 | 113 | if ( $sFeedCommentStatus == 'open' ) : |
| 121 | 114 | update_option('feedwordpress_syndicated_comment_status', 'open'); |
| 122 | 115 | else : |
| 123 | 116 | update_option('feedwordpress_syndicated_comment_status', 'closed'); |
| @@ -127,37 +120,39 @@ | ||
| 127 | 120 | update_option('feedwordpress_syndicated_ping_status', 'open'); |
| 128 | 121 | else : |
| 129 | 122 | update_option('feedwordpress_syndicated_ping_status', 'closed'); |
| 130 | 123 | endif; |
| 131 | - | |
| 132 | - if ( ! is_null( $sSyndicatedPostType ) ) : | |
| 133 | - update_option('feedwordpress_syndicated_post_type', $sSyndicatedPostType ); | |
| 124 | + | |
| 125 | + if (isset($post['syndicated_post_type'])) : | |
| 126 | + update_option('feedwordpress_syndicated_post_type', $post['syndicated_post_type']); | |
| 134 | 127 | endif; |
| 135 | 128 | endif; |
| 136 | 129 | |
| 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; | |
| 130 | + if (isset($post['save']) or isset($post['submit'])) : | |
| 131 | + if (isset($post['boilerplate'])) : | |
| 132 | + foreach ($post['boilerplate'] as $index => $line) : | |
| 133 | + if (0 == strlen(trim($line['template']))) : | |
| 134 | + unset($post['boilerplate'][$index]); | |
| 135 | + endif; | |
| 136 | + endforeach; | |
| 144 | 137 | |
| 145 | - // Convert indexes to 0..(N-1) to avoid possible collisions | |
| 146 | - $boilerplate = array_values( $boilerplate ); | |
| 138 | + // Convert indexes to 0..(N-1) to avoid possible collisions | |
| 139 | + $post['boilerplate'] = array_values($post['boilerplate']); | |
| 147 | 140 | |
| 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 ); | |
| 141 | + if ($this->for_feed_settings()) : | |
| 142 | + $this->link->settings['boilerplate rules'] = serialize($post['boilerplate']); | |
| 143 | + $this->link->save_settings(/*reload=*/ true); | |
| 144 | + else : | |
| 145 | + update_option('feedwordpress_boilerplate', $post['boilerplate']); | |
| 146 | + endif; | |
| 153 | 147 | endif; |
| 148 | + | |
| 149 | + if (isset($post['boilerplate_hook_order'])) : | |
| 150 | + $this->update_setting('boilerplate hook order', intval($post['boilerplate_hook_order'])); | |
| 151 | + endif; | |
| 154 | 152 | endif; |
| 155 | 153 | |
| 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(); | |
| 154 | + parent::save_settings($post); | |
| 160 | 155 | } |
| 161 | 156 | |
| 162 | 157 | /** |
| 163 | 158 | * publication_box: Outputs "Publication" settings box. |
| @@ -169,9 +164,9 @@ | ||
| 169 | 164 | * |
| 170 | 165 | * @uses FeedWordPressPostsPage::these_posts_phrase() |
| 171 | 166 | * @uses FeedWordPress::syndicated_status() |
| 172 | 167 | * @uses SyndicatedLink::syndicated_status() |
| 173 | - */ | |
| 168 | + */ | |
| 174 | 169 | /*static*/ function publication_box ($page, $box = NULL) { |
| 175 | 170 | $thesePosts = $page->these_posts_phrase(); |
| 176 | 171 | $postSelector = array( |
| 177 | 172 | 'publish' => "Publish %s immediately", |
| @@ -183,9 +178,9 @@ | ||
| 183 | 178 | foreach ($postSelector as $index => $value) : |
| 184 | 179 | $postSelector[$index] = sprintf(__($value), $thesePosts); |
| 185 | 180 | $labels[$index] = __(str_replace(' %s', '', strtolower(strtok($value, ';')))); |
| 186 | 181 | endforeach; |
| 187 | - | |
| 182 | + | |
| 188 | 183 | $params = array( |
| 189 | 184 | 'input-name' => 'feed_post_status', |
| 190 | 185 | 'setting-default' => NULL, |
| 191 | 186 | 'global-setting-default' => 'publish', |
| @@ -194,9 +189,9 @@ | ||
| 194 | 189 | |
| 195 | 190 | // Hey ho, let's go... |
| 196 | 191 | ?> |
| 197 | 192 | <table id="syndicated-publication-form" class="edit-form narrow"> |
| 198 | - <tr><th scope="row"><?php esc_html_e('New posts:'); ?></th> | |
| 193 | + <tr><th scope="row"><?php _e('New posts:'); ?></th> | |
| 199 | 194 | <td><?php |
| 200 | 195 | $this->setting_radio_control( |
| 201 | 196 | 'post status', 'syndicated_post_status', |
| 202 | 197 | $postSelector, $params |
| @@ -205,23 +200,23 @@ | ||
| 205 | 200 | </td></tr> |
| 206 | 201 | |
| 207 | 202 | <?php $page->updatedPosts->display(); ?> |
| 208 | 203 | </table> |
| 209 | - | |
| 204 | + | |
| 210 | 205 | <?php |
| 211 | 206 | } /* FeedWordPressPostsPage::publication_box () */ |
| 212 | - | |
| 207 | + | |
| 213 | 208 | /** |
| 214 | 209 | * Outputs "Formatting" settings box |
| 215 | 210 | * |
| 216 | 211 | * @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 | |
| 212 | + * @param object $page of class FeedWordPressPostsPage tells us whether this is | |
| 213 | + * a page for one feed's settings or for global defaults | |
| 219 | 214 | * @param array $box |
| 220 | 215 | * |
| 221 | - */ | |
| 222 | - function formatting_box( $page, $box = NULL ) { | |
| 223 | - $thesePosts = $page->these_posts_phrase(); // result unused, why? (gwyneth 20230920) | |
| 216 | + */ | |
| 217 | + function formatting_box ($page, $box = NULL) { | |
| 218 | + $thesePosts = $page->these_posts_phrase(); | |
| 224 | 219 | |
| 225 | 220 | if ($page->for_feed_settings()) : |
| 226 | 221 | $formatting_filters = null; |
| 227 | 222 | $url = preg_replace('|/+$|', '', $page->link->homepage()); |
| @@ -230,9 +225,9 @@ | ||
| 230 | 225 | $url = 'http://example.com'; |
| 231 | 226 | endif; |
| 232 | 227 | ?> |
| 233 | 228 | <table class="edit-form narrow"> |
| 234 | - <?php if ( !is_null($formatting_filters)) : ?> | |
| 229 | + <?php if (!is_null($formatting_filters)) : ?> | |
| 235 | 230 | |
| 236 | 231 | <tr><th scope="row">Formatting filters:</th> |
| 237 | 232 | <td><select name="formatting_filters" size="1"> |
| 238 | 233 | <option value="no"<?php echo ($formatting_filters!='yes')?' selected="selected"':''; ?>>Protect syndicated posts from formatting filters</option> |
| @@ -244,9 +239,9 @@ | ||
| 244 | 239 | problem.</p> |
| 245 | 240 | </td></tr> |
| 246 | 241 | |
| 247 | 242 | <?php endif; ?> |
| 248 | - | |
| 243 | + | |
| 249 | 244 | <tr><th scope="row">Relative URIs:</th> |
| 250 | 245 | <td><p>If link or image in a syndicated post from <code><?php print esc_html($url); ?></code> |
| 251 | 246 | refers to a partial URI like <code>/about</code>, where should |
| 252 | 247 | the syndicated copy point to?</p> |
| @@ -269,15 +264,15 @@ | ||
| 269 | 264 | $this->setting_radio_control( |
| 270 | 265 | 'resolve relative', 'resolve_relative', |
| 271 | 266 | $options, $params |
| 272 | 267 | ); |
| 273 | - ?> | |
| 268 | + ?> | |
| 274 | 269 | </td></tr> |
| 275 | 270 | |
| 276 | 271 | </table> |
| 277 | 272 | <?php |
| 278 | 273 | } /* FeedWordPressPostsPage::formatting_box() */ |
| 279 | - | |
| 274 | + | |
| 280 | 275 | /** |
| 281 | 276 | * Output "Links" settings box |
| 282 | 277 | * |
| 283 | 278 | * @since 2009.0713 |
| @@ -293,9 +288,9 @@ | ||
| 293 | 288 | 'no' => __('The local copy on this website'), |
| 294 | 289 | ), |
| 295 | 290 | ); |
| 296 | 291 | |
| 297 | - if ( ! $page->for_feed_settings()) : | |
| 292 | + if (!$page->for_feed_settings()) : | |
| 298 | 293 | $use_aggregator_source_data = get_option('feedwordpress_use_aggregator_source_data'); |
| 299 | 294 | endif; |
| 300 | 295 | ?> |
| 301 | 296 | <table class="edit-form narrow"> |
| @@ -300,9 +295,9 @@ | ||
| 300 | 295 | ?> |
| 301 | 296 | <table class="edit-form narrow"> |
| 302 | 297 | <tr><th scope="row">Permalinks point to:</th> |
| 303 | 298 | <td><?php |
| 304 | - | |
| 299 | + | |
| 305 | 300 | $params = array( |
| 306 | 301 | 'setting-default' => 'default', |
| 307 | 302 | 'global-setting-default' => 'yes', |
| 308 | 303 | 'default-input-value' => 'default', |
| @@ -313,10 +308,10 @@ | ||
| 313 | 308 | ); |
| 314 | 309 | ?> |
| 315 | 310 | |
| 316 | 311 | </td></tr> |
| 317 | - | |
| 318 | - <?php if ( ! $page->for_feed_settings()) : ?> | |
| 312 | + | |
| 313 | + <?php if (!$page->for_feed_settings()) : ?> | |
| 319 | 314 | <tr><th scope="row">Posts from aggregator feeds:</th> |
| 320 | 315 | <td><ul class="options"> |
| 321 | 316 | <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 | 317 | <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 +340,9 @@ | ||
| 345 | 340 | 'comment' => array('label' => __('Comments'), 'accept' => 'Allow comments'), |
| 346 | 341 | 'ping' => array('label' => __('Pings'), 'accept' => 'Accept pings'), |
| 347 | 342 | ); |
| 348 | 343 | $onThesePosts = 'on '.$page->these_posts_phrase(); |
| 349 | - | |
| 344 | + | |
| 350 | 345 | $mcflSettings = array( |
| 351 | 346 | "yes" => __('Point to comment feeds from the original website (when provided by the syndicated feed)'), |
| 352 | 347 | "no" => __('Point to local comment feeds on this website'), |
| 353 | 348 | ); |
| @@ -370,9 +365,9 @@ | ||
| 370 | 365 | 'open' => sprintf(__("{$how['accept']} %s"), __($onThesePosts)), |
| 371 | 366 | 'closed' => sprintf(__("Don't ".strtolower($how['accept'])." %s"), __($onThesePosts)), |
| 372 | 367 | ); |
| 373 | 368 | $params[$what] = array( |
| 374 | - 'input-name' => "feed_{$what}_status", | |
| 369 | + 'input-name' => "feed_${what}_status", | |
| 375 | 370 | 'setting-default' => NULL, |
| 376 | 371 | 'global-setting-default' => FeedWordPress::syndicated_status($what, /*default=*/ 'closed'), |
| 377 | 372 | 'labels' => array( |
| 378 | 373 | 'open' => strtolower(__($how['accept'])), |
| @@ -384,20 +379,20 @@ | ||
| 384 | 379 | // Hey ho, let's go... |
| 385 | 380 | ?> |
| 386 | 381 | <table class="edit-form narrow"> |
| 387 | 382 | <?php foreach ($whatsits as $what => $how) : ?> |
| 388 | - | |
| 383 | + | |
| 389 | 384 | <tr><th scope="row"><?php print esc_html($how['label']); ?>:</th> |
| 390 | 385 | <td><?php |
| 391 | 386 | $this->setting_radio_control( |
| 392 | - "$what status", "syndicated_{$what}_status", | |
| 387 | + "$what status", "syndicated_${what}_status", | |
| 393 | 388 | $settings[$what], $params[$what] |
| 394 | 389 | ); |
| 395 | 390 | ?></td></tr> |
| 396 | - | |
| 391 | + | |
| 397 | 392 | <?php endforeach; ?> |
| 398 | - | |
| 399 | - <tr><th scope="row"><?php esc_html_e('Comment feeds'); ?></th> | |
| 393 | + | |
| 394 | + <tr><th scope="row"><?php _e('Comment feeds'); ?></th> | |
| 400 | 395 | <td><p>When WordPress feeds and templates link to comments |
| 401 | 396 | feeds for <?php print esc_html($page->these_posts_phrase()); ?>, the |
| 402 | 397 | URLs for the feeds should...</p> |
| 403 | 398 | <?php |
| @@ -409,9 +404,9 @@ | ||
| 409 | 404 | </table> |
| 410 | 405 | |
| 411 | 406 | <?php |
| 412 | 407 | } /* FeedWordPressPostsPage::comments_and_pings_box() */ |
| 413 | - | |
| 408 | + | |
| 414 | 409 | /*static*/ function custom_post_settings ($page = NULL) { |
| 415 | 410 | if (is_null($page)) : |
| 416 | 411 | $page = $this; |
| 417 | 412 | endif; |
| @@ -424,23 +419,15 @@ | ||
| 424 | 419 | |
| 425 | 420 | if ($custom_settings and !is_array($custom_settings)) : |
| 426 | 421 | $custom_settings = unserialize($custom_settings); |
| 427 | 422 | endif; |
| 428 | - | |
| 429 | - if ( !is_array($custom_settings)) : | |
| 423 | + | |
| 424 | + if (!is_array($custom_settings)) : | |
| 430 | 425 | $custom_settings = array(); |
| 431 | 426 | endif; |
| 432 | 427 | |
| 433 | 428 | return $custom_settings; |
| 434 | 429 | } /* 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 | 430 | |
| 444 | 431 | /** |
| 445 | 432 | * Output "Custom Post Settings" settings box |
| 446 | 433 | * |
| @@ -462,15 +449,18 @@ | ||
| 462 | 449 | </tr> |
| 463 | 450 | |
| 464 | 451 | <?php |
| 465 | 452 | $i = 0; |
| 466 | - foreach ($custom_settings as $key => $value) : | |
| 453 | + $testerButton = '<br/><button id="xpath-test-%d"' | |
| 454 | + .'class="xpath-test"' | |
| 455 | + .'>test expression</button>'; | |
| 456 | + foreach ($custom_settings as $key => $value) : | |
| 467 | 457 | ?> |
| 468 | 458 | <tr style="vertical-align:top"> |
| 469 | 459 | <th width="30%" scope="row"><input type="hidden" name="notes[<?php echo esc_attr($i); ?>][key0]" value="<?php echo esc_html($key); ?>" /> |
| 470 | 460 | <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 | 461 | <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> | |
| 462 | + <?php print sprintf($testerButton, esc_attr($i) ); ?></td> | |
| 473 | 463 | <td width="10%"><select name="notes[<?php echo esc_attr($i); ?>][action]"> |
| 474 | 464 | <option value="update">save changes</option> |
| 475 | 465 | <option value="delete">delete this setting</option> |
| 476 | 466 | </select></td> |
| @@ -482,9 +472,9 @@ | ||
| 482 | 472 | ?> |
| 483 | 473 | |
| 484 | 474 | <tr style="vertical-align: top"> |
| 485 | 475 | <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 ); ?> | |
| 476 | + <td><textarea name="notes[<?php echo esc_attr($i); ?>][value]" rows="2" cols="40"></textarea><?php print sprintf($testerButton, esc_attr($i)); ?> | |
| 487 | 477 | <p>Enter a text value, or a path to a data element from the syndicated item.<br/> |
| 488 | 478 | For data elements, you can use an XPath-like syntax wrapped in <code>$( ... )</code>.<br/> |
| 489 | 479 | <code>hello</code> = the text value <code><span style="background-color: #30FFA0;">hello</span></code><br/> |
| 490 | 480 | <code>$(author/email)</code> = the contents of <code><author><email><span style="background-color: #30FFA0">...</span></email></author></code><br/> |
| @@ -498,12 +488,14 @@ | ||
| 498 | 488 | <?php |
| 499 | 489 | } /* FeedWordPressPostsPage::custom_post_settings_box() */ |
| 500 | 490 | |
| 501 | 491 | function custom_post_types_box ($page, $box = NULL) { |
| 502 | - // local: syndicated post type // default NULL | |
| 492 | + global $fwp_path; | |
| 493 | + | |
| 494 | + // local: syndicated post type // default NULL | |
| 503 | 495 | // global: syndicated_post_type // default 'post' |
| 504 | 496 | // default-input-value => 'default' |
| 505 | - | |
| 497 | + | |
| 506 | 498 | // Get all custom post types |
| 507 | 499 | $post_types = get_post_types(array( |
| 508 | 500 | '_builtin' => false, |
| 509 | 501 | ), 'objects'); |
| @@ -512,19 +504,19 @@ | ||
| 512 | 504 | $ul['post'] = __('Normal WordPress posts'); |
| 513 | 505 | foreach ($post_types as $post_type) : |
| 514 | 506 | $ul[$post_type->name] = __($post_type->labels->name); |
| 515 | 507 | endforeach; |
| 516 | - | |
| 508 | + | |
| 517 | 509 | $params = array( |
| 518 | 510 | 'global-setting-default' => 'post', |
| 519 | 511 | 'default-input-value' => 'default', |
| 520 | 512 | ); |
| 521 | - | |
| 513 | + | |
| 522 | 514 | // Hey, ho, let's go... |
| 523 | 515 | ?> |
| 524 | 516 | <table class="edit-form narrow"> |
| 525 | 517 | <tbody> |
| 526 | - <tr><th><?php esc_html_e('Custom Post Types:'); ?></th> | |
| 518 | + <tr><th><?php _e('Custom Post Types:'); ?></th> | |
| 527 | 519 | <td><p>Incoming syndicated posts should be stored in the |
| 528 | 520 | posts database as...</p> |
| 529 | 521 | <?php |
| 530 | 522 | $this->setting_radio_control( |
| @@ -536,9 +528,9 @@ | ||
| 536 | 528 | </tbody> |
| 537 | 529 | </table> |
| 538 | 530 | <?php |
| 539 | 531 | } /* FeedWordPressPostsPage::custom_post_types_box() */ |
| 540 | - | |
| 532 | + | |
| 541 | 533 | public function boilerplate_box ($page, $box = NULL) { |
| 542 | 534 | if ($page->for_feed_settings()) : |
| 543 | 535 | $attrib = isset($page->link->settings['boilerplate rules']) |
| 544 | 536 | ? unserialize($page->link->settings['boilerplate rules']) |
| @@ -549,9 +541,9 @@ | ||
| 549 | 541 | $syndicatedPosts = 'syndicated posts'; |
| 550 | 542 | endif; |
| 551 | 543 | $hookOrder = intval($page->setting('boilerplate hook order', FEEDWORDPRESS_BOILERPLATE_DEFAULT_HOOK_ORDER)); |
| 552 | 544 | ?> |
| 553 | - <style type="text/css"> | |
| 545 | + <style type="text/css"> | |
| 554 | 546 | .boilerplate-help-box { |
| 555 | 547 | float: right; |
| 556 | 548 | width: 300px; |
| 557 | 549 | border: 1px dotted #777; |
| @@ -577,9 +569,9 @@ | ||
| 577 | 569 | padding-bottom: 5px; |
| 578 | 570 | margin-bottom: 5px; |
| 579 | 571 | border-bottom: 1px dotted black; |
| 580 | 572 | } |
| 581 | - | |
| 573 | + | |
| 582 | 574 | </style> |
| 583 | 575 | |
| 584 | 576 | <div class="boilerplate-help-box"> |
| 585 | 577 | <p style="border-bottom: 1px dotted #777;">To remove boilerplate, just blank out the text box and leave it empty.</p> |
| @@ -597,9 +589,9 @@ | ||
| 597 | 589 | |
| 598 | 590 | <dt><code>[original-link]text[/original-link]</code></dt> |
| 599 | 591 | <dd>A link to the <em>original post</em> back on the source website, |
| 600 | 592 | using <code>text</code> as the link text.</dd> |
| 601 | - | |
| 593 | + | |
| 602 | 594 | <dt><code>[original-url]</code></dt> |
| 603 | 595 | <dd>URL of the <em>original post</em> back on the source website</dd> |
| 604 | 596 | |
| 605 | 597 | <dt><code>[author]</code></dt> |
| @@ -606,9 +598,9 @@ | ||
| 606 | 598 | <dd>A link with the name of the author who wrote the post, linking to other posts by the same author</dd> |
| 607 | 599 | |
| 608 | 600 | <dt><code>[author-name]</code></dt> |
| 609 | 601 | <dd>Name of the author who wrote the post</dd> |
| 610 | - | |
| 602 | + | |
| 611 | 603 | <dt><code>[feed-setting key="setting-name"]</code></dt> |
| 612 | 604 | <dd>Value of a custom feed setting (named <code>setting-name</code>) for the feed</dd> |
| 613 | 605 | </dl> |
| 614 | 606 | </div> |
| @@ -614,9 +606,9 @@ | ||
| 614 | 606 | </div> |
| 615 | 607 | |
| 616 | 608 | <?php |
| 617 | 609 | print "<ul>\n"; |
| 618 | - if ( !is_array($attrib)) : $attrib = array(); endif; | |
| 610 | + if (!is_array($attrib)) : $attrib = array(); endif; | |
| 619 | 611 | |
| 620 | 612 | print '<input type="hidden" id="next-boilerplate-rule-index" name="next_boilerplate_rule_index" value="'.count($attrib).'" />'; |
| 621 | 613 | |
| 622 | 614 | // In AJAX environment, this is a dummy rule that stays hidden. In a |
| @@ -635,9 +627,9 @@ | ||
| 635 | 627 | $selected['title'] = (($line['element']=='title') ? ' selected="selected"' : ''); |
| 636 | 628 | $selected['post'] = (($line['element']=='post') ? ' selected="selected"' : ''); |
| 637 | 629 | $selected['excerpt'] = (($line['element']=='excerpt') ? ' selected="selected"' : ''); |
| 638 | 630 | |
| 639 | - if ( !isset($line['class'])) : $line['class'] = array(); endif; | |
| 631 | + if (!isset($line['class'])) : $line['class'] = array(); endif; | |
| 640 | 632 | $line['class'][] = 'boilerplate-li'; |
| 641 | 633 | ?> |
| 642 | 634 | |
| 643 | 635 | <li id="boilerplate-<?php print esc_attr($index); ?>-li" class="<?php print esc_attr(implode(' ', $line['class'])); ?>">» <strong>Add</strong> <select id="boilerplate-<?php print esc_attr($index); ?>-placement" name="boilerplate[<?php print esc_attr($index); ?>][placement]" style="width: 8.0em"> |
| @@ -646,9 +638,9 @@ | ||
| 646 | 638 | </select> the <select style="width: 8.0em" id="boilerplate-<?php print esc_attr($index); ?>-element" name="boilerplate[<?php print esc_attr($index); ?>][element]"> |
| 647 | 639 | <option value="title"<?php fwp_selected_flag($selected, 'title' ); ?>>title</option> |
| 648 | 640 | <option value="post"<?php fwp_selected_flag( $selected, 'post' ); ?>>content</option> |
| 649 | 641 | <option value="excerpt"<?php fwp_selected_flag( $selected, 'excerpt' ); ?>>excerpt</option> |
| 650 | -</select> of | |
| 642 | +</select> of | |
| 651 | 643 | <?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 | 644 | <?php |
| 653 | 645 | endif; |
| 654 | 646 | endforeach; |
| @@ -689,9 +681,9 @@ | ||
| 689 | 681 | }; |
| 690 | 682 | dummy[element]['el'].attr('id', newIdPrefix+'-'+element); |
| 691 | 683 | dummy[element]['el'].attr('name', newNamePrefix+'['+element+']'); |
| 692 | 684 | } |
| 693 | - | |
| 685 | + | |
| 694 | 686 | var newLi = $('#'+newIdPrefix+'-li').clone(/*events=*/ true); |
| 695 | 687 | //newLi.attr('id', null); |
| 696 | 688 | newLi.removeClass('hide-if-js'); |
| 697 | 689 | newLi.addClass('boilerplate-li'); |
| @@ -717,9 +709,9 @@ | ||
| 717 | 709 | ?> |
| 718 | 710 | <h3>Advanced Settings</h3> |
| 719 | 711 | <table class="edit-form narrow"> |
| 720 | 712 | <tbody> |
| 721 | - <tr><th scope="row"><?php esc_html_e("Hook Order:") ?></th> | |
| 713 | + <tr><th scope="row"><?php _e("Hook Order:") ?></th> | |
| 722 | 714 | <td><input type="number" name="boilerplate_hook_order" value="<?php print esc_attr($hookOrder); ?>" /></td></tr> |
| 723 | 715 | </tbody> |
| 724 | 716 | </table> |
| 725 | 717 | <?php |
| @@ -735,9 +727,9 @@ | ||
| 735 | 727 | 'comments_and_pings_box' => __('Comments & Pings'), |
| 736 | 728 | 'custom_post_settings_box' => __('Custom Post Settings (to apply to each syndicated post)'), |
| 737 | 729 | 'custom_post_types_box' => ('Custom Post Types (advanced database settings)'), |
| 738 | 730 | ); |
| 739 | - | |
| 731 | + | |
| 740 | 732 | parent::display(); |
| 741 | 733 | } /* FeedWordPressPostsPage::display () */ |
| 742 | 734 | |
| 743 | 735 | |