Changeset 8115 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
- Timestamp:
- 01/20/2019 11:07:15 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
r8114 r8115 160 160 161 161 /** 162 * Gets current major WP version to check against "Tested up to" value. 163 * 164 * @static 165 * @global string $wp_version WordPress version. 166 * 167 * @return float Current major WP version. 168 */ 169 public static function get_current_major_wp_version() { 170 $current_version = ''; 171 172 // Assume the value stored in a constant (which is set on WP.org), if defined. 173 if ( defined( 'WP_CORE_LATEST_RELEASE' ) && WP_CORE_LATEST_RELEASE ) { 174 $current_version = substr( WP_CORE_LATEST_RELEASE, 0, 3 ); 175 } 176 177 // Otherwise, use the version of the running WP instance. 178 if ( empty( $current_version ) ) { 179 global $wp_version; 180 181 $current_version = substr( $wp_version, 0, 3 ); 182 183 // However, if the running WP instance appears to not be a release version, assume the latest stable version. 184 if ( false !== strpos( $wp_version, '-' ) ) { 185 $current_version = (float) $current_version - 0.1; 186 } 187 } 188 189 return (float) $current_version; 190 } 191 192 /** 193 * Checks if the plugin was tested with the latest 3 major releases of WordPress. 194 * 195 * @static 196 * 197 * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. 198 * @return bool True if the plugin is marked as tested, false otherwise. 199 */ 200 public static function is_plugin_outdated( $post = null ) { 201 $tested_up_to = (string) get_post_meta( get_post( $post )->ID, 'tested', true ); 202 $version_to_check_against = (string) ( self::get_current_major_wp_version() - 0.2 ); 203 204 return version_compare( $version_to_check_against, $tested_up_to, '>' ); 205 } 206 207 /** 162 208 * Returns a string representing the number of active installations for an item. 163 209 *
Note: See TracChangeset
for help on using the changeset viewer.