| @@ -1,443 +1,748 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | require_once(dirname(__FILE__) . '/admin-ui.php'); |
| 3 | +require_once(dirname(__FILE__) . '/updatedpostscontrol.class.php'); | |
| 3 | 4 | |
| 4 | -function fwp_posts_page () { | |
| 5 | - global $wpdb, $wp_db_version; | |
| 5 | +class FeedWordPressPostsPage extends FeedWordPressAdminPage { | |
| 6 | + var $link = NULL; | |
| 7 | + var $updatedPosts = NULL; | |
| 6 | 8 | |
| 7 | - FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_posts_settings', /*capability=*/ 'manage_links'); | |
| 9 | + /** | |
| 10 | + * Construct the posts page object. | |
| 11 | + * | |
| 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 | + */ | |
| 14 | + public function __construct( $link = -1 ) { | |
| 15 | + if (is_numeric($link) and -1 == $link) : | |
| 16 | + $link = $this->submitted_link(); | |
| 17 | + endif; | |
| 8 | 18 | |
| 9 | - if (isset($GLOBALS['fwp_post']['save']) or isset($GLOBALS['fwp_post']['fix_mismatch'])) : | |
| 10 | - $link_id = $_REQUEST['save_link_id']; | |
| 11 | - elseif (isset($_REQUEST['link_id'])) : | |
| 12 | - $link_id = $_REQUEST['link_id']; | |
| 13 | - else : | |
| 14 | - $link_id = NULL; | |
| 15 | - endif; | |
| 19 | + parent::__construct('feedwordpresspostspage', $link); | |
| 20 | + $this->dispatch = 'feedwordpress_admin_page_posts'; | |
| 21 | + $this->filename = __FILE__; | |
| 22 | + $this->updatedPosts = new UpdatedPostsControl($this); | |
| 16 | 23 | |
| 17 | - if (is_numeric($link_id) and $link_id) : | |
| 18 | - $link =& new SyndicatedLink($link_id); | |
| 19 | - else : | |
| 20 | - $link = NULL; | |
| 21 | - endif; | |
| 24 | + $this->pagenames = array( | |
| 25 | + 'default' => 'Posts', | |
| 26 | + 'settings-update' => 'Syndicated posts', | |
| 27 | + 'open-sheet' => 'Syndicated Posts & Links', | |
| 28 | + ); | |
| 29 | + } /* FeedWordPressPostsPage constructor */ | |
| 22 | 30 | |
| 23 | - $mesg = null; | |
| 31 | + function save_settings () { | |
| 32 | + // custom post settings | |
| 33 | + $custom_settings = $this->custom_post_settings(); | |
| 24 | 34 | |
| 25 | - //////////////////////////////////////////////// | |
| 26 | - // Process POST request, if any ///////////////// | |
| 27 | - //////////////////////////////////////////////// | |
| 28 | - if (isset($GLOBALS['fwp_post']['save'])) : | |
| 29 | - // custom post settings | |
| 30 | - foreach ($GLOBALS['fwp_post']['notes'] as $mn) : | |
| 31 | - $mn['key0'] = trim($mn['key0']); | |
| 32 | - $mn['key1'] = trim($mn['key1']); | |
| 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; | |
| 33 | 43 | |
| 34 | - if (strlen($mn['key0']) > 0) : | |
| 35 | - unset($custom_settings[$mn['key0']]); // out with the old | |
| 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 | |
| 49 | + endif; | |
| 36 | 50 | endif; |
| 37 | - | |
| 38 | - if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) : | |
| 39 | - $custom_settings[$mn['key1']] = $mn['value']; // in with the new | |
| 40 | - endif; | |
| 41 | 51 | endforeach; |
| 42 | 52 | |
| 43 | - if (is_object($link) and $link->found()) : | |
| 44 | - $alter = array (); | |
| 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) | |
| 45 | 56 | |
| 46 | - $link->settings['postmeta'] = serialize($custom_settings); | |
| 57 | + $this->link->settings['postmeta'] = serialize($custom_settings); | |
| 47 | 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 | + | |
| 48 | 69 | // Post status, comment status, ping status |
| 49 | 70 | foreach (array('post', 'comment', 'ping') as $what) : |
| 50 | 71 | $sfield = "feed_{$what}_status"; |
| 51 | - if (isset($GLOBALS['fwp_post'][$sfield])) : | |
| 52 | - if ($GLOBALS['fwp_post'][$sfield]=='site-default') : | |
| 53 | - unset($link->settings["{$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 ]); | |
| 54 | 76 | else : |
| 55 | - $link->settings["{$what} status"] = $GLOBALS['fwp_post'][$sfield]; | |
| 77 | + $this->link->settings[ $afield ] = FeedWordPress::post( $sfield, null, 'text' ); | |
| 56 | 78 | endif; |
| 57 | 79 | endif; |
| 58 | 80 | endforeach; |
| 59 | - | |
| 60 | - $alter[] = "link_notes = '".$wpdb->escape($link->settings_to_notes())."'"; | |
| 61 | 81 | |
| 62 | - $alter_set = implode(", ", $alter); | |
| 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' ); | |
| 87 | + endif; | |
| 88 | + endif; | |
| 63 | 89 | |
| 64 | - // issue update query | |
| 65 | - $result = $wpdb->query(" | |
| 66 | - UPDATE $wpdb->links | |
| 67 | - SET $alter_set | |
| 68 | - WHERE link_id='$link_id' | |
| 69 | - "); | |
| 70 | - $updated_link = true; | |
| 71 | - | |
| 72 | - // reload link information from DB | |
| 73 | - if (function_exists('clean_bookmark_cache')) : | |
| 74 | - clean_bookmark_cache($link_id); | |
| 75 | - endif; | |
| 76 | - $link =& new SyndicatedLink($link_id); | |
| 77 | 90 | else : |
| 78 | 91 | // update_option ... |
| 79 | - if (isset($GLOBALS['fwp_post']['feed_post_status'])) : | |
| 80 | - update_option('feedwordpress_syndicated_post_status', $GLOBALS['fwp_post']['feed_post_status']); | |
| 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 | + | |
| 81 | 96 | endif; |
| 82 | - | |
| 97 | + | |
| 83 | 98 | update_option('feedwordpress_custom_settings', serialize($custom_settings)); |
| 84 | 99 | |
| 85 | - update_option('feedwordpress_munge_permalink', $_REQUEST['munge_permalink']); | |
| 86 | - update_option('feedwordpress_use_aggregator_source_data', $_REQUEST['use_aggregator_source_data']); | |
| 87 | - update_option('feedwordpress_formatting_filters', $_REQUEST['formatting_filters']); | |
| 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' ); | |
| 88 | 108 | |
| 89 | - if (isset($_REQUEST['feed_comment_status']) and ($_REQUEST['feed_comment_status'] == 'open')) : | |
| 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' ) : | |
| 90 | 121 | update_option('feedwordpress_syndicated_comment_status', 'open'); |
| 91 | 122 | else : |
| 92 | 123 | update_option('feedwordpress_syndicated_comment_status', 'closed'); |
| 93 | 124 | endif; |
| 94 | - | |
| 95 | - if (isset($_REQUEST['feed_ping_status']) and ($_REQUEST['feed_ping_status'] == 'open')) : | |
| 125 | + | |
| 126 | + if ( $sFeedPingStatus == 'open' ) : | |
| 96 | 127 | update_option('feedwordpress_syndicated_ping_status', 'open'); |
| 97 | 128 | else : |
| 98 | 129 | update_option('feedwordpress_syndicated_ping_status', 'closed'); |
| 99 | 130 | endif; |
| 100 | - | |
| 101 | - $updated_link = true; | |
| 131 | + | |
| 132 | + if ( ! is_null( $sSyndicatedPostType ) ) : | |
| 133 | + update_option('feedwordpress_syndicated_post_type', $sSyndicatedPostType ); | |
| 134 | + endif; | |
| 102 | 135 | endif; |
| 103 | - else : | |
| 104 | - $updated_link = false; | |
| 105 | - endif; | |
| 106 | 136 | |
| 107 | - //////////////////////////////////////////////// | |
| 108 | - // Get defaults from database ////////////////// | |
| 109 | - //////////////////////////////////////////////// | |
| 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; | |
| 110 | 144 | |
| 111 | - $post_status_global = get_option('feedwordpress_syndicated_post_status'); | |
| 112 | - if (!$post_status_global) : $post_status_global = 'publish'; endif; | |
| 113 | - | |
| 114 | - $comment_status_global = get_option('feedwordpress_syndicated_comment_status'); | |
| 115 | - if (!$comment_status_global) : $comment_status_global = 'closed'; endif; | |
| 145 | + // Convert indexes to 0..(N-1) to avoid possible collisions | |
| 146 | + $boilerplate = array_values( $boilerplate ); | |
| 116 | 147 | |
| 117 | - $ping_status_global = get_option('feedwordpress_syndicated_ping_status'); | |
| 118 | - if (!$ping_status_global) : $ping_status_global = 'closed'; endif; | |
| 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; | |
| 119 | 155 | |
| 120 | - $status['post'] = array('publish' => '', 'private' => '', 'draft' => ''); | |
| 121 | - if (SyndicatedPost::use_api('post_status_pending')) : | |
| 122 | - $status['post']['pending'] = ''; | |
| 123 | - endif; | |
| 156 | + $boilerplate_hook_order = FeedWordPress::post( 'boilerplate_hook_order', 10, 'text' ); | |
| 157 | + $this->update_setting('boilerplate hook order', intval( $boilerplate_hook_order ) ); | |
| 124 | 158 | |
| 125 | - $status['comment'] = array('open' => '', 'closed' => ''); | |
| 126 | - $status['ping'] = array('open' => '', 'closed' => ''); | |
| 159 | + parent::save_settings(); | |
| 160 | + } | |
| 127 | 161 | |
| 128 | - if (is_object($link) and $link->found()) : | |
| 129 | - $thePostsPhrase = __('posts from this feed'); | |
| 162 | + /** | |
| 163 | + * publication_box: Outputs "Publication" settings box. | |
| 164 | + * | |
| 165 | + * @since 2009.0713 | |
| 166 | + * @param object $page of class FeedWordPressPostsPage tells us whether this is | |
| 167 | + * a page for one feed's settings or for global defaults | |
| 168 | + * @param array $box | |
| 169 | + * | |
| 170 | + * @uses FeedWordPressPostsPage::these_posts_phrase() | |
| 171 | + * @uses FeedWordPress::syndicated_status() | |
| 172 | + * @uses SyndicatedLink::syndicated_status() | |
| 173 | + */ | |
| 174 | + /*static*/ function publication_box ($page, $box = NULL) { | |
| 175 | + $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", | |
| 181 | + ); | |
| 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; | |
| 130 | 187 | |
| 131 | - foreach (array('post', 'comment', 'ping') as $what) : | |
| 132 | - $status[$what]['site-default'] = ''; | |
| 133 | - if (isset($link->settings["{$what} status"])) : | |
| 134 | - $status[$what][$link->settings["{$what} status"]] = ' checked="checked"'; | |
| 135 | - else : | |
| 136 | - $status[$what]['site-default'] = ' checked="checked"'; | |
| 137 | - endif; | |
| 138 | - endforeach; | |
| 139 | - | |
| 140 | - $custom_settings = $link->settings["postmeta"]; | |
| 141 | - if ($custom_settings) : | |
| 142 | - $custom_settings = unserialize($custom_settings); | |
| 188 | + $params = array( | |
| 189 | + 'input-name' => 'feed_post_status', | |
| 190 | + 'setting-default' => NULL, | |
| 191 | + 'global-setting-default' => 'publish', | |
| 192 | + 'labels' => $labels, | |
| 193 | + ); | |
| 194 | + | |
| 195 | + // Hey ho, let's go... | |
| 196 | + ?> | |
| 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> | |
| 206 | + | |
| 207 | + <?php $page->updatedPosts->display(); ?> | |
| 208 | + </table> | |
| 209 | + | |
| 210 | + <?php | |
| 211 | + } /* FeedWordPressPostsPage::publication_box () */ | |
| 212 | + | |
| 213 | + /** | |
| 214 | + * Outputs "Formatting" settings box | |
| 215 | + * | |
| 216 | + * @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 | |
| 219 | + * @param array $box | |
| 220 | + * | |
| 221 | + */ | |
| 222 | + function formatting_box( $page, $box = NULL ) { | |
| 223 | + $thesePosts = $page->these_posts_phrase(); // result unused, why? (gwyneth 20230920) | |
| 224 | + | |
| 225 | + if ($page->for_feed_settings()) : | |
| 226 | + $formatting_filters = null; | |
| 227 | + $url = preg_replace('|/+$|', '', $page->link->homepage()); | |
| 228 | + else : | |
| 229 | + $formatting_filters = get_option('feedwordpress_formatting_filters', 'no'); | |
| 230 | + $url = 'http://example.com'; | |
| 143 | 231 | endif; |
| 144 | - | |
| 145 | - if (!is_array($custom_settings)) : | |
| 146 | - $custom_settings = array(); | |
| 232 | + ?> | |
| 233 | + <table class="edit-form narrow"> | |
| 234 | + <?php if ( !is_null($formatting_filters)) : ?> | |
| 235 | + | |
| 236 | + <tr><th scope="row">Formatting filters:</th> | |
| 237 | + <td><select name="formatting_filters" size="1"> | |
| 238 | + <option value="no"<?php echo ($formatting_filters!='yes')?' selected="selected"':''; ?>>Protect syndicated posts from formatting filters</option> | |
| 239 | + <option value="yes"<?php echo ($formatting_filters=='yes')?' selected="selected"':''; ?>>Expose syndicated posts to formatting filters</option> | |
| 240 | + </select> | |
| 241 | + <p class="setting-description">If you have trouble getting plugins to work that are supposed to insert | |
| 242 | + elements after posts (like relevant links or a social networking | |
| 243 | + <q>Share This</q> button), try changing this option to see if it fixes your | |
| 244 | + problem.</p> | |
| 245 | + </td></tr> | |
| 246 | + | |
| 247 | + <?php endif; ?> | |
| 248 | + | |
| 249 | + <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> | |
| 251 | + refers to a partial URI like <code>/about</code>, where should | |
| 252 | + the syndicated copy point to?</p> | |
| 253 | + | |
| 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 | + ?> | |
| 274 | + </td></tr> | |
| 275 | + | |
| 276 | + </table> | |
| 277 | + <?php | |
| 278 | + } /* FeedWordPressPostsPage::formatting_box() */ | |
| 279 | + | |
| 280 | + /** | |
| 281 | + * Output "Links" settings box | |
| 282 | + * | |
| 283 | + * @since 2009.0713 | |
| 284 | + * @param object $page of class FeedWordPressPostsPage tells us whether this is | |
| 285 | + * a page for one feed's settings or for global defaults | |
| 286 | + * @param array $box | |
| 287 | + * | |
| 288 | + */ | |
| 289 | + /*static*/ function links_box ($page, $box = NULL) { | |
| 290 | + $setting = array( | |
| 291 | + 'munge_permalink' => array( | |
| 292 | + 'yes' => __('The copy on the original website'), | |
| 293 | + 'no' => __('The local copy on this website'), | |
| 294 | + ), | |
| 295 | + ); | |
| 296 | + | |
| 297 | + if ( ! $page->for_feed_settings()) : | |
| 298 | + $use_aggregator_source_data = get_option('feedwordpress_use_aggregator_source_data'); | |
| 147 | 299 | endif; |
| 148 | - else : | |
| 149 | - $thePostsPhrase = __('syndicated posts'); | |
| 300 | + ?> | |
| 301 | + <table class="edit-form narrow"> | |
| 302 | + <tr><th scope="row">Permalinks point to:</th> | |
| 303 | + <td><?php | |
| 150 | 304 | |
| 151 | - $status['post'][$post_status_global] = ' checked="checked"'; | |
| 152 | - $status['comment'][$comment_status_global] = ' checked="checked"'; | |
| 153 | - $status['ping'][$ping_status_global] = ' checked="checked"'; | |
| 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 | + ?> | |
| 154 | 315 | |
| 155 | - $munge_permalink = get_option('feedwordpress_munge_permalink'); | |
| 156 | - $formatting_filters = get_option('feedwordpress_formatting_filters'); | |
| 157 | - $use_aggregator_source_data = get_option('feedwordpress_use_aggregator_source_data'); | |
| 316 | + </td></tr> | |
| 158 | 317 | |
| 159 | - $custom_settings = get_option('feedwordpress_custom_settings'); | |
| 160 | - if ($custom_settings) : | |
| 318 | + <?php if ( ! $page->for_feed_settings()) : ?> | |
| 319 | + <tr><th scope="row">Posts from aggregator feeds:</th> | |
| 320 | + <td><ul class="options"> | |
| 321 | + <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 | + <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> | |
| 323 | + </ul> | |
| 324 | + <p class="setting-description">Some feeds (for example, those produced by FeedWordPress) aggregate content from several different sources, and include information about the original source of the post. | |
| 325 | + This setting controls what FeedWordPress will give as the source of posts from | |
| 326 | + such an aggregator feed.</p> | |
| 327 | + </td></tr> | |
| 328 | + <?php endif; ?> | |
| 329 | + </table> | |
| 330 | + | |
| 331 | + <?php | |
| 332 | + } /* FeedWordPressPostsPage::links_box() */ | |
| 333 | + | |
| 334 | + /** | |
| 335 | + * Output "Comments & Pings" settings box | |
| 336 | + * | |
| 337 | + * @since 2009.0713 | |
| 338 | + * @param object $page of class FeedWordPressPostsPage tells us whether this is | |
| 339 | + * a page for one feed's settings or for global defaults | |
| 340 | + * @param array $box | |
| 341 | + * | |
| 342 | + */ | |
| 343 | + /*static*/ function comments_and_pings_box ($page, $box = NULL) { | |
| 344 | + $whatsits = array( | |
| 345 | + 'comment' => array('label' => __('Comments'), 'accept' => 'Allow comments'), | |
| 346 | + 'ping' => array('label' => __('Pings'), 'accept' => 'Accept pings'), | |
| 347 | + ); | |
| 348 | + $onThesePosts = 'on '.$page->these_posts_phrase(); | |
| 349 | + | |
| 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'), | |
| 353 | + ); | |
| 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 | + ); | |
| 363 | + | |
| 364 | + $settings = array(); $params = array(); | |
| 365 | + foreach ($whatsits as $what => $how) : | |
| 366 | + $whatsits[$what]['default'] = FeedWordPress::syndicated_status($what, /*default=*/ 'closed'); | |
| 367 | + | |
| 368 | + // 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)), | |
| 372 | + ); | |
| 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 | + ), | |
| 381 | + ); | |
| 382 | + endforeach; | |
| 383 | + | |
| 384 | + // Hey ho, let's go... | |
| 385 | + ?> | |
| 386 | + <table class="edit-form narrow"> | |
| 387 | + <?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 | + | |
| 397 | + <?php endforeach; ?> | |
| 398 | + | |
| 399 | + <tr><th scope="row"><?php esc_html_e('Comment feeds'); ?></th> | |
| 400 | + <td><p>When WordPress feeds and templates link to comments | |
| 401 | + feeds for <?php print esc_html($page->these_posts_phrase()); ?>, the | |
| 402 | + 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> | |
| 409 | + </table> | |
| 410 | + | |
| 411 | + <?php | |
| 412 | + } /* FeedWordPressPostsPage::comments_and_pings_box() */ | |
| 413 | + | |
| 414 | + /*static*/ function custom_post_settings ($page = NULL) { | |
| 415 | + if (is_null($page)) : | |
| 416 | + $page = $this; | |
| 417 | + endif; | |
| 418 | + | |
| 419 | + if ($page->for_feed_settings()) : | |
| 420 | + $custom_settings = $page->link->setting("postmeta", NULL, array()); | |
| 421 | + else : | |
| 422 | + $custom_settings = get_option('feedwordpress_custom_settings'); | |
| 423 | + endif; | |
| 424 | + | |
| 425 | + if ($custom_settings and !is_array($custom_settings)) : | |
| 161 | 426 | $custom_settings = unserialize($custom_settings); |
| 162 | 427 | endif; |
| 163 | 428 | |
| 164 | - if (!is_array($custom_settings)) : | |
| 429 | + if ( !is_array($custom_settings)) : | |
| 165 | 430 | $custom_settings = array(); |
| 166 | 431 | endif; |
| 167 | - endif; | |
| 168 | -?> | |
| 169 | -<script type="text/javascript"> | |
| 170 | - function contextual_appearance (item, appear, disappear, value, visibleStyle, checkbox) { | |
| 171 | - if (typeof(visibleStyle)=='undefined') visibleStyle = 'block'; | |
| 172 | 432 | |
| 173 | - var rollup=document.getElementById(item); | |
| 174 | - var newuser=document.getElementById(appear); | |
| 175 | - var sitewide=document.getElementById(disappear); | |
| 176 | - if (rollup) { | |
| 177 | - if ((checkbox && rollup.checked) || (!checkbox && value==rollup.value)) { | |
| 178 | - if (newuser) newuser.style.display=visibleStyle; | |
| 179 | - if (sitewide) sitewide.style.display='none'; | |
| 180 | - } else { | |
| 181 | - if (newuser) newuser.style.display='none'; | |
| 182 | - if (sitewide) sitewide.style.display=visibleStyle; | |
| 183 | - } | |
| 184 | - } | |
| 433 | + return $custom_settings; | |
| 434 | + } /* 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 | + | |
| 185 | 442 | } |
| 186 | -</script> | |
| 443 | + | |
| 444 | + /** | |
| 445 | + * Output "Custom Post Settings" settings box | |
| 446 | + * | |
| 447 | + * @since 2009.0713 | |
| 448 | + * @param object $page of class FeedWordPressPostsPage tells us whether this is | |
| 449 | + * a page for one feed's settings or for global defaults | |
| 450 | + * @param array $box | |
| 451 | + */ | |
| 452 | + /*static*/ function custom_post_settings_box ($page, $box = NULL) { | |
| 453 | + $custom_settings = FeedWordPressPostsPage::custom_post_settings($page); | |
| 454 | + ?> | |
| 455 | + <div id="postcustomstuff"> | |
| 456 | + <p>Custom fields can be used to add extra metadata to a post that you can <a href="http://codex.wordpress.org/Using_Custom_Fields">use in your theme</a>.</p> | |
| 457 | + <table id="meta-list" cellpadding="3"> | |
| 458 | + <tr> | |
| 459 | + <th>Key</th> | |
| 460 | + <th>Value</th> | |
| 461 | + <th>Action</th> | |
| 462 | + </tr> | |
| 187 | 463 | |
| 188 | -<?php if ($updated_link) : ?> | |
| 189 | -<div class="updated"><p>Syndicated posts settings updated.</p></div> | |
| 190 | -<?php elseif (!is_null($mesg)) : ?> | |
| 191 | -<div class="updated"><p><?php print wp_specialchars($mesg, 1); ?></p></div> | |
| 192 | -<?php endif; ?> | |
| 464 | + <?php | |
| 465 | + $i = 0; | |
| 466 | + foreach ($custom_settings as $key => $value) : | |
| 467 | + ?> | |
| 468 | + <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]"> | |
| 474 | + <option value="update">save changes</option> | |
| 475 | + <option value="delete">delete this setting</option> | |
| 476 | + </select></td> | |
| 477 | + </tr> | |
| 193 | 478 | |
| 194 | -<div class="wrap"> | |
| 195 | -<form style="position: relative" action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> | |
| 196 | -<div><?php | |
| 197 | - FeedWordPressCompatibility::stamp_nonce('feedwordpress_posts_settings'); | |
| 479 | + <?php | |
| 480 | + $i++; | |
| 481 | + endforeach; | |
| 482 | + ?> | |
| 198 | 483 | |
| 199 | - if (is_numeric($link_id) and $link_id) : | |
| 200 | -?> | |
| 201 | -<input type="hidden" name="save_link_id" value="<?php echo $link_id; ?>" /> | |
| 202 | -<?php | |
| 203 | - else : | |
| 204 | -?> | |
| 205 | -<input type="hidden" name="save_link_id" value="*" /> | |
| 206 | -<?php | |
| 207 | - endif; | |
| 208 | -?> | |
| 209 | -</div> | |
| 484 | + <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 ); ?> | |
| 487 | + <p>Enter a text value, or a path to a data element from the syndicated item.<br/> | |
| 488 | + For data elements, you can use an XPath-like syntax wrapped in <code>$( ... )</code>.<br/> | |
| 489 | + <code>hello</code> = the text value <code><span style="background-color: #30FFA0;">hello</span></code><br/> | |
| 490 | + <code>$(author/email)</code> = the contents of <code><author><email><span style="background-color: #30FFA0">...</span></email></author></code><br/> | |
| 491 | + <code>$(media:content/@url)</code> = the contents of <code><media:content url="<span style="background-color: #30FFA0">...</span>">...</media:content></code></p> | |
| 492 | + </td> | |
| 493 | + <td><em>add new setting...</em><input type="hidden" name="notes[<?php echo esc_attr($i); ?>][action]" value="update" /></td> | |
| 494 | + </tr> | |
| 495 | + </table> | |
| 496 | + </div> <!-- id="postcustomstuff" --> | |
| 210 | 497 | |
| 211 | -<?php $links = FeedWordPress::syndicated_links(); ?> | |
| 212 | -<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?> | |
| 213 | - <div class="icon32"><img src="<?php print htmlspecialchars(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></div> | |
| 214 | -<?php endif; ?> | |
| 498 | + <?php | |
| 499 | + } /* FeedWordPressPostsPage::custom_post_settings_box() */ | |
| 215 | 500 | |
| 216 | -<h2>Syndicated Post Settings<?php if (!is_null($link) and $link->found()) : ?>: <?php echo wp_specialchars($link->link->link_name, 1); ?><?php endif; ?></h2> | |
| 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' | |
| 217 | 505 | |
| 218 | -<style type="text/css"> | |
| 219 | - table.edit-form th { width: 27%; vertical-align: top; } | |
| 220 | - table.edit-form td { width: 73%; vertical-align: top; } | |
| 221 | - table.edit-form td ul.options { margin: 0; padding: 0; list-style: none; } | |
| 222 | -</style> | |
| 506 | + // Get all custom post types | |
| 507 | + $post_types = get_post_types(array( | |
| 508 | + '_builtin' => false, | |
| 509 | + ), 'objects'); | |
| 223 | 510 | |
| 224 | -<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?> | |
| 225 | - <style type="text/css"> | |
| 226 | - #post-search { | |
| 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; | |
| 516 | + | |
| 517 | + $params = array( | |
| 518 | + 'global-setting-default' => 'post', | |
| 519 | + 'default-input-value' => 'default', | |
| 520 | + ); | |
| 521 | + | |
| 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() */ | |
| 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 { | |
| 227 | 555 | float: right; |
| 228 | - margin:11px 12px 0; | |
| 229 | - min-width: 130px; | |
| 230 | - position:relative; | |
| 556 | + width: 300px; | |
| 557 | + border: 1px dotted #777; | |
| 558 | + margin: 3px; | |
| 559 | + padding: 5px; | |
| 560 | + background-color: #f7f7f7; | |
| 231 | 561 | } |
| 232 | - .fwpfs { | |
| 233 | - color: #dddddd; | |
| 234 | - background:#797979 url(<?php bloginfo('home') ?>/wp-admin/images/fav.png) repeat-x scroll left center; | |
| 235 | - border-color:#777777 #777777 #666666 !important; -moz-border-radius-bottomleft:12px; | |
| 236 | - -moz-border-radius-bottomright:12px; | |
| 237 | - -moz-border-radius-topleft:12px; | |
| 238 | - -moz-border-radius-topright:12px; | |
| 239 | - border-style:solid; | |
| 240 | - border-width:1px; | |
| 241 | - line-height:15px; | |
| 242 | - padding:3px 30px 4px 12px; | |
| 562 | + .boilerplate-help-box dt { | |
| 563 | + font-weight: bold; | |
| 564 | + font-size: 85%; | |
| 243 | 565 | } |
| 244 | - .fwpfs.slide-down { | |
| 245 | - border-bottom-color: #626262; | |
| 246 | - -moz-border-radius-bottomleft:0; | |
| 247 | - -moz-border-radius-bottomright:0; | |
| 248 | - -moz-border-radius-topleft:12px; | |
| 249 | - -moz-border-radius-topright:12px; | |
| 250 | - background-image:url(<?php bloginfo('home') ?>/wp-admin/images/fav-top.png); | |
| 251 | - background-position:0 top; | |
| 252 | - background-repeat:repeat-x; | |
| 253 | - border-bottom-style:solid; | |
| 254 | - border-bottom-width:1px; | |
| 566 | + .boilerplate-help-box dd { | |
| 567 | + font-size: 80%; line-height: 100%; font-style: italic; | |
| 568 | + padding-left: 1.5em; | |
| 255 | 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 | + | |
| 256 | 582 | </style> |
| 257 | - | |
| 258 | - <script type="text/javascript"> | |
| 259 | - jQuery(document).ready(function($){ | |
| 260 | - $('.fwpfs').toggle( | |
| 261 | - function(){$('.fwpfs').removeClass('slideUp').addClass('slideDown'); setTimeout(function(){if ( $('.fwpfs').hasClass('slideDown') ) { $('.fwpfs').addClass('slide-down'); }}, 10) }, | |
| 262 | - function(){$('.fwpfs').removeClass('slideDown').addClass('slideUp'); setTimeout(function(){if ( $('.fwpfs').hasClass('slideUp') ) { $('.fwpfs').removeClass('slide-down'); }}, 10) } | |
| 263 | - ); | |
| 264 | - $('.fwpfs').bind( | |
| 265 | - 'change', | |
| 266 | - function () { this.form.submit(); } | |
| 267 | - ); | |
| 268 | - $('#post-search .button').css( 'display', 'none' ); | |
| 269 | - }); | |
| 270 | - </script> | |
| 271 | -<?php endif; /* else : */?> | |
| 272 | -<p id="post-search"> | |
| 273 | -<select name="link_id" class="fwpfs" style="max-width: 20.0em;"> | |
| 274 | - <option value="*"<?php if (is_null($link) or !$link->found()) : ?> selected="selected"<?php endif; ?>>- defaults for all feeds -</option> | |
| 275 | -<?php if ($links) : foreach ($links as $ddlink) : ?> | |
| 276 | - <option value="<?php print (int) $ddlink->link_id; ?>"<?php if (!is_null($link) and ($link->link->link_id==$ddlink->link_id)) : ?> selected="selected"<?php endif; ?>><?php print wp_specialchars($ddlink->link_name, 1); ?></option> | |
| 277 | -<?php endforeach; endif; ?> | |
| 278 | -</select> | |
| 279 | -<input class="button" type="submit" name="go" value="<?php _e('Go') ?> »" /> | |
| 280 | -</p> | |
| 281 | -<?php /* endif; */ ?> | |
| 282 | 583 | |
| 283 | -<?php if (!is_null($link) and $link->found()) : ?> | |
| 284 | - <p>These settings only affect posts syndicated from | |
| 285 | - <strong><?php echo wp_specialchars($link->link->link_name, 1); ?></strong>.</p> | |
| 286 | -<?php else : ?> | |
| 287 | - <p>These settings affect posts syndicated from any feed unless they are overridden | |
| 288 | - by settings for that specific feed.</p> | |
| 289 | -<?php endif; ?> | |
| 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> | |
| 290 | 586 | |
| 291 | -<div id="poststuff"> | |
| 292 | -<div id="post-body"> | |
| 293 | -<?php fwp_option_box_opener('Publication', 'publicationdiv', 'postbox'); ?> | |
| 294 | -<table class="form-table" cellspacing="2" cellpadding="5"> | |
| 295 | -<tr><th width="27%" scope="row" style="vertical-align:top">Status for new posts:</th> | |
| 296 | -<td width="73%" style="vertical-align:top"><ul style="margin:0; list-style:none"> | |
| 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> | |
| 297 | 591 | |
| 298 | -<?php if (is_object($link) and $link->found()) : ?> | |
| 299 | -<li><label><input type="radio" name="feed_post_status" value="site-default" | |
| 300 | -<?php echo $status['post']['site-default']; ?> /> Use <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>">site-wide setting</a> | |
| 301 | -(currently: <strong><?php echo ($post_status_global ? $post_status_global : 'publish'); ?></strong>)</label></li> | |
| 302 | -<?php endif; ?> | |
| 592 | + <dt><code>[source-name]</code></dt> | |
| 593 | + <dd>Name of the source you syndicated the post from</dd> | |
| 303 | 594 | |
| 304 | -<li><label><input type="radio" name="feed_post_status" value="publish" | |
| 305 | -<?php echo $status['post']['publish']; ?> /> Publish <?php print $thePostsPhrase; ?> immediately</label></li> | |
| 595 | + <dt><code>[source-url]</code></dt> | |
| 596 | + <dd>URL of the source you syndicated the post from</dd> | |
| 306 | 597 | |
| 307 | -<?php if (SyndicatedPost::use_api('post_status_pending')) : ?> | |
| 308 | -<li><label><input type="radio" name="feed_post_status" value="pending" | |
| 309 | -<?php echo $status['post']['pending']; ?>/> Hold <?php print $thePostsPhrase; ?> for review; mark as Pending</label></li> | |
| 310 | -<?php endif; ?> | |
| 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> | |
| 311 | 601 | |
| 312 | -<li><label><input type="radio" name="feed_post_status" value="draft" | |
| 313 | -<?php echo $status['post']['draft']; ?> /> Save <?php print $thePostsPhrase; ?> as drafts</label></li> | |
| 314 | -<li><label><input type="radio" name="feed_post_status" value="private" | |
| 315 | -<?php echo $status['post']['private']; ?> /> Save <?php print $thePostsPhrase; ?> as private posts</label></li> | |
| 316 | -</ul></td> | |
| 317 | -</tr> | |
| 318 | -</table> | |
| 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 | + | |
| 319 | 616 | <?php |
| 320 | - fwp_option_box_closer(); | |
| 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'; | |
| 321 | 641 | ?> |
| 322 | 642 | |
| 323 | -<?php if (!(is_object($link) and $link->found())) : ?> | |
| 324 | -<?php fwp_option_box_opener('Formatting', 'formattingdiv', 'postbox'); ?> | |
| 325 | -<table class="form-table" cellspacing="2" cellpadding="5"> | |
| 326 | -<tr><th scope="row">Formatting filters:</th> | |
| 327 | -<td><select name="formatting_filters" size="1"> | |
| 328 | -<option value="no"<?php echo ($formatting_filters!='yes')?' selected="selected"':''; ?>>Protect syndicated posts from formatting filters</option> | |
| 329 | -<option value="yes"<?php echo ($formatting_filters=='yes')?' selected="selected"':''; ?>>Expose syndicated posts to formatting filters</option> | |
| 330 | -</select> | |
| 331 | -<p class="setting-description">If you have trouble getting plugins to work that are supposed to insert | |
| 332 | -elements after posts (like relevant links or a social networking | |
| 333 | -<q>Share This</q> button), try changing this option to see if it fixes your | |
| 334 | -problem.</p> | |
| 335 | -</td></tr> | |
| 336 | -</table> | |
| 337 | -<?php fwp_option_box_closer(); ?> | |
| 338 | - | |
| 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> | |
| 339 | 652 | <?php |
| 340 | - fwp_option_box_opener('Links', 'linksdiv', 'postbox'); | |
| 653 | + endif; | |
| 654 | + endforeach; | |
| 341 | 655 | ?> |
| 342 | -<table class="form-table" cellspacing="2" cellpadding="5"> | |
| 343 | -<tr><th scope="row">Permalinks:</th> | |
| 344 | -<td><select name="munge_permalink" size="1"> | |
| 345 | -<option value="yes"<?php echo ($munge_permalink=='yes')?' selected="selected"':''; ?>>point to the copy on the original website</option> | |
| 346 | -<option value="no"<?php echo ($munge_permalink=='no')?' selected="selected"':''; ?>>point to the local copy on this website</option> | |
| 347 | -</select></td> | |
| 348 | -</tr> | |
| 656 | + </ul> | |
| 657 | + <br style="clear: both" /> | |
| 349 | 658 | |
| 350 | -<tr><th scope="row">Posts from aggregator feeds:</th> | |
| 351 | -<td><ul class="options"> | |
| 352 | -<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> | |
| 353 | -<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> | |
| 354 | -</ul> | |
| 355 | -<p class="setting-description">Some feeds (for example, those produced by FeedWordPress) aggregate content from several different sources, and include information about the original source of the post. | |
| 356 | -This setting controls what FeedWordPress will give as the source of posts from | |
| 357 | -such an aggregator feed.</p> | |
| 358 | -</td></tr> | |
| 359 | -</table> | |
| 360 | -<?php | |
| 361 | - fwp_option_box_closer(); | |
| 362 | - fwp_linkedit_periodic_submit(); | |
| 363 | -endif; | |
| 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 | + } ); | |
| 364 | 667 | |
| 365 | - fwp_option_box_opener(__('Comments & Pings'), 'commentstatus', 'postbox'); | |
| 366 | -?> | |
| 367 | -<table class="form-table" cellspacing="2" cellpadding="5"> | |
| 368 | -<tr><th scope="row"><?php print __('Comments') ?>:</th> | |
| 369 | -<td><ul class="options"> | |
| 370 | -<?php if (is_object($link) and $link->found()) : ?> | |
| 371 | -<li><label><input type="radio" name="feed_comment_status" value="site-default" | |
| 372 | -<?php echo $status['comment']['site-default']; ?> /> Use <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>">site-wide setting</a> | |
| 373 | -(currently: <strong><?php echo $comment_status_global; ?></strong>)</label></li> | |
| 374 | -<?php endif; ?> | |
| 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); | |
| 375 | 671 | |
| 376 | -<li><label><input type="radio" name="feed_comment_status" value="open"<?php echo $status['comment']['open'] ?> /> Allow comments on syndicated posts</label></li> | |
| 377 | -<li><label><input type="radio" name="feed_comment_status" value="closed"<?php echo $status['comment']['closed']; ?> /> Don't allow comments on syndicated posts</label></li> | |
| 378 | -</ul></td></tr> | |
| 672 | + $('#add-new-boilerplate-rule').click( function() { | |
| 673 | + // Get index counter | |
| 674 | + var nextIndex = parseInt($('#next-boilerplate-rule-index').val()); | |
| 379 | 675 | |
| 380 | -<tr><th scope="row"><?php print __('Pings') ?>:</th> | |
| 381 | -<td><ul class="options"> | |
| 382 | -<?php if (is_object($link) and $link->found()) : ?> | |
| 383 | -<li><label><input type="radio" name="feed_ping_status" value="site-default" | |
| 384 | -<?php echo $status['ping']['site-default']; ?> /> Use <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>">site-wide setting</a> | |
| 385 | -(currently: <strong><?php echo $ping_status_global; ?></strong>)</label></li> | |
| 386 | -<?php endif; ?> | |
| 676 | + var newIdPrefix = 'boilerplate-'+nextIndex; | |
| 677 | + var newNamePrefix = 'boilerplate['+nextIndex+']'; | |
| 387 | 678 | |
| 388 | -<li><label><input type="radio" name="feed_ping_status" value="open"<?php echo $status['ping']['open']; ?> /> Accept pings on syndicated posts</label></li> | |
| 389 | -<li><label><input type="radio" name="feed_ping_status" value="closed"<?php echo $status['ping']['closed']; ?> /> Don't accept pings on syndicated posts</label></li> | |
| 390 | -</ul></td></tr> | |
| 391 | -</table> | |
| 392 | -<?php | |
| 393 | - fwp_option_box_closer(); | |
| 394 | - fwp_linkedit_periodic_submit(); | |
| 395 | -?> | |
| 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') }; | |
| 396 | 684 | |
| 397 | -<?php fwp_option_box_opener('Custom Post Settings (to apply to each syndicated post)', 'postcustom', 'postbox'); ?> | |
| 398 | -<div id="postcustomstuff"> | |
| 399 | -<table id="meta-list" cellpadding="3"> | |
| 400 | - <tr> | |
| 401 | - <th>Key</th> | |
| 402 | - <th>Value</th> | |
| 403 | - <th>Action</th> | |
| 404 | - </tr> | |
| 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 | + } | |
| 405 | 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> | |
| 406 | 715 | <?php |
| 407 | - $i = 0; | |
| 408 | - foreach ($custom_settings as $key => $value) : | |
| 716 | + if ($page->for_default_settings()) : | |
| 409 | 717 | ?> |
| 410 | - <tr style="vertical-align:top"> | |
| 411 | - <th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo wp_specialchars($key, 'both'); ?>" /> | |
| 412 | - <input id="notes-<?php echo $i; ?>-key" name="notes[<?php echo $i; ?>][key1]" value="<?php echo wp_specialchars($key, 'both'); ?>" /></th> | |
| 413 | - <td width="60%"><textarea rows="2" cols="40" id="notes-<?php echo $i; ?>-value" name="notes[<?php echo $i; ?>][value]"><?php echo wp_specialchars($value, 'both'); ?></textarea></td> | |
| 414 | - <td width="10%"><select name="notes[<?php echo $i; ?>][action]"> | |
| 415 | - <option value="update">save changes</option> | |
| 416 | - <option value="delete">delete this setting</option> | |
| 417 | - </select></td> | |
| 418 | - </tr> | |
| 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> | |
| 419 | 725 | <?php |
| 420 | - $i++; | |
| 421 | - endforeach; | |
| 422 | -?> | |
| 423 | - <tr> | |
| 424 | - <th scope="row"><input type="text" size="10" name="notes[<?php echo $i; ?>][key1]" value="" /></th> | |
| 425 | - <td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea></td> | |
| 426 | - <td><em>add new setting...</em><input type="hidden" name="notes[<?php echo $i; ?>][action]" value="update" /></td> | |
| 427 | - </tr> | |
| 428 | -</table> | |
| 429 | -<?php fwp_option_box_closer(); ?> | |
| 726 | + endif; | |
| 727 | + } /* FeedWordPressPostsPage::boilerplate_box() */ | |
| 430 | 728 | |
| 431 | -</div> | |
| 432 | -</div> | |
| 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 | + ); | |
| 433 | 739 | |
| 434 | -<p class="submit"> | |
| 435 | -<input class="button-primary" type="submit" name="save" value="Save Changes" /> | |
| 436 | -</p> | |
| 437 | -</form> | |
| 438 | -</div> <!-- class="wrap" --> | |
| 439 | -<?php | |
| 440 | -} /* function fwp_posts_page () */ | |
| 740 | + parent::display(); | |
| 741 | + } /* FeedWordPressPostsPage::display () */ | |
| 441 | 742 | |
| 442 | - fwp_posts_page(); | |
| 743 | + | |
| 744 | +} | |
| 745 | + | |
| 746 | + $postsPage = new FeedWordPressPostsPage; | |
| 747 | + $postsPage->display(); | |
| 443 | 748 | |