wp_plugin_update_row() – Displays update information for a plugin.

You appear to be a bot. Output may be restricted

Description

Displays update information for a plugin.

Usage

$void|false = wp_plugin_update_row( $file, $plugin_data );

Parameters

$file
( string ) required – Plugin basename.
$plugin_data
( array ) required – Plugin information.

Returns

void|false

Source

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


Lines:

1 to 100 of 172
function wp_plugin_update_row( $file, $plugin_data ) {
  $current = get_site_transient( 'update_plugins' );
  if ( ! isset( $current->response[ $file ] ) ) {
    return false;
  }

  $response = $current->response[ $file ];

  $plugins_allowedtags = array(
    'a'       => array(
      'href'  => array(),
      'title' => array(),
    ),
    'abbr'    => array( 'title' => array() ),
    'acronym' => array( 'title' => array() ),
    'code'    => array(),
    'em'      => array(),
    'strong'  => array(),
  );

  $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags );
  $plugin_slug = isset( $response->slug ) ? $response->slug : $response->id;

  if ( isset( $response->slug ) ) {
    $details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_slug . '&section=changelog' );
  } elseif ( isset( $response->url ) ) {
    $details_url = $response->url;
  } else {
    $details_url = $plugin_data['PluginURI'];
  }

  $details_url = add_query_arg(
    array(
      'TB_iframe' => 'true',
      'width'     => 600,
      'height'    => 800,
    ),
    $details_url
  );

  
/** @var WP_Plugins_List_Table $wp_list_table */
  $wp_list_table = _get_list_table(
    'WP_Plugins_List_Table',
    array(
      'screen' => get_current_screen(),
    )
  );

  if ( is_network_admin() || ! is_multisite() ) {
    if ( is_network_admin() ) {
      $active_class = is_plugin_active_for_network( $file ) ? ' active' : '';
    } else {
      $active_class = is_plugin_active( $file ) ? ' active' : '';
    }

    $requires_php   = isset( $response->requires_php ) ? $response->requires_php : null;
    $compatible_php = is_php_version_compatible( $requires_php );
    $notice_type    = $compatible_php ? 'notice-warning' : 'notice-error';

    printf(
      '<tr class="plugin-update-tr%s" id="%s" data-slug="%s" data-plugin="%s">' .
      '<td colspan="%s" class="plugin-update colspanchange">' .
      '<div class="update-message notice inline %s notice-alt"><p>',
      $active_class,
      esc_attr( $plugin_slug . '-update' ),
      esc_attr( $plugin_slug ),
      esc_attr( $file ),
      esc_attr( $wp_list_table->get_column_count() ),
      $notice_type
    );

    if ( ! current_user_can( 'update_plugins' ) ) {
      printf(
        /* translators: 1: Plugin name, 2: Details URL, 3: Additional link attributes, 4: Version number. */
        __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ),
        $plugin_name,
        esc_url( $details_url ),
        sprintf(
          'class="thickbox open-plugin-details-modal" aria-label="%s"',
          /* translators: 1: Plugin name, 2: Version number. */
          esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) )
        ),
        esc_attr( $response->new_version )
      );
    } elseif ( empty( $response->package ) ) {
      printf(
        /* translators: 1: Plugin name, 2: Details URL, 3: Additional link attributes, 4: Version number. */
        __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this plugin.</em>' ),
        $plugin_name,
        esc_url( $details_url ),
        sprintf(
          'class="thickbox open-plugin-details-modal" aria-label="%s"',
          /* translators: 1: Plugin name, 2: Version number. */
          esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) )
        ),
        esc_attr( $response->new_version )
      );
    } else {
      if ( $compatible_php ) {

 View on GitHub View on Trac