Test Setup Failed
Push — master ( 9b1a69...300ef2 )
by Paul
03:03
created
src/GateKeeper.php 3 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -124,6 +124,7 @@  discard block
 block discarded – undo
124 124
 	}
125 125
 
126 126
 	/**
127
+	 * @param string $plugin
127 128
 	 * @return bool
128 129
 	 */
129 130
 	public function hasDependency( $plugin )
@@ -384,6 +385,7 @@  discard block
 block discarded – undo
384 385
 	}
385 386
 
386 387
 	/**
388
+	 * @param string $key
387 389
 	 * @return array|string
388 390
 	 */
389 391
 	protected function getPluginRequirements( $plugin, $key = null )
Please login to merge, or discard this patch.
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 		'meta-box/meta-box.php' => 'Meta Box|4.11|https://wordpress.org/plugins/meta-box/',
15 15
 	];
16 16
 
17
-	public $errors = [];
17
+	public $errors = [ ];
18 18
 
19 19
 	/**
20 20
 	 * @var Notice
@@ -29,17 +29,17 @@  discard block
 block discarded – undo
29 29
 	public function __construct( $plugin )
30 30
 	{
31 31
 		$this->plugin = $plugin;
32
-		add_action( 'admin_init', [$this, 'init'] );
32
+		add_action( 'admin_init', [ $this, 'init' ] );
33 33
 	}
34 34
 
35 35
 	public function init()
36 36
 	{
37 37
 		$this->notice = pollux_app()->make( 'Notice' );
38 38
 
39
-		add_action( 'current_screen',                         [$this, 'activatePlugin'] );
40
-		add_action( 'wp_ajax_pollux/dependency/activate_url', [$this, 'ajaxActivatePluginLink'] );
41
-		add_action( 'admin_notices',                          [$this, 'printNotices'] );
42
-		add_action( 'current_screen',                         [$this, 'setDependencyNotice'] );
39
+		add_action( 'current_screen', [ $this, 'activatePlugin' ] );
40
+		add_action( 'wp_ajax_pollux/dependency/activate_url', [ $this, 'ajaxActivatePluginLink' ] );
41
+		add_action( 'admin_notices', [ $this, 'printNotices' ] );
42
+		add_action( 'current_screen', [ $this, 'setDependencyNotice' ] );
43 43
 	}
44 44
 
45 45
 	/**
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		$plugin = filter_input( INPUT_GET, 'plugin' );
54 54
 		check_admin_referer( 'activate-plugin_' . $plugin );
55 55
 		$result = activate_plugin( $plugin, null, is_network_admin(), true );
56
-		if( is_wp_error( $result )) {
56
+		if( is_wp_error( $result ) ) {
57 57
 			wp_die( $result->get_error_message() );
58 58
 		}
59 59
 		wp_safe_redirect( wp_get_referer() );
@@ -67,19 +67,19 @@  discard block
 block discarded – undo
67 67
 	{
68 68
 		check_ajax_referer( 'updates' );
69 69
 		$plugin = filter_input( INPUT_POST, 'plugin' );
70
-		if( !$this->isPluginDependency( $plugin )) {
70
+		if( !$this->isPluginDependency( $plugin ) ) {
71 71
 			wp_send_json_error();
72 72
 		}
73
-		$activateUrl = add_query_arg([
74
-			'_wpnonce' => wp_create_nonce( sprintf( 'activate-plugin_%s', $plugin )),
73
+		$activateUrl = add_query_arg( [
74
+			'_wpnonce' => wp_create_nonce( sprintf( 'activate-plugin_%s', $plugin ) ),
75 75
 			'action' => 'activate',
76 76
 			'page' => pollux_app()->id,
77 77
 			'plugin' => $plugin,
78
-		], self_admin_url( 'options-general.php' ));
79
-		wp_send_json_success([
78
+		], self_admin_url( 'options-general.php' ) );
79
+		wp_send_json_success( [
80 80
 			'activate_url' => $activateUrl,
81 81
 			filter_input( INPUT_POST, 'type' ) => $plugin,
82
-		]);
82
+		] );
83 83
 	}
84 84
 
85 85
 	/**
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	public function hasDependency( $plugin )
89 89
 	{
90
-		if( !$this->isPluginDependency( $plugin )) {
90
+		if( !$this->isPluginDependency( $plugin ) ) {
91 91
 			return true;
92 92
 		}
93 93
 		return $this->isPluginInstalled( $plugin ) && $this->isPluginValid( $plugin );
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	public function hasPendingDependencies()
100 100
 	{
101 101
 		foreach( static::DEPENDENCIES as $plugin => $data ) {
102
-			if( !$this->isPluginDependency( $plugin ))continue;
102
+			if( !$this->isPluginDependency( $plugin ) )continue;
103 103
 			$this->isPluginActive( $plugin );
104 104
 			$this->isPluginVersionValid( $plugin );
105 105
 		}
@@ -147,17 +147,17 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	public function isPluginVersionValid( $plugin )
149 149
 	{
150
-		if( !$this->isPluginDependency( $plugin )) {
150
+		if( !$this->isPluginDependency( $plugin ) ) {
151 151
 			return true;
152 152
 		}
153
-		if( !$this->isPluginInstalled( $plugin )) {
153
+		if( !$this->isPluginInstalled( $plugin ) ) {
154 154
 			return false;
155 155
 		}
156 156
 		return $this->catchError( $plugin, 'wrong_version', version_compare(
157 157
 			$this->getPluginRequirements( $plugin, 'version' ),
158
-			$this->getAllPlugins()[$plugin]['Version'],
158
+			$this->getAllPlugins()[ $plugin ][ 'Version' ],
159 159
 			'<='
160
-		));
160
+		) );
161 161
 	}
162 162
 
163 163
 	/**
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			__( 'Pollux requires the latest version of the following plugins', 'pollux' ),
184 184
 			$this->getDependencyLinks()
185 185
 		);
186
-		$this->notice->addWarning( [$message, $this->getDependencyActions()] );
186
+		$this->notice->addWarning( [ $message, $this->getDependencyActions() ] );
187 187
 	}
188 188
 
189 189
 	/**
@@ -194,13 +194,13 @@  discard block
 block discarded – undo
194 194
 	 */
