Skip to content

Commit

Permalink
Manage conflict with the new "View Archive" link
Browse files Browse the repository at this point in the history
WordPress adds its own link into the admin bar to go to the archive page
of any post types. But its behaviour does not work correctly with
Thistle because of the possibility to have a post type without
single view (`publicly_queryable => false`).
So the Thistle link is kept in favour of the WP one.
  • Loading branch information
7studio committed Mar 17, 2017
1 parent 0be457b commit cc1d2ac
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions includes/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,21 @@ function thistle_redirect_wp_logout( $logout_url, $redirect ) {
}
}
add_filter( 'logout_url', 'thistle_redirect_wp_logout', 10, 2 );

if ( ! function_exists( 'thistle_remove_admin_bar_archive_node' ) ) {
/**
* Removes the default archive links ("View Posts") from the admin bar in
* favour of the Thistle one. This choice lets us have
* this helpful link even if the post type has not a single view.
*
* @link https://core.trac.wordpress.org/ticket/34113
*
* @global WP_Admin_Bar $wp_admin_bar
*/
function thistle_remove_admin_bar_archive_node() {
global $wp_admin_bar;

$wp_admin_bar->remove_menu( 'archive' );
}
}
add_action( 'wp_before_admin_bar_render', 'thistle_remove_admin_bar_archive_node' );

0 comments on commit cc1d2ac

Please sign in to comment.