PluginProbe
FeedWordPress / 2012.1212
FeedWordPress v2012.1212
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
← All changes | categories-page.php +120 -131 trunk2012.1212 View file →
@@ -1,14 +1,14 @@
1 1 <?php
2 2 require_once(dirname(__FILE__) . '/admin-ui.php');
3 3
4 4 class FeedWordPressCategoriesPage extends FeedWordPressAdminPage {
5 - public function __construct( $link = -1 ) {
5 + function FeedWordPressCategoriesPage ($link = -1) {
6 6 if (is_numeric($link) and -1 == $link) :
7 7 $link = $this->submitted_link();
8 8 endif;
9 -
10 - parent::__construct('feedwordpresscategories', $link);
9 +
10 + FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpresscategories', $link);
11 11 $this->dispatch = 'feedwordpress_admin_page_categories';
12 12 $this->pagenames = array(
13 13 'default' => 'Categories & Tags',
14 14 'settings-update' => 'Syndicated Categories & Tags',
@@ -15,9 +15,9 @@
15 15 'open-sheet' => 'Categories & Tags',
16 16 );
17 17 $this->filename = __FILE__;
18 18 }
19 -
19 +
20 20 function unfamiliar_category_label ($name) {
21 21 if (preg_match('/^create:(.*)$/', $name, $refs)) :
22 22 $tax = get_taxonomy($refs[1]);
23 23 $name = sprintf(__('Create new %s to match them'), $tax->labels->name);
@@ -23,25 +23,13 @@
23 23 $name = sprintf(__('Create new %s to match them'), $tax->labels->name);
24 24 endif;
25 25 return $name;
26 26 }
27 -
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 27
28 +
41 29 function feed_categories_box ($page, $box = NULL) {
42 30 $link = $page->link;
43 -
31 +
44 32 $globalPostType = get_option('feedwordpress_syndicated_post_type', 'post');
45 33 if ($this->for_feed_settings()) :
46 34 $post_type = $link->setting('syndicated post type', 'syndicated_post_type', 'post');
47 35 else :
@@ -53,10 +41,10 @@
53 41 $matchUl = array('cats' => array(), 'tags' => array(), 'filter' => array());
54 42 $tagLikeTaxonomies = array();
55 43 foreach ($taxonomies as $tax) :
56 44 $taxonomy = get_taxonomy($tax);
57 -
58 - if ( ! $taxonomy->hierarchical) :
45 +
46 + if (!$taxonomy->hierarchical) :
59 47 $tagLikeTaxonomies[] = $tax;
60 48 endif;
61 49
62 50 $name = 'create:'.$tax;
@@ -73,14 +61,14 @@
73 61 'labels' => $taxonomy->labels,
74 62 );
75 63 endforeach;
76 64 endforeach;
77 -
65 +
78 66 foreach ($unmatched as $what => $um) :
79 67 $unmatched[$what]['null'] = array('label' => __('Don\'t create any matching terms'));
80 68 $unmatchedRadio[$what]['null'] = '';
81 69 endforeach;
82 -
70 +
83 71 $globalUnmatched = array(
84 72 'category' => FeedWordPress::on_unfamiliar('category'),
85 73 'post_tag' => FeedWordPress::on_unfamiliar('post_tag'),
86 74 );
@@ -88,16 +76,16 @@
88 76 if ($value=='create') : $value = 'create:category'; endif;
89 77 if ($value=='tag') : $value = 'create:post_tag'; endif;
90 78 $globalUnmatched[$what] = $value;
91 79 endforeach;
92 -
80 +
93 81 $globalMatch['cats'] = get_option('feedwordpress_match_cats', $taxonomies);
94 82 $globalMatch['tags'] = get_option('feedwordpress_match_tags', $tagLikeTaxonomies);
95 83 $globalMatch['filter'] = get_option('feedwordpress_match_filter', array());
96 -
84 +
97 85 $globalMatchLabels = array();
98 86 $nothingDoing = array('cats' => "won't try to match", 'tags' => "won't try to match", "filter" => "won't filter");
99 -
87 +
100 88 foreach ($globalMatch as $what => $domain) :
101 89 $labels = array(); $domain = array_filter($domain, 'remove_dummy_zero');
102 90 foreach ($domain as $tax) :
103 91 $tax = get_taxonomy($tax);
@@ -102,9 +90,9 @@
102 90 foreach ($domain as $tax) :
103 91 $tax = get_taxonomy($tax);
104 92 $labels[] = $tax->labels->name;
105 93 endforeach;
106 -
94 +
107 95 if (count($labels) > 0) :
108 96 $globalMatchLabels[$what] = implode(", ", $labels);
109 97 else :
110 98 $globalMatchLabels[$what] = $nothingDoing[$what];
@@ -111,9 +99,9 @@
111 99 endif;
112 100 endforeach;
113 101
114 102 if ($this->for_feed_settings()) :
115 - $href = $this->admin_page_href(basename(__FILE__));
103 + $href = "admin.php?page={$GLOBALS['fwp_path']}/".basename(__FILE__);
116 104
117 105 foreach ($unmatched as $what => $um) :
118 106 // Is the global default setting appropriate to this post type?
119 107 $GUC = $globalUnmatched[$what];
@@ -120,12 +108,15 @@
120 108 if (isset($um[$GUC])) :
121 109 // Yup. Let's add a site-default option
122 110 $currently = $um[$GUC]['label'];
123 111 $defaultLi = array(
124 - 'site-default' => array(
125 - 'label' => [ $href, $currently ],
112 + 'site-default' => array(
113 + 'label' => sprintf(
114 + __('Use the <a href="%s">site-wide setting</a> <span class="current-setting">Currently: <strong>%s</strong></span>'),
115 + $href,
116 + $currently
126 117 ),
127 - );
118 + ), );
128 119 $unmatchedColumns[$what] = array(
129 120 $defaultLi,
130 121 );
131 122 $unmatchedDefault[$what] = 'site-default';
@@ -134,33 +125,33 @@
134 125 $opts = array_keys($unmatched[$what]);
135 126 $unmatchedDefault[$what] = $opts[0];
136 127 $unmatchedColumns[$what] = array();
137 128 endif;
138 -
129 +
139 130 $ucKey[$what] = $link->setting("unfamiliar $what", NULL, NULL);
140 131 endforeach;
141 -
132 +
142 133 $match['cats'] = $this->link->setting('match/cats', NULL, NULL);
143 134 $match['tags'] = $this->link->setting('match/tags', NULL, NULL);
144 135 $match['filter'] = $this->link->setting('match/filter', NULL, NULL);
145 136 else :
146 137 foreach ($unmatched as $what => $um) :
147 - $ucKey[$what] = FeedWordPress::on_unfamiliar($what);
138 + $ucKey[$what] = FeedWordPress::on_unfamiliar($what);
148 139 endforeach;
149 140
150 141 $match = $globalMatch;
151 142 endif;
152 -
143 +
153 144 foreach ($ucKey as $what => $uck) :
154 145 if ($uck == 'tag') : $uck = 'create:post_tag'; endif;
155 146 if ($uck == 'create') : $uck = 'create:category'; endif;
156 -
157 - if ( !is_string($uck)) :
147 +
148 + if (!is_string($uck)) :
158 149 $uck = $unmatchedDefault[$what];
159 150 endif;
160 151 $ucKey[$what] = $uck;
161 -
162 - if ( !array_key_exists($uck, $unmatchedRadio[$what])) :
152 +
153 + if (!array_key_exists($uck, $unmatchedRadio[$what])) :
163 154 $obsoleteLi = array(
164 155 $uck => array(
165 156 '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 157 ),
@@ -167,14 +158,14 @@
167 158 );
168 159 $unmatched[$what] = array_merge($obsoleteLi, $unmatched[$what]);
169 160 $unmatchedRadio[$what][$uck] = ' disabled="disabled"';
170 161 endif;
171 -
162 +
172 163 $unmatchedRadio[$what][$uck] .= ' checked="checked"';
173 -
164 +
174 165 $unmatchedColumns[$what][] = $unmatched[$what];
175 166 endforeach;
176 -
167 +
177 168 $defaulted = array();
178 169 foreach ($match as $what => $set) :
179 170 $defaulted[$what] = false;
180 171 if (is_null($set) or (count($set) < 1)) :
@@ -183,10 +174,10 @@
183 174 $set = $globalMatch[$what];
184 175 $match[$what] = $globalMatch[$what];
185 176 endif;
186 177 endif;
187 -
188 - if ( ! $defaulted[$what] or $this->for_feed_settings()) :
178 +
179 + if (!$defaulted[$what] or $this->for_feed_settings()) :
189 180 foreach ($set as $against) :
190 181 if (array_key_exists($against, $matchUl[$what])) :
191 182 $matchUl[$what][$against]['checked'] = ' checked="checked"';
192 183 endif;
@@ -204,11 +195,13 @@
204 195 <?php if ($offerSiteWideSettings) : ?>
205 196 <table class="twofer">
206 197 <tbody>
207 198 <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>
199 +value="yes" <?php if ($defaulted['cats']) : ?> checked="checked"<?php endif; ?> />
200 +Use the <a href="<?php print $href; ?>">site-wide setting</a>
201 +<span class="current-setting">Currently: <strong><?php print $globalMatchLabels['cats']; ?></strong></span></label></p></td>
209 202 <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; ?> />
203 +value="no" <?php if (!$defaulted['cats']) : ?> checked="checked"<?php endif; ?> />
211 204 Do something different with this feed.</label>
212 205 <?php else : ?>
213 206 <p>
214 207 <?php endif; ?>
@@ -216,10 +209,10 @@
216 209 locally with:</p>
217 210 <ul class="options compact">
218 211 <?php foreach ($matchUl['cats'] as $name => $li) : ?>
219 212 <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>
213 + name="match_categories[cats][]" value="<?php print $name; ?>"
214 + <?php print $li['checked']; ?> /> <?php $l = $li['labels']; print $l->name; ?></label></li>
222 215 <?php endforeach; ?>
223 216 </ul>
224 217 <?php if ($offerSiteWideSettings) : ?>
225 218 </td></tr>
@@ -230,9 +223,9 @@
230 223 </tr>
231 224
232 225 <tr>
233 226 <th scope="row">Unmatched categories:</th>
234 -<td><p>When <?php print esc_html( $this->these_posts_phrase() ); ?> have categories on
227 +<td><p>When <?php print $this->these_posts_phrase(); ?> have categories on
235 228 the feed that don't have any local matches yet...</p>
236 229
237 230 <?php if (count($unmatchedColumns['category']) > 1) : ?>
238 231 <table class="twofer">
@@ -242,16 +235,11 @@
242 235 <tbody>
243 236 <tr>
244 237 <?php foreach ($unmatchedColumns['category'] as $index => $column) : ?>
245 238 <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; ?>
239 + <?php foreach ($column as $name => $li) : ?>
240 + <li><label><input type="radio" name="unfamiliar_category" value="<?php print $name; ?>"<?php print $unmatchedRadio['category'][$name]; ?> /> <?php print $li['label']; ?></label></li>
241 + <?php endforeach; ?>
254 242 </ul></td>
255 243 <?php endforeach; ?>
256 244 </tr>
257 245 </tbody>
@@ -271,12 +259,13 @@
271 259 <table class="twofer">
272 260 <tbody>
273 261 <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 262 value="yes" <?php if ($defaulted['tags']) : ?> checked="checked"<?php endif; ?> />
275 -<?php $this->setting_radio_label( array( "label" => array( $href, $globalMatchLabels['tags'] ) ) ); ?></label></p>
263 +Use the <a href="<?php print $href; ?>">site-wide setting</a>
264 +<span class="current-setting">Currently: <strong><?php print $globalMatchLabels['tags']; ?></strong></span></label></p>
276 265 </td>
277 266 <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; ?> />
267 +value="no" <?php if (!$defaulted['tags']) : ?> checked="checked"<?php endif; ?> />
279 268 Do something different with this feed.</label>
280 269 <?php else : ?>
281 270 <p>
282 271 <?php endif; ?>
@@ -284,10 +273,10 @@
284 273 locally with:</p>
285 274 <ul class="options compact">
286 275 <?php foreach ($matchUl['tags'] as $name => $li) : ?>
287 276 <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>
277 + name="match_categories[tags][]" value="<?php print $name; ?>"
278 + <?php print $li['checked']; ?> /> <?php $l = $li['labels']; print $l->name; ?></label></li>
290 279 <?php endforeach; ?>
291 280 </ul>
292 281 <?php if ($offerSiteWideSettings) : ?>
293 282 </td></tr>
@@ -298,9 +287,9 @@
298 287 </tr>
299 288
300 289 <tr>
301 290 <th scope="row">Unmatched inline tags:</th>
302 -<td><p>When the text of <?php print esc_html( $this->these_posts_phrase() ); ?> contains
291 +<td><p>When the text of <?php print $this->these_posts_phrase(); ?> contains
303 292 inline tags that don't have any local matches yet...</p>
304 293
305 294 <?php if (count($unmatchedColumns['post_tag']) > 1) : ?>
306 295 <table class="twofer">
@@ -311,9 +300,9 @@
311 300 <tr>
312 301 <?php foreach ($unmatchedColumns['post_tag'] as $index => $column) : ?>
313 302 <td class="equals <?php print (($index == 0) ? 'first' : 'second'); ?> inactive"><ul class="options">
314 303 <?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>
304 + <li><label><input type="radio" name="unfamiliar_post_tag" value="<?php print $name; ?>"<?php print $unmatchedRadio['post_tag'][$name]; ?> /> <?php print $li['label']; ?></label></li>
316 305 <?php endforeach; ?>
317 306 </ul></td>
318 307 <?php endforeach; ?>
319 308 </tr>
@@ -331,13 +320,14 @@
331 320 <tr>
332 321 <td class="equals first <?php if ($defaulted['filter']) : ?>active<?php else: ?>inactive<?php endif; ?>">
333 322 <p><label><input type="radio" name="match_default[filter]"
334 323 value="yes" <?php if ($defaulted['filter']) : ?> checked="checked"<?php endif; ?> />
335 -<?php $this->setting_radio_label( array( "label" => array( $href, $globalMatchLabels['filter'] ) ) ); ?></label></p>
324 +Use the <a href="<?php print $href; ?>">site-wide setting</a>
325 +<span class="current-setting">Currently: <strong><?php print $globalMatchLabels['filter']; ?></strong></span></label></p>
336 326 </td>
337 327 <td class="equals second <?php if ($defaulted['filter']) : ?>inactive<?php else: ?>active<?php endif; ?>">
338 328 <p><label><input type="radio" name="match_default[filter]"
339 -value="no" <?php if ( ! $defaulted['filter']) : ?> checked="checked"<?php endif; ?> />
329 +value="no" <?php if (!$defaulted['filter']) : ?> checked="checked"<?php endif; ?> />
340 330 Do something different with this feed:</label></p>
341 331 <div style="margin-left: 3.0em;">
342 332 <?php endif; ?>
343 333
@@ -342,11 +332,11 @@
342 332 <?php endif; ?>
343 333
344 334 <ul class="options">
345 335 <?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>
336 +<li><label><input type="checkbox" name="match_categories[filter][]" value="<?php print $tax; ?>"
337 +<?php print $li['checked']; ?> /> Don't syndicate posts unless they match at
338 +least one local <strong><?php $l = $li['labels']; print $l->singular_name; ?></strong></label></li>
349 339 <?php endforeach; ?>
350 340 </ul>
351 341
352 342 <?php if ($offerSiteWideSettings) : ?>
@@ -359,10 +349,10 @@
359 349 </tr>
360 350 <?php if ($page->for_feed_settings()) : ?>
361 351 <tr>
362 352 <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; ?>" />
353 +<td>
354 +<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 355 <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 356 categories in a single category element. The regular expression should match
367 357 the characters used to separate one category from the next. If the feed uses
368 358 spaces (like <a href="http://del.icio.us/">del.icio.us</a>), use the pattern "\s".
@@ -385,13 +375,11 @@
385 375 'category' => 'cats',
386 376 'post_tag' => 'tags',
387 377 );
388 378 }
389 -
379 +
390 380 function categories_box ($page, $box = NULL) {
391 381 $link = $page->link;
392 - $dummy = null;
393 - $syndicatedlink = new SyndicatedLink($dummy);
394 382
395 383 if ($this->for_feed_settings()) :
396 384 $post_type = $link->setting('syndicated post type', 'syndicated_post_type', 'post');
397 385 else :
@@ -412,9 +400,9 @@
412 400 <?php
413 401 foreach ($taxonomies as $tax) :
414 402 $taxonomy = get_taxonomy($tax);
415 403 ?>
416 - <tr><th><?php print esc_html( $taxonomy->labels->name ); ?></th>
404 + <tr><th><?php print $taxonomy->labels->name; ?></th>
417 405 <td><?php
418 406 if (isset($option_map[$tax])) :
419 407 $option = $option_map[$tax];
420 408 $globalCats = preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, get_option($option));
@@ -428,9 +416,9 @@
428 416 if ($page->for_feed_settings()) :
429 417 $add_global_categories = $link->setting("add/$tax", NULL, 'yes');
430 418 $checked = array('yes' => '', 'no' => '');
431 419 $checked[$add_global_categories] = ' checked="checked"';
432 -
420 +
433 421 if (isset($setting_map[$tax])) :
434 422 $setting = $setting_map[$tax];
435 423 $cats = $link->setting($setting, NULL, NULL);
436 424 if (is_null($cats)) : $cats = array(); endif;
@@ -441,9 +429,9 @@
441 429 endif;
442 430 else :
443 431 $cats = $globalCats;
444 432 endif;
445 -
433 +
446 434 if ($page->for_feed_settings()) :
447 435 ?>
448 436 <table class="twofer">
449 437 <tbody>
@@ -450,30 +438,29 @@
450 438 <tr>
451 439 <td class="primary">
452 440 <?php
453 441 endif;
454 -
455 - $dogs = $syndicatedlink->category_ids(/*post=*/ NULL, $cats, /*unfamiliar=*/ NULL, /*taxonomies=*/ array($tax));
456 442
443 + $dogs = SyndicatedPost::category_ids($cats, /*unfamiliar=*/ NULL, /*taxonomies=*/ array($tax));
444 +
457 445 if ($taxonomy->hierarchical) : // Use a category-style checkbox
458 446 fwp_category_box($dogs, 'all '.$page->these_posts_phrase(), /*tags=*/ array(), /*params=*/ array('taxonomy' => $tax));
459 447 else : // Use a tag-style edit box
460 448 fwp_tags_box($cats, 'all '.$page->these_posts_phrase(), /*params=*/ array('taxonomy' => $tax));
461 449 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 -
450 +
451 + $globalDogs = SyndicatedPost::category_ids($globalCats, /*unfamiliar=*/ 'create:'.$tax, /*taxonomies=*/ array($tax));
452 +
453 + $siteWideHref = 'admin.php?page='.$GLOBALS['fwp_path'].'/'.basename(__FILE__);
467 454 if ($page->for_feed_settings()) :
468 455 ?>
469 456 </td>
470 457 <td class="secondary">
471 - <h4>Site-wide <?php print esc_html( $taxonomy->labels->name ); ?></h4>
458 + <h4>Site-wide <?php print $taxonomy->labels->name; ?></h4>
472 459 <?php if (count($globalCats) > 0) : ?>
473 460 <ul class="current-setting">
474 461 <?php foreach ($globalDogs as $dog) : ?>
475 - <li><?php $cat = get_term($dog, $tax); print esc_html( $cat->name ); ?></li>
462 + <li><?php $cat = get_term($dog, $tax); print $cat->name; ?></li>
476 463 <?php endforeach; ?>
477 464 </ul>
478 465 </div>
479 466 <p>
@@ -480,15 +467,15 @@
480 467 <?php else : ?>
481 468 <p>Site-wide settings may also assign categories to syndicated
482 469 posts.
483 470 <?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 -
471 + Should <?php print $page->these_posts_phrase(); ?> be assigned
472 + these <?php print $taxonomy->labels->name; ?> from the <a href="<?php print esc_html($siteWideHref); ?>">site-wide settings</a>, in
473 + addition to the feed-specific <?php print $taxonomy->labels->name; ?> you set up here?</p>
474 +
488 475 <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>
476 + <li><p><label><input type="radio" name="add_global[<?php print $tax; ?>]" value="yes" <?php print $checked['yes']; ?> /> Yes. Place <?php print $page->these_posts_phrase(); ?> under all these categories.</label></p></li>
477 + <li><p><label><input type="radio" name="add_global[<?php print $tax; ?>]" value="no" <?php print $checked['no']; ?> /> No. Only use the categories I set up on the left. Do not use the global defaults for <?php print $page->these_posts_phrase(); ?></label></p></li>
491 478 </ul>
492 479 </td>
493 480 </tr>
494 481 </tbody>
@@ -504,22 +491,21 @@
504 491 </tbody>
505 492 </table>
506 493 <?php
507 494 } /* 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) :
495 +
496 + function save_settings ($post) {
497 + if (isset($post['match_categories'])) :
498 + foreach ($post['match_categories'] as $what => $set) :
513 499 // 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!
500 + if ($this->for_feed_settings()
501 + and isset($post['match_default'])
502 + and isset($post['match_default'][$what])
503 + and $post['match_default'][$what]=='yes') :
504 + $set = NULL; // Defaulted!
519 505 endif;
520 -
521 - $this->update_setting( "match/$what", $set, null );
506 +
507 + $this->update_setting("match/$what", $set, NULL);
522 508 endforeach;
523 509 endif;
524 510 $optionMap = $this->term_option_map();
525 511 $settingMap = $this->term_setting_map();
@@ -524,19 +510,23 @@
524 510 $optionMap = $this->term_option_map();
525 511 $settingMap = $this->term_setting_map();
526 512
527 513 $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 514
515 + if (!isset($post['tax_input'])) : $post['tax_input'] = array(); endif;
516 +
533 517 // Merge in data from older-notation category check boxes
534 - $tax_input['category'] = array_merge( $tax_input_cats, $post_category );
518 + if (isset($post['post_category'])) :
519 + // Just merging in for processing below.
520 + $post['tax_input']['category'] = array_merge(
521 + (isset($post['tax_input']['category']) ? $post['tax_input']['category'] : array()),
522 + $post['post_category']
523 + );
524 + endif;
535 525
536 526 // Process data from term tag boxes and check boxes
537 - foreach ( $tax_input as $tax => $terms ) :
538 - $saveTerms[ $tax ] = array();
527 + foreach ($post['tax_input'] as $tax => $terms) :
528 + $saveTerms[$tax] = array();
539 529 if (is_array($terms)) : // Numeric IDs from checklist
540 530 foreach ($terms as $term) :
541 531 if ($term) :
542 532 $saveTerms[$tax][] = '{'.$tax.'#'.$term.'}';
@@ -545,9 +535,9 @@
545 535 else : // String from tag input
546 536 $saveTerms[$tax] = explode(",", $terms);
547 537 endif;
548 538 $saveTerms[$tax] = array_map('trim', $saveTerms[$tax]);
549 -
539 +
550 540 if (isset($optionMap[$tax])) :
551 541 $separateSaveTerms[$tax] = $saveTerms[$tax];
552 542 unset($saveTerms[$tax]);
553 543 endif;
@@ -552,30 +542,31 @@
552 542 unset($saveTerms[$tax]);
553 543 endif;
554 544 endforeach;
555 545
556 - foreach ( $post_category as $cat ) :
557 - $separateSaveTerms['category'][] = '{category#' .$cat . '}';
558 - endforeach;
559 -
546 + if (isset($post['post_category'])) :
547 + foreach ($post['post_category'] as $cat) :
548 + $separateSaveTerms['category'][] = '{category#'.$cat.'}';
549 + endforeach;
550 + endif;
551 +
560 552 // Unmatched categories and tags
561 553 foreach (array('category', 'post_tag') as $what) :
562 - $unfamiliar = FeedWordPress::post( "unfamiliar_{$what}" );
563 - if ( ! is_null( $unfamiliar ) ) :
554 + if (isset($post["unfamiliar_{$what}"])) :
564 555 $this->update_setting(
565 556 "unfamiliar {$what}",
566 - $unfamiliar,
557 + $post["unfamiliar_{$what}"],
567 558 'site-default'
568 559 );
569 560 endif;
570 561 endforeach;
571 -
562 +
572 563 // Categories and Tags
573 564 foreach ($separateSaveTerms as $tax => $terms) :
574 565 if ($this->for_feed_settings()) :
575 566 $this->link->update_setting($settingMap[$tax], $terms, array());
576 567 else :
577 - if ( !empty($terms)) :
568 + if (!empty($terms)) :
578 569 update_option($optionMap[$tax], implode(FEEDWORDPRESS_CAT_SEPARATOR, $terms));
579 570 else :
580 571 delete_option($optionMap[$tax]);
581 572 endif;
@@ -580,42 +571,40 @@
580 571 delete_option($optionMap[$tax]);
581 572 endif;
582 573 endif;
583 574 endforeach;
584 -
575 +
585 576 // Other terms
586 577 $this->update_setting(array('feed'=>'terms', 'global'=>'syndication_terms'), $saveTerms, array());
587 578
588 579 if ($this->for_feed_settings()) :
589 580 // 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 ), '' );
581 + if (isset($post['cat_split'])) :
582 + $this->link->update_setting('cat_split', trim($post['cat_split']), '');
593 583 endif;
594 -
584 +
595 585 // Treat global terms (cats, tags, etc.) as additional,
596 586 // 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) :
587 + if (isset($post['add_global'])) :
588 + foreach ($post['add_global'] as $what => $value) :
600 589 $this->link->update_setting("add/$what", $value);
601 590 endforeach;
602 591 endif;
603 592 endif;
604 - parent::save_settings();
593 + parent::save_settings($post);
605 594 } /* FeedWordPressCategoriesPage::save_settings() */
606 -
595 +
607 596 function display () {
608 597 ////////////////////////////////////////////////
609 598 // Display settings boxes //////////////////////
610 599 ////////////////////////////////////////////////
611 -
600 +
612 601 $this->boxes_by_methods = array(
613 602 'feed_categories_box' => __('Feed Categories & Tags'),
614 603 'categories_box' => array('title' => __('Categories'), 'id' => 'categorydiv'),
615 604 );
616 605
617 - parent::display();
606 + parent::display();
618 607 }
619 608 }
620 609
621 610 $categoriesPage = new FeedWordPressCategoriesPage;