<?php
/**
 * Abblog functions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package Abblog
 */

if ( ! defined( 'ABBLOG_VERSION' ) ) {
	// current version of the theme
	define( 'ABBLOG_VERSION', '1.0.0' );
}

if ( ! function_exists( 'abblog_setup' ) ) :
	/**
	 * Sets up theme defaults and registers support for various WordPress features.
	 *
	 * Note that this function is hooked into the after_setup_theme hook, which
	 * runs before the init hook. The init hook is too late for some features, such
	 * as indicating support for post thumbnails.
	 */
	function abblog_setup() {

		load_theme_textdomain( 'abblog', get_template_directory() . '/languages' );

		// Add default posts and comments RSS feed links to head.
		add_theme_support( 'automatic-feed-links' );
		add_theme_support( 'title-tag' );
		add_theme_support( 'post-thumbnails' );
		// additional image sizes
		add_image_size( 'abblog_grid_gallery_thumbnail', 620, 380, true );
		set_post_thumbnail_size( 'abblog_masonry_thumbnail', 620, 9999 );

		// This theme uses wp_nav_menu() in one location.
		register_nav_menus(
			array(
				'menu-1' => esc_html__( 'Primary', 'abblog' ),
			)
		);

		/*
		 * Switch default core markup for search form, comment form, and comments
		 * to output valid HTML5.
		 */
		add_theme_support(
			'html5',
			array(
				'search-form',
				'comment-form',
				'comment-list',
				'gallery',
				'caption',
				'style',
				'script',
			)
		);

		add_theme_support( 'post-formats', array(
			'image',
			'gallery',
		) );

		// Set up the WordPress core custom background feature.
		add_theme_support(
			'custom-background',
			apply_filters(
				'abblog_custom_background_args',
				array(
					'default-color' => 'ffffff',
					'default-image' => '',
				)
			)
		);

		// Add theme support for selective refresh for widgets.
		add_theme_support( 'customize-selective-refresh-widgets' );

		/**
		 * Add support for core custom logo.
		 *
		 * @link https://codex.wordpress.org/Theme_Logo
		 */
		add_theme_support(
			'custom-logo',
			array(
				'height'      => 250,
				'width'       => 250,
				'flex-width'  => true,
				'flex-height' => true,
			)
		);

		/**
		 * Changing excerpt length for abblog theme
		 */
		function abblog_excerpt_length( $length ) {
			if ( ! is_admin() ) {
				return 50;
			} else {
				return $length;
			}
		}
		add_filter( 'excerpt_length', 'abblog_excerpt_length', 999 );

	}
endif;
add_action( 'after_setup_theme', 'abblog_setup' );

/**
 * Set the content width in pixels, based on the theme's design and stylesheet.
 *
 * Priority 0 to make it available to lower priority callbacks.
 *
 * @global int $content_width
 */
function abblog_content_width() {
	$GLOBALS['content_width'] = apply_filters( 'abblog_content_width', 1140 );
}
add_action( 'after_setup_theme', 'abblog_content_width', 0 );



/**
 * Register widget area.
 *
 * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
 */
function abblog_widgets_init() {
	register_sidebar(
		array(
			'name'          => esc_html__( 'Sidebar', 'abblog' ),
			'id'            => 'sidebar-1',
			'description'   => esc_html__( 'Add widgets here.', 'abblog' ),
			'before_widget' => '<section id="%1$s" class="widget %2$s">',
			'after_widget'  => '</section>',
			'before_title'  => '<h2 class="widget-title">',
			'after_title'   => '</h2>',
		)
	);

	 
}
add_action( 'widgets_init', 'abblog_widgets_init' );



/**
 * Enqueue scripts and styles.
 */
function abblog_scripts() {
  // Add custom fonts, used in the main stylesheet.
  wp_enqueue_style( 'abblog-fonts', abblog_fonts_url(), array(), null );

  // Add Font Awesome Icons. Unminified version included.
  wp_enqueue_style('fontAwesome', get_template_directory_uri() . '/inc/font-awesome/css/fontawesome-all.min.css', array(), '5.0.12' );
  
  // Load our responsive stylesheet based on Bootstrap. Unminified version included.
	wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css', array( ), '3.3.5' );
  
	wp_enqueue_style( 'abblog-style', get_stylesheet_uri(), array(), ABBLOG_VERSION );
	

  wp_enqueue_script( 'abblog-navigation', get_template_directory_uri() . '/js/navigation.js', array(), ABBLOG_VERSION, true );
  
  // customjs
	wp_enqueue_script( 'abblog-article-main-js', get_template_directory_uri() . '/js/main.js', array('jquery'), '1.0.0', true );
	wp_enqueue_script( 'abblog-custom-main-js', get_template_directory_uri() . '/js/abblog-custom.js', array('jquery'), '1.0.0', true );

		


	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
		wp_enqueue_script( 'comment-reply' );
	}
}
add_action( 'wp_enqueue_scripts', 'abblog_scripts' );

