<?php

/**
 * Functions which enhance the theme by hooking into WordPress
 *
 * @package Business View
 */

/**
 * Adds custom classes to the array of body classes.
 *
 * @param array $classes Classes for the body element.
 * @return array
 */
function business_view_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';
	}

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

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


/**
 * Get footer credit text based on user role
 *
 * @return string Footer credit HTML
 */
function business_view_get_footer_credits() {
    $site_name = get_bloginfo('name');
    $current_year = date('Y');
    
    if (current_user_can('manage_options')) {
        // Admin message - Professional credit
        return sprintf(
            '&copy; %1$s %2$s - <a href="https://wordpress.org/" target="_blank" rel="nofollow">%3$s</a> | %4$s <a href="https://wpthemespace.com/product/business-view-pro/" target="_blank">Blog Eye</a> %5$s <a href="https://wpthemespace.com/" target="_blank">WP Theme Space</a>',
            esc_html($site_name),
            esc_html($current_year),
            esc_html__('Powered by WordPress','business-view'),
            esc_html__('Theme:','business-view'),
            esc_html__('by','business-view')
        );
    } else {
        // Visitor message - Business development focused
        return sprintf(
            '&copy; %1$s %2$s - %3$s <a href="https://wpthemespace.com/" target="_blank" style="color: #0073aa; font-weight: 600;">WP Theme Space</a> | <a href="https://wpthemespace.com/pro-services/" target="_blank" style="color: #e74c3c; font-weight: 600;">%4$s</a>',
            esc_html($site_name),
            esc_html($current_year),
            esc_html__('Website developed by','business-view'),
            esc_html__('Create Your Professional Website','business-view')
        );
    }
}
