PluginProbe
FeedWordPress / 2013.0504
FeedWordPress v2013.0504
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 +118 -128 trunk2013.0504 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];
@@ -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,19 +438,19 @@
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 -
450 +
451 + $globalDogs = SyndicatedPost::category_ids($globalCats, /*unfamiliar=*/ 'create:'.$tax, /*taxonomies=*/ array($tax));
452 +
465 453 $siteWideHref = $this->admin_page_href(basename(__FILE__));
466 454
467 455 if ($page->for_feed_settings()) :
468 456 ?>
@@ -467,13 +455,13 @@
467 455 if ($page->for_feed_settings()) :
468 456 ?>
469 457 </td>
470 458 <td class="secondary">
471 - <h4>Site-wide <?php print esc_html( $taxonomy->labels->name ); ?></h4>
459 + <h4>Site-wide <?php print $taxonomy->labels->name; ?></h4>
472 460 <?php if (count($globalCats) > 0) : ?>
473 461 <ul class="current-setting">
474 462 <?php foreach ($globalDogs as $dog) : ?>
475 - <li><?php $cat = get_term($dog, $tax); print esc_html( $cat->name ); ?></li>
463 + <li><?php $cat = get_term($dog, $tax); print $cat->name; ?></li>
476 464 <?php endforeach; ?>
477 465 </ul>
478 466 </div>
479 467 <p>
@@ -480,15 +468,15 @@
480 468 <?php else : ?>
481 469 <p>Site-wide settings may also assign categories to syndicated
482 470 posts.
483 471 <?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 -
472 + Should <?php print $page->these_posts_phrase(); ?> be assigned
473 + these <?php print $taxonomy->labels->name; ?> from the <a href="<?php print esc_html($siteWideHref); ?>">site-wide settings</a>, in
474 + addition to the feed-specific <?php print $taxonomy->labels->name; ?> you set up here?</p>
475 +
488 476 <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>
477 + <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>
478 + <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 479 </ul>
492 480 </td>
493 481 </tr>
494 482 </tbody>
@@ -504,22 +492,21 @@
504 492 </tbody>
505 493 </table>
506 494 <?php
507 495 } /* 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) :
496 +
497 + function save_settings ($post) {
498 + if (isset($post['match_categories'])) :
499 + foreach ($post['match_categories'] as $what => $set) :
513 500 // 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!
501 + if ($this->for_feed_settings()
502 + and isset($post['match_default'])
503 + and isset($post['match_default'][$what])
504 + and $post['match_default'][$what]=='yes') :
505 + $set = NULL; // Defaulted!
519 506 endif;
520 -
521 - $this->update_setting( "match/$what", $set, null );
507 +
508 + $this->update_setting("match/$what", $set, NULL);
522 509 endforeach;
523 510 endif;
524 511 $optionMap = $this->term_option_map();
525 512 $settingMap = $this->term_setting_map();
@@ -524,19 +511,23 @@
524 511 $optionMap = $this->term_option_map();
525 512 $settingMap = $this->term_setting_map();
526 513
527 514 $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 515
516 + if (!isset($post['tax_input'])) : $post['tax_input'] = array(); endif;
517 +
533 518 // Merge in data from older-notation category check boxes
534 - $tax_input['category'] = array_merge( $tax_input_cats, $post_category );
519 + if (isset($post['post_category'])) :
520 + // Just merging in for processing below.
521 + $post['tax_input']['category'] = array_merge(
522 + (isset($post['tax_input']['category']) ? $post['tax_input']['category'] : array()),
523 + $post['post_category']
524 + );
525 + endif;
535 526
536 527 // Process data from term tag boxes and check boxes
537 - foreach ( $tax_input as $tax => $terms ) :
538 - $saveTerms[ $tax ] = array();
528 + foreach ($post['tax_input'] as $tax => $terms) :
529 + $saveTerms[$tax] = array();
539 530 if (is_array($terms)) : // Numeric IDs from checklist
540 531 foreach ($terms as $term) :
541 532 if ($term) :
542 533 $saveTerms[$tax][] = '{'.$tax.'#'.$term.'}';
@@ -545,9 +536,9 @@
545 536 else : // String from tag input
546 537 $saveTerms[$tax] = explode(",", $terms);
547 538 endif;
548 539 $saveTerms[$tax] = array_map('trim', $saveTerms[$tax]);
549 -
540 +
550 541 if (isset($optionMap[$tax])) :
551 542 $separateSaveTerms[$tax] = $saveTerms[$tax];
552 543 unset($saveTerms[$tax]);
553 544 endif;
@@ -552,30 +543,31 @@
552 543 unset($saveTerms[$tax]);
553 544 endif;
554 545 endforeach;
555 546
556 - foreach ( $post_category as $cat ) :
557 - $separateSaveTerms['category'][] = '{category#' .$cat . '}';
558 - endforeach;
559 -
547 + if (isset($post['post_category'])) :
548 + foreach ($post['post_category'] as $cat) :
549 + $separateSaveTerms['category'][] = '{category#'.$cat.'}';
550 + endforeach;
551 + endif;
552 +
560 553 // Unmatched categories and tags
561 554 foreach (array('category', 'post_tag') as $what) :
562 - $unfamiliar = FeedWordPress::post( "unfamiliar_{$what}" );
563 - if ( ! is_null( $unfamiliar ) ) :
555 + if (isset($post["unfamiliar_{$what}"])) :
564 556 $this->update_setting(
565 557 "unfamiliar {$what}",
566 - $unfamiliar,
558 + $post["unfamiliar_{$what}"],
567 559 'site-default'
568 560 );
569 561 endif;
570 562 endforeach;
571 -
563 +
572 564 // Categories and Tags
573 565 foreach ($separateSaveTerms as $tax => $terms) :
574 566 if ($this->for_feed_settings()) :
575 567 $this->link->update_setting($settingMap[$tax], $terms, array());
576 568 else :
577 - if ( !empty($terms)) :
569 + if (!empty($terms)) :
578 570 update_option($optionMap[$tax], implode(FEEDWORDPRESS_CAT_SEPARATOR, $terms));
579 571 else :
580 572 delete_option($optionMap[$tax]);
581 573 endif;
@@ -580,42 +572,40 @@
580 572 delete_option($optionMap[$tax]);
581 573 endif;
582 574 endif;
583 575 endforeach;
584 -
576 +
585 577 // Other terms
586 578 $this->update_setting(array('feed'=>'terms', 'global'=>'syndication_terms'), $saveTerms, array());
587 579
588 580 if ($this->for_feed_settings()) :
589 581 // 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 ), '' );
582 + if (isset($post['cat_split'])) :
583 + $this->link->update_setting('cat_split', trim($post['cat_split']), '');
593 584 endif;
594 -
585 +
595 586 // Treat global terms (cats, tags, etc.) as additional,
596 587 // 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) :
588 + if (isset($post['add_global'])) :
589 + foreach ($post['add_global'] as $what => $value) :
600 590 $this->link->update_setting("add/$what", $value);
601 591 endforeach;
602 592 endif;
603 593 endif;
604 - parent::save_settings();
594 + parent::save_settings($post);
605 595 } /* FeedWordPressCategoriesPage::save_settings() */
606 -
596 +
607 597 function display () {
608 598 ////////////////////////////////////////////////
609 599 // Display settings boxes //////////////////////
610 600 ////////////////////////////////////////////////
611 -
601 +
612 602 $this->boxes_by_methods = array(
613 603 'feed_categories_box' => __('Feed Categories & Tags'),
614 604 'categories_box' => array('title' => __('Categories'), 'id' => 'categorydiv'),
615 605 );
616 606
617 - parent::display();
607 + parent::display();
618 608 }
619 609 }
620 610
621 611 $categoriesPage = new FeedWordPressCategoriesPage;