Make WordPress Core


Ignore:
Timestamp:
06/15/2016 04:36:07 PM (9 years ago)
Author:
obenland
Message:

Update/Install: Shiny Updates v2.

Gone are the days of isolation and feelings of "meh", brought on by The Bleak Screen of Sadness. For a shiny knight has arrived to usher our plugins and themes along their arduous journey of installation, updates, and the inevitable fate of ultimate deletion.

Props swissspidy, adamsilverstein, mapk, afragen, ocean90, ryelle, j-falk, michael-arestad, melchoyce, DrewAPicture, AdamSoucie, ethitter, pento, dd32, kraftbj, Ipstenu, jorbin, afercia, stephdau, paulwilde, jipmoors, khag7, svovaf, jipmoors, obenland.
Fixes #22029, #25828, #31002, #31529, #31530, #31773, #33637, #35032.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-plugin-install-list-table.php

    r37488 r37714  
    462462                            $action_links[] = '<a class="install-now button" data-slug="' . esc_attr( $plugin['slug'] ) . '" href="' . esc_url( $status['url'] ) . '" aria-label="' . esc_attr( sprintf( __( 'Install %s now' ), $name ) ) . '" data-name="' . esc_attr( $name ) . '">' . __( 'Install Now' ) . '</a>';
    463463                        }
    464 
    465464                        break;
     465
    466466                    case 'update_available':
    467467                        if ( $status['url'] ) {
     
    469469                            $action_links[] = '<a class="update-now button aria-button-if-js" data-plugin="' . esc_attr( $status['file'] ) . '" data-slug="' . esc_attr( $plugin['slug'] ) . '" href="' . esc_url( $status['url'] ) . '" aria-label="' . esc_attr( sprintf( __( 'Update %s now' ), $name ) ) . '" data-name="' . esc_attr( $name ) . '">' . __( 'Update Now' ) . '</a>';
    470470                        }
    471 
    472471                        break;
     472
    473473                    case 'latest_installed':
    474474                    case 'newer_installed':
    475                         $action_links[] = '<span class="button button-disabled">' . _x( 'Installed', 'plugin' ) . '</span>';
     475                        if ( is_plugin_active( $status['file'] ) ) {
     476                            $action_links[] = '<button type="button" class="button button-disabled" disabled="disabled">' . _x( 'Active', 'plugin' ) . '</button>';
     477                        } elseif ( current_user_can( 'activate_plugins' ) ) {
     478                            $button_text  = __( 'Activate' );
     479                            $activate_url = add_query_arg( array(
     480                                '_wpnonce'    => wp_create_nonce( 'activate-plugin_' . $status['file'] ),
     481                                'action'      => 'activate',
     482                                'plugin'      => $status['file'],
     483                            ), network_admin_url( 'plugins.php' ) );
     484
     485                            if ( is_network_admin() ) {
     486                                $button_text  = __( 'Network Activate' );
     487                                $activate_url = add_query_arg( array( 'networkwide' => 1 ), $activate_url );
     488                            }
     489
     490                            $action_links[] = sprintf(
     491                                '<a href="%1$s" class="button activate-now button-secondary" aria-label="%2$s">%3$s</a>',
     492                                esc_url( $activate_url ),
     493                                /* translators: %s: Plugin name */
     494                                esc_attr( sprintf( __( 'Activate %s' ), $plugin['name'] ) ),
     495                                $button_text
     496                            );
     497                        } else {
     498                            $action_links[] = '<button type="button" class="button button-disabled" disabled="disabled">' . _x( 'Installed', 'plugin' ) . '</button>';
     499                        }
    476500                        break;
    477501                }
Note: See TracChangeset for help on using the changeset viewer.