Skip to content

Commit

Permalink
Block theme: Add back "All" link to category & status menus
Browse files Browse the repository at this point in the history
Fixes #669
  • Loading branch information
ryelle committed Apr 16, 2024
1 parent c997077 commit e537af2
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function inject_category_search_block( $block_content ) {
* Provide a list of local navigation menus.
*/
function add_site_navigation_menus( $menus ) {
global $wp_query;
global $wp_query, $wp;

$menu = array();
$categories = array();
Expand All @@ -320,6 +320,11 @@ function add_site_navigation_menus( $menus ) {

$current_status = isset( $wp_query->query['status'] ) ? $wp_query->query['status'] : false;
$statuses = array(
array(
'label' => __( 'All', 'wporg-patterns' ),
'url' => get_permalink(),
'className' => ! $current_status ? 'current-menu-item' : '',
),
array(
'label' => __( 'Draft', 'wporg-patterns' ),
'url' => add_query_arg( 'status', 'draft', get_permalink() ),
Expand Down Expand Up @@ -360,12 +365,17 @@ function add_site_navigation_menus( $menus ) {
$cat['className'] = 'current-menu-item';
}
if ( is_page( 'favorites' ) || is_author() ) {
global $wp;
$cat['url'] = add_query_arg( 'pattern-categories', $term->slug, home_url( $wp->request ) );
}

$categories[] = $cat;
}
$all_link = array(
'label' => __( 'All', 'wporg-patterns' ),
'url' => is_page( 'favorites' ) || is_author() ? home_url( $wp->request ) : home_url( '/archives/' ),
'className' => empty( $current_cats ) ? 'current-menu-item' : '',
);
array_unshift( $categories, $all_link );
}

return array(
Expand Down

0 comments on commit e537af2

Please sign in to comment.