INN/Largo — pull request #312 by benlk (2014-12-10 23:05:00+00:00)
Title: Optional taxonomies for #282

Leaving this PR here for discussion for a fix on #282.
----

This creates two checkboxes in Theme Settings > Advanced:

- Enable Series in menus, and features that use series.
- Enable Post Types in menus.

## Post Types

Unless the option box is checked in Theme Settings > Advanced:

- The "Post Types" menu item is removed from the sidebar in the dashboard
- The "Post Types" metabox is removed from the post editor
- The "Post Types" column is removed from the table of posts and details

## Series

Unless the option box is checked in Theme Settings > Advanced:

- The HomepageSingleWithSeriesStories front page template will not be an option in the Theme Options. If it was already set, it will not be unset, but Largo will fall back to a blog-style layout
- The widgets "Largo Post Series Links" and "Largo Series Posts" are not an option in the widget section of the dashboard. If they were already put into use, they will present nothing. If these widgets are the only widgets in a custom sidebar, that sidebar will fall back to the site default sidebar.
- The "Largo Related Posts" widget will not find related posts by the series.
- The 'series' taxonomy will not be registered, causing many functions related to series to quietly return `false` or nothing.
- Notably, largo_post_in_series will return `false` even if the post is in a series with other posts. This prevents many series-related functions from running.

A breakdown of what is and isn't changed for the series functionality, and why.

homepages/zones/zones.php
- `homepage_series_stories_list` is only used on HomepageSingleWithSeriesStories.php

homepages/layouts/HomepageSingleWithSeriesStories.php
- Allowed to remain functional because this might have been chosen beforehand
- Removed from the options in homepages.php

homepages/homepage.php
- If series are enabled, HomepageSingleWithSeriesStories is a layout option in the $defaut_layouts. Otherwise, not.
- `largo_get_home_layouts` will `unregister_homepage_layout('HomepageSingleWithSeriesStories')` if the Series taxonomy is disabled

inc/taxonomies.php
- `largo_post_in_series` will return false if series are disabled
- Hide the Series menu in the sidebar
- Hide the Series metabox in the post and page editors

inc/featured-content.php
- `largo_get_the_main_feature` is called in
- homepages/templates/home-part-sticky-posts.php and is conditionally called if `largo_post_in_series` is true
- homepages/zones/zones.php as part of `homepage_series_stories_list`, dismissed above
- partials/sticky-posts.php and is conditionally called if `largo_post_in_series` is true

inc/related-content.php
- `largo_get_recent_posts_for_term` has the option to use series as a term
- `class Largo_Related`, which is only used in inc/widgets/largo-related-posts.php for `class largo_related_posts_widget`, but it's not exclusive to series. Adds a check to see if series are enabled when getting related posts. If series are not enabled, it does not query for series posts.

inc/update.php
- mentions series, but just to replace the `in_series` widget with the `largo-post-series-links` widget

inc/widgets/largo-post-series-links.php
- is a widget, fails gracefully when series are disabled because `largo_post_in_series` returns false

inc/widgets/largo-related-posts.php
- is a widget, included in inc/widgets.php, but left alone because it has non-series functionality

inc/widgets/largo-series-posts.php
- is a widget, fails gracefully when series are disabled because `largo_post_in_series` returns false

options.php
- `optionsframework_options` uses `largo_get_home_layouts` from homepages/homepage.php

partials/sticky-posts.php
- Series functionality escaped via `largo_post_in_series` returning false

series-landing.php
- Only for series landing pages, wouldn't be used otherwise.

## Tests

inc/taxonomies.php is mostly not covered by tests.

This PR includes a way to mock an admin page being loaded, so that `is_admin()` returns true.