list_plugin_updates() – Display the upgrade plugins form.

You appear to be a bot. Output may be restricted

Description

Display the upgrade plugins form.

Usage

list_plugin_updates();

Parameters

Returns

void

Source

File name: wordpress/wp-admin/update-core.php


Lines:

1 to 100 of 172
function list_plugin_updates() {
  $wp_version     = get_bloginfo( 'version' );
  $cur_wp_version = preg_replace( '/-.*$/', '', $wp_version );

  require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
  $plugins = get_plugin_updates();
  if ( empty( $plugins ) ) {
    echo '<h2>' . __( 'Plugins' ) . '</h2>';
    echo '<p>' . __( 'Your plugins are all up to date.' ) . '</p>';
    return;
  }
  $form_action = 'update-core.php?action=do-plugin-upgrade';

  $core_updates = get_core_updates();
  if ( ! isset( $core_updates[0]->response ) || 'latest' === $core_updates[0]->response || 'development' === $core_updates[0]->response || version_compare( $core_updates[0]->current, $cur_wp_version, '=' ) ) {
    $core_update_version = false;
  } else {
    $core_update_version = $core_updates[0]->current;
  }

  $plugins_count = count( $plugins );
  ?>
<h2>
	<?php
  printf(
    '%s <span class="count">(%d)</span>',
    __( 'Plugins' ),
    number_format_i18n( $plugins_count )
  );
  ?>
</h2>
<p><?php _e( 'The following plugins have new versions available. Check the ones you want to update and then click &#8220;Update Plugins&#8221;.' ); ?></p>
<form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-plugins" class="upgrade">
	<?php wp_nonce_field( 'upgrade-core' ); ?>
<p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e( 'Update Plugins' ); ?>" name="upgrade" /></p>
<table class="widefat updates-table" id="update-plugins-table">
	<thead>
	<tr>
		<td class="manage-column check-column"><input type="checkbox" id="plugins-select-all" /></td>
		<td class="manage-column"><label for="plugins-select-all"><?php _e( 'Select All' ); ?></label></td>
	</tr>
	</thead>

	<tbody class="plugins">
	<?php

  $auto_updates = array();
  if ( wp_is_auto_update_enabled_for_type( 'plugin' ) ) {
    $auto_updates       = (array) get_site_option( 'auto_update_plugins', array() );
    $auto_update_notice = ' | ' . wp_get_auto_update_message();
  }

  foreach ( (array) $plugins as $plugin_file => $plugin_data ) {
    $plugin_data = (object) _get_plugin_data_markup_translate( $plugin_file, (array) $plugin_data, false, true );

    $icon            = '<span class="dashicons dashicons-admin-plugins"></span>';
    $preferred_icons = array( 'svg', '2x', '1x', 'default' );
    foreach ( $preferred_icons as $preferred_icon ) {
      if ( ! empty( $plugin_data->update->icons[ $preferred_icon ] ) ) {
        $icon = '<img src="' . esc_url( $plugin_data->update->icons[ $preferred_icon ] ) . '" alt="" />';
        break;
      }
    }

    // Get plugin compat for running version of WordPress.
    if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $cur_wp_version, '>=' ) ) {
      /* translators: %s: WordPress version. */
      $compat = '<br />' . sprintf( __( 'Compatibility with WordPress %s: 100%% (according to its author)' ), $cur_wp_version );
    } else {
      /* translators: %s: WordPress version. */
      $compat = '<br />' . sprintf( __( 'Compatibility with WordPress %s: Unknown' ), $cur_wp_version );
    }
    // Get plugin compat for updated version of WordPress.
    if ( $core_update_version ) {
      if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $core_update_version, '>=' ) ) {
        /* translators: %s: WordPress version. */
        $compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %s: 100%% (according to its author)' ), $core_update_version );
      } else {
        /* translators: %s: WordPress version. */
        $compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %s: Unknown' ), $core_update_version );
      }
    }

    $requires_php   = isset( $plugin_data->update->requires_php ) ? $plugin_data->update->requires_php : null;
    $compatible_php = is_php_version_compatible( $requires_php );

    if ( ! $compatible_php && current_user_can( 'update_php' ) ) {
      $compat .= '<br />' . __( 'This update does not work with your version of PHP.' ) . '&nbsp;';
      $compat .= sprintf(
        /* translators: %s: URL to Update PHP page. */
        __( '<a href="%s">Learn more about updating PHP</a>.' ),
        esc_url( wp_get_update_php_url() )
      );

      $annotation = wp_get_update_php_annotation();

      if ( $annotation ) {
        $compat .= '</p><p><em>' . $annotation . '</em>';
      }
    }

 View on GitHub View on Trac