PluginProbe
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels / 1.1.0
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels v1.1.0
2.9.1 2.9.0 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 2.0.0 2.1.0 2.2.0 2.3.2 2.3.3 2.3.5 2.3.6 2.3.8 2.3.9 2.4.3 All 37 releases
automatic-youtube-gallery / includes / init.php

init.php in Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels 1.1.0, at includes/init.php

212 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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://plugins360.com
10 * @since 1.0.0
11 *
12 * @package Automatic_YouTube_Gallery
13 * @subpackage Automatic_YouTube_Gallery/includes
14 */
15
16 // Exit if accessed directly
17 if ( ! defined( 'WPINC' ) ) {
18 die;
19 }
20
21 /**
22 * AYG_Init - The main plugin class.
23 *
24 * @since 1.0.0
25 */
26 class AYG_Init {
27
28 /**
29 * The loader that's responsible for maintaining and registering all hooks that power
30 * the plugin.
31 *
32 * @since 1.0.0
33 * @access protected
34 * @var AYG_Loader $loader Maintains and registers all hooks for the plugin.
35 */
36 protected $loader;
37
38 /**
39 * Get things started.
40 *
41 * @since 1.0.0
42 */
43 public function __construct() {
44
45 $this->load_dependencies();
46 $this->set_locale();
47 $this->define_admin_hooks();
48 $this->define_public_hooks();
49 $this->define_block_hooks();
50
51 }
52
53 /**
54 * Load the required dependencies for this plugin.
55 *
56 * Create an instance of the loader which will be used to register the hooks
57 * with WordPress.
58 *
59 * @since 1.0.0
60 * @access private
61 */
62 private function load_dependencies() {
63
64 /**
65 * The class responsible for orchestrating the actions and filters of the
66 * core plugin.
67 */
68 require_once AYG_DIR . 'includes/loader.php';
69
70 /**
71 * The class responsible for defining internationalization functionality
72 * of the plugin.
73 */
74 require_once AYG_DIR . 'includes/i18n.php';
75
76 /**
77 * A wrapper class for the Youtube Data API v3.
78 */
79 require_once AYG_DIR . 'includes/youtube-api.php';
80
81 /**
82 * The file that holds the general helper functions.
83 */
84 require_once AYG_DIR . 'includes/functions.php';
85
86 /**
87 * The classes responsible for defining all actions that occur in the admin area.
88 */
89 require_once AYG_DIR . 'admin/admin.php';
90 require_once AYG_DIR . 'admin/settings.php';
91 require_once AYG_DIR . 'admin/shortcode-builder.php';
92 require_once AYG_DIR . 'admin/welcome.php';
93
94 /**
95 * The class responsible for defining all actions that occur in the public-facing
96 * side of the site.
97 */
98 require_once AYG_DIR . 'public/public.php';
99
100 /**
101 * The class responsible for defining all actions that occur in the gutenberg block.
102 */
103 require_once AYG_DIR. 'block/block.php';
104
105 /**
106 * Create an instance of the loader.
107 */
108 $this->loader = new AYG_Loader();
109
110 }
111
112 /**
113 * Define the locale for this plugin for internationalization.
114 *
115 * @since 1.0.0
116 * @access private
117 */
118 private function set_locale() {
119
120 $ayg_i18n = new AYG_i18n();
121
122 $this->loader->add_action( 'plugins_loaded', $ayg_i18n, 'load_plugin_textdomain' );
123
124 }
125
126 /**
127 * Register all of the hooks related to the admin area functionality
128 * of the plugin.
129 *
130 * @since 1.0.0
131 * @access private
132 */
133 private function define_admin_hooks() {
134
135 // Hooks common to all admin pages
136 $ayg_admin = new AYG_Admin();
137
138 $this->loader->add_action( 'admin_enqueue_scripts', $ayg_admin, 'enqueue_styles' );
139 $this->loader->add_action( 'admin_enqueue_scripts', $ayg_admin, 'enqueue_scripts' );
140 $this->loader->add_action( 'admin_notices', $ayg_admin, 'admin_notice' );
141 $this->loader->add_action( 'wp_ajax_ayg_dismiss_admin_notice', $ayg_admin, 'ajax_callback_dismiss_admin_notice' );
142
143 $this->loader->add_filter( 'plugin_action_links_' . AYG_FILE_NAME, $ayg_admin, 'plugin_action_links' );
144
145 // Hooks specific to the settings page
146 $ayg_admin_settings = new AYG_Admin_Settings();
147
148 $this->loader->add_action( 'admin_menu', $ayg_admin_settings, 'add_settings_menu' );
149 $this->loader->add_action( 'admin_init', $ayg_admin_settings, 'admin_init' );
150 $this->loader->add_action( 'admin_init', $ayg_admin_settings, 'delete_cache' );
151 $this->loader->add_action( 'admin_notices', $ayg_admin_settings, 'admin_notices' );
152
153 // Hooks specific to the shortcode builder
154 $ayg_admin_shortcode_builder = new AYG_Admin_Shortcode_Builder();
155
156 $this->loader->add_action( 'media_buttons', $ayg_admin_shortcode_builder, 'media_buttons', 11 );
157 $this->loader->add_action( 'admin_footer', $ayg_admin_shortcode_builder, 'admin_footer' );
158
159 // Hooks specific to the welcome page
160 $ayg_admin_welcome = new AYG_Admin_Welcome();
161
162 $this->loader->add_action( 'admin_menu', $ayg_admin_welcome, 'add_welcome_page_menu' );
163
164 }
165
166 /**
167 * Register all of the hooks related to the public-facing functionality
168 * of the plugin.
169 *
170 * @since 1.0.0
171 * @access private
172 */
173 private function define_public_hooks() {
174
175 $ayg_public = new AYG_Public();
176
177 $this->loader->add_action( 'wp_enqueue_scripts', $ayg_public, 'register_styles' );
178 $this->loader->add_action( 'wp_enqueue_scripts', $ayg_public, 'register_scripts' );
179 $this->loader->add_action( 'wp_ajax_ayg_load_more_videos', $ayg_public, 'ajax_callback_load_more_videos' );
180 $this->loader->add_action( 'wp_ajax_nopriv_ayg_load_more_videos', $ayg_public, 'ajax_callback_load_more_videos' );
181
182 }
183
184 /**
185 * Register all of the hooks related to the gutenberg block.
186 *
187 * @since 1.0.0
188 * @access private
189 */
190 private function define_block_hooks() {
191
192 $ayg_block = new AYG_Block();
193
194 $this->loader->add_action( 'init', $ayg_block, 'register_block_type' );
195 $this->loader->add_action( 'enqueue_block_editor_assets', $ayg_block, 'enqueue_block_editor_assets' );
196 $this->loader->add_action( 'enqueue_block_assets', $ayg_block, 'enqueue_block_assets' );
197
198 $this->loader->add_filter( 'block_categories', $ayg_block, 'block_categories' );
199
200 }
201
202 /**
203 * Run the loader to execute all of the hooks with WordPress.
204 *
205 * @since 1.0.0
206 */
207 public function run() {
208 $this->loader->run();
209 }
210
211 }
212