<?php
/**
 * Functions which enhance the theme by hooking into WordPress
 *
 * @package Buzz_Agency
 */

/**
 * Adds custom classes to the array of body classes.
 *
 * @param array $classes Classes for the body element.
 * @return array
 */
function buzz_agency_body_classes( $classes ) {
	// Adds a class of hfeed to non-singular pages.
	if ( ! is_singular() ) {
		$classes[] = 'hfeed';
	}

	// Adds a class of no-sidebar when there is no sidebar present.
	if ( ! is_active_sidebar( 'sidebar-1' ) ) {
		$classes[] = 'no-sidebar';
	}

	$buzz_agency_vetical_menu_class = get_theme_mod( 'buzz_agency_header_layout_options', 'horizontal-menu-open' );
	$classes[] = esc_attr( $buzz_agency_vetical_menu_class );

	return $classes;
}
add_filter( 'body_class', 'buzz_agency_body_classes' );

/**
 * Add a pingback url auto-discovery header for single posts, pages, or attachments.
 */
function buzz_agency_pingback_header() {
	if ( is_singular() && pings_open() ) {
		printf( '<link rel="pingback" href="%s">', esc_url( get_bloginfo( 'pingback_url' ) ) );
	}
}
add_action( 'wp_head', 'buzz_agency_pingback_header' );



function buzz_agency_add_class_next_post_link($html){
     $html = str_replace('rel="next">','class="box-button" rel="next"><span></span>',$html);
    return $html;
}
add_filter('next_post_link','buzz_agency_add_class_next_post_link',10,1);
 
function buzz_agency_add_class_previous_post_link($html){
     $html = str_replace('rel="prev">','class="box-button" rel="next"><span></span>',$html);
    return $html;
}
add_filter('previous_post_link','buzz_agency_add_class_previous_post_link',10 ,1);

if ( ! function_exists( 'buzz_agency_fonts_url' ) ) :

	// Google Fonts URL
	function buzz_agency_fonts_url() {

		$font_families = array(
			'Mulish:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900',
		);

		$fonts_url = add_query_arg(
			array(
				'family'  => implode( '&family=', $font_families ),
				'display' => 'swap',
			),
			'https://fonts.googleapis.com/css2'
		);

		return esc_url_raw( $fonts_url );

	}

endif;