Using WordPress ‘list_theme_updates()’ PHP function

The list_theme_updates() WordPress PHP function displays the upgrade themes form.

Usage

To use the list_theme_updates() function, simply call the function like this:

list_theme_updates();

Parameters

  • This function does not have any parameters.

More information

See WordPress Developer Resources: list_theme_updates

Examples

Display the theme update form in a custom admin page

Create a custom admin page that displays the theme update form.

function custom_theme_updates_page() {
  add_menu_page('Theme Updates', 'Theme Updates', 'manage_options', 'theme-updates', 'display_theme_updates_page');
}
add_action('admin_menu', 'custom_theme_updates_page');

function display_theme_updates_page() {
  echo '<h1>Theme Updates</h1>';
  // Display the theme update form
  list_theme_updates();
}

Add a link to the theme update form in the WordPress admin bar for easy access.

function add_theme_updates_link($wp_admin_bar) {
  $args = array(
    'id' => 'theme_updates_link',
    'title' => 'Theme Updates',
    'href' => admin_url('themes.php?page=theme-updates'),
    'parent' => 'site-name',
  );
  $wp_admin_bar->add_node($args);
}
add_action('admin_bar_menu', 'add_theme_updates_link', 99);

Display the theme update form in a custom meta box

Add a custom meta box that displays the theme update form on the Dashboard.

function add_theme_updates_meta_box() {
  add_meta_box('theme_updates_meta_box', 'Theme Updates', 'display_theme_updates_meta_box', 'dashboard', 'normal', 'high');
}
add_action('wp_dashboard_setup', 'add_theme_updates_meta_box');

function display_theme_updates_meta_box() {
  // Display the theme update form
  list_theme_updates();
}

Display a notification on the admin dashboard if theme updates are available

Show a notification on the admin dashboard if there are theme updates available.

function theme_updates_notification() {
  if (!current_user_can('update_themes')) {
    return;
  }

  $updates = get_theme_updates();
  if (!empty($updates)) {
    echo '<div class="notice notice-info">';
    echo '<p><strong>Theme Updates Available!</strong> Visit the <a href="' . admin_url('themes.php?page=theme-updates') . '">Theme Updates</a> page to update your themes.</p>';
    echo '</div>';
  }
}
add_action('admin_notices', 'theme_updates_notification');

Automatically redirect to the theme update form after activating a new theme

Redirect the user to the theme update form after activating a new theme.

function redirect_to_theme_updates($url) {
  $url = admin_url('themes.php?page=theme-updates');
  return $url;
}
add_filter('customize_save_after', 'redirect_to_theme_updates');