<?php
/**
 * Add theme page
 */
function narzo_lite_menu() {
	add_theme_page( esc_html__( 'Narzo Lite', 'narzo-lite' ), esc_html__( 'Narzo Premium &#8599;', 'narzo-lite' ), 'edit_theme_options', 'narzo-lite-info', 'narzo_lite_theme_page_display' );
	global $submenu;
	$submenu['themes.php'][7][2] = esc_url( 'https://woocommerce.com/products/narzo/' );

}
add_action( 'admin_menu', 'narzo_lite_menu' );

/**
 * Display About page
 */
function narzo_lite_theme_page_display() {
	$theme = wp_get_theme();

	// if ( is_child_theme() ) {
	// 	$theme = wp_get_theme()->parent();
	// }

	include_once 'templates/theme-info.php';
}

function narzo_lite_admin_plugin_notice() {
	$theme = wp_get_theme();
	$hide_notice_bar = get_user_meta( get_current_user_id(), 'narzo_lite_hide_theme_info_noticebar', true );
	if ( '1' !== $hide_notice_bar ) {
		wp_enqueue_style( 'narzo-lite-admin-style' );
		wp_enqueue_script( 'narzo-lite-admin' );
		include 'templates/admin-plugin-notice.php';
	}
}
add_action( 'admin_notices', 'narzo_lite_admin_plugin_notice' );


function narzo_lite_hide_theme_info_noticebar() {
	check_ajax_referer( 'narzo_lite-nonce', 'narzo_lite-nonce-name' );
	if ( ! current_user_can( 'edit_theme_options' ) ) {
		wp_die( -1 );
	}

	update_user_meta( get_current_user_id(), 'narzo_lite_hide_theme_info_noticebar', 1 );

	wp_die( 1 );
}
add_action( 'wp_ajax_narzo_lite_hide_theme_info_noticebar', 'narzo_lite_hide_theme_info_noticebar' );
