<?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}_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}'); 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' ) ); add_filter( 'foogallery_gallery_template_arguments-{slug}', array( $this, 'build_gallery_template_arguments' ) ); } /** * 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() { //wp_enqueue_script( // '{slug}-dependency', // {constant}_URL . 'js/{slug}-dependency.js', // array(), // {constant}_VERSION //); wp_enqueue_script( '{slug}', {constant}_URL . 'js/{slug}.js', array(), //array('{slug}-dependency'), {constant}_VERSION ); foogallery_enqueue_style( 'scattered-polaroids-gallery', {constant}_URL . 'css/photostack.css', array(), //include any CSS dependencies here {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_support' => true, 'preview_css' => {constant}_URL . 'css/gallery-{slug}.css', 'admin_js' => {constant}_URL . 'js/admin-gallery-{slug}.js', 'fields' => array( array( 'id' => 'thumbnail_dimensions', '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' => {constant}_URL . 'assets/border-style-icon-square-white.png'), // 'border-style-circle-white' => array('label' => 'Circular white border with shadow', 'img' => {constant}_URL . 'assets/border-style-icon-circle-white.png'), // 'border-style-square-black' => array('label' => 'Square Black', 'img' => {constant}_URL . 'assets/border-style-icon-square-black.png'), // 'border-style-circle-black' => array('label' => 'Circular Black', 'img' => {constant}_URL . 'assets/border-style-icon-circle-black.png'), // 'border-style-inset' => array('label' => 'Square Inset', 'img' => {constant}_URL . 'assets/border-style-icon-square-inset.png'), // 'border-style-rounded' => array('label' => 'Plain Rounded', 'img' => {constant}_URL . 'assets/border-style-icon-plain-rounded.png'), // '' => array('label' => 'Plain', 'img' => {constant}_URL . 'assets/border-style-icon-none.png'), // ) //), ) ); return $gallery_templates; } /** * Build up the arguments needed for rendering the gallery template * * @param $args * @return array */ function build_gallery_template_arguments( $args ) { $args = foogallery_gallery_template_setting( 'thumbnail_dimensions', array() ); $args['crop'] = '1'; //we now force thumbs to be cropped $args['link'] = foogallery_gallery_template_setting( 'thumbnail_link', 'image' ); return $args; } } } new {package}();