PluginProbe
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels / 1.2.0
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels v1.2.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.2.0, at includes/init.php

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