submitted_link(); endif; FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpresscategories', $link); $this->dispatch = 'feedwordpress_admin_page_categories'; $this->pagenames = array( 'default' => 'Categories & Tags', 'settings-update' => 'Syndicated Categories & Tags', 'open-sheet' => 'Categories & Tags', ); $this->filename = __FILE__; } function unfamiliar_category_label ($name) { if (preg_match('/^create:(.*)$/', $name, $refs)) : $tax = get_taxonomy($refs[1]); $name = sprintf(__('Create new %s to match them'), $tax->labels->name); endif; return $name; } function feed_categories_box ($page, $box = NULL) { $link = $page->link; $globalPostType = get_option('feedwordpress_syndicated_post_type', 'post'); if ($this->for_feed_settings()) : $post_type = $link->setting('syndicated post type', 'syndicated_post_type', 'post'); else : $post_type = $globalPostType; endif; $taxonomies = get_object_taxonomies(array('object_type' => $post_type), 'names'); $unmatched = array('category' => array(), 'post_tag' => array()); $matchUl = array('cats' => array(), 'tags' => array(), 'filter' => array()); $tagLikeTaxonomies = array(); foreach ($taxonomies as $tax) : $taxonomy = get_taxonomy($tax); if (!$taxonomy->hierarchical) : $tagLikeTaxonomies[] = $tax; endif; $name = 'create:'.$tax; foreach (array('category', 'post_tag') as $what) : $unmatched[$what][$name] = array( 'label' => $this->unfamiliar_category_label($name), ); $unmatchedRadio[$what][$name] = ''; endforeach; foreach (array('cats', 'tags', 'filter') as $what) : $matchUl[$what][$tax] = array( 'checked' => '', 'labels' => $taxonomy->labels, ); endforeach; endforeach; foreach ($unmatched as $what => $um) : $unmatched[$what]['null'] = array('label' => __('Don\'t create any matching terms')); $unmatchedRadio[$what]['null'] = ''; endforeach; $globalUnmatched = array( 'category' => FeedWordPress::on_unfamiliar('category'), 'post_tag' => FeedWordPress::on_unfamiliar('post_tag'), ); foreach ($globalUnmatched as $what => $value) : if ($value=='create') : $value = 'create:category'; endif; if ($value=='tag') : $value = 'create:post_tag'; endif; $globalUnmatched[$what] = $value; endforeach; $globalMatch['cats'] = get_option('feedwordpress_match_cats', $taxonomies); $globalMatch['tags'] = get_option('feedwordpress_match_tags', $tagLikeTaxonomies); $globalMatch['filter'] = get_option('feedwordpress_match_filter', array()); $globalMatchLabels = array(); $nothingDoing = array('cats' => "won't try to match", 'tags' => "won't try to match", "filter" => "won't filter"); foreach ($globalMatch as $what => $domain) : $labels = array(); $domain = array_filter($domain, 'remove_dummy_zero'); foreach ($domain as $tax) : $tax = get_taxonomy($tax); $labels[] = $tax->labels->name; endforeach; if (count($labels) > 0) : $globalMatchLabels[$what] = implode(", ", $labels); else : $globalMatchLabels[$what] = $nothingDoing[$what]; endif; endforeach; if ($this->for_feed_settings()) : $href = $this->admin_page_href(basename(__FILE__)); foreach ($unmatched as $what => $um) : // Is the global default setting appropriate to this post type? $GUC = $globalUnmatched[$what]; if (isset($um[$GUC])) : // Yup. Let's add a site-default option $currently = $um[$GUC]['label']; $defaultLi = array( 'site-default' => array( 'label' => sprintf( __('Use the site-wide setting Currently: %s'), $href, $currently ), ), ); $unmatchedColumns[$what] = array( $defaultLi, ); $unmatchedDefault[$what] = 'site-default'; $unmatchedRadio[$what]['site-default'] = ''; else : $opts = array_keys($unmatched[$what]); $unmatchedDefault[$what] = $opts[0]; $unmatchedColumns[$what] = array(); endif; $ucKey[$what] = $link->setting("unfamiliar $what", NULL, NULL); endforeach; $match['cats'] = $this->link->setting('match/cats', NULL, NULL); $match['tags'] = $this->link->setting('match/tags', NULL, NULL); $match['filter'] = $this->link->setting('match/filter', NULL, NULL); else : foreach ($unmatched as $what => $um) : $ucKey[$what] = FeedWordPress::on_unfamiliar($what); endforeach; $match = $globalMatch; endif; foreach ($ucKey as $what => $uck) : if ($uck == 'tag') : $uck = 'create:post_tag'; endif; if ($uck == 'create') : $uck = 'create:category'; endif; if (!is_string($uck)) : $uck = $unmatchedDefault[$what]; endif; $ucKey[$what] = $uck; if (!array_key_exists($uck, $unmatchedRadio[$what])) : $obsoleteLi = array( $uck => array( 'label' => ' '.$this->unfamiliar_category_label($uck).' (This setting is no longer applicable to the type of post syndicated from this feed!)

