Make WordPress Core


Ignore:
Timestamp:
01/16/2019 05:05:37 PM (6 years ago)
Author:
flixos90
Message:

Plugins: Use centralized API to display information about updating PHP when a plugin requires a higher version.

This changeset uses the API functions introduced in [44476] to link to the resource about updating PHP when highlighting a plugin's required PHP version is not met. It furthermore expands them, introducing a new wp_update_php_annotation() function that prints the markup to indicate that the default URL has been altered by the web host, allowing it to be reused universally.

Furthermore, this changeset adds missing update_php capability checks before displaying the information about updating PHP.

Props afragen.
Fixes #45986. See #43986, #45686.

File:
1 edited

Legend:

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

    r44574 r44627  
    636636                if ( ! $compatible_php && ! $compatible_wp ) {
    637637                    _e( 'This plugin doesn’t work with your versions of WordPress and PHP. ' );
    638                     if ( current_user_can( 'update_core' ) ) {
     638                    if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
    639639                        printf(
    640                             /* translators: 1: "Update WordPress" screen URL, 2: "Updating PHP" page URL */
     640                            /* translators: 1: "Update WordPress" screen URL, 2: "Update PHP" page URL */
    641641                            __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
    642642                            self_admin_url( 'update-core.php' ),
    643                             esc_url( __( 'https://wordpress.org/support/update-php/' ) )
     643                            esc_url( wp_get_update_php_url() )
    644644                        );
    645                     } else {
     645                        wp_update_php_annotation();
     646                    } elseif ( current_user_can( 'update_core' ) ) {
    646647                        printf(
    647                             /* translators: %s: "Updating PHP" page URL */
     648                            /* translators: %s: "Update WordPress" screen URL */
     649                            __( '<a href="%s">Please update WordPress</a>.' ),
     650                            self_admin_url( 'update-core.php' )
     651                        );
     652                    } elseif ( current_user_can( 'update_php' ) ) {
     653                        printf(
     654                            /* translators: %s: "Update PHP" page URL */
    648655                            __( '<a href="%s">Learn more about updating PHP</a>.' ),
    649                             esc_url( __( 'https://wordpress.org/support/update-php/' ) )
     656                            esc_url( wp_get_update_php_url() )
    650657                        );
     658                        wp_update_php_annotation();
    651659                    }
    652660                } elseif ( ! $compatible_wp ) {
     
    661669                } elseif ( ! $compatible_php ) {
    662670                    _e( 'This plugin doesn&#8217;t work with your version of PHP. ' );
    663                     printf(
    664                         /* translators: %s: "Updating PHP" page URL */
    665                         __( '<a href="%s">Learn more about updating PHP</a>.' ),
    666                         esc_url( __( 'https://wordpress.org/support/update-php/' ) )
    667                     );
     671                    if ( current_user_can( 'update_php' ) ) {
     672                        printf(
     673                            /* translators: %s: "Update PHP" page URL */
     674                            __( '<a href="%s">Learn more about updating PHP</a>.' ),
     675                            esc_url( wp_get_update_php_url() )
     676                        );
     677                        wp_update_php_annotation();
     678                    }
    668679                }
    669680                echo '</p></div>';
Note: See TracChangeset for help on using the changeset viewer.