<?php

/**
 * Functions which enhance the theme by hooking into WordPress
 *
 * @package Blog Eye
 */

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

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


function blog_eye_footer_settings_desc()
{
	$blog_eye_pro_link = 'https://wpthemespace.com/product/blog-eye-pro/?add-to-cart=7531';
	$blog_eye_footer_desctext = esc_html__('Upgrade to Pro for this footer text to work', 'blog-eye');
	$blog_eye_btntext = esc_html__('Upgrade Now', 'blog-eye');
	$blog_eye_install_date = get_option('blog_eye_install_date');
	$blog_eye_showtime = round((time() - strtotime($blog_eye_install_date)) / 24 / 60 / 60);
	if ($blog_eye_showtime < 10) {
		$footer_desc = sprintf('%s <a href="%s" target="_blank">%s</a>', esc_html($blog_eye_footer_desctext), esc_url($blog_eye_pro_link), esc_html($blog_eye_btntext));
	} else {
		$footer_desc = esc_html__('Enter your footer text here', 'blog-eye');
	}
	return $footer_desc;
}

/**
 * Get footer credit text based on user role
 *
 * @return string Footer credit HTML
 */
function blog_eye_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/blog-eye-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', 'blog-eye'),
            esc_html__('Theme:', 'blog-eye'),
            esc_html__('by', 'blog-eye')
        );
    } 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', 'blog-eye'),
            esc_html__('Create Your Professional Website', 'blog-eye')
        );
    }
}
