From 2699d8d989274e33ad5c7bb494d90d47705320ab Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Fri, 24 Apr 2015 14:57:28 +0000 Subject: [PATCH] In `wp_list_categories()`, 'All' link should point to post type archive if taxonomy is not registered for 'post' or 'page'. Instead, we point to the post type archive of the first registered object_type that supports archives. Props stevegrunwell, hrishiv90, boonebgorges. Fixes #21881. Built from https://develop.svn.wordpress.org/trunk@32292 git-svn-id: http://core.svn.wordpress.org/trunk@32263 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/category-template.php | 23 ++++++++++++++++++++++- wp-includes/version.php | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index 9a2120c9e3..5fb7485332 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -532,7 +532,28 @@ function wp_list_categories( $args = '' ) { } } else { if ( ! empty( $show_option_all ) ) { - $posts_page = ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) ) ? get_permalink( get_option( 'page_for_posts' ) ) : home_url( '/' ); + + $posts_page = ''; + + // For taxonomies that belong only to custom post types, point to a valid archive. + $taxonomy_object = get_taxonomy( $r['taxonomy'] ); + if ( ! in_array( 'post', $taxonomy_object->object_type ) && ! in_array( 'page', $taxonomy_object->object_type ) ) { + foreach ( $taxonomy_object->object_type as $object_type ) { + $_object_type = get_post_type_object( $object_type ); + + // Grab the first one. + if ( ! empty( $_object_type->has_archive ) ) { + $posts_page = get_post_type_archive_link( $object_type ); + break; + } + } + } + + // Fallback for the 'All' link is the front page. + if ( ! $posts_page ) { + $posts_page = 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) ? get_permalink( get_option( 'page_for_posts' ) ) : home_url( '/' ); + } + $posts_page = esc_url( $posts_page ); if ( 'list' == $r['style'] ) { $output .= "
  • $show_option_all
  • "; diff --git a/wp-includes/version.php b/wp-includes/version.php index 0fbf6c78c4..e7a4722138 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.3-alpha-32280'; +$wp_version = '4.3-alpha-32292'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.