WordPress.org

Make WordPress Core

Ticket #42404: 42404.patch

File 42404.patch, 4.4 KB (added by antonioeatgoat, 4 years ago)

Handled singular capability 'delete_plugin'. It still needs unit tests.

  • src/wp-admin/includes/ajax-actions.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    42104210                'slug'   => sanitize_key( wp_unslash( $_POST['slug'] ) ),
    42114211        );
    42124212
    4213         if ( ! current_user_can( 'delete_plugins' ) || 0 !== validate_file( $plugin ) ) {
    4214                 $status['errorMessage'] = __( 'Sorry, you are not allowed to delete plugins for this site.' );
     4213        if ( ! current_user_can( 'delete_plugin', $plugin ) || 0 !== validate_file( $plugin ) ) {
     4214                $status['errorMessage'] = __( 'Sorry, you are not allowed to delete this plugin.' );
    42154215                wp_send_json_error( $status );
    42164216        }
    42174217
  • src/wp-admin/includes/class-wp-plugins-list-table.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    628628                                                /* translators: %s: plugin name */
    629629                                                $actions['activate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . urlencode( $plugin_file ) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'activate-plugin_' . $plugin_file ) . '" class="edit" aria-label="' . esc_attr( sprintf( _x( 'Network Activate %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Network Activate' ) . '</a>';
    630630                                        }
    631                                         if ( current_user_can( 'delete_plugins' ) && ! is_plugin_active( $plugin_file ) ) {
     631                                        if ( current_user_can( 'delete_plugin', $plugin_file ) && ! is_plugin_active( $plugin_file ) ) {
    632632                                                /* translators: %s: plugin name */
    633633                                                $actions['delete'] = '<a href="' . wp_nonce_url( 'plugins.php?action=delete-selected&amp;checked[]=' . urlencode( $plugin_file ) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins' ) . '" class="delete" aria-label="' . esc_attr( sprintf( _x( 'Delete %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Delete' ) . '</a>';
    634634                                        }
     
    653653                                                $actions['activate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . urlencode( $plugin_file ) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'activate-plugin_' . $plugin_file ) . '" class="edit" aria-label="' . esc_attr( sprintf( _x( 'Activate %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Activate' ) . '</a>';
    654654                                        }
    655655
    656                                         if ( ! is_multisite() && current_user_can( 'delete_plugins' ) ) {
     656                                        if ( ! is_multisite() && current_user_can( 'delete_plugin', $plugin_file ) ) {
    657657                                                /* translators: %s: plugin name */
    658658                                                $actions['delete'] = '<a href="' . wp_nonce_url( 'plugins.php?action=delete-selected&amp;checked[]=' . urlencode( $plugin_file ) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins' ) . '" class="delete" aria-label="' . esc_attr( sprintf( _x( 'Delete %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Delete' ) . '</a>';
    659659                                        }
  • src/wp-admin/plugins.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    248248                        exit;
    249249
    250250                case 'delete-selected':
    251                         if ( ! current_user_can( 'delete_plugins' ) ) {
    252                                 wp_die( __( 'Sorry, you are not allowed to delete plugins for this site.' ) );
     251                        if ( ! current_user_can( 'delete_plugin', $plugin ) ) {
     252                                wp_die( __( 'Sorry, you are not allowed to delete this plugin.' ) );
    253253                        }
    254254
    255255                        check_admin_referer( 'bulk-plugins' );
  • src/wp-includes/capabilities.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    416416                        break;
    417417                case 'update_plugins':
    418418                case 'delete_plugins':
     419                case 'delete_plugin':
    419420                case 'install_plugins':
    420421                case 'upload_plugins':
    421422                case 'update_themes':