| @@ -10,158 +10,113 @@ | ||
| 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 | - public function __construct( $link = -1 ) { | |
| 15 | - if (is_numeric($link) and -1 == $link) : | |
| 16 | - $link = $this->submitted_link(); | |
| 17 | - endif; | |
| 18 | - | |
| 19 | - parent::__construct('feedwordpresspostspage', $link); | |
| 20 | - $this->dispatch = 'feedwordpress_admin_page_posts'; | |
| 14 | + function FeedWordPressPostsPage ($link = NULL) { | |
| 15 | + FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpresspostspage', $link); | |
| 16 | + $this->dispatch = 'feedwordpress_posts_settings'; | |
| 21 | 17 | $this->filename = __FILE__; |
| 22 | 18 | $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 | - ); | |
| 29 | 19 | } /* FeedWordPressPostsPage constructor */ |
| 30 | 20 | |
| 31 | - function save_settings () { | |
| 32 | - // custom post settings | |
| 33 | - $custom_settings = $this->custom_post_settings(); | |
| 21 | + function accept_POST ($post) { | |
| 22 | + global $wpdb; | |
| 34 | 23 | |
| 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 | |
| 41 | - endif; | |
| 42 | - endif; | |
| 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(); | |
| 43 | 28 | |
| 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 | |
| 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 | |
| 49 | 35 | endif; |
| 50 | - endif; | |
| 51 | - endforeach; | |
| 52 | - | |
| 53 | - $this->updatedPosts->accept_POST(); | |
| 54 | - if ($this->for_feed_settings()) : | |
| 55 | - // $alter = array(); // this appears elsewhere, too, also unused, and possibly removed as well (gwyneth 20230920) | |
| 56 | - | |
| 57 | - $this->link->settings['postmeta'] = serialize($custom_settings); | |
| 58 | - | |
| 59 | - if ( ! is_null( FeedWordPress::post( 'resolve_relative', null ) ) ) : | |
| 60 | - $this->link->settings['resolve relative'] = FeedWordPress::post( 'resolve_relative', null, 'text' ); | |
| 61 | - endif; | |
| 62 | - if ( ! is_null( FeedWordPress::post('munge_permalink', null, 'text' ) ) ) : | |
| 63 | - $this->link->settings['munge permalink'] = FeedWordPress::post( 'munge_permalink', null, 'text' ); | |
| 64 | - 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' ); | |
| 67 | - endif; | |
| 68 | - | |
| 69 | - // Post status, comment status, ping status | |
| 70 | - foreach (array('post', 'comment', 'ping') as $what) : | |
| 71 | - $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 ]); | |
| 76 | - else : | |
| 77 | - $this->link->settings[ $afield ] = FeedWordPress::post( $sfield, null, 'text' ); | |
| 78 | - endif; | |
| 36 | + | |
| 37 | + if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) : | |
| 38 | + $custom_settings[$mn['key1']] = $mn['value']; // in with the new | |
| 79 | 39 | endif; |
| 80 | 40 | endforeach; |
| 81 | - | |
| 82 | - if ( ! is_null( FeedWordPress::post('syndicated_post_type', null, 'text' ) ) ) : | |
| 83 | - if ( FeedWordPress::post( 'syndicated_post_type', null, 'text' ) == 'default' ) : | |
| 84 | - unset($this->link->settings['syndicated post type']); | |
| 85 | - else : | |
| 86 | - $this->link->settings['syndicated post type'] = FeedWordPress::post( 'syndicated_post_type', null, 'text' ); | |
| 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']; | |
| 87 | 50 | endif; |
| 88 | - 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; | |
| 89 | 57 | |
| 90 | - else : | |
| 91 | - // update_option ... | |
| 92 | - if ( ! is_null( FeedWordPress::post( 'feed_post_status', null ) ) ) : | |
| 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; | |
| 93 | 69 | |
| 94 | - update_option('feedwordpress_syndicated_post_status', FeedWordPress::post( 'feed_post_status', null, 'text' ) ); | |
| 70 | + // Save settings | |
| 71 | + $this->link->save_settings(/*reload=*/ true); | |
| 72 | + $this->updated = true; | |
| 95 | 73 | |
| 96 | - endif; | |
| 97 | - | |
| 98 | - 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 | - | |
| 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 ); | |
| 115 | - endif; | |
| 116 | - if ( ! is_null( $sMungeCommentsFeedLinks ) ) : | |
| 117 | - update_option('feedwordpress_munge_comments_feed_links', $sMungeCommentsFeedLinks ); | |
| 118 | - endif; | |
| 119 | - | |
| 120 | - if ( $sFeedCommentStatus == 'open' ) : | |
| 121 | - update_option('feedwordpress_syndicated_comment_status', 'open'); | |
| 74 | + // Reset, reload | |
| 75 | + $link_id = $this->link->id; | |
| 76 | + unset($this->link); | |
| 77 | + $this->link = new SyndicatedLink($link_id); | |
| 122 | 78 | else : |
| 123 | - update_option('feedwordpress_syndicated_comment_status', 'closed'); | |
| 124 | - endif; | |
| 79 | + // update_option ... | |
| 80 | + if (isset($post['feed_post_status'])) : | |
| 81 | + update_option('feedwordpress_syndicated_post_status', $post['feed_post_status']); | |
| 82 | + endif; | |
| 125 | 83 | |
| 126 | - if ( $sFeedPingStatus == 'open' ) : | |
| 127 | - update_option('feedwordpress_syndicated_ping_status', 'open'); | |
| 128 | - else : | |
| 129 | - update_option('feedwordpress_syndicated_ping_status', 'closed'); | |
| 130 | - endif; | |
| 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; | |
| 131 | 101 | |
| 132 | - if ( ! is_null( $sSyndicatedPostType ) ) : | |
| 133 | - update_option('feedwordpress_syndicated_post_type', $sSyndicatedPostType ); | |
| 134 | - endif; | |
| 135 | - 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] ); | |
| 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'); | |
| 142 | 106 | 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 ); | |
| 107 | + | |
| 108 | + $this->updated = true; | |
| 153 | 109 | endif; |
| 154 | - endif; | |
| 155 | 110 | |
| 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(); | |
| 111 | + // Probably a "Go" button for the drop-down | |
| 112 | + else : | |
| 113 | + $this->updated = false; | |
| 114 | + endif; | |
| 160 | 115 | } |
| 161 | 116 | |
| 162 | 117 | /** |
| 163 | - * publication_box: Outputs "Publication" settings box. | |
| 118 | + * Outputs "Publication" settings box. | |
| 164 | 119 | * |
| 165 | 120 | * @since 2009.0713 |
| 166 | 121 | * @param object $page of class FeedWordPressPostsPage tells us whether this is |
| 167 | 122 | * a page for one feed's settings or for global defaults |
| @@ -169,70 +124,108 @@ | ||
| 169 | 124 | * |
| 170 | 125 | * @uses FeedWordPressPostsPage::these_posts_phrase() |
| 171 | 126 | * @uses FeedWordPress::syndicated_status() |
| 172 | 127 | * @uses SyndicatedLink::syndicated_status() |
| 173 | - */ | |
| 128 | + * @uses SyndicatedPost::use_api() | |
| 129 | + */ | |
| 174 | 130 | /*static*/ function publication_box ($page, $box = NULL) { |
| 131 | + global $fwp_path; | |
| 132 | + | |
| 133 | + $post_status_global = FeedWordPress::syndicated_status('post', /*default=*/ 'publish'); | |
| 175 | 134 | $thesePosts = $page->these_posts_phrase(); |
| 176 | - $postSelector = array( | |
| 177 | - 'publish' => "Publish %s immediately", | |
| 178 | - 'pending' => "Hold %s for review; mark as Pending", | |
| 179 | - 'draft' => "Save %s as drafts", | |
| 180 | - 'private' => "Save %s as private posts", | |
| 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' => ''), | |
| 181 | 141 | ); |
| 182 | - $labels = array(); | |
| 183 | - foreach ($postSelector as $index => $value) : | |
| 184 | - $postSelector[$index] = sprintf(__($value), $thesePosts); | |
| 185 | - $labels[$index] = __(str_replace(' %s', '', strtolower(strtok($value, ';')))); | |
| 186 | - endforeach; | |
| 142 | + if (SyndicatedPost::use_api('post_status_pending')) : | |
| 143 | + $setting['pending'] = array('label' => "Hold %s for review; mark as Pending", 'checked' => ''); | |
| 144 | + endif; | |
| 187 | 145 | |
| 188 | - $params = array( | |
| 189 | - 'input-name' => 'feed_post_status', | |
| 190 | - 'setting-default' => NULL, | |
| 191 | - 'global-setting-default' => 'publish', | |
| 192 | - 'labels' => $labels, | |
| 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', | |
| 193 | 166 | ); |
| 194 | - | |
| 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 | + | |
| 195 | 174 | // Hey ho, let's go... |
| 196 | 175 | ?> |
| 197 | - <table id="syndicated-publication-form" class="edit-form narrow"> | |
| 198 | - <tr><th scope="row"><?php esc_html_e('New posts:'); ?></th> | |
| 199 | - <td><?php | |
| 200 | - $this->setting_radio_control( | |
| 201 | - 'post status', 'syndicated_post_status', | |
| 202 | - $postSelector, $params | |
| 203 | - ); | |
| 204 | - ?> | |
| 205 | - </td></tr> | |
| 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"> | |
| 182 | + <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> | |
| 206 | 191 | |
| 207 | 192 | <?php $page->updatedPosts->display(); ?> |
| 208 | 193 | </table> |
| 209 | - | |
| 194 | + | |
| 210 | 195 | <?php |
| 211 | 196 | } /* FeedWordPressPostsPage::publication_box () */ |
| 212 | - | |
| 197 | + | |
| 213 | 198 | /** |
| 214 | 199 | * Outputs "Formatting" settings box |
| 215 | 200 | * |
| 216 | 201 | * @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 | |
| 202 | + * @param object $page of class FeedWordPressPostsPage tells us whether this is | |
| 203 | + * a page for one feed's settings or for global defaults | |
| 219 | 204 | * @param array $box |
| 220 | 205 | * |
| 221 | - */ | |
| 222 | - function formatting_box( $page, $box = NULL ) { | |
| 223 | - $thesePosts = $page->these_posts_phrase(); // result unused, why? (gwyneth 20230920) | |
| 224 | - | |
| 206 | + */ | |
| 207 | + 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'); | |
| 225 | 211 | if ($page->for_feed_settings()) : |
| 226 | 212 | $formatting_filters = null; |
| 213 | + $resolve_relative = $page->link->setting('resolve relative', NULL, 'default'); | |
| 227 | 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__); | |
| 228 | 220 | else : |
| 229 | 221 | $formatting_filters = get_option('feedwordpress_formatting_filters', 'no'); |
| 222 | + $resolve_relative = $global_resolve_relative; | |
| 230 | 223 | $url = 'http://example.com'; |
| 231 | 224 | endif; |
| 232 | 225 | ?> |
| 233 | - <table class="edit-form narrow"> | |
| 234 | - <?php if ( !is_null($formatting_filters)) : ?> | |
| 226 | + <table class="form-table" cellspacing="2" cellpadding="5"> | |
| 227 | + <?php if (!is_null($formatting_filters)) : ?> | |
| 235 | 228 | |
| 236 | 229 | <tr><th scope="row">Formatting filters:</th> |
| 237 | 230 | <td><select name="formatting_filters" size="1"> |
| 238 | 231 | <option value="no"<?php echo ($formatting_filters!='yes')?' selected="selected"':''; ?>>Protect syndicated posts from formatting filters</option> |
| @@ -244,40 +237,30 @@ | ||
| 244 | 237 | problem.</p> |
| 245 | 238 | </td></tr> |
| 246 | 239 | |
| 247 | 240 | <?php endif; ?> |
| 248 | - | |
| 241 | + | |
| 249 | 242 | <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> | |
| 243 | + <td>If link or image in a syndicated post from <code><?php print $url; ?></code> | |
| 251 | 244 | refers to a partial URI like <code>/about</code>, where should |
| 252 | 245 | the syndicated copy point to?</p> |
| 253 | 246 | |
| 254 | - <?php | |
| 255 | - $options = array( | |
| 256 | - '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>', | |
| 257 | - '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>', | |
| 258 | - ); | |
| 259 | - $params = array( | |
| 260 | - 'setting-default' => 'default', | |
| 261 | - 'global-setting-default' => 'yes', | |
| 262 | - 'labels' => array( | |
| 263 | - 'yes' => __('resolve relative URIs'), | |
| 264 | - 'no' => __('leave relative URIs unresolved'), | |
| 265 | - ), | |
| 266 | - 'default-input-value' => 'default', | |
| 267 | - ); | |
| 268 | - | |
| 269 | - $this->setting_radio_control( | |
| 270 | - 'resolve relative', 'resolve_relative', | |
| 271 | - $options, $params | |
| 272 | - ); | |
| 273 | - ?> | |
| 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> | |
| 274 | 257 | </td></tr> |
| 275 | 258 | |
| 276 | 259 | </table> |
| 277 | 260 | <?php |
| 278 | 261 | } /* FeedWordPressPostsPage::formatting_box() */ |
| 279 | - | |
| 262 | + | |
| 280 | 263 | /** |
| 281 | 264 | * Output "Links" settings box |
| 282 | 265 | * |
| 283 | 266 | * @since 2009.0713 |
| @@ -288,35 +271,34 @@ | ||
| 288 | 271 | */ |
| 289 | 272 | /*static*/ function links_box ($page, $box = NULL) { |
| 290 | 273 | $setting = array( |
| 291 | 274 | 'munge_permalink' => array( |
| 292 | - 'yes' => __('The copy on the original website'), | |
| 293 | - 'no' => __('The local copy on this website'), | |
| 275 | + 'yes' => 'the copy on the original website', | |
| 276 | + 'no' => 'the local copy on this website', | |
| 294 | 277 | ), |
| 295 | 278 | ); |
| 296 | 279 | |
| 297 | - if ( ! $page->for_feed_settings()) : | |
| 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; | |
| 298 | 285 | $use_aggregator_source_data = get_option('feedwordpress_use_aggregator_source_data'); |
| 299 | 286 | endif; |
| 287 | + | |
| 300 | 288 | ?> |
| 301 | - <table class="edit-form narrow"> | |
| 289 | + <table class="form-table" cellspacing="2" cellpadding="5"> | |
| 302 | 290 | <tr><th scope="row">Permalinks point to:</th> |
| 303 | - <td><?php | |
| 304 | - | |
| 305 | - $params = array( | |
| 306 | - 'setting-default' => 'default', | |
| 307 | - 'global-setting-default' => 'yes', | |
| 308 | - 'default-input-value' => 'default', | |
| 309 | - ); | |
| 310 | - $this->setting_radio_control( | |
| 311 | - 'munge permalink', 'munge_permalink', | |
| 312 | - $setting['munge_permalink'], $params | |
| 313 | - ); | |
| 314 | - ?> | |
| 315 | - | |
| 316 | - </td></tr> | |
| 317 | - | |
| 318 | - <?php if ( ! $page->for_feed_settings()) : ?> | |
| 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> | |
| 299 | + | |
| 300 | + <?php if (!$page->for_feed_settings()) : ?> | |
| 319 | 301 | <tr><th scope="row">Posts from aggregator feeds:</th> |
| 320 | 302 | <td><ul class="options"> |
| 321 | 303 | <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 | 304 | <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> |
| @@ -340,8 +322,13 @@ | ||
| 340 | 322 | * @param array $box |
| 341 | 323 | * |
| 342 | 324 | */ |
| 343 | 325 | /*static*/ function comments_and_pings_box ($page, $box = NULL) { |
| 326 | + global $fwp_path; | |
| 327 | + | |
| 328 | + $setting = array(); | |
| 329 | + $selector = array(); | |
| 330 | + | |
| 344 | 331 | $whatsits = array( |
| 345 | 332 | 'comment' => array('label' => __('Comments'), 'accept' => 'Allow comments'), |
| 346 | 333 | 'ping' => array('label' => __('Pings'), 'accept' => 'Accept pings'), |
| 347 | 334 | ); |
| @@ -346,72 +333,89 @@ | ||
| 346 | 333 | 'ping' => array('label' => __('Pings'), 'accept' => 'Accept pings'), |
| 347 | 334 | ); |
| 348 | 335 | $onThesePosts = 'on '.$page->these_posts_phrase(); |
| 349 | 336 | |
| 350 | - $mcflSettings = array( | |
| 351 | - "yes" => __('Point to comment feeds from the original website (when provided by the syndicated feed)'), | |
| 352 | - "no" => __('Point to local comment feeds on this website'), | |
| 337 | + $selected = array( | |
| 338 | + 'munge_comments_feed_links' => array('yes' => '', 'no' => '') | |
| 353 | 339 | ); |
| 354 | - $mcflParams = array( | |
| 355 | - 'setting-default' => 'default', | |
| 356 | - 'global-setting-default' => 'yes', | |
| 357 | - 'labels' => array( | |
| 358 | - 'yes' => __('comment feeds from the original website'), | |
| 359 | - 'no' => __('local comment feeds on this website') | |
| 360 | - ), | |
| 361 | - 'default-input-value' => 'default', | |
| 362 | - ); | |
| 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; | |
| 363 | 354 | |
| 364 | - $settings = array(); $params = array(); | |
| 365 | 355 | foreach ($whatsits as $what => $how) : |
| 366 | 356 | $whatsits[$what]['default'] = FeedWordPress::syndicated_status($what, /*default=*/ 'closed'); |
| 367 | 357 | |
| 368 | 358 | // Set up array for selector |
| 369 | - $settings[$what] = array( | |
| 370 | - 'open' => sprintf(__("{$how['accept']} %s"), __($onThesePosts)), | |
| 371 | - 'closed' => sprintf(__("Don't ".strtolower($how['accept'])." %s"), __($onThesePosts)), | |
| 359 | + $setting = array( | |
| 360 | + 'open' => array ('label' => "{$how['accept']} %s", 'checked' => ''), | |
| 361 | + 'closed' => array('label' => "Don't ".strtolower($how['accept'])." %s", 'checked' => ''), | |
| 372 | 362 | ); |
| 373 | - $params[$what] = array( | |
| 374 | - 'input-name' => "feed_{$what}_status", | |
| 375 | - 'setting-default' => NULL, | |
| 376 | - 'global-setting-default' => FeedWordPress::syndicated_status($what, /*default=*/ 'closed'), | |
| 377 | - 'labels' => array( | |
| 378 | - 'open' => strtolower(__($how['accept'])), | |
| 379 | - 'closed' => strtolower(__("Don't ".$how['accept'])), | |
| 380 | - ), | |
| 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', | |
| 381 | 380 | ); |
| 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"'; | |
| 382 | 387 | endforeach; |
| 383 | 388 | |
| 384 | 389 | // Hey ho, let's go... |
| 385 | 390 | ?> |
| 386 | - <table class="edit-form narrow"> | |
| 391 | + <table class="form-table" cellspacing="2" cellpadding="5"> | |
| 387 | 392 | <?php foreach ($whatsits as $what => $how) : ?> |
| 388 | - | |
| 389 | - <tr><th scope="row"><?php print esc_html($how['label']); ?>:</th> | |
| 390 | - <td><?php | |
| 391 | - $this->setting_radio_control( | |
| 392 | - "$what status", "syndicated_{$what}_status", | |
| 393 | - $settings[$what], $params[$what] | |
| 394 | - ); | |
| 395 | - ?></td></tr> | |
| 396 | - | |
| 393 | + <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> | |
| 397 | 401 | <?php endforeach; ?> |
| 398 | - | |
| 399 | - <tr><th scope="row"><?php esc_html_e('Comment feeds'); ?></th> | |
| 402 | + <tr><th scope="row"><?php _e('Comment feeds'); ?></th> | |
| 400 | 403 | <td><p>When WordPress feeds and templates link to comments |
| 401 | - feeds for <?php print esc_html($page->these_posts_phrase()); ?>, the | |
| 404 | + feeds for <?php print $page->these_posts_phrase(); ?>, the | |
| 402 | 405 | URLs for the feeds should...</p> |
| 403 | - <?php | |
| 404 | - $this->setting_radio_control( | |
| 405 | - "munge comments feed links", "munge_comments_feed_links", | |
| 406 | - $mcflSettings, $mcflParams | |
| 407 | - ); | |
| 408 | - ?></td></tr> | |
| 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> | |
| 409 | 413 | </table> |
| 410 | 414 | |
| 411 | 415 | <?php |
| 412 | 416 | } /* FeedWordPressPostsPage::comments_and_pings_box() */ |
| 413 | - | |
| 417 | + | |
| 414 | 418 | /*static*/ function custom_post_settings ($page = NULL) { |
| 415 | 419 | if (is_null($page)) : |
| 416 | 420 | $page = $this; |
| 417 | 421 | endif; |
| @@ -416,9 +420,9 @@ | ||
| 416 | 420 | $page = $this; |
| 417 | 421 | endif; |
| 418 | 422 | |
| 419 | 423 | if ($page->for_feed_settings()) : |
| 420 | - $custom_settings = $page->link->setting("postmeta", NULL, array()); | |
| 424 | + $custom_settings = $page->link->settings["postmeta"]; | |
| 421 | 425 | else : |
| 422 | 426 | $custom_settings = get_option('feedwordpress_custom_settings'); |
| 423 | 427 | endif; |
| 424 | 428 | |
| @@ -424,23 +428,15 @@ | ||
| 424 | 428 | |
| 425 | 429 | if ($custom_settings and !is_array($custom_settings)) : |
| 426 | 430 | $custom_settings = unserialize($custom_settings); |
| 427 | 431 | endif; |
| 428 | - | |
| 429 | - if ( !is_array($custom_settings)) : | |
| 432 | + | |
| 433 | + if (!is_array($custom_settings)) : | |
| 430 | 434 | $custom_settings = array(); |
| 431 | 435 | endif; |
| 432 | 436 | |
| 433 | 437 | return $custom_settings; |
| 434 | 438 | } /* 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 | 439 | |
| 444 | 440 | /** |
| 445 | 441 | * Output "Custom Post Settings" settings box |
| 446 | 442 | * |
| @@ -465,13 +461,12 @@ | ||
| 465 | 461 | $i = 0; |
| 466 | 462 | foreach ($custom_settings as $key => $value) : |
| 467 | 463 | ?> |
| 468 | 464 | <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]"> | |
| 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> | |
| 468 | + <td width="10%"><select name="notes[<?php echo $i; ?>][action]"> | |
| 474 | 469 | <option value="update">save changes</option> |
| 475 | 470 | <option value="delete">delete this setting</option> |
| 476 | 471 | </select></td> |
| 477 | 472 | </tr> |
| @@ -481,10 +476,10 @@ | ||
| 481 | 476 | endforeach; |
| 482 | 477 | ?> |
| 483 | 478 | |
| 484 | 479 | <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 ); ?> | |
| 480 | + <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> | |
| 487 | 482 | <p>Enter a text value, or a path to a data element from the syndicated item.<br/> |
| 488 | 483 | For data elements, you can use an XPath-like syntax wrapped in <code>$( ... )</code>.<br/> |
| 489 | 484 | <code>hello</code> = the text value <code><span style="background-color: #30FFA0;">hello</span></code><br/> |
| 490 | 485 | <code>$(author/email)</code> = the contents of <code><author><email><span style="background-color: #30FFA0">...</span></email></author></code><br/> |
| @@ -489,260 +484,89 @@ | ||
| 489 | 484 | <code>hello</code> = the text value <code><span style="background-color: #30FFA0;">hello</span></code><br/> |
| 490 | 485 | <code>$(author/email)</code> = the contents of <code><author><email><span style="background-color: #30FFA0">...</span></email></author></code><br/> |
| 491 | 486 | <code>$(media:content/@url)</code> = the contents of <code><media:content url="<span style="background-color: #30FFA0">...</span>">...</media:content></code></p> |
| 492 | 487 | </td> |
| 493 | - <td><em>add new setting...</em><input type="hidden" name="notes[<?php echo esc_attr($i); ?>][action]" value="update" /></td> | |
| 488 | + <td><em>add new setting...</em><input type="hidden" name="notes[<?php echo $i; ?>][action]" value="update" /></td> | |
| 494 | 489 | </tr> |
| 495 | 490 | </table> |
| 496 | 491 | </div> <!-- id="postcustomstuff" --> |
| 497 | 492 | |
| 498 | 493 | <?php |
| 499 | - } /* FeedWordPressPostsPage::custom_post_settings_box() */ | |
| 494 | + } /* FeedWordPressPostsPage::custom_post_settings_box() */ | |
| 495 | +} | |
| 500 | 496 | |
| 501 | - function custom_post_types_box ($page, $box = NULL) { | |
| 502 | - // local: syndicated post type // default NULL | |
| 503 | - // global: syndicated_post_type // default 'post' | |
| 504 | - // default-input-value => 'default' | |
| 497 | +function fwp_posts_page () { | |
| 498 | + global $wpdb, $wp_db_version; | |
| 499 | + global $fwp_post; | |
| 505 | 500 | |
| 506 | - // Get all custom post types | |
| 507 | - $post_types = get_post_types(array( | |
| 508 | - '_builtin' => false, | |
| 509 | - ), 'objects'); | |
| 501 | + if (FeedWordPress::needs_upgrade()) : | |
| 502 | + fwp_upgrade_page(); | |
| 503 | + return; | |
| 504 | + endif; | |
| 510 | 505 | |
| 511 | - $ul = array(); | |
| 512 | - $ul['post'] = __('Normal WordPress posts'); | |
| 513 | - foreach ($post_types as $post_type) : | |
| 514 | - $ul[$post_type->name] = __($post_type->labels->name); | |
| 515 | - endforeach; | |
| 506 | + // If this is a POST, validate source and user credentials | |
| 507 | + FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_posts_settings', /*capability=*/ 'manage_links'); | |
| 516 | 508 | |
| 517 | - $params = array( | |
| 518 | - 'global-setting-default' => 'post', | |
| 519 | - 'default-input-value' => 'default', | |
| 520 | - ); | |
| 509 | + $link = FeedWordPressAdminPage::submitted_link(); | |
| 521 | 510 | |
| 522 | - // Hey, ho, let's go... | |
| 523 | - ?> | |
| 524 | - <table class="edit-form narrow"> | |
| 525 | - <tbody> | |
| 526 | - <tr><th><?php esc_html_e('Custom Post Types:'); ?></th> | |
| 527 | - <td><p>Incoming syndicated posts should be stored in the | |
| 528 | - posts database as...</p> | |
| 529 | - <?php | |
| 530 | - $this->setting_radio_control( | |
| 531 | - 'syndicated post type', 'syndicated_post_type', | |
| 532 | - $ul, $params | |
| 533 | - ); | |
| 534 | - ?> | |
| 535 | - </td></tr> | |
| 536 | - </tbody> | |
| 537 | - </table> | |
| 538 | - <?php | |
| 539 | - } /* FeedWordPressPostsPage::custom_post_types_box() */ | |
| 511 | + $postsPage = new FeedWordPressPostsPage($link); | |
| 540 | 512 | |
| 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 | - } | |
| 513 | + $mesg = null; | |
| 575 | 514 | |
| 576 | - .boilerplate-li { | |
| 577 | - padding-bottom: 5px; | |
| 578 | - margin-bottom: 5px; | |
| 579 | - border-bottom: 1px dotted black; | |
| 580 | - } | |
| 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; | |
| 522 | + | |
| 523 | + $postsPage->ajax_interface_js(); | |
| 581 | 524 | |
| 582 | - </style> | |
| 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; ?> | |
| 583 | 530 | |
| 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 | 531 | <?php |
| 617 | - print "<ul>\n"; | |
| 618 | - if ( !is_array($attrib)) : $attrib = array(); endif; | |
| 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 | +); | |
| 619 | 549 | |
| 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' => '', | |
| 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() | |
| 629 | 557 | ); |
| 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'; | |
| 558 | + endforeach; | |
| 559 | + do_action('feedwordpress_admin_page_posts_meta_boxes', $postsPage); | |
| 641 | 560 | ?> |
| 642 | - | |
| 643 | -<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"> | |
| 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> | |
| 561 | + <div class="metabox-holder"> | |
| 652 | 562 | <?php |
| 653 | - endif; | |
| 654 | - endforeach; | |
| 563 | + fwp_do_meta_boxes($postsPage->meta_box_context(), $postsPage->meta_box_context(), $postsPage); | |
| 655 | 564 | ?> |
| 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> | |
| 565 | + </div> <!-- class="metabox-holder" --> | |
| 566 | +</div> <!-- id="post-body" --> | |
| 715 | 567 | <?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() */ | |
| 568 | + $postsPage->close_sheet(); | |
| 569 | +} /* function fwp_posts_page () */ | |
| 728 | 570 | |
| 729 | - function display () { | |
| 730 | - $this->boxes_by_methods = array( | |
| 731 | - 'publication_box' => __('Syndicated Posts'), | |
| 732 | - 'links_box' => __('Links'), | |
| 733 | - 'formatting_box' => __('Formatting'), | |
| 734 | - 'boilerplate_box' => ('Boilerplate / Credits'), | |
| 735 | - 'comments_and_pings_box' => __('Comments & Pings'), | |
| 736 | - 'custom_post_settings_box' => __('Custom Post Settings (to apply to each syndicated post)'), | |
| 737 | - 'custom_post_types_box' => ('Custom Post Types (advanced database settings)'), | |
| 738 | - ); | |
| 739 | - | |
| 740 | - parent::display(); | |
| 741 | - } /* FeedWordPressPostsPage::display () */ | |
| 742 | - | |
| 743 | - | |
| 744 | -} | |
| 745 | - | |
| 746 | - $postsPage = new FeedWordPressPostsPage; | |
| 747 | - $postsPage->display(); | |
| 571 | + fwp_posts_page(); | |
| 748 | 572 | |