list_plugin_updates

The WordPress Core list plugin updates function.

Description

list_plugin_updates(); 

Usage

  1. if ( !function_exists( 'list_plugin_updates' ) ) { 
  2. require_once ABSPATH . '/wp-admin/update-core.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = list_plugin_updates(); 
  7.  

Defined (1)

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

/wp-admin/update-core.php  
  1. function list_plugin_updates() { 
  2. $wp_version = get_bloginfo( 'version' ); 
  3. $cur_wp_version = preg_replace( '/-.*$/', '', $wp_version ); 
  4.  
  5. require_once(ABSPATH . 'wp-admin/includes/plugin-install.php'); 
  6. $plugins = get_plugin_updates(); 
  7. if ( empty( $plugins ) ) { 
  8. echo '<h2>' . __( 'Plugins' ) . '</h2>'; 
  9. echo '<p>' . __( 'Your plugins are all up to date.' ) . '</p>'; 
  10. return; 
  11. $form_action = 'update-core.php?action=do-plugin-upgrade'; 
  12.  
  13. $core_updates = get_core_updates(); 
  14. 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, '=') ) 
  15. $core_update_version = false; 
  16. else 
  17. $core_update_version = $core_updates[0]->current; 
  18. ?> 
  19. <h2><?php _e( 'Plugins' ); ?></h2> 
  20. <p><?php _e( 'The following plugins have new versions available. Check the ones you want to update and then click “Update Plugins”.' ); ?></p> 
  21. <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-plugins" class="upgrade"> 
  22. <?php wp_nonce_field('upgrade-core'); ?> 
  23. <p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p> 
  24. <table class="widefat updates-table" id="update-plugins-table"> 
  25. <thead> 
  26. <tr> 
  27. <td class="manage-column check-column"><input type="checkbox" id="plugins-select-all" /></td> 
  28. <td class="manage-column"><label for="plugins-select-all"><?php _e( 'Select All' ); ?></label></td> 
  29. </tr> 
  30. </thead> 
  31.  
  32. <tbody class="plugins"> 
  33. <?php 
  34. foreach ( (array) $plugins as $plugin_file => $plugin_data ) { 
  35. $plugin_data = (object) _get_plugin_data_markup_translate( $plugin_file, (array) $plugin_data, false, true ); 
  36.  
  37. // Get plugin compat for running version of WordPress. 
  38. if ( isset($plugin_data->update->tested) && version_compare($plugin_data->update->tested, $cur_wp_version, '>=') ) { 
  39. $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: 100%% (according to its author)'), $cur_wp_version); 
  40. } elseif ( isset($plugin_data->update->compatibility->{$cur_wp_version}) ) { 
  41. $compat = $plugin_data->update->compatibility->{$cur_wp_version}; 
  42. $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)'), $cur_wp_version, $compat->percent, $compat->votes, $compat->total_votes); 
  43. } else { 
  44. $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $cur_wp_version); 
  45. // Get plugin compat for updated version of WordPress. 
  46. if ( $core_update_version ) { 
  47. if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $core_update_version, '>=' ) ) { 
  48. $compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %1$s: 100%% (according to its author)' ), $core_update_version ); 
  49. } elseif ( isset( $plugin_data->update->compatibility->{$core_update_version} ) ) { 
  50. $update_compat = $plugin_data->update->compatibility->{$core_update_version}; 
  51. $compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)'), $core_update_version, $update_compat->percent, $update_compat->votes, $update_compat->total_votes); 
  52. } else { 
  53. $compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $core_update_version); 
  54. // Get the upgrade notice for the new plugin version. 
  55. if ( isset($plugin_data->update->upgrade_notice) ) { 
  56. $upgrade_notice = '<br />' . strip_tags($plugin_data->update->upgrade_notice); 
  57. } else { 
  58. $upgrade_notice = ''; 
  59.  
  60. $details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin_data->update->slug . '§ion=changelog&TB_iframe=true&width=640&height=662'); 
  61. $details = sprintf( 
  62. '<a href="%1$s" class="thickbox open-plugin-details-modal" aria-label="%2$s">%3$s</a>',  
  63. esc_url( $details_url ),  
  64. /** translators: 1: plugin name, 2: version number */ 
  65. esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_data->Name, $plugin_data->update->new_version ) ),  
  66. /** translators: %s: plugin version */ 
  67. sprintf( __( 'View version %s details.' ), $plugin_data->update->new_version ) 
  68. ); 
  69.  
  70. $checkbox_id = "checkbox_" . md5( $plugin_data->Name ); 
  71. ?> 
  72. <tr> 
  73. <td class="check-column"> 
  74. <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $plugin_file ); ?>" /> 
  75. <label for="<?php echo $checkbox_id; ?>" class="screen-reader-text"><?php 
  76. /** translators: %s: plugin name */ 
  77. printf( __( 'Select %s' ),  
  78. $plugin_data->Name 
  79. ); 
  80. ?></label> 
  81. </td> 
  82. <td class="plugin-title"><p> 
  83. <strong><?php echo $plugin_data->Name; ?></strong> 
  84. <?php 
  85. /** translators: 1: plugin version, 2: new version */ 
  86. printf( __( 'You have version %1$s installed. Update to %2$s.' ),  
  87. $plugin_data->Version,  
  88. $plugin_data->update->new_version 
  89. ); 
  90. echo ' ' . $details . $compat . $upgrade_notice; 
  91. ?> 
  92. </p></td> 
  93. </tr> 
  94. <?php 
  95. ?> 
  96. </tbody> 
  97.  
  98. <tfoot> 
  99. <tr> 
  100. <td class="manage-column check-column"><input type="checkbox" id="plugins-select-all-2" /></td> 
  101. <td class="manage-column"><label for="plugins-select-all-2"><?php _e( 'Select All' ); ?></label></td> 
  102. </tr> 
  103. </tfoot> 
  104. </table> 
  105. <p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p> 
  106. </form> 
  107. <?php