Please change this one of the following settings:

', ), ); $unmatched[$what] = array_merge($obsoleteLi, $unmatched[$what]); $unmatchedRadio[$what][$uck] = ' disabled="disabled"'; endif; $unmatchedRadio[$what][$uck] .= ' checked="checked"'; $unmatchedColumns[$what][] = $unmatched[$what]; endforeach; $defaulted = array(); foreach ($match as $what => $set) : $defaulted[$what] = false; if (is_null($set) or (count($set) < 1)) : $defaulted[$what] = true; if ($this->for_feed_settings()) : $set = $globalMatch[$what]; $match[$what] = $globalMatch[$what]; endif; endif; if (!$defaulted[$what] or $this->for_feed_settings()) : foreach ($set as $against) : if (array_key_exists($against, $matchUl[$what])) : $matchUl[$what][$against]['checked'] = ' checked="checked"'; endif; endforeach; endif; endforeach; // Hey ho, let's go... $offerSiteWideSettings = ($page->for_feed_settings() and ($post_type==$globalPostType)); ?> for_feed_settings()) : ?>
Match feed categories:

When a feed provides categories for a post, try to match those categories locally with:

    $li) : ?>
Unmatched categories:

When these_posts_phrase(); ?> have categories on the feed that don't have any local matches yet...

1) : ?>
$column) : ?>
    $li) : ?>
Match inline tags:

Applies only to inline tags marked as links in the text of syndicated posts, using the <a rel="tag">...</a> microformat. Most feeds with "tags" just treat them as normal feed categories, like those handled above.

When a feed provides tags inline in a post, try to match those tags locally with:

    $li) : ?>
Unmatched inline tags:

When the text of these_posts_phrase(); ?> contains inline tags that don't have any local matches yet...

1) : ?>
$column) : ?>
    $li) : ?>
Filter:

    $li) : ?>
Multiple categories:

Enter a Perl-compatible regular expression here if the feed provides multiple categories in a single category element. The regular expression should match the characters used to separate one category from the next. If the feed uses spaces (like del.icio.us), use the pattern "\s". If the feed does not provide multiple categories in a single element, leave this blank.

'feedwordpress_syndication_cats', 'post_tag' => 'feedwordpress_syndication_tags', ); } function term_setting_map () { return array( 'category' => 'cats', 'post_tag' => 'tags', ); } function categories_box ($page, $box = NULL) { $link = $page->link; if ($this->for_feed_settings()) : $post_type = $link->setting('syndicated post type', 'syndicated_post_type', 'post'); else : $post_type = get_option('feedwordpress_syndicated_post_type', 'post'); endif; $taxonomies = get_object_taxonomies(array('object_type' => $post_type), 'names'); $option_map = $this->term_option_map(); $setting_map = $this->term_setting_map(); $globalTax = get_option('feedwordpress_syndication_terms', array()); if ($page->for_feed_settings()) : $terms = $link->setting('terms', NULL, array()); endif; ?>
labels->name; ?> for_feed_settings()) : $add_global_categories = $link->setting("add/$tax", NULL, 'yes'); $checked = array('yes' => '', 'no' => ''); $checked[$add_global_categories] = ' checked="checked"'; if (isset($setting_map[$tax])) : $setting = $setting_map[$tax]; $cats = $link->setting($setting, NULL, NULL); if (is_null($cats)) : $cats = array(); endif; elseif (isset($terms[$tax])) : $cats = $terms[$tax]; else : $cats = array(); endif; else : $cats = $globalCats; endif; if ($page->for_feed_settings()) : ?>
hierarchical) : // Use a category-style checkbox fwp_category_box($dogs, 'all '.$page->these_posts_phrase(), /*tags=*/ array(), /*params=*/ array('taxonomy' => $tax)); else : // Use a tag-style edit box fwp_tags_box($cats, 'all '.$page->these_posts_phrase(), /*params=*/ array('taxonomy' => $tax)); endif; $globalDogs = SyndicatedPost::category_ids($globalCats, /*unfamiliar=*/ 'create:'.$tax, /*taxonomies=*/ array($tax)); $siteWideHref = $this->admin_page_href(basename(__FILE__)); if ($page->for_feed_settings()) : ?>

