Make WordPress Core

Ticket #45986: 45986.5.diff

File 45986.5.diff, 6.3 KB (added by flixos90, 6 years ago)
  • src/wp-admin/includes/class-wp-plugin-install-list-table.php

     
    635635                                echo '<div class="notice inline notice-error notice-alt"><p>';
    636636                                if ( ! $compatible_php && ! $compatible_wp ) {
    637637                                        _e( 'This plugin doesn&#8217;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 ) {
    653661                                        _e( 'This plugin doesn&#8217;t work with your version of WordPress. ' );
     
    660668                                        }
    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>';
    670681                        }
  • src/wp-admin/includes/dashboard.php

     
    16261626                $msg = __( 'WordPress has detected that your site is running on an outdated version of PHP.' );
    16271627        }
    16281628
    1629         $update_url  = wp_get_update_php_url();
    1630         $default_url = wp_get_default_update_php_url();
    1631 
    16321629        ?>
    16331630        <p><?php echo $msg; ?></p>
    16341631
     
    16391636                <?php
    16401637                printf(
    16411638                        '<a class="button button-primary" href="%1$s" target="_blank" rel="noopener noreferrer">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
    1642                         esc_url( $update_url ),
     1639                        esc_url( wp_get_update_php_url() ),
    16431640                        __( 'Learn more about updating PHP' ),
    16441641                        /* translators: accessibility text */
    16451642                        __( '(opens in a new tab)' )
     
    16481645        </p>
    16491646        <?php
    16501647
    1651         if ( $update_url !== $default_url ) {
    1652                 ?>
    1653                 <p class="description">
    1654                         <?php
    1655                         printf(
    1656                                 /* translators: %s: default Update PHP page URL */
    1657                                 __( 'This resource is provided by your web host, and is specific to your site. For more information, <a href="%s" target="_blank">see the official WordPress documentation</a>.' ),
    1658                                 esc_url( $default_url )
    1659                         );
    1660                         ?>
    1661                 </p>
    1662                 <?php
    1663         }
     1648        wp_update_php_annotation();
    16641649}
    16651650
    16661651/**
  • src/wp-admin/includes/plugin-install.php

     
    762762
    763763        if ( ! $compatible_php ) {
    764764                echo '<div class="notice notice-error notice-alt"><p>';
    765                 printf(
    766                         /* translators: "Updating PHP" page URL */
    767                         __( '<strong>Error:</strong> This plugin <strong>requires a newer version of PHP</strong>, so unfortunately you cannot install it. <a href="%s" target="_blank">Click here to learn more about updating PHP</a>.' ),
    768                         esc_url( __( 'https://wordpress.org/support/update-php/' ) )
    769                 );
    770                 echo '</p></div>';
     765                _e( '<strong>Error:</strong> This plugin <strong>requires a newer version of PHP</strong>.' );
     766                if ( current_user_can( 'update_php' ) ) {
     767                        printf(
     768                                /* translators: %s: "Update PHP" page URL */
     769                                ' ' . __( '<a href="%s" target="_blank">Click here to learn more about updating PHP</a>.' ),
     770                                esc_url( wp_get_update_php_url() )
     771                        );
     772                        echo '</p>';
     773                        wp_update_php_annotation();
     774                } else {
     775                        echo '</p>';
     776                }
     777                echo '</div>';
    771778        }
    772779
    773780        if ( ! $tested_wp ) {
  • src/wp-includes/functions.php

     
    67166716function wp_get_default_update_php_url() {
    67176717        return _x( 'https://wordpress.org/support/update-php/', 'localized PHP upgrade information page' );
    67186718}
     6719
     6720/**
     6721 * Prints the default annotation for the web host altering the "Update PHP" page URL.
     6722 *
     6723 * This function is to be used after {@see wp_get_update_php_url()} to display a consistent
     6724 * annotation if the web host has altered the default "Update PHP" page URL.
     6725 *
     6726 * @since 5.1.0
     6727 */
     6728function wp_update_php_annotation() {
     6729        $update_url  = wp_get_update_php_url();
     6730        $default_url = wp_get_default_update_php_url();
     6731
     6732        if ( $update_url === $default_url ) {
     6733                return;
     6734        }
     6735
     6736        echo '<p class="description">';
     6737        printf(
     6738                /* translators: %s: default Update PHP page URL */
     6739                __( 'This resource is provided by your web host, and is specific to your site. For more information, <a href="%s" target="_blank">see the official WordPress documentation</a>.' ),
     6740                esc_url( $default_url )
     6741        );
     6742        echo'</p>';
     6743}