| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * TablePress environment compatibility check. |
| 4 | 4 | * |
| 5 | - * Note: This file must not contain PHP code that does not run on PHP < 7.2! | |
| 5 | + * Note: This file must not contain PHP code that does not run on PHP < 7.4! | |
| 6 | 6 | * |
| 7 | 7 | * @package TablePress |
| 8 | 8 | * @author Tobias Bäthge |
| 9 | 9 | * @since 2.2.0 |
| @@ -12,16 +12,19 @@ | ||
| 12 | 12 | // Prohibit direct script loading. |
| 13 | 13 | defined( 'ABSPATH' ) || die( 'No direct script access allowed!' ); |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Check if the site is using WordPress 6.0 or newer. | |
| 16 | + * Check if the site is using WordPress 6.2 or newer. | |
| 17 | 17 | */ |
| 18 | -require ABSPATH . WPINC . '/version.php'; // Include an unmodified $wp_version. | |
| 19 | -if ( version_compare( str_replace( '-src', '', $wp_version ), '6.0', '<' ) ) { // @phpstan-ignore-line ($wp_version is a global variable, defined in the included file.) | |
| 18 | +// Include an unmodified $wp_version. | |
| 19 | +require ABSPATH . WPINC . '/version.php'; // @phpstan-ignore require.fileNotFound (This is a WordPress core file that always exists.) | |
| 20 | +if ( version_compare( str_replace( '-src', '', $wp_version ), '6.2', '<' ) ) { // @phpstan-ignore variable.undefined ($wp_version is a global variable, defined in the included file.) | |
| 20 | 21 | /** |
| 21 | 22 | * Show an error notice to admins, if the installed version of WordPress is not supported. |
| 22 | 23 | * |
| 23 | 24 | * @since 2.2.0 |
| 25 | + * | |
| 26 | + * @phpstan-ignore missingType.return | |
| 24 | 27 | */ |
| 25 | 28 | function tablepress_admin_error_notice_minimum_version_wp() /* No return type declaration, due to required PHP compatibility! */ { |
| 26 | 29 | ?> |
| 27 | 30 | <div class="notice notice-error notice-alt notice-large"> |
| @@ -35,11 +38,11 @@ | ||
| 35 | 38 | <p style="font-size:14px"> |
| 36 | 39 | <strong> |
| 37 | 40 | <?php |
| 38 | 41 | if ( current_user_can( 'update_core' ) ) { |
| 39 | - printf( __( 'Please <a href="%1$s">update your WordPress installation</a> to at least version %2$s!', 'tablepress' ), esc_url( self_admin_url( 'update-core.php' ) ), '6.0' ); | |
| 42 | + printf( __( 'Please <a href="%1$s">update your WordPress installation</a> to at least version %2$s!', 'tablepress' ), esc_url( self_admin_url( 'update-core.php' ) ), '6.2' ); | |
| 40 | 43 | } else { |
| 41 | - printf( __( 'Please ask your site’s administrator to update WordPress to at least version %1$s!', 'tablepress' ), '6.0' ); | |
| 44 | + printf( __( 'Please ask your site’s administrator to update WordPress to at least version %1$s!', 'tablepress' ), '6.2' ); | |
| 42 | 45 | } |
| 43 | 46 | ?> |
| 44 | 47 | </strong> |
| 45 | 48 | </p> |
| @@ -52,15 +55,17 @@ | ||
| 52 | 55 | return false; |
| 53 | 56 | } |
| 54 | 57 | |
| 55 | 58 | /** |
| 56 | - * Check if the server is running PHP 7.2 or newer. | |
| 59 | + * Check if the server is running PHP 7.4 or newer. | |
| 57 | 60 | */ |
| 58 | -if ( PHP_VERSION_ID < 70200 ) { | |
| 61 | +if ( PHP_VERSION_ID < 70400 ) { | |
| 59 | 62 | /** |
| 60 | 63 | * Show an error notice to admins, if the installed version of PHP is not supported. |
| 61 | 64 | * |
| 62 | 65 | * @since 2.2.0 |
| 66 | + * | |
| 67 | + * @phpstan-ignore missingType.return | |
| 63 | 68 | */ |
| 64 | 69 | function tablepress_admin_error_notice_minimum_version_php() /* No return type declaration, due to required PHP compatibility! */ { |
| 65 | 70 | ?> |
| 66 | 71 | <div class="notice notice-error notice-alt notice-large"> |
| @@ -68,9 +73,9 @@ | ||
| 68 | 73 | <span aria-hidden="true" class="dashicons dashicons-warning" style="color:#d63638;vertical-align:bottom"></span> |
| 69 | 74 | <?php _e( 'Attention: Unfortunately, there is a problem!', 'tablepress' ); ?> |
| 70 | 75 | </em></h3> |
| 71 | 76 | <p style="font-size:14px"> |
| 72 | - <?php printf( __( 'Your server is running a version of PHP that is too old for the TablePress plugin to work. TablePress requires PHP %s or newer, where newer versions are recommended.', 'tablepress' ), '7.2' ); ?> | |
| 77 | + <?php printf( __( 'Your server is running a version of PHP that is too old for the TablePress plugin to work. TablePress requires PHP %s or newer, where newer versions are recommended.', 'tablepress' ), '7.4' ); ?> | |
| 73 | 78 | </p> |
| 74 | 79 | <p style="font-size:14px"> |
| 75 | 80 | <strong><?php printf( __( '<a href="%s">Learn more about updating PHP</a> or contact your server administrator.', 'tablepress' ), esc_url( wp_get_update_php_url() ) ); ?></strong> |
| 76 | 81 | </p> |
| @@ -81,7 +86,25 @@ | ||
| 81 | 86 | |
| 82 | 87 | // Exit TablePress early. |
| 83 | 88 | return false; |
| 84 | 89 | } |
| 90 | + | |
| 91 | +/** | |
| 92 | + * Turns off Elementor's element caching if used as the callback for the `pre_option_elementor_experiment-e_element_cache` filter hook. | |
| 93 | + * | |
| 94 | + * @since 3.0.0 | |
| 95 | + * | |
| 96 | + * @param string $value The value to return for the option. | |
| 97 | + * @param string $option The option name. | |
| 98 | + * @param string $default_value The default value for the option. | |
| 99 | + * @return string The value to return for the option. | |
| 100 | + */ | |
| 101 | +function tablepress_turn_off_elementor_element_caching( $value, /* string */ $option, $default_value ) /* No return type declaration, due to required PHP compatibility! */ { | |
| 102 | + // Don't use type hints in the function declaration, due to required PHP compatibility of this file! | |
| 103 | + return 'inactive'; | |
| 104 | +} | |
| 105 | + | |
| 106 | +// Turn off Elementor's Element Caching as it breaks the loading of CSS and JS files. | |
| 107 | +add_filter( 'pre_option_elementor_experiment-e_element_cache', 'tablepress_turn_off_elementor_element_caching', 10, 3 ); | |
| 85 | 108 | |
| 86 | 109 | // All environment checks passed. |
| 87 | 110 | return true; |