Site-wide labels->name; ?>

0) : ?>
  • name; ?>

Site-wide settings may also assign categories to syndicated posts. Should these_posts_phrase(); ?> be assigned these labels->name; ?> from the site-wide settings, in addition to the feed-specific labels->name; ?> you set up here?

$set) : // Defaulting is controlled by a separate radio button if ($this->for_feed_settings() and isset($post['match_default']) and isset($post['match_default'][$what]) and $post['match_default'][$what]=='yes') : $set = NULL; // Defaulted! endif; $this->update_setting("match/$what", $set, NULL); endforeach; endif; $optionMap = $this->term_option_map(); $settingMap = $this->term_setting_map(); $saveTerms = array(); $separateSaveTerms = array('category' => array(), 'post_tag' => array()); if (!isset($post['tax_input'])) : $post['tax_input'] = array(); endif; // Merge in data from older-notation category check boxes if (isset($post['post_category'])) : // Just merging in for processing below. $post['tax_input']['category'] = array_merge( (isset($post['tax_input']['category']) ? $post['tax_input']['category'] : array()), $post['post_category'] ); endif; // Process data from term tag boxes and check boxes foreach ($post['tax_input'] as $tax => $terms) : $saveTerms[$tax] = array(); if (is_array($terms)) : // Numeric IDs from checklist foreach ($terms as $term) : if ($term) : $saveTerms[$tax][] = '{'.$tax.'#'.$term.'}'; endif; endforeach; else : // String from tag input $saveTerms[$tax] = explode(",", $terms); endif; $saveTerms[$tax] = array_map('trim', $saveTerms[$tax]); if (isset($optionMap[$tax])) : $separateSaveTerms[$tax] = $saveTerms[$tax]; unset($saveTerms[$tax]); endif; endforeach; if (isset($post['post_category'])) : foreach ($post['post_category'] as $cat) : $separateSaveTerms['category'][] = '{category#'.$cat.'}'; endforeach; endif; // Unmatched categories and tags foreach (array('category', 'post_tag') as $what) : if (isset($post["unfamiliar_{$what}"])) : $this->update_setting( "unfamiliar {$what}", $post["unfamiliar_{$what}"], 'site-default' ); endif; endforeach; // Categories and Tags foreach ($separateSaveTerms as $tax => $terms) : if ($this->for_feed_settings()) : $this->link->update_setting($settingMap[$tax], $terms, array()); else : if (!empty($terms)) : update_option($optionMap[$tax], implode(FEEDWORDPRESS_CAT_SEPARATOR, $terms)); else : delete_option($optionMap[$tax]); endif; endif; endforeach; // Other terms $this->update_setting(array('feed'=>'terms', 'global'=>'syndication_terms'), $saveTerms, array()); if ($this->for_feed_settings()) : // Category splitting regex if (isset($post['cat_split'])) : $this->link->update_setting('cat_split', trim($post['cat_split']), ''); endif; // Treat global terms (cats, tags, etc.) as additional, // or as defaults to be overridden and replaced? if (isset($post['add_global'])) : foreach ($post['add_global'] as $what => $value) : $this->link->update_setting("add/$what", $value); endforeach; endif; endif; parent::save_settings($post); } /* FeedWordPressCategoriesPage::save_settings() */ function display () { //////////////////////////////////////////////// // Display settings boxes ////////////////////// //////////////////////////////////////////////// $this->boxes_by_methods = array( 'feed_categories_box' => __('Feed Categories & Tags'), 'categories_box' => array('title' => __('Categories'), 'id' => 'categorydiv'), ); parent::display(); } } $categoriesPage = new FeedWordPressCategoriesPage; $categoriesPage->display();