PluginProbe ʕ •ᴥ•ʔ
Gallery : FooGallery / 3.2.6
Gallery : FooGallery v3.2.6
3.3.0 3.1.31 3.1.32 3.1.34 3.1.36 3.2.0 3.2.6 trunk 1.10.3 2.0.24 2.1.34 2.2.44 2.3.3 2.4.32 3.0.6 3.1.11 3.1.12 3.1.13 3.1.20 3.1.25 3.1.26 3.1.26.1 3.1.26.2
foogallery / foogallery.php
foogallery Last commit date
assets 3 weeks ago css 3 weeks ago extensions 3 weeks ago freemius 3 weeks ago gutenberg 3 weeks ago includes 3 weeks ago js 3 weeks ago languages 3 weeks ago lib 3 weeks ago templates 3 weeks ago views 3 weeks ago LICENSE.txt 3 weeks ago README.txt 1 week ago changelog.txt 3 weeks ago foogallery.php 3 weeks ago index.html 3 weeks ago wpml-config.xml 3 weeks ago
foogallery.php
456 lines
1 <?php
2
3 /*
4 Plugin Name: FooGallery
5 Description: FooGallery is the most intuitive and extensible gallery management tool ever created for WordPress
6 Version: 3.2.6
7 Author: FooPlugins
8 Plugin URI: https://fooplugins.com/foogallery-wordpress-gallery-plugin/
9 Author URI: https://fooplugins.com
10 Text Domain: foogallery
11 License: GPL-2.0+
12 Domain Path: /languages
13 Requires at least: 5.3
14 Requires PHP: 7.0
15 */
16 // If this file is called directly, abort.
17 if ( !defined( 'WPINC' ) ) {
18 die;
19 }
20 if ( function_exists( 'foogallery_fs' ) ) {
21 foogallery_fs()->set_basename( false, __FILE__ );
22 } else {
23 if ( !class_exists( 'FooGallery_Plugin' ) ) {
24 define( 'FOOGALLERY_SLUG', 'foogallery' );
25 define( 'FOOGALLERY_PATH', plugin_dir_path( __FILE__ ) );
26 define( 'FOOGALLERY_URL', plugin_dir_url( __FILE__ ) );
27 define( 'FOOGALLERY_FILE', __FILE__ );
28 define( 'FOOGALLERY_VERSION', '3.2.6' );
29 define( 'FOOGALLERY_SETTINGS_VERSION', '2' );
30 if ( file_exists( FOOGALLERY_PATH . 'vendor-scoped/scoper-autoload.php' ) ) {
31 require_once FOOGALLERY_PATH . 'vendor-scoped/scoper-autoload.php';
32 } elseif ( file_exists( FOOGALLERY_PATH . 'vendor-scoped/autoload.php' ) ) {
33 require_once FOOGALLERY_PATH . 'vendor-scoped/autoload.php';
34 }
35 require_once FOOGALLERY_PATH . 'includes/constants.php';
36 require_once FOOGALLERY_PATH . 'includes/functions.php';
37 // Create a helper function for easy SDK access.
38 function foogallery_fs() {
39 global $foogallery_fs;
40 if ( !isset( $foogallery_fs ) ) {
41 // Include Freemius SDK.
42 require_once dirname( __FILE__ ) . '/freemius/start.php';
43 $foogallery_fs = fs_dynamic_init( array(
44 'id' => '843',
45 'slug' => 'foogallery',
46 'type' => 'plugin',
47 'public_key' => 'pk_d87616455a835af1d0658699d0192',
48 'anonymous_mode' => foogallery_freemius_is_anonymous(),
49 'is_premium' => false,
50 'has_paid_plans' => true,
51 'has_addons' => true,
52 'has_affiliation' => 'selected',
53 'trial' => array(
54 'days' => 7,
55 'is_require_payment' => false,
56 ),
57 'menu' => array(
58 'slug' => 'edit.php?post_type=' . FOOGALLERY_CPT_GALLERY,
59 'first-path' => 'edit.php?post_type=' . FOOGALLERY_CPT_GALLERY . '&page=' . FOOGALLERY_ADMIN_MENU_HELP_SLUG,
60 'account' => true,
61 'contact' => false,
62 'support' => false,
63 ),
64 'is_live' => true,
65 'is_org_compliant' => true,
66 ) );
67 }
68 return $foogallery_fs;
69 }
70
71 // Init Freemius.
72 foogallery_fs();
73 // Signal that SDK was initiated.
74 do_action( 'foogallery_fs_loaded' );
75 require_once FOOGALLERY_PATH . 'includes/foopluginbase/bootstrapper.php';
76 /**
77 * FooGallery_Plugin class
78 *
79 * @package FooGallery
80 * @author Brad Vincent <brad@fooplugins.com>
81 * @license GPL-2.0+
82 * @link https://github.com/fooplugins/foogallery
83 * @copyright 2013 FooPlugins LLC
84 */
85 class FooGallery_Plugin extends Foo_Plugin_Base_v2_4 {
86 private static $instance;
87
88 public static function get_instance() {
89 if ( !isset( self::$instance ) && !self::$instance instanceof FooGallery_Plugin ) {
90 self::$instance = new FooGallery_Plugin();
91 }
92 return self::$instance;
93 }
94
95 /**
96 * Initialize the plugin by setting localization, filters, and administration functions.
97 */
98 private function __construct() {
99 // include everything we need!
100 require_once FOOGALLERY_PATH . 'includes/includes.php';
101 register_activation_hook( __FILE__, array('FooGallery_Plugin', 'activate') );
102 FooGallery_License_Constant_Handler::init();
103 // init FooPluginBase.
104 $this->init(
105 FOOGALLERY_FILE,
106 FOOGALLERY_SLUG,
107 FOOGALLERY_VERSION,
108 'FooGallery'
109 );
110 add_filter( 'foogallery_default_options', 'foogallery_get_default_options' );
111 // load text domain.
112 add_action( 'init', array($this, 'load_plugin_textdomain') );
113 // setup gallery post type.
114 new FooGallery_PostTypes();
115 // load any extensions.
116 new FooGallery_Extensions_Loader();
117 // Load any bundled extension initializers.
118 new FooGallery_Import_Export_Extension();
119 if ( is_admin() ) {
120 new FooGallery_Admin();
121 add_action( 'wpmu_new_blog', array($this, 'set_default_extensions_for_multisite_network_activated') );
122 foogallery_fs()->add_filter(
123 'plugin_icon',
124 array($this, 'freemius_plugin_icon'),
125 10,
126 1
127 );
128 foogallery_fs()->add_filter( 'pricing/show_annual_in_monthly', '__return_false' );
129 foogallery_fs()->add_filter( 'show_affiliate_program_notice', '__return_false' );
130 add_action( 'foogallery_admin_menu_before', array($this, 'add_freemius_activation_menu') );
131 } else {
132 new FooGallery_Public();
133 }
134 // handles previews. Needed on both frontend and backend.
135 new FooGallery_Previews();
136 // initialize the thumbnail manager.
137 new FooGallery_Thumb_Manager();
138 new FooGallery_Shortcodes();
139 new FooGallery_Thumbnails();
140 new FooGallery_Attachment_Filters();
141 new FooGallery_Retina();
142 new FooGallery_Animated_Gif_Support();
143 new FooGallery_Cache();
144 new FooGallery_Lightbox();
145 new FooGallery_Common_Fields();
146 new FooGallery_LazyLoad();
147 new FooGallery_Paging();
148 new FooGallery_Thumbnail_Dimensions();
149 new FooGallery_Attachment_Filename();
150 new FooGallery_Attachment_Custom_Class();
151 new FooGallery_Compatibility();
152 new FooGallery_Extensions_Compatibility();
153 new FooGallery_Crop_Position();
154 new FooGallery_ForceHttps();
155 new FooGallery_Debug();
156 new FooGallery_Password_Protect();
157 $checker = new FooGallery_Version_Check();
158 $checker->wire_up_checker();
159 new FooGallery_Widget_Init();
160 // include the default templates no matter what!
161 new FooGallery_Default_Templates();
162 // init the default media library datasource.
163 new FooGallery_Datasource_MediaLibrary();
164 // Initialize the FooGallery abilities bridge for WordPress core.
165 new FooGallery_Abilities();
166 new FooGallery_Attachment_Type();
167 $pro_code_included = false;
168 if ( !$pro_code_included ) {
169 add_filter( 'foogallery_extensions_for_view', array($this, 'add_foogallery_pro_features') );
170 }
171 add_filter( 'foogallery_extensions_for_view', array($this, 'add_foogallery_addon_features'), 20 );
172 // init Gutenberg!
173 new FooGallery_Gutenberg();
174 // init advanced settings.
175 new FooGallery_Advanced_Gallery_Settings();
176 // init localization for FooGallery.
177 new FooGallery_il8n();
178 }
179
180 function add_foogallery_pro_features( $extensions ) {
181 $pro_features = foogallery_pro_features();
182 $extensions[] = array(
183 'slug' => 'foogallery-bulk-copy',
184 'categories' => array('Premium'),
185 'title' => foogallery__( 'Bulk Copy', 'foogallery' ),
186 'description' => $pro_features['bulk_copy']['desc'],
187 'external_link_text' => foogallery__( 'Read documentation', 'foogallery' ),
188 'external_link_url' => $pro_features['bulk_copy']['link'],
189 'dashicon' => 'dashicons-admin-page',
190 'tags' => array('Premium'),
191 'source' => 'upgrade',
192 );
193 $extensions[] = array(
194 'slug' => 'foogallery-whitelabeling',
195 'categories' => array('Premium'),
196 'title' => foogallery__( 'White Labeling', 'foogallery' ),
197 'description' => $pro_features['whitelabeling']['desc'],
198 'external_link_text' => foogallery__( 'Read documentation', 'foogallery' ),
199 'external_link_url' => $pro_features['whitelabeling']['link'],
200 'dashicon' => 'dashicons-tag',
201 'tags' => array('Premium'),
202 'source' => 'upgrade',
203 );
204 $extensions[] = array(
205 'slug' => 'foogallery-exif',
206 'categories' => array('Premium'),
207 'title' => foogallery__( 'EXIF', 'foogallery' ),
208 'description' => $pro_features['exif']['desc'],
209 'external_link_text' => foogallery__( 'Read documentation', 'foogallery' ),
210 'external_link_url' => $pro_features['exif']['link'],
211 'dashicon' => 'dashicons-camera',
212 'tags' => array('Premium'),
213 'source' => 'upgrade',
214 );
215 $extensions[] = array(
216 'slug' => 'foogallery-filtering',
217 'categories' => array('Premium'),
218 'title' => foogallery__( 'Filtering', 'foogallery' ),
219 'description' => $pro_features['filtering']['desc'],
220 'external_link_text' => foogallery__( 'Read documentation', 'foogallery' ),
221 'external_link_url' => $pro_features['filtering']['link'],
222 'dashicon' => 'dashicons-filter',
223 'tags' => array('Premium'),
224 'source' => 'upgrade',
225 );
226 $extensions[] = array(
227 'slug' => 'foogallery-gallery-blueprints',
228 'categories' => array('Premium'),
229 'title' => foogallery__( 'Gallery Blueprints', 'foogallery' ),
230 'description' => $pro_features['gallery_blueprints']['desc'],
231 'external_link_text' => foogallery__( 'Read documentation', 'foogallery' ),
232 'external_link_url' => $pro_features['gallery_blueprints']['link'],
233 'dashicon' => 'dashicons-networking',
234 'tags' => array('Premium'),
235 'source' => 'upgrade',
236 );
237 $extensions[] = array(
238 'slug' => 'foogallery-paging',
239 'categories' => array('Premium'),
240 'title' => foogallery__( 'Pagination', 'foogallery' ),
241 'description' => $pro_features['pagination']['desc'],
242 'external_link_text' => foogallery__( 'Read documentation', 'foogallery' ),
243 'external_link_url' => $pro_features['pagination']['link'],
244 'dashicon' => 'dashicons-arrow-right-alt',
245 'tags' => array('Premium'),
246 'source' => 'upgrade',
247 );
248 $extensions[] = array(
249 'slug' => 'foogallery-protection',
250 'categories' => array('Premium'),
251 'title' => foogallery__( 'Watermarking & Protection', 'foogallery' ),
252 'description' => $pro_features['protection']['desc'],
253 'external_link_text' => foogallery__( 'Read documentation', 'foogallery' ),
254 'external_link_url' => $pro_features['protection']['link'],
255 'dashicon' => 'dashicons-lock',
256 'tags' => array('Premium'),
257 'source' => 'upgrade',
258 );
259 $extensions[] = array(
260 'slug' => 'foogallery-video',
261 'categories' => array('Premium'),
262 'title' => foogallery__( 'Video', 'foogallery' ),
263 'description' => $pro_features['video']['desc'],
264 'external_link_text' => foogallery__( 'Read documentation', 'foogallery' ),
265 'external_link_url' => $pro_features['video']['link'],
266 'dashicon' => 'dashicons-video-alt3',
267 'tags' => array('Premium'),
268 'source' => 'upgrade',
269 );
270 $extensions[] = array(
271 'slug' => 'foogallery-woocommerce',
272 'categories' => array('Premium'),
273 'title' => foogallery__( 'Ecommerce', 'foogallery' ),
274 'description' => $pro_features['ecommerce']['desc'],
275 'external_link_text' => foogallery__( 'Read documentation', 'foogallery' ),
276 'external_link_url' => $pro_features['ecommerce']['link'],
277 'dashicon' => 'dashicons-cart',
278 'tags' => array('Premium'),
279 'source' => 'upgrade',
280 );
281 return $extensions;
282 }
283
284 function add_foogallery_addon_features( $extensions ) {
285 $addon_features = array(array(
286 'slug' => 'foogallery-user-uploads',
287 'categories' => array('Add-ons', 'Premium'),
288 'title' => foogallery__( 'User Uploads', 'foogallery' ),
289 'description' => foogallery__( 'Allow visitors to upload images and videos into galleries. Includes image moderation, form field customization, email notifications and more.', 'foogallery' ),
290 'external_link_text' => foogallery__( 'Learn More', 'foogallery' ),
291 'external_link_url' => 'https://fooplugins.com/foogallery-wordpress-gallery-plugin/user-uploads/',
292 'addon_link_url' => foogallery_fs()->addon_url( 'foogallery-user-uploads' ),
293 'dashicon' => 'dashicons-upload',
294 'tags' => array('Add-on', 'Premium'),
295 'source' => 'addon',
296 ), array(
297 'slug' => 'foogallery-social',
298 'categories' => array('Add-ons', 'Premium'),
299 'title' => foogallery__( 'Social', 'foogallery' ),
300 'description' => foogallery__( 'Allow your visitors to like, comment and share images to social networks.', 'foogallery' ),
301 'external_link_text' => foogallery__( 'Learn More', 'foogallery' ),
302 'external_link_url' => 'https://fooplugins.com/foogallery-wordpress-gallery-plugin/social/',
303 'addon_link_url' => foogallery_fs()->addon_url( 'foogallery-social' ),
304 'dashicon' => 'dashicons-share',
305 'tags' => array('Add-on', 'Premium'),
306 'source' => 'addon',
307 ), array(
308 'slug' => 'foogallery-proofing',
309 'categories' => array('Add-ons', 'Premium'),
310 'title' => foogallery__( 'Client Proofing', 'foogallery' ),
311 'description' => foogallery__( 'Create private proofing sessions so clients can select, reject, comment on, and submit gallery images for review.', 'foogallery' ),
312 'addon_link_url' => foogallery_fs()->addon_url( 'foogallery-proofing' ),
313 'external_link_url' => 'https://fooplugins.com/foogallery-wordpress-gallery-plugin/client-proofing/',
314 'dashicon' => 'dashicons-visibility',
315 'tags' => array('Add-on', 'Premium'),
316 'source' => 'addon',
317 ));
318 foreach ( $addon_features as $addon_feature ) {
319 if ( !$this->feature_exists_for_view( $extensions, $addon_feature['slug'] ) ) {
320 $extensions[] = $addon_feature;
321 }
322 }
323 return $extensions;
324 }
325
326 private function feature_exists_for_view( $extensions, $slug ) {
327 foreach ( $extensions as $extension ) {
328 if ( isset( $extension['slug'] ) && $slug === $extension['slug'] ) {
329 return true;
330 }
331 }
332 return false;
333 }
334
335 function add_freemius_activation_menu() {
336 if ( foogallery_freemius_is_anonymous() ) {
337 return;
338 }
339 global $foogallery_fs;
340 $parent_slug = foogallery_admin_menu_parent_slug();
341 if ( !$foogallery_fs->is_registered() ) {
342 add_submenu_page(
343 $parent_slug,
344 __( 'FooGallery Opt-In', 'foogallery' ),
345 __( 'Activation', 'foogallery' ),
346 'manage_options',
347 'foogallery-optin',
348 array($foogallery_fs, '_connect_page_render')
349 );
350 }
351 }
352
353 /**
354 * Set Freemius plugin icon.
355 *
356 * @return string
357 */
358 public function freemius_plugin_icon( $icon ) {
359 return FOOGALLERY_PATH . 'assets/foogallery.jpg';
360 }
361
362 /**
363 * Set default extensions when a new site is created in multisite and FooGallery is network activated
364 *
365 * @since 1.2.5
366 *
367 * @param int $blog_id The ID of the newly created site
368 */
369 public function set_default_extensions_for_multisite_network_activated( $blog_id ) {
370 switch_to_blog( $blog_id );
371 if ( false === get_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, false ) ) {
372 $api = new FooGallery_Extensions_API();
373 $api->auto_activate_extensions();
374 update_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, true );
375 }
376 restore_current_blog();
377 }
378
379 /**
380 * Fired when the plugin is activated.
381 *
382 * @since 1.0.0
383 *
384 * @param boolean $network_wide True if WPMU superadmin uses
385 * "Network Activate" action, false if
386 * WPMU is disabled or plugin is
387 * activated on an individual blog.
388 */
389 public static function activate( $network_wide ) {
390 FooGallery_License_Constant_Handler::flag_activation();
391 if ( function_exists( 'is_multisite' ) && is_multisite() ) {
392 if ( $network_wide ) {
393 // Get all blog ids
394 $blog_ids = self::get_blog_ids();
395 if ( is_array( $blog_ids ) ) {
396 foreach ( $blog_ids as $blog_id ) {
397 switch_to_blog( $blog_id );
398 self::single_activate();
399 }
400 restore_current_blog();
401 }
402 } else {
403 self::single_activate();
404 }
405 } else {
406 self::single_activate( false );
407 }
408 }
409
410 /**
411 * Fired for each blog when the plugin is activated.
412 *
413 * @since 1.0.0
414 */
415 private static function single_activate( $multisite = true ) {
416 if ( false === get_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, false ) ) {
417 $api = new FooGallery_Extensions_API();
418 $api->auto_activate_extensions();
419 update_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, true );
420 }
421 if ( false === $multisite ) {
422 // Make sure we redirect to the welcome page
423 set_transient( FOOGALLERY_ACTIVATION_REDIRECT_TRANSIENT_KEY, true, 30 );
424 }
425 // Set the 'advanced_attachment_modal' setting to 'on'
426 if ( !foogallery_get_setting( 'advanced_attachment_modal' ) ) {
427 foogallery_set_setting( 'advanced_attachment_modal', 'on' );
428 }
429 // Force a version check on activation to make sure housekeeping is performed
430 foogallery_perform_version_check();
431 }
432
433 /**
434 * Get all blog ids of blogs in the current network that are:
435 * - not archived
436 * - not spam
437 * - not deleted
438 *
439 * @since 1.0.0
440 *
441 * @return array The blog IDs.
442 */
443 private static function get_blog_ids() {
444 $sites = get_sites();
445 $blog_ids = array();
446 foreach ( $sites as $site ) {
447 $blog_ids[] = $site->blog_id;
448 }
449 return $blog_ids;
450 }
451
452 }
453
454 }
455 FooGallery_Plugin::get_instance();
456 }