<li> element. * @param object $item The current menu item. * @param array $args An array of wp_nav_menu() arguments. * @param int $depth Depth of menu item. Used for padding. */ function briar_nav_menu_css_class( $classes, $item, $args, $depth ) { if ( isset( $args->item_class ) ) { $classes[] = $args->item_class; } return $classes; } add_filter( 'nav_menu_css_class', 'briar_nav_menu_css_class', 10, 4 ); /** * Add class to main nav links * * @see https://developer.wordpress.org/reference/hooks/nav_menu_link_attributes/ * @param array $atts The HTML attributes applied to the menu item's <a> element, empty strings are ignored. * @param object $item The current menu item. * @param array $args An array of wp_nav_menu() arguments. * @param int $depth Depth of menu item. Used for padding. */ function briar_nav_menu_link_attributes( $atts, $item, $args, $depth ) { if ( isset( $args->link_class ) ) { $atts['class'] = $args->link_class; } return $atts; } add_filter( 'nav_menu_link_attributes', 'briar_nav_menu_link_attributes', 10, 4 ); /** * Change read more link class * * @see https://developer.wordpress.org/reference/hooks/the_content_more_link/ * @param string $link Read More link element. */ function briar_the_content_more_link( $link ) { return str_replace( '"more-link"', '"post-item__btn btn--transition"', $link ); } add_filter( 'the_content_more_link', 'briar_the_content_more_link', 10, 1 ); /** * Adds custom classes to the array of body classes. * * @since 1.0 * * @param array $classes Classes for the body element. * @return array */ function briar_body_classes( $classes ) { // Adds a class of group-blog to blogs with more than 1 published author. if ( is_multi_author() ) { $classes[] = 'group-blog'; } if ( is_customize_preview() ) { $classes[] = 'customize-preview'; } if ( is_singular() && has_post_thumbnail() ) { $classes[] = 'single--featured'; } return $classes; } add_filter( 'body_class', 'briar_body_classes' ); if ( version_compare( $GLOBALS['wp_version'], '4.1', '<' ) ) : /** * Filters wp_title to print a neat tag based on what is being viewed. * * @param string $title Default title text for current view. * @param string $sep Optional separator. * @return string The filtered title. */ function briar_wp_title( $title, $sep ) { if ( is_feed() ) { return $title; } global $page, $paged; // Add the blog name. $title .= get_bloginfo( 'name', 'display' ); // Add the blog description for the home/front page. $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description && ( is_home() || is_front_page() ) ) { $title .= " $sep $site_description"; } // Add a page number if necessary. if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) { $title .= " $sep " . sprintf( esc_html__( 'Page %s', 'briar' ), max( $paged, $page ) ); } return $title; } add_filter( 'wp_title', 'briar_wp_title', 10, 2 ); /** * Title shim for sites older than WordPress 4.1. * * @link https://make.wordpress.org/core/2014/10/29/title-tags-in-4-1/ * @todo Remove this function when WordPress 4.3 is released. */ function briar_render_title() { ?> <title><?php wp_title( '|', true, 'right' ); ?> ' . trim( $link ) . ''; } return $link; } add_filter( 'wp_link_pages_link', 'briar_wp_link_pages_link', 10, 2 ); /** * Allow display and border-radius * @param array $allowed_attr Allowed attributes. * @return array */ function briar_safe_style_css( $allowed_attr ) { $allowed_attr[] = 'display'; $allowed_attr[] = 'border-radius'; return $allowed_attr; } add_filter( 'safe_style_css', 'briar_safe_style_css', 10, 1 );