PluginProbe ʕ •ᴥ•ʔ
Gallery : FooGallery / 3.3.0
Gallery : FooGallery v3.3.0
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 1 week ago css 1 week ago extensions 1 week ago freemius 1 week ago gutenberg 1 week ago includes 1 week ago js 1 week ago languages 1 week ago lib 1 week ago templates 1 week ago views 1 week ago LICENSE.txt 1 week ago README.txt 1 week ago changelog.txt 1 week ago foogallery.php 1 week ago index.html 1 week ago wpml-config.xml 1 week ago
foogallery.php
457 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.3.0
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.3.0' );
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_No_Javascript_Fallback();
147 new FooGallery_LazyLoad();
148 new FooGallery_Paging();
149 new FooGallery_Thumbnail_Dimensions();
150 new FooGallery_Attachment_Filename();
151 new FooGallery_Attachment_Custom_Class();
152 new FooGallery_Compatibility();
153 new FooGallery_Extensions_Compatibility();
154 new FooGallery_Crop_Position();
155 new FooGallery_ForceHttps();
156 new FooGallery_Debug();
157 new FooGallery_Password_Protect();
158 $checker = new FooGallery_Version_Check();
159 $checker->wire_up_checker();
160 new FooGallery_Widget_Init();
161 // include the default templates no matter what!
162 new FooGallery_Default_Templates();
163 // init the default media library datasource.
164 new FooGallery_Datasource_MediaLibrary();
165 // Initialize the FooGallery abilities bridge for WordPress core.
166 new FooGallery_Abilities();
167 new FooGallery_Attachment_Type();
168 $pro_code_included = false;
169 if ( !$pro_code_included ) {
170 add_filter( 'foogallery_extensions_for_view', array($this, 'add_foogallery_pro_features') );
171 }
172 add_filter( 'foogallery_extensions_for_view', array($this, 'add_foogallery_addon_features'), 20 );
173 // init Gutenberg!
174 new FooGallery_Gutenberg();
175 // init advanced settings.
176 new FooGallery_Advanced_Gallery_Settings();
177 // init localization for FooGallery.
178 new FooGallery_il8n();
179 }
180
181 function add_foogallery_pro_features( $extensions ) {
182 $pro_features = foogallery_pro_features();
183 $extensions[] = array(
184 'slug' => 'foogallery-bulk-copy',
185 'categories' => array('Premium'),
186 'title' => foogallery__( 'Bulk Copy', 'foogallery' ),
187 'description' => $pro_features['bulk_copy']['desc'],
188 'external_link_text' => foogallery__( 'Read documentation', 'foogallery' ),
189 'external_link_url' => $pro_features['bulk_copy']['link'],
190 'dashicon' => 'dashicons-admin-page',
191 'tags' => array('Premium'),
192 'source' => 'upgrade',
193 );
194 $extensions[] = array(
195 'slug' => 'foogallery-whitelabeling',
196 'categories' => array('Premium'),
197 'title' => foogallery__( 'White Labeling', 'foogallery' ),
198 'description' => $pro_features['whitelabeling']['desc'],
199 'external_link_text' => foogallery__( 'Read documentation', 'foogallery' ),
200 'external_link_url' => $pro_features['whitelabeling']['link'],
201 'dashicon' => 'dashicons-tag',
202 'tags' => array('Premium'),
203 'source' => 'upgrade',
204 );
205 $extensions[] = array(
206 'slug' => 'foogallery-exif',
207 'categories' => array('Premium'),
208 'title' => foogallery__( 'EXIF', 'foogallery' ),
209 'description' => $pro_features['exif']['desc'],
210 'external_link_text' => foogallery__( 'Read documentation', 'foogallery' ),
211 'external_link_url' => $pro_features['exif']['link'],
212 'dashicon' => 'dashicons-camera',
213 'tags' => array('Premium'),
214 'source' => 'upgrade',
215 );
216 $extensions[] = array(
217 'slug' => 'foogallery-filtering',
218 'categories' => array('Premium'),
219 'title' => foogallery__( 'Filtering', 'foogallery' ),
220 'description' => $pro_features['filtering']['desc'],
221 'external_link_text' => foogallery__( 'Read documentation', 'foogallery' ),
222 'external_link_url' => $pro_features['filtering']['link'],
223 'dashicon' => 'dashicons-filter',
224 'tags' => array('Premium'),
225 'source' => 'upgrade',
226 );
227 $extensions[] = array(
228 'slug' => 'foogallery-gallery-blueprints',
229 'categories' => array('Premium'),
230 'title' => foogallery__( 'Gallery Blueprints', 'foogallery' ),
231 'description' => $pro_features['gallery_blueprints']['desc'],
232 'external_link_text' => foogallery__( 'Read documentation', 'foogallery' ),
233 'external_link_url' => $pro_features['gallery_blueprints']['link'],
234 'dashicon' => 'dashicons-networking',
235 'tags' => array('Premium'),
236 'source' => 'upgrade',
237 );
238 $extensions[] = array(
239 'slug' => 'foogallery-paging',
240 'categories' => array('Premium'),
241 'title' => foogallery__( 'Pagination', 'foogallery' ),
242 'description' => $pro_features['pagination']['desc'],
243 'external_link_text' => foogallery__( 'Read documentation', 'foogallery' ),
244 'external_link_url' => $pro_features['pagination']['link'],
245 'dashicon' => 'dashicons-arrow-right-alt',
246 'tags' => array('Premium'),
247 'source' => 'upgrade',
248 );
249 $extensions[] = array(
250 'slug' => 'foogallery-protection',
251 'categories' => array('Premium'),
252 'title' => foogallery__( 'Watermarking & Protection', 'foogallery' ),
253 'description' => $pro_features['protection']['desc'],
254 'external_link_text' => foogallery__( 'Read documentation', 'foogallery' ),
255 'external_link_url' => $pro_features['protection']['link'],
256 'dashicon' => 'dashicons-lock',
257 'tags' => array('Premium'),
258 'source' => 'upgrade',
259 );
260 $extensions[] = array(
261 'slug' => 'foogallery-video',
262 'categories' => array('Premium'),
263 'title' => foogallery__( 'Video', 'foogallery' ),
264 'description' => $pro_features['video']['desc'],
265 'external_link_text' => foogallery__( 'Read documentation', 'foogallery' ),
266 'external_link_url' => $pro_features['video']['link'],
267 'dashicon' => 'dashicons-video-alt3',
268 'tags' => array('Premium'),
269 'source' => 'upgrade',
270 );
271 $extensions[] = array(
272 'slug' => 'foogallery-woocommerce',
273 'categories' => array('Premium'),
274 'title' => foogallery__( 'Ecommerce', 'foogallery' ),
275 'description' => $pro_features['ecommerce']['desc'],
276 'external_link_text' => foogallery__( 'Read documentation', 'foogallery' ),
277 'external_link_url' => $pro_features['ecommerce']['link'],
278 'dashicon' => 'dashicons-cart',
279 'tags' => array('Premium'),
280 'source' => 'upgrade',
281 );
282 return $extensions;
283 }
284
285 function add_foogallery_addon_features( $extensions ) {
286 $addon_features = array(array(
287 'slug' => 'foogallery-user-uploads',
288 'categories' => array('Add-ons', 'Premium'),
289 'title' => foogallery__( 'User Uploads', 'foogallery' ),
290 'description' => foogallery__( 'Allow visitors to upload images and videos into galleries. Includes image moderation, form field customization, email notifications and more.', 'foogallery' ),
291 'external_link_text' => foogallery__( 'Learn More', 'foogallery' ),
292 'external_link_url' => 'https://fooplugins.com/foogallery-wordpress-gallery-plugin/user-uploads/',
293 'addon_link_url' => foogallery_fs()->addon_url( 'foogallery-user-uploads' ),
294 'dashicon' => 'dashicons-upload',
295 'tags' => array('Add-on', 'Premium'),
296 'source' => 'addon',
297 ), array(
298 'slug' => 'foogallery-social',
299 'categories' => array('Add-ons', 'Premium'),
300 'title' => foogallery__( 'Social', 'foogallery' ),
301 'description' => foogallery__( 'Allow your visitors to like, comment and share images to social networks.', 'foogallery' ),
302 'external_link_text' => foogallery__( 'Learn More', 'foogallery' ),
303 'external_link_url' => 'https://fooplugins.com/foogallery-wordpress-gallery-plugin/social/',
304 'addon_link_url' => foogallery_fs()->addon_url( 'foogallery-social' ),
305 'dashicon' => 'dashicons-share',
306 'tags' => array('Add-on', 'Premium'),
307 'source' => 'addon',
308 ), array(
309 'slug' => 'foogallery-proofing',
310 'categories' => array('Add-ons', 'Premium'),
311 'title' => foogallery__( 'Client Proofing', 'foogallery' ),
312 'description' => foogallery__( 'Create private proofing sessions so clients can select, reject, comment on, and submit gallery images for review.', 'foogallery' ),
313 'addon_link_url' => foogallery_fs()->addon_url( 'foogallery-proofing' ),
314 'external_link_url' => 'https://fooplugins.com/foogallery-wordpress-gallery-plugin/client-proofing/',
315 'dashicon' => 'dashicons-visibility',
316 'tags' => array('Add-on', 'Premium'),
317 'source' => 'addon',
318 ));
319 foreach ( $addon_features as $addon_feature ) {
320 if ( !$this->feature_exists_for_view( $extensions, $addon_feature['slug'] ) ) {
321 $extensions[] = $addon_feature;
322 }
323 }
324 return $extensions;
325 }
326
327 private function feature_exists_for_view( $extensions, $slug ) {
328 foreach ( $extensions as $extension ) {
329 if ( isset( $extension['slug'] ) && $slug === $extension['slug'] ) {
330 return true;
331 }
332 }
333 return false;
334 }
335
336 function add_freemius_activation_menu() {
337 if ( foogallery_freemius_is_anonymous() ) {
338 return;
339 }
340 global $foogallery_fs;
341 $parent_slug = foogallery_admin_menu_parent_slug();
342 if ( !$foogallery_fs->is_registered() ) {
343 add_submenu_page(
344 $parent_slug,
345 __( 'FooGallery Opt-In', 'foogallery' ),
346 __( 'Activation', 'foogallery' ),
347 'manage_options',
348 'foogallery-optin',
349 array($foogallery_fs, '_connect_page_render')
350 );
351 }
352 }
353
354 /**
355 * Set Freemius plugin icon.
356 *
357 * @return string
358 */
359 public function freemius_plugin_icon( $icon ) {
360 return FOOGALLERY_PATH . 'assets/foogallery.jpg';
361 }
362
363 /**
364 * Set default extensions when a new site is created in multisite and FooGallery is network activated
365 *
366 * @since 1.2.5
367 *
368 * @param int $blog_id The ID of the newly created site
369 */
370 public function set_default_extensions_for_multisite_network_activated( $blog_id ) {
371 switch_to_blog( $blog_id );
372 if ( false === get_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, false ) ) {
373 $api = new FooGallery_Extensions_API();
374 $api->auto_activate_extensions();
375 update_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, true );
376 }
377 restore_current_blog();
378 }
379
380 /**
381 * Fired when the plugin is activated.
382 *
383 * @since 1.0.0
384 *
385 * @param boolean $network_wide True if WPMU superadmin uses
386 * "Network Activate" action, false if
387 * WPMU is disabled or plugin is
388 * activated on an individual blog.
389 */
390 public static function activate( $network_wide ) {
391 FooGallery_License_Constant_Handler::flag_activation();
392 if ( function_exists( 'is_multisite' ) && is_multisite() ) {
393 if ( $network_wide ) {
394 // Get all blog ids
395 $blog_ids = self::get_blog_ids();
396 if ( is_array( $blog_ids ) ) {
397 foreach ( $blog_ids as $blog_id ) {
398 switch_to_blog( $blog_id );
399 self::single_activate();
400 }
401 restore_current_blog();
402 }
403 } else {
404 self::single_activate();
405 }
406 } else {
407 self::single_activate( false );
408 }
409 }
410
411 /**
412 * Fired for each blog when the plugin is activated.
413 *
414 * @since 1.0.0
415 */
416 private static function single_activate( $multisite = true ) {
417 if ( false === get_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, false ) ) {
418 $api = new FooGallery_Extensions_API();
419 $api->auto_activate_extensions();
420 update_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, true );
421 }
422 if ( false === $multisite ) {
423 // Make sure we redirect to the welcome page
424 set_transient( FOOGALLERY_ACTIVATION_REDIRECT_TRANSIENT_KEY, true, 30 );
425 }
426 // Set the 'advanced_attachment_modal' setting to 'on'
427 if ( !foogallery_get_setting( 'advanced_attachment_modal' ) ) {
428 foogallery_set_setting( 'advanced_attachment_modal', 'on' );
429 }
430 // Force a version check on activation to make sure housekeeping is performed
431 foogallery_perform_version_check();
432 }
433
434 /**
435 * Get all blog ids of blogs in the current network that are:
436 * - not archived
437 * - not spam
438 * - not deleted
439 *
440 * @since 1.0.0
441 *
442 * @return array The blog IDs.
443 */
444 private static function get_blog_ids() {
445 $sites = get_sites();
446 $blog_ids = array();
447 foreach ( $sites as $site ) {
448 $blog_ids[] = $site->blog_id;
449 }
450 return $blog_ids;
451 }
452
453 }
454
455 }
456 FooGallery_Plugin::get_instance();
457 }