@@ -20,13 +20,13 @@ |
||
| 20 | 20 | defined('ABSPATH') || exit; |
| 21 | 21 | |
| 22 | 22 | if (!class_exists('GL_Plugin_Check_v6')) { |
| 23 | - require_once __DIR__.'/activate.php'; |
|
| 23 | + require_once __DIR__.'/activate.php'; |
|
| 24 | 24 | } |
| 25 | 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 | - } |
|
| 31 | - (new GeminiLabs\BlackBar\Application())->init(); |
|
| 26 | + require_once __DIR__.'/autoload.php'; |
|
| 27 | + require_once __DIR__.'/compatibility.php'; |
|
| 28 | + if (!defined('SAVEQUERIES')) { |
|
| 29 | + define('SAVEQUERIES', 1); |
|
| 30 | + } |
|
| 31 | + (new GeminiLabs\BlackBar\Application())->init(); |
|
| 32 | 32 | } |
@@ -17,16 +17,16 @@ |
||
| 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 | } |
@@ -3,20 +3,20 @@ |
||
| 3 | 3 | defined('WPINC') || die; |
| 4 | 4 | |
| 5 | 5 | spl_autoload_register(function ($className) { |
| 6 | - $namespaces = [ |
|
| 7 | - 'GeminiLabs\\BlackBar\\' => __DIR__.'/plugin/', |
|
| 8 | - 'GeminiLabs\\BlackBar\\Tests\\' => __DIR__.'/tests/', |
|
| 9 | - ]; |
|
| 10 | - foreach ($namespaces as $prefix => $baseDir) { |
|
| 11 | - $len = strlen($prefix); |
|
| 12 | - if (0 !== strncmp($prefix, $className, $len)) { |
|
| 13 | - continue; |
|
| 14 | - } |
|
| 15 | - $file = $baseDir.str_replace('\\', '/', substr($className, $len)).'.php'; |
|
| 16 | - if (!file_exists($file)) { |
|
| 17 | - continue; |
|
| 18 | - } |
|
| 19 | - require $file; |
|
| 20 | - break; |
|
| 21 | - } |
|
| 6 | + $namespaces = [ |
|
| 7 | + 'GeminiLabs\\BlackBar\\' => __DIR__.'/plugin/', |
|
| 8 | + 'GeminiLabs\\BlackBar\\Tests\\' => __DIR__.'/tests/', |
|
| 9 | + ]; |
|
| 10 | + foreach ($namespaces as $prefix => $baseDir) { |
|
| 11 | + $len = strlen($prefix); |
|
| 12 | + if (0 !== strncmp($prefix, $className, $len)) { |
|
| 13 | + continue; |
|
| 14 | + } |
|
| 15 | + $file = $baseDir.str_replace('\\', '/', substr($className, $len)).'.php'; |
|
| 16 | + if (!file_exists($file)) { |
|
| 17 | + continue; |
|
| 18 | + } |
|
| 19 | + require $file; |
|
| 20 | + break; |
|
| 21 | + } |
|
| 22 | 22 | }); |
@@ -1,19 +1,19 @@ |
||
| 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; |
@@ -2,7 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | defined('WPINC') || die; |
| 4 | 4 | |
| 5 | -spl_autoload_register(function ($className) { |
|
| 5 | +spl_autoload_register(function ($className) |
|
| 6 | +{ |
|
| 6 | 7 | $namespaces = [ |
| 7 | 8 | 'GeminiLabs\\BlackBar\\' => __DIR__.'/plugin/', |
| 8 | 9 | 'GeminiLabs\\BlackBar\\Tests\\' => __DIR__.'/tests/', |
@@ -8,141 +8,141 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | class GL_Plugin_Check_v6 |
| 10 | 10 | { |
| 11 | - const MIN_PHP_VERSION = '7.2'; |
|
| 12 | - const MIN_WORDPRESS_VERSION = '5.8'; |
|
| 11 | + const MIN_PHP_VERSION = '7.2'; |
|
| 12 | + const MIN_WORDPRESS_VERSION = '5.8'; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * @var array |
|
| 16 | - */ |
|
| 17 | - public $versions; |
|
| 14 | + /** |
|
| 15 | + * @var array |
|
| 16 | + */ |
|
| 17 | + public $versions; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @var string |
|
| 21 | - */ |
|
| 22 | - protected $file; |
|
| 19 | + /** |
|
| 20 | + * @var string |
|
| 21 | + */ |
|
| 22 | + protected $file; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @param string $file |
|
| 26 | - */ |
|
| 27 | - public function __construct($file) |
|
| 28 | - { |
|
| 29 | - $this->file = realpath($file); |
|
| 30 | - $versionRequirements = get_file_data($this->file, [ |
|
| 31 | - 'php' => 'Requires PHP', |
|
| 32 | - 'wordpress' => 'Requires at least', |
|
| 33 | - ]); |
|
| 34 | - $this->versions = wp_parse_args(array_filter($versionRequirements), [ |
|
| 35 | - 'php' => static::MIN_PHP_VERSION, |
|
| 36 | - 'wordpress' => static::MIN_WORDPRESS_VERSION, |
|
| 37 | - ]); |
|
| 38 | - } |
|
| 24 | + /** |
|
| 25 | + * @param string $file |
|
| 26 | + */ |
|
| 27 | + public function __construct($file) |
|
| 28 | + { |
|
| 29 | + $this->file = realpath($file); |
|
| 30 | + $versionRequirements = get_file_data($this->file, [ |
|
| 31 | + 'php' => 'Requires PHP', |
|
| 32 | + 'wordpress' => 'Requires at least', |
|
| 33 | + ]); |
|
| 34 | + $this->versions = wp_parse_args(array_filter($versionRequirements), [ |
|
| 35 | + 'php' => static::MIN_PHP_VERSION, |
|
| 36 | + 'wordpress' => static::MIN_WORDPRESS_VERSION, |
|
| 37 | + ]); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @return bool |
|
| 42 | - */ |
|
| 43 | - public function canProceed() |
|
| 44 | - { |
|
| 45 | - if ($this->isValid()) { |
|
| 46 | - return true; |
|
| 47 | - } |
|
| 48 | - add_action('activated_plugin', [$this, 'deactivate']); |
|
| 49 | - add_action('admin_notices', [$this, 'deactivate']); |
|
| 50 | - return false; |
|
| 51 | - } |
|
| 40 | + /** |
|
| 41 | + * @return bool |
|
| 42 | + */ |
|
| 43 | + public function canProceed() |
|
| 44 | + { |
|
| 45 | + if ($this->isValid()) { |
|
| 46 | + return true; |
|
| 47 | + } |
|
| 48 | + add_action('activated_plugin', [$this, 'deactivate']); |
|
| 49 | + add_action('admin_notices', [$this, 'deactivate']); |
|
| 50 | + return false; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @return bool |
|
| 55 | - */ |
|
| 56 | - public function isPhpValid() |
|
| 57 | - { |
|
| 58 | - return version_compare(PHP_VERSION, $this->versions['php'], '>='); |
|
| 59 | - } |
|
| 53 | + /** |
|
| 54 | + * @return bool |
|
| 55 | + */ |
|
| 56 | + public function isPhpValid() |
|
| 57 | + { |
|
| 58 | + return version_compare(PHP_VERSION, $this->versions['php'], '>='); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @return bool |
|
| 63 | - */ |
|
| 64 | - public function isValid() |
|
| 65 | - { |
|
| 66 | - return $this->isPhpValid() && $this->isWpValid(); |
|
| 67 | - } |
|
| 61 | + /** |
|
| 62 | + * @return bool |
|
| 63 | + */ |
|
| 64 | + public function isValid() |
|
| 65 | + { |
|
| 66 | + return $this->isPhpValid() && $this->isWpValid(); |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * @return bool |
|
| 71 | - */ |
|
| 72 | - public function isWpValid() |
|
| 73 | - { |
|
| 74 | - global $wp_version; |
|
| 75 | - return version_compare($wp_version, $this->versions['wordpress'], '>='); |
|
| 76 | - } |
|
| 69 | + /** |
|
| 70 | + * @return bool |
|
| 71 | + */ |
|
| 72 | + public function isWpValid() |
|
| 73 | + { |
|
| 74 | + global $wp_version; |
|
| 75 | + return version_compare($wp_version, $this->versions['wordpress'], '>='); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * @param string $plugin |
|
| 80 | - * @return void |
|
| 81 | - */ |
|
| 82 | - public function deactivate($plugin) |
|
| 83 | - { |
|
| 84 | - if ($this->isValid()) { |
|
| 85 | - return; |
|
| 86 | - } |
|
| 87 | - $pluginSlug = plugin_basename($this->file); |
|
| 88 | - if ($plugin == $pluginSlug) { |
|
| 89 | - $this->redirect(); // exit |
|
| 90 | - } |
|
| 91 | - $pluginData = get_file_data($this->file, ['name' => 'Plugin Name'], 'plugin'); |
|
| 92 | - deactivate_plugins($pluginSlug); |
|
| 93 | - $this->printNotice($pluginData['name']); |
|
| 94 | - } |
|
| 78 | + /** |
|
| 79 | + * @param string $plugin |
|
| 80 | + * @return void |
|
| 81 | + */ |
|
| 82 | + public function deactivate($plugin) |
|
| 83 | + { |
|
| 84 | + if ($this->isValid()) { |
|
| 85 | + return; |
|
| 86 | + } |
|
| 87 | + $pluginSlug = plugin_basename($this->file); |
|
| 88 | + if ($plugin == $pluginSlug) { |
|
| 89 | + $this->redirect(); // exit |
|
| 90 | + } |
|
| 91 | + $pluginData = get_file_data($this->file, ['name' => 'Plugin Name'], 'plugin'); |
|
| 92 | + deactivate_plugins($pluginSlug); |
|
| 93 | + $this->printNotice($pluginData['name']); |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * @return array |
|
| 98 | - */ |
|
| 99 | - protected function getMessages() |
|
| 100 | - { |
|
| 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'), |
|
| 109 | - ]; |
|
| 110 | - } |
|
| 96 | + /** |
|
| 97 | + * @return array |
|
| 98 | + */ |
|
| 99 | + protected function getMessages() |
|
| 100 | + { |
|
| 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'), |
|
| 109 | + ]; |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - /** |
|
| 113 | - * @param string $pluginName |
|
| 114 | - * @return void |
|
| 115 | - */ |
|
| 116 | - protected function printNotice($pluginName) |
|
| 117 | - { |
|
| 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 | - $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 |
|
| 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']) |
|
| 132 | - ); |
|
| 133 | - } |
|
| 134 | - } |
|
| 112 | + /** |
|
| 113 | + * @param string $pluginName |
|
| 114 | + * @return void |
|
| 115 | + */ |
|
| 116 | + protected function printNotice($pluginName) |
|
| 117 | + { |
|
| 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 | + $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 |
|
| 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']) |
|
| 132 | + ); |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - /** |
|
| 137 | - * @return void |
|
| 138 | - */ |
|
| 139 | - protected function redirect() |
|
| 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 | - ))); |
|
| 146 | - exit; |
|
| 147 | - } |
|
| 136 | + /** |
|
| 137 | + * @return void |
|
| 138 | + */ |
|
| 139 | + protected function redirect() |
|
| 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 | + ))); |
|
| 146 | + exit; |
|
| 147 | + } |
|
| 148 | 148 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -124,7 +124,8 @@ |
||
| 124 | 124 | sprintf($messages['wrong_version'], $messages['php_version'].' '.$this->versions['php']), |
| 125 | 125 | sprintf($messages['update_php'], PHP_VERSION).'</p><p>'.$rollbackMessage |
| 126 | 126 | ); |
| 127 | - } elseif (!$this->isWpValid()) { |
|
| 127 | + } |
|
| 128 | + elseif (!$this->isWpValid()) { |
|
| 128 | 129 | printf($noticeTemplate, |
| 129 | 130 | sprintf($messages['notice'], $pluginName), |
| 130 | 131 | sprintf($messages['wrong_version'], $messages['wp_version'].' '.$this->versions['wordpress']), |