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 — feature/gallery-template-clien... ( b12418...8dad82 )
by Brad
02:54
created

FooGallery_Plugin::add_freemius_activation_menu()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 11
nc 2
nop 0
dl 0
loc 16
rs 9.4285
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 28.

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.11
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.11' );
26
	define( 'FOOGALLERY_SETTINGS_VERSION', '2' );
27
28
	require_once( FOOGALLERY_PATH . 'includes/constants.php' );
29
30
	// Create a helper function for easy SDK access.
31
	function foogallery_fs() {
32
		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...
33
34
		if ( ! isset( $foogallery_fs ) ) {
35
			// Include Freemius SDK.
36
			require_once dirname(__FILE__) . '/freemius/start.php';
37
38
			$foogallery_fs = fs_dynamic_init( array(
39
				'id'                => '843',
40
				'slug'              => 'foogallery',
41
				'type'              => 'plugin',
42
				'public_key'        => 'pk_d87616455a835af1d0658699d0192',
43
				'is_premium'        => false,
44
				'has_addons'        => false,
45
				'has_paid_plans'    => false,
46
				'menu'              => array(
47
					'slug'       => 'edit.php?post_type=' . FOOGALLERY_CPT_GALLERY,
48
					'first-path' => 'edit.php?post_type=' . FOOGALLERY_CPT_GALLERY . '&page=' . FOOGALLERY_ADMIN_MENU_HELP_SLUG,
49
					'account'    => false,
50
					'contact'    => false,
51
					'support'    => false,
52
				),
53
			) );
54
		}
55
56
		return $foogallery_fs;
57
	}
58
59
	// Init Freemius.
60
	foogallery_fs();
61
62
	// Signal that SDK was initiated.
63
	do_action( 'foogallery_fs_loaded' );
64
65
66
	require_once( FOOGALLERY_PATH . 'includes/foopluginbase/bootstrapper.php' );
67
68
	/**
69
	 * FooGallery_Plugin class
70
	 *
71
	 * @package   FooGallery
72
	 * @author    Brad Vincent <[email protected]>
73
	 * @license   GPL-2.0+
74
	 * @link      https://github.com/fooplugins/foogallery
75
	 * @copyright 2013 FooPlugins LLC
76
	 */
77
	class FooGallery_Plugin extends Foo_Plugin_Base_v2_4 {
78
79
		private static $instance;
80
81
		public static function get_instance() {
82
			if ( ! isset(self::$instance) && ! (self::$instance instanceof FooGallery_Plugin) ) {
83
				self::$instance = new FooGallery_Plugin();
84
			}
85
86
			return self::$instance;
87
		}
88
89
		/**
90
		 * Initialize the plugin by setting localization, filters, and administration functions.
91
		 */
92
		private function __construct() {
93
94
			//include everything we need!
95
			require_once( FOOGALLERY_PATH . 'includes/includes.php' );
96
97
			register_activation_hook( __FILE__, array( 'FooGallery_Plugin', 'activate' ) );
98
99
			//init FooPluginBase
100
			$this->init( FOOGALLERY_FILE, FOOGALLERY_SLUG, FOOGALLERY_VERSION, 'FooGallery' );
101
102
			//setup text domain
103
			$this->load_plugin_textdomain();
104
105
			//setup gallery post type
106
			new FooGallery_PostTypes();
107
108
			//load any extensions
109
			new FooGallery_Extensions_Loader();
110
111
			if ( is_admin() ) {
112
				new FooGallery_Admin();
113
				add_action( 'wpmu_new_blog', array( $this, 'set_default_extensions_for_multisite_network_activated' ) );
114
				add_action( 'admin_page_access_denied', array( $this, 'check_for_access_denied' ) );
115
				foogallery_fs()->add_filter( 'connect_message_on_update', array( $this, 'override_connect_message_on_update' ), 10, 6 );
116
				add_action( 'foogallery_admin_menu_before', array( $this, 'add_freemius_activation_menu' ) );
117
			} else {
118
				new FooGallery_Public();
119
			}
120
121
			new FooGallery_Thumbnails();
122
123
			new FooGallery_Polylang_Compatibility();
124
125
			new FooGallery_Attachment_Filters();
126
127
			new FooGallery_Retina();
128
129
			new FooGallery_WPThumb_Enhancements();
130
131
			new FooGallery_Animated_Gif_Support();
132
133
			new FooGallery_Cache();
134
135
			new FooGallery_LazyLoad();
136
137
			new FooGallery_Thumbnail_Dimensions();
138
139
			new FooGallery_FooBox_Support();
140
141
			new FooGallery_Responsive_Lightbox_dFactory_Support();
142
143
			new FooGallery_Attachment_Custom_Class();
144
145
			new FooGallery_Upgrade();
146
147
			$checker = new FooGallery_Version_Check();
148
			$checker->wire_up_checker();
149
		}
150
151
		/**
152
		 * Checks for the access denied page after we have activated/updated the plugin
153
		 */
154
		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...
155
			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...
156
157
			if ( FOOGALLERY_ADMIN_MENU_HELP_SLUG === $plugin_page ||
158
				FOOGALLERY_ADMIN_MENU_SETTINGS_SLUG === $plugin_page ||
159
				FOOGALLERY_ADMIN_MENU_EXTENSIONS_SLUG === $plugin_page ||
160
				FOOGALLERY_ADMIN_MENU_SYSTEMINFO_SLUG === $plugin_page) {
161
				fs_redirect( 'admin.php?page=' . FOOGALLERY_SLUG );
162
			}
163
		}
