PluginProbe
Video Gallery – YouTube Gallery, Playlist & Video Grid / 4.0.6
Video Gallery – YouTube Gallery, Playlist & Video Grid v4.0.6
4.0.6 4.0.5 4.0.4 trunk 1.0 1.0.1 1.1 1.1.1 1.2.0 1.3.0 1.4.0 1.4.1 2.0.0 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0 2.5.1 2.6.0 2.7.0 2.7.2 2.7.5 2.7.6 2.8.0 All 59 releases
youtube-showcase / youtube-showcase.php
youtube-showcase.php
365 lines 13.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Video Gallery – YouTube Gallery, Playlist & Video Grid
4 * Plugin URI: https://emarketdesign.com
5 * Description: Responsive YouTube gallery, playlist, and video grid builder. Curate YouTube videos into beautiful grids, blocks, or playlists, no coding required.
6 * Version: 4.0.6
7 * Author: eMarket Design
8 * Author URI: https://emdplugins.com?pk_campaign=youtube-showcase-com&pk_kwd=readme-by
9 * Text Domain: youtube-showcase
10 * Domain Path: /lang
11 * License: GPLv2 or later
12 * License URI: http://www.gnu.org/licenses/gpl-2.0.html
13 * @package YOUTUBE_SHOWCASE
14 * @since WPAS 4.0
15 */
16 /*
17 * LICENSE:
18 * Youtube Showcase is free software: you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation, either version 2 of the License, or
21 * any later version.
22 *
23 * Youtube Showcase is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * Please see <http://www.gnu.org/licenses/> for details.
29 */
30 if (!defined('ABSPATH')) exit;
31 if (!class_exists('Youtube_Showcase')):
32 /**
33 * Main class for Youtube Showcase
34 *
35 * @class Youtube_Showcase
36 */
37 final class Youtube_Showcase {
38 /**
39 * @var Youtube_Showcase single instance of the class
40 */
41 private static $_instance;
42 public $app_name = 'youtube_showcase';
43 public $session;
44 /**
45 * Main Youtube_Showcase Instance
46 *
47 * Ensures only one instance of Youtube_Showcase is loaded or can be loaded.
48 *
49 * @static
50 * @see YOUTUBE_SHOWCASE()
51 * @return Youtube_Showcase - Main instance
52 */
53 public static function instance() {
54 if (!isset(self::$_instance)) {
55 self::$_instance = new self();
56 self::$_instance->define_constants();
57 self::$_instance->includes();
58 self::$_instance->load_plugin_textdomain();
59 self::$_instance->session = new Emd_Session('youtube_showcase');
60 add_filter('the_content', array(
61 self::$_instance,
62 'change_content'
63 ));
64 add_action('admin_menu', array(
65 self::$_instance,
66 'display_settings'
67 ));
68 add_filter('template_include', array(
69 self::$_instance,
70 'show_template'
71 ));
72 add_action('widgets_init', array(
73 self::$_instance,
74 'include_widgets'
75 ));
76 }
77 return self::$_instance;
78 }
79 /**
80 * Cloning is forbidden.
81 */
82 public function __clone() {
83 _doing_it_wrong(__FUNCTION__, __('Cheatin&#8217; huh?', 'youtube-showcase') , '1.0');
84 }
85 /**
86 * Define Youtube_Showcase Constants
87 *
88 * @access private
89 * @return void
90 */
91 private function define_constants() {
92 define('YOUTUBE_SHOWCASE_VERSION', '4.0.6');
93 define('YOUTUBE_SHOWCASE_AUTHOR', 'eMarket Design');
94 define('YOUTUBE_SHOWCASE_NAME', 'Youtube Showcase');
95 define('YOUTUBE_SHOWCASE_PLUGIN_FILE', __FILE__);
96 define('YOUTUBE_SHOWCASE_PLUGIN_DIR', plugin_dir_path(__FILE__));
97 define('YOUTUBE_SHOWCASE_PLUGIN_URL', plugin_dir_url(__FILE__));
98 define('EMD_ADMIN_DIR', ABSPATH . 'wp-admin');
99 }
100 /**
101 * Include required files
102 *
103 * @access private
104 * @return void
105 */
106 private function includes() {
107 //these files are in all apps
108 if (!function_exists('emd_mb_meta')) {
109 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'assets/ext/emd-meta-box/emd-meta-box.php';
110 }
111 if (!function_exists('emd_translate_date_format')) {
112 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/date-functions.php';
113 }
114 if (!function_exists('emd_get_hidden_func')) {
115 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/common-functions.php';
116 }
117 if (!class_exists('Emd_Entity')) {
118 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/entities/class-emd-entity.php';
119 }
120 if (!function_exists('emd_get_template_part')) {
121 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/layout-functions.php';
122 }
123 //the rest
124 if (!class_exists('Emd_Query')) {
125 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/class-emd-query.php';
126 }
127 if (!function_exists('emd_shc_get_layout_list')) {
128 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/shortcode-functions.php';
129 }
130 if (!function_exists('emd_get_widg_pagenum')) {
131 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/widget-functions.php';
132 }
133 if (!class_exists('Emd_Widget')) {
134 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/class-emd-widget.php';
135 }
136 if (!class_exists('Emd_Session')) {
137 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/class-emd-session.php';
138 }
139 if (!function_exists('emd_show_login_register_forms')) {
140 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/login-register-functions.php';
141 }
142 do_action('emd_ext_include_files');
143 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/plugin-app-functions.php';
144 //app specific files
145 if (!function_exists('emd_show_settings_page')) {
146 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/admin/settings-functions.php';
147 }
148 if (!function_exists('emd_global_register_settings')) {
149 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/admin/settings-functions-globs.php';
150 }
151 if (!function_exists('emd_misc_register_settings')) {
152 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/admin/settings-functions-misc.php';
153 }
154 if (is_admin()) {
155 if (!class_exists('WP_List_Table', false)) {
156 require_once EMD_ADMIN_DIR . '/includes/class-wp-list-table.php';
157 }
158 if (!class_exists('Emd_List_Table')) {
159 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/admin/class-emd-list-table.php';
160 }
161 if (!function_exists('emd_show_shortcodes_page')) {
162 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/admin/shortcode-list-functions.php';
163 }
164 //these files are in all apps
165 if (!function_exists('emd_display_store')) {
166 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/admin/store-functions.php';
167 }
168 //the rest
169 if (!function_exists('emd_shc_button')) {
170 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/admin/wpas-btn-functions.php';
171 }
172 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/admin/glossary.php';
173 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/admin/getting-started.php';
174 }
175 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/integration-shortcodes.php';
176 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/class-install-deactivate.php';
177 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/entities/class-emd-video.php';
178 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/entities/emd-video-shortcodes.php';
179 if (!function_exists('emd_show_forms_lite_page')) {
180 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/emd-form-builder-lite/emd-form-builder.php';
181 }
182 if (!function_exists('emd_lite_modal')) {
183 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/emd-lite/emd-lite.php';
184 }
185 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/scripts.php';
186 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/query-filters.php';
187 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/plugin-feedback-functions.php';
188 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/content-functions.php';
189 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/blocks/block.php';
190 }
191 /**
192 * Loads plugin language files
193 *
194 * @access public
195 * @return void
196 */
197 public function load_plugin_textdomain() {
198 $locale = apply_filters('plugin_locale', get_locale() , 'youtube-showcase');
199 $mofile = sprintf('%1$s-%2$s.mo', 'youtube-showcase', $locale);
200 $localmo = YOUTUBE_SHOWCASE_PLUGIN_DIR . '/lang/' . $mofile;
201 $globalmo = WP_LANG_DIR . '/youtube-showcase/' . $mofile;
202 if (file_exists($globalmo)) {
203 load_textdomain('youtube-showcase', $globalmo);
204 } elseif (file_exists($localmo)) {
205 load_textdomain('youtube-showcase', $localmo);
206 } else {
207 load_plugin_textdomain('youtube-showcase', false, YOUTUBE_SHOWCASE_PLUGIN_DIR . '/lang/');
208 }
209 }
210 /**
211 * Changes content on frontend views
212 *
213 * @access public
214 * @param string $content
215 *
216 * @return string $content
217 */
218 public function change_content($content) {
219 if (!is_admin()) {
220 if (post_password_required()) {
221 $content = get_the_password_form();
222 } else {
223 $mypost_type = get_post_type();
224 if ($mypost_type == 'post' || $mypost_type == 'page') {
225 $mypost_type = "emd_" . $mypost_type;
226 }
227 $ent_list = get_option($this->app_name . '_ent_list');
228 if (in_array($mypost_type, array_keys($ent_list)) && class_exists($mypost_type)) {
229 $func = "change_content";
230 $obj = new $mypost_type;
231 $content = $obj->$func($content);
232 }
233 }
234 }
235 return $content;
236 }
237 /**
238 * Creates plugin page in menu with submenus
239 *
240 * @access public
241 * @return void
242 */
243 public function display_settings() {
244 $settings_pages_cap = 'manage_options';
245 $settings_pages_cap = apply_filters('emd_settings_pages_cap', $settings_pages_cap, $this->app_name);
246 add_menu_page(__('Video Settings', 'youtube-showcase') , __('Video Settings', 'youtube-showcase') , $settings_pages_cap, $this->app_name, array(
247 $this,
248 'display_getting_started_page'
249 ));
250 add_submenu_page($this->app_name, __('Getting Started', 'youtube-showcase') , __('Getting Started', 'youtube-showcase') , $settings_pages_cap, $this->app_name);
251 add_submenu_page($this->app_name, __('Glossary', 'youtube-showcase') , __('Glossary', 'youtube-showcase') , $settings_pages_cap, $this->app_name . '_glossary', array(
252 $this,
253 'display_glossary_page'
254 ));
255 add_submenu_page($this->app_name, __('Settings', 'youtube-showcase') , __('Settings', 'youtube-showcase') , $settings_pages_cap, $this->app_name . '_settings', array(
256 $this,
257 'display_settings_page'
258 ));
259 add_submenu_page($this->app_name, __('YouTube API', 'youtube-showcase') , __('YouTube API', 'youtube-showcase') , $settings_pages_cap, $this->app_name . '_youtube', array(
260 $this,
261 'display_youtube_page'
262 ));
263 add_submenu_page($this->app_name, __('Shortcodes', 'youtube-showcase') , __('Shortcodes', 'youtube-showcase') , $settings_pages_cap, $this->app_name . '_shortcodes', array(
264 $this,
265 'display_shortcodes_page'
266 ));
267 add_submenu_page($this->app_name, __('Forms', 'youtube-showcase') , __('Forms', 'youtube-showcase') , $settings_pages_cap, $this->app_name . '_forms', array(
268 $this,
269 'display_forms_page'
270 ));
271 add_submenu_page($this->app_name, __('Plugins', 'youtube-showcase') , __('Plugins', 'youtube-showcase') , $settings_pages_cap, $this->app_name . '_store', array(
272 $this,
273 'display_store_page'
274 ));
275 add_submenu_page($this->app_name, __('Support', 'youtube-showcase') , __('Support', 'youtube-showcase') , $settings_pages_cap, $this->app_name . '_support', array(
276 $this,
277 'display_support_page'
278 ));
279 //add submenu page under app settings page
280 do_action('emd_ext_add_menu_pages', $this->app_name);
281 $emd_lic_settings = get_option('emd_license_settings', Array());
282 $show_lic_page = 0;
283 if (!empty($emd_lic_settings)) {
284 foreach ($emd_lic_settings as $key => $val) {
285 if ($key == $this->app_name) {
286 $show_lic_page = 1;
287 break;
288 } else if ($val['type'] == 'ext') {
289 $show_lic_page = 1;
290 break;
291 }
292 }
293 if ($show_lic_page == 1 && function_exists('emd_show_license_page')) {
294 add_submenu_page($this->app_name, __('Licenses', 'youtube-showcase') , __('Licenses', 'youtube-showcase') , 'manage_options', $this->app_name . '_licenses', array(
295 $this,
296 'display_licenses_page'
297 ));
298 }
299 }
300 }
301 /**
302 * Calls settings function to display glossary page
303 *
304 * @access public
305 * @return void
306 */
307 public function display_glossary_page() {
308 do_action($this->app_name . '_settings_glossary');
309 }
310 public function display_getting_started_page() {
311 do_action($this->app_name . '_getting_started');
312 }
313 public function display_store_page() {
314 emd_display_store($this->app_name);
315 }
316 public function display_support_page() {
317 emd_display_support($this->app_name, 2, 'youtube-showcase');
318 }
319 public function display_licenses_page() {
320 do_action('emd_show_license_page', $this->app_name);
321 }
322 public function display_settings_page() {
323 do_action('emd_show_settings_page', $this->app_name);
324 }
325 public function display_shortcodes_page() {
326 do_action('emd_show_shortcodes_page', $this->app_name);
327 }
328 public function display_forms_page() {
329 do_action('emd_show_forms_lite_page', $this->app_name);
330 }
331 public function display_youtube_page() {
332 emd_lite_get_operations('yt_api', __('Videos', 'youtube-showcase') , 'youtube_showcase');
333 }
334 /**
335 * Displays single, archive, tax and no-access frontend views
336 *
337 * @access public
338 * @return string, $template:emd template or template
339 */
340 public function show_template($template) {
341 return emd_show_template($this->app_name, YOUTUBE_SHOWCASE_PLUGIN_DIR, $template);
342 }
343 /**
344 * Loads sidebar widgets
345 *
346 * @access public
347 * @return void
348 */
349 public function include_widgets() {
350 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/entities/class-emd-video-widgets.php';
351 require_once YOUTUBE_SHOWCASE_PLUGIN_DIR . 'includes/class-integration-widgets.php';
352 }
353 }
354 endif;
355 /**
356 * Returns the main instance of Youtube_Showcase
357 *
358 * @return Youtube_Showcase
359 */
360 function YOUTUBE_SHOWCASE() {
361 return Youtube_Showcase::instance();
362 }
363 // Get the Youtube_Showcase instance
364 YOUTUBE_SHOWCASE();
365