Making WordPress.org

Changeset 9672


Ignore:
Timestamp:
04/01/2020 06:41:40 AM (5 years ago)
Author:
dd32
Message:

Plugin Directory: Allow plugin committers to self-close plugins.

See #1560.

Location:
sites/trunk/wordpress.org/public_html/wp-content
Files:
1 added
4 edited

Legend:

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

    r6287 r9672  
    3232        new Routes\Plugin_Committers();
    3333        new Routes\Plugin_Support_Reps();
     34        new Routes\Plugin_Self_Close();
    3435    }
    3536
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php

    r9651 r9672  
    811811
    812812    /**
     813     * Generates a link to self-close a plugin..
     814     *
     815     * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
     816     * @return string URL to toggle status.
     817     */
     818    public static function get_self_close_link( $post = null ) {
     819        $post = get_post( $post );
     820
     821        return add_query_arg(
     822            array( '_wpnonce' => wp_create_nonce( 'wp_rest' ) ),
     823            home_url( 'wp-json/plugins/v1/plugin/' . $post->post_name . '/self-close' )
     824        );
     825    }
     826
     827    /**
    813828     * Returns the reasons for closing or disabling a plugin.
    814829     *
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/inc/template-tags.php

    r9129 r9672  
    300300    );
    301301}
     302
     303/**
     304 * Displays a
     305 */
     306function the_plugin_self_close_button() {
     307    $post = get_post();
     308
     309    if ( ! current_user_can( 'plugin_add_committer', $post ) || 'publish' != $post->post_status ) {
     310        return;
     311    }
     312
     313    $close_link = Template::get_self_close_link( $post );
     314
     315    ?>
     316    <h5><?php esc_html_e( 'Close This Plugin', 'wporg-plugins' ); ?></h5>
     317    <div class="plugin-notice notice notice-warning notice-alt"><p><?php _e( '<strong>Warning:</strong> Closing your plugin is intended to be a permanent action. You will not be able to reopen it without contacting the plugins team.', 'wporg-plugins' ); ?></p></div>
     318
     319    <form method="POST" action="<?php echo esc_url( $close_link ); ?>">
     320    <p>
     321        <input class="button" type="submit" value="<?php echo esc_attr( sprintf( __( 'I understand, Please close %s.', 'wporg-plugins' ), get_the_title() ) ); ?>" />
     322    </p>
     323    </form>
     324<?php
     325}
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/section-advanced.php

    r6343 r9672  
    3535
    3636    <?php the_previous_version_download(); ?>
     37
     38    <?php the_plugin_self_close_button(); ?>
    3739</div>
Note: See TracChangeset for help on using the changeset viewer.