195 195
 	protected function catchError( $plugin, $error, $isValid )
196 196
 	{
197
-		if( !$isValid && $this->isPluginDependency( $plugin )) {
198
-			if( !isset( $this->errors[$plugin] )) {
199
-				$this->errors[$plugin] = [];
197
+		if( !$isValid && $this->isPluginDependency( $plugin ) ) {
198
+			if( !isset( $this->errors[ $plugin ] ) ) {
199
+				$this->errors[ $plugin ] = [ ];
200 200
 			}
201
-			$this->errors[$plugin] = array_keys( array_flip(
202
-				array_merge( $this->errors[$plugin], [$error] )
203
-			));
201
+			$this->errors[ $plugin ] = array_keys( array_flip(
202
+				array_merge( $this->errors[ $plugin ], [ $error ] )
203
+			) );
204 204
 		}
205 205
 		return $isValid;
206 206
 	}
@@ -221,14 +221,14 @@  discard block
 block discarded – undo
221 221
 	{
222 222
 		$actions = '';
223 223
 		foreach( $this->errors as $plugin => $errors ) {
224
-			if( in_array( 'not_found', $errors ) && current_user_can( 'install_plugins' )) {
225
-				$actions .= $this->notice->installButton( $this->getPluginRequirements( $plugin ));
224
+			if( in_array( 'not_found', $errors ) && current_user_can( 'install_plugins' ) ) {
225
+				$actions .= $this->notice->installButton( $this->getPluginRequirements( $plugin ) );
226 226
 			}
227
-			else if( in_array( 'wrong_version', $errors ) && current_user_can( 'update_plugins' )) {
228
-				$actions .= $this->notice->updateButton( $this->getPluginInformation( $plugin ));
227
+			else if( in_array( 'wrong_version', $errors ) && current_user_can( 'update_plugins' ) ) {
228
+				$actions .= $this->notice->updateButton( $this->getPluginInformation( $plugin ) );
229 229
 			}
230
-			else if( in_array( 'inactive', $errors ) && current_user_can( 'activate_plugins' )) {
231
-				$actions .= $this->notice->activateButton( $this->getPluginInformation( $plugin ));
230
+			else if( in_array( 'inactive', $errors ) && current_user_can( 'activate_plugins' ) ) {
231
+				$actions .= $this->notice->activateButton( $this->getPluginInformation( $plugin ) );
232 232
 			}
233 233
 		}
234 234
 		return $actions;
@@ -250,10 +250,10 @@  discard block
 block discarded – undo
250 250
 	protected function getMustUsePlugins()
251 251
 	{
252 252
 		$plugins = get_mu_plugins();
253
-		if( in_array( 'Bedrock Autoloader', array_column( $plugins, 'Name' ))) {
253
+		if( in_array( 'Bedrock Autoloader', array_column( $plugins, 'Name' ) ) ) {
254 254
 			$autoloadedPlugins = get_site_option( 'bedrock_autoloader' );
255
-			if( !empty( $autoloadedPlugins['plugins'] )) {
256
-				return array_merge( $plugins, $autoloadedPlugins['plugins'] );
255
+			if( !empty( $autoloadedPlugins[ 'plugins' ] ) ) {
256
+				return array_merge( $plugins, $autoloadedPlugins[ 'plugins' ] );
257 257
 			}
258 258
 		}
259 259
 		return $plugins;
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
 	 */
265 265
 	protected function getPlugin( $plugin )
266 266
 	{
267
-		if( $this->isPluginInstalled( $plugin )) {
268
-			return $this->getAllPlugins()[$plugin];
267
+		if( $this->isPluginInstalled( $plugin ) ) {
268
+			return $this->getAllPlugins()[ $plugin ];
269 269
 		}
270 270
 		return false;
271 271
 	}
@@ -275,18 +275,18 @@  discard block
 block discarded – undo
275 275
 	 */
276 276
 	protected function getPluginData( $plugin, $data, $key = null )
277 277
 	{
278
-		if( !is_array( $data )) {
279
-			throw new Exception( sprintf( 'Plugin information not found for: %s', $plugin ));
278
+		if( !is_array( $data ) ) {
279
+			throw new Exception( sprintf( 'Plugin information not found for: %s', $plugin ) );
280 280
 		}
281
-		$data['plugin'] = $plugin;
282
-		$data['slug'] = $this->getPluginSlug( $plugin );
281
+		$data[ 'plugin' ] = $plugin;
282
+		$data[ 'slug' ] = $this->getPluginSlug( $plugin );
283 283
 		$data = array_change_key_case( $data );
284
-		if( is_null( $key )) {
284
+		if( is_null( $key ) ) {
285 285
 			return $data;
286 286
 		}
287 287
 		$key = strtolower( $key );
288
-		return isset( $data[$key] )
289
-			? $data[$key]
288
+		return isset( $data[ $key ] )
289
+			? $data[ $key ]
290 290
 			: '';
291 291
 	}
292 292
 
@@ -310,9 +310,9 @@  discard block
 block discarded – undo
310 310
 			$data = $this->getPluginRequirements( $plugin );
311 311
 		}
312 312
 		return sprintf( '<span class="plugin-%s"><a href="%s">%s</a></span>',
313
-			$data['slug'],
314
-			$data['pluginuri'],
315
-			$data['name']
313
+			$data[ 'slug' ],
314
+			$data[ 'pluginuri' ],
315
+			$data[ 'name' ]
316 316
 		);
317 317
 	}
318 318
 
@@ -321,9 +321,9 @@  discard block
 block discarded – undo
321 321
 	 */
322 322
 	protected function getPluginRequirements( $plugin, $key = null )
323 323
 	{
324
-		$keys = ['Name', 'Version', 'PluginURI'];
324
+		$keys = [ 'Name', 'Version', 'PluginURI' ];
325 325
 		$requirements = $this->isPluginDependency( $plugin )
326
-			? array_pad( explode( '|', static::DEPENDENCIES[$plugin] ), 3, '' )
326
+			? array_pad( explode( '|', static::DEPENDENCIES[ $plugin ] ), 3, '' )
327 327
 			: array_fill( 0, 3, '' );
328 328
 		return $this->getPluginData( $plugin, array_combine( $keys, $requirements ), $key );
329 329
 	}
@@ -333,6 +333,6 @@  discard block
 block discarded – undo
333 333
 	 */
334 334
 	protected function getPluginSlug( $plugin )
335 335
 	{
336
-		return substr( $plugin, 0, strrpos( $plugin, '/' ));
336
+		return substr( $plugin, 0, strrpos( $plugin, '/' ) );
337 337
 	}
338 338
 }
Please login to merge, or discard this patch.
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,7 +49,9 @@  discard block
 block discarded – undo
49 49
 	{
50 50
 		if( get_current_screen()->id != sprintf( 'settings_page_%s', pollux_app()->id )
51 51
 			|| filter_input( INPUT_GET, 'action' ) != 'activate'
52
-		)return;
52
+		) {
53
+			return;
54
+		}
53 55
 		$plugin = filter_input( INPUT_GET, 'plugin' );
54 56
 		check_admin_referer( 'activate-plugin_' . $plugin );
55 57
 		$result = activate_plugin( $plugin, null, is_network_admin(), true );
@@ -99,7 +101,9 @@  discard block
 block discarded – undo
99 101
 	public function hasPendingDependencies()
100 102
 	{
101 103
 		foreach( static::DEPENDENCIES as $plugin => $data ) {
102
-			if( !$this->isPluginDependency( $plugin ))continue;
104
+			if( !$this->isPluginDependency( $plugin )) {
105
+				continue;
106
+			}
103 107
 			$this->isPluginActive( $plugin );
104 108
 			$this->isPluginVersionValid( $plugin );
105 109
 		}
@@ -178,7 +182,9 @@  discard block
 block discarded – undo
178 182
 		if( get_current_screen()->id != 'settings_page_pollux'
179 183
 			|| pollux_app()->config->disable_config
180 184
 			|| !$this->hasPendingDependencies()
181
-		)return;
185
+		) {
186
+			return;
187
+		}
182 188
 		$message = sprintf( '<strong>%s:</strong> %s',
183 189
 			__( 'Pollux requires the latest version of the following plugins', 'pollux' ),
184 190
 			$this->getDependencyLinks()
@@ -239,7 +245,8 @@  discard block
 block discarded – undo
239 245
 	 */
240 246
 	protected function getDependencyLinks()
241 247
 	{
242
-		return array_reduce( array_keys( $this->errors ), function( $carry, $plugin ) {
248
+		return array_reduce( array_keys( $this->errors ), function( $carry, $plugin )
249
+		{
243 250
 			return $carry . $this->getPluginLink( $plugin );
244 251
 		});
245 252
 	}
Please login to merge, or discard this patch.
pollux.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -18,18 +18,18 @@
 block discarded – undo
18 18
 
19 19
 defined( 'WPINC' ) || die;
20 20
 
21
-require_once __DIR__.'/activate.php';
21
+require_once __DIR__ . '/activate.php';
22 22
 
23 23
 if( \Pollux_Activate::shouldDeactivate() )return;
24 24
 
25
-require_once __DIR__.'/autoload.php';
26
-require_once __DIR__.'/helpers.php';
27
-require_once __DIR__.'/thirdparty.php';
25
+require_once __DIR__ . '/autoload.php';
26
+require_once __DIR__ . '/helpers.php';
27
+require_once __DIR__ . '/thirdparty.php';
28 28
 
29 29
 $app = \GeminiLabs\Pollux\Application::getInstance();
30 30
 
31
-register_activation_hook( __FILE__, array( $app, 'onActivation' ));
32
-register_deactivation_hook( __FILE__, array( $app, 'onDeactivation' ));
31
+register_activation_hook( __FILE__, array( $app, 'onActivation' ) );
32
+register_deactivation_hook( __FILE__, array( $app, 'onDeactivation' ) );
33 33
 
34 34
 $app->register( new \GeminiLabs\Pollux\Provider );
35 35
 $app->init();
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@
 block discarded – undo
20 20
 
21 21
 require_once __DIR__.'/activate.php';
22 22
 
23
-if( \Pollux_Activate::shouldDeactivate() )return;
23
+if( \Pollux_Activate::shouldDeactivate() ) {
24
+	return;
25
+}
24 26
 
25 27
 require_once __DIR__.'/autoload.php';
26 28
 require_once __DIR__.'/helpers.php';
Please login to merge, or discard this patch.
activate.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public static function shouldDeactivate()
45 45
 	{
46
-		if( empty( static::$instance )) {
46
+		if( empty( static::$instance ) ) {
47 47
 			static::$instance = new static;
48 48
 		}
49 49
 		if( !static::isValid() ) {
50
-			add_action( 'activated_plugin', array( static::$instance, 'deactivate' ));
51
-			add_action( 'admin_notices', array( static::$instance, 'deactivate' ));
50
+			add_action( 'activated_plugin', array( static::$instance, 'deactivate' ) );
51
+			add_action( 'admin_notices', array( static::$instance, 'deactivate' ) );
52 52
 			return true;
53 53
 		}
54 54
 		return false;
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	public function deactivate( $plugin )
61 61
 	{
62 62
 		if( static::isValid() )return;
63
-		$pluginName = plugin_basename( dirname( realpath( __FILE__ )).'/'.static::BASENAME );
63
+		$pluginName = plugin_basename( dirname( realpath( __FILE__ ) ) . '/' . static::BASENAME );
64 64
 		if( $plugin == $pluginName ) {
65 65
 			$this->redirect(); //exit
66 66
 		}
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			filter_input( INPUT_GET, 'plugin_status' ),
78 78
 			filter_input( INPUT_GET, 'paged' ),
79 79
 			filter_input( INPUT_GET, 's' )
80
-		)));
80
+		) ) );
81 81
 		exit;
82 82
 	}
83 83
 
@@ -91,22 +91,22 @@  discard block
 block discarded – undo
91 91
 			__( 'The Pollux plugin was deactivated.', 'pollux' ),
92 92
 			__( 'Sorry, this plugin requires %s or greater in order to work properly.', 'pollux' ),
93 93
 			__( 'Please contact your hosting provider or server administrator to upgrade the version of PHP on your server (your server is running PHP version %s), or try to find an alternative plugin.', 'pollux' ),
94
-			__( 'PHP version', 'pollux' ).' '.static::MIN_PHP_VERSION,
95
-			__( 'WordPress version', 'pollux' ).' '.static::MIN_WORDPRESS_VERSION,
94
+			__( 'PHP version', 'pollux' ) . ' ' . static::MIN_PHP_VERSION,
95
+			__( 'WordPress version', 'pollux' ) . ' ' . static::MIN_WORDPRESS_VERSION,
96 96
 			__( 'Update WordPress', 'pollux' ),
97 97
 		);
98 98
 		if( !static::isPhpValid() ) {
99 99
 			printf( $noticeTemplate,
100
-				$messages[0],
101
-				sprintf( $messages[1], $messages[3] ),
102
-				sprintf( $messages[2], PHP_VERSION )
100
+				$messages[ 0 ],
101
+				sprintf( $messages[ 1 ], $messages[ 3 ] ),
102
+				sprintf( $messages[ 2 ], PHP_VERSION )
103 103
 			);
104 104
 		}
105 105
 		else if( !static::isWpValid() ) {
106 106
 			printf( $noticeTemplate,
107
-				$messages[0],
108
-				sprintf( $messages[1], $messages[4] ),
109
-				sprintf( '<a href="%s">%s</a>', admin_url( 'update-core.php' ), $messages[5] )
107
+				$messages[ 0 ],
108
+				sprintf( $messages[ 1 ], $messages[ 4 ] ),
109
+				sprintf( '<a href="%s">%s</a>', admin_url( 'update-core.php' ), $messages[ 5 ] )
110 110
 			);
111 111
 		}
112 112
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,9 @@
 block discarded – undo
59 59
 	 */
60 60
 	public function deactivate( $plugin )
61 61
 	{
62
-		if( static::isValid() )return;
62
+		if( static::isValid() ) {
63
+			return;
64
+		}
63 65
 		$pluginName = plugin_basename( dirname( realpath( __FILE__ )).'/'.static::BASENAME );
64 66
 		if( $plugin == $pluginName ) {
65 67
 			$this->redirect(); //exit
Please login to merge, or discard this patch.