Making WordPress.org


Ignore:
Timestamp:
11/26/2016 03:47:38 AM (9 years ago)
Author:
dd32
Message:

Plugin Directory: Update the tested postmeta field when new versions of WordPress are released.
This removes the need for having a postmeta display filter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php

    r4389 r4423  
    147147        }
    148148
     149        // Update the tested-up-to value
     150        $tested = $readme->tested;
     151        if ( function_exists( 'wporg_get_version_equivalents' ) ) {
     152            foreach ( wporg_get_version_equivalents() as $latest_compatible_version => $compatible_with ) {
     153                if ( in_array( $readme->tested, $compatible_with, true ) ) {
     154                    $tested = $latest_compatible_version;
     155                    break;
     156                }
     157            }
     158        }
     159
     160        // Update all readme meta
    149161        foreach ( $this->readme_fields as $readme_field ) {
    150             // Don't change the tested version if a newer version was specified through wp-admin
    151             if ( 'tested' == $readme_field && version_compare( get_post_meta( $plugin->ID, 'tested', true ), $readme->$readme_field, '>' ) ) {
    152                 continue;
    153             }
    154 
    155             update_post_meta( $plugin->ID, $readme_field, wp_slash( $readme->$readme_field ) );
     162            $value = ( 'tested' == $readme_field ) ? $tested : $readme->field;
     163            update_post_meta( $plugin->ID, $readme_field, wp_slash( $value ) );
    156164        }
    157165
Note: See TracChangeset for help on using the changeset viewer.