Skip to content

Commit

Permalink
Merge pull request #1187 from INN/HELPDESK-589-tax-list-widget-redo
Browse files Browse the repository at this point in the history
Revisit the Taxonomy List widget
  • Loading branch information
aschweigert committed Mar 31, 2016
2 parents e3f90eb + 630934d commit 76bf5ce
Show file tree
Hide file tree
Showing 5 changed files with 239 additions and 196 deletions.
24 changes: 19 additions & 5 deletions docs/users/sidebarswidgets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,29 @@ Typically used in the Article Bottom widget area, this will display a list of ca
Largo Taxonomy List
-------------------

List all of the terms in a given taxonomy with links to their archive pages. This is most commonly used to generate a list of series/projects with links to their project pages. To use this widget begin by entering in the Taxonomy field the slug of the taxonomy you want to use. For example, the slug for Categories is "category"; the slug for Tags is "post_tag"; the slug for Post Prominence is "prominence"; and the slug for Series is "series". You must enter one of these slugs for the widget to function correctly.
List all of the terms in a given taxonomy with links to their archive pages. This widget is most commonly used to generate a list of series/projects with links to their project pages. An explanation of the options:

By default the widget will pull in *all* posts in the taxonomy, which could be a very large number of posts. Use the Count field to limit the number of posts displayed. You can also limit the display to specific terms in the taxonomy. To do this you must find the term's ID by visiting the list of terms in the taxonomy (under Posts in the dashboard), then hover over or click on the term and find the tag_ID number in the URL for that term.
**Title**: This is what the widget will be named. Leave blank to have no title displayed.

For example, in this URL for the term "Bacon" the term ID is 482:
**Taxonomy**: This dropdown allows you to configure the taxonomy from which terms will be drawn. Example taxonomies are Category, Tag, Post Prominence, and Series. This option defaults to Series.

``/wp-admin/edit-tags.php?action=edit&taxonomy=post_tag&tag_ID=482&post_type=post``
**Sort order**:
- Alphabetically: Terms will be sorted in alphabetical order by their name. Terms beginning with punctuation will come after terms beginning with letters. Terms beginning with numbers will come before terms beginning with letters.
- Most Recent: Terms created more recently will appear first. Term sort order is determined by the term's ID, and newer terms always have higher ID values.

After setting the taxonomy slug, count, and optionally limiting by term ID, you choose to display thumbnails and a headline of the most recent post in the taxonomy, or display the taxonomy list as as dropdown menu. The Title of the widget defaults to Categories, but you can override this with a title of your choice.
**Count**: By default the widget will pull in 5 posts from the taxonomy. Use the Count field to increase or decrease the number of posts displayed. The minimum number of terms displayed is 1. In theory you can display all terms in a taxonomy by setting the count to the number of posts in the taxonomy, but in practice you should not set the number higher than 10. Using a large count number in conjunction with the thumbnail or headline options will negatively affect your site's performance, and may cause your server to run out of memory.

**Exclude**: Entering a comma-separated list of term IDs will exclude those terms from displayed results. To do this, go to "Posts" in the dashboard. Under "Posts" will be a list of taxonomies. Click on the desired taxonomy entry. A list of taxonomy terms will appear. Find your term in the list, then hover over or click on the term and find the tag_ID number in the URL for that term.

For example, in this URL for the term "Bacon" the term ID is 482:

``/wp-admin/edit-tags.php?action=edit&taxonomy=post_tag&tag_ID=482&post_type=post``

**Display as dropdown**: This option causes the term results to be displayed as a plain dropdown. No thumbnails or recent posts will be displayed.

**Display thumbnails**: Check this option if you want to display thumbnails next to the term link. If the taxonomy is "Series" and a series landing page exists for the series term, the series landing page's featured image will be displayed if it is available. In all other cases, the featured media thumbnail image from the most-recent post in the term will be displayed.

**Display headline**: If checked, the headline of the most-recent post in the taxonomy term will be displayed.

