Making WordPress.org

Changeset 13637


Ignore:
Timestamp:
05/01/2024 01:51:39 AM ( 3 weeks ago)
Author:
dd32
Message:

Plugin Directory: Support the Tested Up To header in the main plugin file.

This is as the other similar metadata fields are preferred from the plugin file, so it makes sense to have all versions co-located.

Fixes #4621 .

File:
1 edited

Legend:

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

    r13551 r13637  
    twenty-nine twenty-nine     // Readme fields which get stored in plugin meta
    thirty thirty     public $readme_fields = array(
    thirty-one           'tested',
    thirty-two thirty-one         'donate_link',
    thirty-three thirty-two         'license',
     
    thirty-seven thirty-six
    thirty-eight thirty-seven         // These headers are stored as post meta, but are handled separately.
      thirty-eight         // 'tested',
    thirty-nine thirty-nine         // 'requires',
    forty forty         // 'requires_php',
     
    three hundred and twenty three hundred and twenty         }
    three hundred and twenty-one three hundred and twenty-one
    three hundred and twenty-two           // Update the tested-up-to value
    three hundred and twenty-three           $tested = $readme->tested;
    three hundred and twenty-four           if ( function_exists( 'wporg_get_version_equivalents' ) ) {
    three hundred and twenty-five               foreach ( wporg_get_version_equivalents() as $latest_compatible_version => $compatible_with ) {
    three hundred and twenty-six                   if ( in_array( $readme->tested, $compatible_with, true ) ) {
    three hundred and twenty-seven                       $tested = $latest_compatible_version;
    three hundred and twenty-eight                       break;
    three hundred and twenty-nine                   }
    three hundred and thirty               }
    three hundred and thirty-one           }
    three hundred and thirty-two  
    three hundred and thirty-three three hundred and twenty-two         // Update all readme meta
    three hundred and thirty-four three hundred and twenty-three         foreach ( $this->readme_fields as $readme_field ) {
    three hundred and thirty-five               $value = ( 'tested' == $readme_field ) ? $ tested : $readme->$readme_field;
    three hundred and thirty-six               update_post_meta( $plugin->ID, $readme_field, wp_slash( $value ) );
      three hundred and twenty-four             update_post_meta( $plugin->ID, $readme_field, wp_slash( $readme->$readme_field ) );
    three hundred and thirty-seven three hundred and twenty-five         }
    three hundred and thirty-eight three hundred and twenty-six
     
    three hundred and forty-two three hundred and thirty         }
    three hundred and forty-three three hundred and thirty-one
    three hundred and forty-four           // Update the Requires  and Requires PHP fields, prefering those from the Plugin Headers.
      three hundred and thirty-two         // Update the Requires , Requires PHP, and Tested up to fields, prefering those from the Plugin Headers.
    three hundred and forty-five three hundred and thirty-three         // Unfortunately the value within $headers is not always a well-formed value.
    three hundred and forty-six three hundred and thirty-four         $requires     = $readme->requires;
    three hundred and forty-seven three hundred and thirty-five         $requires_php = $readme->requires_php;
      three hundred and thirty-six         $tested       = $readme->tested;
    three hundred and forty-eight three hundred and thirty-seven         if ( $headers->RequiresWP && preg_match( '!^[\d.]{3,}$!', $headers->RequiresWP ) ) {
    three hundred and forty-nine three hundred and thirty-eight             $requires = $headers->RequiresWP;
     
    three hundred and fifty-one three hundred and forty         if ( $headers->RequiresPHP && preg_match( '!^[\d.]{3,}$!', $headers->RequiresPHP ) ) {
    three hundred and fifty-two three hundred and forty-one             $requires_php = $headers->RequiresPHP;
      three hundred and forty-two         }
      three hundred and forty-three         if ( $headers->TestedUpTo && preg_match( '!^[\d.]{3,}$!', $headers->TestedUpTo ) ) {
      three hundred and forty-four             $tested = $headers->TestedUpTo;
      three hundred and forty-five         }
      three hundred and forty-six
      three hundred and forty-seven         // Sanitize the tested version.
      three hundred and forty-eight         if ( function_exists( 'wporg_get_version_equivalents' ) ) {
      three hundred and forty-nine             foreach ( wporg_get_version_equivalents() as $latest_compatible_version => $compatible_with ) {
      three hundred and fifty                 if ( in_array( $tested, $compatible_with, true ) ) {
      three hundred and fifty-one                     $tested = $latest_compatible_version;
      three hundred and fifty-two                     break;
      three hundred and fifty-three                 }
      three hundred and fifty-four             }
    three hundred and fifty-three three hundred and fifty-five         }
    three hundred and fifty-four three hundred and fifty-six
     
    three hundred and sixty-four three hundred and sixty-six         update_post_meta( $plugin->ID, 'requires',           wp_slash( $requires ) );
    three hundred and sixty-five three hundred and sixty-seven         update_post_meta( $plugin->ID, 'requires_php',       wp_slash( $requires_php ) );
      three hundred and sixty-eight         update_post_meta( $plugin->ID, 'tested',             wp_slash( $tested ) );
    three hundred and sixty-six three hundred and sixty-nine         update_post_meta( $plugin->ID, 'tagged_versions',    wp_slash( array_keys( $tagged_versions ) ) );
    three hundred and sixty-seven three hundred and seventy         update_post_meta( $plugin->ID, 'sections',           wp_slash( array_keys( $readme->sections ) ) );
     
    nine hundred and seventy-three nine hundred and seventy-six         if ( ! isset( $headers['RequiresPlugins'] ) ) {
    nine hundred and seventy-four nine hundred and seventy-seven             $headers['RequiresPlugins'] = 'Requires Plugins';
      nine hundred and seventy-eight         }
      nine hundred and seventy-nine         // https://meta.trac.wordpress.org/ticket/4621
      nine hundred and eighty         if ( ! isset( $headers['TestedUpTo'] ) ) {
      nine hundred and eighty-one             $headers['TestedUpTo'] = 'Tested up to';
    nine hundred and seventy-five nine hundred and eighty-two         }
    nine hundred and seventy-six nine hundred and eighty-three
Note: See TracChangeset for help on using the changeset viewer.