@@ -19,182 +19,182 @@ |
||
| 19 | 19 | class RecommendedVersions extends Middleware |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * converts a Request to a Response |
|
| 24 | - * |
|
| 25 | - * @param RequestInterface $request |
|
| 26 | - * @param ResponseInterface $response |
|
| 27 | - * @return ResponseInterface |
|
| 28 | - * @throws InvalidDataTypeException |
|
| 29 | - */ |
|
| 30 | - public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
| 31 | - { |
|
| 32 | - $this->request = $request; |
|
| 33 | - $this->response = $response; |
|
| 34 | - // check required WP version |
|
| 35 | - if (! $this->minimumWordPressVersionRequired()) { |
|
| 36 | - $this->request->unSetRequestParam('activate', true); |
|
| 37 | - add_action('admin_notices', array($this, 'minimumWpVersionError'), 1); |
|
| 38 | - $this->response->terminateRequest(); |
|
| 39 | - $this->response->deactivatePlugin(); |
|
| 40 | - } |
|
| 41 | - // check recommended PHP version |
|
| 42 | - if (! $this->minimumPhpVersionRecommended()) { |
|
| 43 | - $this->displayMinimumRecommendedPhpVersionNotice(); |
|
| 44 | - } |
|
| 45 | - // upcoming required version |
|
| 46 | - if (! $this->upcomingRequiredPhpVersion()) { |
|
| 47 | - $this->displayUpcomingRequiredVersion(); |
|
| 48 | - } |
|
| 49 | - $this->response = $this->processRequestStack($this->request, $this->response); |
|
| 50 | - return $this->response; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Helper method to assess installed wp version against given values. |
|
| 56 | - * By default this compares the required minimum version of WP for EE against the installed version of WP |
|
| 57 | - * Note, $wp_version is the first parameter sent into the PHP version_compare function (what is being checked |
|
| 58 | - * against) so consider that when sending in your values. |
|
| 59 | - * |
|
| 60 | - * @param string $version_to_check |
|
| 61 | - * @param string $operator |
|
| 62 | - * @return bool |
|
| 63 | - */ |
|
| 64 | - public static function compareWordPressVersion($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=') |
|
| 65 | - { |
|
| 66 | - global $wp_version; |
|
| 67 | - return version_compare( |
|
| 68 | - // first account for wp_version being pre-release |
|
| 69 | - // (like RC, beta etc) which are usually in the format like 4.7-RC3-39519 |
|
| 70 | - strpos($wp_version, '-') > 0 |
|
| 71 | - ? substr($wp_version, 0, strpos($wp_version, '-')) |
|
| 72 | - : $wp_version, |
|
| 73 | - $version_to_check, |
|
| 74 | - $operator |
|
| 75 | - ); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @return boolean |
|
| 81 | - */ |
|
| 82 | - private function minimumWordPressVersionRequired() |
|
| 83 | - { |
|
| 84 | - return RecommendedVersions::compareWordPressVersion(); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * @param string $min_version |
|
| 90 | - * @return boolean |
|
| 91 | - */ |
|
| 92 | - private function checkPhpVersion($min_version = EE_MIN_PHP_VER_RECOMMENDED) |
|
| 93 | - { |
|
| 94 | - return version_compare(PHP_VERSION, $min_version, '>=') ? true : false; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * @return boolean |
|
| 100 | - */ |
|
| 101 | - private function minimumPhpVersionRecommended() |
|
| 102 | - { |
|
| 103 | - return $this->checkPhpVersion(); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * @return void |
|
| 109 | - */ |
|
| 110 | - public function minimumWpVersionError() |
|
| 111 | - { |
|
| 112 | - global $wp_version; |
|
| 113 | - ?> |
|
| 22 | + /** |
|
| 23 | + * converts a Request to a Response |
|
| 24 | + * |
|
| 25 | + * @param RequestInterface $request |
|
| 26 | + * @param ResponseInterface $response |
|
| 27 | + * @return ResponseInterface |
|
| 28 | + * @throws InvalidDataTypeException |
|
| 29 | + */ |
|
| 30 | + public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
| 31 | + { |
|
| 32 | + $this->request = $request; |
|
| 33 | + $this->response = $response; |
|
| 34 | + // check required WP version |
|
| 35 | + if (! $this->minimumWordPressVersionRequired()) { |
|
| 36 | + $this->request->unSetRequestParam('activate', true); |
|
| 37 | + add_action('admin_notices', array($this, 'minimumWpVersionError'), 1); |
|
| 38 | + $this->response->terminateRequest(); |
|
| 39 | + $this->response->deactivatePlugin(); |
|
| 40 | + } |
|
| 41 | + // check recommended PHP version |
|
| 42 | + if (! $this->minimumPhpVersionRecommended()) { |
|
| 43 | + $this->displayMinimumRecommendedPhpVersionNotice(); |
|
| 44 | + } |
|
| 45 | + // upcoming required version |
|
| 46 | + if (! $this->upcomingRequiredPhpVersion()) { |
|
| 47 | + $this->displayUpcomingRequiredVersion(); |
|
| 48 | + } |
|
| 49 | + $this->response = $this->processRequestStack($this->request, $this->response); |
|
| 50 | + return $this->response; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Helper method to assess installed wp version against given values. |
|
| 56 | + * By default this compares the required minimum version of WP for EE against the installed version of WP |
|
| 57 | + * Note, $wp_version is the first parameter sent into the PHP version_compare function (what is being checked |
|
| 58 | + * against) so consider that when sending in your values. |
|
| 59 | + * |
|
| 60 | + * @param string $version_to_check |
|
| 61 | + * @param string $operator |
|
| 62 | + * @return bool |
|
| 63 | + */ |
|
| 64 | + public static function compareWordPressVersion($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=') |
|
| 65 | + { |
|
| 66 | + global $wp_version; |
|
| 67 | + return version_compare( |
|
| 68 | + // first account for wp_version being pre-release |
|
| 69 | + // (like RC, beta etc) which are usually in the format like 4.7-RC3-39519 |
|
| 70 | + strpos($wp_version, '-') > 0 |
|
| 71 | + ? substr($wp_version, 0, strpos($wp_version, '-')) |
|
| 72 | + : $wp_version, |
|
| 73 | + $version_to_check, |
|
| 74 | + $operator |
|
| 75 | + ); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @return boolean |
|
| 81 | + */ |
|
| 82 | + private function minimumWordPressVersionRequired() |
|
| 83 | + { |
|
| 84 | + return RecommendedVersions::compareWordPressVersion(); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * @param string $min_version |
|
| 90 | + * @return boolean |
|
| 91 | + */ |
|
| 92 | + private function checkPhpVersion($min_version = EE_MIN_PHP_VER_RECOMMENDED) |
|
| 93 | + { |
|
| 94 | + return version_compare(PHP_VERSION, $min_version, '>=') ? true : false; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * @return boolean |
|
| 100 | + */ |
|
| 101 | + private function minimumPhpVersionRecommended() |
|
| 102 | + { |
|
| 103 | + return $this->checkPhpVersion(); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * @return void |
|
| 109 | + */ |
|
| 110 | + public function minimumWpVersionError() |
|
| 111 | + { |
|
| 112 | + global $wp_version; |
|
| 113 | + ?> |
|
| 114 | 114 | <div class="error"> |
| 115 | 115 | <p> |
| 116 | 116 | <?php |
| 117 | - printf( |
|
| 118 | - __( |
|
| 119 | - 'We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', |
|
| 120 | - 'event_espresso' |
|
| 121 | - ), |
|
| 122 | - EE_MIN_WP_VER_REQUIRED, |
|
| 123 | - $wp_version, |
|
| 124 | - '<br/>', |
|
| 125 | - '<a href="http://codex.wordpress.org/Updating_WordPress">http://codex.wordpress.org/Updating_WordPress</a>' |
|
| 126 | - ); |
|
| 127 | - ?> |
|
| 117 | + printf( |
|
| 118 | + __( |
|
| 119 | + 'We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', |
|
| 120 | + 'event_espresso' |
|
| 121 | + ), |
|
| 122 | + EE_MIN_WP_VER_REQUIRED, |
|
| 123 | + $wp_version, |
|
| 124 | + '<br/>', |
|
| 125 | + '<a href="http://codex.wordpress.org/Updating_WordPress">http://codex.wordpress.org/Updating_WordPress</a>' |
|
| 126 | + ); |
|
| 127 | + ?> |
|
| 128 | 128 | </p> |
| 129 | 129 | </div> |
| 130 | 130 | <?php |
| 131 | - } |
|
| 132 | - |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * _display_minimum_recommended_php_version_notice |
|
| 136 | - * |
|
| 137 | - * @access private |
|
| 138 | - * @return void |
|
| 139 | - * @throws InvalidDataTypeException |
|
| 140 | - */ |
|
| 141 | - private function displayMinimumRecommendedPhpVersionNotice() |
|
| 142 | - { |
|
| 143 | - if ($this->request->isAdmin()) { |
|
| 144 | - new PersistentAdminNotice( |
|
| 145 | - 'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended', |
|
| 146 | - sprintf( |
|
| 147 | - esc_html__( |
|
| 148 | - 'Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 149 | - 'event_espresso' |
|
| 150 | - ), |
|
| 151 | - EE_MIN_PHP_VER_RECOMMENDED, |
|
| 152 | - PHP_VERSION, |
|
| 153 | - '<br/>', |
|
| 154 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 155 | - ) |
|
| 156 | - ); |
|
| 157 | - } |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * Returns whether the provided php version number is less than the current version of php installed on the server. |
|
| 163 | - * |
|
| 164 | - * @param string $version_required |
|
| 165 | - * @return bool |
|
| 166 | - */ |
|
| 167 | - private function upcomingRequiredPhpVersion($version_required = '5.5') |
|
| 168 | - { |
|
| 169 | - return true; |
|
| 170 | - // return $this->checkPhpVersion($version_required); |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * Sets a notice for an upcoming required version of PHP in the next update of EE core. |
|
| 176 | - */ |
|
| 177 | - private function displayUpcomingRequiredVersion() |
|
| 178 | - { |
|
| 179 | - if ($this->request->isAdmin() |
|
| 180 | - && apply_filters('FHEE__EE_Recommended_Versions__displayUpcomingRequiredVersion', true, $this->request) |
|
| 181 | - && current_user_can('update_plugins') |
|
| 182 | - ) { |
|
| 183 | - add_action('admin_notices', function () { |
|
| 184 | - echo '<div class="notice event-espresso-admin-notice notice-warning"><p>' |
|
| 185 | - . sprintf( |
|
| 186 | - esc_html__( |
|
| 187 | - 'Please note: The next update of Event Espresso 4 will %1$srequire%2$s PHP 5.4.45 or greater. Your web server\'s PHP version is %3$s. You can contact your host and ask them to update your PHP version to at least PHP 5.6. Please do not update to the new version of Event Espresso 4 until the PHP update is completed. Read about why keeping your server on the latest version of PHP is a good idea %4$shere%5$s', |
|
| 188 | - 'event_espresso' |
|
| 189 | - ), |
|
| 190 | - '<strong>', |
|
| 191 | - '</strong>', |
|
| 192 | - PHP_VERSION, |
|
| 193 | - '<a href="https://wordpress.org/support/upgrade-php/">', |
|
| 194 | - '</a>' |
|
| 195 | - ) |
|
| 196 | - . '</p></div>'; |
|
| 197 | - }); |
|
| 198 | - } |
|
| 199 | - } |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * _display_minimum_recommended_php_version_notice |
|
| 136 | + * |
|
| 137 | + * @access private |
|
| 138 | + * @return void |
|
| 139 | + * @throws InvalidDataTypeException |
|
| 140 | + */ |
|
| 141 | + private function displayMinimumRecommendedPhpVersionNotice() |
|
| 142 | + { |
|
| 143 | + if ($this->request->isAdmin()) { |
|
| 144 | + new PersistentAdminNotice( |
|
| 145 | + 'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended', |
|
| 146 | + sprintf( |
|
| 147 | + esc_html__( |
|
| 148 | + 'Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 149 | + 'event_espresso' |
|
| 150 | + ), |
|
| 151 | + EE_MIN_PHP_VER_RECOMMENDED, |
|
| 152 | + PHP_VERSION, |
|
| 153 | + '<br/>', |
|
| 154 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 155 | + ) |
|
| 156 | + ); |
|
| 157 | + } |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * Returns whether the provided php version number is less than the current version of php installed on the server. |
|
| 163 | + * |
|
| 164 | + * @param string $version_required |
|
| 165 | + * @return bool |
|
| 166 | + */ |
|
| 167 | + private function upcomingRequiredPhpVersion($version_required = '5.5') |
|
| 168 | + { |
|
| 169 | + return true; |
|
| 170 | + // return $this->checkPhpVersion($version_required); |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * Sets a notice for an upcoming required version of PHP in the next update of EE core. |
|
| 176 | + */ |
|
| 177 | + private function displayUpcomingRequiredVersion() |
|
| 178 | + { |
|
| 179 | + if ($this->request->isAdmin() |
|
| 180 | + && apply_filters('FHEE__EE_Recommended_Versions__displayUpcomingRequiredVersion', true, $this->request) |
|
| 181 | + && current_user_can('update_plugins') |
|
| 182 | + ) { |
|
| 183 | + add_action('admin_notices', function () { |
|
| 184 | + echo '<div class="notice event-espresso-admin-notice notice-warning"><p>' |
|
| 185 | + . sprintf( |
|
| 186 | + esc_html__( |
|
| 187 | + 'Please note: The next update of Event Espresso 4 will %1$srequire%2$s PHP 5.4.45 or greater. Your web server\'s PHP version is %3$s. You can contact your host and ask them to update your PHP version to at least PHP 5.6. Please do not update to the new version of Event Espresso 4 until the PHP update is completed. Read about why keeping your server on the latest version of PHP is a good idea %4$shere%5$s', |
|
| 188 | + 'event_espresso' |
|
| 189 | + ), |
|
| 190 | + '<strong>', |
|
| 191 | + '</strong>', |
|
| 192 | + PHP_VERSION, |
|
| 193 | + '<a href="https://wordpress.org/support/upgrade-php/">', |
|
| 194 | + '</a>' |
|
| 195 | + ) |
|
| 196 | + . '</p></div>'; |
|
| 197 | + }); |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | 200 | } |
@@ -32,18 +32,18 @@ discard block |
||
| 32 | 32 | $this->request = $request; |
| 33 | 33 | $this->response = $response; |
| 34 | 34 | // check required WP version |
| 35 | - if (! $this->minimumWordPressVersionRequired()) { |
|
| 35 | + if ( ! $this->minimumWordPressVersionRequired()) { |
|
| 36 | 36 | $this->request->unSetRequestParam('activate', true); |
| 37 | 37 | add_action('admin_notices', array($this, 'minimumWpVersionError'), 1); |
| 38 | 38 | $this->response->terminateRequest(); |
| 39 | 39 | $this->response->deactivatePlugin(); |
| 40 | 40 | } |
| 41 | 41 | // check recommended PHP version |
| 42 | - if (! $this->minimumPhpVersionRecommended()) { |
|
| 42 | + if ( ! $this->minimumPhpVersionRecommended()) { |
|
| 43 | 43 | $this->displayMinimumRecommendedPhpVersionNotice(); |
| 44 | 44 | } |
| 45 | 45 | // upcoming required version |
| 46 | - if (! $this->upcomingRequiredPhpVersion()) { |
|
| 46 | + if ( ! $this->upcomingRequiredPhpVersion()) { |
|
| 47 | 47 | $this->displayUpcomingRequiredVersion(); |
| 48 | 48 | } |
| 49 | 49 | $this->response = $this->processRequestStack($this->request, $this->response); |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | { |
| 143 | 143 | if ($this->request->isAdmin()) { |
| 144 | 144 | new PersistentAdminNotice( |
| 145 | - 'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended', |
|
| 145 | + 'php_version_'.str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED).'_recommended', |
|
| 146 | 146 | sprintf( |
| 147 | 147 | esc_html__( |
| 148 | 148 | 'Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | && apply_filters('FHEE__EE_Recommended_Versions__displayUpcomingRequiredVersion', true, $this->request) |
| 181 | 181 | && current_user_can('update_plugins') |
| 182 | 182 | ) { |
| 183 | - add_action('admin_notices', function () { |
|
| 183 | + add_action('admin_notices', function() { |
|
| 184 | 184 | echo '<div class="notice event-espresso-admin-notice notice-warning"><p>' |
| 185 | 185 | . sprintf( |
| 186 | 186 | esc_html__( |