Largo Twitter Widget
--------------------
Expand Down
73 changes: 46 additions & 27 deletions inc/taxonomies.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ function largo_is_series_landing_enabled() {
* @since 1.0
*/
function largo_custom_taxonomies() {
if (!taxonomy_exists('prominence')) {

/*
* Register the "Post Prominence" taxonomy, which is used to determine where posts display
*/
if ( !taxonomy_exists('prominence') ) {
register_taxonomy(
'prominence',
'post',
Expand Down Expand Up @@ -115,7 +119,45 @@ function largo_custom_taxonomies() {

do_action('largo_after_create_prominence_taxonomy', $largoProminenceTerms);

/*
* Register the "Post Types" taxonomy, used for icons. This is not enabled by default in Largo.
*
* Replaces Largo_Term_Icons::register_post_type and unregister_post_types_taxonomy()
* @since 0.5.5
* @link https://github.com/INN/Largo/issues/1173
*/
if ( !taxonomy_exists('post-type') ) {
$enabled = ( ! of_get_option('post_types_enabled') == 0 );
register_taxonomy(
'post-type',
array( 'post' ),
array(
'label' => __( 'Post Types', 'largo' ),
'labels' => array(
'name' => __( 'Post Types', 'largo' ),
'singular_name' => __( 'Post Type', 'largo' ),
'all_items' => __( 'All Post Types', 'largo' ),
'edit_item' => __( 'Edit Post Type', 'largo' ),
'update_item' => __( 'Update Post Type', 'largo' ),
'view_item' => __( 'View Post Type', 'largo' ),
'add_new_item' => __( 'Add New Post Type', 'largo' ),
'new_item_name' => __( 'New Post Type Name', 'largo' ),
'search_items' => __( 'Search Post Type'),
),
'public' => $enabled,
'show_admin_column' => $enabled,
'show_in_nav_menus' => $enabled,
'hierarchical' => true,
)
);
}

/**
* Register the "Series" taxonomy, used to group posts together by ongoing coverage. This is not enabled by default in Largo.
*
*/
if ( ! taxonomy_exists( 'series' ) ) {
$series_enabled = largo_is_series_enabled();
register_taxonomy(
'series',
'post',
Expand All @@ -135,6 +177,9 @@ function largo_custom_taxonomies() {
'new_item_name' => __( 'New Series Name' ),
'menu_name' => __( 'Series' ),
),
'public' => $series_enabled,
'show_admin_column' => $series_enabled,
'show_in_nav_menus' => $series_enabled,
'query_var' => true,
'rewrite' => true,
)
Expand Down Expand Up @@ -443,29 +488,3 @@ function largo_first_headline_in_post_array($array) {

return $headline;
}

/**
* If the option in Advanced Options is unchecked, unregister the "Series" taxonomy
*
* @uses largo_is_series_enabled
* @since 0.4
*/
function unregister_series_taxonomy() {
if ( !largo_is_series_enabled() ) {
register_taxonomy( 'series', array(), array('show_in_nav_menus' => false) );
}
}
add_action( 'init', 'unregister_series_taxonomy', 999 );

/**
* If the option in Advanced Options is unchecked, unregister the "Post Types" taxonomy
*
* @uses of_get_option
* @since 0.4
*/
function unregister_post_types_taxonomy() {
if ( of_get_option('post_types_enabled') == 0 ) {
register_taxonomy( 'post-type', array(), array('show_in_nav_menus' => false) );
}
}
add_action( 'init', 'unregister_post_types_taxonomy', 999 );
25 changes: 0 additions & 25 deletions inc/term-icons.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,6 @@ function __construct() {
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts') );
add_action( 'edit_terms', array( $this, 'edit_terms' ) );
add_action( 'create_term', array( $this, 'edit_terms' ) );
add_action( 'init', array( $this, 'register_taxonomy' ) );
}


/**
* Register the taxonomy post-type
*/
function register_taxonomy() {
register_taxonomy( 'post-type', array( 'post' ), array(
'label' => __( 'Post Types', 'largo' ),
'labels' => array(
'name' => __( 'Post Types', 'largo' ),
'singular_name' => __( 'Post Type', 'largo' ),
'all_items' => __( 'All Post Types', 'largo' ),
'edit_item' => __( 'Edit Post Type', 'largo' ),
'update_item' => __( 'Update Post Type', 'largo' ),
'view_item' => __( 'View Post Type', 'largo' ),
'add_new_item' => __( 'Add New Post Type', 'largo' ),
'new_item_name' => __( 'New Post Type Name', 'largo' ),
'search_items' => __( 'Search Post Type'),
),
'public' => true,
'show_admin_column' => true,
'hierarchical' => true,
) );
}

/**
Expand Down
Loading

0 comments on commit 76bf5ce

Please sign in to comment.