Make WordPress Core

Changeset 44939


Ignore:
Timestamp:
03/20/2019 02:58:03 PM (6 years ago)
Author:
desrosj
Message:

Plugins: Block plugin updates on the update screen if required PHP version is not supported.

This brings the changes in [44937] to the WordPress Updates page in the admin. Now, when a site does not meet the minimum PHP version requirements for a plugin update, the user will not be able to update. Instead, they will be presented with educational information to guide them through the process of updating PHP.

Props afragen, miyauchi, TimothyBlynJacobs, desrosj.
Fixes #44350.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/update-core.php

    r44700 r44939  
    295295            }
    296296        }
     297
     298        $compatible_php = ( empty( $plugin_data->update->requires_php ) || version_compare( phpversion(), $plugin_data->update->requires_php, '>=' ) );
     299
     300        if ( ! $compatible_php && current_user_can( 'update_php' ) ) {
     301            $compat .= '<br>' . __( 'This update doesn&#8217;t work with your version of PHP.' ) . '&nbsp;';
     302            /* translators: %s: Update PHP page URL */
     303            $compat .= sprintf(
     304                __( '<a href="%s">Learn more about updating PHP.</a>' ),
     305                esc_url( wp_get_update_php_url() )
     306            );
     307            $compat .= '</p><p><em>' . wp_get_update_php_annotation() . '</em>';
     308        }
     309
    297310        // Get the upgrade notice for the new plugin version.
    298311        if ( isset( $plugin_data->update->upgrade_notice ) ) {
     
    316329    <tr>
    317330        <td class="check-column">
     331        <?php if ( $compatible_php ) : ?>
    318332            <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $plugin_file ); ?>" />
    319333            <label for="<?php echo $checkbox_id; ?>" class="screen-reader-text">
     
    326340            ?>
    327341            </label>
     342        <?php endif; ?>
    328343        </td>
    329344        <td class="plugin-title"><p>
    330                 <?php echo $icon; ?>
     345            <?php echo $icon; ?>
    331346            <strong><?php echo $plugin_data->Name; ?></strong>
    332347            <?php
     
    337352                $plugin_data->update->new_version
    338353            );
    339                 echo ' ' . $details . $compat . $upgrade_notice;
     354            echo ' ' . $details . $compat . $upgrade_notice;
    340355            ?>
    341356        </p></td>
    342357    </tr>
    343             <?php
     358        <?php
    344359    }
    345360    ?>
Note: See TracChangeset for help on using the changeset viewer.