class-bulk-theme-upgrader-skin.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * Upgrader API: Bulk_Plugin_Upgrader_Skin class
  4. *
  5. * @package WordPress
  6. * @subpackage Upgrader
  7. * @since 4.6.0
  8. */
  9. /**
  10. * Bulk Theme Upgrader Skin for WordPress Theme Upgrades.
  11. *
  12. * @since 3.0.0
  13. * @since 4.6.0 Moved to its own file from wp-admin/includes/class-wp-upgrader-skins.php.
  14. *
  15. * @see Bulk_Upgrader_Skin
  16. */
  17. class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
  18. /**
  19. * Theme info.
  20. *
  21. * The Theme_Upgrader::bulk_upgrade() method will fill this in
  22. * with info retrieved from the Theme_Upgrader::theme_info() method,
  23. * which in turn calls the wp_get_theme() function.
  24. *
  25. * @var WP_Theme|false The theme's info object, or false.
  26. */
  27. public $theme_info = false;
  28. public function add_strings() {
  29. parent::add_strings();
  30. /* translators: 1: Theme name, 2: Number of the theme, 3: Total number of themes being updated. */
  31. $this->upgrader->strings['skin_before_update_header'] = __( 'Updating Theme %1$s (%2$d/%3$d)' );
  32. }
  33. /**
  34. * @param string $title
  35. */
  36. public function before( $title = '' ) {
  37. parent::before( $this->theme_info->display( 'Name' ) );
  38. }
  39. /**
  40. * @param string $title
  41. */
  42. public function after( $title = '' ) {
  43. parent::after( $this->theme_info->display( 'Name' ) );
  44. $this->decrement_update_count( 'theme' );
  45. }
  46. /**
  47. */
  48. public function bulk_footer() {
  49. parent::bulk_footer();
  50. $update_actions = array(
  51. 'themes_page' => sprintf(
  52. '<a href="%s" target="_parent">%s</a>',
  53. self_admin_url( 'themes.php' ),
  54. __( 'Go to Themes page' )
  55. ),
  56. 'updates_page' => sprintf(
  57. '<a href="%s" target="_parent">%s</a>',
  58. self_admin_url( 'update-core.php' ),
  59. __( 'Go to WordPress Updates page' )
  60. ),
  61. );
  62. if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) ) {
  63. unset( $update_actions['themes_page'] );
  64. }
  65. /**
  66. * Filters the list of action links available following bulk theme updates.
  67. *
  68. * @since 3.0.0
  69. *
  70. * @param string[] $update_actions Array of theme action links.
  71. * @param WP_Theme $theme_info Theme object for the last-updated theme.
  72. */
  73. $update_actions = apply_filters( 'update_bulk_theme_complete_actions', $update_actions, $this->theme_info );
  74. if ( ! empty( $update_actions ) ) {
  75. $this->feedback( implode( ' | ', (array) $update_actions ) );
  76. }
  77. }
  78. }