Passed
Push — master ( 389fdd...630338 )
by Paul
04:32
created
blackbar.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -17,16 +17,16 @@
 block discarded – undo
17 17
  * Text Domain:       blackbar
18 18
  * Domain Path:       languages
19 19
  */
20
-defined('ABSPATH') || exit;
20
+defined( 'ABSPATH' ) || exit;
21 21
 
22
-if (!class_exists('GL_Plugin_Check_v6')) {
23
-    require_once __DIR__.'/activate.php';
22
+if( !class_exists( 'GL_Plugin_Check_v6' ) ) {
23
+    require_once __DIR__ . '/activate.php';
24 24
 }
25
-if ((new GL_Plugin_Check_v6(__FILE__))->canProceed()) {
26
-    require_once __DIR__.'/autoload.php';
27
-    require_once __DIR__.'/compatibility.php';
28
-    if (!defined('SAVEQUERIES')) {
29
-        define('SAVEQUERIES', 1);
25
+if( ( new GL_Plugin_Check_v6( __FILE__ ) )->canProceed() ) {
26
+    require_once __DIR__ . '/autoload.php';
27
+    require_once __DIR__ . '/compatibility.php';
28
+    if( !defined( 'SAVEQUERIES' ) ) {
29
+        define( 'SAVEQUERIES', 1 );
30 30
     }
31
-    (new GeminiLabs\BlackBar\Application())->init();
31
+    ( new GeminiLabs\BlackBar\Application() )->init();
32 32
 }
Please login to merge, or discard this patch.
autoload.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-defined('WPINC') || die;
3
+defined( 'WPINC' ) || die;
4 4
 
5
-spl_autoload_register(function ($className) {
5
+spl_autoload_register( function( $className ) {
6 6
     $namespaces = [
7
-        'GeminiLabs\\BlackBar\\' => __DIR__.'/plugin/',
8
-        'GeminiLabs\\BlackBar\\Tests\\' => __DIR__.'/tests/',
7
+        'GeminiLabs\\BlackBar\\' => __DIR__ . '/plugin/',
8
+        'GeminiLabs\\BlackBar\\Tests\\' => __DIR__ . '/tests/',
9 9
     ];
10
-    foreach ($namespaces as $prefix => $baseDir) {
11
-        $len = strlen($prefix);
12
-        if (0 !== strncmp($prefix, $className, $len)) {
10
+    foreach( $namespaces as $prefix => $baseDir ) {
11
+        $len = strlen( $prefix );
12
+        if( 0 !== strncmp( $prefix, $className, $len ) ) {
13 13
             continue;
14 14
         }
15
-        $file = $baseDir.str_replace('\\', '/', substr($className, $len)).'.php';
16
-        if (!file_exists($file)) {
15
+        $file = $baseDir . str_replace( '\\', '/', substr( $className, $len ) ) . '.php';
16
+        if( !file_exists( $file ) ) {
17 17
             continue;
18 18
         }
19 19
         require $file;
Please login to merge, or discard this patch.
activate.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-defined('ABSPATH') || exit;
3
+defined( 'ABSPATH' ) || exit;
4 4
 
5 5
 /**
6 6
  * Check for minimum system requirements on plugin activation.
@@ -24,17 +24,17 @@  discard block
 block discarded – undo
24 24
     /**
25 25
      * @param string $file
26 26
      */
27
-    public function __construct($file)
27
+    public function __construct( $file )
28 28
     {
29
-        $this->file = realpath($file);
30
-        $versionRequirements = get_file_data($this->file, [
29
+        $this->file = realpath( $file );
30
+        $versionRequirements = get_file_data( $this->file, [
31 31
             'php' => 'Requires PHP',
32 32
             'wordpress' => 'Requires at least',
33
-        ]);
34
-        $this->versions = wp_parse_args(array_filter($versionRequirements), [
33
+        ] );
34
+        $this->versions = wp_parse_args( array_filter( $versionRequirements ), [
35 35
             'php' => static::MIN_PHP_VERSION,
36 36
             'wordpress' => static::MIN_WORDPRESS_VERSION,
37
-        ]);
37
+        ] );
38 38
     }
39 39
 
40 40
     /**
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function canProceed()
44 44
     {
45
-        if ($this->isValid()) {
45
+        if( $this->isValid() ) {
46 46
             return true;
47 47
         }
48
-        add_action('activated_plugin', [$this, 'deactivate']);
49
-        add_action('admin_notices', [$this, 'deactivate']);
48
+        add_action( 'activated_plugin', [ $this, 'deactivate' ] );
49
+        add_action( 'admin_notices', [ $this, 'deactivate' ] );
50 50
         return false;
51 51
     }
52 52
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
      */
56 56
     public function isPhpValid()
57 57
     {
58
-        return version_compare(PHP_VERSION, $this->versions['php'], '>=');
58
+        return version_compare( PHP_VERSION, $this->versions[ 'php' ], '>=' );
59 59
     }
60 60
 
61 61
     /**
@@ -72,25 +72,25 @@  discard block
 block discarded – undo
72 72
     public function isWpValid()
73 73
     {
74 74
         global $wp_version;
75
-        return version_compare($wp_version, $this->versions['wordpress'], '>=');
75
+        return version_compare( $wp_version, $this->versions[ 'wordpress' ], '>=' );
76 76
     }
77 77
 
78 78
     /**
79 79
      * @param string $plugin
80 80
      * @return void
81 81
      */
82
-    public function deactivate($plugin)
82
+    public function deactivate( $plugin )
83 83
     {
84
-        if ($this->isValid()) {
84
+        if( $this->isValid() ) {
85 85
             return;
86 86
         }
87
-        $pluginSlug = plugin_basename($this->file);
88
-        if ($plugin == $pluginSlug) {
87
+        $pluginSlug = plugin_basename( $this->file );
88
+        if( $plugin == $pluginSlug ) {
89 89
             $this->redirect(); // exit
90 90
         }
91
-        $pluginData = get_file_data($this->file, ['name' => 'Plugin Name'], 'plugin');
92
-        deactivate_plugins($pluginSlug);
93
-        $this->printNotice($pluginData['name']);
91
+        $pluginData = get_file_data( $this->file, [ 'name' => 'Plugin Name' ], 'plugin' );
92
+        deactivate_plugins( $pluginSlug );
93
+        $this->printNotice( $pluginData[ 'name' ] );
94 94
     }
95 95
 
96 96
     /**
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
     protected function getMessages()
100 100
     {
101 101
         return [
102
-            'notice' => _x('The %s plugin was deactivated.', 'admin-text', 'blackbar'),
103
-            'php_version' => _x('PHP version', 'admin-text', 'blackbar'),
104
-            'rollback' => _x('You can use the %s plugin to restore %s to the previous version.', 'admin-text', 'blackbar'),
105
-            'update_php' => _x('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.', 'admin-text', 'blackbar'),
106
-            'update_wp' => _x('Update WordPress', 'admin-text', 'blackbar'),
107
-            'wp_version' => _x('WordPress version', 'admin-text', 'blackbar'),
108
-            'wrong_version' => _x('This plugin requires %s or greater in order to work properly.', 'admin-text', 'blackbar'),
102
+            'notice' => _x( 'The %s plugin was deactivated.', 'admin-text', 'blackbar' ),
103
+            'php_version' => _x( 'PHP version', 'admin-text', 'blackbar' ),
104
+            'rollback' => _x( 'You can use the %s plugin to restore %s to the previous version.', 'admin-text', 'blackbar' ),
105
+            'update_php' => _x( '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.', 'admin-text', 'blackbar' ),
106
+            'update_wp' => _x( 'Update WordPress', 'admin-text', 'blackbar' ),
107
+            'wp_version' => _x( 'WordPress version', 'admin-text', 'blackbar' ),
108
+            'wrong_version' => _x( 'This plugin requires %s or greater in order to work properly.', 'admin-text', 'blackbar' ),
109 109
         ];
110 110
     }
111 111
 
@@ -113,22 +113,22 @@  discard block
 block discarded – undo
113 113
      * @param string $pluginName
114 114
      * @return void
115 115
      */
116
-    protected function printNotice($pluginName)
116
+    protected function printNotice( $pluginName )
117 117
     {
118 118
         $noticeTemplate = '<div id="message" class="notice notice-error error is-dismissible"><p><strong>%s</strong></p><p>%s</p><p>%s</p></div>';
119 119
         $messages = $this->getMessages();
120
-        $rollbackMessage = sprintf('<strong>'.$messages['rollback'].'</strong>', '<a href="https://wordpress.org/plugins/wp-rollback/" target="_blank">WP Rollback</a>', $pluginName);
121
-        if (!$this->isPhpValid()) {
122
-            printf($noticeTemplate,
123
-                sprintf($messages['notice'], $pluginName),
124
-                sprintf($messages['wrong_version'], $messages['php_version'].' '.$this->versions['php']),
125
-                sprintf($messages['update_php'], PHP_VERSION).'</p><p>'.$rollbackMessage
120
+        $rollbackMessage = sprintf( '<strong>' . $messages[ 'rollback' ] . '</strong>', '<a href="https://wordpress.org/plugins/wp-rollback/" target="_blank">WP Rollback</a>', $pluginName );
121
+        if( !$this->isPhpValid() ) {
122
+            printf( $noticeTemplate,
123
+                sprintf( $messages[ 'notice' ], $pluginName ),
124
+                sprintf( $messages[ 'wrong_version' ], $messages[ 'php_version' ] . ' ' . $this->versions[ 'php' ] ),
125
+                sprintf( $messages[ 'update_php' ], PHP_VERSION ) . '</p><p>' . $rollbackMessage
126 126
             );
127
-        } elseif (!$this->isWpValid()) {
128
-            printf($noticeTemplate,
129
-                sprintf($messages['notice'], $pluginName),
130
-                sprintf($messages['wrong_version'], $messages['wp_version'].' '.$this->versions['wordpress']),
131
-                $rollbackMessage.'</p><p>'.sprintf('<a href="%s">%s</a>', admin_url('update-core.php'), $messages['update_wp'])
127
+        } elseif( !$this->isWpValid() ) {
128
+            printf( $noticeTemplate,
129
+                sprintf( $messages[ 'notice' ], $pluginName ),
130
+                sprintf( $messages[ 'wrong_version' ], $messages[ 'wp_version' ] . ' ' . $this->versions[ 'wordpress' ] ),
131
+                $rollbackMessage . '</p><p>' . sprintf( '<a href="%s">%s</a>', admin_url( 'update-core.php' ), $messages[ 'update_wp' ] )
132 132
             );
133 133
         }
134 134
     }
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
      */
139 139
     protected function redirect()
140 140
     {
141
-        wp_safe_redirect(self_admin_url(sprintf('plugins.php?plugin_status=%s&paged=%s&s=%s',
142
-            filter_input(INPUT_GET, 'plugin_status'),
143
-            filter_input(INPUT_GET, 'paged'),
144
-            filter_input(INPUT_GET, 's')
145
-        )));
141
+        wp_safe_redirect( self_admin_url( sprintf( 'plugins.php?plugin_status=%s&paged=%s&s=%s',
142
+            filter_input( INPUT_GET, 'plugin_status' ),
143
+            filter_input( INPUT_GET, 'paged' ),
144
+            filter_input( INPUT_GET, 's' )
145
+        ) ) );
146 146
         exit;
147 147
     }
148 148
 }
Please login to merge, or discard this patch.