Making WordPress.org


Ignore:
Timestamp:
10/11/2016 06:27:26 AM (9 years ago)
Author:
dd32
Message:

Plugin Directory: Remove wp-admin access and a bunch of code that's no longer needed.

See #2111.

File:
1 edited

Legend:

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

    r3782 r4212  
    8787        $post           = get_post();
    8888        $tested_up_to   = (string) get_post_meta( $post->ID, 'tested', true );
    89         $versions       = self::get_tested_up_to_versions( $tested_up_to );
    90         $tested_up_to   = $versions['tested_up_to'];
    9189        $unknown_string = _x( 'Unknown', 'unknown version', 'wporg-plugins' );
    9290        ?>
     
    9492            <label for="tested_with"><?php _e( 'Tested With:', 'wporg-plugins' ); ?></label>
    9593            <strong id="tested-with-display"><?php echo ( $tested_up_to ? sprintf( 'WordPress %s', $tested_up_to ) : $unknown_string ); ?></strong>
    96             <button type="button" class="button-link edit-tested-with hide-if-no-js">
    97                 <span aria-hidden="true"><?php _e( 'Edit', 'wporg-plugins' ); ?></span>
    98                 <span class="screen-reader-text"><?php _e( 'Edit tested with version', 'wporg-plugins' ); ?></span>
    99             </button>
    100 
    101             <div id="tested-with-select" class="plugin-control-select hide-if-js">
    102                 <input type="hidden" name="hidden_tested_with" id="hidden-tested-with" value="<?php echo esc_attr( $tested_up_to ); ?>">
    103                 <label class="screen-reader-text" for="tested-with"><?php _e( 'Version of WordPress it was tested with', 'wporg-plugins' ); ?></label>
    104                 <select name="tested_with" id="tested-with">
    105                     <?php
    106                     foreach ( $versions['versions'] as $ver ) {
    107                         printf(
    108                             '<option value="%s" %s>%s</option>',
    109                             esc_attr( $ver ),
    110                             selected( $tested_up_to, $ver, true ),
    111                             esc_html( $ver ? sprintf( 'WordPress %s', $ver ) : $unknown_string )
    112                         );
    113                     }
    114                     ?>
    115                 </select>
    116                 <button type="button" class="save-tested-with hide-if-no-js button"><?php _e( 'OK', 'wporg-plugins' ); ?></button>
    117                 <button type="button" class="cancel-tested-with hide-if-no-js button-link"><?php _e( 'Cancel', 'wporg-plugins' ); ?></button>
    118             </div>
    11994
    12095        </div><!-- .misc-pub-section --><?php
    12196    }
    12297
    123     /**
    124      * Fetch all versions which an author can set their plugin as tested with.
    125      *
    126      * This returns the latest release in the previous 4 branches, trunk, and
    127      * the current version the plugin is marked as tested with.
    128      *
    129      * @global string $wp_version The WordPress version string.
    130      *
    131      * @param string $tested_up_to The version which the plugin is currently specified as compatible to.
    132      * @return array An array containing 'versions' an array of versions for display, and 'tested_up_to'
    133      *               the sanitized/most recent version of the $tested_up_to parameter.
    134      */
    135     protected static function get_tested_up_to_versions( $tested_up_to ) {
    136         global $wp_version;
    137 
    138         // Fetch all "compatible" versions, this array is in the form of [ '4.4.2' => [ '4.4.1', '4.4' ], ...]
    139         if ( function_exists( 'wporg_get_version_equivalents' ) ) {
    140 
    141             // This function is a global WordPress.org function.
    142             $all_versions = wporg_get_version_equivalents();
    143         } else {
    144             $all_versions = array( (string)(float) $wp_version => array( $wp_version ) );
    145         }
    146 
    147         $versions = array_slice( array_keys( $all_versions ), 0, 4 );
    148 
    149         foreach( $versions as $version ) {
    150             if ( in_array( $tested_up_to, $all_versions[ $version ] ) ) {
    151                 $tested_up_to = $version;
    152                 break;
    153             }
    154         }
    155 
    156         // If the version specified isn't going to display, insert it into the list.
    157         if ( ! in_array( $tested_up_to, $versions ) ) {
    158             $versions[] = $tested_up_to;
    159         }
    160 
    161         // WordPress.org runs trunk, this keeps the highest version selectable as trunk.
    162         $versions[] = preg_replace( '!-\d{4,}$!', '', $wp_version );
    163 
    164         return compact( 'versions', 'tested_up_to' );
    165     }
    16698}
Note: See TracChangeset for help on using the changeset viewer.