WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/12/2019 11:55:19 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Plugins: Introduce is_wp_version_compatible() and is_php_version_compatible() for checking compatibility with the current WordPress or PHP version.

Props afragen.
Fixes #46599.

File:
1 edited

Legend:

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

    r45177 r45185  
    34183418    <data>
    34193419        <status>{$r['response']}</status>
    3420     </data> 
     3420    </data>
    34213421</error>
    34223422
     
    71227122    return $size;
    71237123}
     7124
     7125/**
     7126* Checks compatibility with the current WordPress version.
     7127*
     7128* @since 5.2.0
     7129*
     7130* @param string $required Minimum required WordPress version.
     7131* @return bool True if required version is compatible or empty, false if not.
     7132*/
     7133function is_wp_version_compatible( $required ) {
     7134    return empty( $required ) || version_compare( get_bloginfo( 'version' ), $required, '>=' );
     7135}
     7136
     7137/**
     7138 * Checks compatibility with the current PHP version.
     7139 *
     7140 * @since 5.2.0
     7141 *
     7142 * @param string $required Minimum required PHP version.
     7143 * @return bool True if required version is compatible or empty, false if not.
     7144 */
     7145function is_php_version_compatible( $required ) {
     7146    return empty( $required ) || version_compare( phpversion(), $required, '>=' );
     7147}
Note: See TracChangeset for help on using the changeset viewer.