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