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