mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-04-18 17:33:43 +03:00
Styles: Add helper class to hide page title on pages in main menu
This commit is contained in:
parent
8df86334e3
commit
4e06badef3
|
@ -20,6 +20,7 @@ add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_assets' );
|
|||
add_filter( 'the_content', __NAMESPACE__ . '\inject_pledge_content', 1 );
|
||||
add_filter( 'get_the_excerpt', __NAMESPACE__ . '\inject_pledge_content', 1 );
|
||||
add_filter( 'search_template_hierarchy', __NAMESPACE__ . '\use_archive_template' );
|
||||
add_filter( 'body_class', __NAMESPACE__ . '\add_body_class' );
|
||||
|
||||
/**
|
||||
* Enqueue scripts and styles.
|
||||
|
@ -73,3 +74,27 @@ function use_archive_template( $templates ) {
|
|||
|
||||
return $templates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a class to body when the current page is in the menu.
|
||||
*
|
||||
* @param string[] $classes An array of body class names.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
function add_body_class( $classes ) {
|
||||
global $wp;
|
||||
// Get the main menu using the hooked function.
|
||||
$menus = Block_Config\add_site_navigation_menus( [] );
|
||||
$slug = $wp->request;
|
||||
$has_page = array_filter(
|
||||
$menus['main'],
|
||||
function ( $item ) use ( $slug ) {
|
||||
return trim( $item['url'], '/' ) === $slug;
|
||||
}
|
||||
);
|
||||
if ( ! empty( $has_page ) ) {
|
||||
$classes[] = 'is-page-in-menu';
|
||||
}
|
||||
return $classes;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,13 @@
|
|||
--wp--custom--form--border--width: 0;
|
||||
}
|
||||
|
||||
/* Hide the post title on search pages, or if it is in the main navigation. */
|
||||
body.search .wp-block-wporg-local-navigation-bar .wp-block-post-title,
|
||||
body.is-page-in-menu .wp-block-wporg-local-navigation-bar .wp-block-post-title {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Style the group blocks inside a template list. */
|
||||
.wp-block-post:where(li.type-5ftf_pledge) {
|
||||
> .wp-block-group {
|
||||
|
||||
|
|
Loading…
Reference in a new issue