164
165
		/**
166
		 *
167
		 */
168
		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...
169
170
			return
171
				sprintf( __( 'Hey %s', 'foogallery' ), $first_name ) . '<br>' .
172
				sprintf(
173
					__( '<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' ),
174
					'<b>' . $plugin_name . '</b>',
175
					'<b>' . $login . '</b>',
176
					$link,
177
					$freemius_link,
178
					FOOGALLERY_VERSION
179
				);
180
		}
181
182
		function add_freemius_activation_menu() {
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...
183
			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...
184
185
			$parent_slug = foogallery_admin_menu_parent_slug();
186
187
			if ( ! $foogallery_fs->is_registered() ) {
188
				add_submenu_page(
189
					$parent_slug,
190
					__( 'FooGallery Opt-In', 'foogallery' ),
191
					__( 'Activation', 'foogallery' ),
192
					'manage_options',
193
					'foogallery-optin',
194
					array( $foogallery_fs, '_connect_page_render' )
195
				);
196
			}
197
		}
198
199
		/**
200
		 * Set default extensions when a new site is created in multisite and FooGallery is network activated
201
		 *
202
		 * @since 1.2.5
203
		 *
204
		 * @param int $blog_id The ID of the newly created site
205
		 */
206
		public function set_default_extensions_for_multisite_network_activated( $blog_id ) {
207
			switch_to_blog( $blog_id );
208
209
			if ( false === get_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, false ) ) {
210
				$api = new FooGallery_Extensions_API();
211
212
				$api->auto_activate_extensions();
213
214
				update_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, true );
215
			}
216
217
			restore_current_blog();
218
		}
219
220
		/**
221
		 * Fired when the plugin is activated.
222
		 *
223
		 * @since    1.0.0
224
		 *
225
		 * @param    boolean    $network_wide    True if WPMU superadmin uses
226
		 *                                       "Network Activate" action, false if
227
		 *                                       WPMU is disabled or plugin is
228
		 *                                       activated on an individual blog.
229
		 */
230
		public static function activate( $network_wide ) {
231
			if ( function_exists( 'is_multisite' ) && is_multisite() ) {
232
233
				if ( $network_wide  ) {
234
235
					// Get all blog ids
236
					$blog_ids = self::get_blog_ids();
237
					if ( is_array( $blog_ids ) ) {
238
						foreach ( $blog_ids as $blog_id ) {
239
240
							switch_to_blog( $blog_id );
241
							self::single_activate();
242
						}
243
244
						restore_current_blog();
245
					}
246
247
				} else {
248
					self::single_activate();
249
				}
250
251
			} else {
252
				self::single_activate( false );
253
			}
254
		}
255
256
		/**
257
		 * Fired for each blog when the plugin is activated.
258
		 *
259
		 * @since    1.0.0
260
		 */
261
		private static function single_activate( $multisite = true ) {
262
			if ( false === get_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, false ) ) {
263
				$api = new FooGallery_Extensions_API();
264
265
				$api->auto_activate_extensions();
266
267
				update_option( FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, true );
268
			}
269
			if ( false === $multisite ) {
270
				//Make sure we redirect to the welcome page
271
				set_transient( FOOGALLERY_ACTIVATION_REDIRECT_TRANSIENT_KEY, true, 30 );
272
			}
273
274
			//force a version check on activation to make sure housekeeping is performed
275
			foogallery_perform_version_check();
276
		}
277
278
		/**
279
		 * Get all blog ids of blogs in the current network that are:
280
		 * - not archived
281
		 * - not spam
282
		 * - not deleted
283
		 *
284
		 * @since    1.0.0
285
		 *
286
		 * @return   array|false    The blog ids, false if no matches.
287
		 */
288
		private static function get_blog_ids() {
289
290
			if ( function_exists( 'wp_get_sites' ) ) {
291
292
				$sites = wp_get_sites();
293
				$blog_ids = array();
294
				foreach ( $sites as $site ) {
295
					$blog_ids[] = $site['blog_id'];
296
				}
297
				return $blog_ids;
298
			} else {
299
				//pre WP 3.7 - do this the old way!
300
				global $wpdb;
301
302
				// get an array of blog ids
303
				$sql = "SELECT blog_id FROM $wpdb->blogs WHERE archived = '0' AND spam = '0' AND deleted = '0'";
304
305
				return $wpdb->get_col( $sql );
306
			}
307
		}
308
	}
309
}
310
311
FooGallery_Plugin::get_instance();
312