/**
 * Implement the Custom Header feature.
 */
require get_template_directory() . '/inc/custom-header.php';



/**
 * Register Google fonts.
 * @return string Google fonts URL for the theme.
 */

if ( ! function_exists( 'abblog_fonts_url' ) ) :
	function abblog_fonts_url() {
		$abblog_fonts_url = '';
		$abblog_fonts     = array();
		$abblog_font_subsets   = 'latin,latin-ext';
			
		// Translators: If there are characters in your language that are not supported by Open Sans, translate this to 'off'. Do not translate into your own language. 
		if ( 'off' !== esc_html_x( 'on', 'Open Sans font: on or off', 'abblog' ) ) {
			$abblog_fonts[] = 'Open Sans:400,600,700';
		}
			
		// Translators: If there are characters in your language that are not supported by Bad Script, translate this to 'off'. Do not translate into your own language. 
		if ( 'off' !== esc_html_x( 'on', 'Bad Script font: on or off', 'abblog' ) ) {
			$abblog_fonts[] = 'Bad Script:400';
		}	
	
		if ( $abblog_fonts ) {
			$abblog_fonts_url = add_query_arg( array(
				'family' => urlencode( implode( '|', $abblog_fonts ) ),
				'subset' => urlencode( $abblog_font_subsets ),
			), 'https://fonts.googleapis.com/css' );
		}
	
		return $abblog_fonts_url;
	}
	endif;

/**
 * Custom template tags for this theme.
 */
require get_template_directory() . '/inc/template-tags.php';

/**
 * Functions which enhance the theme by hooking into WordPress.
 */
require get_template_directory() . '/inc/template-functions.php';

/**
 * Customizer additions.
 */
require get_template_directory() . '/inc/customizer.php';



/**
 * abblog customizer
 */
require get_template_directory() . '/inc/abnoo-customizer/class-customize.php';






/**
 * Compare page CSS
 */

function abblog_comparepage_css($hook) {
	if ( 'appearance_page_abblog-info' != $hook ) {
		return;
	}
	wp_enqueue_style( 'abblog-custom-style', get_template_directory_uri() . '/css/compare.css' );
}
add_action( 'admin_enqueue_scripts', 'abblog_comparepage_css' );

/**
 * Compare page content
 */

add_action('admin_menu', 'abblog_themepage');
function abblog_themepage(){
	$theme_info = add_theme_page( __('Abblog Info','abblog'), __('Abblog Info','abblog'), 'manage_options', 'abblog-info.php', 'abblog_info_page' );
}

function abblog_info_page() {
	$user = wp_get_current_user();
	?>
	<div class="wrap about-wrap abblog-add-css">
		<div>
			<h1>
				<?php echo esc_html_e('Thank you for using Abblog Theme','abblog'); ?>
			</h1>

			
		</div>
		<hr>

		<h2><?php echo esc_html_e("Get Abblog PRO Theme Just $12","abblog"); ?></h2>
		<div class="col">
					<div class="widgets-holder-wrap">
						 <p><?php echo esc_html_e("You are using Free Version of Abblog Pro Theme. Upgrade to Pro for more extra features like Home Page Unlimited Slider, Work Gallery, Photo Gallery, Team & Client Section, Contact Page and many more Page Templates, Social Link Section, Documents, Life time customer support and much more.", "abblog"); ?></p>
						 
					</div>
				</div>
		<div class="abblog-button-container">
			<a target="blank" href="http://abnoothemes.com/abblog-responsive-multipurpose-wordpress-theme/" class="button button-primary abblogbt">
				<?php echo esc_html_e("Upgrade to Abblog Pro", "abblog"); ?>
			</a>
		</div>


		

	</div>
	<?php
}












