<?php
/**
 * Getting Started Page.
 *
 * @package blog_starter
 */


$construc_theme = wp_get_theme();
$construc_version = $construc_theme->get('Version');
$construc_name = $construc_theme->get('Name');

define('construc_THEME_VERSION', $construc_version);
define('construc_THEME_NAME', $construc_name);
require get_template_directory() . '/inc/getting-started/class-getting-start-plugin-helper.php';

if( ! function_exists( 'construc_getting_started_admin_scripts' ) ) :
/**
 * Load Getting Started styles in the admin
 */
function construc_getting_started_admin_scripts( $hook ){
    wp_enqueue_style( 'construc-focus', get_template_directory_uri() . '/inc/getting-started/css/focus.css', false, construc_THEME_VERSION );
	// Load styles only on our page
	if( 'appearance_page_construc-getting-started' != $hook ) return;

    wp_enqueue_style( 'construc-getting-started', get_template_directory_uri() . '/inc/getting-started/css/getting-started.css', false, construc_THEME_VERSION );
    
    wp_enqueue_script( 'plugin-install' );
    wp_enqueue_script( 'updates' );
    wp_enqueue_script( 'construc-getting-started', get_template_directory_uri() . '/inc/getting-started/js/getting-started.js', array( 'jquery' ), construc_THEME_VERSION, true );
    wp_enqueue_script( 'construc-recommended-plugin-install', get_template_directory_uri() . '/inc/getting-started/js/recommended-plugin-install.js', array( 'jquery' ), construc_THEME_VERSION, true );    
    wp_localize_script( 'construc-recommended-plugin-install', 'construc_start_page', array( 'activating' => __( 'Activating ', 'construc' ) ) );
}
endif;
add_action( 'admin_enqueue_scripts', 'construc_getting_started_admin_scripts' );

if( ! function_exists( 'construc_call_plugin_api' ) ) :
/**
 * Plugin API
**/
function construc_call_plugin_api( $plugin ) {
	include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
	$call_api = plugins_api( 
        'plugin_information', 
            array(
    		'slug'   => $plugin,
    		'fields' => array(
    			'downloaded'        => false,
    			'rating'            => false,
    			'description'       => false,
    			'short_description' => true,
    			'donate_link'       => false,
    			'tags'              => false,
    			'sections'          => true,
    			'homepage'          => true,
    			'added'             => false,
    			'last_updated'      => false,
    			'compatibility'     => false,
    			'tested'            => false,
    			'requires'          => false,
    			'downloadlink'      => false,
    			'icons'             => true
    		)
    	) 
    );
	return $call_api;
}
endif;

if( ! function_exists( 'construc_check_for_icon' ) ) :
/**
 * Check For Icon 
**/
function construc_check_for_icon( $arr ) {
	if( ! empty( $arr['svg'] ) ){
		$plugin_icon_url = $arr['svg'];
	}elseif( ! empty( $arr['2x'] ) ){
		$plugin_icon_url = $arr['2x'];
	}elseif( ! empty( $arr['1x'] ) ){
		$plugin_icon_url = $arr['1x'];
	}else{
		$plugin_icon_url = $arr['default'];
	}                               
	return $plugin_icon_url;
}
endif;