| @@ -1,368 +1,307 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | require_once(dirname(__FILE__) . '/admin-ui.php'); |
| 3 | 3 | |
| 4 | -class FeedWordPressCategoriesPage extends FeedWordPressAdminPage { | |
| 5 | - public function __construct( $link = -1 ) { | |
| 6 | - if (is_numeric($link) and -1 == $link) : | |
| 7 | - $link = $this->submitted_link(); | |
| 8 | - endif; | |
| 4 | +function fwp_categories_page () { | |
| 5 | + global $wpdb, $wp_db_version; | |
| 9 | 6 | |
| 10 | - parent::__construct('feedwordpresscategories', $link); | |
| 11 | - $this->dispatch = 'feedwordpress_admin_page_categories'; | |
| 12 | - $this->pagenames = array( | |
| 13 | - 'default' => 'Categories & Tags', | |
| 14 | - 'settings-update' => 'Syndicated Categories & Tags', | |
| 15 | - 'open-sheet' => 'Categories & Tags', | |
| 16 | - ); | |
| 17 | - $this->filename = __FILE__; | |
| 18 | - } | |
| 7 | + FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_categories_settings', /*capability=*/ 'manage_links'); | |
| 19 | 8 | |
| 20 | - function unfamiliar_category_label ($name) { | |
| 21 | - if (preg_match('/^create:(.*)$/', $name, $refs)) : | |
| 22 | - $tax = get_taxonomy($refs[1]); | |
| 23 | - $name = sprintf(__('Create new %s to match them'), $tax->labels->name); | |
| 24 | - endif; | |
| 25 | - return $name; | |
| 26 | - } | |
| 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; | |
| 27 | 16 | |
| 28 | - public function setting_radio_label( $li ) { | |
| 29 | - if ( is_array($li['label'] ) ) : | |
| 30 | - list( $a_href, $s_currently ) = $li['label']; | |
| 31 | - printf( | |
| 32 | - 'Use the <a href="%s">site-wide setting</a> <span class="current-setting">Currently: <strong>%s</strong></span>', | |
| 33 | - esc_url( $a_href ), | |
| 34 | - esc_html( $s_currently ) | |
| 35 | - ); | |
| 36 | - else : | |
| 37 | - print esc_html( $li['label'] ); | |
| 38 | - endif; | |
| 39 | - } | |
| 40 | - | |
| 41 | - function feed_categories_box ($page, $box = NULL) { | |
| 42 | - $link = $page->link; | |
| 17 | + if (is_numeric($link_id) and $link_id) : | |
| 18 | + $link =& new SyndicatedLink($link_id); | |
| 19 | + else : | |
| 20 | + $link = NULL; | |
| 21 | + endif; | |
| 43 | 22 | |
| 44 | - $globalPostType = get_option('feedwordpress_syndicated_post_type', 'post'); | |
| 45 | - if ($this->for_feed_settings()) : | |
| 46 | - $post_type = $link->setting('syndicated post type', 'syndicated_post_type', 'post'); | |
| 47 | - else : | |
| 48 | - $post_type = $globalPostType; | |
| 23 | + $mesg = null; | |
| 24 | + | |
| 25 | + //////////////////////////////////////////////// | |
| 26 | + // Process POST request, if any ///////////////// | |
| 27 | + //////////////////////////////////////////////// | |
| 28 | + if (isset($GLOBALS['fwp_post']['save'])) : | |
| 29 | + $saveCats = array(); | |
| 30 | + if (isset($GLOBALS['fwp_post']['post_category'])) : | |
| 31 | + foreach ($GLOBALS['fwp_post']['post_category'] as $cat_id) : | |
| 32 | + $saveCats[] = '{#'.$cat_id.'}'; | |
| 33 | + endforeach; | |
| 49 | 34 | endif; |
| 50 | - $taxonomies = get_object_taxonomies(array('object_type' => $post_type), 'names'); | |
| 51 | 35 | |
| 52 | - $unmatched = array('category' => array(), 'post_tag' => array()); | |
| 53 | - $matchUl = array('cats' => array(), 'tags' => array(), 'filter' => array()); | |
| 54 | - $tagLikeTaxonomies = array(); | |
| 55 | - foreach ($taxonomies as $tax) : | |
| 56 | - $taxonomy = get_taxonomy($tax); | |
| 36 | + if (is_object($link) and $link->found()) : | |
| 37 | + $alter = array (); | |
| 57 | 38 | |
| 58 | - if ( ! $taxonomy->hierarchical) : | |
| 59 | - $tagLikeTaxonomies[] = $tax; | |
| 39 | + // Categories | |
| 40 | + if (!empty($saveCats)) : $link->settings['cats'] = $saveCats; | |
| 41 | + else : unset($link->settings['cats']); | |
| 60 | 42 | endif; |
| 61 | 43 | |
| 62 | - $name = 'create:'.$tax; | |
| 63 | - foreach (array('category', 'post_tag') as $what) : | |
| 64 | - $unmatched[$what][$name] = array( | |
| 65 | - 'label' => $this->unfamiliar_category_label($name), | |
| 66 | - ); | |
| 67 | - $unmatchedRadio[$what][$name] = ''; | |
| 68 | - endforeach; | |
| 44 | + // Tags | |
| 45 | + if (isset($GLOBALS['fwp_post']['tags_input'])) : | |
| 46 | + $link->settings['tags'] = array(); | |
| 47 | + foreach (explode(',', $GLOBALS['fwp_post']['tags_input']) as $tag) : | |
| 48 | + $link->settings['tags'][] = trim($tag); | |
| 49 | + endforeach; | |
| 50 | + endif; | |
| 69 | 51 | |
| 70 | - foreach (array('cats', 'tags', 'filter') as $what) : | |
| 71 | - $matchUl[$what][$tax] = array( | |
| 72 | - 'checked' => '', | |
| 73 | - 'labels' => $taxonomy->labels, | |
| 74 | - ); | |
| 75 | - endforeach; | |
| 76 | - endforeach; | |
| 52 | + // Unfamiliar categories | |
| 53 | + if (isset($GLOBALS['fwp_post']["unfamiliar_category"])) : | |
| 54 | + if ('site-default'==$GLOBALS['fwp_post']["unfamiliar_category"]) : | |
| 55 | + unset($link->settings["unfamiliar category"]); | |
| 56 | + else : | |
| 57 | + $link->settings["unfamiliar category"] = $GLOBALS['fwp_post']["unfamiliar_category"]; | |
| 58 | + endif; | |
| 59 | + endif; | |
| 77 | 60 | |
| 78 | - foreach ($unmatched as $what => $um) : | |
| 79 | - $unmatched[$what]['null'] = array('label' => __('Don\'t create any matching terms')); | |
| 80 | - $unmatchedRadio[$what]['null'] = ''; | |
| 81 | - endforeach; | |
| 61 | + // Category spitting regex | |
| 62 | + if (isset($GLOBALS['fwp_post']['cat_split'])) : | |
| 63 | + if (strlen(trim($GLOBALS['fwp_post']['cat_split'])) > 0) : | |
| 64 | + $link->settings['cat_split'] = trim($GLOBALS['fwp_post']['cat_split']); | |
| 65 | + else : | |
| 66 | + unset($link->settings['cat_split']); | |
| 67 | + endif; | |
| 68 | + endif; | |
| 82 | 69 | |
| 83 | - $globalUnmatched = array( | |
| 84 | - 'category' => FeedWordPress::on_unfamiliar('category'), | |
| 85 | - 'post_tag' => FeedWordPress::on_unfamiliar('post_tag'), | |
| 86 | - ); | |
| 87 | - foreach ($globalUnmatched as $what => $value) : | |
| 88 | - if ($value=='create') : $value = 'create:category'; endif; | |
| 89 | - if ($value=='tag') : $value = 'create:post_tag'; endif; | |
| 90 | - $globalUnmatched[$what] = $value; | |
| 91 | - endforeach; | |
| 70 | + $alter[] = "link_notes = '".$wpdb->escape($link->settings_to_notes())."'"; | |
| 92 | 71 | |
| 93 | - $globalMatch['cats'] = get_option('feedwordpress_match_cats', $taxonomies); | |
| 94 | - $globalMatch['tags'] = get_option('feedwordpress_match_tags', $tagLikeTaxonomies); | |
| 95 | - $globalMatch['filter'] = get_option('feedwordpress_match_filter', array()); | |
| 72 | + $alter_set = implode(", ", $alter); | |
| 96 | 73 | |
| 97 | - $globalMatchLabels = array(); | |
| 98 | - $nothingDoing = array('cats' => "won't try to match", 'tags' => "won't try to match", "filter" => "won't filter"); | |
| 74 | + // issue update query | |
| 75 | + $result = $wpdb->query(" | |
| 76 | + UPDATE $wpdb->links | |
| 77 | + SET $alter_set | |
| 78 | + WHERE link_id='$link_id' | |
| 79 | + "); | |
| 80 | + $updated_link = true; | |
| 99 | 81 | |
| 100 | - foreach ($globalMatch as $what => $domain) : | |
| 101 | - $labels = array(); $domain = array_filter($domain, 'remove_dummy_zero'); | |
| 102 | - foreach ($domain as $tax) : | |
| 103 | - $tax = get_taxonomy($tax); | |
| 104 | - $labels[] = $tax->labels->name; | |
| 105 | - endforeach; | |
| 106 | - | |
| 107 | - if (count($labels) > 0) : | |
| 108 | - $globalMatchLabels[$what] = implode(", ", $labels); | |
| 82 | + // reload link information from DB | |
| 83 | + if (function_exists('clean_bookmark_cache')) : | |
| 84 | + clean_bookmark_cache($link_id); | |
| 85 | + endif; | |
| 86 | + $link =& new SyndicatedLink($link_id); | |
| 87 | + else : | |
| 88 | + // Categories | |
| 89 | + if (!empty($saveCats)) : | |
| 90 | + update_option('feedwordpress_syndication_cats', implode(FEEDWORDPRESS_CAT_SEPARATOR, $saveCats)); | |
| 109 | 91 | else : |
| 110 | - $globalMatchLabels[$what] = $nothingDoing[$what]; | |
| 92 | + delete_option('feedwordpress_syndication_cats'); | |
| 111 | 93 | endif; |
| 112 | - endforeach; | |
| 94 | + | |
| 95 | + // Tags | |
| 96 | + if (isset($_REQUEST['tags_input'])) : | |
| 97 | + $tags = explode(",", $_REQUEST['tags_input']); | |
| 98 | + else : | |
| 99 | + $tags = array(); | |
| 100 | + endif; | |
| 101 | + | |
| 102 | + if (!empty($tags)) : | |
| 103 | + update_option('feedwordpress_syndication_tags', implode(FEEDWORDPRESS_CAT_SEPARATOR, $tags)); | |
| 104 | + else : | |
| 105 | + delete_option('feedwordpress_syndication_tags'); | |
| 106 | + endif; | |
| 113 | 107 | |
| 114 | - if ($this->for_feed_settings()) : | |
| 115 | - $href = $this->admin_page_href(basename(__FILE__)); | |
| 108 | + update_option('feedwordpress_unfamiliar_category', $_REQUEST['unfamiliar_category']); | |
| 116 | 109 | |
| 117 | - foreach ($unmatched as $what => $um) : | |
| 118 | - // Is the global default setting appropriate to this post type? | |
| 119 | - $GUC = $globalUnmatched[$what]; | |
| 120 | - if (isset($um[$GUC])) : | |
| 121 | - // Yup. Let's add a site-default option | |
| 122 | - $currently = $um[$GUC]['label']; | |
| 123 | - $defaultLi = array( | |
| 124 | - 'site-default' => array( | |
| 125 | - 'label' => [ $href, $currently ], | |
| 126 | - ), | |
| 127 | - ); | |
| 128 | - $unmatchedColumns[$what] = array( | |
| 129 | - $defaultLi, | |
| 130 | - ); | |
| 131 | - $unmatchedDefault[$what] = 'site-default'; | |
| 132 | - $unmatchedRadio[$what]['site-default'] = ''; | |
| 133 | - else : | |
| 134 | - $opts = array_keys($unmatched[$what]); | |
| 135 | - $unmatchedDefault[$what] = $opts[0]; | |
| 136 | - $unmatchedColumns[$what] = array(); | |
| 137 | - endif; | |
| 110 | + $updated_link = true; | |
| 111 | + endif; | |
| 112 | + else : | |
| 113 | + $updated_link = false; | |
| 114 | + endif; | |
| 138 | 115 | |
| 139 | - $ucKey[$what] = $link->setting("unfamiliar $what", NULL, NULL); | |
| 140 | - endforeach; | |
| 116 | + //////////////////////////////////////////////// | |
| 117 | + // Get defaults from database ////////////////// | |
| 118 | + //////////////////////////////////////////////// | |
| 119 | + | |
| 120 | + $unfamiliar = array ('create'=>'','tag' => '', 'default'=>'','filter'=>''); | |
| 121 | + if (is_object($link) and $link->found()) : | |
| 122 | + $unfamiliar['site-default'] = ''; | |
| 123 | + $ucKey = $link->settings["unfamiliar category"]; | |
| 124 | + $ucDefault = 'site-default'; | |
| 141 | 125 | |
| 142 | - $match['cats'] = $this->link->setting('match/cats', NULL, NULL); | |
| 143 | - $match['tags'] = $this->link->setting('match/tags', NULL, NULL); | |
| 144 | - $match['filter'] = $this->link->setting('match/filter', NULL, NULL); | |
| 145 | - else : | |
| 146 | - foreach ($unmatched as $what => $um) : | |
| 147 | - $ucKey[$what] = FeedWordPress::on_unfamiliar($what); | |
| 148 | - endforeach; | |
| 126 | + if (is_array($link->settings['cats'])) : $cats = $link->settings['cats']; | |
| 127 | + else : $cats = array(); | |
| 128 | + endif; | |
| 149 | 129 | |
| 150 | - $match = $globalMatch; | |
| 151 | - endif; | |
| 130 | + $tags = $link->settings['tags']; | |
| 131 | + else : | |
| 132 | + $ucKey = FeedWordPress::on_unfamiliar('category'); | |
| 133 | + $ucDefault = 'create'; | |
| 152 | 134 | |
| 153 | - foreach ($ucKey as $what => $uck) : | |
| 154 | - if ($uck == 'tag') : $uck = 'create:post_tag'; endif; | |
| 155 | - if ($uck == 'create') : $uck = 'create:category'; endif; | |
| 135 | + $cats = array_map('trim', | |
| 136 | + preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, get_option('feedwordpress_syndication_cats')) | |
| 137 | + ); | |
| 138 | + $tags = array_map('trim', | |
| 139 | + preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, get_option('feedwordpress_syndication_tags')) | |
| 140 | + ); | |
| 141 | + endif; | |
| 156 | 142 | |
| 157 | - if ( !is_string($uck)) : | |
| 158 | - $uck = $unmatchedDefault[$what]; | |
| 159 | - endif; | |
| 160 | - $ucKey[$what] = $uck; | |
| 143 | + if (!is_string($ucKey) or !array_key_exists($ucKey, $unfamiliar)) : | |
| 144 | + $ucKey = $ucDefault; | |
| 145 | + endif; | |
| 146 | + $unfamiliar[$ucKey] = ' checked="checked"'; | |
| 161 | 147 | |
| 162 | - if ( !array_key_exists($uck, $unmatchedRadio[$what])) : | |
| 163 | - $obsoleteLi = array( | |
| 164 | - $uck => array( | |
| 165 | - 'label' => ' <span style="font-style: italic; color: #777;">'.$this->unfamiliar_category_label($uck).'</span> <span style="background-color: #ffff90; color: black;">(This setting is no longer applicable to the type of post syndicated from this feed!)</span><p>Please change this one of the following settings:</p>', | |
| 166 | - ), | |
| 167 | - ); | |
| 168 | - $unmatched[$what] = array_merge($obsoleteLi, $unmatched[$what]); | |
| 169 | - $unmatchedRadio[$what][$uck] = ' disabled="disabled"'; | |
| 170 | - endif; | |
| 148 | + $dogs = SyndicatedPost::category_ids($cats, /*unfamiliar=*/ NULL); | |
| 149 | +?> | |
| 150 | +<script type="text/javascript"> | |
| 151 | + function contextual_appearance (item, appear, disappear, value, visibleStyle, checkbox) { | |
| 152 | + if (typeof(visibleStyle)=='undefined') visibleStyle = 'block'; | |
| 171 | 153 | |
| 172 | - $unmatchedRadio[$what][$uck] .= ' checked="checked"'; | |
| 154 | + var rollup=document.getElementById(item); | |
| 155 | + var newuser=document.getElementById(appear); | |
| 156 | + var sitewide=document.getElementById(disappear); | |
| 157 | + if (rollup) { | |
| 158 | + if ((checkbox && rollup.checked) || (!checkbox && value==rollup.value)) { | |
| 159 | + if (newuser) newuser.style.display=visibleStyle; | |
| 160 | + if (sitewide) sitewide.style.display='none'; | |
| 161 | + } else { | |
| 162 | + if (newuser) newuser.style.display='none'; | |
| 163 | + if (sitewide) sitewide.style.display=visibleStyle; | |
| 164 | + } | |
| 165 | + } | |
| 166 | + } | |
| 167 | +</script> | |
| 173 | 168 | |
| 174 | - $unmatchedColumns[$what][] = $unmatched[$what]; | |
| 175 | - endforeach; | |
| 169 | +<?php if ($updated_link) : ?> | |
| 170 | +<div class="updated"><p>Syndicated categories and tags settings updated.</p></div> | |
| 171 | +<?php elseif (!is_null($mesg)) : ?> | |
| 172 | +<div class="updated"><p><?php print wp_specialchars($mesg, 1); ?></p></div> | |
| 173 | +<?php endif; ?> | |
| 176 | 174 | |
| 177 | - $defaulted = array(); | |
| 178 | - foreach ($match as $what => $set) : | |
| 179 | - $defaulted[$what] = false; | |
| 180 | - if (is_null($set) or (count($set) < 1)) : | |
| 181 | - $defaulted[$what] = true; | |
| 182 | - if ($this->for_feed_settings()) : | |
| 183 | - $set = $globalMatch[$what]; | |
| 184 | - $match[$what] = $globalMatch[$what]; | |
| 185 | - endif; | |
| 186 | - endif; | |
| 175 | +<div class="wrap"> | |
| 176 | +<form style="position: relative" action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> | |
| 177 | +<div><?php | |
| 178 | + FeedWordPressCompatibility::stamp_nonce('feedwordpress_categories_settings'); | |
| 187 | 179 | |
| 188 | - if ( ! $defaulted[$what] or $this->for_feed_settings()) : | |
| 189 | - foreach ($set as $against) : | |
| 190 | - if (array_key_exists($against, $matchUl[$what])) : | |
| 191 | - $matchUl[$what][$against]['checked'] = ' checked="checked"'; | |
| 192 | - endif; | |
| 193 | - endforeach; | |
| 194 | - endif; | |
| 195 | - endforeach; | |
| 180 | + if (is_numeric($link_id) and $link_id) : | |
| 181 | +?> | |
| 182 | +<input type="hidden" name="save_link_id" value="<?php echo $link_id; ?>" /> | |
| 183 | +<?php | |
| 184 | + else : | |
| 185 | +?> | |
| 186 | +<input type="hidden" name="save_link_id" value="*" /> | |
| 187 | +<?php | |
| 188 | + endif; | |
| 189 | +?> | |
| 190 | +</div> | |
| 196 | 191 | |
| 197 | - // Hey ho, let's go... | |
| 198 | - $offerSiteWideSettings = ($page->for_feed_settings() and ($post_type==$globalPostType)); | |
| 199 | - ?> | |
| 200 | -<table class="edit-form narrow"> | |
| 201 | -<tr> | |
| 202 | -<th scope="row">Match feed categories:</th> | |
| 203 | -<td><input type="hidden" name="match_categories[cats][]" value="0" /> | |
| 204 | -<?php if ($offerSiteWideSettings) : ?> | |
| 205 | - <table class="twofer"> | |
| 206 | - <tbody> | |
| 207 | - <tr><td class="equals first <?php if ($defaulted['cats']) : ?>active<?php else: ?>inactive<?php endif; ?>"><p><label><input type="radio" name="match_default[cats]" | |
| 208 | -value="yes" <?php if ($defaulted['cats']) : ?> checked="checked"<?php endif; ?> /><?php $this->setting_radio_label( array( "label" => array ( $href, $globalMatchLabels['cats'] ) ) ); ?></label></p></td> | |
| 209 | - <td class="equals second <?php if ($defaulted['cats']) : ?>inactive<?php else: ?>active<?php endif; ?>"><p><label><input type="radio" name="match_default[cats]" | |
| 210 | -value="no" <?php if ( ! $defaulted['cats']) : ?> checked="checked"<?php endif; ?> /> | |
| 211 | -Do something different with this feed.</label> | |
| 212 | -<?php else : ?> | |
| 213 | - <p> | |
| 192 | +<?php $links = FeedWordPress::syndicated_links(); ?> | |
| 193 | +<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?> | |
| 194 | + <div class="icon32"><img src="<?php print htmlspecialchars(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></div> | |
| 214 | 195 | <?php endif; ?> |
| 215 | -When a feed provides categories for a post, try to match those categories | |
| 216 | -locally with:</p> | |
| 217 | -<ul class="options compact"> | |
| 218 | -<?php foreach ($matchUl['cats'] as $name => $li) : ?> | |
| 219 | - <li><label><input type="checkbox" | |
| 220 | - name="match_categories[cats][]" value="<?php print esc_attr( $name ); ?>" | |
| 221 | - <?php fwp_checked_flag($li, 'checked'); ?> /> <?php $l = $li['labels']; print esc_html($l->name); ?></label></li> | |
| 222 | -<?php endforeach; ?> | |
| 223 | -</ul> | |
| 224 | -<?php if ($offerSiteWideSettings) : ?> | |
| 225 | - </td></tr> | |
| 226 | - </tbody> | |
| 227 | - </table> | |
| 228 | -<?php endif; ?> | |
| 229 | -</td> | |
| 230 | -</tr> | |
| 196 | +<h2>Categories & Tags Settings<?php if (!is_null($link) and $link->found()) : ?>: <?php echo wp_specialchars($link->link->link_name, 1); ?><?php endif; ?></h2> | |
| 231 | 197 | |
| 232 | -<tr> | |
| 233 | -<th scope="row">Unmatched categories:</th> | |
| 234 | -<td><p>When <?php print esc_html( $this->these_posts_phrase() ); ?> have categories on | |
| 235 | -the feed that don't have any local matches yet...</p> | |
| 198 | +<style type="text/css"> | |
| 199 | + table.edit-form th { width: 27%; vertical-align: top; } | |
| 200 | + table.edit-form td { width: 73%; vertical-align: top; } | |
| 201 | + table.edit-form td ul.options { margin: 0; padding: 0; list-style: none; } | |
| 202 | +</style> | |
| 236 | 203 | |
| 237 | -<?php if (count($unmatchedColumns['category']) > 1) : ?> | |
| 238 | - <table class="twofer"> | |
| 239 | -<?php else : ?> | |
| 240 | - <table style="width: 100%"> | |
| 241 | -<?php endif; ?> | |
| 242 | - <tbody> | |
| 243 | - <tr> | |
| 244 | - <?php foreach ($unmatchedColumns['category'] as $index => $column) : ?> | |
| 245 | - <td class="equals <?php print (($index == 0) ? 'first' : 'second'); ?> inactive"><ul class="options"> | |
| 246 | - <?php | |
| 247 | - foreach ($column as $name => $li) : | |
| 248 | - ?> | |
| 249 | - <li><label><input type="radio" name="unfamiliar_category" value="<?php print esc_attr( $name ); ?>"<?php fwp_checked_flag($unmatchedRadio['category'][$name]); ?> /> <?php | |
| 250 | - $this->setting_radio_label( $li ); | |
| 251 | - ?></label></li> | |
| 252 | - <?php | |
| 253 | - endforeach; ?> | |
| 254 | - </ul></td> | |
| 255 | - <?php endforeach; ?> | |
| 256 | - </tr> | |
| 257 | - </tbody> | |
| 258 | - </table> | |
| 259 | -</td></tr> | |
| 204 | +<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?> | |
| 205 | + <style type="text/css"> | |
| 206 | + #post-search { | |
| 207 | + float: right; | |
| 208 | + margin:11px 12px 0; | |
| 209 | + min-width: 130px; | |
| 210 | + position:relative; | |
| 211 | + } | |
| 212 | + .fwpfs { | |
| 213 | + color: #dddddd; | |
| 214 | + background:#797979 url(<?php bloginfo('home') ?>/wp-admin/images/fav.png) repeat-x scroll left center; | |
| 215 | + border-color:#777777 #777777 #666666 !important; -moz-border-radius-bottomleft:12px; | |
| 216 | + -moz-border-radius-bottomright:12px; | |
| 217 | + -moz-border-radius-topleft:12px; | |
| 218 | + -moz-border-radius-topright:12px; | |
| 219 | + border-style:solid; | |
| 220 | + border-width:1px; | |
| 221 | + line-height:15px; | |
| 222 | + padding:3px 30px 4px 12px; | |
| 223 | + } | |
| 224 | + .fwpfs.slide-down { | |
| 225 | + border-bottom-color: #626262; | |
| 226 | + -moz-border-radius-bottomleft:0; | |
| 227 | + -moz-border-radius-bottomright:0; | |
| 228 | + -moz-border-radius-topleft:12px; | |
| 229 | + -moz-border-radius-topright:12px; | |
| 230 | + background-image:url(<?php bloginfo('home') ?>/wp-admin/images/fav-top.png); | |
| 231 | + background-position:0 top; | |
| 232 | + background-repeat:repeat-x; | |
| 233 | + border-bottom-style:solid; | |
| 234 | + border-bottom-width:1px; | |
| 235 | + } | |
| 236 | + </style> | |
| 237 | + | |
| 238 | + <script type="text/javascript"> | |
| 239 | + jQuery(document).ready(function($){ | |
| 240 | + $('.fwpfs').toggle( | |
| 241 | + function(){$('.fwpfs').removeClass('slideUp').addClass('slideDown'); setTimeout(function(){if ( $('.fwpfs').hasClass('slideDown') ) { $('.fwpfs').addClass('slide-down'); }}, 10) }, | |
| 242 | + function(){$('.fwpfs').removeClass('slideDown').addClass('slideUp'); setTimeout(function(){if ( $('.fwpfs').hasClass('slideUp') ) { $('.fwpfs').removeClass('slide-down'); }}, 10) } | |
| 243 | + ); | |
| 244 | + $('.fwpfs').bind( | |
| 245 | + 'change', | |
| 246 | + function () { this.form.submit(); } | |
| 247 | + ); | |
| 248 | + $('#post-search .button').css( 'display', 'none' ); | |
| 249 | + }); | |
| 250 | + </script> | |
| 251 | +<?php endif; /* else : */?> | |
| 252 | +<p id="post-search"> | |
| 253 | +<select name="link_id" class="fwpfs" style="max-width: 20.0em;"> | |
| 254 | + <option value="*"<?php if (is_null($link) or !$link->found()) : ?> selected="selected"<?php endif; ?>>- defaults for all feeds -</option> | |
| 255 | +<?php if ($links) : foreach ($links as $ddlink) : ?> | |
| 256 | + <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> | |
| 257 | +<?php endforeach; endif; ?> | |
| 258 | +</select> | |
| 259 | +<input class="button" type="submit" name="go" value="<?php _e('Go') ?> »" /> | |
| 260 | +</p> | |
| 261 | +<?php /* endif; */ ?> | |
| 260 | 262 | |
| 261 | -<tr> | |
| 262 | -<th scope="row">Match inline tags: | |
| 263 | -<p class="setting-description">Applies only to inline tags marked | |
| 264 | -as links in the text of syndicated posts, using the | |
| 265 | -<code><a rel="tag">...</a></code> microformat. | |
| 266 | -Most feeds with "tags" just treat them as normal feed categories, | |
| 267 | -like those handled above.</p> | |
| 268 | -</th> | |
| 269 | -<td><input type="hidden" name="match_categories[tags][]" value="0" /> | |
| 270 | -<?php if ($offerSiteWideSettings) : ?> | |
| 271 | - <table class="twofer"> | |
| 272 | - <tbody> | |
| 273 | - <tr><td class="equals first <?php if ($defaulted['tags']) : ?>active<?php else: ?>inactive<?php endif; ?>"><p><label><input type="radio" name="match_default[tags]" | |
| 274 | -value="yes" <?php if ($defaulted['tags']) : ?> checked="checked"<?php endif; ?> /> | |
| 275 | -<?php $this->setting_radio_label( array( "label" => array( $href, $globalMatchLabels['tags'] ) ) ); ?></label></p> | |
| 276 | -</td> | |
| 277 | - <td class="equals second <?php if ($defaulted['tags']) : ?>inactive<?php else: ?>active<?php endif; ?>"><p><label><input type="radio" name="match_default[tags]" | |
| 278 | -value="no" <?php if ( ! $defaulted['tags']) : ?> checked="checked"<?php endif; ?> /> | |
| 279 | -Do something different with this feed.</label> | |
| 263 | +<?php if (!is_null($link) and $link->found()) : ?> | |
| 264 | + <p>These settings only affect posts syndicated from | |
| 265 | + <strong><?php echo wp_specialchars($link->link->link_name, 1); ?></strong>.</p> | |
| 280 | 266 | <?php else : ?> |
| 281 | - <p> | |
| 267 | + <p>These settings affect posts syndicated from any feed unless they are overridden | |
| 268 | + by settings for that specific feed.</p> | |
| 282 | 269 | <?php endif; ?> |
| 283 | -When a feed provides tags inline in a post, try to match those tags | |
| 284 | -locally with:</p> | |
| 285 | -<ul class="options compact"> | |
| 286 | -<?php foreach ($matchUl['tags'] as $name => $li) : ?> | |
| 287 | - <li><label><input type="checkbox" | |
| 288 | - name="match_categories[tags][]" value="<?php print esc_attr( $name ); ?>" | |
| 289 | - <?php fwp_checked_flag( $li, 'checked' ); ?> /> <?php $l = $li['labels']; print esc_html( $l->name ); ?></label></li> | |
| 290 | -<?php endforeach; ?> | |
| 291 | -</ul> | |
| 292 | -<?php if ($offerSiteWideSettings) : ?> | |
| 293 | - </td></tr> | |
| 294 | - </tbody> | |
| 295 | - </table> | |
| 296 | -<?php endif; ?> | |
| 297 | -</td> | |
| 298 | -</tr> | |
| 299 | 270 | |
| 271 | +<div id="poststuff"> | |
| 272 | +<div id="post-body"> | |
| 273 | +<?php | |
| 274 | + fwp_option_box_opener(__('Categories'), 'categorydiv', 'postbox'); | |
| 275 | + fwp_category_box($dogs, 'all syndicated posts'.((is_object($link) and $link->found()) ? ' from this feed':'')); | |
| 276 | +?> | |
| 277 | +<table class="edit-form"> | |
| 300 | 278 | <tr> |
| 301 | -<th scope="row">Unmatched inline tags:</th> | |
| 302 | -<td><p>When the text of <?php print esc_html( $this->these_posts_phrase() ); ?> contains | |
| 303 | -inline tags that don't have any local matches yet...</p> | |
| 279 | +<th scope="row">Unfamiliar categories:</th> | |
| 280 | +<td><p>When one of the categories on a syndicated post is a category that FeedWordPress has not encountered before ...</p> | |
| 304 | 281 | |
| 305 | -<?php if (count($unmatchedColumns['post_tag']) > 1) : ?> | |
| 306 | - <table class="twofer"> | |
| 307 | -<?php else : ?> | |
| 308 | - <table style="width: 100%"> | |
| 309 | -<?php endif; ?> | |
| 310 | - <tbody> | |
| 311 | - <tr> | |
| 312 | - <?php foreach ($unmatchedColumns['post_tag'] as $index => $column) : ?> | |
| 313 | - <td class="equals <?php print (($index == 0) ? 'first' : 'second'); ?> inactive"><ul class="options"> | |
| 314 | - <?php foreach ($column as $name => $li) : ?> | |
| 315 | - <li><label><input type="radio" name="unfamiliar_post_tag" value="<?php print esc_attr( $name ); ?>"<?php fwp_checked_flag($unmatchedRadio['post_tag'][$name]); ?> /> <?php $this->setting_radio_label( $li ); ?></label></li> | |
| 316 | - <?php endforeach; ?> | |
| 317 | - </ul></td> | |
| 318 | - <?php endforeach; ?> | |
| 319 | - </tr> | |
| 320 | - </tbody> | |
| 321 | - </table> | |
| 282 | +<ul class="options"> | |
| 283 | +<?php if (is_object($link) and ($link->found())) : ?> | |
| 284 | +<li><label><input type="radio" name="unfamiliar_category" value="site-default"<?php echo $unfamiliar['site-default']; ?> /> use the <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>">site-wide setting</a> | |
| 285 | +(currently <strong><?php echo FeedWordPress::on_unfamiliar('category'); ?></strong>)</label></li> | |
| 286 | +<?php endif; ?> | |
| 322 | 287 | |
| 323 | -</td></tr> | |
| 288 | +<li><label><input type="radio" name="unfamiliar_category" value="create"<?php echo $unfamiliar['create']; ?> /> create a new category</label></li> | |
| 324 | 289 | |
| 325 | -<tr> | |
| 326 | -<th scope="row">Filter:</th> | |
| 327 | -<td><input type="hidden" name="match_categories[filter][]" value="0" /> | |
| 328 | -<?php if ($offerSiteWideSettings) : ?> | |
| 329 | - <table class="twofer"> | |
| 330 | - <tbody> | |
| 331 | - <tr> | |
| 332 | - <td class="equals first <?php if ($defaulted['filter']) : ?>active<?php else: ?>inactive<?php endif; ?>"> | |
| 333 | - <p><label><input type="radio" name="match_default[filter]" | |
| 334 | -value="yes" <?php if ($defaulted['filter']) : ?> checked="checked"<?php endif; ?> /> | |
| 335 | -<?php $this->setting_radio_label( array( "label" => array( $href, $globalMatchLabels['filter'] ) ) ); ?></label></p> | |
| 336 | - </td> | |
| 337 | - <td class="equals second <?php if ($defaulted['filter']) : ?>inactive<?php else: ?>active<?php endif; ?>"> | |
| 338 | - <p><label><input type="radio" name="match_default[filter]" | |
| 339 | -value="no" <?php if ( ! $defaulted['filter']) : ?> checked="checked"<?php endif; ?> /> | |
| 340 | -Do something different with this feed:</label></p> | |
| 341 | -<div style="margin-left: 3.0em;"> | |
| 290 | +<?php if (fwp_test_wp_version(FWP_SCHEMA_23)) : ?> | |
| 291 | +<li><label><input type="radio" name="unfamiliar_category" value="tag"<?php echo $unfamiliar['tag']; ?>/> create a new tag</label></li> | |
| 342 | 292 | <?php endif; ?> |
| 343 | 293 | |
| 344 | -<ul class="options"> | |
| 345 | -<?php foreach ($matchUl['filter'] as $tax => $li) : ?> | |
| 346 | -<li><label><input type="checkbox" name="match_categories[filter][]" value="<?php print esc_attr( $tax ); ?>" | |
| 347 | -<?php fwp_checked_flag($li, 'checked'); ?> /> Don't syndicate posts unless they match at | |
| 348 | -least one local <strong><?php $l = $li['labels']; print esc_html( $l->singular_name ); ?></strong></label></li> | |
| 349 | -<?php endforeach; ?> | |
| 350 | -</ul> | |
| 294 | +<li><label><input type="radio" name="unfamiliar_category" value="default"<?php echo $unfamiliar['default']; ?> /> don't create new categories<?php if (fwp_test_wp_version(FWP_SCHEMA_23)) : ?> or tags<?php endif; ?></label></li> | |
| 295 | +<li><label><input type="radio" name="unfamiliar_category" value="filter"<?php echo $unfamiliar['filter']; ?> /> don't create new categories<?php if (fwp_test_wp_version(FWP_SCHEMA_23)) : ?> or tags<?php endif; ?> and don't syndicate posts unless they match at least one familiar category</label></li> | |
| 296 | +</ul></td> | |
| 297 | +</tr> | |
| 351 | 298 | |
| 352 | -<?php if ($offerSiteWideSettings) : ?> | |
| 353 | - </div> | |
| 354 | - </td></tr> | |
| 355 | - </tbody> | |
| 356 | - </table> | |
| 357 | -<?php endif; ?> | |
| 358 | -</td> | |
| 359 | -</tr> | |
| 360 | -<?php if ($page->for_feed_settings()) : ?> | |
| 299 | +<?php if (is_object($link) and $link->found()) : ?> | |
| 361 | 300 | <tr> |
| 362 | 301 | <th scope="row">Multiple categories:</th> |
| 363 | -<td> | |
| 364 | -<input type="text" size="20" id="cat_split" name="cat_split" value="<?php if ( isset( $link->settings['cat_split'] ) ) : echo esc_attr( $link->settings['cat_split'] ); endif; ?>" /> | |
| 302 | +<td> | |
| 303 | +<input type="text" size="20" id="cat_split" name="cat_split" value="<?php if (isset($link->settings['cat_split'])) : echo htmlspecialchars($link->settings['cat_split']); endif; ?>" /> | |
| 365 | 304 | <p class="setting-description">Enter a <a href="http://us.php.net/manual/en/reference.pcre.pattern.syntax.php">Perl-compatible regular expression</a> here if the feed provides multiple |
| 366 | 305 | categories in a single category element. The regular expression should match |
| 367 | 306 | the characters used to separate one category from the next. If the feed uses |
| 368 | 307 | spaces (like <a href="http://del.icio.us/">del.icio.us</a>), use the pattern "\s". |
| @@ -370,254 +309,38 @@ | ||
| 370 | 309 | blank.</p></td> |
| 371 | 310 | </tr> |
| 372 | 311 | <?php endif; ?> |
| 373 | 312 | </table> |
| 374 | - <?php | |
| 375 | - } /* FeedWordPressCategoriesPage::feed_categories_box() */ | |
| 313 | +<?php | |
| 314 | + fwp_option_box_closer(); | |
| 315 | + fwp_linkedit_periodic_submit(); | |
| 316 | + | |
| 317 | +if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25) : | |
| 318 | + fwp_tags_box($tags); | |
| 319 | + fwp_linkedit_periodic_submit(); | |
| 320 | +endif; ?> | |
| 321 | +</div> | |
| 322 | +</div> | |
| 376 | 323 | |
| 377 | - function term_option_map () { | |
| 378 | - return array( | |
| 379 | - 'category' => 'feedwordpress_syndication_cats', | |
| 380 | - 'post_tag' => 'feedwordpress_syndication_tags', | |
| 381 | - ); | |
| 382 | - } | |
| 383 | - function term_setting_map () { | |
| 384 | - return array( | |
| 385 | - 'category' => 'cats', | |
| 386 | - 'post_tag' => 'tags', | |
| 387 | - ); | |
| 388 | - } | |
| 324 | +<p class="submit"> | |
| 325 | +<input class="button-primary" type="submit" name="save" value="Save Changes" /> | |
| 326 | +</p> | |
| 389 | 327 | |
| 390 | - function categories_box ($page, $box = NULL) { | |
| 391 | - $link = $page->link; | |
| 392 | - $dummy = null; | |
| 393 | - $syndicatedlink = new SyndicatedLink($dummy); | |
| 328 | +<script type="text/javascript"> | |
| 329 | + contextual_appearance('unfamiliar-author', 'unfamiliar-author-newuser', 'unfamiliar-author-default', 'newuser', 'inline'); | |
| 330 | +<?php if (is_object($link) and $link->found()) : ?> | |
| 331 | +<?php for ($j=1; $j<=$i; $j++) : ?> | |
| 332 | + contextual_appearance('author-rules-<?php echo $j; ?>', 'author-rules-<?php echo $j; ?>-newuser', 'author-rules-<?php echo $j; ?>-default', 'newuser', 'inline'); | |
| 333 | +<?php endfor; ?> | |
| 334 | + contextual_appearance('add-author-rule', 'add-author-rule-newuser', 'add-author-rule-default', 'newuser', 'inline'); | |
| 335 | + contextual_appearance('fix-mismatch-to', 'fix-mismatch-to-newuser', null, 'newuser', 'inline'); | |
| 336 | +<?php else : ?> | |
| 337 | + contextual_appearance('match-author-by-email', 'unless-null-email', null, 'yes', 'block', /*checkbox=*/ true); | |
| 338 | +<?php endif; ?> | |
| 339 | +</script> | |
| 340 | +</form> | |
| 341 | +</div> <!-- class="wrap" --> | |
| 342 | +<?php | |
| 343 | +} /* function fwp_categories_page () */ | |
| 394 | 344 | |
| 395 | - if ($this->for_feed_settings()) : | |
| 396 | - $post_type = $link->setting('syndicated post type', 'syndicated_post_type', 'post'); | |
| 397 | - else : | |
| 398 | - $post_type = get_option('feedwordpress_syndicated_post_type', 'post'); | |
| 399 | - endif; | |
| 400 | - $taxonomies = get_object_taxonomies(array('object_type' => $post_type), 'names'); | |
| 401 | - | |
| 402 | - $option_map = $this->term_option_map(); | |
| 403 | - $setting_map = $this->term_setting_map(); | |
| 404 | - $globalTax = get_option('feedwordpress_syndication_terms', array()); | |
| 405 | - if ($page->for_feed_settings()) : | |
| 406 | - $terms = $link->setting('terms', NULL, array()); | |
| 407 | - endif; | |
| 408 | - | |
| 409 | - ?> | |
| 410 | - <table class="edit-form narrow"> | |
| 411 | - <tbody> | |
| 412 | - <?php | |
| 413 | - foreach ($taxonomies as $tax) : | |
| 414 | - $taxonomy = get_taxonomy($tax); | |
| 415 | - ?> | |
| 416 | - <tr><th><?php print esc_html( $taxonomy->labels->name ); ?></th> | |
| 417 | - <td><?php | |
| 418 | - if (isset($option_map[$tax])) : | |
| 419 | - $option = $option_map[$tax]; | |
| 420 | - $globalCats = preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, get_option($option)); | |
| 421 | - elseif (isset($globalTax[$tax])) : | |
| 422 | - $globalCats = $globalTax[$tax]; | |
| 423 | - else : | |
| 424 | - $globalCats = array(); | |
| 425 | - endif; | |
| 426 | - $globalCats = array_map('trim', $globalCats); | |
| 427 | - | |
| 428 | - if ($page->for_feed_settings()) : | |
| 429 | - $add_global_categories = $link->setting("add/$tax", NULL, 'yes'); | |
| 430 | - $checked = array('yes' => '', 'no' => ''); | |
| 431 | - $checked[$add_global_categories] = ' checked="checked"'; | |
| 432 | - | |
| 433 | - if (isset($setting_map[$tax])) : | |
| 434 | - $setting = $setting_map[$tax]; | |
| 435 | - $cats = $link->setting($setting, NULL, NULL); | |
| 436 | - if (is_null($cats)) : $cats = array(); endif; | |
| 437 | - elseif (isset($terms[$tax])) : | |
| 438 | - $cats = $terms[$tax]; | |
| 439 | - else : | |
| 440 | - $cats = array(); | |
| 441 | - endif; | |
| 442 | - else : | |
| 443 | - $cats = $globalCats; | |
| 444 | - endif; | |
| 445 | - | |
| 446 | - if ($page->for_feed_settings()) : | |
| 447 | - ?> | |
| 448 | - <table class="twofer"> | |
| 449 | - <tbody> | |
| 450 | - <tr> | |
| 451 | - <td class="primary"> | |
| 452 | - <?php | |
| 453 | - endif; | |
| 454 | - | |
| 455 | - $dogs = $syndicatedlink->category_ids(/*post=*/ NULL, $cats, /*unfamiliar=*/ NULL, /*taxonomies=*/ array($tax)); | |
| 456 | - | |
| 457 | - if ($taxonomy->hierarchical) : // Use a category-style checkbox | |
| 458 | - fwp_category_box($dogs, 'all '.$page->these_posts_phrase(), /*tags=*/ array(), /*params=*/ array('taxonomy' => $tax)); | |
| 459 | - else : // Use a tag-style edit box | |
| 460 | - fwp_tags_box($cats, 'all '.$page->these_posts_phrase(), /*params=*/ array('taxonomy' => $tax)); | |
| 461 | - endif; | |
| 462 | - | |
| 463 | - $globalDogs = $syndicatedlink->category_ids(/*post=*/ NULL, $globalCats, /*unfamiliar=*/ 'create:'.$tax, /*taxonomies=*/ array($tax)); | |
| 464 | - | |
| 465 | - $siteWideHref = $this->admin_page_href(basename(__FILE__)); | |
| 466 | - | |
| 467 | - if ($page->for_feed_settings()) : | |
| 468 | - ?> | |
| 469 | - </td> | |
| 470 | - <td class="secondary"> | |
| 471 | - <h4>Site-wide <?php print esc_html( $taxonomy->labels->name ); ?></h4> | |
| 472 | - <?php if (count($globalCats) > 0) : ?> | |
| 473 | - <ul class="current-setting"> | |
| 474 | - <?php foreach ($globalDogs as $dog) : ?> | |
| 475 | - <li><?php $cat = get_term($dog, $tax); print esc_html( $cat->name ); ?></li> | |
| 476 | - <?php endforeach; ?> | |
| 477 | - </ul> | |
| 478 | - </div> | |
| 479 | - <p> | |
| 480 | - <?php else : ?> | |
| 481 | - <p>Site-wide settings may also assign categories to syndicated | |
| 482 | - posts. | |
| 483 | - <?php endif; ?> | |
| 484 | - Should <?php print esc_html( $page->these_posts_phrase() ); ?> be assigned | |
| 485 | - these <?php print esc_html( $taxonomy->labels->name ); ?> from the <a href="<?php print esc_url( $siteWideHref ); ?>">site-wide settings</a>, in | |
| 486 | - addition to the feed-specific <?php print esc_html( $taxonomy->labels->name ); ?> you set up here?</p> | |
| 487 | - | |
| 488 | - <ul class="settings"> | |
| 489 | - <li><p><label><input type="radio" name="add_global[<?php print esc_attr( $tax ); ?>]" value="yes" <?php fwp_checked_flag($checked, 'yes'); ?> /> Yes. Place <?php print esc_html( $page->these_posts_phrase() ); ?> under all these categories.</label></p></li> | |
| 490 | - <li><p><label><input type="radio" name="add_global[<?php print esc_attr( $tax ); ?>]" value="no" <?php fwp_checked_flag($checked, 'no'); ?> /> No. Only use the categories I set up on the left. Do not use the global defaults for <?php print esc_html( $page->these_posts_phrase() ); ?></label></p></li> | |
| 491 | - </ul> | |
| 492 | - </td> | |
| 493 | - </tr> | |
| 494 | - </tbody> | |
| 495 | - </table> | |
| 496 | - <?php | |
| 497 | - endif; | |
| 498 | - ?> | |
| 499 | - </td> | |
| 500 | - </tr> | |
| 501 | - <?php | |
| 502 | - endforeach; | |
| 503 | - ?> | |
| 504 | - </tbody> | |
| 505 | - </table> | |
| 506 | - <?php | |
| 507 | - } /* FeedWordPressCategoriesPage::categories_box () */ | |
| 508 | - | |
| 509 | - function save_settings () { | |
| 510 | - $match_categories = FeedWordPress::post( 'match_categories', array() ); | |
| 511 | - if ( is_array( $match_categories ) ) : | |
| 512 | - foreach ( $match_categories as $what => $set) : | |
| 513 | - // Defaulting is controlled by a separate radio button | |
| 514 | - $match_default = FeedWordPress::post( 'match_default', array() ); | |
| 515 | - $match_default_here = ( is_array( $match_default ) && array_key_exists( $what, $match_default ) ? $match_default[ $what ] : null ); | |
| 516 | - | |
| 517 | - if ( FeedWordPress::affirmative( $match_default_here ) ) : | |
| 518 | - $set = null; // Defaulted! | |
| 519 | - endif; | |
| 520 | - | |
| 521 | - $this->update_setting( "match/$what", $set, null ); | |
| 522 | - endforeach; | |
| 523 | - endif; | |
| 524 | - $optionMap = $this->term_option_map(); | |
| 525 | - $settingMap = $this->term_setting_map(); | |
| 526 | - | |
| 527 | - $saveTerms = array(); $separateSaveTerms = array('category' => array(), 'post_tag' => array()); | |
| 528 | - | |
| 529 | - $tax_input = FeedWordPress::post( 'tax_input', array() ); | |
| 530 | - $tax_input_cats = ( isset( $tax_input['category'] ) ? $tax_input['category'] : array() ); | |
| 531 | - $post_category = FeedWordPress::post( 'post_category', array() ); | |
| 532 | - | |
| 533 | - // Merge in data from older-notation category check boxes | |
| 534 | - $tax_input['category'] = array_merge( $tax_input_cats, $post_category ); | |
| 535 | - | |
| 536 | - // Process data from term tag boxes and check boxes | |
| 537 | - foreach ( $tax_input as $tax => $terms ) : | |
| 538 | - $saveTerms[ $tax ] = array(); | |
| 539 | - if (is_array($terms)) : // Numeric IDs from checklist | |
| 540 | - foreach ($terms as $term) : | |
| 541 | - if ($term) : | |
| 542 | - $saveTerms[$tax][] = '{'.$tax.'#'.$term.'}'; | |
| 543 | - endif; | |
| 544 | - endforeach; | |
| 545 | - else : // String from tag input | |
| 546 | - $saveTerms[$tax] = explode(",", $terms); | |
| 547 | - endif; | |
| 548 | - $saveTerms[$tax] = array_map('trim', $saveTerms[$tax]); | |
| 549 | - | |
| 550 | - if (isset($optionMap[$tax])) : | |
| 551 | - $separateSaveTerms[$tax] = $saveTerms[$tax]; | |
| 552 | - unset($saveTerms[$tax]); | |
| 553 | - endif; | |
| 554 | - endforeach; | |
| 555 | - | |
| 556 | - foreach ( $post_category as $cat ) : | |
| 557 | - $separateSaveTerms['category'][] = '{category#' .$cat . '}'; | |
| 558 | - endforeach; | |
| 559 | - | |
| 560 | - // Unmatched categories and tags | |
| 561 | - foreach (array('category', 'post_tag') as $what) : | |
| 562 | - $unfamiliar = FeedWordPress::post( "unfamiliar_{$what}" ); | |
| 563 | - if ( ! is_null( $unfamiliar ) ) : | |
| 564 | - $this->update_setting( | |
| 565 | - "unfamiliar {$what}", | |
| 566 | - $unfamiliar, | |
| 567 | - 'site-default' | |
| 568 | - ); | |
| 569 | - endif; | |
| 570 | - endforeach; | |
| 571 | - | |
| 572 | - // Categories and Tags | |
| 573 | - foreach ($separateSaveTerms as $tax => $terms) : | |
| 574 | - if ($this->for_feed_settings()) : | |
| 575 | - $this->link->update_setting($settingMap[$tax], $terms, array()); | |
| 576 | - else : | |
| 577 | - if ( !empty($terms)) : | |
| 578 | - update_option($optionMap[$tax], implode(FEEDWORDPRESS_CAT_SEPARATOR, $terms)); | |
| 579 | - else : | |
| 580 | - delete_option($optionMap[$tax]); | |
| 581 | - endif; | |
| 582 | - endif; | |
| 583 | - endforeach; | |
| 584 | - | |
| 585 | - // Other terms | |
| 586 | - $this->update_setting(array('feed'=>'terms', 'global'=>'syndication_terms'), $saveTerms, array()); | |
| 587 | - | |
| 588 | - if ($this->for_feed_settings()) : | |
| 589 | - // Category splitting regex | |
| 590 | - $cat_split = FeedWordPress::post( 'cat_split' ); | |
| 591 | - if ( ! is_null( $cat_split ) ) : | |
| 592 | - $this->link->update_setting( 'cat_split', trim( $cat_split ), '' ); | |
| 593 | - endif; | |
| 594 | - | |
| 595 | - // Treat global terms (cats, tags, etc.) as additional, | |
| 596 | - // or as defaults to be overridden and replaced? | |
| 597 | - $add_global = FeedWordPress::post( 'add_global', array() ); | |
| 598 | - if ( is_array( $add_global ) ) : | |
| 599 | - foreach ($add_global as $what => $value) : | |
| 600 | - $this->link->update_setting("add/$what", $value); | |
| 601 | - endforeach; | |
| 602 | - endif; | |
| 603 | - endif; | |
| 604 | - parent::save_settings(); | |
| 605 | - } /* FeedWordPressCategoriesPage::save_settings() */ | |
| 606 | - | |
| 607 | - function display () { | |
| 608 | - //////////////////////////////////////////////// | |
| 609 | - // Display settings boxes ////////////////////// | |
| 610 | - //////////////////////////////////////////////// | |
| 611 | - | |
| 612 | - $this->boxes_by_methods = array( | |
| 613 | - 'feed_categories_box' => __('Feed Categories & Tags'), | |
| 614 | - 'categories_box' => array('title' => __('Categories'), 'id' => 'categorydiv'), | |
| 615 | - ); | |
| 616 | - | |
| 617 | - parent::display(); | |
| 618 | - } | |
| 619 | -} | |
| 620 | - | |
| 621 | - $categoriesPage = new FeedWordPressCategoriesPage; | |
| 622 | - $categoriesPage->display(); | |
| 345 | + fwp_categories_page(); | |
| 623 | 346 | |