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.3.6 |
||
| 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 | |||
| 14 | // If this file is called directly, abort. |
||
| 15 | if ( ! defined( 'WPINC' ) ) { |
||
| 16 | die; |
||
| 17 | } |
||
| 18 | |||
| 19 | if ( ! class_exists( 'FooGallery_Plugin' ) ) { |
||
| 20 | |||
| 21 | define( 'FOOGALLERY_SLUG', 'foogallery' ); |
||
| 22 | define( 'FOOGALLERY_PATH', plugin_dir_path( __FILE__ ) ); |
||
| 23 | define( 'FOOGALLERY_URL', plugin_dir_url( __FILE__ ) ); |
||
| 24 | define( 'FOOGALLERY_FILE', __FILE__ ); |
||
| 25 | define( 'FOOGALLERY_VERSION', '1.3.6' ); |
||
| 26 | |||
| 27 | require_once( FOOGALLERY_PATH . 'includes/constants.php' ); |
||
| 28 | |||
| 29 | // Create a helper function for easy SDK access. |
||
| 30 | function foogallery_fs() { |
||
| 31 | global $foogallery_fs; |
||
|
0 ignored issues
–
show
|
|||
| 32 | |||
| 33 | if ( ! isset( $foogallery_fs ) ) { |
||
| 34 | // Include Freemius SDK. |
||
| 35 | require_once dirname(__FILE__) . '/freemius/start.php'; |
||
| 36 | |||
| 37 | $foogallery_fs = fs_dynamic_init( array( |
||
| 38 | 'id' => '843', |
||
| 39 | 'slug' => 'foogallery', |
||
| 40 | 'type' => 'plugin', |
||
| 41 | 'public_key' => 'pk_d87616455a835af1d0658699d0192', |
||
| 42 | 'is_premium' => false, |
||
| 43 | 'has_addons' => false, |
||
| 44 | 'has_paid_plans' => false, |
||
| 45 | 'menu' => array( |
||
| 46 | 'slug' => 'edit.php?post_type=' . FOOGALLERY_CPT_GALLERY, |
||
| 47 | 'first-path' => 'edit.php?post_type=' . FOOGALLERY_CPT_GALLERY . '&page=' . FOOGALLERY_ADMIN_MENU_HELP_SLUG, |
||
| 48 | 'account' => false, |
||
| 49 | 'contact' => false, |
||
| 50 | 'support' => false, |
||
| 51 | ), |
||
| 52 | ) ); |
||
| 53 | } |
||
| 54 | |||
| 55 | return $foogallery_fs; |
||
| 56 | } |
||
| 57 | |||
| 58 | // Init Freemius. |
||
| 59 | foogallery_fs(); |
||
| 60 | |||
| 61 | // Signal that SDK was initiated. |
||
| 62 | do_action( 'foogallery_fs_loaded' ); |
||
| 63 | |||
| 64 | |||
| 65 | require_once( FOOGALLERY_PATH . 'includes/foopluginbase/bootstrapper.php' ); |
||
| 66 | |||
| 67 | /** |
||
| 68 | * FooGallery_Plugin class |
||
| 69 | * |
||
| 70 | * @package FooGallery |
||
| 71 | * @author Brad Vincent <[email protected]> |
||
| 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_3 { |
||
| 77 | |||
| 78 | private static $instance; |
||
| 79 | |||
| 80 | public static function get_instance() { |
||
| 81 | if ( ! isset(self::$instance) && ! (self::$instance instanceof FooGallery_Plugin) ) { |
||
| 82 | self::$instance = new FooGallery_Plugin(); |
||
| 83 | } |
||
| 84 | |||
| 85 | return self::$instance; |
||
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * Initialize the plugin by setting localization, filters, and administration functions. |
||
| 90 | */ |
||
| 91 | private function __construct() { |
||
| 92 | |||
| 93 | //include everything we need! |
||
| 94 | require_once( FOOGALLERY_PATH . 'includes/includes.php' ); |
||
| 95 | |||
| 96 | register_activation_hook( __FILE__, array( 'FooGallery_Plugin', 'activate' ) ); |
||
| 97 | |||
| 98 | //init FooPluginBase |
||
| 99 | $this->init( FOOGALLERY_FILE, FOOGALLERY_SLUG, FOOGALLERY_VERSION, 'FooGallery' ); |
||
| 100 | |||
| 101 | //setup text domain |
||
| 102 | $this->load_plugin_textdomain(); |
||
| 103 | |||
| 104 | //setup gallery post type |
||
| 105 | new FooGallery_PostTypes(); |
||
| 106 | |||
| 107 | //load any extensions |
||
| 108 | new FooGallery_Extensions_Loader(); |
||
| 109 | |||
| 110 | if ( is_admin() ) { |
||
| 111 | new FooGallery_Admin(); |
||
| 112 | add_action( 'wpmu_new_blog', array( $this, 'set_default_extensions_for_multisite_network_activated' ) ); |
||
| 113 | add_action( 'admin_page_access_denied', array( $this, 'check_for_access_denied' ) ); |
||
| 114 | foogallery_fs()->add_filter( 'connect_message_on_update', array( $this, 'override_connect_message_on_update' ), 10, 6 ); |
||
| 115 | } else { |
||
| 116 | new FooGallery_Public(); |
||
| 117 | } |
||
| 118 | |||
| 119 | new FooGallery_Thumbnails(); |
||
| 120 | |||
| 121 | new FooGallery_Polylang_Compatibility(); |
||
| 122 | |||
| 123 | new FooGallery_Attachment_Filters(); |
||
| 124 | |||
| 125 | new FooGallery_Retina(); |
||
| 126 | |||
| 127 | new FooGallery_WPThumb_Enhancements(); |
||
| 128 | |||
| 129 | new FooGallery_Animated_Gif_Support(); |
||
| 130 | |||
| 131 | new FooGallery_Cache(); |
||
| 132 | |||
| 133 | new FooGallery_Thumbnail_Dimensions(); |
||
| 134 | |||
| 135 | new FooGallery_Responsive_Lightbox_dFactory_Support(); |
||
| 136 | |||
| 137 | new FooGallery_Attachment_Custom_Class(); |
||
| 138 | |||
| 139 | $checker = new FooGallery_Version_Check(); |
||
| 140 | $checker->wire_up_checker(); |
||
| 141 | } |
||
| 142 | |||
| 143 | /** |
||
| 144 | * Checks for the access denied page after we have activated/updated the plugin |
||
| 145 | */ |
||
| 146 | function check_for_access_denied() { |
||
|
0 ignored issues
–
show
|
|||
| 147 | global $plugin_page; |
||
|
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
Loading history...
|
|||
| 148 | |||
| 149 | if ( FOOGALLERY_ADMIN_MENU_HELP_SLUG === $plugin_page ) { |
||
| 150 | fs_redirect( 'admin.php?page=' . FOOGALLERY_ADMIN_MENU_HELP_SLUG ); |
||
| 151 | } |
||
| 152 | } |
||
| 153 | |||
| 154 | /** |
||
| 155 | * |
||
| 156 | */ |
||
| 157 | function override_connect_message_on_update( $original, $first_name, $plugin_name, $login, $link, $freemius_link ) { |
||
|
0 ignored issues
–
show
|
|||
| 158 | |||
| 159 | return |
||
| 160 | sprintf( __( 'Hey %s', 'foogallery' ), $first_name ) . '<br>' . |
||
| 161 | sprintf( |
||
| 162 | __( '<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' ), |
||
| 163 | '<b>' . $plugin_name . '</b>', |
||
| 164 | '<b>' . $login . '</b>', |
||
| 165 | $link, |
||
| 166 | $freemius_link, |
||
| 167 | FOOGALLERY_VERSION |
||
| 168 | ); |
||
| 169 | } |
||
| 170 | |||
| 171 | /** |
||
| 172 | * Set default extensions when a new site is created in multisite and FooGallery is network activated |
||
| 173 | * |
||
| 174 | * @since 1.2.5 |
||
| 175 | * |
||
| 176 | * @param int $blog_id The ID of the newly created site |
||
| 177 | */ |
||
| 178 | public function set_default_extensions_for_multisite_network_activated( $blog_id ) { |
||
| 179 | switch_to_blog( $blog_id ); |
||
| 180 | |||
| 181 | if ( false === get_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, false ) ) { |
||
| 182 | $api = new FooGallery_Extensions_API(); |
||
| 183 | |||
| 184 | $api->auto_activate_extensions(); |
||
| 185 | |||
| 186 | update_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, true ); |
||
| 187 | } |
||
| 188 | |||
| 189 | restore_current_blog(); |
||
| 190 | } |
||
| 191 | |||
| 192 | /** |
||
| 193 | * Fired when the plugin is activated. |
||
| 194 | * |
||
| 195 | * @since 1.0.0 |
||
| 196 | * |
||
| 197 | * @param boolean $network_wide True if WPMU superadmin uses |
||
| 198 | * "Network Activate" action, false if |
||
| 199 | * WPMU is disabled or plugin is |
||
| 200 | * activated on an individual blog. |
||
| 201 | */ |
||
| 202 | public static function activate( $network_wide ) { |
||
| 203 | if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
||
| 204 | |||
| 205 | if ( $network_wide ) { |
||
| 206 | |||
| 207 | // Get all blog ids |
||
| 208 | $blog_ids = self::get_blog_ids(); |
||
| 209 | if ( is_array( $blog_ids ) ) { |
||
| 210 | foreach ( $blog_ids as $blog_id ) { |
||
| 211 | |||
| 212 | switch_to_blog( $blog_id ); |
||
| 213 | self::single_activate(); |
||
| 214 | } |
||
| 215 | |||
| 216 | restore_current_blog(); |
||
| 217 | } |
||
| 218 | |||
| 219 | } else { |
||
| 220 | self::single_activate(); |
||
| 221 | } |
||
| 222 | |||
| 223 | } else { |
||
| 224 | self::single_activate( false ); |
||
| 225 | } |
||
| 226 | } |
||
| 227 | |||
| 228 | /** |
||
| 229 | * Fired for each blog when the plugin is activated. |
||
| 230 | * |
||
| 231 | * @since 1.0.0 |
||
| 232 | */ |
||
| 233 | private static function single_activate( $multisite = true ) { |
||
| 234 | if ( false === get_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, false ) ) { |
||
| 235 | $api = new FooGallery_Extensions_API(); |
||
| 236 | |||
| 237 | $api->auto_activate_extensions(); |
||
| 238 | |||
| 239 | update_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, true ); |
||
| 240 | } |
||
| 241 | if ( false === $multisite ) { |
||
| 242 | //Make sure we redirect to the welcome page |
||
| 243 | set_transient( FOOGALLERY_ACTIVATION_REDIRECT_TRANSIENT_KEY, true, 30 ); |
||
| 244 | } |
||
| 245 | |||
| 246 | //force a version check on activation to make sure housekeeping is performed |
||
| 247 | foogallery_perform_version_check(); |
||
| 248 | } |
||
| 249 | |||
| 250 | /** |
||
| 251 | * Get all blog ids of blogs in the current network that are: |
||
| 252 | * - not archived |
||
| 253 | * - not spam |
||
| 254 | * - not deleted |
||
| 255 | * |
||
| 256 | * @since 1.0.0 |
||
| 257 | * |
||
| 258 | * @return array|false The blog ids, false if no matches. |
||
| 259 | */ |
||
| 260 | private static function get_blog_ids() { |
||
| 261 | |||
| 262 | if ( function_exists( 'wp_get_sites' ) ) { |
||
| 263 | |||
| 264 | $sites = wp_get_sites(); |
||
| 265 | $blog_ids = array(); |
||
| 266 | foreach ( $sites as $site ) { |
||
| 267 | $blog_ids[] = $site['blog_id']; |
||
| 268 | } |
||
| 269 | return $blog_ids; |
||
| 270 | } else { |
||
| 271 | //pre WP 3.7 - do this the old way! |
||
| 272 | global $wpdb; |
||
| 273 | |||
| 274 | // get an array of blog ids |
||
| 275 | $sql = "SELECT blog_id FROM $wpdb->blogs WHERE archived = '0' AND spam = '0' AND deleted = '0'"; |
||
| 276 | |||
| 277 | return $wpdb->get_col( $sql ); |
||
| 278 | } |
||
| 279 | } |
||
| 280 | } |
||
| 281 | } |
||
| 282 | |||
| 283 | FooGallery_Plugin::get_instance(); |
||
| 284 |
Instead of relying on
globalstate, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state