Making WordPress.org


Ignore:
Timestamp:
10/07/2016 06:37:32 AM (8 years ago)
Author:
dd32
Message:

Plugin Directory: Conditionally show the Tested up to: field based on whether the plugin has specified one, Automatically display the latest compatible minor release when appropriate.
For example, a plugin specifying Tested up to: 4.5.1 should automatically display Tested up to: 4.5.2 as appropriate.

Fixes #2093

File:
1 edited

Legend:

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

    r4197 r4201  
    865865                break;
    866866
     867            case 'tested':
     868                // For the tested field, we bump up the minor release to the latest compatible minor release.
     869                if ( function_exists( 'wporg_get_version_equivalents' ) ) {
     870
     871                    // As we're on a pre-filter, we'll have to detach, fetch and reattach..
     872                    remove_filter( 'get_post_metadata', array( $this, 'filter_shim_postmeta' ) );
     873                    $value = get_metadata( 'post', $object_id, $meta_key );
     874                    add_filter( 'get_post_metadata', array( $this, 'filter_shim_postmeta' ), 10, 3 );
     875
     876                    foreach ( wporg_get_version_equivalents() as $latest_compatible_version => $compatible_with ) {
     877                        if ( in_array( (string)$value[0], $compatible_with, true ) ) {
     878                            $value[0] = $latest_compatible_version;
     879                            break;
     880                        }
     881                    }
     882                }
     883                break;
     884
    867885            case false:
    868886
     
    876894                add_filter( 'get_post_metadata', array( $this, 'filter_shim_postmeta' ), 10, 3 );
    877895
    878                 $custom_meta_fields = array( 'downloads', 'rating', 'ratings' );
     896                $custom_meta_fields = array( 'downloads', 'rating', 'ratings', 'tested' );
    879897                $custom_meta_fields = apply_filters( 'wporg_plugins_custom_meta_fields', $custom_meta_fields, $object_id );
    880898
Note: See TracChangeset for help on using the changeset viewer.