wp_plugin_update_row

Displays update information for a plugin.

Description

(false|void) wp_plugin_update_row( (string) $file, (array) $plugin_data ); 

Returns (false|void)

Parameters (2)

0. $file (string)
Plugin basename.
1. $plugin_data (array)
Plugin information.

Usage

  1. if ( !function_exists( 'wp_plugin_update_row' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/update.php'; 
  3.  
  4. // Plugin basename. 
  5. $file = ''; 
  6.  
  7. // Plugin information. 
  8. $plugin_data = array(); 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wp_plugin_update_row($file, $plugin_data); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/update.php  
  1. function wp_plugin_update_row( $file, $plugin_data ) { 
  2. $current = get_site_transient( 'update_plugins' ); 
  3. if ( ! isset( $current->response[ $file ] ) ) { 
  4. return false; 
  5.  
  6. $response = $current->response[ $file ]; 
  7.  
  8. $plugins_allowedtags = array( 
  9. 'a' => array( 'href' => array(), 'title' => array() ),  
  10. 'abbr' => array( 'title' => array() ),  
  11. 'acronym' => array( 'title' => array() ),  
  12. 'code' => array(),  
  13. 'em' => array(),  
  14. 'strong' => array(),  
  15. ); 
  16.  
  17. $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags ); 
  18. $details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $response->slug . '§ion=changelog&TB_iframe=true&width=600&height=800' ); 
  19.  
  20. /** @var WP_Plugins_List_Table $wp_list_table */ 
  21. $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); 
  22.  
  23. if ( is_network_admin() || ! is_multisite() ) { 
  24. if ( is_network_admin() ) { 
  25. $active_class = is_plugin_active_for_network( $file ) ? ' active' : ''; 
  26. } else { 
  27. $active_class = is_plugin_active( $file ) ? ' active' : ''; 
  28.  
  29. echo '<tr class="plugin-update-tr' . $active_class . '" id="' . esc_attr( $response->slug . '-update' ) . '" data-slug="' . esc_attr( $response->slug ) . '" data-plugin="' . esc_attr( $file ) . '"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message notice inline notice-warning notice-alt"><p>'; 
  30.  
  31. if ( ! current_user_can( 'update_plugins' ) ) { 
  32. /** translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number */ 
  33. printf( __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ),  
  34. $plugin_name,  
  35. esc_url( $details_url ),  
  36. sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"',  
  37. /** translators: 1: plugin name, 2: version number */ 
  38. esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) 
  39. ),  
  40. $response->new_version 
  41. ); 
  42. } elseif ( empty( $response->package ) ) { 
  43. /** translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number */ 
  44. printf( __( '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>' ),  
  45. $plugin_name,  
  46. esc_url( $details_url ),  
  47. sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"',  
  48. /** translators: 1: plugin name, 2: version number */ 
  49. esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) 
  50. ),  
  51. $response->new_version 
  52. ); 
  53. } else { 
  54. /** translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number, 5: update URL, 6: additional link attributes */ 
  55. printf( __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.' ),  
  56. $plugin_name,  
  57. esc_url( $details_url ),  
  58. sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"',  
  59. /** translators: 1: plugin name, 2: version number */ 
  60. esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) 
  61. ),  
  62. $response->new_version,  
  63. wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $file, 'upgrade-plugin_' . $file ),  
  64. sprintf( 'class="update-link" aria-label="%s"',  
  65. /** translators: %s: plugin name */ 
  66. esc_attr( sprintf( __( 'Update %s now' ), $plugin_name ) ) 
  67. ); 
  68.  
  69. /** 
  70. * Fires at the end of the update message container in each 
  71. * row of the plugins list table. 
  72. * The dynamic portion of the hook name, `$file`, refers to the path 
  73. * of the plugin's primary file relative to the plugins directory. 
  74. * @since 2.8.0 
  75. * @param array $plugin_data { 
  76. * An array of plugin metadata. 
  77. * @type string $name The human-readable name of the plugin. 
  78. * @type string $plugin_uri Plugin URI. 
  79. * @type string $version Plugin version. 
  80. * @type string $description Plugin description. 
  81. * @type string $author Plugin author. 
  82. * @type string $author_uri Plugin author URI. 
  83. * @type string $text_domain Plugin text domain. 
  84. * @type string $domain_path Relative path to the plugin's .mo file(s). 
  85. * @type bool $network Whether the plugin can only be activated network wide. 
  86. * @type string $title The human-readable title of the plugin. 
  87. * @type string $author_name Plugin author's name. 
  88. * @type bool $update Whether there's an available update. Default null. 
  89. * } 
  90. * @param array $response { 
  91. * An array of metadata about the available plugin update. 
  92. * @type int $id Plugin ID. 
  93. * @type string $slug Plugin slug. 
  94. * @type string $new_version New plugin version. 
  95. * @type string $url Plugin URL. 
  96. * @type string $package Plugin update package URL. 
  97. * } 
  98. */ 
  99. do_action( "in_plugin_update_message-{$file}", $plugin_data, $response ); 
  100.  
  101. echo '</p></div></td></tr>';