<?php
/**
 * FooGallery {name} Extension
 *
 * {desc}
 *
 * @package   {package}
 * @author    {author}
 * @license   GPL-2.0+
 * @link      {author_link}
 * @copyright 2014 {author}
 *
 * @wordpress-plugin
 * Plugin Name: FooGallery - {name}
 * Description: {desc}
 * Version:     1.0.0
 * Author:      {author}
 * Author URI:  {author_link}
 * License:     GPL-2.0+
 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
 */

if ( !class_exists( '{package}' ) ) {

	define('{constant}_FILE', __FILE__ );
	define('{constant}_URL', plugin_dir_url( __FILE__ ));
	define('{constant}_VERSION', '1.0.0');
	define('{constant}_PATH', plugin_dir_path( __FILE__ ));
	define('{constant}_SLUG', 'foogallery-{slug}');
	//define('{constant}_UPDATE_URL', 'http://fooplugins.com');
	//define('{constant}_UPDATE_ITEM_NAME', '{name}');

	require_once( 'foogallery-{slug}-init.php' );

	class {package} {
		/**
		 * Wire up everything we need to run the extension
		 */
		function __construct() {
			add_filter( 'foogallery_gallery_templates', array( $this, 'add_template' ) );
			add_filter( 'foogallery_gallery_templates_files', array( $this, 'register_myself' ) );
			add_filter( 'foogallery_located_template-{slug}', array( $this, 'enqueue_dependencies' ) );
			add_filter( 'foogallery_template_js_ver-{slug}', array( $this, 'override_version' ) );
			add_filter( 'foogallery_template_css_ver-{slug}', array( $this, 'override_version' ) );

			//used for auto updates and licensing in premium extensions. Delete if not applicable
			//init licensing and update checking
			//require_once( {constant}_PATH . 'includes/EDD_SL_FooGallery.php' );

			//new EDD_SL_FooGallery_v1_1(
			//	{constant}_FILE,
			//	{constant}_SLUG,
			//	{constant}_VERSION,
			//	{constant}_UPDATE_URL,
			//	{constant}_UPDATE_ITEM_NAME,
			//	'{name}');
		}

		/**
		 * Register myself so that all associated JS and CSS files can be found and automatically included
		 * @param $extensions
		 *
		 * @return array
		 */
		function register_myself( $extensions ) {
			$extensions[] = __FILE__;
			return $extensions;
		}

		/**
		 * Override the asset version number when enqueueing extension assets
		 */
		function override_version( $version ) {
			return {constant}_VERSION;
		}

		/**
		 * Enqueue any script or stylesheet file dependencies that your gallery template relies on
		 */
		function enqueue_dependencies() {
			//$js = {constant}_URL . 'js/jquery.{slug}.js';
			//wp_enqueue_script( '{slug}', $js, array('jquery'), {constant}_VERSION );

			//$css = {constant}_URL . 'css/{slug}.css';
			//foogallery_enqueue_style( '{slug}', $css, array(), {constant}_VERSION );
		}

		/**
		 * Add our gallery template to the list of templates available for every gallery
		 * @param $gallery_templates
		 *
		 * @return array
		 */
		function add_template( $gallery_templates ) {

			$gallery_templates[] = array(
				'slug'        => '{slug}',
				'name'        => __( '{name}', '{plugin_slug}'),
				'preview_css' => {constant}_URL . 'css/gallery-{slug}.css',
				'admin_js'	  => {constant}_URL . 'js/admin-gallery-{slug}.js',
				'fields'	  => array(
					array(
						'id'      => 'thumbnail_size',
						'title'   => __('Thumbnail Size', '{plugin_slug}'),
						'desc'    => __('Choose the size of your thumbs.', '{plugin_slug}'),
						'type'    => 'thumb_size',
						'default' => array(
							'width' => get_option( 'thumbnail_size_w' ),
							'height' => get_option( 'thumbnail_size_h' ),
							'crop' => true
						)
					),
					array(
						'id'      => 'thumbnail_link',
						'title'   => __('Thumbnail Link', '{plugin_slug}'),
						'default' => 'image' ,
						'type'    => 'thumb_link',
						'spacer'  => '<span class="spacer"></span>',
						'desc'	  => __('You can choose to either link each thumbnail to the full size image or to the image\'s attachment page.', '{plugin_slug}')
					),
					array(
						'id'      => 'lightbox',
						'title'   => __('Lightbox', '{plugin_slug}'),
						'desc'    => __('Choose which lightbox you want to use in the gallery.', '{plugin_slug}'),
						'type'    => 'lightbox'
					),
					array(
						'id'      => 'alignment',
						'title'   => __('Gallery Alignment', '{plugin_slug}'),
						'desc'    => __('The horizontal alignment of the thumbnails inside the gallery.', '{plugin_slug}'),
						'default' => 'alignment-center',
						'type'    => 'select',
						'choices' => array(
							'alignment-left' => __( 'Left', '{plugin_slug}' ),
							'alignment-center' => __( 'Center', '{plugin_slug}' ),
							'alignment-right' => __( 'Right', '{plugin_slug}' )
						)
					)
					//available field types available : html, checkbox, select, radio, textarea, text, checkboxlist, icon
					//an example of a icon field used in the default gallery template
					//array(
					//	'id'      => 'border-style',
					//	'title'   => __('Border Style', '{plugin_slug}'),
					//	'desc'    => __('The border style for each thumbnail in the gallery.', '{plugin_slug}'),
					//	'type'    => 'icon',
					//	'default' => 'border-style-square-white',
					//	'choices' => array(
					//		'border-style-square-white' => array('label' => 'Square white border with shadow', 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_URL . 'assets/border-style-icon-square-white.png'),
					//		'border-style-circle-white' => array('label' => 'Circular white border with shadow', 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_URL . 'assets/border-style-icon-circle-white.png'),
					//		'border-style-square-black' => array('label' => 'Square Black', 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_URL . 'assets/border-style-icon-square-black.png'),
					//		'border-style-circle-black' => array('label' => 'Circular Black', 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_URL . 'assets/border-style-icon-circle-black.png'),
					//		'border-style-inset' => array('label' => 'Square Inset', 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_URL . 'assets/border-style-icon-square-inset.png'),
					//		'border-style-rounded' => array('label' => 'Plain Rounded', 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_URL . 'assets/border-style-icon-plain-rounded.png'),
					//		'' => array('label' => 'Plain', 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_URL . 'assets/border-style-icon-none.png'),
					//	)
					//),
				)
			);

			return $gallery_templates;
		}
	}
}