GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 8a4343...7d5fa4 )
by Brad
11:03 queued 06:20
created

FooGallery_Plugin::check_for_access_denied()   B

Complexity

Conditions 5
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 7
nc 2
nop 0
dl 0
loc 10
rs 8.8571
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 21 and the first side effect is on line 27.

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.

Loading history...
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.7
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.7' );
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
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 global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
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
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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 global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class 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
				FOOGALLERY_ADMIN_MENU_SETTINGS_SLUG === $plugin_page ||
151
				FOOGALLERY_ADMIN_MENU_EXTENSIONS_SLUG === $plugin_page ||
152
				FOOGALLERY_ADMIN_MENU_SYSTEMINFO_SLUG === $plugin_page) {
153
				fs_redirect( 'admin.php?page=' . FOOGALLERY_SLUG );
154
			}
155
		}
156
157
		/**
158
		 *
159
		 */
160
		function override_connect_message_on_update( $original, $first_name, $plugin_name, $login, $link, $freemius_link ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
161
162
			return
163
				sprintf( __( 'Hey %s', 'foogallery' ), $first_name ) . '<br>' .
164
				sprintf(
165
					__( '<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 &amp; 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' ),
166
					'<b>' . $plugin_name . '</b>',
167
					'<b>' . $login . '</b>',
168
					$link,
169
					$freemius_link,
170
					FOOGALLERY_VERSION
171
				);
172
		}
173
174
		/**
175
		 * Set default extensions when a new site is created in multisite and FooGallery is network activated
176
		 *
177
		 * @since 1.2.5
178
		 *
179
		 * @param int $blog_id The ID of the newly created site
180
		 */
181
		public function set_default_extensions_for_multisite_network_activated( $blog_id ) {
182
			switch_to_blog( $blog_id );
183
184
			if ( false === get_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, false ) ) {
185
				$api = new FooGallery_Extensions_API();
186
187
				$api->auto_activate_extensions();
188
189
				update_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, true );
190
			}
191
192
			restore_current_blog();
193
		}
194
195
		/**
196
		 * Fired when the plugin is activated.
197
		 *
198
		 * @since    1.0.0
199
		 *
200
		 * @param    boolean    $network_wide    True if WPMU superadmin uses
201
		 *                                       "Network Activate" action, false if
202
		 *                                       WPMU is disabled or plugin is
203
		 *                                       activated on an individual blog.
204
		 */
205
		public static function activate( $network_wide ) {
206
			if ( function_exists( 'is_multisite' ) && is_multisite() ) {
207
208
				if ( $network_wide  ) {
209
210
					// Get all blog ids
211
					$blog_ids = self::get_blog_ids();
212
					if ( is_array( $blog_ids ) ) {
213
						foreach ( $blog_ids as $blog_id ) {
214
215
							switch_to_blog( $blog_id );
216
							self::single_activate();
217
						}
218
219
						restore_current_blog();
220
					}
221
222
				} else {
223
					self::single_activate();
224
				}
225
226
			} else {
227
				self::single_activate( false );
228
			}
229
		}
230
231
		/**
232
		 * Fired for each blog when the plugin is activated.
233
		 *
234
		 * @since    1.0.0
235
		 */
236
		private static function single_activate( $multisite = true ) {
237
			if ( false === get_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, false ) ) {
238
				$api = new FooGallery_Extensions_API();
239
240
				$api->auto_activate_extensions();
241
242
				update_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, true );
243
			}
244
			if ( false === $multisite ) {
245
				//Make sure we redirect to the welcome page
246
				set_transient( FOOGALLERY_ACTIVATION_REDIRECT_TRANSIENT_KEY, true, 30 );
247
			}
248
249
			//force a version check on activation to make sure housekeeping is performed
250
			foogallery_perform_version_check();
251
		}
252
253
		/**
254
		 * Get all blog ids of blogs in the current network that are:
255
		 * - not archived
256
		 * - not spam
257
		 * - not deleted
258
		 *
259
		 * @since    1.0.0
260
		 *
261
		 * @return   array|false    The blog ids, false if no matches.
262
		 */
263
		private static function get_blog_ids() {
264
265
			if ( function_exists( 'wp_get_sites' ) ) {
266
267
				$sites = wp_get_sites();
268
				$blog_ids = array();
269
				foreach ( $sites as $site ) {
270
					$blog_ids[] = $site['blog_id'];
271
				}
272
				return $blog_ids;
273
			} else {
274
				//pre WP 3.7 - do this the old way!
275
				global $wpdb;
276
277
				// get an array of blog ids
278
				$sql = "SELECT blog_id FROM $wpdb->blogs WHERE archived = '0' AND spam = '0' AND deleted = '0'";
279
280
				return $wpdb->get_col( $sql );
281
			}
282
		}
283
	}
284
}
285
286
FooGallery_Plugin::get_instance();
287