My twentytwentyone child theme for my wordpress site on DeGruchy.org https://degruchy.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

261 lines
8.0 KiB

<?php
/**
* Load in the original twentytwentyone styles
*/
if ( !function_exists( "degruchy_org_enqueue_tto_styles" ) )
{
/**
* Enqueue the styles of the parent theme, and this theme
*
* @return void
* @since 1.0
*/
function degruchy_org_enqueue_tto_styles()
:void
{
$theme = wp_get_theme();
wp_enqueue_style(
'parent-style',
get_template_directory_uri() . '/style.css',
array(), // if the parent theme code has a dependency, copy it to here
$theme->parent()->get( 'Version' )
);
wp_enqueue_style(
'child-style',
get_stylesheet_uri(),
array( 'parent-style' ),
$theme->get( 'Version' ) // this only works if you have Version in the style header
);
}
}
if ( !function_exists( "degruchy_org_disable_archive_prefix" ) )
{
/**
* Removes the archive prefix title from any listing-style pages that are auto-generated, these sorts of prefixes,
* while helpful, feel more annoying to me.
*
* @param string $title Title string to be manipulated.
*
* @return string The mangled string.
* @since 1.1
*/
function degruchy_org_disable_archive_prefix( string $title )
:string
{
if ( is_category() )
{
$title = single_cat_title( '', FALSE );
}
else if ( is_tag() )
{
$title = single_tag_title( '', FALSE );
}
else if ( is_author() )
{
$title = '<span class="vcard">' . get_the_author() . '</span>';
}
else if ( is_post_type_archive() )
{
$title = post_type_archive_title( '', FALSE );
}
else if ( is_tax() )
{
$title = single_term_title( '', FALSE );
}
return $title;
}
}
if( !function_exists( "degruchy_twenty_twenty_one_social_icons_map" ) )
{
/**
* Add mastodon support in social icons
* @param Array $icons List of existing social icons to append
* @link https://wordpress.org/support/topic/2021-social-icons/
* @since 1.1.3
* @return array An array of icons for the social menu
*/
function degruchy_twenty_twenty_one_social_icons_map( array $icons ): Array
{
$icons[ 'mastodon' ] = array(
'fosstodon.org', // this only maps fosstodon, you could add more here
);
return $icons;
}
}
if( !function_exists( "degruchy_twenty_twenty_one_svg_icons_social" ))
{
/**
* @param $icons array List of existing social icons svg content
* @since 1.1.3
* @return array an updated repository of SVG icons for the social menu
*/
function degruchy_twenty_twenty_one_svg_icons_social( array $icons ): Array
{
$icons[ 'mastodon' ] = '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M23.193 7.879c0-5.206-3.411-6.732-3.411-6.732C18.062.357 15.108.025 12.041 0h-.076c-3.068.025-6.02.357-7.74 1.147 0 0-3.411 1.526-3.411 6.732 0 1.192-.023 2.618.015 4.129.124 5.092.934 10.109 5.641 11.355 2.17.574 4.034.695 5.535.612 2.722-.15 4.25-.972 4.25-.972l-.09-1.975s-1.945.613-4.129.539c-2.165-.074-4.449-.233-4.799-2.891a5.499 5.499 0 0 1-.048-.745s2.125.52 4.817.643c1.646.075 3.19-.097 4.758-.283 3.007-.359 5.625-2.212 5.954-3.905.517-2.665.475-6.507.475-6.507zm-4.024 6.709h-2.497V8.469c0-1.29-.543-1.944-1.628-1.944-1.2 0-1.802.776-1.802 2.312v3.349h-2.483v-3.35c0-1.536-.602-2.312-1.802-2.312-1.085 0-1.628.655-1.628 1.944v6.119H4.832V8.284c0-1.289.328-2.313.987-3.07.68-.758 1.569-1.146 2.674-1.146 1.278 0 2.246.491 2.886 1.474L12 6.585l.622-1.043c.64-.983 1.608-1.474 2.886-1.474 1.104 0 1.994.388 2.674 1.146.658.757.986 1.781.986 3.07v6.304z"/></svg>';
return $icons;
}
}
/**
* Prints HTML with meta information for the categories, tags and comments.
* Footer entry meta is displayed differently in archives and single posts.
*
* @since Twenty Twenty-One 1.0
*
* @return void
*/
function twenty_twenty_one_entry_meta_footer()
{
// Early exit if not a post.
if ('post' !== get_post_type())
{
return;
}
// Hide meta information on pages.
if (!is_single())
{
if (is_sticky())
{
echo '<p>' . esc_html_x('Featured post', 'Label for sticky posts', 'twentytwentyone') . '</p>';
}
$post_format = get_post_format();
if ('aside' === $post_format || 'status' === $post_format)
{
echo '<p><a href="' . esc_url(get_permalink()) . '">' . twenty_twenty_one_continue_reading_text() . '</a></p>'; // phpcs:ignore WordPress.Security.EscapeOutput
}
// Posted on.
twenty_twenty_one_posted_on();
// Edit post link.
edit_post_link(
sprintf(
/* translators: %s: Name of current post. Only visible to screen readers. */
esc_html__('Edit %s', 'twentytwentyone'),
'<span class="screen-reader-text">' . get_the_title() . '</span>'
),
'<span class="edit-link">',
'</span><br>'
);
if (has_category() || has_tag())
{
echo '<div class="post-taxonomies">';
/* translators: Used between list items, there is a space after the comma. */
$categories_list = get_the_category_list(__(', ', 'twentytwentyone'));
if ($categories_list)
{
printf(
/* translators: %s: List of categories. */
'<span class="cat-links p-category">' . esc_html__('Categorized as %s', 'twentytwentyone') . ' </span>',
$categories_list // phpcs:ignore WordPress.Security.EscapeOutput
);
}
/* translators: Used between list items, there is a space after the comma. */
$tags_list = get_the_tag_list('', __(', ', 'twentytwentyone'));
if ($tags_list)
{
printf(
/* translators: %s: List of tags. */
'<span class="tags-links p-category">' . esc_html__('Tagged %s', 'twentytwentyone') . '</span>',
$tags_list // phpcs:ignore WordPress.Security.EscapeOutput
);
}
echo '</div>';
}
}
else
{
echo '<div class="posted-by">';
// Posted on.
twenty_twenty_one_posted_on();
// Posted by.
twenty_twenty_one_posted_by();
// Edit post link.
edit_post_link(
sprintf(
/* translators: %s: Name of current post. Only visible to screen readers. */
esc_html__('Edit %s', 'twentytwentyone'),
'<span class="screen-reader-text">' . get_the_title() . '</span>'
),
'<span class="edit-link">',
'</span>'
);
echo '</div>';
if (has_category() || has_tag())
{
echo '<div class="post-taxonomies">';
/* translators: Used between list items, there is a space after the comma. */
$categories_list = get_the_category_list(__(', ', 'twentytwentyone'));
if ($categories_list)
{
printf(
/* translators: %s: List of categories. */
'<span class="cat-links p-category">' . esc_html__('Categorized as %s', 'twentytwentyone') . ' </span>',
$categories_list // phpcs:ignore WordPress.Security.EscapeOutput
);
}
/* translators: Used between list items, there is a space after the comma. */
$tags_list = get_the_tag_list('', __(', ', 'twentytwentyone'));
if ($tags_list)
{
printf(
/* translators: %s: List of tags. */
'<span class="tags-links p-category">' . esc_html__('Tagged %s', 'twentytwentyone') . '</span>',
$tags_list // phpcs:ignore WordPress.Security.EscapeOutput
);
}
echo '</div>';
}
}
}
/**
* Prints HTML with meta information for the current post-date/time.
*
* @since Twenty Twenty-One 1.0
*
* @return void
*/
function twenty_twenty_one_posted_on() {
$time_string = '<time class="entry-date published updated dt-published" datetime="%1$s">%2$s</time>';
$time_string = sprintf(
$time_string,
esc_attr( get_the_date( DATE_W3C ) ),
esc_html( get_the_date() )
);
echo '<span class="posted-on">';
printf(
/* translators: %s: Publish date. */
esc_html__( 'Published %s', 'twentytwentyone' ),
$time_string // phpcs:ignore WordPress.Security.EscapeOutput
);
echo '</span>';
}
add_filter( 'twenty_twenty_one_social_icons_map', 'degruchy_twenty_twenty_one_social_icons_map' );
add_filter( 'twenty_twenty_one_svg_icons_social', 'degruchy_twenty_twenty_one_svg_icons_social' );
add_filter( 'get_the_archive_title', 'degruchy_org_disable_archive_prefix' );
add_action( 'wp_enqueue_scripts', 'degruchy_org_enqueue_tto_styles' );