|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * The file that defines the core plugin class |
| 5 | + * |
| 6 | + * A class definition that includes attributes and functions used across both the |
| 7 | + * public-facing side of the site and the admin area. |
| 8 | + * |
| 9 | + * @link https://addonify.com/ |
| 10 | + * @since 1.0.0 |
| 11 | + * |
| 12 | + * @package Addonify_Gutenberg_Block_Image_Gallery_Lightbox |
| 13 | + * @subpackage Addonify_Gutenberg_Block_Image_Gallery_Lightbox/includes |
| 14 | + */ |
| 15 | + |
| 16 | +/** |
| 17 | + * The core plugin class. |
| 18 | + * |
| 19 | + * This is used to define internationalization, admin-specific hooks, and |
| 20 | + * public-facing site hooks. |
| 21 | + * |
| 22 | + * Also maintains the unique identifier of this plugin as well as the current |
| 23 | + * version of the plugin. |
| 24 | + * |
| 25 | + * @since 1.0.0 |
| 26 | + * @package Addonify_Gutenberg_Block_Image_Gallery_Lightbox |
| 27 | + * @subpackage Addonify_Gutenberg_Block_Image_Gallery_Lightbox/includes |
| 28 | + * @author Addonify <addonify@gmail.com> |
| 29 | + */ |
| 30 | +class Addonify_Gutenberg_Block_Image_Gallery_Lightbox { |
| 31 | + |
| 32 | + /** |
| 33 | + * The loader that's responsible for maintaining and registering all hooks that power |
| 34 | + * the plugin. |
| 35 | + * |
| 36 | + * @since 1.0.0 |
| 37 | + * @access protected |
| 38 | + * @var Addonify_Gutenberg_Block_Image_Gallery_Lightbox_Loader $loader Maintains and registers all hooks for the plugin. |
| 39 | + */ |
| 40 | + protected $loader; |
| 41 | + |
| 42 | + /** |
| 43 | + * The unique identifier of this plugin. |
| 44 | + * |
| 45 | + * @since 1.0.0 |
| 46 | + * @access protected |
| 47 | + * @var string $plugin_name The string used to uniquely identify this plugin. |
| 48 | + */ |
| 49 | + protected $plugin_name; |
| 50 | + |
| 51 | + /** |
| 52 | + * The current version of the plugin. |
| 53 | + * |
| 54 | + * @since 1.0.0 |
| 55 | + * @access protected |
| 56 | + * @var string $version The current version of the plugin. |
| 57 | + */ |
| 58 | + protected $version; |
| 59 | + |
| 60 | + /** |
| 61 | + * Define the core functionality of the plugin. |
| 62 | + * |
| 63 | + * Set the plugin name and the plugin version that can be used throughout the plugin. |
| 64 | + * Load the dependencies, define the locale, and set the hooks for the admin area and |
| 65 | + * the public-facing side of the site. |
| 66 | + * |
| 67 | + * @since 1.0.0 |
| 68 | + */ |
| 69 | + public function __construct() { |
| 70 | + if ( defined( 'ADDONIFY_GUTENBERG_BLOCK_IMAGE_GALLERY_LIGHTBOX_VERSION' ) ) { |
| 71 | + $this->version = ADDONIFY_GUTENBERG_BLOCK_IMAGE_GALLERY_LIGHTBOX_VERSION; |
| 72 | + } else { |
| 73 | + $this->version = '1.0.0'; |
| 74 | + } |
| 75 | + $this->plugin_name = 'addonify-gutenberg-block-image-gallery-lightbox'; |
| 76 | + |
| 77 | + $this->load_dependencies(); |
| 78 | + $this->set_locale(); |
| 79 | + $this->define_public_hooks(); |
| 80 | + |
| 81 | + } |
| 82 | + |
| 83 | + /** |
| 84 | + * Load the required dependencies for this plugin. |
| 85 | + * |
| 86 | + * Include the following files that make up the plugin: |
| 87 | + * |
| 88 | + * - Addonify_Gutenberg_Block_Image_Gallery_Lightbox_Loader. Orchestrates the hooks of the plugin. |
| 89 | + * - Addonify_Gutenberg_Block_Image_Gallery_Lightbox_i18n. Defines internationalization functionality. |
| 90 | + * - Addonify_Gutenberg_Block_Image_Gallery_Lightbox_Admin. Defines all hooks for the admin area. |
| 91 | + * - Addonify_Gutenberg_Block_Image_Gallery_Lightbox_Public. Defines all hooks for the public side of the site. |
| 92 | + * |
| 93 | + * Create an instance of the loader which will be used to register the hooks |
| 94 | + * with WordPress. |
| 95 | + * |
| 96 | + * @since 1.0.0 |
| 97 | + * @access private |
| 98 | + */ |
| 99 | + private function load_dependencies() { |
| 100 | + |
| 101 | + /** |
| 102 | + * The class responsible for orchestrating the actions and filters of the |
| 103 | + * core plugin. |
| 104 | + */ |
| 105 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-loader.php'; |
| 106 | + |
| 107 | + /** |
| 108 | + * The class responsible for defining internationalization functionality |
| 109 | + * of the plugin. |
| 110 | + */ |
| 111 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-i18n.php'; |
| 112 | + |
| 113 | + /** |
| 114 | + * The class responsible for defining all actions that occur in the public-facing |
| 115 | + * side of the site. |
| 116 | + */ |
| 117 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-addonify-gutenberg-block-image-gallery-lightbox-public.php'; |
| 118 | + |
| 119 | + $this->loader = new Addonify_Gutenberg_Block_Image_Gallery_Lightbox_Loader(); |
| 120 | + |
| 121 | + } |
| 122 | + |
| 123 | + /** |
| 124 | + * Define the locale for this plugin for internationalization. |
| 125 | + * |
| 126 | + * Uses the Addonify_Gutenberg_Block_Image_Gallery_Lightbox_i18n class in order to set the domain and to register the hook |
| 127 | + * with WordPress. |
| 128 | + * |
| 129 | + * @since 1.0.0 |
| 130 | + * @access private |
| 131 | + */ |
| 132 | + private function set_locale() { |
| 133 | + |
| 134 | + $plugin_i18n = new Addonify_Gutenberg_Block_Image_Gallery_Lightbox_i18n(); |
| 135 | + |
| 136 | + $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
| 137 | + |
| 138 | + } |
| 139 | + |
| 140 | + /** |
| 141 | + * Register all of the hooks related to the public-facing functionality |
| 142 | + * of the plugin. |
| 143 | + * |
| 144 | + * @since 1.0.0 |
| 145 | + * @access private |
| 146 | + */ |
| 147 | + private function define_public_hooks() { |
| 148 | + |
| 149 | + $plugin_public = new Addonify_Gutenberg_Block_Image_Gallery_Lightbox_Public( $this->get_plugin_name(), $this->get_version() ); |
| 150 | + |
| 151 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
| 152 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
| 153 | + |
| 154 | + } |
| 155 | + |
| 156 | + /** |
| 157 | + * Run the loader to execute all of the hooks with WordPress. |
| 158 | + * |
| 159 | + * @since 1.0.0 |
| 160 | + */ |
| 161 | + public function run() { |
| 162 | + $this->loader->run(); |
| 163 | + } |
| 164 | + |
| 165 | + /** |
| 166 | + * The name of the plugin used to uniquely identify it within the context of |
| 167 | + * WordPress and to define internationalization functionality. |
| 168 | + * |
| 169 | + * @since 1.0.0 |
| 170 | + * @return string The name of the plugin. |
| 171 | + */ |
| 172 | + public function get_plugin_name() { |
| 173 | + return $this->plugin_name; |
| 174 | + } |
| 175 | + |
| 176 | + /** |
| 177 | + * The reference to the class that orchestrates the hooks with the plugin. |
| 178 | + * |
| 179 | + * @since 1.0.0 |
| 180 | + * @return Addonify_Gutenberg_Block_Image_Gallery_Lightbox_Loader Orchestrates the hooks of the plugin. |
| 181 | + */ |
| 182 | + public function get_loader() { |
| 183 | + return $this->loader; |
| 184 | + } |
| 185 | + |
| 186 | + /** |
| 187 | + * Retrieve the version number of the plugin. |
| 188 | + * |
| 189 | + * @since 1.0.0 |
| 190 | + * @return string The version number of the plugin. |
| 191 | + */ |
| 192 | + public function get_version() { |
| 193 | + return $this->version; |
| 194 | + } |
| 195 | + |
| 196 | +} |
0 commit comments