updated theme Twenty Nineteen version 3.1

This commit is contained in:
2025-04-29 21:21:21 +00:00
committed by Gitium
parent 5dc2981470
commit 51f6d193dd
23 changed files with 408 additions and 337 deletions

View File

@ -32,6 +32,9 @@ function twentynineteen_get_avatar_size() {
* Returns true if comment is by author of the post.
*
* @see get_comment_class()
*
* @param WP_Comment|null $comment The comment object to check. Defaults to the current comment.
* @return bool True if the comment is by the author of the post, false otherwise.
*/
function twentynineteen_is_comment_by_post_author( $comment = null ) {
if ( is_object( $comment ) && $comment->user_id > 0 ) {
@ -82,7 +85,12 @@ function twentynineteen_get_discussion_data() {
}
/**
* Converts HSL to HEX colors.
* Converts HSL to HEX or RGB colors.
*
* @param float $h The hue component (0-360).
* @param float $s The saturation component (0-100).
* @param float $l The lightness component (0-100).
* @param bool $to_hex Whether to convert to HEX format (true) or RGB (false). Default true.
*/
function twentynineteen_hsl_hex( $h, $s, $l, $to_hex = true ) {

View File

@ -9,6 +9,9 @@
/**
* Gets the SVG code for a given icon.
*
* @param string $icon The specific icon to retrieve.
* @param int $size The desired width and height for the SVG icon.
*/
function twentynineteen_get_icon_svg( $icon, $size = 24 ) {
return TwentyNineteen_SVG_Icons::get_svg( 'ui', $icon, $size );
@ -16,6 +19,9 @@ function twentynineteen_get_icon_svg( $icon, $size = 24 ) {
/**
* Gets the SVG code for a given social icon.
*
* @param string $icon The specific icon to retrieve.
* @param int $size The desired width and height for the SVG icon.
*/
function twentynineteen_get_social_icon_svg( $icon, $size = 24 ) {
return TwentyNineteen_SVG_Icons::get_svg( 'social', $icon, $size );
@ -23,6 +29,9 @@ function twentynineteen_get_social_icon_svg( $icon, $size = 24 ) {
/**
* Detects the social network from a URL and returns the SVG code for its icon.
*
* @param string $uri The URL of the social network link.
* @param int $size The desired width and height for the SVG icon.
*/
function twentynineteen_get_social_link_svg( $uri, $size = 24 ) {
return TwentyNineteen_SVG_Icons::get_social_link_svg( $uri, $size );

View File

@ -57,6 +57,8 @@ add_action( 'wp_head', 'twentynineteen_pingback_header' );
/**
* Changes comment form default fields.
*
* @param array $defaults The default comment form arguments.
*/
function twentynineteen_comment_form_defaults( $defaults ) {
$comment_field = $defaults['comment_field'];
@ -165,7 +167,7 @@ add_filter( 'wp_nav_menu', 'twentynineteen_add_ellipses_to_nav', 10, 2 );
*
* @link https://www.w3.org/WAI/tutorials/menus/flyout/
*
* @param array $atts {
* @param array $atts {
* The HTML attributes applied to the menu item's `<a>` element, empty strings are ignored.
*
* @type string $title Title attribute.
@ -174,21 +176,25 @@ add_filter( 'wp_nav_menu', 'twentynineteen_add_ellipses_to_nav', 10, 2 );
* @type string $href The href attribute.
* @type string $aria-current The aria-current attribute.
* }
* @param WP_Post $item The current menu item object.
* @param WP_Post $item The current menu item object.
* @param stdClass $args An object of `wp_nav_menu()` arguments.
* @return string[] Modified attributes.
*/
function twentynineteen_nav_menu_link_attributes( $atts, $item ) {
function twentynineteen_nav_menu_link_attributes( $atts, $item, $args ) {
// Add [aria-haspopup] and [aria-expanded] to menu items that have children.
$item_has_children = in_array( 'menu-item-has-children', $item->classes, true );
if ( $item_has_children ) {
$atts['aria-haspopup'] = 'true';
$atts['aria-expanded'] = 'false';
// Check that this is the primary menu.
if ( isset( $args->theme_location ) && 'menu-1' === $args->theme_location ) {
// Add [aria-haspopup] and [aria-expanded] to menu items that have children.
$item_has_children = in_array( 'menu-item-has-children', $item->classes, true );
if ( $item_has_children ) {
$atts['aria-haspopup'] = 'true';
$atts['aria-expanded'] = 'false';
}
}
return $atts;
}
add_filter( 'nav_menu_link_attributes', 'twentynineteen_nav_menu_link_attributes', 10, 2 );
add_filter( 'nav_menu_link_attributes', 'twentynineteen_nav_menu_link_attributes', 10, 3 );
/**
* Creates a nav menu item to be displayed on mobile to navigate from submenu back to the parent.