Make WordPress Core


Ignore:
Timestamp:
08/27/2021 03:42:36 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Plugins: Display a message on Plugins list table if a plugin requires a higher version of PHP or WordPress.

Installation and activation of incompatible plugins was previously disallowed in [43436] and [44978], but if such a plugin was installed manually, there was nothing on the Plugins screen that would show its compatibility status.

Showing an appropriate notice with a documentation link makes the UI more consistent and improves user experience.

Follow-up to [43436], [44937], [44939], [44978], [45043], [45165], [45546], [47573], [47816], [47819], [48172], [48636], [48637], [48638], [48640], [48652], [48653], [48654], [48660].

Props TacoVerdo, SergeyBiryukov.
Fixes #53990.

File:
1 edited

Legend:

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

    r50921 r51678  
    587587                                                        );
    588588                                                } elseif ( current_user_can( 'activate_plugin', $status['file'] ) ) {
    589                                                         $button_text = __( 'Activate' );
    590                                                         /* translators: %s: Plugin name. */
    591                                                         $button_label = _x( 'Activate %s', 'plugin' );
    592                                                         $activate_url = add_query_arg(
    593                                                                 array(
    594                                                                         '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $status['file'] ),
    595                                                                         'action'   => 'activate',
    596                                                                         'plugin'   => $status['file'],
    597                                                                 ),
    598                                                                 network_admin_url( 'plugins.php' )
    599                                                         );
    600 
    601                                                         if ( is_network_admin() ) {
    602                                                                 $button_text = __( 'Network Activate' );
     589                                                        if ( $compatible_php && $compatible_wp ) {
     590                                                                $button_text = __( 'Activate' );
    603591                                                                /* translators: %s: Plugin name. */
    604                                                                 $button_label = _x( 'Network Activate %s', 'plugin' );
    605                                                                 $activate_url = add_query_arg( array( 'networkwide' => 1 ), $activate_url );
     592                                                                $button_label = _x( 'Activate %s', 'plugin' );
     593                                                                $activate_url = add_query_arg(
     594                                                                        array(
     595                                                                                '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $status['file'] ),
     596                                                                                'action'   => 'activate',
     597                                                                                'plugin'   => $status['file'],
     598                                                                        ),
     599                                                                        network_admin_url( 'plugins.php' )
     600                                                                );
     601
     602                                                                if ( is_network_admin() ) {
     603                                                                        $button_text = __( 'Network Activate' );
     604                                                                        /* translators: %s: Plugin name. */
     605                                                                        $button_label = _x( 'Network Activate %s', 'plugin' );
     606                                                                        $activate_url = add_query_arg( array( 'networkwide' => 1 ), $activate_url );
     607                                                                }
     608
     609                                                                $action_links[] = sprintf(
     610                                                                        '<a href="%1$s" class="button activate-now" aria-label="%2$s">%3$s</a>',
     611                                                                        esc_url( $activate_url ),
     612                                                                        esc_attr( sprintf( $button_label, $plugin['name'] ) ),
     613                                                                        $button_text
     614                                                                );
     615                                                        } else {
     616                                                                $action_links[] = sprintf(
     617                                                                        '<button type="button" class="button button-disabled" disabled="disabled">%s</button>',
     618                                                                        _x( 'Cannot Activate', 'plugin' )
     619                                                                );
    606620                                                        }
    607 
    608                                                         $action_links[] = sprintf(
    609                                                                 '<a href="%1$s" class="button activate-now" aria-label="%2$s">%3$s</a>',
    610                                                                 esc_url( $activate_url ),
    611                                                                 esc_attr( sprintf( $button_label, $plugin['name'] ) ),
    612                                                                 $button_text
    613                                                         );
    614621                                                } else {
    615622                                                        $action_links[] = sprintf(
Note: See TracChangeset for help on using the changeset viewer.