'; } } add_action( 'wp_head', 'seedlet_pingback_header' ); /** * Changes comment form default fields. */ function seedlet_comment_form_defaults( $defaults ) { $comment_field = $defaults['comment_field']; // Adjust height of comment form. $defaults['comment_field'] = preg_replace( '/rows="\d+"/', 'rows="5"', $comment_field ); return $defaults; } add_filter( 'comment_form_defaults', 'seedlet_comment_form_defaults' ); /** * Filters the default archive titles. */ function seedlet_get_the_archive_title( $title, $original_title, $prefix ) { if ( is_category() ) { $prefix = '' . __( 'Category Archives: ', 'seedlet' ) . ''; $title = '' . single_term_title( '', false ) . ''; } elseif ( is_tag() ) { $prefix = '' . __( 'Tag Archives: ', 'seedlet' ) . ' '; $title = '' . single_term_title( '', false ) . ''; } elseif ( is_author() ) { $prefix = '' . __( 'Author Archives: ', 'seedlet' ) . ' '; $title = '' . get_the_author_meta( 'display_name' ) . ''; } elseif ( is_year() ) { $prefix = '' . __( 'Yearly Archives: ', 'seedlet' ) . ' '; $title = '' . get_the_date( _x( 'Y', 'yearly archives date format', 'seedlet' ) ) . ''; } elseif ( is_month() ) { $prefix = '' . __( 'Monthly Archives: ', 'seedlet' ) . ' '; $title = '' . get_the_date( _x( 'F Y', 'monthly archives date format', 'seedlet' ) ) . ''; } elseif ( is_day() ) { $prefix = '' . __( 'Daily Archives: ', 'seedlet' ) . ' '; $title = '' . get_the_date() . ''; } elseif ( is_post_type_archive() ) { $prefix = ''; $cpt = get_post_type_object( get_queried_object()->name ); /* translators: %s: Post type singular name */ $title = sprintf( esc_html__( '%s Archives', 'seedlet' ), $cpt->labels->singular_name ); } elseif ( is_tax() ) { $prefix = ''; $tax = get_taxonomy( get_queried_object()->taxonomy ); /* translators: %s: Taxonomy singular name */ $title = sprintf( esc_html__( '%s Archives', 'seedlet' ), $tax->labels->singular_name ); } else { $prefix = ''; $title = '' . __( 'Archives: ', 'seedlet' ) . ' '; } return '

' . $prefix . $title . '

'; } add_filter( 'get_the_archive_title', 'seedlet_get_the_archive_title', 10, 3 ); /** * Determines if post thumbnail can be displayed. */ function seedlet_can_show_post_thumbnail() { return apply_filters( 'seedlet_can_show_post_thumbnail', ! post_password_required() && ! is_attachment() && has_post_thumbnail() ); } /** * Returns the size for avatars used in the theme. */ function seedlet_get_avatar_size() { return 60; } /** * Returns true if comment is by author of the post. * * @see get_comment_class() */ function seedlet_is_comment_by_post_author( $comment = null ) { if ( is_object( $comment ) && $comment->user_id > 0 ) { $user = get_userdata( $comment->user_id ); $post = get_post( $comment->comment_post_ID ); if ( ! empty( $user ) && ! empty( $post ) ) { return $comment->user_id === $post->post_author; } } return false; } /** * WCAG 2.0 Attributes for Dropdown Menus * * Adjustments to menu attributes tot support WCAG 2.0 recommendations * for flyout and dropdown menus. * * @ref https://www.w3.org/WAI/tutorials/menus/flyout/ */ function seedlet_nav_menu_link_attributes( $atts, $item, $args, $depth ) { // Add [aria-haspopup] and [aria-expanded] to menu items that have children $item_has_children = in_array( 'menu-item-has-children', $item->classes ); if ( $item_has_children ) { $atts['aria-haspopup'] = 'true'; $atts['aria-expanded'] = 'false'; } return $atts; } add_filter( 'nav_menu_link_attributes', 'seedlet_nav_menu_link_attributes', 10, 4 ); /* * Create the continue reading link */ function seedlet_continue_reading_link() { if ( ! is_admin() ) { $continue_reading = sprintf( /* translators: %s: Name of current post. */ wp_kses( __( 'Continue reading %s', 'seedlet' ), array( 'span' => array( 'class' => array() ) ) ), the_title( '"', '"', false ) ); return '' . $continue_reading . ''; } } // Filter the excerpt more link add_filter( 'excerpt_more', 'seedlet_continue_reading_link' ); // Filter the content more link add_filter( 'the_content_more_link', 'seedlet_continue_reading_link' ); /** * Add a dropdown icon to top-level menu items. * * @param string $output Nav menu item start element. * @param object $item Nav menu item. * @param int $depth Depth. * @param object $args Nav menu args. * @return string Nav menu item start element. * Add a dropdown icon to top-level menu items */ function seedlet_add_dropdown_icons( $output, $item, $depth, $args ) { // Only add class to 'top level' items on the 'primary' menu. if ( ! isset( $args->theme_location ) || 'primary' !== $args->theme_location ) { return $output; } if ( 'primary' == $args->theme_location && $depth === 0 ) { if ( in_array( 'menu-item-has-children', $item->classes, true ) ) { // Add SVG icon to parent items. $output .= seedlet_get_icon_svg( 'dropdown', 24 ); } } return $output; } add_filter( 'walker_nav_menu_start_el', 'seedlet_add_dropdown_icons', 10, 4 );