', esc_url(get_bloginfo('pingback_url')));
}
}
add_action('wp_head', 'benzin_pingback_header');
/**
* Fix skip link focus in IE11.
*
* This does not enqueue the script because it is tiny and because it is only for IE11,
* thus it does not warrant having an entire dedicated blocking script being loaded.
*
* @link https://git.io/vWdr2
*/
function benzin_skip_link_focus_fix()
{
// The following is minified via `terser --compress --mangle -- assets/js/skip-link-focus-fix.js`.
?>
' . esc_html('Skip to the content', 'benzin') . '';
}
add_action('wp_body_open', 'benzin_skip_link', 5);
if (!function_exists('benzin_primary_navigation_fallback')) :
/**
* Fallback for primary navigation.
*
* @since 1.0.0
*/
function benzin_primary_navigation_fallback()
{
echo '
';
}
endif;
/**
Site Logo
**/
function benzin_site_logo($args = array(), $echo = true)
{
$logo = get_custom_logo();
$site_title = get_bloginfo('name');
$contents = '';
$classname = '';
$defaults = array(
'logo' => '%1$s%2$s',
'logo_class' => 'site-logo',
'title' => '%2$s',
'title_class' => 'site-title',
'home_wrap' => '%2$s
',
'single_wrap' => '%2$s
',
'condition' => (is_front_page() || is_home()) && !is_page(),
);
$args = wp_parse_args($args, $defaults);
/**
* Filters the arguments for `benzin_site_logo()`.
*
* @param array $args Parsed arguments.
* @param array $defaults Function's default arguments.
*/
$args = apply_filters('benzin_site_logo_args', $args, $defaults);
if (has_custom_logo()) {
$contents = sprintf($args['logo'], $logo, esc_html($site_title));
$classname = $args['logo_class'];
} else {
$contents = sprintf($args['title'], esc_url(get_home_url(null, '/')), esc_html($site_title));
$classname = $args['title_class'];
}
$wrap = $args['condition'] ? 'home_wrap' : 'single_wrap';
$html = sprintf($args[$wrap], $classname, $contents);
/**
* Filters the arguments for `benzin_site_logo()`.
*
* @param string $html Compiled html based on our arguments.
* @param array $args Parsed arguments.
* @param string $classname Class name based on current view, home or single.
* @param string $contents HTML for site title or logo.
*/
$html = apply_filters('benzin_site_logo', $html, $args, $classname, $contents);
if (!$echo) {
return $html;
}
echo $html; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
Add Image Size
**/
function benzin_thumbsize()
{
add_image_size('benzin-blog-thumbnail', 420, 320, true);
}
add_action('after_setup_theme', 'benzin_thumbsize');
/**
Custom Excerpt
**/
function benzin_get_excerpt($count)
{
global $post;
$permalink = esc_url(get_permalink($post->ID));
$excerpt = get_the_content();
$excerpt = strip_tags($excerpt);
$excerpt = substr($excerpt, 0, $count);
$excerpt = wp_kses_post(substr($excerpt, 0, strripos($excerpt, " ")));
if (is_home() || is_front_page()) {
$excerpt = '' . $excerpt . '...
';
return $excerpt;
}
}
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function benzin_widgets_init()
{
register_sidebar(
array(
'name' => esc_html__('Sidebar', 'benzin'),
'id' => 'sidebar',
'description' => esc_html__('Add widgets here.', 'benzin'),
'before_widget' => '',
'before_title' => '',
)
);
register_sidebar(
array(
'name' => esc_html__('Footer Menu Widget Area', 'benzin'),
'id' => 'footer_menu',
'description' => esc_html__('Footer Menu Area', 'benzin'),
'before_widget' => '',
'before_title' => '',
)
);
}
add_action('widgets_init', 'benzin_widgets_init');
/**
Pagination
**/
function benzin_the_posts_pagination()
{
the_posts_pagination(array(
'mid_size' => 2,
'prev_text' => __('Previous', 'benzin'),
'next_text' => __('Next', 'benzin'),
));
}