fooplugins /
foogallery
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /* |
||
| 3 | Plugin Name: FooGallery |
||
| 4 | Description: FooGallery is the most intuitive and extensible gallery management tool ever created for WordPress |
||
| 5 | Version: 1.4.17 |
||
| 6 | Author: FooPlugins |
||
| 7 | Plugin URI: https://foo.gallery |
||
| 8 | Author URI: http://fooplugins.com |
||
| 9 | Text Domain: foogallery |
||
| 10 | License: GPL-2.0+ |
||
| 11 | Domain Path: /languages |
||
| 12 | |||
| 13 | @fs_premium_only /pro/ |
||
| 14 | */ |
||
| 15 | |||
| 16 | // If this file is called directly, abort. |
||
| 17 | if ( ! defined( 'WPINC' ) ) { |
||
| 18 | die; |
||
| 19 | } |
||
| 20 | |||
| 21 | if ( ! class_exists( 'FooGallery_Plugin' ) ) { |
||
| 22 | |||
| 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', '1.4.17' ); |
||
| 28 | define( 'FOOGALLERY_SETTINGS_VERSION', '2' ); |
||
| 29 | |||
| 30 | require_once( FOOGALLERY_PATH . 'includes/constants.php' ); |
||
| 31 | |||
| 32 | // Create a helper function for easy SDK access. |
||
| 33 | function foogallery_fs() { |
||
| 34 | global $foogallery_fs; |
||
| 35 | |||
| 36 | if ( ! isset( $foogallery_fs ) ) { |
||
| 37 | // Include Freemius SDK. |
||
| 38 | require_once dirname(__FILE__) . '/freemius/start.php'; |
||
| 39 | |||
| 40 | $foogallery_fs = fs_dynamic_init( array( |
||
| 41 | 'id' => '843', |
||
| 42 | 'slug' => 'foogallery', |
||
| 43 | 'type' => 'plugin', |
||
| 44 | 'public_key' => 'pk_d87616455a835af1d0658699d0192', |
||
| 45 | 'is_premium' => true, |
||
| 46 | 'has_addons' => true, |
||
| 47 | 'has_paid_plans' => true, |
||
| 48 | 'trial' => array( |
||
| 49 | 'days' => 7, |
||
| 50 | 'is_require_payment' => false, |
||
| 51 | ), |
||
| 52 | 'menu' => array( |
||
| 53 | 'slug' => 'edit.php?post_type=' . FOOGALLERY_CPT_GALLERY, |
||
| 54 | 'first-path' => 'edit.php?post_type=' . FOOGALLERY_CPT_GALLERY . '&page=' . FOOGALLERY_ADMIN_MENU_HELP_SLUG, |
||
| 55 | 'account' => true, |
||
| 56 | 'contact' => false, |
||
| 57 | 'support' => false, |
||
| 58 | ), |
||
| 59 | ) ); |
||
| 60 | } |
||
| 61 | |||
| 62 | return $foogallery_fs; |
||
| 63 | } |
||
| 64 | |||
| 65 | // Init Freemius. |
||
| 66 | foogallery_fs(); |
||
| 67 | |||
| 68 | // Signal that SDK was initiated. |
||
| 69 | do_action( 'foogallery_fs_loaded' ); |
||
| 70 | |||
| 71 | |||
| 72 | require_once( FOOGALLERY_PATH . 'includes/foopluginbase/bootstrapper.php' ); |
||
| 73 | |||
| 74 | /** |
||
| 75 | * FooGallery_Plugin class |
||
| 76 | * |
||
| 77 | * @package FooGallery |
||
| 78 | * @author Brad Vincent <[email protected]> |
||
| 79 | * @license GPL-2.0+ |
||
| 80 | * @link https://github.com/fooplugins/foogallery |
||
| 81 | * @copyright 2013 FooPlugins LLC |
||
| 82 | */ |
||
| 83 | class FooGallery_Plugin extends Foo_Plugin_Base_v2_4 { |
||
| 84 | |||
| 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 | |||
| 92 | return self::$instance; |
||
| 93 | } |
||
| 94 | |||
| 95 | /** |
||
| 96 | * Initialize the plugin by setting localization, filters, and administration functions. |
||
| 97 | */ |
||
| 98 | private function __construct() { |
||
| 99 | |||
| 100 | //include everything we need! |
||
| 101 | require_once( FOOGALLERY_PATH . 'includes/includes.php' ); |
||
| 102 | |||
| 103 | register_activation_hook( __FILE__, array( 'FooGallery_Plugin', 'activate' ) ); |
||
| 104 | |||
| 105 | //init FooPluginBase |
||
| 106 | $this->init( FOOGALLERY_FILE, FOOGALLERY_SLUG, FOOGALLERY_VERSION, 'FooGallery' ); |
||
| 107 | |||
| 108 | //setup text domain |
||
| 109 | $this->load_plugin_textdomain(); |
||
| 110 | |||
| 111 | //setup gallery post type |
||
| 112 | new FooGallery_PostTypes(); |
||
| 113 | |||
| 114 | //load any extensions |
||
| 115 | new FooGallery_Extensions_Loader(); |
||
| 116 | |||
| 117 | if ( is_admin() ) { |
||
| 118 | new FooGallery_Admin(); |
||
| 119 | add_action( 'wpmu_new_blog', array( $this, 'set_default_extensions_for_multisite_network_activated' ) ); |
||
| 120 | add_action( 'admin_page_access_denied', array( $this, 'check_for_access_denied' ) ); |
||
| 121 | foogallery_fs()->add_filter( 'connect_message_on_update', array( $this, 'override_connect_message_on_update' ), 10, 6 ); |
||
| 122 | foogallery_fs()->add_filter( 'is_submenu_visible', array( $this, 'is_submenu_visible' ), 10, 2 ); |
||
| 123 | foogallery_fs()->add_filter( 'hide_account_tabs', '__return_true' ); |
||
| 124 | add_action( 'foogallery_admin_menu_before', array( $this, 'add_freemius_activation_menu' ) ); |
||
| 125 | } else { |
||
| 126 | new FooGallery_Public(); |
||
| 127 | } |
||
| 128 | |||
| 129 | new FooGallery_Thumbnails(); |
||
| 130 | |||
| 131 | new FooGallery_Polylang_Compatibility(); |
||
| 132 | |||
| 133 | new FooGallery_Attachment_Filters(); |
||
| 134 | |||
| 135 | new FooGallery_Retina(); |
||
| 136 | |||
| 137 | new FooGallery_WPThumb_Enhancements(); |
||
| 138 | |||
| 139 | new FooGallery_Animated_Gif_Support(); |
||
| 140 | |||
| 141 | new FooGallery_Cache(); |
||
| 142 | |||
| 143 | new FooGallery_Common_Fields(); |
||
| 144 | |||
| 145 | new FooGallery_LazyLoad(); |
||
| 146 | |||
| 147 | new FooGallery_Paging(); |
||
| 148 | |||
| 149 | new FooGallery_Thumbnail_Dimensions(); |
||
| 150 | |||
| 151 | new FooGallery_FooBox_Support(); |
||
| 152 | |||
| 153 | new FooGallery_Responsive_Lightbox_dFactory_Support(); |
||
| 154 | |||
| 155 | new FooGallery_Attachment_Custom_Class(); |
||
| 156 | |||
| 157 | new FooGallery_Upgrade(); |
||
| 158 | |||
| 159 | new FooGallery_Extensions_Compatibility(); |
||
| 160 | |||
| 161 | $checker = new FooGallery_Version_Check(); |
||
| 162 | $checker->wire_up_checker(); |
||
| 163 | |||
| 164 | new FooGallery_Widget_Init(); |
||
| 165 | |||
| 166 | //include the default templates no matter what! |
||
| 167 | new FooGallery_Default_Templates(); |
||
| 168 | |||
| 169 | if ( foogallery_fs()->is__premium_only() ) { |
||
| 170 | if ( foogallery_fs()->can_use_premium_code() ) { |
||
| 171 | require_once FOOGALLERY_PATH . 'pro/foogallery-pro.php'; |
||
| 172 | |||
| 173 | new FooGallery_Pro(); |
||
| 174 | } |
||
| 175 | } else { |
||
| 176 | add_filter( 'foogallery_extensions_for_view', array( $this, 'add_foogallery_pro_extension' ) ); |
||
| 177 | } |
||
| 178 | } |
||
| 179 | |||
| 180 | function add_foogallery_pro_extension( $extensions ) { |
||
|
0 ignored issues
–
show
|
|||
| 181 | |||
| 182 | $extension = array( |
||
| 183 | 'slug' => 'foogallery-pro', |
||
| 184 | 'class' => 'FooGallery_Pro', |
||
| 185 | 'categories' => array( 'Featured', 'Premium' ), |
||
| 186 | 'title' => 'FooGallery Pro', |
||
| 187 | 'description' => 'The best gallery plugin for WordPress just got even better!', |
||
| 188 | 'price' => '$49', |
||
| 189 | 'author' => 'FooPlugins', |
||
| 190 | 'author_url' => 'http://fooplugins.com', |
||
| 191 | 'thumbnail' => 'https://s3.amazonaws.com/foogallery/extensions/foogallerypro.png', |
||
| 192 | 'tags' => array( 'premium' ), |
||
| 193 | 'source' => 'fooplugins', |
||
| 194 | "download_button" => array( |
||
| 195 | "text" => "Start FREE Trial", |
||
| 196 | "target" => "_self", |
||
| 197 | "href" => foogallery_fs()->checkout_url( WP_FS__PERIOD_ANNUALLY, true ), |
||
| 198 | "confirm" => false |
||
| 199 | ) |
||
| 200 | ); |
||
| 201 | |||
| 202 | array_unshift( $extensions, $extension ); |
||
| 203 | |||
| 204 | return $extensions; |
||
| 205 | } |
||
| 206 | |||
| 207 | /** |
||
| 208 | * Checks for the access denied page after we have activated/updated the plugin |
||
| 209 | */ |
||
| 210 | function check_for_access_denied() { |
||
| 211 | global $plugin_page; |
||
| 212 | |||
| 213 | if ( FOOGALLERY_ADMIN_MENU_HELP_SLUG === $plugin_page || |
||
| 214 | FOOGALLERY_ADMIN_MENU_SETTINGS_SLUG === $plugin_page || |
||
| 215 | FOOGALLERY_ADMIN_MENU_EXTENSIONS_SLUG === $plugin_page || |
||
| 216 | FOOGALLERY_ADMIN_MENU_SYSTEMINFO_SLUG === $plugin_page) { |
||
| 217 | //fs_redirect( 'admin.php?page=' . FOOGALLERY_SLUG ); |
||
| 218 | } |
||
| 219 | } |
||
| 220 | |||
| 221 | /** |
||
| 222 | * |
||
| 223 | */ |
||
| 224 | function override_connect_message_on_update( $original, $first_name, $plugin_name, $login, $link, $freemius_link ) { |
||
| 225 | |||
| 226 | return |
||
| 227 | sprintf( __( 'Hey %s', 'foogallery' ), $first_name ) . '<br>' . |
||
| 228 | sprintf( |
||
| 229 | __( '<h2>Thank you for updating to %1$s v%5$s!</h2>Our goal with this update is to make %1$s the best gallery plugin for WordPress, but we need your help!<br><br>We have introduced this opt-in so that you can help us improve %1$s by simply clicking <strong>Allow & Continue</strong>.<br><br>If you opt-in, some data about your usage of %1$s will be sent to %4$s. If you skip this, that\'s okay! %1$s will still work just fine.', 'foogallery' ), |
||
| 230 | '<b>' . $plugin_name . '</b>', |
||
| 231 | '<b>' . $login . '</b>', |
||
| 232 | $link, |
||
| 233 | $freemius_link, |
||
| 234 | FOOGALLERY_VERSION |
||
| 235 | ); |
||
| 236 | } |
||
| 237 | |||
| 238 | function add_freemius_activation_menu() { |
||
| 239 | global $foogallery_fs; |
||
| 240 | |||
| 241 | $parent_slug = foogallery_admin_menu_parent_slug(); |
||
| 242 | |||
| 243 | if ( ! $foogallery_fs->is_registered() ) { |
||
| 244 | add_submenu_page( |
||
| 245 | $parent_slug, |
||
| 246 | __( 'FooGallery Opt-In', 'foogallery' ), |
||
| 247 | __( 'Activation', 'foogallery' ), |
||
| 248 | 'manage_options', |
||
| 249 | 'foogallery-optin', |
||
| 250 | array( $foogallery_fs, '_connect_page_render' ) |
||
| 251 | ); |
||
| 252 | } |
||
| 253 | } |
||
| 254 | |||
| 255 | function is_submenu_visible( $visible, $id ) { |
||
|
0 ignored issues
–
show
|
|||
| 256 | if ( 'addons' === $id ) { |
||
| 257 | //hide addons submenu for now |
||
| 258 | $visible = false; |
||
| 259 | } |
||
| 260 | return $visible; |
||
| 261 | } |
||
| 262 | |||
| 263 | /** |
||
| 264 | * Set default extensions when a new site is created in multisite and FooGallery is network activated |
||
| 265 | * |
||
| 266 | * @since 1.2.5 |
||
| 267 | * |
||
| 268 | * @param int $blog_id The ID of the newly created site |
||
| 269 | */ |
||
| 270 | public function set_default_extensions_for_multisite_network_activated( $blog_id ) { |
||
| 271 | switch_to_blog( $blog_id ); |
||
| 272 | |||
| 273 | if ( false === get_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, false ) ) { |
||
| 274 | $api = new FooGallery_Extensions_API(); |
||
| 275 | |||
| 276 | $api->auto_activate_extensions(); |
||
| 277 | |||
| 278 | update_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, true ); |
||
| 279 | } |
||
| 280 | |||
| 281 | restore_current_blog(); |
||
| 282 | } |
||
| 283 | |||
| 284 | /** |
||
| 285 | * Fired when the plugin is activated. |
||
| 286 | * |
||
| 287 | * @since 1.0.0 |
||
| 288 | * |
||
| 289 | * @param boolean $network_wide True if WPMU superadmin uses |
||
| 290 | * "Network Activate" action, false if |
||
| 291 | * WPMU is disabled or plugin is |
||
| 292 | * activated on an individual blog. |
||
| 293 | */ |
||
| 294 | public static function activate( $network_wide ) { |
||
| 295 | if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
||
| 296 | |||
| 297 | if ( $network_wide ) { |
||
| 298 | |||
| 299 | // Get all blog ids |
||
| 300 | $blog_ids = self::get_blog_ids(); |
||
| 301 | if ( is_array( $blog_ids ) ) { |
||
| 302 | foreach ( $blog_ids as $blog_id ) { |
||
| 303 | |||
| 304 | switch_to_blog( $blog_id ); |
||
| 305 | self::single_activate(); |
||
| 306 | } |
||
| 307 | |||
| 308 | restore_current_blog(); |
||
| 309 | } |
||
| 310 | |||
| 311 | } else { |
||
| 312 | self::single_activate(); |
||
| 313 | } |
||
| 314 | |||
| 315 | } else { |
||
| 316 | self::single_activate( false ); |
||
| 317 | } |
||
| 318 | } |
||
| 319 | |||
| 320 | /** |
||
| 321 | * Fired for each blog when the plugin is activated. |
||
| 322 | * |
||
| 323 | * @since 1.0.0 |
||
| 324 | */ |
||
| 325 | private static function single_activate( $multisite = true ) { |
||
| 326 | if ( false === get_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, false ) ) { |
||
| 327 | $api = new FooGallery_Extensions_API(); |
||
| 328 | |||
| 329 | $api->auto_activate_extensions(); |
||
| 330 | |||
| 331 | update_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, true ); |
||
| 332 | } |
||
| 333 | if ( false === $multisite ) { |
||
| 334 | //Make sure we redirect to the welcome page |
||
| 335 | set_transient( FOOGALLERY_ACTIVATION_REDIRECT_TRANSIENT_KEY, true, 30 ); |
||
| 336 | } |
||
| 337 | |||
| 338 | //force a version check on activation to make sure housekeeping is performed |
||
| 339 | foogallery_perform_version_check(); |
||
| 340 | } |
||
| 341 | |||
| 342 | /** |
||
| 343 | * Get all blog ids of blogs in the current network that are: |
||
| 344 | * - not archived |
||
| 345 | * - not spam |
||
| 346 | * - not deleted |
||
| 347 | * |
||
| 348 | * @since 1.0.0 |
||
| 349 | * |
||
| 350 | * @return array|false The blog ids, false if no matches. |
||
| 351 | */ |
||
| 352 | private static function get_blog_ids() { |
||
| 353 | |||
| 354 | if ( function_exists( 'get_sites' ) ) { |
||
| 355 | |||
| 356 | $sites = get_sites(); |
||
| 357 | $blog_ids = array(); |
||
| 358 | foreach ( $sites as $site ) { |
||
| 359 | $blog_ids[] = $site->blog_id; |
||
| 360 | } |
||
| 361 | return $blog_ids; |
||
| 362 | } else { |
||
| 363 | //pre WP 3.7 - do this the old way! |
||
| 364 | global $wpdb; |
||
| 365 | |||
| 366 | // get an array of blog ids |
||
| 367 | $sql = "SELECT blog_id FROM $wpdb->blogs WHERE archived = '0' AND spam = '0' AND deleted = '0'"; |
||
| 368 | |||
| 369 | return $wpdb->get_col( $sql ); |
||
| 370 | } |
||
| 371 | } |
||
| 372 | } |
||
| 373 | } |
||
| 374 | |||
| 375 | FooGallery_Plugin::get_instance(); |
||
| 376 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.