<?php
/**
 * FooGallery - {name}
 *
 * {desc}
 *
 * 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}_URL', plugin_dir_url( __FILE__ ));
	define('{constant}_VERSION', '1.0.0');

	class {package} {

		/**
		 * Wire up everything we need to run
		 */
		function __construct() {
			add_filter( 'foogallery_gallery_template_field_lightboxes', array($this, 'add_lightbox') );
			add_action( 'foogallery_template_lightbox-{slug}', array($this, 'add_required_files') );
			add_filter( 'foogallery_attachment_html_link_attributes', array($this, 'add_html_attributes') );
		}

		/**
		 * Add our lightbox to the lightbox dropdown on the gallery edit page
		 */
		function add_lightbox($lightboxes) {
			$lightboxes['{slug}'] = __( '{name}', '{plugin_slug}' );
			return $lightboxes;
		}

		/**
		 * Add any JS or CSS required by the extension
		 */
		function add_required_files() {
			//enqueue the lightbox script
			wp_enqueue_script( '{slug}', {constant}_URL . 'js/lightbox-{slug}.js', array('jquery'), {constant}_VERSION );
			//optional : enqueue the init code to hook up your lightbox
			//wp_enqueue_script( '{slug}_init', {constant}_URL . 'js/lightbox-{slug}-init.js', array('{slug}'), {constant}_VERSION );
			//enqueue the lightbox stylesheets
			foogallery_enqueue_style( '{slug}', {constant}_URL . 'css/lightbox-{slug}.css', array(), {constant}_VERSION );
		}

		/**
		 * Optional. Alter the anchor attributes so that the lightbox extension can work
		 */
		function add_html_attributes($attr) {
			global $current_foogallery;

			$lightbox = foogallery_gallery_template_setting( 'lightbox' );

			//if the gallery is using our lightbox, then alter the HTML so the lightbox script can find it
			if ( '{slug}' == $lightbox ) {
				//add custom attributes to the anchor
				//$attr['rel'] = "{slug}[foogallery-{$current_foogallery->ID}]";
			}

			return $attr;
		}
	}
}

new {package}();