<?php
/**
 * Custom hooks
 *
 * @package Digital
 */

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;

if ( ! function_exists( 'digital_site_info' ) ) {
	/**
	 * Add site info hook to WP hook library.
	 */
	function digital_site_info() {
		do_action( 'digital_site_info' );
	}
}

add_action( 'digital_site_info', 'digital_add_site_info' );
if ( ! function_exists( 'digital_add_site_info' ) ) {
	/**
	 * Add site info content.
	 */
	function digital_add_site_info() {
		$the_theme = wp_get_theme();
		$credit = '</a>';

		$site_info = sprintf(
			'<a href="%1$s">%2$s</a><span class="sep"> | </span>%3$s',
			esc_url( __( 'https://wordpress.org/', 'digital' ) ),
			sprintf(
				/* translators: WordPress */
				esc_html__( 'Proudly powered by %s', 'digital' ),
				'WordPress'
			),
			sprintf(
				/* translators: 1: Theme name, 2: Theme author */
				esc_html__( 'Design %1$s by %2$s', 'digital' ),
				$the_theme->get( 'Name' ),
				'<a href="' . esc_url( __( 'https://www.insertcart.com/product/digital-wp-theme/', 'digital' ) ) . '">InsertCart.com</a>'
			)
		);

		// Check if customizer site info has value.
		if ( get_theme_mod( 'digital_site_info_override' ) ) {
			$site_info = get_theme_mod( 'digital_site_info_override' ) . $credit;
			$credit = sprintf(
				/* translators: 1: Theme name, 2: Theme author */
				esc_html__( 'Design %1$s by %2$s', 'digital' ),
				$the_theme->get( 'Name' ),
				'<a href="' . esc_url( __( 'hhttps://www.insertcart.com/product/digital-wp-theme/', 'digital' ) ) . '">InsertCart.com</a>'
			);
		}

		echo apply_filters( 'digital_site_info_content', $site_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped

	}
}
