PluginProbe
FeedWordPress / 2015.0514
FeedWordPress v2015.0514
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 +78 -86 trunk2015.0514 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 9
10 - parent::__construct('feedwordpresscategories', $link);
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',
@@ -24,21 +24,9 @@
24 24 endif;
25 25 return $name;
26 26 }
27 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 -
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');
@@ -54,9 +42,9 @@
54 42 $tagLikeTaxonomies = array();
55 43 foreach ($taxonomies as $tax) :
56 44 $taxonomy = get_taxonomy($tax);
57 45
58 - if ( ! $taxonomy->hierarchical) :
46 + if (!$taxonomy->hierarchical) :
59 47 $tagLikeTaxonomies[] = $tax;
60 48 endif;
61 49
62 50 $name = 'create:'.$tax;
@@ -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';
@@ -153,14 +144,14 @@
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 147
157 - if ( !is_string($uck)) :
148 + if (!is_string($uck)) :
158 149 $uck = $unmatchedDefault[$what];
159 150 endif;
160 151 $ucKey[$what] = $uck;
161 152
162 - if ( !array_key_exists($uck, $unmatchedRadio[$what])) :
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 ),
@@ -184,9 +175,9 @@
184 175 $match[$what] = $globalMatch[$what];
185 176 endif;
186 177 endif;
187 178
188 - if ( ! $defaulted[$what] or $this->for_feed_settings()) :
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) : ?>
@@ -360,9 +350,9 @@
360 350 <?php if ($page->for_feed_settings()) : ?>
361 351 <tr>
362 352 <th scope="row">Multiple categories:</th>
363 353 <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; ?>" />
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".
@@ -412,9 +402,9 @@
412 402 <?php
413 403 foreach ($taxonomies as $tax) :
414 404 $taxonomy = get_taxonomy($tax);
415 405 ?>
416 - <tr><th><?php print esc_html( $taxonomy->labels->name ); ?></th>
406 + <tr><th><?php print $taxonomy->labels->name; ?></th>
417 407 <td><?php
418 408 if (isset($option_map[$tax])) :
419 409 $option = $option_map[$tax];
420 410 $globalCats = preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, get_option($option));
@@ -467,13 +457,13 @@
467 457 if ($page->for_feed_settings()) :
468 458 ?>
469 459 </td>
470 460 <td class="secondary">
471 - <h4>Site-wide <?php print esc_html( $taxonomy->labels->name ); ?></h4>
461 + <h4>Site-wide <?php print $taxonomy->labels->name; ?></h4>
472 462 <?php if (count($globalCats) > 0) : ?>
473 463 <ul class="current-setting">
474 464 <?php foreach ($globalDogs as $dog) : ?>
475 - <li><?php $cat = get_term($dog, $tax); print esc_html( $cat->name ); ?></li>
465 + <li><?php $cat = get_term($dog, $tax); print $cat->name; ?></li>
476 466 <?php endforeach; ?>
477 467 </ul>
478 468 </div>
479 469 <p>
@@ -480,15 +470,15 @@
480 470 <?php else : ?>
481 471 <p>Site-wide settings may also assign categories to syndicated
482 472 posts.
483 473 <?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>
474 + Should <?php print $page->these_posts_phrase(); ?> be assigned
475 + these <?php print $taxonomy->labels->name; ?> from the <a href="<?php print esc_html($siteWideHref); ?>">site-wide settings</a>, in
476 + addition to the feed-specific <?php print $taxonomy->labels->name; ?> you set up here?</p>
487 477
488 478 <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>
479 + <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>
480 + <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 481 </ul>
492 482 </td>
493 483 </tr>
494 484 </tbody>
@@ -505,21 +495,20 @@
505 495 </table>
506 496 <?php
507 497 } /* FeedWordPressCategoriesPage::categories_box () */
508 498
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) :
499 + function save_settings ($post) {
500 + if (isset($post['match_categories'])) :
501 + foreach ($post['match_categories'] as $what => $set) :
513 502 // 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!
503 + if ($this->for_feed_settings()
504 + and isset($post['match_default'])
505 + and isset($post['match_default'][$what])
506 + and $post['match_default'][$what]=='yes') :
507 + $set = NULL; // Defaulted!
519 508 endif;
520 509
521 - $this->update_setting( "match/$what", $set, null );
510 + $this->update_setting("match/$what", $set, NULL);
522 511 endforeach;
523 512 endif;
524 513 $optionMap = $this->term_option_map();
525 514 $settingMap = $this->term_setting_map();
@@ -525,18 +514,22 @@
525 514 $settingMap = $this->term_setting_map();
526 515
527 516 $saveTerms = array(); $separateSaveTerms = array('category' => array(), 'post_tag' => array());
528 517
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 -
518 + if (!isset($post['tax_input'])) : $post['tax_input'] = array(); endif;
519 +
533 520 // Merge in data from older-notation category check boxes
534 - $tax_input['category'] = array_merge( $tax_input_cats, $post_category );
521 + if (isset($post['post_category'])) :
522 + // Just merging in for processing below.
523 + $post['tax_input']['category'] = array_merge(
524 + (isset($post['tax_input']['category']) ? $post['tax_input']['category'] : array()),
525 + $post['post_category']
526 + );
527 + endif;
535 528
536 529 // Process data from term tag boxes and check boxes
537 - foreach ( $tax_input as $tax => $terms ) :
538 - $saveTerms[ $tax ] = array();
530 + foreach ($post['tax_input'] as $tax => $terms) :
531 + $saveTerms[$tax] = array();
539 532 if (is_array($terms)) : // Numeric IDs from checklist
540 533 foreach ($terms as $term) :
541 534 if ($term) :
542 535 $saveTerms[$tax][] = '{'.$tax.'#'.$term.'}';
@@ -552,19 +545,20 @@
552 545 unset($saveTerms[$tax]);
553 546 endif;
554 547 endforeach;
555 548
556 - foreach ( $post_category as $cat ) :
557 - $separateSaveTerms['category'][] = '{category#' .$cat . '}';
558 - endforeach;
549 + if (isset($post['post_category'])) :
550 + foreach ($post['post_category'] as $cat) :
551 + $separateSaveTerms['category'][] = '{category#'.$cat.'}';
552 + endforeach;
553 + endif;
559 554
560 555 // Unmatched categories and tags
561 556 foreach (array('category', 'post_tag') as $what) :
562 - $unfamiliar = FeedWordPress::post( "unfamiliar_{$what}" );
563 - if ( ! is_null( $unfamiliar ) ) :
557 + if (isset($post["unfamiliar_{$what}"])) :
564 558 $this->update_setting(
565 559 "unfamiliar {$what}",
566 - $unfamiliar,
560 + $post["unfamiliar_{$what}"],
567 561 'site-default'
568 562 );
569 563 endif;
570 564 endforeach;
@@ -573,9 +567,9 @@
573 567 foreach ($separateSaveTerms as $tax => $terms) :
574 568 if ($this->for_feed_settings()) :
575 569 $this->link->update_setting($settingMap[$tax], $terms, array());
576 570 else :
577 - if ( !empty($terms)) :
571 + if (!empty($terms)) :
578 572 update_option($optionMap[$tax], implode(FEEDWORDPRESS_CAT_SEPARATOR, $terms));
579 573 else :
580 574 delete_option($optionMap[$tax]);
581 575 endif;
@@ -586,23 +580,21 @@
586 580 $this->update_setting(array('feed'=>'terms', 'global'=>'syndication_terms'), $saveTerms, array());
587 581
588 582 if ($this->for_feed_settings()) :
589 583 // 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 ), '' );
584 + if (isset($post['cat_split'])) :
585 + $this->link->update_setting('cat_split', trim($post['cat_split']), '');
593 586 endif;
594 587
595 588 // Treat global terms (cats, tags, etc.) as additional,
596 589 // 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) :
590 + if (isset($post['add_global'])) :
591 + foreach ($post['add_global'] as $what => $value) :
600 592 $this->link->update_setting("add/$what", $value);
601 593 endforeach;
602 594 endif;
603 595 endif;
604 - parent::save_settings();
596 + parent::save_settings($post);
605 597 } /* FeedWordPressCategoriesPage::save_settings() */
606 598
607 599 function display () {
608 600 ////////////////////////////////////////////////