34 |
49 |
35 parent::__construct( $args ); |
50 parent::__construct( $args ); |
36 } |
51 } |
37 |
52 |
38 /** |
53 /** |
|
54 * Action to perform following a single theme update. |
|
55 * |
|
56 * @since 2.8.0 |
39 */ |
57 */ |
40 public function after() { |
58 public function after() { |
41 $this->decrement_update_count( 'theme' ); |
59 $this->decrement_update_count( 'theme' ); |
42 |
60 |
43 $update_actions = array(); |
61 $update_actions = array(); |
44 if ( ! empty( $this->upgrader->result['destination_name'] ) && $theme_info = $this->upgrader->theme_info() ) { |
62 $theme_info = $this->upgrader->theme_info(); |
|
63 if ( $theme_info ) { |
45 $name = $theme_info->display( 'Name' ); |
64 $name = $theme_info->display( 'Name' ); |
46 $stylesheet = $this->upgrader->result['destination_name']; |
65 $stylesheet = $this->upgrader->result['destination_name']; |
47 $template = $theme_info->get_template(); |
66 $template = $theme_info->get_template(); |
48 |
67 |
49 $activate_link = add_query_arg( |
68 $activate_link = add_query_arg( |
61 'theme' => urlencode( $stylesheet ), |
80 'theme' => urlencode( $stylesheet ), |
62 'return' => urlencode( admin_url( 'themes.php' ) ), |
81 'return' => urlencode( admin_url( 'themes.php' ) ), |
63 ), |
82 ), |
64 admin_url( 'customize.php' ) |
83 admin_url( 'customize.php' ) |
65 ); |
84 ); |
66 if ( get_stylesheet() == $stylesheet ) { |
85 |
|
86 if ( get_stylesheet() === $stylesheet ) { |
67 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { |
87 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { |
68 $update_actions['preview'] = '<a href="' . esc_url( $customize_url ) . '" class="hide-if-no-customize load-customize">'; |
88 $update_actions['preview'] = sprintf( |
69 $update_actions['preview'] .= '<span aria-hidden="true">' . __( 'Customize' ) . '</span>'; |
89 '<a href="%s" class="hide-if-no-customize load-customize">' . |
70 /* translators: %s: theme name */ |
90 '<span aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', |
71 $update_actions['preview'] .= '<span class="screen-reader-text">' . sprintf( __( 'Customize “%s”' ), $name ) . '</span></a>'; |
91 esc_url( $customize_url ), |
|
92 __( 'Customize' ), |
|
93 /* translators: %s: Theme name. */ |
|
94 sprintf( __( 'Customize “%s”' ), $name ) |
|
95 ); |
72 } |
96 } |
73 } elseif ( current_user_can( 'switch_themes' ) ) { |
97 } elseif ( current_user_can( 'switch_themes' ) ) { |
74 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { |
98 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { |
75 $update_actions['preview'] = '<a href="' . esc_url( $customize_url ) . '" class="hide-if-no-customize load-customize">'; |
99 $update_actions['preview'] = sprintf( |
76 $update_actions['preview'] .= '<span aria-hidden="true">' . __( 'Live Preview' ) . '</span>'; |
100 '<a href="%s" class="hide-if-no-customize load-customize">' . |
77 /* translators: %s: theme name */ |
101 '<span aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', |
78 $update_actions['preview'] .= '<span class="screen-reader-text">' . sprintf( __( 'Live Preview “%s”' ), $name ) . '</span></a>'; |
102 esc_url( $customize_url ), |
|
103 __( 'Live Preview' ), |
|
104 /* translators: %s: Theme name. */ |
|
105 sprintf( __( 'Live Preview “%s”' ), $name ) |
|
106 ); |
79 } |
107 } |
80 $update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink">'; |
108 |
81 $update_actions['activate'] .= '<span aria-hidden="true">' . __( 'Activate' ) . '</span>'; |
109 $update_actions['activate'] = sprintf( |
82 /* translators: %s: theme name */ |
110 '<a href="%s" class="activatelink">' . |
83 $update_actions['activate'] .= '<span class="screen-reader-text">' . sprintf( __( 'Activate “%s”' ), $name ) . '</span></a>'; |
111 '<span aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', |
|
112 esc_url( $activate_link ), |
|
113 __( 'Activate' ), |
|
114 /* translators: %s: Theme name. */ |
|
115 sprintf( _x( 'Activate “%s”', 'theme' ), $name ) |
|
116 ); |
84 } |
117 } |
85 |
118 |
86 if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() ) { |
119 if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() ) { |
87 unset( $update_actions['preview'], $update_actions['activate'] ); |
120 unset( $update_actions['preview'], $update_actions['activate'] ); |
88 } |
121 } |
89 } |
122 } |
90 |
123 |
91 $update_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>'; |
124 $update_actions['themes_page'] = sprintf( |
|
125 '<a href="%s" target="_parent">%s</a>', |
|
126 self_admin_url( 'themes.php' ), |
|
127 __( 'Return to Themes page' ) |
|
128 ); |
92 |
129 |
93 /** |
130 /** |
94 * Filters the list of action links available following a single theme update. |
131 * Filters the list of action links available following a single theme update. |
95 * |
132 * |
96 * @since 2.8.0 |
133 * @since 2.8.0 |