Making WordPress.org

Changeset 4201


Ignore:
Timestamp:
10/07/2016 06:37:32 AM (7 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

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
Files:
2 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
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-meta.php

    r4182 r4201  
    5656            </li>
    5757            <li><?php printf( __( 'Active installs: %s', 'wporg-plugins' ), '<strong>' . Template::active_installs( false ) . '</strong>' ); ?></li>
    58             <li><?php printf( __( 'Tested up to: %s', 'wporg-plugins' ), '<strong>' . (string) get_post_meta( $post->ID, 'tested', true ) . '</strong>' ); ?></li>
     58            <?php if ( $tested_up_to = (string) get_post_meta( $post->ID, 'tested', true ) ) { ?>
     59                <li><?php printf( __( 'Tested up to: %s', 'wporg-plugins' ), '<strong>' . $tested_up_to . '</strong>' ); ?></li>
     60            <?php } ?>
    5961            <?php if ( $tags = get_the_term_list( $post->ID, 'plugin_tags', '<div class="tags">', '', '</div>' ) ) : ?>
    6062                <li><?php printf( _n( 'Tag: %s', 'Tags: %s', count( get_the_terms( $post, 'plugin_tags' ) ), 'wporg-plugins' ), $tags ); ?></li>
Note: See TracChangeset for help on using the changeset viewer.