Making WordPress.org


Ignore:
Timestamp:
08/08/2023 05:14:08 AM (10 months ago)
Author:
dd32
Message:

Plugin Directory: Allow plugins releases to be discarded instead of confirmed.

Sometimes a release should not be released, this allows discarding those releases to cease the warnings.

See #5352.

File:
1 edited

Legend:

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

    r12617 r12813  
    800800     * Generates a link to confirm a release.
    801801     *
     802     * @param string            $tag  The tag to confirm.
    802803     * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
     804     * @param string            $what Optional. What operation to perform. Default: approve.
    803805     * @return string URL to enable confirmations.
    804806     */
    805     public static function get_release_confirmation_link( $tag, $post = null) {
     807    public static function get_release_confirmation_link( $tag, $post = null, $what = 'approve' ) {
    806808        $post = get_post( $post );
     809
     810        if ( 'approve' === $what ) {
     811            $endpoint = 'plugin/%s/release-confirmation/%s';
     812        } elseif ( 'discard' === $what ) {
     813            $endpoint = 'plugin/%s/release-confirmation/%s/discard';
     814        } else {
     815            return '';
     816        }
     817
     818        $url = home_url( 'wp-json/plugins/v1/' . sprintf( $endpoint, urlencode( $post->post_name ), urlencode( $tag ) ) );
    807819
    808820        return add_query_arg(
    809821            array( '_wpnonce' => wp_create_nonce( 'wp_rest' ) ),
    810             home_url( 'wp-json/plugins/v1/plugin/' . $post->post_name . '/release-confirmation/' . $tag )
     822            $url
    811823        );
    812824    }
Note: See TracChangeset for help on using the changeset viewer.