<?php
/**
 * Custom functions that act independently of the theme templates.
 *
 * Eventually, some of the functionality here could be replaced by core features.
 *
 * @package Elite Security Guard
 */

/**
 * Adds custom classes to the array of body classes.
 *
 * @param array $classes Classes for the body element.
 * @return array
 */
function elite_security_guard_body_classes( $classes ) {
	// Adds a class of group-blog to blogs with more than 1 published author.
	if ( is_multi_author() ) {
		$classes[] = 'group-blog';
	}

	// Adds a class of hfeed to non-singular pages.
	if ( ! is_singular() ) {
		$classes[] = 'hfeed';
	}

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

if ( ! function_exists( 'wp_body_open' ) ) {
	/**
	 * Backward compatibility for wp_body_open hook.
	 *
	 * @since 1.0.0
	 */
	function wp_body_open() {
		do_action( 'wp_body_open' );
	}
}

if (!function_exists('elite_security_guard_str_replace_assoc')) {
    /**
     * elite_security_guard_str_replace_assoc
     * @param  array $replace
     * @param  array $subject
     * @return array
     */
    function elite_security_guard_str_replace_assoc(array $replace, $subject) {
        return str_replace(array_keys($replace), array_values($replace), $subject);
    }
}

if (!function_exists('elite_security_guard_logo_title_description')) {
    /**
     * Display custom logo with fallback to site title and tagline
     *
     * @package Elite Security Guard
     */
    function elite_security_guard_logo_title_description() {
        if (function_exists('the_custom_logo') && has_custom_logo()) {
            the_custom_logo();
        } else {
            if (get_theme_mod('elite_security_guard_site_title_display_setting', true)) {
                echo '<a href="' . esc_url(home_url('/')) . '" rel="home">';
                echo '<h1 class="site-title">' . esc_html(get_bloginfo('name')) . '</h1>';
                echo '</a>';
            }
            if (get_theme_mod('elite_security_guard_tagline_display_setting', true)) {
                echo '<p class="site-description">' . esc_html(get_bloginfo('description')) . '</p>';
            }
        }
    }
}