| @@ -29,9 +29,9 @@ | ||
| 29 | 29 | } |
| 30 | 30 | /** |
| 31 | 31 | * Get the status of the requirements check. |
| 32 | 32 | */ |
| 33 | - public function met() : bool | |
| 33 | + public function met(): bool | |
| 34 | 34 | { |
| 35 | 35 | return $this->doesNotMeet === []; |
| 36 | 36 | } |
| 37 | 37 | /** |
| @@ -39,12 +39,12 @@ | ||
| 39 | 39 | * the specified version. |
| 40 | 40 | * |
| 41 | 41 | * @param string $minVersion The minimum PHP version required. |
| 42 | 42 | */ |
| 43 | - public function php(string $minVersion) : self | |
| 43 | + public function php(string $minVersion): self | |
| 44 | 44 | { |
| 45 | - if (\version_compare(\PHP_VERSION, $minVersion, '<')) { | |
| 46 | - $this->doesNotMeet[] = \sprintf('<strong>%s</strong> <code>%s</code> or higher', 'PHP', $minVersion); | |
| 45 | + if (version_compare(\PHP_VERSION, $minVersion, '<')) { | |
| 46 | + $this->doesNotMeet[] = sprintf('<strong>%s</strong> <code>%s</code> or higher', 'PHP', $minVersion); | |
| 47 | 47 | } |
| 48 | 48 | return $this; |
| 49 | 49 | } |
| 50 | 50 | /** |
| @@ -52,12 +52,12 @@ | ||
| 52 | 52 | * the specified version. |
| 53 | 53 | * |
| 54 | 54 | * @param string $minVersion The minimum WordPress version required. |
| 55 | 55 | */ |
| 56 | - public function wp(string $minVersion) : self | |
| 56 | + public function wp(string $minVersion): self | |
| 57 | 57 | { |
| 58 | - if (\version_compare(\get_bloginfo('version'), $minVersion, '<')) { | |
| 59 | - $this->doesNotMeet[] = \sprintf('<strong>%s</strong> <code>%s</code> or higher', 'WordPress', $minVersion); | |
| 58 | + if (version_compare(get_bloginfo('version'), $minVersion, '<')) { | |
| 59 | + $this->doesNotMeet[] = sprintf('<strong>%s</strong> <code>%s</code> or higher', 'WordPress', $minVersion); | |
| 60 | 60 | } |
| 61 | 61 | return $this; |
| 62 | 62 | } |
| 63 | 63 | /** |
| @@ -64,11 +64,11 @@ | ||
| 64 | 64 | * Check if the plugin is running on multisite. |
| 65 | 65 | * |
| 66 | 66 | * @param bool $must Whether the plugin must be running on multisite. |
| 67 | 67 | */ |
| 68 | - public function multisite(bool $must) : self | |
| 68 | + public function multisite(bool $must): self | |
| 69 | 69 | { |
| 70 | - if ($must && !\is_multisite()) { | |
| 70 | + if ($must && !is_multisite()) { | |
| 71 | 71 | $this->doesNotMeet[] = 'WordPress Multisite'; |
| 72 | 72 | } |
| 73 | 73 | return $this; |
| 74 | 74 | } |
| @@ -76,22 +76,22 @@ | ||
| 76 | 76 | * Check if plugins are active and may have the minimum version specified. |
| 77 | 77 | * |
| 78 | 78 | * @param list<string|array{0: string, 1: string}> $plugins The plugins to check. Use the plugin file path, e.g. `windpress/windpress.php`. |
| 79 | 79 | */ |
| 80 | - public function plugins(array $plugins) : self | |
| 80 | + public function plugins(array $plugins): self | |
| 81 | 81 | { |
| 82 | 82 | foreach ($plugins as $k => $v) { |
| 83 | - if (\is_int($k)) { | |
| 84 | - if (!\is_plugin_active($v)) { | |
| 85 | - $pluginName = \get_plugin_data(\WP_PLUGIN_DIR . '/' . $v)['Name']; | |
| 86 | - $this->doesNotMeet[] = \sprintf('<strong>%s</strong>', $pluginName); | |
| 83 | + if (is_int($k)) { | |
| 84 | + if (!is_plugin_active($v)) { | |
| 85 | + $pluginName = get_plugin_data(\WP_PLUGIN_DIR . '/' . $v)['Name']; | |
| 86 | + $this->doesNotMeet[] = sprintf('<strong>%s</strong>', $pluginName); | |
| 87 | 87 | } |
| 88 | 88 | } else { |
| 89 | - $pluginName = \get_plugin_data(\WP_PLUGIN_DIR . '/' . $k)['Name']; | |
| 90 | - if (!\is_plugin_active($k)) { | |
| 91 | - $this->doesNotMeet[] = \sprintf('<strong>%s</strong>', $pluginName); | |
| 92 | - } elseif (\version_compare(\get_plugin_data(\WP_PLUGIN_DIR . '/' . $k)['Version'], $v, '<')) { | |
| 93 | - $this->doesNotMeet[] = \sprintf('<strong>%s</strong> <code>%s</code> or higher', $pluginName, $v); | |
| 89 | + $pluginName = get_plugin_data(\WP_PLUGIN_DIR . '/' . $k)['Name']; | |
| 90 | + if (!is_plugin_active($k)) { | |
| 91 | + $this->doesNotMeet[] = sprintf('<strong>%s</strong>', $pluginName); | |
| 92 | + } elseif (version_compare(get_plugin_data(\WP_PLUGIN_DIR . '/' . $k)['Version'], $v, '<')) { | |
| 93 | + $this->doesNotMeet[] = sprintf('<strong>%s</strong> <code>%s</code> or higher', $pluginName, $v); | |
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | return $this; |
| @@ -101,29 +101,29 @@ | ||
| 101 | 101 | * |
| 102 | 102 | * @param string $parentTheme The parent theme to check. |
| 103 | 103 | * @param string|null $version The minimum version of the parent theme. |
| 104 | 104 | */ |
| 105 | - public function theme(string $parentTheme, ?string $version = null) : self | |
| 105 | + public function theme(string $parentTheme, ?string $version = null): self | |
| 106 | 106 | { |
| 107 | - $theme = \wp_get_theme(); | |
| 108 | - if (\get_template() !== $parentTheme) { | |
| 109 | - $this->doesNotMeet[] = \sprintf('<strong>%s</strong>', $parentTheme); | |
| 110 | - } elseif ($version && \version_compare(($theme->parent() ?: $theme)->get('Version'), $version, '<')) { | |
| 111 | - $this->doesNotMeet[] = \sprintf('<strong>%s</strong> <code>%s</code> or higher', $parentTheme, $version); | |
| 107 | + $theme = wp_get_theme(); | |
| 108 | + if (get_template() !== $parentTheme) { | |
| 109 | + $this->doesNotMeet[] = sprintf('<strong>%s</strong>', $parentTheme); | |
| 110 | + } elseif ($version && version_compare(($theme->parent() ?: $theme)->get('Version'), $version, '<')) { | |
| 111 | + $this->doesNotMeet[] = sprintf('<strong>%s</strong> <code>%s</code> or higher', $parentTheme, $version); | |
| 112 | 112 | } |
| 113 | 113 | return $this; |
| 114 | 114 | } |
| 115 | 115 | public function printNotice() |
| 116 | 116 | { |
| 117 | - $name = \esc_html(\get_plugin_data(WIND_PRESS::FILE, \false)['Name']); | |
| 118 | - if (!\current_user_can('activate_plugins')) { | |
| 117 | + $name = esc_html(get_plugin_data(WIND_PRESS::FILE, \false)['Name']); | |
| 118 | + if (!current_user_can('activate_plugins')) { | |
| 119 | 119 | return; |
| 120 | 120 | } |
| 121 | - $notice = \sprintf( | |
| 121 | + $notice = sprintf( | |
| 122 | 122 | /* translators: 1: plugin name, 2: list of requirements */ |
| 123 | - \esc_html__('The %1$s plugin minimum requirements are not met:', 'windpress'), | |
| 123 | + esc_html__('The %1$s plugin minimum requirements are not met:', 'windpress'), | |
| 124 | 124 | '<strong>' . $name . '</strong>' |
| 125 | 125 | ); |
| 126 | - $requirements = \count($this->doesNotMeet) === 0 ? '' : '<ul><li>' . \implode('</li><li>', $this->doesNotMeet) . '</li></ul>'; | |
| 127 | - \printf('<div class="notice notice-error"><p>%1$s</p>%2$s</div>', \wp_kses_post($notice), \wp_kses_post($requirements)); | |
| 126 | + $requirements = count($this->doesNotMeet) === 0 ? '' : '<ul><li>' . implode('</li><li>', $this->doesNotMeet) . '</li></ul>'; | |
| 127 | + printf('<div class="notice notice-error"><p>%1$s</p>%2$s</div>', wp_kses_post($notice), wp_kses_post($requirements)); | |
| 128 | 128 | } |
| 129 | 129 | } |