### FooGallery Extension Initialization Source: https://github.com/wp-plugins/foogallery/blob/master/includes/admin/boilerplates/template/foogallery-EXTSLUG-extension.php.txt Defines constants and includes the main initialization file for the extension. ```php if ( !class_exists( '{package}' ) ) { define('{constant}_URL', plugin_dir_url( __FILE__ )); define('{constant}_VERSION', '1.0.0'); require_once( 'foogallery-{slug}-init.php' ); ``` -------------------------------- ### Initialize FooGallery Extension Source: https://github.com/wp-plugins/foogallery/blob/master/includes/admin/boilerplates/lightbox/foogallery-EXTSLUG-init.php.txt Use this class to add your extension to the FooGallery available extensions list during development. This file is not needed once the extension is officially supported. ```php '{slug}', 'class'=> '{package}', 'title'=> __('{name}', '{plugin_slug}'), 'file'=> 'foogallery-{slug}-extension.php', 'description'=> __('{desc}', '{plugin_slug}'), 'author'=> '{author}', 'author_url'=> '{author_link}', 'thumbnail'=> {constant}_URL . '/assets/extension_bg.png', 'tags'=> array( __('{type}', 'foogallery') ), //use foogallery translations 'categories'=> array( __('Build Your Own', 'foogallery') ), //use foogallery translations 'source'=> 'generated' ); return $extensions; } } new {package}_Init(); } ``` -------------------------------- ### FooGallery Extension Class Structure Source: https://github.com/wp-plugins/foogallery/blob/master/includes/admin/boilerplates/template/foogallery-EXTSLUG-extension.php.txt Main class for the FooGallery extension, including the constructor and methods for template registration and dependency enqueuing. ```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' ) ); } /** * 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; } /** * 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'; //wp_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' => '', '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'), ``` -------------------------------- ### FooGallery Template Rendering Source: https://github.com/wp-plugins/foogallery/blob/master/includes/admin/boilerplates/template/gallery-EXTSLUG.php.txt This PHP code defines the structure for displaying a FooGallery on the frontend. It retrieves gallery settings and iterates through attachments to generate HTML for each image, including lightbox integration. ```php ``` -------------------------------- ### FooGallery Lightbox Extension Boilerplate Source: https://github.com/wp-plugins/foogallery/blob/master/includes/admin/boilerplates/lightbox/foogallery-EXTSLUG-extension.php.txt This is the main class structure for a FooGallery lightbox extension. It defines constants, includes initialization files, and sets up hooks for integrating a new lightbox. ```php ID}]"; } return $attr; } } } ``` -------------------------------- ### FooGallery Extension Plugin Header Source: https://github.com/wp-plugins/foogallery/blob/master/includes/admin/boilerplates/template/foogallery-EXTSLUG-extension.php.txt Standard WordPress plugin header information for a FooGallery extension. ```php