| @@ -7,8 +7,8 @@ discard block | ||
| 7 | 7 | * @see https://docs.gravityforms.com/gform_noconflict_scripts/ | 
| 8 | 8 | */ | 
| 9 | 9 |  add_filter('gform_noconflict_scripts', function (array $scripts) { | 
| 10 | - $scripts[] = 'blackbar'; | |
| 11 | - return $scripts; | |
| 10 | + $scripts[] = 'blackbar'; | |
| 11 | + return $scripts; | |
| 12 | 12 | }); | 
| 13 | 13 | |
| 14 | 14 | /* | 
| @@ -16,7 +16,7 @@ discard block | ||
| 16 | 16 | * @see https://docs.gravityforms.com/gform_noconflict_styles/ | 
| 17 | 17 | */ | 
| 18 | 18 |  add_filter('gform_noconflict_styles', function (array $styles) { | 
| 19 | - $styles[] = 'blackbar'; | |
| 20 | - $styles[] = 'blackbar-syntax'; | |
| 21 | - return $styles; | |
| 19 | + $styles[] = 'blackbar'; | |
| 20 | + $styles[] = 'blackbar-syntax'; | |
| 21 | + return $styles; | |
| 22 | 22 | }); | 
| @@ -1,13 +1,13 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -defined('WPINC') || die; | |
| 3 | +defined( 'WPINC' ) || die; | |
| 4 | 4 | |
| 5 | 5 | /* | 
| 6 | 6 | * @return array | 
| 7 | 7 | * @see https://docs.gravityforms.com/gform_noconflict_scripts/ | 
| 8 | 8 | */ | 
| 9 | -add_filter('gform_noconflict_scripts', function (array $scripts) { | |
| 10 | - $scripts[] = 'blackbar'; | |
| 9 | +add_filter( 'gform_noconflict_scripts', function( array $scripts ) { | |
| 10 | + $scripts[ ] = 'blackbar'; | |
| 11 | 11 | return $scripts; | 
| 12 | 12 | }); | 
| 13 | 13 | |
| @@ -15,8 +15,8 @@ discard block | ||
| 15 | 15 | * @return array | 
| 16 | 16 | * @see https://docs.gravityforms.com/gform_noconflict_styles/ | 
| 17 | 17 | */ | 
| 18 | -add_filter('gform_noconflict_styles', function (array $styles) { | |
| 19 | - $styles[] = 'blackbar'; | |
| 20 | - $styles[] = 'blackbar-syntax'; | |
| 18 | +add_filter( 'gform_noconflict_styles', function( array $styles ) { | |
| 19 | + $styles[ ] = 'blackbar'; | |
| 20 | + $styles[ ] = 'blackbar-syntax'; | |
| 21 | 21 | return $styles; | 
| 22 | 22 | }); | 
| @@ -6,7 +6,8 @@ discard block | ||
| 6 | 6 | * @return array | 
| 7 | 7 | * @see https://docs.gravityforms.com/gform_noconflict_scripts/ | 
| 8 | 8 | */ | 
| 9 | -add_filter('gform_noconflict_scripts', function (array $scripts) { | |
| 9 | +add_filter('gform_noconflict_scripts', function (array $scripts) | |
| 10 | +{ | |
| 10 | 11 | $scripts[] = 'blackbar'; | 
| 11 | 12 | return $scripts; | 
| 12 | 13 | }); | 
| @@ -15,7 +16,8 @@ discard block | ||
| 15 | 16 | * @return array | 
| 16 | 17 | * @see https://docs.gravityforms.com/gform_noconflict_styles/ | 
| 17 | 18 | */ | 
| 18 | -add_filter('gform_noconflict_styles', function (array $styles) { | |
| 19 | +add_filter('gform_noconflict_styles', function (array $styles) | |
| 20 | +{ | |
| 19 | 21 | $styles[] = 'blackbar'; | 
| 20 | 22 | $styles[] = 'blackbar-syntax'; | 
| 21 | 23 | return $styles; | 
| @@ -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']), | 
| @@ -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 | - GeminiLabs\BlackBar\Application::load()->init(); | |
| 26 | + require_once __DIR__.'/autoload.php'; | |
| 27 | + require_once __DIR__.'/compatibility.php'; | |
| 28 | +	if (!defined('SAVEQUERIES')) { | |
| 29 | +		define('SAVEQUERIES', 1); | |
| 30 | + } | |
| 31 | + GeminiLabs\BlackBar\Application::load()->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 | 31 | GeminiLabs\BlackBar\Application::load()->init(); | 
| 32 | 32 | } | 
| @@ -11,93 +11,93 @@ | ||
| 11 | 11 | |
| 12 | 12 | final class Application | 
| 13 | 13 |  { | 
| 14 | - const CONSOLE_HOOK = 'console'; | |
| 15 | - const ID = 'blackbar'; | |
| 16 | - const PROFILER_HOOK = 'profile'; | |
| 14 | + const CONSOLE_HOOK = 'console'; | |
| 15 | + const ID = 'blackbar'; | |
| 16 | + const PROFILER_HOOK = 'profile'; | |
| 17 | 17 | |
| 18 | - public $actions; | |
| 19 | - public $console; | |
| 20 | - public $file; | |
| 21 | - public $globals; | |
| 22 | - public $profiler; | |
| 23 | - public $queries; | |
| 24 | - public $templates; | |
| 18 | + public $actions; | |
| 19 | + public $console; | |
| 20 | + public $file; | |
| 21 | + public $globals; | |
| 22 | + public $profiler; | |
| 23 | + public $queries; | |
| 24 | + public $templates; | |
| 25 | 25 | |
| 26 | - protected static $instance; | |
| 26 | + protected static $instance; | |
| 27 | 27 | |
| 28 | - public function __construct() | |
| 29 | -    { | |
| 30 | - $file = wp_normalize_path((new \ReflectionClass($this))->getFileName()); | |
| 31 | - $this->actions = new Actions($this); | |
| 32 | - $this->console = new Console($this); | |
| 33 | -        $this->file = str_replace('plugin/Application', static::ID, $file); | |
| 34 | - $this->globals = new Globals($this); | |
| 35 | - $this->profiler = new Profiler($this); | |
| 36 | - $this->queries = new Queries($this); | |
| 37 | - $this->templates = new Templates($this); | |
| 38 | - } | |
| 28 | + public function __construct() | |
| 29 | +	{ | |
| 30 | + $file = wp_normalize_path((new \ReflectionClass($this))->getFileName()); | |
| 31 | + $this->actions = new Actions($this); | |
| 32 | + $this->console = new Console($this); | |
| 33 | +		$this->file = str_replace('plugin/Application', static::ID, $file); | |
| 34 | + $this->globals = new Globals($this); | |
| 35 | + $this->profiler = new Profiler($this); | |
| 36 | + $this->queries = new Queries($this); | |
| 37 | + $this->templates = new Templates($this); | |
| 38 | + } | |
| 39 | 39 | |
| 40 | - public function errorHandler(int $errno, string $message, string $file, int $line): bool | |
| 41 | -    { | |
| 42 | - $path = explode(ABSPATH, $file); | |
| 43 | -        $location = sprintf('%s:%s', array_pop($path), $line); | |
| 44 | - $this->console->store($message, (string) $errno, $location); | |
| 45 | - return true; | |
| 46 | - } | |
| 40 | + public function errorHandler(int $errno, string $message, string $file, int $line): bool | |
| 41 | +	{ | |
| 42 | + $path = explode(ABSPATH, $file); | |
| 43 | +		$location = sprintf('%s:%s', array_pop($path), $line); | |
| 44 | + $this->console->store($message, (string) $errno, $location); | |
| 45 | + return true; | |
| 46 | + } | |
| 47 | 47 | |
| 48 | - public function init(): void | |
| 49 | -    { | |
| 50 | - $controller = new Controller($this); | |
| 51 | -        add_action('all', [$controller, 'initActions']); | |
| 52 | -        add_action('all', [$controller, 'initConsole']); | |
| 53 | -        add_action('all', [$controller, 'initProfiler']); | |
| 54 | -        add_action('plugins_loaded', [$controller, 'registerLanguages']); | |
| 55 | -        add_action('init', function () use ($controller) { | |
| 56 | -            if (!apply_filters('blackbar/enabled', current_user_can('administrator'))) { | |
| 57 | - return; | |
| 58 | - } | |
| 59 | -            add_action('admin_enqueue_scripts', [$controller, 'enqueueAssets']); | |
| 60 | -            add_action('wp_enqueue_scripts', [$controller, 'enqueueAssets']); | |
| 61 | -            add_action('admin_footer', [$controller, 'renderBar'], 99999); | |
| 62 | -            add_action('wp_footer', [$controller, 'renderBar'], 99999); | |
| 63 | -            add_filter('admin_body_class', [$controller, 'filterBodyClasses']); | |
| 64 | - }); | |
| 65 | -        apply_filters('debug', 'Profiler Started'); | |
| 66 | -        apply_filters('debug', 'blackbar/profiler/noise'); | |
| 67 | - set_error_handler([$this, 'errorHandler'], E_ALL | E_STRICT); | |
| 68 | - } | |
| 48 | + public function init(): void | |
| 49 | +	{ | |
| 50 | + $controller = new Controller($this); | |
| 51 | +		add_action('all', [$controller, 'initActions']); | |
| 52 | +		add_action('all', [$controller, 'initConsole']); | |
| 53 | +		add_action('all', [$controller, 'initProfiler']); | |
| 54 | +		add_action('plugins_loaded', [$controller, 'registerLanguages']); | |
| 55 | +		add_action('init', function () use ($controller) { | |
| 56 | +			if (!apply_filters('blackbar/enabled', current_user_can('administrator'))) { | |
| 57 | + return; | |
| 58 | + } | |
| 59 | +			add_action('admin_enqueue_scripts', [$controller, 'enqueueAssets']); | |
| 60 | +			add_action('wp_enqueue_scripts', [$controller, 'enqueueAssets']); | |
| 61 | +			add_action('admin_footer', [$controller, 'renderBar'], 99999); | |
| 62 | +			add_action('wp_footer', [$controller, 'renderBar'], 99999); | |
| 63 | +			add_filter('admin_body_class', [$controller, 'filterBodyClasses']); | |
| 64 | + }); | |
| 65 | +		apply_filters('debug', 'Profiler Started'); | |
| 66 | +		apply_filters('debug', 'blackbar/profiler/noise'); | |
| 67 | + set_error_handler([$this, 'errorHandler'], E_ALL | E_STRICT); | |
| 68 | + } | |
| 69 | 69 | |
| 70 | - /** | |
| 71 | - * @return static | |
| 72 | - */ | |
| 73 | - public static function load() | |
| 74 | -    { | |
| 75 | -        if (empty(static::$instance)) { | |
| 76 | - static::$instance = new static(); | |
| 77 | - } | |
| 78 | - return static::$instance; | |
| 79 | - } | |
| 70 | + /** | |
| 71 | + * @return static | |
| 72 | + */ | |
| 73 | + public static function load() | |
| 74 | +	{ | |
| 75 | +		if (empty(static::$instance)) { | |
| 76 | + static::$instance = new static(); | |
| 77 | + } | |
| 78 | + return static::$instance; | |
| 79 | + } | |
| 80 | 80 | |
| 81 | - public function path(string $file = '', bool $realpath = true): string | |
| 82 | -    { | |
| 83 | - $path = $realpath | |
| 84 | - ? plugin_dir_path($this->file) | |
| 85 | - : trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file)); | |
| 86 | - return trailingslashit($path).ltrim(trim($file), '/'); | |
| 87 | - } | |
| 81 | + public function path(string $file = '', bool $realpath = true): string | |
| 82 | +	{ | |
| 83 | + $path = $realpath | |
| 84 | + ? plugin_dir_path($this->file) | |
| 85 | + : trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file)); | |
| 86 | + return trailingslashit($path).ltrim(trim($file), '/'); | |
| 87 | + } | |
| 88 | 88 | |
| 89 | - public function render(string $view, array $data = []): void | |
| 90 | -    { | |
| 91 | -        $file = $this->path(sprintf('views/%s.php', str_replace('.php', '', $view))); | |
| 92 | -        if (!file_exists($file)) { | |
| 93 | - return; | |
| 94 | - } | |
| 95 | - extract($data); | |
| 96 | - include $file; | |
| 97 | - } | |
| 89 | + public function render(string $view, array $data = []): void | |
| 90 | +	{ | |
| 91 | +		$file = $this->path(sprintf('views/%s.php', str_replace('.php', '', $view))); | |
| 92 | +		if (!file_exists($file)) { | |
| 93 | + return; | |
| 94 | + } | |
| 95 | + extract($data); | |
| 96 | + include $file; | |
| 97 | + } | |
| 98 | 98 | |
| 99 | - public function url(string $path = ''): string | |
| 100 | -    { | |
| 101 | - return esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/')); | |
| 102 | - } | |
| 99 | + public function url(string $path = ''): string | |
| 100 | +	{ | |
| 101 | + return esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/')); | |
| 102 | + } | |
| 103 | 103 | } | 
| @@ -27,44 +27,44 @@ discard block | ||
| 27 | 27 | |
| 28 | 28 | public function __construct() | 
| 29 | 29 |      { | 
| 30 | - $file = wp_normalize_path((new \ReflectionClass($this))->getFileName()); | |
| 31 | - $this->actions = new Actions($this); | |
| 32 | - $this->console = new Console($this); | |
| 33 | -        $this->file = str_replace('plugin/Application', static::ID, $file); | |
| 34 | - $this->globals = new Globals($this); | |
| 35 | - $this->profiler = new Profiler($this); | |
| 36 | - $this->queries = new Queries($this); | |
| 37 | - $this->templates = new Templates($this); | |
| 30 | + $file = wp_normalize_path( ( new \ReflectionClass( $this ) )->getFileName() ); | |
| 31 | + $this->actions = new Actions( $this ); | |
| 32 | + $this->console = new Console( $this ); | |
| 33 | + $this->file = str_replace( 'plugin/Application', static::ID, $file ); | |
| 34 | + $this->globals = new Globals( $this ); | |
| 35 | + $this->profiler = new Profiler( $this ); | |
| 36 | + $this->queries = new Queries( $this ); | |
| 37 | + $this->templates = new Templates( $this ); | |
| 38 | 38 | } | 
| 39 | 39 | |
| 40 | - public function errorHandler(int $errno, string $message, string $file, int $line): bool | |
| 40 | + public function errorHandler( int $errno, string $message, string $file, int $line ): bool | |
| 41 | 41 |      { | 
| 42 | - $path = explode(ABSPATH, $file); | |
| 43 | -        $location = sprintf('%s:%s', array_pop($path), $line); | |
| 44 | - $this->console->store($message, (string) $errno, $location); | |
| 42 | + $path = explode( ABSPATH, $file ); | |
| 43 | + $location = sprintf( '%s:%s', array_pop( $path ), $line ); | |
| 44 | + $this->console->store( $message, (string) $errno, $location ); | |
| 45 | 45 | return true; | 
| 46 | 46 | } | 
| 47 | 47 | |
| 48 | 48 | public function init(): void | 
| 49 | 49 |      { | 
| 50 | - $controller = new Controller($this); | |
| 51 | -        add_action('all', [$controller, 'initActions']); | |
| 52 | -        add_action('all', [$controller, 'initConsole']); | |
| 53 | -        add_action('all', [$controller, 'initProfiler']); | |
| 54 | -        add_action('plugins_loaded', [$controller, 'registerLanguages']); | |
| 55 | -        add_action('init', function () use ($controller) { | |
| 56 | -            if (!apply_filters('blackbar/enabled', current_user_can('administrator'))) { | |
| 50 | + $controller = new Controller( $this ); | |
| 51 | + add_action( 'all', [ $controller, 'initActions' ] ); | |
| 52 | + add_action( 'all', [ $controller, 'initConsole' ] ); | |
| 53 | + add_action( 'all', [ $controller, 'initProfiler' ] ); | |
| 54 | + add_action( 'plugins_loaded', [ $controller, 'registerLanguages' ] ); | |
| 55 | +        add_action( 'init', function() use ( $controller ) { | |
| 56 | +            if( !apply_filters( 'blackbar/enabled', current_user_can( 'administrator' ) ) ) { | |
| 57 | 57 | return; | 
| 58 | 58 | } | 
| 59 | -            add_action('admin_enqueue_scripts', [$controller, 'enqueueAssets']); | |
| 60 | -            add_action('wp_enqueue_scripts', [$controller, 'enqueueAssets']); | |
| 61 | -            add_action('admin_footer', [$controller, 'renderBar'], 99999); | |
| 62 | -            add_action('wp_footer', [$controller, 'renderBar'], 99999); | |
| 63 | -            add_filter('admin_body_class', [$controller, 'filterBodyClasses']); | |
| 59 | + add_action( 'admin_enqueue_scripts', [ $controller, 'enqueueAssets' ] ); | |
| 60 | + add_action( 'wp_enqueue_scripts', [ $controller, 'enqueueAssets' ] ); | |
| 61 | + add_action( 'admin_footer', [ $controller, 'renderBar' ], 99999 ); | |
| 62 | + add_action( 'wp_footer', [ $controller, 'renderBar' ], 99999 ); | |
| 63 | + add_filter( 'admin_body_class', [ $controller, 'filterBodyClasses' ] ); | |
| 64 | 64 | }); | 
| 65 | -        apply_filters('debug', 'Profiler Started'); | |
| 66 | -        apply_filters('debug', 'blackbar/profiler/noise'); | |
| 67 | - set_error_handler([$this, 'errorHandler'], E_ALL | E_STRICT); | |
| 65 | + apply_filters( 'debug', 'Profiler Started' ); | |
| 66 | + apply_filters( 'debug', 'blackbar/profiler/noise' ); | |
| 67 | + set_error_handler( [ $this, 'errorHandler' ], E_ALL | E_STRICT ); | |
| 68 | 68 | } | 
| 69 | 69 | |
| 70 | 70 | /** | 
| @@ -72,32 +72,32 @@ discard block | ||
| 72 | 72 | */ | 
| 73 | 73 | public static function load() | 
| 74 | 74 |      { | 
| 75 | -        if (empty(static::$instance)) { | |
| 75 | +        if( empty( static::$instance ) ) { | |
| 76 | 76 | static::$instance = new static(); | 
| 77 | 77 | } | 
| 78 | 78 | return static::$instance; | 
| 79 | 79 | } | 
| 80 | 80 | |
| 81 | - public function path(string $file = '', bool $realpath = true): string | |
| 81 | + public function path( string $file = '', bool $realpath = true ): string | |
| 82 | 82 |      { | 
| 83 | 83 | $path = $realpath | 
| 84 | - ? plugin_dir_path($this->file) | |
| 85 | - : trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file)); | |
| 86 | - return trailingslashit($path).ltrim(trim($file), '/'); | |
| 84 | + ? plugin_dir_path( $this->file ) | |
| 85 | + : trailingslashit( WP_PLUGIN_DIR ) . basename( dirname( $this->file ) ); | |
| 86 | + return trailingslashit( $path ) . ltrim( trim( $file ), '/' ); | |
| 87 | 87 | } | 
| 88 | 88 | |
| 89 | - public function render(string $view, array $data = []): void | |
| 89 | + public function render( string $view, array $data = [ ] ): void | |
| 90 | 90 |      { | 
| 91 | -        $file = $this->path(sprintf('views/%s.php', str_replace('.php', '', $view))); | |
| 92 | -        if (!file_exists($file)) { | |
| 91 | + $file = $this->path( sprintf( 'views/%s.php', str_replace( '.php', '', $view ) ) ); | |
| 92 | +        if( !file_exists( $file ) ) { | |
| 93 | 93 | return; | 
| 94 | 94 | } | 
| 95 | - extract($data); | |
| 95 | + extract( $data ); | |
| 96 | 96 | include $file; | 
| 97 | 97 | } | 
| 98 | 98 | |
| 99 | - public function url(string $path = ''): string | |
| 99 | + public function url( string $path = '' ): string | |
| 100 | 100 |      { | 
| 101 | - return esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/')); | |
| 101 | + return esc_url( plugin_dir_url( $this->file ) . ltrim( trim( $path ), '/' ) ); | |
| 102 | 102 | } | 
| 103 | 103 | } | 
| @@ -52,7 +52,8 @@ | ||
| 52 | 52 |          add_action('all', [$controller, 'initConsole']); | 
| 53 | 53 |          add_action('all', [$controller, 'initProfiler']); | 
| 54 | 54 |          add_action('plugins_loaded', [$controller, 'registerLanguages']); | 
| 55 | -        add_action('init', function () use ($controller) { | |
| 55 | +        add_action('init', function () use ($controller) | |
| 56 | +        { | |
| 56 | 57 |              if (!apply_filters('blackbar/enabled', current_user_can('administrator'))) { | 
| 57 | 58 | return; | 
| 58 | 59 | } | 
| @@ -6,79 +6,79 @@ | ||
| 6 | 6 | |
| 7 | 7 | class Globals implements Module | 
| 8 | 8 |  { | 
| 9 | - /** | |
| 10 | - * @var Application | |
| 11 | - */ | |
| 12 | - protected $app; | |
| 13 | - /** | |
| 14 | - * @var array | |
| 15 | - */ | |
| 16 | - protected $entries; | |
| 9 | + /** | |
| 10 | + * @var Application | |
| 11 | + */ | |
| 12 | + protected $app; | |
| 13 | + /** | |
| 14 | + * @var array | |
| 15 | + */ | |
| 16 | + protected $entries; | |
| 17 | 17 | |
| 18 | - public function __construct(Application $app) | |
| 19 | -    { | |
| 20 | - $this->app = $app; | |
| 21 | - $this->entries = []; | |
| 22 | - } | |
| 18 | + public function __construct(Application $app) | |
| 19 | +	{ | |
| 20 | + $this->app = $app; | |
| 21 | + $this->entries = []; | |
| 22 | + } | |
| 23 | 23 | |
| 24 | - public function entries(): array | |
| 25 | -    { | |
| 26 | -        if (!empty($this->entries)) { | |
| 27 | - return $this->entries; | |
| 28 | - } | |
| 29 | -        if (is_admin() && $screen = get_current_screen()) { | |
| 30 | - $reflection = new \ReflectionClass($screen); | |
| 31 | - $properties = $reflection->getProperties(\ReflectionProperty::IS_PUBLIC); | |
| 32 | - $values = []; | |
| 33 | -            foreach ($properties as $property) { | |
| 34 | - $values[$property->getName()] = $property->getValue($screen); | |
| 35 | - } | |
| 36 | - $this->entries[] = [ | |
| 37 | - 'name' => 'WP_Screen', | |
| 38 | - 'value' => var_export($values, true), | |
| 39 | - ]; | |
| 40 | - } | |
| 41 | - $this->entries[] = [ | |
| 42 | - 'name' => '$_GET', | |
| 43 | - 'value' => var_export($_GET, true), | |
| 44 | - ]; | |
| 45 | - $this->entries[] = [ | |
| 46 | - 'name' => '$_SERVER', | |
| 47 | - 'value' => var_export($_SERVER, true), | |
| 48 | - ]; | |
| 49 | - $this->entries[] = [ | |
| 50 | - 'name' => '$_COOKIE', | |
| 51 | - 'value' => var_export($_COOKIE, true), | |
| 52 | - ]; | |
| 53 | - $this->entries[] = [ | |
| 54 | - 'name' => '$_SESSION', | |
| 55 | - 'value' => var_export(isset($_SESSION) ? $_SESSION : [], true), | |
| 56 | - ]; | |
| 57 | - return $this->entries; | |
| 58 | - } | |
| 24 | + public function entries(): array | |
| 25 | +	{ | |
| 26 | +		if (!empty($this->entries)) { | |
| 27 | + return $this->entries; | |
| 28 | + } | |
| 29 | +		if (is_admin() && $screen = get_current_screen()) { | |
| 30 | + $reflection = new \ReflectionClass($screen); | |
| 31 | + $properties = $reflection->getProperties(\ReflectionProperty::IS_PUBLIC); | |
| 32 | + $values = []; | |
| 33 | +			foreach ($properties as $property) { | |
| 34 | + $values[$property->getName()] = $property->getValue($screen); | |
| 35 | + } | |
| 36 | + $this->entries[] = [ | |
| 37 | + 'name' => 'WP_Screen', | |
| 38 | + 'value' => var_export($values, true), | |
| 39 | + ]; | |
| 40 | + } | |
| 41 | + $this->entries[] = [ | |
| 42 | + 'name' => '$_GET', | |
| 43 | + 'value' => var_export($_GET, true), | |
| 44 | + ]; | |
| 45 | + $this->entries[] = [ | |
| 46 | + 'name' => '$_SERVER', | |
| 47 | + 'value' => var_export($_SERVER, true), | |
| 48 | + ]; | |
| 49 | + $this->entries[] = [ | |
| 50 | + 'name' => '$_COOKIE', | |
| 51 | + 'value' => var_export($_COOKIE, true), | |
| 52 | + ]; | |
| 53 | + $this->entries[] = [ | |
| 54 | + 'name' => '$_SESSION', | |
| 55 | + 'value' => var_export(isset($_SESSION) ? $_SESSION : [], true), | |
| 56 | + ]; | |
| 57 | + return $this->entries; | |
| 58 | + } | |
| 59 | 59 | |
| 60 | - public function hasEntries(): bool | |
| 61 | -    { | |
| 62 | - return !empty($this->entries()); | |
| 63 | - } | |
| 60 | + public function hasEntries(): bool | |
| 61 | +	{ | |
| 62 | + return !empty($this->entries()); | |
| 63 | + } | |
| 64 | 64 | |
| 65 | - public function id(): string | |
| 66 | -    { | |
| 67 | - return 'glbb-globals'; | |
| 68 | - } | |
| 65 | + public function id(): string | |
| 66 | +	{ | |
| 67 | + return 'glbb-globals'; | |
| 68 | + } | |
| 69 | 69 | |
| 70 | - public function isVisible(): bool | |
| 71 | -    { | |
| 72 | - return true; | |
| 73 | - } | |
| 70 | + public function isVisible(): bool | |
| 71 | +	{ | |
| 72 | + return true; | |
| 73 | + } | |
| 74 | 74 | |
| 75 | - public function label(): string | |
| 76 | -    { | |
| 77 | -        return __('Globals', 'blackbar'); | |
| 78 | - } | |
| 75 | + public function label(): string | |
| 76 | +	{ | |
| 77 | +		return __('Globals', 'blackbar'); | |
| 78 | + } | |
| 79 | 79 | |
| 80 | - public function render(): void | |
| 81 | -    { | |
| 82 | -        $this->app->render('panels/globals', ['globals' => $this]); | |
| 83 | - } | |
| 80 | + public function render(): void | |
| 81 | +	{ | |
| 82 | +		$this->app->render('panels/globals', ['globals' => $this]); | |
| 83 | + } | |
| 84 | 84 | } | 
| @@ -15,51 +15,51 @@ discard block | ||
| 15 | 15 | */ | 
| 16 | 16 | protected $entries; | 
| 17 | 17 | |
| 18 | - public function __construct(Application $app) | |
| 18 | + public function __construct( Application $app ) | |
| 19 | 19 |      { | 
| 20 | 20 | $this->app = $app; | 
| 21 | - $this->entries = []; | |
| 21 | + $this->entries = [ ]; | |
| 22 | 22 | } | 
| 23 | 23 | |
| 24 | 24 | public function entries(): array | 
| 25 | 25 |      { | 
| 26 | -        if (!empty($this->entries)) { | |
| 26 | +        if( !empty( $this->entries ) ) { | |
| 27 | 27 | return $this->entries; | 
| 28 | 28 | } | 
| 29 | -        if (is_admin() && $screen = get_current_screen()) { | |
| 30 | - $reflection = new \ReflectionClass($screen); | |
| 31 | - $properties = $reflection->getProperties(\ReflectionProperty::IS_PUBLIC); | |
| 32 | - $values = []; | |
| 33 | -            foreach ($properties as $property) { | |
| 34 | - $values[$property->getName()] = $property->getValue($screen); | |
| 29 | +        if( is_admin() && $screen = get_current_screen() ) { | |
| 30 | + $reflection = new \ReflectionClass( $screen ); | |
| 31 | + $properties = $reflection->getProperties( \ReflectionProperty::IS_PUBLIC ); | |
| 32 | + $values = [ ]; | |
| 33 | +            foreach( $properties as $property ) { | |
| 34 | + $values[ $property->getName() ] = $property->getValue( $screen ); | |
| 35 | 35 | } | 
| 36 | - $this->entries[] = [ | |
| 36 | + $this->entries[ ] = [ | |
| 37 | 37 | 'name' => 'WP_Screen', | 
| 38 | - 'value' => var_export($values, true), | |
| 38 | + 'value' => var_export( $values, true ), | |
| 39 | 39 | ]; | 
| 40 | 40 | } | 
| 41 | - $this->entries[] = [ | |
| 41 | + $this->entries[ ] = [ | |
| 42 | 42 | 'name' => '$_GET', | 
| 43 | - 'value' => var_export($_GET, true), | |
| 43 | + 'value' => var_export( $_GET, true ), | |
| 44 | 44 | ]; | 
| 45 | - $this->entries[] = [ | |
| 45 | + $this->entries[ ] = [ | |
| 46 | 46 | 'name' => '$_SERVER', | 
| 47 | - 'value' => var_export($_SERVER, true), | |
| 47 | + 'value' => var_export( $_SERVER, true ), | |
| 48 | 48 | ]; | 
| 49 | - $this->entries[] = [ | |
| 49 | + $this->entries[ ] = [ | |
| 50 | 50 | 'name' => '$_COOKIE', | 
| 51 | - 'value' => var_export($_COOKIE, true), | |
| 51 | + 'value' => var_export( $_COOKIE, true ), | |
| 52 | 52 | ]; | 
| 53 | - $this->entries[] = [ | |
| 53 | + $this->entries[ ] = [ | |
| 54 | 54 | 'name' => '$_SESSION', | 
| 55 | - 'value' => var_export(isset($_SESSION) ? $_SESSION : [], true), | |
| 55 | + 'value' => var_export( isset( $_SESSION ) ? $_SESSION : [ ], true ), | |
| 56 | 56 | ]; | 
| 57 | 57 | return $this->entries; | 
| 58 | 58 | } | 
| 59 | 59 | |
| 60 | 60 | public function hasEntries(): bool | 
| 61 | 61 |      { | 
| 62 | - return !empty($this->entries()); | |
| 62 | + return !empty( $this->entries() ); | |
| 63 | 63 | } | 
| 64 | 64 | |
| 65 | 65 | public function id(): string | 
| @@ -74,11 +74,11 @@ discard block | ||
| 74 | 74 | |
| 75 | 75 | public function label(): string | 
| 76 | 76 |      { | 
| 77 | -        return __('Globals', 'blackbar'); | |
| 77 | + return __( 'Globals', 'blackbar' ); | |
| 78 | 78 | } | 
| 79 | 79 | |
| 80 | 80 | public function render(): void | 
| 81 | 81 |      { | 
| 82 | -        $this->app->render('panels/globals', ['globals' => $this]); | |
| 82 | + $this->app->render( 'panels/globals', [ 'globals' => $this ] ); | |
| 83 | 83 | } | 
| 84 | 84 | } | 
| @@ -6,64 +6,64 @@ | ||
| 6 | 6 | |
| 7 | 7 | class Templates implements Module | 
| 8 | 8 |  { | 
| 9 | - /** | |
| 10 | - * @var Application | |
| 11 | - */ | |
| 12 | - protected $app; | |
| 13 | - /** | |
| 14 | - * @var array | |
| 15 | - */ | |
| 16 | - protected $entries; | |
| 9 | + /** | |
| 10 | + * @var Application | |
| 11 | + */ | |
| 12 | + protected $app; | |
| 13 | + /** | |
| 14 | + * @var array | |
| 15 | + */ | |
| 16 | + protected $entries; | |
| 17 | 17 | |
| 18 | - public function __construct(Application $app) | |
| 19 | -    { | |
| 20 | - $this->app = $app; | |
| 21 | - $this->entries = []; | |
| 22 | - } | |
| 18 | + public function __construct(Application $app) | |
| 19 | +	{ | |
| 20 | + $this->app = $app; | |
| 21 | + $this->entries = []; | |
| 22 | + } | |
| 23 | 23 | |
| 24 | - public function entries(): array | |
| 25 | -    { | |
| 26 | -        if (!empty($this->entries)) { | |
| 27 | - return $this->entries; | |
| 28 | - } | |
| 29 | -        if (class_exists('\GeminiLabs\Castor\Facades\Development') | |
| 30 | -            && class_exists('\GeminiLabs\Castor\Helpers\Development') | |
| 31 | -            && method_exists('\GeminiLabs\Castor\Helpers\Development', 'templatePaths')) { // @phpstan-ignore-line | |
| 32 | - $this->entries = \GeminiLabs\Castor\Facades\Development::templatePaths(); | |
| 33 | -        } else { | |
| 34 | -            $files = array_values(array_filter(get_included_files(), function ($file) { | |
| 35 | - $bool = false !== strpos($file, '/themes/') && false === strpos($file, '/functions.php'); | |
| 36 | -                return (bool) apply_filters('blackbar/templates/file', $bool, $file); | |
| 37 | - })); | |
| 38 | -            $this->entries = array_map(function ($file) { | |
| 39 | - return str_replace(trailingslashit(WP_CONTENT_DIR), '', $file); | |
| 40 | - }, $files); | |
| 41 | - } | |
| 42 | - return $this->entries; | |
| 43 | - } | |
| 24 | + public function entries(): array | |
| 25 | +	{ | |
| 26 | +		if (!empty($this->entries)) { | |
| 27 | + return $this->entries; | |
| 28 | + } | |
| 29 | +		if (class_exists('\GeminiLabs\Castor\Facades\Development') | |
| 30 | +			&& class_exists('\GeminiLabs\Castor\Helpers\Development') | |
| 31 | +			&& method_exists('\GeminiLabs\Castor\Helpers\Development', 'templatePaths')) { // @phpstan-ignore-line | |
| 32 | + $this->entries = \GeminiLabs\Castor\Facades\Development::templatePaths(); | |
| 33 | +		} else { | |
| 34 | +			$files = array_values(array_filter(get_included_files(), function ($file) { | |
| 35 | + $bool = false !== strpos($file, '/themes/') && false === strpos($file, '/functions.php'); | |
| 36 | +				return (bool) apply_filters('blackbar/templates/file', $bool, $file); | |
| 37 | + })); | |
| 38 | +			$this->entries = array_map(function ($file) { | |
| 39 | + return str_replace(trailingslashit(WP_CONTENT_DIR), '', $file); | |
| 40 | + }, $files); | |
| 41 | + } | |
| 42 | + return $this->entries; | |
| 43 | + } | |
| 44 | 44 | |
| 45 | - public function hasEntries(): bool | |
| 46 | -    { | |
| 47 | - return !empty($this->entries()); | |
| 48 | - } | |
| 45 | + public function hasEntries(): bool | |
| 46 | +	{ | |
| 47 | + return !empty($this->entries()); | |
| 48 | + } | |
| 49 | 49 | |
| 50 | - public function id(): string | |
| 51 | -    { | |
| 52 | - return 'glbb-templates'; | |
| 53 | - } | |
| 50 | + public function id(): string | |
| 51 | +	{ | |
| 52 | + return 'glbb-templates'; | |
| 53 | + } | |
| 54 | 54 | |
| 55 | - public function isVisible(): bool | |
| 56 | -    { | |
| 57 | - return !is_admin(); | |
| 58 | - } | |
| 55 | + public function isVisible(): bool | |
| 56 | +	{ | |
| 57 | + return !is_admin(); | |
| 58 | + } | |
| 59 | 59 | |
| 60 | - public function label(): string | |
| 61 | -    { | |
| 62 | -        return __('Templates', 'blackbar'); | |
| 63 | - } | |
| 60 | + public function label(): string | |
| 61 | +	{ | |
| 62 | +		return __('Templates', 'blackbar'); | |
| 63 | + } | |
| 64 | 64 | |
| 65 | - public function render(): void | |
| 66 | -    { | |
| 67 | -        $this->app->render('panels/templates', ['templates' => $this]); | |
| 68 | - } | |
| 65 | + public function render(): void | |
| 66 | +	{ | |
| 67 | +		$this->app->render('panels/templates', ['templates' => $this]); | |
| 68 | + } | |
| 69 | 69 | } | 
| @@ -15,36 +15,36 @@ discard block | ||
| 15 | 15 | */ | 
| 16 | 16 | protected $entries; | 
| 17 | 17 | |
| 18 | - public function __construct(Application $app) | |
| 18 | + public function __construct( Application $app ) | |
| 19 | 19 |      { | 
| 20 | 20 | $this->app = $app; | 
| 21 | - $this->entries = []; | |
| 21 | + $this->entries = [ ]; | |
| 22 | 22 | } | 
| 23 | 23 | |
| 24 | 24 | public function entries(): array | 
| 25 | 25 |      { | 
| 26 | -        if (!empty($this->entries)) { | |
| 26 | +        if( !empty( $this->entries ) ) { | |
| 27 | 27 | return $this->entries; | 
| 28 | 28 | } | 
| 29 | -        if (class_exists('\GeminiLabs\Castor\Facades\Development') | |
| 30 | -            && class_exists('\GeminiLabs\Castor\Helpers\Development') | |
| 31 | -            && method_exists('\GeminiLabs\Castor\Helpers\Development', 'templatePaths')) { // @phpstan-ignore-line | |
| 29 | + if( class_exists( '\GeminiLabs\Castor\Facades\Development' ) | |
| 30 | + && class_exists( '\GeminiLabs\Castor\Helpers\Development' ) | |
| 31 | +            && method_exists( '\GeminiLabs\Castor\Helpers\Development', 'templatePaths' ) ) { // @phpstan-ignore-line | |
| 32 | 32 | $this->entries = \GeminiLabs\Castor\Facades\Development::templatePaths(); | 
| 33 | 33 |          } else { | 
| 34 | -            $files = array_values(array_filter(get_included_files(), function ($file) { | |
| 35 | - $bool = false !== strpos($file, '/themes/') && false === strpos($file, '/functions.php'); | |
| 36 | -                return (bool) apply_filters('blackbar/templates/file', $bool, $file); | |
| 37 | - })); | |
| 38 | -            $this->entries = array_map(function ($file) { | |
| 39 | - return str_replace(trailingslashit(WP_CONTENT_DIR), '', $file); | |
| 40 | - }, $files); | |
| 34 | +            $files = array_values( array_filter( get_included_files(), function( $file ) { | |
| 35 | + $bool = false !== strpos( $file, '/themes/' ) && false === strpos( $file, '/functions.php' ); | |
| 36 | + return (bool) apply_filters( 'blackbar/templates/file', $bool, $file ); | |
| 37 | + }) ); | |
| 38 | +            $this->entries = array_map( function( $file ) { | |
| 39 | + return str_replace( trailingslashit( WP_CONTENT_DIR ), '', $file ); | |
| 40 | + }, $files ); | |
| 41 | 41 | } | 
| 42 | 42 | return $this->entries; | 
| 43 | 43 | } | 
| 44 | 44 | |
| 45 | 45 | public function hasEntries(): bool | 
| 46 | 46 |      { | 
| 47 | - return !empty($this->entries()); | |
| 47 | + return !empty( $this->entries() ); | |
| 48 | 48 | } | 
| 49 | 49 | |
| 50 | 50 | public function id(): string | 
| @@ -59,11 +59,11 @@ discard block | ||
| 59 | 59 | |
| 60 | 60 | public function label(): string | 
| 61 | 61 |      { | 
| 62 | -        return __('Templates', 'blackbar'); | |
| 62 | + return __( 'Templates', 'blackbar' ); | |
| 63 | 63 | } | 
| 64 | 64 | |
| 65 | 65 | public function render(): void | 
| 66 | 66 |      { | 
| 67 | -        $this->app->render('panels/templates', ['templates' => $this]); | |
| 67 | + $this->app->render( 'panels/templates', [ 'templates' => $this ] ); | |
| 68 | 68 | } | 
| 69 | 69 | } | 
| @@ -30,12 +30,15 @@ | ||
| 30 | 30 |              && class_exists('\GeminiLabs\Castor\Helpers\Development') | 
| 31 | 31 |              && method_exists('\GeminiLabs\Castor\Helpers\Development', 'templatePaths')) { // @phpstan-ignore-line | 
| 32 | 32 | $this->entries = \GeminiLabs\Castor\Facades\Development::templatePaths(); | 
| 33 | -        } else { | |
| 34 | -            $files = array_values(array_filter(get_included_files(), function ($file) { | |
| 33 | + } | |
| 34 | +        else { | |
| 35 | + $files = array_values(array_filter(get_included_files(), function ($file) | |
| 36 | +            { | |
| 35 | 37 | $bool = false !== strpos($file, '/themes/') && false === strpos($file, '/functions.php'); | 
| 36 | 38 |                  return (bool) apply_filters('blackbar/templates/file', $bool, $file); | 
| 37 | 39 | })); | 
| 38 | -            $this->entries = array_map(function ($file) { | |
| 40 | + $this->entries = array_map(function ($file) | |
| 41 | +            { | |
| 39 | 42 | return str_replace(trailingslashit(WP_CONTENT_DIR), '', $file); | 
| 40 | 43 | }, $files); | 
| 41 | 44 | } | 
| @@ -6,132 +6,132 @@ | ||
| 6 | 6 | |
| 7 | 7 | class Profiler implements Module | 
| 8 | 8 |  { | 
| 9 | - /** | |
| 10 | - * @var Application | |
| 11 | - */ | |
| 12 | - protected $app; | |
| 13 | - /** | |
| 14 | - * @var float | |
| 15 | - */ | |
| 16 | - protected $noise; | |
| 17 | - /** | |
| 18 | - * @var float | |
| 19 | - */ | |
| 20 | - protected $start; | |
| 21 | - /** | |
| 22 | - * @var float | |
| 23 | - */ | |
| 24 | - protected $stop; | |
| 25 | - /** | |
| 26 | - * @var array | |
| 27 | - */ | |
| 28 | - protected $timers; | |
| 29 | - | |
| 30 | - public function __construct(Application $app) | |
| 31 | -    { | |
| 32 | - $this->app = $app; | |
| 33 | - $this->noise = (float) 0; // This is the time that WordPress takes to execute the all hook. | |
| 34 | - $this->start = (float) 0; | |
| 35 | - $this->stop = (float) 0; | |
| 36 | - $this->timers = []; | |
| 37 | - } | |
| 38 | - | |
| 39 | - public function entries(): array | |
| 40 | -    { | |
| 41 | - $entries = []; | |
| 42 | -        foreach ($this->timers as $timer) { | |
| 43 | - $entries[] = [ | |
| 44 | - 'memory' => $this->getMemoryString($timer), | |
| 45 | - 'name' => $this->getNameString($timer), | |
| 46 | - 'time' => $this->getTimeString($timer), | |
| 47 | - ]; | |
| 48 | - } | |
| 49 | - return $entries; | |
| 50 | - } | |
| 51 | - | |
| 52 | - public function getMeasure(): array | |
| 53 | -    { | |
| 54 | - return $this->timers; | |
| 55 | - } | |
| 56 | - | |
| 57 | - public function getMemoryString(array $timer): string | |
| 58 | -    { | |
| 59 | - return (string) round($this->normalize($timer)['memory'] / 1000); | |
| 60 | - } | |
| 61 | - | |
| 62 | - public function getNameString(array $timer): string | |
| 63 | -    { | |
| 64 | - return $this->normalize($timer)['name']; | |
| 65 | - } | |
| 66 | - | |
| 67 | - public function getTimeString(array $timer): string | |
| 68 | -    { | |
| 69 | - $timer = $this->normalize($timer); | |
| 70 | - $index = array_search($timer['name'], array_column($this->timers, 'name')); | |
| 71 | - $start = $this->start + ($index * $this->noise); | |
| 72 | - return number_format(round(($timer['time'] - $start) * 1000, 4), 4); | |
| 73 | - } | |
| 74 | - | |
| 75 | - public function getTotalTime(): float | |
| 76 | -    { | |
| 77 | - $totalNoise = (count($this->timers) - 1) * $this->noise; | |
| 78 | - return $this->stop - $this->start - $totalNoise; | |
| 79 | - } | |
| 80 | - | |
| 81 | - public function hasEntries(): bool | |
| 82 | -    { | |
| 83 | - return !empty($this->timers); | |
| 84 | - } | |
| 85 | - | |
| 86 | - public function id(): string | |
| 87 | -    { | |
| 88 | - return 'glbb-profiler'; | |
| 89 | - } | |
| 90 | - | |
| 91 | - public function isVisible(): bool | |
| 92 | -    { | |
| 93 | - return true; | |
| 94 | - } | |
| 95 | - | |
| 96 | - public function label(): string | |
| 97 | -    { | |
| 98 | -        $label = __('Profiler', 'blackbar'); | |
| 99 | - $time = number_format($this->getTotalTime() * 1000, 0); | |
| 100 | -        if ($time > 0) { | |
| 101 | -            $label .= sprintf(' (%s %s)', $time, __('ms', 'blackbar')); | |
| 102 | - } | |
| 103 | - return $label; | |
| 104 | - } | |
| 105 | - | |
| 106 | - public function render(): void | |
| 107 | -    { | |
| 108 | -        $this->app->render('panels/profiler', ['profiler' => $this]); | |
| 109 | - } | |
| 110 | - | |
| 111 | - public function trace(string $name): void | |
| 112 | -    { | |
| 113 | - $microtime = microtime(true); // float | |
| 114 | -        if (!$this->start) { | |
| 115 | - $this->start = $microtime; | |
| 116 | - } | |
| 117 | -        if ('blackbar/profiler/noise' === $name) { | |
| 118 | - $this->noise = $microtime - $this->start; | |
| 119 | - return; | |
| 120 | - } | |
| 121 | - $this->timers[] = [ | |
| 122 | - 'memory' => memory_get_peak_usage(), | |
| 123 | - 'name' => $name, | |
| 124 | - 'time' => $microtime, | |
| 125 | - ]; | |
| 126 | - $this->stop = $microtime; | |
| 127 | - } | |
| 128 | - | |
| 129 | - protected function normalize(array $timer): array | |
| 130 | -    { | |
| 131 | - return wp_parse_args($timer, [ | |
| 132 | - 'memory' => 0, | |
| 133 | - 'name' => '', | |
| 134 | - 'time' => (float) 0, | |
| 135 | - ]); | |
| 136 | - } | |
| 9 | + /** | |
| 10 | + * @var Application | |
| 11 | + */ | |
| 12 | + protected $app; | |
| 13 | + /** | |
| 14 | + * @var float | |
| 15 | + */ | |
| 16 | + protected $noise; | |
| 17 | + /** | |
| 18 | + * @var float | |
| 19 | + */ | |
| 20 | + protected $start; | |
| 21 | + /** | |
| 22 | + * @var float | |
| 23 | + */ | |
| 24 | + protected $stop; | |
| 25 | + /** | |
| 26 | + * @var array | |
| 27 | + */ | |
| 28 | + protected $timers; | |
| 29 | + | |
| 30 | + public function __construct(Application $app) | |
| 31 | +	{ | |
| 32 | + $this->app = $app; | |
| 33 | + $this->noise = (float) 0; // This is the time that WordPress takes to execute the all hook. | |
| 34 | + $this->start = (float) 0; | |
| 35 | + $this->stop = (float) 0; | |
| 36 | + $this->timers = []; | |
| 37 | + } | |
| 38 | + | |
| 39 | + public function entries(): array | |
| 40 | +	{ | |
| 41 | + $entries = []; | |
| 42 | +		foreach ($this->timers as $timer) { | |
| 43 | + $entries[] = [ | |
| 44 | + 'memory' => $this->getMemoryString($timer), | |
| 45 | + 'name' => $this->getNameString($timer), | |
| 46 | + 'time' => $this->getTimeString($timer), | |
| 47 | + ]; | |
| 48 | + } | |
| 49 | + return $entries; | |
| 50 | + } | |
| 51 | + | |
| 52 | + public function getMeasure(): array | |
| 53 | +	{ | |
| 54 | + return $this->timers; | |
| 55 | + } | |
| 56 | + | |
| 57 | + public function getMemoryString(array $timer): string | |
| 58 | +	{ | |
| 59 | + return (string) round($this->normalize($timer)['memory'] / 1000); | |
| 60 | + } | |
| 61 | + | |
| 62 | + public function getNameString(array $timer): string | |
| 63 | +	{ | |
| 64 | + return $this->normalize($timer)['name']; | |
| 65 | + } | |
| 66 | + | |
| 67 | + public function getTimeString(array $timer): string | |
| 68 | +	{ | |
| 69 | + $timer = $this->normalize($timer); | |
| 70 | + $index = array_search($timer['name'], array_column($this->timers, 'name')); | |
| 71 | + $start = $this->start + ($index * $this->noise); | |
| 72 | + return number_format(round(($timer['time'] - $start) * 1000, 4), 4); | |
| 73 | + } | |
| 74 | + | |
| 75 | + public function getTotalTime(): float | |
| 76 | +	{ | |
| 77 | + $totalNoise = (count($this->timers) - 1) * $this->noise; | |
| 78 | + return $this->stop - $this->start - $totalNoise; | |
| 79 | + } | |
| 80 | + | |
| 81 | + public function hasEntries(): bool | |
| 82 | +	{ | |
| 83 | + return !empty($this->timers); | |
| 84 | + } | |
| 85 | + | |
| 86 | + public function id(): string | |
| 87 | +	{ | |
| 88 | + return 'glbb-profiler'; | |
| 89 | + } | |
| 90 | + | |
| 91 | + public function isVisible(): bool | |
| 92 | +	{ | |
| 93 | + return true; | |
| 94 | + } | |
| 95 | + | |
| 96 | + public function label(): string | |
| 97 | +	{ | |
| 98 | +		$label = __('Profiler', 'blackbar'); | |
| 99 | + $time = number_format($this->getTotalTime() * 1000, 0); | |
| 100 | +		if ($time > 0) { | |
| 101 | +			$label .= sprintf(' (%s %s)', $time, __('ms', 'blackbar')); | |
| 102 | + } | |
| 103 | + return $label; | |
| 104 | + } | |
| 105 | + | |
| 106 | + public function render(): void | |
| 107 | +	{ | |
| 108 | +		$this->app->render('panels/profiler', ['profiler' => $this]); | |
| 109 | + } | |
| 110 | + | |
| 111 | + public function trace(string $name): void | |
| 112 | +	{ | |
| 113 | + $microtime = microtime(true); // float | |
| 114 | +		if (!$this->start) { | |
| 115 | + $this->start = $microtime; | |
| 116 | + } | |
| 117 | +		if ('blackbar/profiler/noise' === $name) { | |
| 118 | + $this->noise = $microtime - $this->start; | |
| 119 | + return; | |
| 120 | + } | |
| 121 | + $this->timers[] = [ | |
| 122 | + 'memory' => memory_get_peak_usage(), | |
| 123 | + 'name' => $name, | |
| 124 | + 'time' => $microtime, | |
| 125 | + ]; | |
| 126 | + $this->stop = $microtime; | |
| 127 | + } | |
| 128 | + | |
| 129 | + protected function normalize(array $timer): array | |
| 130 | +	{ | |
| 131 | + return wp_parse_args($timer, [ | |
| 132 | + 'memory' => 0, | |
| 133 | + 'name' => '', | |
| 134 | + 'time' => (float) 0, | |
| 135 | + ]); | |
| 136 | + } | |
| 137 | 137 | } | 
| @@ -27,23 +27,23 @@ discard block | ||
| 27 | 27 | */ | 
| 28 | 28 | protected $timers; | 
| 29 | 29 | |
| 30 | - public function __construct(Application $app) | |
| 30 | + public function __construct( Application $app ) | |
| 31 | 31 |      { | 
| 32 | 32 | $this->app = $app; | 
| 33 | 33 | $this->noise = (float) 0; // This is the time that WordPress takes to execute the all hook. | 
| 34 | 34 | $this->start = (float) 0; | 
| 35 | 35 | $this->stop = (float) 0; | 
| 36 | - $this->timers = []; | |
| 36 | + $this->timers = [ ]; | |
| 37 | 37 | } | 
| 38 | 38 | |
| 39 | 39 | public function entries(): array | 
| 40 | 40 |      { | 
| 41 | - $entries = []; | |
| 42 | -        foreach ($this->timers as $timer) { | |
| 43 | - $entries[] = [ | |
| 44 | - 'memory' => $this->getMemoryString($timer), | |
| 45 | - 'name' => $this->getNameString($timer), | |
| 46 | - 'time' => $this->getTimeString($timer), | |
| 41 | + $entries = [ ]; | |
| 42 | +        foreach( $this->timers as $timer ) { | |
| 43 | + $entries[ ] = [ | |
| 44 | + 'memory' => $this->getMemoryString( $timer ), | |
| 45 | + 'name' => $this->getNameString( $timer ), | |
| 46 | + 'time' => $this->getTimeString( $timer ), | |
| 47 | 47 | ]; | 
| 48 | 48 | } | 
| 49 | 49 | return $entries; | 
| @@ -54,33 +54,33 @@ discard block | ||
| 54 | 54 | return $this->timers; | 
| 55 | 55 | } | 
| 56 | 56 | |
| 57 | - public function getMemoryString(array $timer): string | |
| 57 | + public function getMemoryString( array $timer ): string | |
| 58 | 58 |      { | 
| 59 | - return (string) round($this->normalize($timer)['memory'] / 1000); | |
| 59 | + return (string) round( $this->normalize( $timer )[ 'memory' ] / 1000 ); | |
| 60 | 60 | } | 
| 61 | 61 | |
| 62 | - public function getNameString(array $timer): string | |
| 62 | + public function getNameString( array $timer ): string | |
| 63 | 63 |      { | 
| 64 | - return $this->normalize($timer)['name']; | |
| 64 | + return $this->normalize( $timer )[ 'name' ]; | |
| 65 | 65 | } | 
| 66 | 66 | |
| 67 | - public function getTimeString(array $timer): string | |
| 67 | + public function getTimeString( array $timer ): string | |
| 68 | 68 |      { | 
| 69 | - $timer = $this->normalize($timer); | |
| 70 | - $index = array_search($timer['name'], array_column($this->timers, 'name')); | |
| 71 | - $start = $this->start + ($index * $this->noise); | |
| 72 | - return number_format(round(($timer['time'] - $start) * 1000, 4), 4); | |
| 69 | + $timer = $this->normalize( $timer ); | |
| 70 | + $index = array_search( $timer[ 'name' ], array_column( $this->timers, 'name' ) ); | |
| 71 | + $start = $this->start + ( $index * $this->noise ); | |
| 72 | + return number_format( round( ( $timer[ 'time' ] - $start ) * 1000, 4 ), 4 ); | |
| 73 | 73 | } | 
| 74 | 74 | |
| 75 | 75 | public function getTotalTime(): float | 
| 76 | 76 |      { | 
| 77 | - $totalNoise = (count($this->timers) - 1) * $this->noise; | |
| 77 | + $totalNoise = ( count( $this->timers ) - 1 ) * $this->noise; | |
| 78 | 78 | return $this->stop - $this->start - $totalNoise; | 
| 79 | 79 | } | 
| 80 | 80 | |
| 81 | 81 | public function hasEntries(): bool | 
| 82 | 82 |      { | 
| 83 | - return !empty($this->timers); | |
| 83 | + return !empty( $this->timers ); | |
| 84 | 84 | } | 
| 85 | 85 | |
| 86 | 86 | public function id(): string | 
| @@ -95,30 +95,30 @@ discard block | ||
| 95 | 95 | |
| 96 | 96 | public function label(): string | 
| 97 | 97 |      { | 
| 98 | -        $label = __('Profiler', 'blackbar'); | |
| 99 | - $time = number_format($this->getTotalTime() * 1000, 0); | |
| 100 | -        if ($time > 0) { | |
| 101 | -            $label .= sprintf(' (%s %s)', $time, __('ms', 'blackbar')); | |
| 98 | + $label = __( 'Profiler', 'blackbar' ); | |
| 99 | + $time = number_format( $this->getTotalTime() * 1000, 0 ); | |
| 100 | +        if( $time > 0 ) { | |
| 101 | + $label .= sprintf( ' (%s %s)', $time, __( 'ms', 'blackbar' ) ); | |
| 102 | 102 | } | 
| 103 | 103 | return $label; | 
| 104 | 104 | } | 
| 105 | 105 | |
| 106 | 106 | public function render(): void | 
| 107 | 107 |      { | 
| 108 | -        $this->app->render('panels/profiler', ['profiler' => $this]); | |
| 108 | + $this->app->render( 'panels/profiler', [ 'profiler' => $this ] ); | |
| 109 | 109 | } | 
| 110 | 110 | |
| 111 | - public function trace(string $name): void | |
| 111 | + public function trace( string $name ): void | |
| 112 | 112 |      { | 
| 113 | - $microtime = microtime(true); // float | |
| 114 | -        if (!$this->start) { | |
| 113 | + $microtime = microtime( true ); // float | |
| 114 | +        if( !$this->start ) { | |
| 115 | 115 | $this->start = $microtime; | 
| 116 | 116 | } | 
| 117 | -        if ('blackbar/profiler/noise' === $name) { | |
| 117 | +        if( 'blackbar/profiler/noise' === $name ) { | |
| 118 | 118 | $this->noise = $microtime - $this->start; | 
| 119 | 119 | return; | 
| 120 | 120 | } | 
| 121 | - $this->timers[] = [ | |
| 121 | + $this->timers[ ] = [ | |
| 122 | 122 | 'memory' => memory_get_peak_usage(), | 
| 123 | 123 | 'name' => $name, | 
| 124 | 124 | 'time' => $microtime, | 
| @@ -126,12 +126,12 @@ discard block | ||
| 126 | 126 | $this->stop = $microtime; | 
| 127 | 127 | } | 
| 128 | 128 | |
| 129 | - protected function normalize(array $timer): array | |
| 129 | + protected function normalize( array $timer ): array | |
| 130 | 130 |      { | 
| 131 | - return wp_parse_args($timer, [ | |
| 131 | + return wp_parse_args( $timer, [ | |
| 132 | 132 | 'memory' => 0, | 
| 133 | 133 | 'name' => '', | 
| 134 | 134 | 'time' => (float) 0, | 
| 135 | - ]); | |
| 135 | + ] ); | |
| 136 | 136 | } | 
| 137 | 137 | } | 
| @@ -4,10 +4,10 @@ | ||
| 4 | 4 | |
| 5 | 5 | interface Module | 
| 6 | 6 |  { | 
| 7 | - public function entries(): array; | |
| 8 | - public function hasEntries(): bool; | |
| 9 | - public function id(): string; | |
| 10 | - public function isVisible(): bool; | |
| 11 | - public function label(): string; | |
| 12 | - public function render(): void; | |
| 7 | + public function entries(): array; | |
| 8 | + public function hasEntries(): bool; | |
| 9 | + public function id(): string; | |
| 10 | + public function isVisible(): bool; | |
| 11 | + public function label(): string; | |
| 12 | + public function render(): void; | |
| 13 | 13 | } |