This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | /* |
||
3 | Plugin Name: FooGallery |
||
4 | Description: FooGallery is the most intuitive and extensible gallery management tool ever created for WordPress |
||
5 | Version: 1.6.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 ( function_exists( 'foogallery_fs' ) ) { |
||
22 | foogallery_fs()->set_basename( true, __FILE__ ); |
||
23 | } else { |
||
24 | |||
25 | if ( ! class_exists( 'FooGallery_Plugin' ) ) { |
||
26 | |||
27 | define( 'FOOGALLERY_SLUG', 'foogallery' ); |
||
28 | define( 'FOOGALLERY_PATH', plugin_dir_path( __FILE__ ) ); |
||
29 | define( 'FOOGALLERY_URL', plugin_dir_url( __FILE__ ) ); |
||
30 | define( 'FOOGALLERY_FILE', __FILE__ ); |
||
31 | define( 'FOOGALLERY_VERSION', '1.6.17' ); |
||
32 | define( 'FOOGALLERY_SETTINGS_VERSION', '2' ); |
||
33 | |||
34 | require_once( FOOGALLERY_PATH . 'includes/constants.php' ); |
||
35 | |||
36 | // Create a helper function for easy SDK access. |
||
37 | function foogallery_fs() { |
||
38 | global $foogallery_fs; |
||
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
}
}
![]() |
|||
39 | |||
40 | if ( ! isset( $foogallery_fs ) ) { |
||
41 | // Include Freemius SDK. |
||
42 | require_once dirname( __FILE__ ) . '/freemius/start.php'; |
||
43 | |||
44 | $foogallery_fs = fs_dynamic_init( |
||
45 | array( |
||
46 | 'id' => '843', |
||
47 | 'slug' => 'foogallery', |
||
48 | 'type' => 'plugin', |
||
49 | 'public_key' => 'pk_d87616455a835af1d0658699d0192', |
||
50 | 'is_premium' => true, |
||
51 | 'has_paid_plans' => true, |
||
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 | ) |
||
64 | ); |
||
65 | } |
||
66 | |||
67 | return $foogallery_fs; |
||
68 | } |
||
69 | |||
70 | // Init Freemius. |
||
71 | foogallery_fs(); |
||
72 | |||
73 | // Signal that SDK was initiated. |
||
74 | do_action( 'foogallery_fs_loaded' ); |
||
75 | |||
76 | |||
77 | require_once( FOOGALLERY_PATH . 'includes/foopluginbase/bootstrapper.php' ); |
||
78 | |||
79 | /** |
||
80 | * FooGallery_Plugin class |
||
81 | * |
||
82 | * @package FooGallery |
||
83 | * @author Brad Vincent <[email protected]> |
||
84 | * @license GPL-2.0+ |
||
85 | * @link https://github.com/fooplugins/foogallery |
||
86 | * @copyright 2013 FooPlugins LLC |
||
87 | */ |
||
88 | class FooGallery_Plugin extends Foo_Plugin_Base_v2_4 { |
||
89 | |||
90 | private static $instance; |
||
91 | |||
92 | public static function get_instance() { |
||
93 | if ( ! isset( self::$instance ) && ! ( self::$instance instanceof FooGallery_Plugin ) ) { |
||
94 | self::$instance = new FooGallery_Plugin(); |
||
95 | } |
||
96 | |||
97 | return self::$instance; |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * Initialize the plugin by setting localization, filters, and administration functions. |
||
102 | */ |
||
103 | private function __construct() { |
||
104 | |||
105 | //include everything we need! |
||
106 | require_once( FOOGALLERY_PATH . 'includes/includes.php' ); |
||
107 | |||
108 | register_activation_hook( __FILE__, array( 'FooGallery_Plugin', 'activate' ) ); |
||
109 | |||
110 | //init FooPluginBase |
||
111 | $this->init( FOOGALLERY_FILE, FOOGALLERY_SLUG, FOOGALLERY_VERSION, 'FooGallery' ); |
||
112 | |||
113 | //setup text domain |
||
114 | $this->load_plugin_textdomain(); |
||
115 | |||
116 | //setup gallery post type |
||
117 | new FooGallery_PostTypes(); |
||
118 | |||
119 | //load any extensions |
||
120 | new FooGallery_Extensions_Loader(); |
||
121 | |||
122 | if ( is_admin() ) { |
||
123 | new FooGallery_Admin(); |
||
124 | add_action( 'wpmu_new_blog', array( $this, 'set_default_extensions_for_multisite_network_activated' ) ); |
||
125 | add_action( 'admin_page_access_denied', array( $this, 'check_for_access_denied' ) ); |
||
126 | foogallery_fs()->add_filter( 'connect_message_on_update', array( $this, 'override_connect_message_on_update' ), 10, 6 ); |
||
127 | foogallery_fs()->add_filter( 'is_submenu_visible', array( $this, 'is_submenu_visible' ), 10, 2 ); |
||
128 | foogallery_fs()->add_filter( 'plugin_icon', array( $this, 'freemius_plugin_icon' ), 10, 1 ); |
||
129 | add_action( 'foogallery_admin_menu_before', array( $this, 'add_freemius_activation_menu' ) ); |
||
130 | } else { |
||
131 | new FooGallery_Public(); |
||
132 | } |
||
133 | |||
134 | new FooGallery_Shortcodes(); |
||
135 | |||
136 | new FooGallery_Thumbnails(); |
||
137 | |||
138 | new FooGallery_Attachment_Filters(); |
||
139 | |||
140 | new FooGallery_Retina(); |
||
141 | |||
142 | new FooGallery_WPThumb_Enhancements(); |
||
143 | |||
144 | new FooGallery_Animated_Gif_Support(); |
||
145 | |||
146 | new FooGallery_Cache(); |
||
147 | |||
148 | new FooGallery_Common_Fields(); |
||
149 | |||
150 | new FooGallery_LazyLoad(); |
||
151 | |||
152 | new FooGallery_Paging(); |
||
153 | |||
154 | new FooGallery_Thumbnail_Dimensions(); |
||
155 | |||
156 | new FooGallery_Attachment_Custom_Class(); |
||
157 | |||
158 | new FooGallery_Upgrade(); |
||
159 | |||
160 | new FooGallery_Compatibility(); |
||
161 | |||
162 | new FooGallery_Extensions_Compatibility(); |
||
163 | |||
164 | new FooGallery_Default_Crop_Position(); |
||
165 | |||
166 | $checker = new FooGallery_Version_Check(); |
||
167 | $checker->wire_up_checker(); |
||
168 | |||
169 | new FooGallery_Widget_Init(); |
||
170 | |||
171 | //include the default templates no matter what! |
||
172 | new FooGallery_Default_Templates(); |
||
173 | |||
174 | if ( foogallery_fs()->is__premium_only() ) { |
||
175 | if ( foogallery_fs()->can_use_premium_code() ) { |
||
176 | require_once FOOGALLERY_PATH . 'pro/foogallery-pro.php'; |
||
177 | |||
178 | new FooGallery_Pro(); |
||
179 | } |
||
180 | } else { |
||
181 | add_filter( 'foogallery_extensions_for_view', array( $this, 'add_foogallery_pro_extension' ) ); |
||
182 | } |
||
183 | |||
184 | //init Gutenberg! |
||
185 | new FooGallery_Gutenberg(); |
||
186 | } |
||
187 | |||
188 | function add_foogallery_pro_extension( $extensions ) { |
||
0 ignored issues
–
show
|
|||
189 | |||
190 | $extension = array( |
||
191 | 'slug' => 'foogallery-pro', |
||
192 | 'class' => 'FooGallery_Pro', |
||
193 | 'categories' => array( 'Featured', 'Premium' ), |
||
194 | 'title' => 'FooGallery Pro', |
||
195 | 'description' => 'The best gallery plugin for WordPress just got even better!', |
||
196 | 'price' => '$49', |
||
197 | 'author' => 'FooPlugins', |
||
198 | 'author_url' => 'http://fooplugins.com', |
||
199 | 'thumbnail' => 'https://s3.amazonaws.com/foogallery/extensions/foogallerypro.png', |
||
200 | 'tags' => array( 'premium' ), |
||
201 | 'source' => 'fooplugins', |
||
202 | "download_button" => array( |
||
203 | "text" => "Start FREE Trial", |
||
204 | "target" => "_self", |
||
205 | "href" => foogallery_fs()->checkout_url( WP_FS__PERIOD_ANNUALLY, true ), |
||
206 | "confirm" => false |
||
207 | ) |
||
208 | ); |
||
209 | |||
210 | array_unshift( $extensions, $extension ); |
||
211 | |||
212 | return $extensions; |
||
213 | } |
||
214 | |||
215 | /** |
||
216 | * Checks for the access denied page after we have activated/updated the plugin |
||
217 | */ |
||
218 | function check_for_access_denied() { |
||
0 ignored issues
–
show
|
|||
219 | 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
}
}
![]() |
|||
220 | |||
221 | if ( FOOGALLERY_ADMIN_MENU_HELP_SLUG === $plugin_page || |
||
0 ignored issues
–
show
This
if statement is empty and can be removed.
This check looks for the bodies of These if (rand(1, 6) > 3) {
//print "Check failed";
} else {
print "Check succeeded";
}
could be turned into if (rand(1, 6) <= 3) {
print "Check succeeded";
}
This is much more concise to read. ![]() |
|||
222 | FOOGALLERY_ADMIN_MENU_SETTINGS_SLUG === $plugin_page || |
||
223 | FOOGALLERY_ADMIN_MENU_EXTENSIONS_SLUG === $plugin_page || |
||
224 | FOOGALLERY_ADMIN_MENU_SYSTEMINFO_SLUG === $plugin_page ) { |
||
225 | //fs_redirect( 'admin.php?page=' . FOOGALLERY_SLUG ); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
37% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
226 | } |
||
227 | } |
||
228 | |||
229 | /** |
||
230 | * |
||
231 | */ |
||
232 | function override_connect_message_on_update( $original, $first_name, $plugin_name, $login, $link, $freemius_link ) { |
||
0 ignored issues
–
show
|
|||
233 | |||
234 | return |
||
235 | sprintf( __( 'Hey %s', 'foogallery' ), $first_name ) . '<br>' . |
||
236 | sprintf( |
||
237 | __( '<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' ), |
||
238 | '<b>' . $plugin_name . '</b>', |
||
239 | '<b>' . $login . '</b>', |
||
240 | $link, |
||
241 | $freemius_link, |
||
242 | FOOGALLERY_VERSION |
||
243 | ); |
||
244 | } |
||
245 | |||
246 | function add_freemius_activation_menu() { |
||
0 ignored issues
–
show
|
|||
247 | global $foogallery_fs; |
||
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
}
}
![]() |
|||
248 | |||
249 | $parent_slug = foogallery_admin_menu_parent_slug(); |
||
250 | |||
251 | if ( ! $foogallery_fs->is_registered() ) { |
||
252 | add_submenu_page( |
||
253 | $parent_slug, |
||
254 | __( 'FooGallery Opt-In', 'foogallery' ), |
||
255 | __( 'Activation', 'foogallery' ), |
||
256 | 'manage_options', |
||
257 | 'foogallery-optin', |
||
258 | array( $foogallery_fs, '_connect_page_render' ) |
||
259 | ); |
||
260 | } |
||
261 | } |
||
262 | |||
263 | function is_submenu_visible( $visible, $id ) { |
||
0 ignored issues
–
show
|
|||
264 | if ( 'addons' === $id ) { |
||
265 | //hide addons submenu for now |
||
266 | $visible = false; |
||
267 | } |
||
268 | |||
269 | return $visible; |
||
270 | } |
||
271 | |||
272 | /** |
||
273 | * Set Freemius plugin icon. |
||
274 | * |
||
275 | * @return string |
||
276 | */ |
||
277 | public function freemius_plugin_icon( $icon ) { |
||
278 | return FOOGALLERY_PATH . 'assets/foogallery.png'; |
||
279 | } |
||
280 | |||
281 | /** |
||
282 | * Set default extensions when a new site is created in multisite and FooGallery is network activated |
||
283 | * |
||
284 | * @since 1.2.5 |
||
285 | * |
||
286 | * @param int $blog_id The ID of the newly created site |
||
287 | */ |
||
288 | public function set_default_extensions_for_multisite_network_activated( $blog_id ) { |
||
289 | switch_to_blog( $blog_id ); |
||
290 | |||
291 | if ( false === get_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, false ) ) { |
||
292 | $api = new FooGallery_Extensions_API(); |
||
293 | |||
294 | $api->auto_activate_extensions(); |
||
295 | |||
296 | update_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, true ); |
||
297 | } |
||
298 | |||
299 | restore_current_blog(); |
||
300 | } |
||
301 | |||
302 | /** |
||
303 | * Fired when the plugin is activated. |
||
304 | * |
||
305 | * @since 1.0.0 |
||
306 | * |
||
307 | * @param boolean $network_wide True if WPMU superadmin uses |
||
308 | * "Network Activate" action, false if |
||
309 | * WPMU is disabled or plugin is |
||
310 | * activated on an individual blog. |
||
311 | */ |
||
312 | public static function activate( $network_wide ) { |
||
313 | if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
||
314 | |||
315 | if ( $network_wide ) { |
||
316 | |||
317 | // Get all blog ids |
||
318 | $blog_ids = self::get_blog_ids(); |
||
319 | if ( is_array( $blog_ids ) ) { |
||
320 | foreach ( $blog_ids as $blog_id ) { |
||
321 | |||
322 | switch_to_blog( $blog_id ); |
||
323 | self::single_activate(); |
||
324 | } |
||
325 | |||
326 | restore_current_blog(); |
||
327 | } |
||
328 | |||
329 | } else { |
||
330 | self::single_activate(); |
||
331 | } |
||
332 | |||
333 | } else { |
||
334 | self::single_activate( false ); |
||
335 | } |
||
336 | } |
||
337 | |||
338 | /** |
||
339 | * Fired for each blog when the plugin is activated. |
||
340 | * |
||
341 | * @since 1.0.0 |
||
342 | */ |
||
343 | private static function single_activate( $multisite = true ) { |
||
344 | if ( false === get_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, false ) ) { |
||
345 | $api = new FooGallery_Extensions_API(); |
||
346 | |||
347 | $api->auto_activate_extensions(); |
||
348 | |||
349 | update_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, true ); |
||
350 | } |
||
351 | if ( false === $multisite ) { |
||
352 | //Make sure we redirect to the welcome page |
||
353 | set_transient( FOOGALLERY_ACTIVATION_REDIRECT_TRANSIENT_KEY, true, 30 ); |
||
354 | } |
||
355 | |||
356 | //force a version check on activation to make sure housekeeping is performed |
||
357 | foogallery_perform_version_check(); |
||
358 | } |
||
359 | |||
360 | /** |
||
361 | * Get all blog ids of blogs in the current network that are: |
||
362 | * - not archived |
||
363 | * - not spam |
||
364 | * - not deleted |
||
365 | * |
||
366 | * @since 1.0.0 |
||
367 | * |
||
368 | * @return array|false The blog ids, false if no matches. |
||
369 | */ |
||
370 | private static function get_blog_ids() { |
||
371 | |||
372 | if ( function_exists( 'get_sites' ) ) { |
||
373 | |||
374 | $sites = get_sites(); |
||
375 | $blog_ids = array(); |
||
376 | foreach ( $sites as $site ) { |
||
377 | $blog_ids[] = $site->blog_id; |
||
378 | } |
||
379 | |||
380 | return $blog_ids; |
||
381 | } else { |
||
382 | //pre WP 3.7 - do this the old way! |
||
383 | global $wpdb; |
||
384 | |||
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 | |||
388 | return $wpdb->get_col( $sql ); |
||
389 | } |
||
390 | } |
||
391 | } |
||
392 | } |
||
393 | |||
394 | FooGallery_Plugin::get_instance(); |
||
395 | } |
||
396 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.