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