WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/22/2019 12:36:30 AM (22 months ago)
Author:
SergeyBiryukov
Message:

Plugins: Block plugin activation if it requires a higher version of PHP or WordPress.

Introduce validate_plugin_requirements() for validating a plugin's WordPress and PHP version requirements.

Introduce wp_is_wp_compatible() and wp_is_php_compatible() for checking compatibility with the current WordPress or PHP version.

Props afragen, joyously, DrewAPicture, TimothyBlynJacobs, desrosj, flixos90, SergeyBiryukov.
See #43992.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r44935 r44978  
    68986898    echo '</p>';
    68996899}
     6900
     6901/**
     6902 * Checks compatibility with the current WordPress version.
     6903 *
     6904 * @since 5.2.0
     6905 *
     6906 * @param string $required Minimum required WordPress version.
     6907 * @return bool True if required version is compatible or empty, false if not.
     6908 */
     6909function wp_is_wp_compatible( $required ) {
     6910    $wp_version = get_bloginfo( 'version' );
     6911
     6912    return empty( $required ) || version_compare( $wp_version, $required, '>=' );
     6913}
     6914
     6915/**
     6916 * Checks compatibility with the current PHP version.
     6917 *
     6918 * @since 5.2.0
     6919 *
     6920 * @param string $required Minimum required PHP version.
     6921 * @return bool True if required version is compatible or empty, false if not.
     6922 */
     6923function wp_is_php_compatible( $required ) {
     6924    return empty( $required ) || version_compare( phpversion(), $required, '>=' );
     6925}
Note: See TracChangeset for help on using the changeset viewer.