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