<?php
/**
 * Getting Started Page. 
 *
 * @package Consultco
 */
require get_template_directory() . '/inc/ansar/admin/class-getting-start-plugin-helper.php';


// Load Getting Started styles in the admin
if( ! function_exists( 'consultco_getting_started_admin_scripts' ) ) :
function consultco_getting_started_admin_scripts( $hook ){
	// Load styles only on our page
	if( 'appearance_page_consultco-getting-started' != $hook ) return;

    wp_enqueue_style( 'consultco-getting-started', get_template_directory_uri() . '/inc/ansar/admin/css/getting-started.css', false, CONSULTCO_THEME_VERSION );
    wp_enqueue_script( 'plugin-install' );
    wp_enqueue_script( 'updates' );
    wp_enqueue_script( 'consultco-getting-started', get_template_directory_uri() . '/inc/ansar/admin/js/getting-started.js', array( 'jquery' ), CONSULTCO_THEME_VERSION, true );
    wp_enqueue_script( 'consultco-recommended-plugin-install', get_template_directory_uri() . '/inc/ansar/admin/js/recommended-plugin-install.js', array( 'jquery' ), CONSULTCO_THEME_VERSION, true );    
    wp_localize_script( 'consultco-recommended-plugin-install', 'consultco_start_page', array( 'activating' => __( 'Activating ', 'consultco' ) ) );
}
endif;
add_action( 'admin_enqueue_scripts', 'consultco_getting_started_admin_scripts' );


// Plugin API
if( ! function_exists( 'consultco_call_plugin_api' ) ) :
function consultco_call_plugin_api( $slug ) {
	require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
		$call_api = get_transient( 'consultco_about_plugin_info_' . $slug );

		if ( false === $call_api ) {
				$call_api = plugins_api(
					'plugin_information', array(
						'slug'   => $slug,
						'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,
						),
					)
				);
				set_transient( 'consultco_about_plugin_info_' . $slug, $call_api, 30 * MINUTE_IN_SECONDS );
			}

			return $call_api;
		}
endif;