wp_theme_update_row

Displays update information for a theme.

Description

(false|void) wp_theme_update_row( (string) $theme_key, (WP_Theme) $theme ); 

Returns (false|void)

Parameters (2)

0. $theme_key (string)
Theme stylesheet.
1. $theme (WP_Theme)
Theme object.

Usage

  1. if ( !function_exists( 'wp_theme_update_row' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/update.php'; 
  3.  
  4. // Theme stylesheet. 
  5. $theme_key = ''; 
  6.  
  7. // Theme object. 
  8. $theme = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wp_theme_update_row($theme_key, $theme); 
  12.  

Defined (1)

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

/wp-admin/includes/update.php  
  1. function wp_theme_update_row( $theme_key, $theme ) { 
  2. $current = get_site_transient( 'update_themes' ); 
  3.  
  4. if ( ! isset( $current->response[ $theme_key ] ) ) { 
  5. return false; 
  6.  
  7. $response = $current->response[ $theme_key ]; 
  8.  
  9. $details_url = add_query_arg( array( 
  10. 'TB_iframe' => 'true',  
  11. 'width' => 1024,  
  12. 'height' => 800,  
  13. ), $current->response[ $theme_key ]['url'] ); 
  14.  
  15. /** @var WP_MS_Themes_List_Table $wp_list_table */ 
  16. $wp_list_table = _get_list_table( 'WP_MS_Themes_List_Table' ); 
  17.  
  18. $active = $theme->is_allowed( 'network' ) ? ' active' : ''; 
  19.  
  20. echo '<tr class="plugin-update-tr' . $active . '" id="' . esc_attr( $theme->get_stylesheet() . '-update' ) . '" data-slug="' . esc_attr( $theme->get_stylesheet() ) . '"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message notice inline notice-warning notice-alt"><p>'; 
  21. if ( ! current_user_can( 'update_themes' ) ) { 
  22. /** translators: 1: theme name, 2: details URL, 3: additional link attributes, 4: version number */ 
  23. printf( __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.'),  
  24. $theme['Name'],  
  25. esc_url( $details_url ),  
  26. sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"',  
  27. /** translators: 1: theme name, 2: version number */ 
  28. esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) 
  29. ),  
  30. $response['new_version'] 
  31. ); 
  32. } elseif ( empty( $response['package'] ) ) { 
  33. /** translators: 1: theme name, 2: details URL, 3: additional link attributes, 4: version number */ 
  34. 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 theme.</em>' ),  
  35. $theme['Name'],  
  36. esc_url( $details_url ),  
  37. sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"',  
  38. /** translators: 1: theme name, 2: version number */ 
  39. esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) 
  40. ),  
  41. $response['new_version'] 
  42. ); 
  43. } else { 
  44. /** translators: 1: theme name, 2: details URL, 3: additional link attributes, 4: version number, 5: update URL, 6: additional link attributes */ 
  45. 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>.' ),  
  46. $theme['Name'],  
  47. esc_url( $details_url ),  
  48. sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"',  
  49. /** translators: 1: theme name, 2: version number */ 
  50. esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) 
  51. ),  
  52. $response['new_version'],  
  53. wp_nonce_url( self_admin_url( 'update.php?action=upgrade-theme&theme=' ) . $theme_key, 'upgrade-theme_' . $theme_key ),  
  54. sprintf( 'class="update-link" aria-label="%s"',  
  55. /** translators: %s: theme name */ 
  56. esc_attr( sprintf( __( 'Update %s now' ), $theme['Name'] ) ) 
  57. ); 
  58.  
  59. /** 
  60. * Fires at the end of the update message container in each 
  61. * row of the themes list table. 
  62. * The dynamic portion of the hook name, `$theme_key`, refers to 
  63. * the theme slug as found in the WordPress.org themes repository. 
  64. * @since 3.1.0 
  65. * @param WP_Theme $theme The WP_Theme object. 
  66. * @param array $response { 
  67. * An array of metadata about the available theme update. 
  68. * @type string $new_version New theme version. 
  69. * @type string $url Theme URL. 
  70. * @type string $package Theme update package URL. 
  71. * } 
  72. */ 
  73. do_action( "in_theme_update_message-{$theme_key}", $theme, $response ); 
  74.  
  75. echo '</p></div></td></tr>';