@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @license GPL2+ |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if ( ! class_exists( 'WP_Requirements' ) ) { |
|
| 14 | +if ( ! class_exists('WP_Requirements')) { |
|
| 15 | 15 | |
| 16 | 16 | class WP_Requirements { |
| 17 | 17 | |
@@ -90,13 +90,13 @@ discard block |
||
| 90 | 90 | * @param string $plugin Output of `plugin_basename( __FILE__ )`. |
| 91 | 91 | * @param array $requirements Associative array with requirements. |
| 92 | 92 | */ |
| 93 | - public function __construct( $name, $plugin, $requirements ) { |
|
| 93 | + public function __construct($name, $plugin, $requirements) { |
|
| 94 | 94 | |
| 95 | - $this->name = htmlspecialchars( strip_tags( $name ) ); |
|
| 95 | + $this->name = htmlspecialchars(strip_tags($name)); |
|
| 96 | 96 | $this->plugin = $plugin; |
| 97 | 97 | $this->requirements = $requirements; |
| 98 | 98 | |
| 99 | - if ( ! empty( $requirements ) && is_array( $requirements ) ) { |
|
| 99 | + if ( ! empty($requirements) && is_array($requirements)) { |
|
| 100 | 100 | |
| 101 | 101 | $failures = $extensions = array(); |
| 102 | 102 | |
@@ -109,10 +109,10 @@ discard block |
||
| 109 | 109 | ); |
| 110 | 110 | |
| 111 | 111 | // Check for WordPress version. |
| 112 | - if ( $requirements['WordPress'] && is_string( $requirements['WordPress'] ) ) { |
|
| 113 | - if ( function_exists( 'get_bloginfo' ) ) { |
|
| 114 | - $wp_version = get_bloginfo( 'version' ); |
|
| 115 | - if ( version_compare( $wp_version, $requirements['WordPress'] ) === - 1 ) { |
|
| 112 | + if ($requirements['WordPress'] && is_string($requirements['WordPress'])) { |
|
| 113 | + if (function_exists('get_bloginfo')) { |
|
| 114 | + $wp_version = get_bloginfo('version'); |
|
| 115 | + if (version_compare($wp_version, $requirements['WordPress']) === - 1) { |
|
| 116 | 116 | $failures['WordPress'] = $wp_version; |
| 117 | 117 | $this->wp = false; |
| 118 | 118 | } |
@@ -120,24 +120,24 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | // Check fo PHP version. |
| 123 | - if ( $requirements['PHP'] && is_string( $requirements['PHP'] ) ) { |
|
| 124 | - if ( version_compare( PHP_VERSION, $requirements['PHP'] ) === -1 ) { |
|
| 123 | + if ($requirements['PHP'] && is_string($requirements['PHP'])) { |
|
| 124 | + if (version_compare(PHP_VERSION, $requirements['PHP']) === -1) { |
|
| 125 | 125 | $failures['PHP'] = PHP_VERSION; |
| 126 | 126 | $this->php = false; |
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | // Check fo PHP Extensions. |
| 131 | - if ( $requirements['Extensions'] && is_array( $requirements['Extensions'] ) ) { |
|
| 132 | - foreach ( $requirements['Extensions'] as $extension ) { |
|
| 133 | - if ( $extension && is_string( $extension ) ) { |
|
| 134 | - $extensions[ $extension ] = extension_loaded( $extension ); |
|
| 131 | + if ($requirements['Extensions'] && is_array($requirements['Extensions'])) { |
|
| 132 | + foreach ($requirements['Extensions'] as $extension) { |
|
| 133 | + if ($extension && is_string($extension)) { |
|
| 134 | + $extensions[$extension] = extension_loaded($extension); |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | - if ( in_array( false, $extensions ) ) { |
|
| 138 | - foreach ( $extensions as $extension_name => $found ) { |
|
| 139 | - if ( $found === false ) { |
|
| 140 | - $failures['Extensions'][ $extension_name ] = $extension_name; |
|
| 137 | + if (in_array(false, $extensions)) { |
|
| 138 | + foreach ($extensions as $extension_name => $found) { |
|
| 139 | + if ($found === false) { |
|
| 140 | + $failures['Extensions'][$extension_name] = $extension_name; |
|
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | $this->extensions = false; |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | } else { |
| 150 | 150 | |
| 151 | - trigger_error( 'WP Requirements: the requirements are invalid.', E_USER_ERROR ); |
|
| 151 | + trigger_error('WP Requirements: the requirements are invalid.', E_USER_ERROR); |
|
| 152 | 152 | |
| 153 | 153 | } |
| 154 | 154 | } |
@@ -168,11 +168,11 @@ discard block |
||
| 168 | 168 | * @return bool |
| 169 | 169 | */ |
| 170 | 170 | public function pass() { |
| 171 | - if ( in_array( false, array( |
|
| 171 | + if (in_array(false, array( |
|
| 172 | 172 | $this->wp, |
| 173 | 173 | $this->php, |
| 174 | 174 | $this->extensions, |
| 175 | - ) ) ) { |
|
| 175 | + ))) { |
|
| 176 | 176 | return false; |
| 177 | 177 | } |
| 178 | 178 | return true; |
@@ -185,27 +185,27 @@ discard block |
||
| 185 | 185 | * |
| 186 | 186 | * @return string |
| 187 | 187 | */ |
| 188 | - public function get_notice( $message = '' ) { |
|
| 188 | + public function get_notice($message = '') { |
|
| 189 | 189 | |
| 190 | 190 | $notice = ''; |
| 191 | 191 | $name = $this->name; |
| 192 | 192 | $failures = $this->failures; |
| 193 | 193 | |
| 194 | - if ( ! empty( $failures ) && is_array( $failures ) ) { |
|
| 194 | + if ( ! empty($failures) && is_array($failures)) { |
|
| 195 | 195 | |
| 196 | 196 | $notice = '<div class="error">' . "\n"; |
| 197 | 197 | $notice .= "\t" . '<p>' . "\n"; |
| 198 | - $notice .= '<strong>' . sprintf( '%s could not be activated.', $name ) . '</strong><br>'; |
|
| 198 | + $notice .= '<strong>' . sprintf('%s could not be activated.', $name) . '</strong><br>'; |
|
| 199 | 199 | |
| 200 | - foreach ( $failures as $requirement => $found ) { |
|
| 200 | + foreach ($failures as $requirement => $found) { |
|
| 201 | 201 | |
| 202 | - $required = $this->requirements[ $requirement ]; |
|
| 202 | + $required = $this->requirements[$requirement]; |
|
| 203 | 203 | |
| 204 | - if ( 'Extensions' == $requirement ) { |
|
| 205 | - if ( is_array( $found ) ) { |
|
| 204 | + if ('Extensions' == $requirement) { |
|
| 205 | + if (is_array($found)) { |
|
| 206 | 206 | $notice .= sprintf( |
| 207 | 207 | 'Required PHP Extension(s) not found: %s.', |
| 208 | - join( ', ', $found ) |
|
| 208 | + join(', ', $found) |
|
| 209 | 209 | ) . '<br>'; |
| 210 | 210 | } |
| 211 | 211 | } else { |
@@ -219,9 +219,9 @@ discard block |
||
| 219 | 219 | |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - $notice .= '<em>' . sprintf( 'Please update to meet %s requirements.', $name ) . '</em>' . "\n"; |
|
| 222 | + $notice .= '<em>' . sprintf('Please update to meet %s requirements.', $name) . '</em>' . "\n"; |
|
| 223 | 223 | $notice .= "\t" . '</p>' . "\n"; |
| 224 | - if ( $message ) { |
|
| 224 | + if ($message) { |
|
| 225 | 225 | $notice .= $message; |
| 226 | 226 | } |
| 227 | 227 | $notice .= '</div>'; |
@@ -241,8 +241,8 @@ discard block |
||
| 241 | 241 | * Deactivate plugin. |
| 242 | 242 | */ |
| 243 | 243 | public function deactivate_plugin() { |
| 244 | - if ( function_exists( 'deactivate_plugins' ) && function_exists( 'plugin_basename' ) ) { |
|
| 245 | - deactivate_plugins( $this->plugin ); |
|
| 244 | + if (function_exists('deactivate_plugins') && function_exists('plugin_basename')) { |
|
| 245 | + deactivate_plugins($this->plugin); |
|
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | 248 | |
@@ -251,17 +251,17 @@ discard block |
||
| 251 | 251 | * |
| 252 | 252 | * @param string $message An additional message in notice. |
| 253 | 253 | */ |
| 254 | - public function halt( $message = '' ) { |
|
| 254 | + public function halt($message = '') { |
|
| 255 | 255 | |
| 256 | - $this->notice = $this->get_notice( $message ); |
|
| 256 | + $this->notice = $this->get_notice($message); |
|
| 257 | 257 | |
| 258 | - if ( $this->notice && function_exists( 'add_action' ) ) { |
|
| 258 | + if ($this->notice && function_exists('add_action')) { |
|
| 259 | 259 | |
| 260 | - add_action( 'admin_notices', array( $this, 'print_notice' ) ); |
|
| 261 | - add_action( 'admin_init', array( $this, 'deactivate_plugin' ) ); |
|
| 260 | + add_action('admin_notices', array($this, 'print_notice')); |
|
| 261 | + add_action('admin_init', array($this, 'deactivate_plugin')); |
|
| 262 | 262 | |
| 263 | - if ( isset( $_GET['activate'] ) ) { |
|
| 264 | - unset( $_GET['activate'] ); |
|
| 263 | + if (isset($_GET['activate'])) { |
|
| 264 | + unset($_GET['activate']); |
|
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | 267 | } |