PluginProbe
Photonic Gallery & Lightbox for Flickr, SmugMug & Others / 3.37
Photonic Gallery & Lightbox for Flickr, SmugMug & Others v3.37
3.37 3.36 3.35 3.34 3.33 2.19 2.20 2.21 2.22 2.23 2.24 2.25 2.26 2.27 2.28 2.29 2.30 2.31 2.32 2.33 2.34 2.40 2.41 2.42 2.43 All 142 releases
← All changes | photonic.php +33 -1808 2.19 → 3.37 View file →
@@ -1,1843 +1,68 @@
1 1 <?php
2 2 /**
3 - * Plugin Name: Photonic Gallery & Lightbox for Flickr, SmugMug, Google Photos, Zenfolio and Instagram
3 + * Plugin Name: Photonic Gallery & Lightbox for Flickr, SmugMug & Others
4 4 * Plugin URI: https://aquoid.com/plugins/photonic/
5 - * Description: Extends the native gallery to support Flickr, SmugMug, Google Photos, Zenfolio and Instagram. JS libraries like Swipebox, Fancybox, PhotoSwipe, Magnific, Colorbox, PrettyPhoto, Image Lightbox, Featherlight, Lightcase and Lightgallery are supported. Photos are displayed in grids of square or circular thumbnails, or slideshows, or justified or masonry or random mosaic layouts. The plugin also extends all layout options to a regular WP gallery.
6 - * Version: 2.19
5 + * Description: Extends the native gallery to support Flickr, SmugMug and Zenfolio. JS libraries like BaguetteBox, BigPicture, Gie Lightbox, LightGallery, PhotoSwipe, Spotlight, Swipebox, Fancybox, Magnific, Colorbox, PrettyPhoto, Image Lightbox, Featherlight and Lightcase are supported. Photos are displayed in vanilla grids of thumbnails, or more fancy slideshows, or justified or masonry or random mosaic layouts. The plugin also extends all layout options to a regular WP gallery.
6 + * Version: 3.37
7 + * Requires at least: 6.2
8 + * Requires PHP: 7.4
7 9 * Author: Sayontan Sinha
8 10 * Author URI: https://mynethome.net/
9 - * License: GNU General Public License (GPL), v3 (or newer)
11 + * License: GPLv3 or later
10 12 * License URI: https://www.gnu.org/licenses/gpl-3.0.html
11 13 * Text Domain: photonic
12 14 *
13 - * Copyright (c) 2011 - 2019 Sayontan Sinha. All rights reserved.
15 + * Copyright (c) 2011 - 2026 Sayontan Sinha. All rights reserved.
14 16 *
15 17 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
16 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 19 */
18 20
19 -class Photonic {
20 - var $version, $registered_extensions, $defaults, $plugin_name, $options_page_name, $settings_page, $helper_page, $getting_started_page, $authentication_page, $gutenberg_page;
21 - function __construct() {
22 - global $photonic_options, $photonic_setup_options, $photonic_is_IE;
21 +namespace Photonic_Plugin;
22 +
23 +use Photonic_Plugin\Core\Photonic;
24 +
25 +class Photonic_Plugin {
26 + public function __construct() {
23 27 if (!defined('PHOTONIC_VERSION')) {
24 - define('PHOTONIC_VERSION', '2.19');
28 + define('PHOTONIC_VERSION', '3.37');
25 29 }
26 30
27 - if (!defined('PHOTONIC_PATH')) {
28 - define('PHOTONIC_PATH', plugin_dir_path(__FILE__));
29 - }
31 + define('PHOTONIC_PATH', __DIR__);
30 32
31 33 if (!defined('PHOTONIC_URL')) {
32 34 define('PHOTONIC_URL', plugin_dir_url(__FILE__));
33 35 }
34 36
35 - $upload_dir = wp_upload_dir();
37 + $photonic_wp_upload_dir = wp_upload_dir();
36 38 if (!defined('PHOTONIC_UPLOAD_DIR')) {
37 - define('PHOTONIC_UPLOAD_DIR', trailingslashit($upload_dir['basedir']).'photonic');
39 + define('PHOTONIC_UPLOAD_DIR', trailingslashit($photonic_wp_upload_dir['basedir']) . 'photonic');
38 40 }
39 41
40 42 if (!defined('PHOTONIC_UPLOAD_URL')) {
41 - define('PHOTONIC_UPLOAD_URL', trailingslashit($upload_dir['baseurl']).'photonic');
43 + define('PHOTONIC_UPLOAD_URL', trailingslashit($photonic_wp_upload_dir['baseurl']) . 'photonic');
42 44 }
43 45
44 - //WP provides a global $is_IE, but we specifically need to find IE6x (or, heaven forbid, IE5x). Note that older versions of Opera used to identify themselves as IE6, so we exclude Opera.
45 - $photonic_is_IE = preg_match('/MSIE [56789]/i', $_SERVER['HTTP_USER_AGENT']);
46 -
47 - require_once(plugin_dir_path(__FILE__)."/options/photonic-options.php");
48 -
49 - $this->plugin_name = plugin_basename(__FILE__);
50 -
51 - add_action('admin_menu', array(&$this, 'add_admin_menu'));
52 - add_action('admin_enqueue_scripts', array(&$this, 'add_admin_scripts'));
53 - add_action('admin_init', array(&$this, 'admin_init'));
54 - add_action('admin_notices', array(&$this, 'admin_notices'));
55 -
56 - $photonic_options = get_option('photonic_options');
57 - $default_options = array();
58 - foreach ($photonic_setup_options as $default_option) {
59 - if (isset($default_option['id']) && isset($default_option['std'])) {
60 - $default_options[$default_option['id']] = $default_option['std'];
61 - }
62 - }
63 -
64 - $set_options = isset($photonic_options) && is_array($photonic_options) ? $photonic_options : array();
65 - $all_options = array_merge($default_options, $set_options);
66 -
67 - foreach ($all_options as $key => $value) {
68 - $mod_key = 'photonic_'.$key;
69 - global ${$mod_key};
70 - ${$mod_key} = $value;
71 - }
72 -
73 - if (!empty($photonic_ssl_verify_off)) {
74 - define('PHOTONIC_SSL_VERIFY', false);
75 - }
76 - else {
77 - define('PHOTONIC_SSL_VERIFY', true);
78 - }
79 -
80 - if (!empty($photonic_script_dev_mode)) {
81 - define('PHOTONIC_DEV_MODE', '');
82 - }
83 - else {
84 - define('PHOTONIC_DEV_MODE', '.min');
85 - }
86 -
87 - if (!empty($photonic_curl_timeout) && is_numeric($photonic_curl_timeout)) {
88 - define('PHOTONIC_CURL_TIMEOUT', $photonic_curl_timeout);
89 - }
90 - else {
91 - define('PHOTONIC_CURL_TIMEOUT', 10);
92 - }
93 -
94 - if (!empty($photonic_debug_on)) {
95 - define('PHOTONIC_DEBUG', true);
96 - }
97 - else {
98 - define('PHOTONIC_DEBUG', false);
99 - }
100 -
101 - add_action('admin_head', array($this, 'admin_head'));
102 -
103 - // Gallery
104 - if (!empty($photonic_alternative_shortcode)) {
105 - add_shortcode($photonic_alternative_shortcode, array(&$this, 'modify_gallery'));
106 - }
107 - else {
108 - add_filter('post_gallery', array(&$this, 'modify_gallery'), 20, 2);
109 - }
110 -
111 - add_shortcode('photonic_helper', array(&$this, 'helper_shortcode'));
112 -
113 - add_action('wp_enqueue_scripts', array(&$this, 'add_scripts'), 20);
114 - add_action('wp_head', array(&$this, 'print_scripts'), 20);
115 - add_action('wp_loaded', array(&$this, 'check_authentication'), 20);
116 -
117 - add_action('wp_ajax_photonic_display_level_2_contents', array(&$this, 'display_level_2_contents'));
118 - add_action('wp_ajax_nopriv_photonic_display_level_2_contents', array(&$this, 'display_level_2_contents'));
119 -
120 - add_action('wp_ajax_photonic_display_level_3_contents', array(&$this, 'display_level_3_contents'));
121 - add_action('wp_ajax_nopriv_photonic_display_level_3_contents', array(&$this, 'display_level_3_contents'));
122 -
123 - add_action('wp_ajax_photonic_load_more', array(&$this, 'load_more'));
124 - add_action('wp_ajax_nopriv_photonic_load_more', array(&$this, 'load_more'));
125 -
126 - add_action('wp_ajax_photonic_helper_shortcode_more', array(&$this, 'helper_shortcode_more'));
127 - add_action('wp_ajax_nopriv_photonic_helper_shortcode_more', array(&$this, 'helper_shortcode_more'));
128 -
129 - add_filter('media_upload_tabs', array(&$this, 'media_upload_tabs'));
130 - add_action('media_upload_photonic', array(&$this, 'media_upload_photonic'));
131 -
132 - add_action('print_media_templates', array(&$this, 'edit_gallery'));
133 -
134 - add_action('wp_ajax_photonic_invoke_helper', array(&$this, 'invoke_helper'));
135 - add_action('wp_ajax_photonic_obtain_token', array(&$this, 'obtain_token'));
136 - add_action('wp_ajax_photonic_save_token', array(&$this, 'save_token_in_options'));
137 - add_action('wp_ajax_photonic_delete_token', array(&$this, 'delete_token_from_options'));
138 -
139 - $this->registered_extensions = array();
140 - $this->add_extensions();
141 -
142 - add_action('wp_ajax_photonic_authenticate', array(&$this, 'authenticate'));
143 - add_action('wp_ajax_nopriv_photonic_authenticate', array(&$this, 'authenticate'));
144 -
145 - add_action('wp_ajax_photonic_dismiss_warning', array(&$this, 'dismiss_warning'));
146 - add_action('wp_ajax_nopriv_photonic_dismiss_warning', array(&$this, 'dismiss_warning'));
147 -
148 - add_action('http_api_curl', array(&$this, 'curl_timeout'), 100, 1);
149 -
150 - if (empty($photonic_disable_flow_editor_global)) {
151 - add_action('media_buttons', array(&$this, 'add_photonic_button'));
152 - add_action('admin_action_photonic_flow', array(&$this, 'insertion_flow'));
153 - add_action('wp_ajax_photonic_flow_next_screen', array(&$this, 'flow_next_screen'));
154 - add_action('wp_ajax_nopriv_photonic_flow_next_screen', array(&$this, 'flow_next_screen'));
155 - add_action('wp_ajax_photonic_flow_more', array(&$this, 'flow_more'));
156 - add_action('wp_ajax_nopriv_photonic_flow_more', array(&$this, 'flow_more'));
157 - }
158 -
159 - $this->add_gutenberg_support();
160 - add_action('enqueue_block_editor_assets', array(&$this, 'enqueue_gutenberg_assets'));
161 -
162 - add_action('plugins_loaded', array(&$this, 'enable_translations'));
163 -
164 - add_filter('body_class', array(&$this, 'body_class'), 10, 2);
46 + require_once PHOTONIC_PATH . '/Core/Photonic.php';
165 47 }
48 +}
166 49
167 - /**
168 - * @param $show_full
169 - * @param bool $return_formatted
170 - * @return array
171 - */
172 - public static function get_wp_image_sizes($show_full, $return_formatted = false) {
173 - global $_wp_additional_image_sizes;
174 - $image_sizes = array();
175 - $standard_sizes = array('thumbnail', 'medium', 'large');
176 - if ($show_full) {
177 - $standard_sizes[] = 'full';
178 - }
179 - foreach ($standard_sizes as $standard_size) {
180 - if ($standard_size != 'full') {
181 - $image_sizes[$standard_size] = array('width' => get_option($standard_size . '_size_w'), 'height' => get_option($standard_size . '_size_h'));
182 - }
183 - else {
184 - $image_sizes[$standard_size] = array('width' => esc_html__('Original width', 'photonic'), 'height' => esc_html__('Original height', 'photonic'));
185 - }
186 - }
187 - if (is_array($_wp_additional_image_sizes)) {
188 - $image_sizes = array_merge($image_sizes, $_wp_additional_image_sizes);
189 - }
50 +new Photonic_Plugin();
190 51
191 - if ($return_formatted) {
192 - $formatted = array();
193 - foreach ($image_sizes as $size_name => $size_attrs) {
194 - $formatted[$size_name] = "$size_name ({$size_attrs['width']} &times; {$size_attrs['height']})";
195 - }
196 - return $formatted;
197 - }
198 - return $image_sizes;
199 - }
52 +add_action('admin_init', '\Photonic_Plugin\photonic_utilities_init');
53 +add_action('init', '\Photonic_Plugin\photonic_init', 0); // Delaying the start from 10 to 100 so that CPTs can be picked up
200 54
201 - /**
202 - * Adds a menu item to the "Settings" section of the admin page.
203 - *
204 - * @return void
205 - */
206 - function add_admin_menu() {
207 - global $photonic_options_manager;
208 - $this->options_page_name = add_menu_page('Photonic', 'Photonic', 'edit_posts', 'photonic-options-manager', array(&$photonic_options_manager, 'render_settings_page'), plugins_url('include/images/Photonic-20-gr.png', __FILE__));
209 - $this->settings_page = add_submenu_page('photonic-options-manager', esc_html__('Settings', 'photonic'), esc_html__('Settings', 'photonic'), 'edit_theme_options', 'photonic-options-manager', array(&$photonic_options_manager, 'render_settings_page'));
210 - $this->getting_started_page = add_submenu_page('photonic-options-manager', 'Getting Started', 'Getting Started', 'edit_posts', 'photonic-getting-started', array(&$photonic_options_manager, 'render_getting_started'));
211 - $this->authentication_page = add_submenu_page('photonic-options-manager', 'Authentication', 'Authentication', 'edit_theme_options', 'photonic-auth', array(&$photonic_options_manager, 'render_authentication'));
212 - $this->gutenberg_page = add_submenu_page('photonic-options-manager', esc_html__('Prepare for Gutenberg', 'photonic'), '<div style="color: #c66">'.esc_html__('Prepare for Gutenberg', 'photonic').'</div>', 'edit_posts', 'photonic-gutenberg', array(&$photonic_options_manager, 'render_gutenberg'));
213 - $this->helper_page = add_submenu_page('photonic-options-manager', 'Helpers', 'Helpers', 'edit_posts', 'photonic-helpers', array(&$photonic_options_manager, 'render_helpers'));
214 - }
215 -
216 - /**
217 - * Adds all scripts and their dependencies to the <head> of the Photonic administration page. This takes care to not add scripts on other admin pages.
218 - *
219 - * @param $hook
220 - * @return void
221 - */
222 - function add_admin_scripts($hook) {
223 - if ($this->options_page_name == $hook) {
224 - wp_enqueue_style('photonic-admin-css', plugins_url('include/css/admin.css', __FILE__), array('wp-color-picker'), $this->get_version(plugin_dir_path(__FILE__).'include/css/admin.css'));
225 - global $photonic_options;
226 - $js_array = array(
227 - 'category' => isset($photonic_options) && isset($photonic_options['last-set-section']) ? $photonic_options['last-set-section'] : 'generic-settings',
228 - );
229 - wp_enqueue_script('photonic-options-js', plugins_url('include/scripts/admin/options-manager.js', __FILE__), array('jquery', 'wp-color-picker'), $this->get_version(plugin_dir_path(__FILE__).'include/scripts/admin/options-manager.js'));
230 - wp_localize_script('photonic-options-js', 'Photonic_Options_JS', $js_array);
231 - }
232 - else if ($this->helper_page == $hook || $this->authentication_page == $hook || $this->gutenberg_page == $hook) {
233 - wp_enqueue_script('photonic-admin-js', plugins_url('include/scripts/admin/helpers.js', __FILE__), array('jquery'), $this->get_version(plugin_dir_path(__FILE__).'include/scripts/admin/helpers.js'));
234 - wp_enqueue_style('photonic-admin-css', plugins_url('include/css/admin.css', __FILE__), array(), $this->get_version(plugin_dir_path(__FILE__).'include/css/admin.css'));
235 -
236 - $js_array = array(
237 - 'obtain_token' => esc_attr__('Step 2: Obtain Token', 'photonic')
238 - );
239 - wp_localize_script('photonic-admin-js', 'Photonic_Admin_JS', $js_array);
240 - }
241 - else if ($this->getting_started_page == $hook) {
242 - wp_enqueue_style('photonic-admin-css', plugins_url('include/css/admin.css', __FILE__), array(), $this->get_version(plugin_dir_path(__FILE__).'include/css/admin.css'));
243 - }
244 - else if ('media-upload-popup' == $hook) {
245 - wp_enqueue_script('jquery');
246 - wp_enqueue_style('photonic-upload', plugins_url('include/css/admin-form.css', __FILE__), array(), $this->get_version(plugin_dir_path(__FILE__).'include/css/admin-form.css'));
247 - }
248 - else if ('post-new.php' == $hook || 'post.php' == $hook) {
249 - global $photonic_disable_editor, $photonic_disable_editor_post_type;
250 - $disabled_types = explode(',', $photonic_disable_editor_post_type);
251 - $post_type = empty($_REQUEST['post_type']) ? 'post' : $_REQUEST['post_type'];
252 - wp_enqueue_style('photonic-upload', plugins_url('include/css/admin-form.css', __FILE__), array(), $this->get_version(plugin_dir_path(__FILE__).'include/css/admin-form.css'));
253 - if (empty($photonic_disable_editor) && !in_array($post_type, $disabled_types)) {
254 - $this->prepare_mce_data();
255 -
256 - add_editor_style(plugins_url('include/css/admin-editor.css?'.$this->get_version(plugin_dir_path(__FILE__).'include/css/admin-editor.css'), __FILE__));
257 - }
258 - }
259 - }
260 -
261 - /**
262 - * Adds all scripts and their dependencies to the <head> section of the page.
263 - *
264 - * @return void
265 - */
266 - function add_scripts() {
267 - global $photonic_slideshow_library, $photonic_custom_lightbox_js, $photonic_custom_lightbox_css, $photonic_is_IE, $photonic_custom_lightbox,
268 - $photonic_disable_photonic_lightbox_scripts, $photonic_disable_photonic_slider_scripts;
269 -
270 - $photonic_dependencies = array('jquery', 'jquery-ui-tooltip', 'jquery-ui-dialog');
271 -
272 - if (empty($photonic_disable_photonic_slider_scripts)) {
273 - wp_enqueue_script('photonic-slideshow', plugins_url('include/scripts/third-party/lightslider/lightslider'.PHOTONIC_DEV_MODE.'.js', __FILE__), array('jquery'), $this->get_version(plugin_dir_path(__FILE__).'include/scripts/third-party/lightslider/lightslider'.PHOTONIC_DEV_MODE.'.js'));
274 - wp_enqueue_style("photonic-slideshow", plugins_url('include/scripts/third-party/lightslider/css/lightslider.css', __FILE__), array(), $this->get_version(plugin_dir_path(__FILE__).'include/scripts/third-party/lightslider/css/lightslider.css'));
275 - }
276 -
277 - if ($photonic_is_IE) {
278 - wp_enqueue_script('photonic-ie', plugins_url('include/scripts/front-end/src/photonic-ie.js', __FILE__), array('jquery-masonry', 'photonic'), $this->get_version(plugin_dir_path(__FILE__).'include/scripts/front-end/src/photonic-ie.js'));
279 - }
280 -
281 - if ($photonic_slideshow_library == 'thickbox') {
282 - wp_enqueue_script('thickbox');
283 - $photonic_dependencies[] = 'thickbox';
284 - }
285 - else if ($photonic_slideshow_library == 'custom') {
286 - $counter = 1;
287 - $dependencies = array('jquery');
288 - foreach(preg_split("/((\r?\n)|(\r\n?))/", $photonic_custom_lightbox_js) as $line){
289 - wp_enqueue_script('photonic-lightbox-'.$counter, trim($line), $dependencies, PHOTONIC_VERSION);
290 - $photonic_dependencies[] = 'photonic-lightbox-'.$counter;
291 - $counter++;
292 - }
293 -
294 - $counter = 1;
295 - foreach(preg_split("/((\r?\n)|(\r\n?))/", $photonic_custom_lightbox_css) as $line){
296 - wp_enqueue_style('photonic-lightbox-'.$counter, trim($line), array(), PHOTONIC_VERSION);
297 - $counter++;
298 - }
299 - }
300 - else if ($photonic_slideshow_library != 'none') {
301 - if (empty($photonic_slideshow_library)) {
302 - $photonic_slideshow_library = 'swipebox';
303 - }
304 -
305 - if (empty($photonic_disable_photonic_lightbox_scripts)) {
306 - $lb_deps = array('jquery');
307 - if ($photonic_slideshow_library == 'fluidbox') {
308 - $lb_deps[] = 'imagesloaded';
309 - }
310 - wp_enqueue_script('photonic-lightbox', plugins_url('include/scripts/third-party/'.$photonic_slideshow_library.'/'.$photonic_slideshow_library.PHOTONIC_DEV_MODE.'.js', __FILE__), $lb_deps, $this->get_version(plugin_dir_path(__FILE__).'include/scripts/third-party/'.$photonic_slideshow_library.'/'.$photonic_slideshow_library.PHOTONIC_DEV_MODE.'.js'));
311 - if ($photonic_slideshow_library == 'lightgallery') {
312 - global $photonic_enable_lg_zoom, $photonic_enable_lg_thumbnail, $photonic_enable_lg_fullscreen, $photonic_enable_lg_autoplay;
313 - $lightgallery_plugins = array();
314 - if (!empty($photonic_enable_lg_autoplay)) { $lightgallery_plugins[] = 'autoplay'; }
315 - if (!empty($photonic_enable_lg_fullscreen)) { $lightgallery_plugins[] = 'fullscreen'; }
316 - if (!empty($photonic_enable_lg_thumbnail)) { $lightgallery_plugins[] = 'thumbnail'; }
317 - if (!empty($photonic_enable_lg_zoom)) { $lightgallery_plugins[] = 'zoom'; }
318 - foreach ($lightgallery_plugins as $plugin) {
319 - wp_enqueue_script('photonic-lightbox-'.$plugin, plugins_url('include/scripts/third-party/'.$photonic_slideshow_library.'/lg-plugin-'.$plugin.'.min.js', __FILE__), array('photonic-lightbox'), $this->get_version(plugin_dir_path(__FILE__).'include/scripts/third-party/'.$photonic_slideshow_library.'/lg-plugin-'.$plugin.'.min.js'));
320 - }
321 - }
322 - else if ($photonic_slideshow_library == 'galleria') {
323 - wp_enqueue_script('photonic-lightbox-theme', plugins_url('include/scripts/third-party/galleria/themes/classic/galleria.classic.min.js', __FILE__), array('photonic-lightbox'), $this->get_version(plugin_dir_path(__FILE__).'include/scripts/third-party/galleria/themes/classic/galleria.classic.min.js'));
324 - }
325 - $photonic_dependencies[] = 'photonic-lightbox';
326 -
327 - $this->enqueue_lightbox_styles();
328 - }
329 - }
330 -
331 - $slideshow_library = $photonic_slideshow_library == 'custom' ? $photonic_custom_lightbox : $photonic_slideshow_library;
332 - $slideshow_library = empty($slideshow_library) ? 'swipebox' : $slideshow_library;
333 -
334 - wp_enqueue_script('photonic', plugins_url('include/scripts/front-end/build/photonic-'.$slideshow_library.PHOTONIC_DEV_MODE.'.js', __FILE__), $photonic_dependencies, $this->get_version(plugin_dir_path(__FILE__).'include/scripts/front-end/build/photonic-'.$slideshow_library.PHOTONIC_DEV_MODE.'.js'));
335 -
336 - $js_array = $this->get_localized_js_variables();
337 - wp_localize_script('photonic', 'Photonic_JS', $js_array);
338 -
339 - wp_enqueue_style('photonic', plugins_url('include/css/photonic.css', __FILE__), array(), $this->get_version(plugin_dir_path(__FILE__).'include/css/photonic.css'));
340 - global $photonic_css_in_file;
341 - $file = trailingslashit(PHOTONIC_UPLOAD_DIR).'custom-styles.css';
342 - if (@file_exists($file) && !empty($photonic_css_in_file)) {
343 - wp_enqueue_style('photonic-custom', trailingslashit(PHOTONIC_UPLOAD_URL).'custom-styles.css', array('photonic'), $this->get_version($file));
344 - }
345 - }
346 -
347 - function enqueue_lightbox_styles() {
348 - global $photonic_slideshow_library;
349 - $template_directory = get_template_directory();
350 - $stylesheet_directory = get_stylesheet_directory();
351 -
352 - if ($photonic_slideshow_library == 'colorbox') {
353 - global $photonic_cbox_theme;
354 - if ($photonic_cbox_theme == 'theme' && @file_exists($stylesheet_directory.'/scripts/colorbox/colorbox.css')) {
355 - wp_enqueue_style('photonic-lightbox', get_stylesheet_directory_uri().'/scripts/colorbox/colorbox.css', array(), PHOTONIC_VERSION);
356 - }
357 - else if ($photonic_cbox_theme == 'theme' && @file_exists($template_directory.'/scripts/colorbox/colorbox.css')) {
358 - wp_enqueue_style('photonic-lightbox', get_template_directory_uri().'/scripts/colorbox/colorbox.css', array(), PHOTONIC_VERSION);
359 - }
360 - else if ($photonic_cbox_theme == 'theme') {
361 - wp_enqueue_style('photonic-lightbox', plugins_url('include/scripts/third-party/colorbox/style-1/colorbox.css', __FILE__), array(), $this->get_version(plugin_dir_path(__FILE__).'include/scripts/third-party/colorbox/style-1/colorbox.css'));
362 - }
363 - else {
364 - wp_enqueue_style('photonic-lightbox', plugins_url('include/scripts/third-party/colorbox/style-'.$photonic_cbox_theme.'/colorbox.css', __FILE__), array(), $this->get_version(plugin_dir_path(__FILE__).'include/scripts/third-party/colorbox/style-'.$photonic_cbox_theme.'/colorbox.css'));
365 - }
366 - }
367 - else if ($photonic_slideshow_library == 'fancybox') {
368 - wp_enqueue_style('photonic-lightbox', plugins_url('include/scripts/third-party/fancybox/jquery.fancybox-1.3.4.css', __FILE__), array(), $this->get_version(plugin_dir_path(__FILE__).'include/scripts/third-party/fancybox/jquery.fancybox-1.3.4.css'));
369 - }
370 - else if ($photonic_slideshow_library == 'fancybox3') {
371 - wp_enqueue_style('photonic-lightbox', plugins_url('include/scripts/third-party/fancybox3/fancybox3.min.css', __FILE__), array(), $this->get_version(plugin_dir_path(__FILE__).'include/scripts/third-party/fancybox3/fancybox3.min.css'));
372 - }
373 - else if ($photonic_slideshow_library == 'featherlight') {
374 - wp_enqueue_style('photonic-lightbox', plugins_url('include/scripts/third-party/featherlight/css/featherlight.min.css', __FILE__), array(), $this->get_version(plugin_dir_path(__FILE__).'include/scripts/third-party/featherlight/css/featherlight.min.css'));
375 - }
376 - else if ($photonic_slideshow_library == 'galleria') {
377 - wp_enqueue_style('photonic-lightbox', plugins_url('include/scripts/third-party/galleria/themes/classic/galleria.classic.min.css', __FILE__), array(), $this->get_version(plugin_dir_path(__FILE__).'include/scripts/third-party/galleria/themes/classic/galleria.classic.min.css'));
378 - }
379 - else if ($photonic_slideshow_library == 'imagelightbox') {
380 - wp_enqueue_style('photonic-lightbox', plugins_url('include/scripts/third-party/imagelightbox/imagelightbox.css', __FILE__), array(), $this->get_version(plugin_dir_path(__FILE__).'include/scripts/third-party/imagelightbox/imagelightbox.css'));
381 - }
382 - else if ($photonic_slideshow_library == 'lightcase') {
383 - wp_enqueue_style('photonic-lightbox', plugins_url('include/scripts/third-party/lightcase/lightcase.css', __FILE__), array(), $this->get_version(plugin_dir_path(__FILE__).'include/scripts/third-party/lightcase/lightcase.css'));
384 - }
385 - else if ($photonic_slideshow_library == 'lightgallery') {
386 - global $photonic_enable_lg_transitions;
387 - wp_enqueue_style('photonic-lightbox', plugins_url('include/scripts/third-party/lightgallery/css/lightgallery.min.css', __FILE__), array(), $this->get_version(plugin_dir_path(__FILE__).'include/scripts/third-party/lightgallery/css/lightgallery.min.css'));
388 - if (!empty($photonic_enable_lg_transitions)) {
389 - wp_enqueue_style('photonic-lightbox-lg-transitions', plugins_url('include/scripts/third-party/lightgallery/css/lightgallery-transitions.min.css', __FILE__), array(), $this->get_version(plugin_dir_path(__FILE__).'include/scripts/third-party/lightgallery/css/lightgallery-transitions.min.css'));
390 - }
391 - }
392 - else if ($photonic_slideshow_library == 'magnific') {
393 - wp_enqueue_style('photonic-lightbox', plugins_url('include/scripts/third-party/magnific/magnific.css', __FILE__), array(), $this->get_version(plugin_dir_path(__FILE__).'include/scripts/third-party/magnific/magnific.css'));
394 - }
395 - else if ($photonic_slideshow_library == 'photoswipe') {
396 - wp_enqueue_style('photonic-lightbox', plugins_url('include/scripts/third-party/photoswipe/photoswipe.min.css', __FILE__), array(), $this->get_version(plugin_dir_path(__FILE__).'include/scripts/third-party/photoswipe/photoswipe.min.css'));
397 - }
398 - else if ($photonic_slideshow_library == 'prettyphoto') {
399 - wp_enqueue_style('photonic-lightbox', plugins_url('include/scripts/third-party/prettyphoto/css/prettyPhoto.css', __FILE__), array(), $this->get_version(plugin_dir_path(__FILE__).'include/scripts/third-party/prettyphoto/css/prettyPhoto.css'));
400 - }
401 - else if ($photonic_slideshow_library == 'swipebox') {
402 - wp_enqueue_style('photonic-lightbox', plugins_url('include/scripts/third-party/swipebox/css/swipebox.min.css', __FILE__), array(), $this->get_version(plugin_dir_path(__FILE__).'include/scripts/third-party/swipebox/css/swipebox.min.css'));
403 - }
404 - else if ($photonic_slideshow_library == 'thickbox') {
405 - wp_enqueue_style('thickbox');
406 - }
407 -
408 - }
409 -
410 - /**
411 - * Prints the custom CSS directly in the header if the option is not set to include it as a file
412 - */
413 - function print_scripts() {
414 - global $photonic_css_in_file;
415 - $file = trailingslashit(PHOTONIC_UPLOAD_DIR).'custom-styles.css';
416 - if (!@file_exists($file) || empty($photonic_css_in_file)) {
417 - $this->generate_css();
418 - }
419 - }
420 -
421 - /**
422 - * Prints the dynamically generated CSS based on option selections.
423 - *
424 - * @param bool $header
425 - * @return string
426 - */
427 - function generate_css($header = true) {
428 - global $photonic_flickr_collection_set_constrain_by_padding, $photonic_flickr_photos_constrain_by_padding, $photonic_flickr_photos_pop_constrain_by_padding, $photonic_flickr_galleries_constrain_by_padding;
429 - global $photonic_smug_photos_constrain_by_padding, $photonic_smug_photos_pop_constrain_by_padding, $photonic_smug_albums_album_constrain_by_padding, $photonic_instagram_photos_constrain_by_padding;
430 - global $photonic_zenfolio_photos_constrain_by_padding, $photonic_zenfolio_sets_constrain_by_padding, $photonic_tile_spacing, $photonic_masonry_tile_spacing, $photonic_mosaic_tile_spacing, $photonic_masonry_min_width;
431 - global $photonic_google_photos_constrain_by_padding;
432 -
433 - $css = '';
434 - if ($header) {
435 - $css .= '<style type="text/css">'."\n";
436 - }
437 - $css .= ".photonic-flickr-stream .photonic-pad-photosets { margin: {$photonic_flickr_collection_set_constrain_by_padding}px; }\n";
438 - $css .= ".photonic-flickr-stream .photonic-pad-galleries { margin: {$photonic_flickr_galleries_constrain_by_padding}px; }\n";
439 - $css .= ".photonic-flickr-stream .photonic-pad-photos { padding: 5px {$photonic_flickr_photos_constrain_by_padding}px; }\n";
440 -
441 - $css .= ".photonic-google-stream .photonic-pad-photos { padding: 5px {$photonic_google_photos_constrain_by_padding}px; }\n";
442 - $css .= ".photonic-google-stream img { ".$this->get_border_css('photonic_google_photo_thumb_border').$this->get_padding_css('photonic_google_photo_thumb_padding')." }\n";
443 - $css .= ".photonic-panel .photonic-google-image img { ".$this->get_border_css('photonic_google_photo_pop_thumb_border').$this->get_padding_css('photonic_google_photo_pop_thumb_padding')." }\n";
444 -
445 - $css .= ".photonic-zenfolio-stream .photonic-pad-photos { padding: 5px {$photonic_zenfolio_photos_constrain_by_padding}px; }\n";
446 - $css .= ".photonic-zenfolio-stream .photonic-pad-photosets { margin: 5px {$photonic_zenfolio_sets_constrain_by_padding}px; }\n";
447 - $css .= ".photonic-zenfolio-photo img { ".$this->get_border_css('photonic_zenfolio_photo_thumb_border').$this->get_padding_css('photonic_zenfolio_photo_thumb_padding')." }\n";
448 - $css .= ".photonic-zenfolio-set-thumb img { ".$this->get_border_css('photonic_zenfolio_sets_set_thumb_border').$this->get_padding_css('photonic_zenfolio_sets_set_thumb_padding')." }\n";
449 -
450 - $css .= ".photonic-instagram-stream .photonic-pad-photos { padding: 5px {$photonic_instagram_photos_constrain_by_padding}px; }\n";
451 - $css .= ".photonic-instagram-photo img { ".$this->get_border_css('photonic_instagram_photo_thumb_border').$this->get_padding_css('photonic_instagram_photo_thumb_padding')." }\n";
452 -
453 - $css .= ".photonic-smug-stream .photonic-pad-albums { margin: {$photonic_smug_albums_album_constrain_by_padding}px; }\n";
454 - $css .= ".photonic-smug-stream .photonic-pad-photos { padding: 5px {$photonic_smug_photos_constrain_by_padding}px; }\n";
455 - $css .= ".photonic-smug-stream img { ".$this->get_border_css('photonic_smug_photo_thumb_border').$this->get_padding_css('photonic_smug_photo_thumb_padding')." }\n";
456 - $css .= ".photonic-panel .photonic-smug-image img { ".$this->get_border_css('photonic_smug_photo_pop_thumb_border').$this->get_padding_css('photonic_smug_photo_pop_thumb_padding')." }\n";
457 -
458 - $css .= ".photonic-panel { ".$this->get_bg_css('photonic_flickr_gallery_panel_background').$this->get_border_css('photonic_flickr_set_popup_thumb_border')." }\n";
459 -
460 - $css .= ".photonic-panel .photonic-flickr-image img { ".$this->get_border_css('photonic_flickr_pop_photo_thumb_border').$this->get_padding_css('photonic_flickr_pop_photo_thumb_padding')." }\n";
461 - $css .= ".photonic-flickr-panel .photonic-pad-photos { padding: 10px {$photonic_flickr_photos_pop_constrain_by_padding}px; box-sizing: border-box; }\n";
462 - $css .= ".photonic-smug-panel .photonic-pad-photos { padding: 10px {$photonic_smug_photos_pop_constrain_by_padding}px; box-sizing: border-box; }\n";
463 - $css .= ".photonic-flickr-coll-thumb img { ".$this->get_border_css('photonic_flickr_coll_thumb_border').$this->get_padding_css('photonic_flickr_coll_thumb_padding')." }\n";
464 - $css .= ".photonic-flickr-set .photonic-flickr-set-solo-thumb img { ".$this->get_border_css('photonic_flickr_set_alone_thumb_border').$this->get_padding_css('photonic_flickr_set_alone_thumb_padding')." }\n";
465 - $css .= ".photonic-flickr-stream .photonic-flickr-photo img { ".$this->get_border_css('photonic_flickr_photo_thumb_border').$this->get_padding_css('photonic_flickr_photo_thumb_padding')." }\n";
466 - $css .= ".photonic-flickr-set-thumb img { ".$this->get_border_css('photonic_flickr_sets_set_thumb_border').$this->get_padding_css('photonic_flickr_sets_set_thumb_padding')." }\n";
467 - $css .= ".photonic-smug-album-thumb img { ".$this->get_border_css('photonic_smug_albums_album_thumb_border').$this->get_padding_css('photonic_smug_albums_album_thumb_padding')." }\n";
468 -
469 - $css .= ".photonic-random-layout .photonic-tiled-photo { padding: {$photonic_tile_spacing}px}\n";
470 - $css .= ".photonic-masonry-layout .photonic-thumb { padding: {$photonic_masonry_tile_spacing}px}\n";
471 - $css .= ".photonic-mosaic-layout .photonic-thumb { padding: {$photonic_mosaic_tile_spacing}px}\n";
472 -
473 - $css .= ".photonic-ie .photonic-masonry-layout .photonic-level-1, .photonic-ie .photonic-masonry-layout .photonic-level-2 { width: ".(absint($photonic_masonry_min_width) ? absint($photonic_masonry_min_width) : 200)."px; }\n";
474 -
475 - if ($header) {
476 - $css .= "\n</style>\n";
477 - echo $css;
478 - }
479 - return $css;
480 - }
481 -
482 - function get_version($file) {
483 - return date("Ymd-Gis", @filemtime($file));
484 - }
485 -
486 - function admin_init() {
487 - if (!empty($_REQUEST['page']) &&
488 - in_array($_REQUEST['page'], array('photonic-options-manager', 'photonic-options', 'photonic-helpers', 'photonic-getting-started', 'photonic-auth', 'photonic-gutenberg'))) {
489 - global $photonic_options_manager;
490 - require_once(plugin_dir_path(__FILE__)."/photonic-options-manager.php");
491 - $photonic_options_manager = new Photonic_Options_Manager(__FILE__, $this);
492 - $photonic_options_manager->init();
493 - }
494 - }
495 -
496 - function add_extensions() {
497 - require_once(plugin_dir_path(__FILE__)."/extensions/Photonic_Processor.php");
498 - require_once(plugin_dir_path(__FILE__)."/extensions/Photonic_OAuth1_Processor.php");
499 - require_once(plugin_dir_path(__FILE__)."/extensions/Photonic_OAuth2_Processor.php");
500 - $this->register_extension('Photonic_Flickr_Processor', plugin_dir_path(__FILE__)."/extensions/Photonic_Flickr_Processor.php");
501 - $this->register_extension('Photonic_Google_Photos_Processor', plugin_dir_path(__FILE__)."/extensions/Photonic_Google_Photos_Processor.php");
502 - $this->register_extension('Photonic_Native_Processor', plugin_dir_path(__FILE__)."/extensions/Photonic_Native_Processor.php");
503 - $this->register_extension('Photonic_SmugMug_Processor', plugin_dir_path(__FILE__)."/extensions/Photonic_SmugMug_Processor.php");
504 - $this->register_extension('Photonic_Instagram_Processor', plugin_dir_path(__FILE__)."/extensions/Photonic_Instagram_Processor.php");
505 - $this->register_extension('Photonic_Zenfolio_Processor', plugin_dir_path(__FILE__)."/extensions/Photonic_Zenfolio_Processor.php");
506 -
507 - require_once(plugin_dir_path(__FILE__).'/layouts/Layout_Default.php');
508 - require_once(plugin_dir_path(__FILE__).'/layouts/Layout_Slideshow.php');
509 -
510 - do_action('photonic_register_extensions');
511 - }
512 -
513 - public function register_extension($extension, $path) {
514 - if (@!file_exists($path)) {
515 - return;
516 - }
517 - require_once($path);
518 - if (!class_exists($extension) || is_subclass_of($extension, 'Photonic_Processor')) {
519 - return;
520 - }
521 - $this->registered_extensions[] = $extension;
522 - }
523 -
524 - /**
525 - * Overrides the native gallery short code, and does a lot more.
526 - *
527 - * @param $content
528 - * @param array $attr
529 - * @return string
530 - */
531 - function modify_gallery($content, $attr = array()) {
532 - global $photonic_alternative_shortcode;
533 -
534 - // If an alternative shortcode is used, then $content has the shortcode attributes
535 - if (!empty($photonic_alternative_shortcode)) {
536 - $attr = $content;
537 - }
538 - if ($attr == null) {
539 - $attr = array();
540 - }
541 -
542 - $images = $this->get_gallery_images($attr);
543 -
544 - if (isset($images) && !is_array($images)) {
545 - return $images;
546 - }
547 -
548 - return $content;
549 - }
550 -
551 - /**
552 - * @param array $attr
553 - * @return string
554 - */
555 - function helper_shortcode($attr = array()) {
556 - if ($attr == null) {
557 - $attr = array();
558 - }
559 -
560 - if (empty($attr['type']) || !in_array(strtolower($attr['type']), array('google', 'flickr', 'smugmug', 'zenfolio'))) {
561 - return sprintf(esc_html__('Please specify a value for %1%s. Accepted values are %2$s, %3$s, %4$s, %5$s', 'photonic'), '<code>type</code>', '<code>google</code>', '<code>flickr</code>', '<code>smugmug</code>', '<code>zenfolio</code>');
562 - }
563 - $gallery = $this->initialize_extension($attr['type']);
564 - return $gallery->execute_helper($attr);
565 - }
566 -
567 - /**
568 - * @param $attr
569 - * @return array|bool|string
570 - */
571 - private function get_gallery_images($attr) {
572 - global $post, $photonic_thumbnail_style, $photonic_nested_shortcodes;
573 - $attr = array_merge(array(
574 - // Especially for Photonic
575 - 'type' => 'default', //default, flickr, smugmug, google, zenfolio, instagram
576 - 'style' => 'default', //default, strip-below, strip-above, strip-right, strip-left, no-strip, launch
577 - 'id' => $post->ID,
578 - 'layout' => isset($photonic_thumbnail_style) ? $photonic_thumbnail_style : 'square',
579 - ), $attr);
580 -
581 - if ($photonic_nested_shortcodes) {
582 - $attr = array_map('do_shortcode', $attr);
583 - }
584 -
585 - extract($attr);
586 -
587 - $type = strtolower($attr['type']);
588 -
589 - if ($type == 'picasa') {
590 - $message = esc_html__('Google has deprecated the Picasa API. Please consider switching over to Google Photos', 'photonic');
591 - return "<div class='photonic-error'>\n\t<span class='photonic-error-icon photonic-icon'>&nbsp;</span>\n\t<div class='photonic-message'>\n\t\t$message\n\t</div>\n</div>\n";
592 - }
593 -
594 - if ($type == '500px') {
595 - $message = esc_html__('The API for 500px.com is no longer available for public use.', 'photonic');
596 - return "<div class='photonic-error'>\n\t<span class='photonic-error-icon photonic-icon'>&nbsp;</span>\n\t<div class='photonic-message'>\n\t\t$message\n\t</div>\n</div>\n";
597 - }
598 -
599 - if (!in_array($type, array('flickr', 'smugmug', 'google', 'zenfolio', 'instagram'))) {
600 - $gallery = $this->initialize_extension('native');
601 - }
602 - else {
603 - $gallery = $this->initialize_extension($type);
604 - }
605 -
606 - if (!is_null($gallery)) {
607 - $images = $gallery->get_gallery_images($attr);
608 - }
609 - return $images;
610 - }
611 -
612 - /**
613 - * @param $provider
614 - * @return Photonic_Processor|Photonic_Flickr_Processor|Photonic_Instagram_Processor|Photonic_Native_Processor|Photonic_Google_Photos_Processor|Photonic_SmugMug_Processor|Photonic_Zenfolio_Processor
615 - */
616 - function initialize_extension($provider) {
617 - global $photonic_flickr_gallery, $photonic_google_gallery, $photonic_smugmug_gallery, $photonic_instagram_gallery, $photonic_zenfolio_gallery, $photonic_native_gallery;
618 - if ($provider == 'flickr') {
619 - if (!isset($photonic_flickr_gallery)) $photonic_flickr_gallery = new Photonic_Flickr_Processor();
620 - return $photonic_flickr_gallery;
621 - }
622 - else if ($provider == 'google') {
623 - if (!isset($photonic_google_gallery)) $photonic_google_gallery = new Photonic_Google_Photos_Processor();
624 - return $photonic_google_gallery;
625 - }
626 - else if ($provider == 'smugmug' || $provider == 'smug') {
627 - if (!isset($photonic_smugmug_gallery)) $photonic_smugmug_gallery = new Photonic_SmugMug_Processor();
628 - return $photonic_smugmug_gallery;
629 - }
630 - else if ($provider == 'zenfolio') {
631 - if (!isset($photonic_zenfolio_gallery)) $photonic_zenfolio_gallery = new Photonic_Zenfolio_Processor();
632 - return $photonic_zenfolio_gallery;
633 - }
634 - else if ($provider == 'instagram') {
635 - if (!isset($photonic_instagram_gallery)) $photonic_instagram_gallery = new Photonic_Instagram_Processor();
636 - return $photonic_instagram_gallery;
637 - }
638 - else {
639 - if (!isset($photonic_native_gallery)) $photonic_native_gallery = new Photonic_Native_Processor();
640 - return $photonic_native_gallery;
641 - }
642 - }
643 -
644 - /**
645 - * Clicking on a level 2 object (i.e. an Album / Set / Gallery) triggers this. This will fetch the contents of the level 2 object and generate the markup for it.
646 - *
647 - * @return void
648 - */
649 - function display_level_2_contents() {
650 - $panel = esc_attr($_POST['panel_id']);
651 - $components = explode('-', $panel);
652 -
653 - if (count($components) <= 5) {
654 - die();
655 - }
656 - $panel = implode('-', array_slice($components, 4, 10, true));
657 - $args = array(
658 - 'display' => 'popup',
659 - 'layout' => 'square',
660 - 'panel' => $panel,
661 - 'password' => !empty($_POST['password']) ? sanitize_text_field($_POST['password']) : '',
662 - 'count' => sanitize_text_field($_POST['photo_count']),
663 - 'photo_more' => sanitize_text_field($_POST['photo_more']),
664 - );
665 -
666 - $provider = $components[1];
667 - $type = $components[2];
668 - if ($provider == 'smug') {
669 - $this->check_authentication_smug();
670 - $args['view'] = 'album';
671 - $args['album_key'] = $components[4];
672 - $gallery = $this->initialize_extension('smugmug');
673 - }
674 - else if ($provider == 'zenfolio') {
675 - $args['view'] = 'photosets';
676 - $args['object_id'] = $components[4];
677 - $args['thumb_size'] = sanitize_text_field($_POST['overlay_size']);
678 - $args['realm_id'] = sanitize_text_field($_POST['realm_id']);
679 - $gallery = $this->initialize_extension('zenfolio');
680 - }
681 -/* else if ($provider == '500px') {
682 - $args['view'] = 'collections';
683 - $args['view_id'] = $components[4];
684 - $gallery = $this->initialize_extension('500px');
685 - }*/
686 - else if ($provider == 'google') {
687 - $args['view'] = 'photos';
688 - $args['album_id'] = implode('-', array_slice($components, 4, (count($components) - 1) - 4));
689 - $args['thumb_size'] = sanitize_text_field($_POST['overlay_size']);
690 - $args['crop_thumb'] = sanitize_text_field($_POST['overlay_crop']);
691 - $gallery = $this->initialize_extension('google');
692 - }
693 - else if ($provider == 'flickr') {
694 - if ($type == 'gallery') {
695 - $args['gallery_id'] = $components[4].'-'.$components[5];
696 - $args['gallery_id_computed'] = true;
697 - }
698 - else if ($type = 'set') {
699 - $args['photoset_id'] = $components[4];
700 - }
701 - $args['thumb_size'] = sanitize_text_field($_POST['overlay_size']);
702 - $gallery = $this->initialize_extension('flickr');
703 - }
704 -
705 - echo $gallery->get_gallery_images($args);
706 - die();
707 - }
708 -
709 - function display_level_3_contents() {
710 - $node = esc_attr($_POST['node']);
711 - $components = explode('-', $node);
712 -
713 - if (count($components) <= 3) {
714 - die();
715 - }
716 -
717 - $args = array('display' => 'in-page', 'headers' => '', 'layout' => esc_attr($_POST['layout']));
718 -
719 - $provider = $components[0];
720 - if ($provider == 'flickr') {
721 - $args['collection_id'] = implode('-', array_slice($components, 2, 2, true));
722 - $args['user_id'] = $components[4];
723 - $gallery = $this->initialize_extension('flickr');
724 - }
725 -
726 - echo $gallery->get_gallery_images($args);
727 - die();
728 - }
729 -
730 - /**
731 - * Checks if a text being passed to it is an integer or not.
732 - *
733 - * @param $val
734 - * @return bool
735 - */
736 - static function check_integer($val) {
737 - if (substr($val, 0, 1) == '-') {
738 - $val = substr($val, 1);
739 - }
740 - return (preg_match('/^\d*$/', $val) == 1);
741 - }
742 -
743 - /**
744 - * Converts a string to a boolean variable, if possible.
745 - *
746 - * @param $value
747 - * @return bool
748 - */
749 - static function string_to_bool($value) {
750 - if ($value == true || $value == 'true' || $value == 'TRUE' || $value == '1') {
751 - return true;
752 - }
753 - else if ($value == false || $value == 'false' || $value == 'FALSE' || $value == '0') {
754 - return false;
755 - }
756 - else {
757 - return $value;
758 - }
759 - }
760 -
761 - /**
762 - * Constructs the CSS for a "background" option
763 - *
764 - * @param $option
765 - * @return string
766 - */
767 - function get_bg_css($option) {
768 - global ${$option};
769 - $option_val = ${$option};
770 - if (!is_array($option_val)) {
771 - $val_array = array();
772 - $vals = explode(';', $option_val);
773 - foreach ($vals as $val) {
774 - if (trim($val) == '') { continue; }
775 - $pair = explode('=', $val);
776 - $val_array[$pair[0]] = $pair[1];
777 - }
778 - $option_val = $val_array;
779 - }
780 - $bg_string = "";
781 - $bg_rgba_string = "";
782 - if (!isset($option_val['colortype']) || $option_val['colortype'] == 'transparent') {
783 - $bg_string .= " transparent ";
784 - }
785 - else {
786 - if (isset($option_val['color'])) {
787 - if (substr($option_val['color'], 0, 1) == '#') {
788 - $color_string = substr($option_val['color'],1);
789 - }
790 - else {
791 - $color_string = $option_val['color'];
792 - }
793 - $rgb_str_array = array();
794 - if (strlen($color_string)==3) {
795 - $rgb_str_array[] = substr($color_string, 0, 1).substr($color_string, 0, 1);
796 - $rgb_str_array[] = substr($color_string, 1, 1).substr($color_string, 1, 1);
797 - $rgb_str_array[] = substr($color_string, 2, 1).substr($color_string, 2, 1);
798 - }
799 - else {
800 - $rgb_str_array[] = substr($color_string, 0, 2);
801 - $rgb_str_array[] = substr($color_string, 2, 2);
802 - $rgb_str_array[] = substr($color_string, 4, 2);
803 - }
804 - $rgb_array = array();
805 - $rgb_array[] = hexdec($rgb_str_array[0]);
806 - $rgb_array[] = hexdec($rgb_str_array[1]);
807 - $rgb_array[] = hexdec($rgb_str_array[2]);
808 - $rgb_string = implode(',',$rgb_array);
809 - $rgb_string = ' rgb('.$rgb_string.') ';
810 -
811 - if (isset($option_val['trans'])) {
812 - $bg_rgba_string = $bg_string;
813 - $transparency = (int)$option_val['trans'];
814 - if ($transparency != 0) {
815 - $trans_dec = $transparency/100;
816 - $rgba_string = implode(',', $rgb_array);
817 - $rgba_string = ' rgba('.$rgba_string.','.$trans_dec.') ';
818 - $bg_rgba_string .= $rgba_string;
819 - }
820 - }
821 -
822 - $bg_string .= $rgb_string;
823 - }
824 - }
825 - if (isset($option_val['image']) && trim($option_val['image']) != '') {
826 - $bg_string .= " url(".$option_val['image'].") ";
827 - $bg_string .= $option_val['position']." ".$option_val['repeat'];
828 -
829 - if (trim($bg_rgba_string) != '') {
830 - $bg_rgba_string .= " url(".$option_val['image'].") ";
831 - $bg_rgba_string .= $option_val['position']." ".$option_val['repeat'];
832 - }
833 - }
834 -
835 - if (trim($bg_string) != '') {
836 - $bg_string = "background: ".$bg_string." !important;\n";
837 - if (trim($bg_rgba_string) != '') {
838 - $bg_string .= "\tbackground: ".$bg_rgba_string." !important;\n";
839 - }
840 - }
841 - return $bg_string;
842 - }
843 -
844 - /**
845 - * Generates the CSS for borders. Each border, top, right, bottom and left is generated as a separate line.
846 - *
847 - * @param $option
848 - * @return string
849 - */
850 - function get_border_css($option) {
851 - global ${$option};
852 - $option_val = ${$option};
853 - if (!is_array($option_val)) {
854 - $option_val = stripslashes($option_val);
855 - $edge_array = $this->build_edge_array($option_val);
856 - $option_val = $edge_array;
857 - }
858 - $border_string = '';
859 - foreach ($option_val as $edge => $selections) {
860 - $border_string .= "\tborder-$edge: ";
861 - if (!isset($selections['style'])) {
862 - $selections['style'] = 'none';
863 - }
864 - if ($selections['style'] == 'none') {
865 - $border_string .= "none";
866 - }
867 - else {
868 - if (isset($selections['border-width'])) {
869 - $border_string .= $selections['border-width'];
870 - }
871 - if (isset($selections['border-width-type'])) {
872 - $border_string .= $selections['border-width-type'];
873 - }
874 - else {
875 - $border_string .= "px";
876 - }
877 - $border_string .= " ".$selections['style']." ";
878 - if ($selections['colortype'] == 'transparent') {
879 - $border_string .= "transparent";
880 - }
881 - else {
882 - if (substr($selections['color'], 0, 1) == '#') {
883 - $border_string .= $selections['color'];
884 - }
885 - else {
886 - $border_string .= '#'.$selections['color'];
887 - }
888 - }
889 - }
890 - $border_string .= ";\n";
891 - }
892 - return "\n".$border_string;
893 - }
894 -
895 - /**
896 - * Generates the CSS for use in padding. This generates individual padding strings for each side, top, right, bottom and left.
897 - *
898 - * @param $option
899 - * @return string
900 - */
901 - function get_padding_css($option) {
902 - global ${$option};
903 - $option_val = ${$option};
904 - if (!is_array($option_val)) {
905 - $option_val = stripslashes($option_val);
906 - $edge_array = $this->build_edge_array($option_val);
907 - $option_val = $edge_array;
908 - }
909 -
910 - $edges = array();
911 - foreach ($option_val as $edge => $selections) {
912 - $padding = '';
913 - if (isset($selections['padding'])) {
914 - $padding .= $selections['padding'];
915 - }
916 - else {
917 - $padding .= 0;
918 - }
919 -
920 - if ($padding != '0' && isset($selections['padding-type'])) {
921 - $padding .= $selections['padding-type'];
922 - }
923 - else if ($padding != '0') {
924 - $padding .= "px";
925 - }
926 - $edges[$edge] = $padding;
927 - }
928 -
929 - $edge_master = array('top', 'right', 'bottom', 'left');
930 - $consolidated = '';
931 - foreach ($edge_master as $edge) {
932 - $consolidated .= empty($edges[$edge]) ? '0 ' : $edges[$edge].' ';
933 - }
934 - $padding_string = "\tpadding: $consolidated;\n";
935 -
936 - return $padding_string;
937 - }
938 -
939 - public function build_edge_array($option_val) {
940 - $edge_array = array();
941 - $edges = explode('||', $option_val);
942 - foreach ($edges as $edge_val) {
943 - if (trim($edge_val) != '') {
944 - $edge_options = explode('::', trim($edge_val));
945 - if (is_array($edge_options) && count($edge_options) > 1) {
946 - $val_array = array();
947 - $vals = explode(';', $edge_options[1]);
948 - foreach ($vals as $val) {
949 - $pair = explode('=', $val);
950 - if (is_array($pair) && count($pair) > 1) {
951 - $val_array[$pair[0]] = $pair[1];
952 - }
953 - }
954 - $edge_array[$edge_options[0]] = $val_array;
955 - }
956 - }
957 - }
958 - return $edge_array;
959 - }
960 -
961 - /**
962 - * Adds a "Photonic" tab to the "Add Media" panel.
963 - *
964 - * @param $tabs
965 - * @return array
966 - */
967 - function media_upload_tabs($tabs) {
968 - if (!function_exists('is_gutenberg_page') || (function_exists('is_gutenberg_page') && !is_gutenberg_page())) {
969 - $tabs['photonic'] = 'Photonic';
970 - }
971 - return $tabs;
972 - }
973 -
974 - /**
975 - * Invokes the form to display the photonic insertion screen in the "Add Media" panel. The call to wp_iframe ensures that the right CSS and JS are called.
976 - *
977 - * @return void
978 - */
979 - function media_upload_photonic() {
980 - wp_iframe(array(&$this, 'media_upload_photonic_form'));
981 - }
982 -
983 - /**
984 - * First prints the standard buttons for media upload, then shows the UI for Photonic.
985 - *
986 - * @return void
987 - */
988 - function media_upload_photonic_form() {
989 - media_upload_header();
990 - require_once(plugin_dir_path(__FILE__)."/admin/add-gallery.php");
991 - }
992 -
993 - function edit_gallery() {
994 - require_once(plugin_dir_path(__FILE__)."/admin/edit-gallery-templates.php");
995 - }
996 -
997 - static function get_image_sizes_selection($element_name, $show_full = false) {
998 - $image_sizes = self::get_wp_image_sizes($show_full);
999 - $ret = "<select name='$element_name'>";
1000 - foreach ($image_sizes as $size_name => $size_attrs) {
1001 - $ret .= "<option value='$size_name'>$size_name ({$size_attrs['width']} &times; {$size_attrs['height']})</option>";
1002 - }
1003 - $ret .= '</select>';
1004 - return $ret;
1005 - }
1006 -
1007 - /**
1008 - * Make an HTTP request
1009 - *
1010 - * @static
1011 - * @param $url
1012 - * @param string $method GET | POST | DELETE
1013 - * @param null $post_fields
1014 - * @param string $user_agent
1015 - * @param int $timeout
1016 - * @param bool $ssl_verify_peer
1017 - * @return array|WP_Error
1018 - */
1019 - static function http($url, $method = 'POST', $post_fields = NULL, $user_agent = null, $timeout = 90, $ssl_verify_peer = false, $headers = array(), $cookies = array()) {
1020 - $curl_args = array(
1021 - 'user-agent' => $user_agent,
1022 - 'timeout' => $timeout,
1023 - 'sslverify' => $ssl_verify_peer,
1024 - 'headers' => array_merge(array('Expect:'), $headers),
1025 - 'method' => $method,
1026 - 'body' => $post_fields,
1027 - 'cookies' => $cookies,
1028 - );
1029 -
1030 - switch ($method) {
1031 - case 'DELETE':
1032 - if (!empty($post_fields)) {
1033 - $url = "{$url}?{$post_fields}";
1034 - }
1035 - break;
1036 - }
1037 -
1038 - $response = wp_remote_request($url, $curl_args);
1039 - return $response;
1040 - }
1041 -
1042 - /**
1043 - * Returns the page where the OAuth API is being invoked. The invocation happens through admin-ajax.php, but we don't want
1044 - * the validated user to land up there. Instead we want the users to reach the page where they clicked the "Login" button.
1045 - *
1046 - * @static
1047 - * @return string
1048 - */
1049 - static function get_callback_url() {
1050 - global $photonic_callback_url;
1051 - if (isset($photonic_callback_url)) {
1052 - return $photonic_callback_url;
1053 - }
1054 -
1055 - $page_URL = 'http';
1056 - if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
1057 - $page_URL .= "s";
1058 - }
1059 - $page_URL .= "://";
1060 - if (isset($_SERVER["SERVER_PORT"])) {
1061 - $page_URL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
1062 - }
1063 - else if (!isset($_SERVER["SERVER_PORT"]) && $page_URL == 'http://') {
1064 - $page_URL .= $_SERVER["SERVER_NAME"].":80".$_SERVER["REQUEST_URI"];
1065 - }
1066 - else if (!isset($_SERVER["SERVER_PORT"]) && $page_URL == 'https://') {
1067 - $page_URL .= $_SERVER["SERVER_NAME"].":443".$_SERVER["REQUEST_URI"];
1068 - }
1069 - else {
1070 - $page_URL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
1071 - }
1072 - return $page_URL;
1073 - }
1074 -
1075 - /**
1076 - * Checks if a user has authenticated a particular provider's services. When this is invoked we don't know if the page has
1077 - * a Flickr / 500px / SmugMug gallery, so we just invoke it and set some global variables.
1078 - *
1079 - * @return void
1080 - */
1081 - function check_authentication() {
1082 - if (is_admin()) {
1083 - return;
1084 - }
1085 - global $photonic_flickr_allow_oauth, $photonic_smug_allow_oauth;
1086 - if (!$photonic_flickr_allow_oauth && !$photonic_smug_allow_oauth) {
1087 - return;
1088 - }
1089 -
1090 - global $photonic_flickr_oauth_done, $photonic_smug_oauth_done;
1091 - $photonic_flickr_oauth_done = $photonic_smug_oauth_done = false;
1092 -
1093 - $cookie = Photonic::parse_cookie();
1094 - global $photonic_flickr_gallery;
1095 -
1096 - $this->check_provider_authentication($photonic_flickr_allow_oauth, 'flickr', $photonic_flickr_gallery, $photonic_flickr_oauth_done);
1097 -
1098 - $this->check_authentication_smug($cookie);
1099 - }
1100 -
1101 - /**
1102 - * Searches for specific cookies in the user's browser. It then builds an array with the available cookies. The keys of the array
1103 - * are the individual providers ('flickr', 'smug' etc) and the values are arrays of key-value mappings.
1104 - *
1105 - * @static
1106 - * @return array
1107 - */
1108 - public static function parse_cookie() {
1109 - $cookie = array(
1110 - 'flickr' => array(),
1111 - 'smug' => array(),
1112 - );
1113 - $auth_types = array(
1114 - 'flickr' => 'oauth1',
1115 - 'smug' => 'oauth1',
1116 - );
1117 - $cookie_keys = array('oauth_token', 'oauth_token_secret', 'oauth_token_type', 'access_token', 'access_token_type', 'oauth_token_created', 'oauth_token_expires', 'oauth_refresh_token');
1118 - foreach ($cookie as $provider => $cookies) {
1119 - $orig_secret = $auth_types[$provider] == 'oauth1' ? 'photonic_'.$provider.'_api_secret' : 'photonic_'.$provider.'_client_secret';
1120 - global ${$orig_secret};
1121 - if (isset(${$orig_secret})) {
1122 - $secret = md5(${$orig_secret}, false);
1123 - foreach ($cookie_keys as $cookie_key) {
1124 - $key = '-'.str_replace('_', '-', $cookie_key);
1125 - if (isset($_COOKIE['photonic-'.$secret.$key])) {
1126 - $cookie[$provider][$cookie_key] = $_COOKIE['photonic-'.$secret.$key];
1127 - }
1128 - }
1129 - }
1130 - }
1131 - return $cookie;
1132 - }
1133 -
1134 - /**
1135 - * The initiation process for the authentication. When a user clicks on this button, a request token is obtained and the authorization
1136 - * is performed. Then the user is redirected to an authorization site, where the user can authorize this site.
1137 - */
1138 - function authenticate() {
1139 - if (isset($_POST['provider'])) {
1140 - $provider = sanitize_text_field($_POST['provider']);
1141 - $callback_id = sanitize_text_field($_POST['callback_id']);
1142 - $post_id = substr($callback_id, 19);
1143 - global $photonic_callback_url;
1144 - $photonic_callback_url = get_permalink($post_id);
1145 -
1146 - $gallery = $this->initialize_extension($provider);
1147 - switch ($provider) {
1148 - case 'flickr':
1149 - $request_token = $gallery->get_request_token();
1150 - $authorize_url = $gallery->get_authorize_URL($request_token);
1151 - echo $authorize_url.'&perms=read';
1152 - die;
1153 -
1154 - case 'smug':
1155 - $request_token = $gallery->get_request_token();
1156 - $authorize_url = $gallery->get_authorize_URL($request_token);
1157 - echo $authorize_url.'&Access=Full&Permissions=Read';
1158 - die;
1159 - }
1160 - }
1161 - }
1162 -
1163 - function obtain_token() {
1164 - global $photonic_google_gallery, $photonic_flickr_gallery, $photonic_smugmug_gallery, $photonic_zenfolio_gallery;
1165 - $provider = sanitize_text_field($_POST['provider']);
1166 - if ($provider == 'google') {
1167 - $code = esc_attr($_POST['code']);
1168 - $photonic_google_gallery = $this->initialize_extension('google');
1169 - global $photonic_google_use_own_keys, $photonic_google_client_id, $photonic_google_client_secret;
1170 -// if (!empty($photonic_google_use_own_keys) || (!empty($photonic_google_client_id) && !empty($photonic_google_client_secret))) {
1171 - $response = Photonic::http($photonic_google_gallery->access_token_URL(), 'POST', array(
1172 - 'code' => $code,
1173 - 'grant_type' => 'authorization_code',
1174 - 'client_id' => $photonic_google_gallery->client_id,
1175 - 'client_secret' => $photonic_google_gallery->client_secret,
1176 - 'redirect_uri' => admin_url('admin.php?page=photonic-auth&source=google'),
1177 - ));
1178 -/* }
1179 - else {
1180 - $response = Photonic::http($photonic_google_gallery->access_token_URL(), 'POST', array(
1181 - 'code' => $code,
1182 - 'grant_type' => 'authorization_code',
1183 - 'client_id' => $photonic_google_gallery->client_id,
1184 - 'client_secret' => $photonic_google_gallery->client_secret,
1185 - 'redirect_uri' => 'https://aquoid.com/photonic-router/google.php',
1186 - 'state' => admin_url('admin.php?page=photonic-auth&source=google'),
1187 - ));
1188 - }*/
1189 -
1190 - if (!is_wp_error($response) && is_array($response)) {
1191 - echo($response['body']);
1192 - }
1193 - else {
1194 - }
1195 - }
1196 - else if ($provider == 'flickr') {
1197 - $photonic_flickr_gallery = $this->initialize_extension('flickr');
1198 - if (empty($_POST['oauth_token']) && empty($_POST['oauth_verifier'])) {
1199 - $request_token = $photonic_flickr_gallery->get_request_token(admin_url('admin.php?page=photonic-auth&provider=flickr'), false);
1200 - $authorize_url = $photonic_flickr_gallery->get_authorize_URL($request_token);
1201 - $authorize_url .= '&perms=read';
1202 - $photonic_flickr_gallery->save_token($request_token);
1203 - echo $authorize_url;
1204 - }
1205 - }
1206 - else if ($provider == 'smug') {
1207 - $photonic_smugmug_gallery = $this->initialize_extension('smugmug');
1208 - if (empty($_POST['oauth_token']) && empty($_POST['oauth_verifier'])) {
1209 - $request_token = $photonic_smugmug_gallery->get_request_token(admin_url('admin.php?page=photonic-auth&provider=smug'), false);
1210 - $authorize_url = $photonic_smugmug_gallery->get_authorize_URL($request_token);
1211 - $authorize_url .= '&Access=Full&Permissions=Read';
1212 - $photonic_smugmug_gallery->save_token($request_token);
1213 - echo $authorize_url;
1214 - }
1215 - }
1216 - else if ($provider == 'zenfolio') {
1217 - $photonic_zenfolio_gallery = $this->initialize_extension('zenfolio');
1218 - if (!empty($_POST['password'])) {
1219 - $response = $photonic_zenfolio_gallery->authenticate($_POST['password']);
1220 - if (!empty($response['error'])) {
1221 - echo $response['error'];
1222 - }
1223 - else if (!empty($response['success'])) {
1224 - esc_html_e('Authentication successful! All your galleries will be displayed with Authentication in place.', 'photonic');
1225 - }
1226 - }
1227 - }
1228 - die();
1229 - }
1230 -
1231 - function save_token_in_options() {
1232 - $provider = strtolower(sanitize_text_field($_POST['provider']));
1233 - $token = esc_attr($_POST['token']);
1234 - $secret = esc_attr($_POST['secret']);
1235 -
1236 - $options = get_option('photonic_options');
1237 - if (empty($options)) {
1238 - $options = array();
1239 - }
1240 - $option_set = false;
1241 - if (in_array($provider, array('flickr', 'smug', 'instagram', 'zenfolio'))) {
1242 - $options[$provider.'_access_token'] = $token;
1243 - if ($provider != 'instagram') {
1244 - $options[$provider.'_token_secret'] = $secret;
1245 - }
1246 - $option_set = true;
1247 - }
1248 - else if (in_array($provider, array('google'))) {
1249 - $options[$provider.'_refresh_token'] = $token;
1250 - $option_set = true;
1251 - }
1252 - if ($option_set) {
1253 - update_option('photonic_options', $options);
1254 - echo admin_url('admin.php?page=photonic-options-manager&tab='.($provider == 'smug' ? 'smugmug' : $provider).'-options.php');
1255 - }
1256 - die();
1257 - }
1258 -
1259 - function delete_token_from_options() {
1260 - $provider = strtolower(sanitize_text_field($_POST['provider']));
1261 - $photonic_authentication = get_option('photonic_authentication');
1262 - if ($provider == 'zenfolio') {
1263 - if (isset($photonic_authentication[$provider])) {
1264 - unset($photonic_authentication[$provider]);
1265 - }
1266 - }
1267 - update_option('photonic_authentication', $photonic_authentication);
1268 - die();
1269 - }
1270 -
1271 - function invoke_helper() {
1272 - global $photonic_options_manager;
1273 - require_once(plugin_dir_path(__FILE__)."/photonic-options-manager.php");
1274 - $photonic_options_manager = new Photonic_Options_Manager(__FILE__, $this);
1275 - $photonic_options_manager->init();
1276 - $photonic_options_manager->invoke_helper();
1277 - }
1278 -
1279 - /**
1280 - * @return array
1281 - */
1282 - public function get_localized_js_variables() {
1283 - global $photonic_lightbox_no_loop, $photonic_slideshow_mode, $photonic_slideshow_interval, $photonic_slideshow_library, $photonic_custom_lightbox,
1284 - $photonic_cb_transition_effect, $photonic_cb_transition_speed,
1285 - $photonic_fbox_title_position, $photonic_fb3_transition_effect, $photonic_fb3_transition_speed, $photonic_fb3_show_fullscreen, $photonic_enable_fb3_fullscreen,
1286 - $photonic_fb3_hide_thumbs, $photonic_enable_fb3_thumbnail, $photonic_fb3_disable_zoom, $photonic_fb3_disable_slideshow, $photonic_fb3_enable_download, $photonic_fb3_disable_right_click,
1287 - $photonic_lc_transition_effect, $photonic_lc_transition_speed_in, $photonic_lc_transition_speed_out, $photonic_lc_enable_shrink,
1288 - $photonic_lg_transition_effect, $photonic_lg_transition_speed, $photonic_disable_lg_download, $photonic_lg_hide_bars_delay,
1289 - $photonic_tile_spacing, $photonic_tile_min_height, $photonic_pphoto_theme, $photonic_pp_animation_speed,
1290 - $photonic_enable_swipebox_mobile_bars, $photonic_sb_hide_mobile_close, $photonic_sb_hide_bars_delay,
1291 - $photonic_lightbox_for_all, $photonic_lightbox_for_videos, $photonic_popup_panel_width, $photonic_deep_linking, $photonic_social_media,
1292 - $photonic_slideshow_prevent_autostart, $photonic_wp_slide_adjustment, $photonic_masonry_min_width, $photonic_mosaic_trigger_width;
1293 -
1294 - global $photonic_js_variables;
1295 -
1296 - $slideshow_library = $photonic_slideshow_library == 'custom' ? $photonic_custom_lightbox : $photonic_slideshow_library;
1297 - $js_array = array(
1298 - 'ajaxurl' => admin_url('admin-ajax.php'),
1299 - 'plugin_url' => PHOTONIC_URL,
1300 - 'fbox_show_title' => $photonic_fbox_title_position == 'none' ? false : true,
1301 - 'fbox_title_position' => $photonic_fbox_title_position == 'none' ? 'outside' : $photonic_fbox_title_position,
1302 -
1303 - 'slide_adjustment' => empty($photonic_wp_slide_adjustment) ? 'adapt-height-width' : $photonic_wp_slide_adjustment,
1304 -
1305 - 'deep_linking' => isset($photonic_deep_linking) ? $photonic_deep_linking : 'none',
1306 - 'social_media' => isset($photonic_deep_linking) ? $photonic_deep_linking != 'none' && empty($photonic_social_media) : '',
1307 -
1308 - 'slideshow_library' => $slideshow_library,
1309 - 'tile_spacing' => (empty($photonic_tile_spacing) || empty(absint($photonic_tile_spacing))) ? 0 : absint($photonic_tile_spacing),
1310 - 'tile_min_height' => (empty($photonic_tile_min_height) || empty(absint($photonic_tile_min_height))) ? 200 : absint($photonic_tile_min_height),
1311 - 'masonry_min_width' => (empty($photonic_masonry_min_width) || empty(absint($photonic_masonry_min_width))) ? 200 : absint($photonic_masonry_min_width),
1312 - 'mosaic_trigger_width' => (empty($photonic_mosaic_trigger_width) || empty(absint($photonic_mosaic_trigger_width))) ? 200 : absint($photonic_mosaic_trigger_width),
1313 -
1314 - 'slideshow_mode' => (isset($photonic_slideshow_mode) && $photonic_slideshow_mode == 'on') ? true : false,
1315 - 'slideshow_interval' => (isset($photonic_slideshow_interval) && absint($photonic_slideshow_interval)) ? absint($photonic_slideshow_interval) : 5000,
1316 - 'lightbox_loop' => empty($photonic_lightbox_no_loop),
1317 -
1318 - 'gallery_panel_width' => (empty($photonic_popup_panel_width) || !absint($photonic_popup_panel_width) || absint($photonic_popup_panel_width) > 100) ? 80 : absint($photonic_popup_panel_width),
1319 -
1320 - 'cb_transition_effect' => empty($photonic_cb_transition_effect) ? 'elastic' : $photonic_cb_transition_effect,
1321 - 'cb_transition_speed' => (isset($photonic_cb_transition_speed) && absint($photonic_cb_transition_speed)) ? absint($photonic_cb_transition_speed) : 350,
1322 -
1323 - 'fb3_transition_effect' => empty($photonic_fb3_transition_effect) ? 'zoom' : $photonic_fb3_transition_effect,
1324 - 'fb3_transition_speed' => (isset($photonic_fb3_transition_speed) && absint($photonic_fb3_transition_speed)) ? absint($photonic_fb3_transition_speed) : 366,
1325 - 'fb3_fullscreen_button' => !empty($photonic_fb3_show_fullscreen),
1326 - 'fb3_fullscreen' => isset($photonic_enable_fb3_fullscreen) && $photonic_enable_fb3_fullscreen == 'on' ? true : false,
1327 - 'fb3_thumbs_button' => empty($photonic_fb3_hide_thumbs),
1328 - 'fb3_thumbs' => isset($photonic_enable_fb3_thumbnail) && $photonic_enable_fb3_thumbnail == 'on' ? true : false,
1329 - 'fb3_zoom' => empty($photonic_fb3_disable_zoom),
1330 - 'fb3_slideshow' => empty($photonic_fb3_disable_slideshow),
1331 - 'fb3_download' => !empty($photonic_fb3_enable_download),
1332 - 'fb3_disable_right_click' => !empty($photonic_fb3_disable_right_click),
1333 -
1334 - 'lc_transition_effect' => empty($photonic_lc_transition_effect) ? 'scrollHorizontal' : $photonic_lc_transition_effect,
1335 - 'lc_transition_speed_in' => (isset($photonic_lc_transition_speed_in) && absint($photonic_lc_transition_speed_in)) ? absint($photonic_lc_transition_speed_in) : 350,
1336 - 'lc_transition_speed_out' => (isset($photonic_lc_transition_speed_out) && absint($photonic_lc_transition_speed_out)) ? absint($photonic_lc_transition_speed_out) : 250,
1337 - 'lc_disable_shrink' => empty($photonic_lc_enable_shrink),
1338 -
1339 - 'lg_transition_effect' => empty($photonic_lg_transition_effect) ? 'lg-slide' : $photonic_lg_transition_effect,
1340 - 'lg_enable_download' => empty($photonic_disable_lg_download),
1341 - 'lg_hide_bars_delay' => (isset($photonic_lg_hide_bars_delay) && absint($photonic_lg_hide_bars_delay)) ? absint($photonic_lg_hide_bars_delay) : 6000,
1342 - 'lg_transition_speed' => (isset($photonic_lg_transition_speed) && absint($photonic_lg_transition_speed)) ? absint($photonic_lg_transition_speed) : 600,
1343 -
1344 - 'pphoto_theme' => isset($photonic_pphoto_theme) ? $photonic_pphoto_theme : 'pp_default',
1345 - 'pphoto_animation_speed' => empty($photonic_pp_animation_speed) ? 'fast' : $photonic_pp_animation_speed,
1346 -
1347 - 'enable_swipebox_mobile_bars' => !empty($photonic_enable_swipebox_mobile_bars),
1348 - 'sb_hide_mobile_close' => !empty($photonic_sb_hide_mobile_close),
1349 - 'sb_hide_bars_delay' => (isset($photonic_sb_hide_bars_delay) && absint($photonic_sb_hide_bars_delay)) ? absint($photonic_sb_hide_bars_delay) : 0,
1350 -
1351 - 'lightbox_for_all' => !empty($photonic_lightbox_for_all),
1352 - 'lightbox_for_videos' => !empty($photonic_lightbox_for_videos),
1353 -
1354 - 'slideshow_autostart' => !(isset($photonic_slideshow_prevent_autostart) && $photonic_slideshow_prevent_autostart == 'on'),
1355 -
1356 - 'password_failed' => esc_attr__('This album is password-protected. Please provide a valid password.', 'photonic'),
1357 - 'incorrect_password' => esc_attr__('Incorrect password.', 'photonic'),
1358 - 'maximize_panel' => esc_attr__('Show', 'photonic'),
1359 - 'minimize_panel' => esc_attr__('Hide', 'photonic'),
1360 - );
1361 - $photonic_js_variables = $js_array;
1362 - return $js_array;
1363 - }
1364 -
1365 - function enable_translations() {
1366 - load_plugin_textdomain('photonic', FALSE, FALSE);
1367 - }
1368 -
1369 - /**
1370 - * Checks authentication status for a provider, by verifying both, server-side and client-side authentication.
1371 - *
1372 - * @param $allow_auth
1373 - * @param $provider
1374 - * @param $gallery Photonic_OAuth1_Processor|Photonic_OAuth2_Processor
1375 - * @param $oauth_done
1376 - */
1377 - function check_provider_authentication($allow_auth, $provider, &$gallery, &$oauth_done) {
1378 - $this->initialize_extension($provider);
1379 - $cookie = Photonic::parse_cookie();
1380 - if ($allow_auth && isset($cookie[$provider]) && isset($cookie[$provider]['oauth_token']) && isset($cookie[$provider]['oauth_token_secret'])) {
1381 - $current_token = array(
1382 - 'oauth_token' => $cookie[$provider]['oauth_token'],
1383 - 'oauth_token_secret' => $cookie[$provider]['oauth_token_secret'],
1384 - );
1385 - if (isset($_REQUEST['oauth_verifier']) && isset($_REQUEST['oauth_token'])) {
1386 - $current_token['oauth_token'] = $_REQUEST['oauth_token'];
1387 - $current_token['oauth_verifier'] = $_REQUEST['oauth_verifier'];
1388 - $new_token = $gallery->get_access_token($current_token);
1389 - if (isset($new_token['oauth_token']) && isset($new_token['oauth_token_secret'])) {
1390 - // Strip out the token and the verifier from the callback URL and send the user to the callback URL.
1391 - $oauth_done = true;
1392 - $redirect = remove_query_arg(array('oauth_token', 'oauth_verifier'));
1393 - wp_redirect($redirect);
1394 - exit;
1395 - }
1396 - }
1397 - else if (isset($cookie[$provider]['oauth_token_type']) && $cookie[$provider]['oauth_token_type'] == 'access') {
1398 - $access_token_response = $gallery->check_access_token($current_token);
1399 - if (is_wp_error($access_token_response)) {
1400 - $gallery->is_server_down = true;
1401 - }
1402 - $oauth_done = $gallery->is_access_token_valid($access_token_response);
1403 - }
1404 - }
1405 - else if (!empty($gallery->token) && !empty($gallery->token_secret)) {
1406 - $token = array('oauth_token' => $gallery->token, 'oauth_token_secret' => $gallery->token_secret);
1407 - $access_token_response = $gallery->check_access_token($token);
1408 - if (is_wp_error($access_token_response)) {
1409 - $gallery->is_server_down = true;
1410 - }
1411 - $oauth_done = $gallery->is_access_token_valid($access_token_response);
1412 - }
1413 - }
1414 -
1415 - /**
1416 - * @param $cookie
1417 - * @return void
1418 - */
1419 - public function check_authentication_smug($cookie = null) {
1420 - if ($cookie == null) {
1421 - $cookie = Photonic::parse_cookie();
1422 - }
1423 -
1424 - global $photonic_smugmug_gallery, $photonic_smug_allow_oauth, $photonic_smug_oauth_done;
1425 - $photonic_smugmug_gallery = $this->initialize_extension('smugmug');
1426 - if ($photonic_smug_allow_oauth && isset($cookie['smug']) && isset($cookie['smug']['oauth_token']) && isset($cookie['smug']['oauth_token_secret'])) {
1427 - $current_token = array(
1428 - 'oauth_token' => $cookie['smug']['oauth_token'],
1429 - 'oauth_token_secret' => $cookie['smug']['oauth_token_secret']
1430 - );
1431 -
1432 - if (!$photonic_smug_oauth_done &&
1433 - ((isset($cookie['smug']['oauth_token_type']) && $cookie['smug']['oauth_token_type'] == 'request') || !isset($cookie['smug']['oauth_token_type']))) {
1434 - $current_token['oauth_verifier'] = $_REQUEST['oauth_verifier'];
1435 - $new_token = $photonic_smugmug_gallery->get_access_token($current_token);
1436 - if (isset($new_token['oauth_token']) && isset($new_token['oauth_token_secret'])) {
1437 - $access_token_response = $photonic_smugmug_gallery->check_access_token($new_token);
1438 - if (is_wp_error($access_token_response)) {
1439 - $photonic_smugmug_gallery->is_server_down = true;
1440 - }
1441 - $photonic_smug_oauth_done = $photonic_smugmug_gallery->is_access_token_valid($access_token_response);
1442 - }
1443 - }
1444 - else if (isset($cookie['smug']['oauth_token_type']) && $cookie['smug']['oauth_token_type'] == 'access') {
1445 - $access_token_response = $photonic_smugmug_gallery->check_access_token($current_token);
1446 - if (is_wp_error($access_token_response)) {
1447 - $photonic_smugmug_gallery->is_server_down = true;
1448 - }
1449 - $photonic_smug_oauth_done = $photonic_smugmug_gallery->is_access_token_valid($access_token_response);
1450 - }
1451 - }
1452 - else if (!empty($photonic_smugmug_gallery->token) && !empty($photonic_smugmug_gallery->token_secret)) {
1453 - $token = array('oauth_token' => $photonic_smugmug_gallery->token, 'oauth_token_secret' => $photonic_smugmug_gallery->token_secret);
1454 - $access_token_response = $photonic_smugmug_gallery->check_access_token($token);
1455 - if (is_wp_error($access_token_response)) {
1456 - $photonic_smugmug_gallery->is_server_down = true;
1457 - }
1458 - $photonic_smug_oauth_done = $photonic_smugmug_gallery->is_access_token_valid($access_token_response);
1459 - }
1460 - }
1461 -
1462 - function load_more() {
1463 - $provider = esc_attr($_POST['provider']);
1464 - $query = sanitize_text_field($_POST['query']);
1465 - $attr = wp_parse_args($query);
1466 -
1467 - $gallery = $this->initialize_extension($provider);
1468 - if ($provider == 'flickr') {
1469 - $attr['page'] = isset($attr['page']) ? $attr['page'] + 1 : 0;
1470 - }
1471 - else if ($provider == 'google') {
1472 - }
1473 - else if ($provider == 'smug') {
1474 - $attr['start'] = $attr['start'] + $attr['count'];
1475 - }
1476 - else if ($provider == 'zenfolio') {
1477 - $attr['offset'] = $attr['offset'] + $attr['limit'];
1478 - }
1479 - else if ($provider == 'instagram') {
1480 - }
1481 - else if ($provider == 'wp') {
1482 - $attr['page'] = $attr['page'] + 1;
1483 - }
1484 -
1485 - if (!is_null($gallery)) {
1486 - echo $gallery->get_gallery_images($attr);
1487 - }
1488 - die();
1489 - }
1490 -
1491 - function helper_shortcode_more() {
1492 - if (!empty($_POST['provider'])) {
1493 - $provider = sanitize_text_field($_POST['provider']);
1494 - if (in_array($provider, array('google'))) {
1495 - $gallery = $this->initialize_extension($provider);
1496 - if ($provider == 'google') {
1497 - echo $gallery->execute_helper(array('nextPageToken' => sanitize_text_field($_POST['nextPageToken'])));
1498 - }
1499 - }
1500 - }
1501 - die();
1502 - }
1503 -
1504 - static function title_caption_options($blank = false, $selection = false) {
1505 - $ret = array(
1506 - '' => esc_html__('Default from settings', 'photonic'),
1507 - 'none' => esc_html__('No title / caption / description', 'photonic'),
1508 - 'title' => esc_html__('Always use the photo title, even if blank', 'photonic'),
1509 - 'desc' => esc_html__('Always use the photo description / caption, even if blank', 'photonic'),
1510 - 'desc-title' => esc_html__('Use the photo description / caption. If blank use the title', 'photonic'),
1511 - 'title-desc' => esc_html__('Use the photo title. If blank use the description / caption', 'photonic'),
1512 - );
1513 -
1514 - if (!$blank) {
1515 - unset($ret['']);
1516 - }
1517 - else if (!empty($ret[$selection])) {
1518 - $ret[''] .= ' - '.$ret[$selection];
1519 - }
1520 -
1521 - return $ret;
1522 - }
1523 -
1524 - static function layout_options($show_blank = false) {
1525 - $ret = array();
1526 - if ($show_blank) {
1527 - $ret[''] = '';
1528 - }
1529 - return array_merge($ret, array(
1530 - 'strip-below' => esc_html__('Thumbnail strip below slideshow', 'photonic'),
1531 - 'strip-above' => esc_html__('Thumbnail strip above slideshow', 'photonic'),
1532 - 'strip-right' => esc_html__('Thumbnail strip to the right of the slideshow', 'photonic'),
1533 - 'no-strip' => esc_html__('Slideshow without thumbnails', 'photonic'),
1534 - 'square' => esc_html__('Square thumbnail grid, lightbox', 'photonic'),
1535 - 'circle' => esc_html__('Circular thumbnail grid, lightbox', 'photonic'),
1536 - 'random' => esc_html__('Random justified gallery, lightbox', 'photonic'),
1537 - 'masonry' => esc_html__('Masonry layout, lightbox', 'photonic'),
1538 - 'mosaic' => esc_html__('Mosaic layout, lightbox', 'photonic'),
1539 - ));
1540 - }
1541 -
1542 - static function media_options($blank = false, $selection = false) {
1543 - $options = array(
1544 - '' => esc_html__('Default from settings', 'photonic'),
1545 - 'photos' => esc_html__('Photos only', 'photonic'),
1546 - 'videos' => esc_html__('Videos only', 'photonic'),
1547 - 'all' => esc_html__('Both photos and videos', 'photonic'),
1548 - );
1549 -
1550 - if (!$blank) {
1551 - unset($options['']);
1552 - }
1553 - else if (!empty($options[$selection])) {
1554 - $options[''] .= ' - '.$options[$selection];
1555 - }
1556 -
1557 - return $options;
1558 - }
1559 -
1560 - function admin_head() {
1561 - // check user permissions
1562 - if (!current_user_can('edit_posts') && !current_user_can('edit_pages')) {
1563 - return;
1564 - }
1565 -
1566 - global $photonic_disable_editor, $photonic_disable_editor_post_type;
1567 - $disabled_types = explode(',', $photonic_disable_editor_post_type);
1568 - $post_type = empty($_REQUEST['post_type']) ? 'post' : $_REQUEST['post_type'];
1569 - // check if WYSIWYG is enabled
1570 - if ('true' == get_user_option('rich_editing') && empty($photonic_disable_editor) && !in_array($post_type, $disabled_types)) {
1571 - $this->prepare_mce_data();
1572 - add_filter('mce_external_plugins', array($this ,'mce_photonic'), 5);
1573 - add_filter('mce_buttons', array($this ,'mce_flow_button'), 5);
1574 - }
1575 - }
1576 -
1577 - function prepare_mce_data() {
1578 - global $photonic_alternative_shortcode, $photonic_disable_flow_editor;
1579 - $url = add_query_arg( array(
1580 - 'action' => 'photonic_flow',
1581 - 'class' => 'photonic-flow',
1582 - 'post_id' => empty($_REQUEST['post']) ? '' : $_REQUEST['post'],
1583 - 'width' => '1000',
1584 - 'height' => '600',
1585 - 'TB_iframe' => 'true',
1586 - ), admin_url( 'admin.php' ) );
1587 - $js_array = array(
1588 - 'flow_url' => $url,
1589 - 'ajaxurl' => admin_url('admin-ajax.php'),
1590 - 'shortcode' => empty($photonic_alternative_shortcode) ? 'gallery' : $photonic_alternative_shortcode,
1591 - 'disable_flow' => !empty($photonic_disable_flow_editor),
1592 - 'default_gallery_type' => 'default',
1593 - 'plugin_dir' => plugin_dir_url(__FILE__),
1594 - );
1595 - wp_enqueue_script('photonic-admin-js', plugins_url('include/scripts/admin/gallery-settings.js', __FILE__), array('jquery', 'media-views', 'media-upload'), $this->get_version(plugin_dir_path(__FILE__).'include/scripts/admin/gallery-settings.js'));
1596 - wp_localize_script('photonic-admin-js', 'Photonic_Admin_JS', $js_array);
1597 - }
1598 -
1599 - function mce_photonic($plugin_array) {
1600 - $plugin_array['photonic'] = plugins_url('include/scripts/admin/mce.js?'.$this->get_version(plugin_dir_path(__FILE__).'include/scripts/admin/mce.js') , __FILE__);
1601 - return $plugin_array;
1602 - }
1603 -
1604 - function mce_flow_button($buttons) {
1605 - array_push($buttons, 'photonic_flow');
1606 - return $buttons;
1607 - }
1608 -
1609 - /**
1610 - * @param string|array $classes
1611 - * @param string $class
1612 - * @return array
1613 - */
1614 - function body_class($classes = array(), $class = '') {
1615 - if (!is_array($classes)) {
1616 - $classes = explode(' ', $classes);
1617 - }
1618 - global $photonic_is_IE;
1619 - if ($photonic_is_IE) {
1620 - $classes[] = 'photonic-ie';
1621 - }
1622 -
1623 - return $classes;
1624 - }
1625 -
1626 - function add_photonic_button() {
1627 - add_thickbox();
1628 - $url = add_query_arg( array(
1629 - 'action' => 'photonic_flow',
1630 - 'class' => 'photonic-flow',
1631 - 'post_id' => empty($_REQUEST['post']) ? '' : $_REQUEST['post'],
1632 - 'width' => '1000',
1633 - 'height' => '600',
1634 - 'TB_iframe' => 'true',
1635 - ), admin_url( 'admin.php' ) );
1636 -
1637 - printf('<a href="%s" class="button photonic-button thickbox" id="photonic-add-gallery" title="Photonic Gallery"><img class="wp-media-buttons-icon" src="'.plugins_url('include/images/Photonic-20.png', __FILE__).'"/> %s</a>',
1638 - $url, esc_html__( 'Add / Edit Photonic Gallery', 'photonic'));
1639 - }
1640 -
1641 - function insertion_flow() {
1642 - define( 'IFRAME_REQUEST', true );
1643 - $this->enqueue_flow_scripts();
1644 - iframe_header(esc_html__('Add / Edit Photonic Gallery', 'photonic'));
1645 - require_once(plugin_dir_path(__FILE__).'/admin/flow/Flow.php');
1646 - iframe_footer();
1647 - exit;
1648 - }
1649 -
1650 - function enqueue_flow_scripts() {
1651 - global $photonic_alternative_shortcode;
1652 - $flow_js = array(
1653 - 'ajaxurl' => admin_url('admin-ajax.php'),
1654 - 'shortcode' => empty($photonic_alternative_shortcode) ? 'gallery' : $photonic_alternative_shortcode,
1655 - 'insert_gallery' => esc_html__('Insert Gallery', 'photonic'),
1656 - 'update_gallery' => esc_html__('Update Gallery', 'photonic'),
1657 - 'error_mandatory' => esc_html__('Please fill the mandatory fields. Mandatory fields are marked with a red "*".', 'photonic'),
1658 - 'media_library_title' => esc_html__('Select from WordPress Media Library', 'photonic'),
1659 - 'media_library_button' => esc_html__('Select', 'photonic'),
1660 - 'info_editor_not_shortcode' => esc_html__('The text selected in the editor is not a Photonic shortcode. Creating a new shortcode.', 'photonic'),
1661 - 'info_editor_block_select' => sprintf(esc_html__('%1$sHint:%2$s To edit an existing Photonic block simply click on the block.', 'photonic'), '<strong>', '</strong>'),
1662 - );
1663 - if (!empty($_REQUEST['shortcode'])) {
1664 - $flow_js['shortcode'] = $_REQUEST['shortcode'];
1665 - }
1666 - wp_enqueue_style('photonic-flow', plugins_url('include/css/admin-flow.css', __FILE__), array(), $this->get_version(plugin_dir_path(__FILE__).'include/css/admin-flow.css'));
1667 - wp_enqueue_script('photonic-flow-js', plugins_url('include/scripts/admin/flow.js', __FILE__), array('jquery'), $this->get_version(plugin_dir_path(__FILE__).'include/scripts/admin/flow.js'));
1668 - wp_localize_script('photonic-flow-js', 'Photonic_Flow_JS', $flow_js);
1669 - }
1670 -
1671 - function flow_next_screen() {
1672 - require_once(plugin_dir_path(__FILE__)."/admin/flow/Photonic_Flow_Manager.php");
1673 - if (isset($_POST['provider'])) {
1674 - $flow_manager = new Photonic_Flow_Manager();
1675 - echo $flow_manager->get_screen();
1676 - }
1677 - die();
1678 - }
1679 -
1680 - function flow_more() {
1681 - require_once(plugin_dir_path(__FILE__)."/admin/flow/Photonic_Flow_Manager.php");
1682 - if (isset($_POST['url']) && isset($_POST['provider']) && isset($_POST['display_type'])) {
1683 - $url = base64_decode(sanitize_text_field($_POST['url']));
1684 -
1685 - $provider = sanitize_text_field($_POST['provider']);
1686 - $display_type = sanitize_text_field($_POST['display_type']);
1687 -
1688 - $response = wp_remote_request($url, array('sslverify' => PHOTONIC_SSL_VERIFY));
1689 -
1690 - $flow_manager = new Photonic_Flow_Manager();
1691 - $objects = $flow_manager->process_response($response, $provider, $display_type, array(), array(), $url, true);
1692 -
1693 - if (!empty($objects['success'])) {
1694 - echo $objects['success'];
1695 - }
1696 - else if (!empty($objects['error'])) {
1697 - echo $objects['error'];
1698 - }
1699 - }
1700 - die();
1701 - }
1702 -
1703 - public static function get_formatted_post_type_array() {
1704 - global $photonic_post_type_array;
1705 - $ret = array();
1706 -
1707 - $post_types = get_post_types(array('show_ui' => 1), 'objects');
1708 - if (!empty($post_types)) {
1709 - foreach ($post_types as $name => $post_type) {
1710 - $ret[$name] = array ("title" => $post_type->label." (Post type: $name)", "depth" => 0);
1711 - }
1712 - }
1713 -
1714 - $photonic_post_type_array = $ret;
1715 - return $ret;
1716 - }
1717 -
1718 - /**
1719 - * Used for handling the front-end for Gutenberg blocks
1720 - *
1721 - * @param $attributes
1722 - * @return array|bool|string
1723 - */
1724 - function render_block($attributes) {
1725 - if (!empty($attributes['shortcode'])) {
1726 - $shortcode = (array)(json_decode($attributes['shortcode']));
1727 -
1728 - if (!empty($attributes['align'])) {
1729 - $shortcode['alignment'] = $attributes['align'];
1730 - }
1731 - if (!empty($attributes['className'])) {
1732 - $shortcode['custom_classes'] = $attributes['className'];
1733 - }
1734 -
1735 - return $this->get_gallery_images($shortcode);
1736 - }
1737 - return '';
1738 - }
1739 -
1740 - function enqueue_gutenberg_assets() {
1741 - if (function_exists('register_block_type')) {
1742 - wp_enqueue_script('photonic-gutenberg',
1743 - plugins_url('include/scripts/admin/block.js', __FILE__),
1744 - array('jquery', 'wp-blocks', 'wp-i18n', 'wp-element', 'shortcode', 'thickbox'),
1745 - $this->get_version(plugin_dir_path(__FILE__).'include/scripts/admin/block.js')
1746 - );
1747 -
1748 - if (function_exists( 'gutenberg_get_jed_locale_data')) {
1749 - $locale = gutenberg_get_jed_locale_data('photonic');
1750 - $content = 'wp.i18n.setLocaleData('.json_encode($locale).', "photonic");';
1751 - wp_script_add_data( 'photonic-gutenberg', 'data', $content );
1752 - }
1753 -
1754 - global $photonic_alternative_shortcode;
1755 - $url = add_query_arg( array(
1756 - 'action' => 'photonic_flow',
1757 - 'class' => 'photonic-flow',
1758 - 'post_id' => empty($_REQUEST['post']) ? '' : $_REQUEST['post'],
1759 - 'width' => '1000',
1760 - 'height' => '600',
1761 - 'TB_iframe' => 'true',
1762 - ), admin_url( 'admin.php' ) );
1763 -
1764 - $js_array = array(
1765 - 'flow_url' => $url,
1766 - 'ajaxurl' => admin_url('admin-ajax.php'),
1767 - 'shortcode' => empty($photonic_alternative_shortcode) ? 'gallery' : $photonic_alternative_shortcode,
1768 - 'default_gallery_type' => 'default',
1769 - 'plugin_dir' => plugin_dir_url(__FILE__),
1770 - );
1771 - wp_localize_script('photonic-gutenberg', 'Photonic_Gutenberg_JS', $js_array);
1772 -
1773 - wp_enqueue_style('photonic-gutenberg',
1774 - plugins_url('include/css/admin-block.css', __FILE__),
1775 - array('thickbox'),
1776 - $this->get_version(plugin_dir_path(__FILE__).'include/css/admin-block.css')
1777 - );
1778 - }
1779 - }
1780 -
1781 - private function add_gutenberg_support() {
1782 - if (function_exists('register_block_type')) {
1783 - register_block_type('photonic/gallery',
1784 - array(
1785 - 'attributes' => array(
1786 - 'shortcode' => array(
1787 - 'type' => 'string',
1788 - ),
1789 - ),
1790 - 'render_callback' => array(&$this, 'render_block'),
1791 - )
1792 - );
1793 - }
1794 - }
1795 -
1796 - function admin_notices() {
1797 - if (!empty($_REQUEST['page']) && in_array($_REQUEST['page'], array('photonic-options-manager', 'photonic-getting-started', 'photonic-auth', 'photonic-helpers'))){
1798 - if (function_exists('register_block_type')) {
1799 - $dismissed = get_user_meta(get_current_user_id(), 'photonic_gutenberg');
1800 - if (!$dismissed) {
1801 - echo "<div class='notice notice-warning'>\n<p>\n";
1802 - echo sprintf(esc_html__('It looks like you are using the Gutenberg editor. Please ensure that you have followed the instructions under %s.', 'photonic'), '<em><a href="'.admin_url('admin.php?page=photonic-gutenberg').'">Photonic &rarr; Prepare for Gutenberg</a></em>');
1803 - echo "</p>\n";
1804 - echo "<button type='button' data-photonic-dismissible='gutenberg' class='photonic-notice-dismiss'><span class='screen-reader-text'>Dismiss this notice.</span></button>";
1805 - echo "</div>\n";
1806 - }
1807 - }
1808 - }
1809 - }
1810 -
1811 - function dismiss_warning() {
1812 - $user_id = get_current_user_id();
1813 - $response = array();
1814 - if (!empty($_POST['dismissible'])) {
1815 - add_user_meta( $user_id, "photonic_".esc_sql($_POST['dismissible']), 'true', true );
1816 - $response[$_POST['dismissible']] = 'true';
1817 - }
1818 - echo json_encode($response);
1819 - die();
1820 - }
1821 -
1822 - function curl_timeout($handle) {
1823 - curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, PHOTONIC_CURL_TIMEOUT);
1824 - curl_setopt($handle, CURLOPT_TIMEOUT, PHOTONIC_CURL_TIMEOUT);
1825 - }
1826 -
1827 - static function log($element) {
1828 - if (PHOTONIC_DEBUG) {
1829 - print_r($element);
1830 - }
1831 - }
1832 -
1833 - static function doc_link($link) {
1834 - return ' '.sprintf(esc_html__('See %1$shere%2$s for documentation.', 'photonic'), "<a href='$link'>", '</a>');
1835 - }
1836 -}
1837 -
1838 -add_action('init', 'photonic_init', 100); // Delaying the start from 10 to 100 so that CPTs can be picked up
1839 -
55 +/**
56 + * Main plugin initiation
57 + */
1840 58 function photonic_init() {
1841 59 global $photonic;
1842 60 $photonic = new Photonic();
61 +}
62 +
63 +/**
64 + * Loads up the utilities file
65 + */
66 +function photonic_utilities_init() {
67 + require_once PHOTONIC_PATH . '/Core/Utilities.php';
1843 68 }