95 } |
95 } |
96 |
96 |
97 $blog_id = get_current_blog_id(); |
97 $blog_id = get_current_blog_id(); |
98 if ( is_multisite() ) { |
98 if ( is_multisite() ) { |
99 if ( current_user_can( 'install_themes' ) && current_user_can( 'manage_network_themes' ) ) { |
99 if ( current_user_can( 'install_themes' ) && current_user_can( 'manage_network_themes' ) ) { |
100 printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> or <a href="%2$s">install</a> more themes.' ), network_admin_url( 'site-themes.php?id=' . $blog_id ), network_admin_url( 'theme-install.php' ) ); |
100 printf( |
|
101 /* translators: 1: URL to Themes tab on Edit Site screen, 2: URL to Add Themes screen. */ |
|
102 __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> or <a href="%2$s">install</a> more themes.' ), |
|
103 network_admin_url( 'site-themes.php?id=' . $blog_id ), |
|
104 network_admin_url( 'theme-install.php' ) |
|
105 ); |
101 |
106 |
102 return; |
107 return; |
103 } elseif ( current_user_can( 'manage_network_themes' ) ) { |
108 } elseif ( current_user_can( 'manage_network_themes' ) ) { |
104 printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> more themes.' ), network_admin_url( 'site-themes.php?id=' . $blog_id ) ); |
109 printf( |
|
110 /* translators: %s: URL to Themes tab on Edit Site screen. */ |
|
111 __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%s">enable</a> more themes.' ), |
|
112 network_admin_url( 'site-themes.php?id=' . $blog_id ) |
|
113 ); |
105 |
114 |
106 return; |
115 return; |
107 } |
116 } |
108 // Else, fallthrough. install_themes doesn't help if you can't enable it. |
117 // Else, fallthrough. install_themes doesn't help if you can't enable it. |
109 } else { |
118 } else { |
110 if ( current_user_can( 'install_themes' ) ) { |
119 if ( current_user_can( 'install_themes' ) ) { |
111 printf( __( 'You only have one theme installed right now. Live a little! You can choose from over 1,000 free themes in the WordPress Theme Directory at any time: just click on the <a href="%s">Install Themes</a> tab above.' ), admin_url( 'theme-install.php' ) ); |
120 printf( |
|
121 /* translators: %s: URL to Add Themes screen. */ |
|
122 __( 'You only have one theme installed right now. Live a little! You can choose from over 1,000 free themes in the WordPress Theme Directory at any time: just click on the <a href="%s">Install Themes</a> tab above.' ), |
|
123 admin_url( 'theme-install.php' ) |
|
124 ); |
112 |
125 |
113 return; |
126 return; |
114 } |
127 } |
115 } |
128 } |
116 // Fallthrough. |
129 // Fallthrough. |
117 printf( __( 'Only the current theme is available to you. Contact the %s administrator for information about accessing additional themes.' ), get_site_option( 'site_name' ) ); |
130 printf( |
|
131 /* translators: %s: Network title. */ |
|
132 __( 'Only the current theme is available to you. Contact the %s administrator for information about accessing additional themes.' ), |
|
133 get_site_option( 'site_name' ) |
|
134 ); |
118 } |
135 } |
119 |
136 |
120 /** |
137 /** |
121 * @param string $which |
138 * @param string $which |
122 */ |
139 */ |
184 $author = $theme->display( 'Author' ); |
206 $author = $theme->display( 'Author' ); |
185 |
207 |
186 $activate_link = wp_nonce_url( 'themes.php?action=activate&template=' . urlencode( $template ) . '&stylesheet=' . urlencode( $stylesheet ), 'switch-theme_' . $stylesheet ); |
208 $activate_link = wp_nonce_url( 'themes.php?action=activate&template=' . urlencode( $template ) . '&stylesheet=' . urlencode( $stylesheet ), 'switch-theme_' . $stylesheet ); |
187 |
209 |
188 $actions = array(); |
210 $actions = array(); |
189 $actions['activate'] = '<a href="' . $activate_link . '" class="activatelink" title="' |
211 $actions['activate'] = sprintf( |
190 . esc_attr( sprintf( __( 'Activate “%s”' ), $title ) ) . '">' . __( 'Activate' ) . '</a>'; |
212 '<a href="%s" class="activatelink" title="%s">%s</a>', |
|
213 $activate_link, |
|
214 /* translators: %s: Theme name. */ |
|
215 esc_attr( sprintf( _x( 'Activate “%s”', 'theme' ), $title ) ), |
|
216 __( 'Activate' ) |
|
217 ); |
191 |
218 |
192 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { |
219 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { |
193 $actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="load-customize hide-if-no-customize">' |
220 $actions['preview'] .= sprintf( |
194 . __( 'Live Preview' ) . '</a>'; |
221 '<a href="%s" class="load-customize hide-if-no-customize">%s</a>', |
|
222 wp_customize_url( $stylesheet ), |
|
223 __( 'Live Preview' ) |
|
224 ); |
195 } |
225 } |
196 |
226 |
197 if ( ! is_multisite() && current_user_can( 'delete_themes' ) ) { |
227 if ( ! is_multisite() && current_user_can( 'delete_themes' ) ) { |
198 $actions['delete'] = '<a class="submitdelete deletion" href="' . wp_nonce_url( 'themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet ) |
228 $actions['delete'] = sprintf( |
199 . '" onclick="' . "return confirm( '" . esc_js( sprintf( __( "You are about to delete this theme '%s'\n 'Cancel' to stop, 'OK' to delete." ), $title ) ) |
229 '<a class="submitdelete deletion" href="%s" onclick="return confirm( \'%s\' );">%s</a>', |
200 . "' );" . '">' . __( 'Delete' ) . '</a>'; |
230 wp_nonce_url( 'themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet ), |
|
231 /* translators: %s: Theme name. */ |
|
232 esc_js( sprintf( __( "You are about to delete this theme '%s'\n 'Cancel' to stop, 'OK' to delete." ), $title ) ), |
|
233 __( 'Delete' ) |
|
234 ); |
201 } |
235 } |
202 |
236 |
203 /** This filter is documented in wp-admin/includes/class-wp-ms-themes-list-table.php */ |
237 /** This filter is documented in wp-admin/includes/class-wp-ms-themes-list-table.php */ |
204 $actions = apply_filters( 'theme_action_links', $actions, $theme, 'all' ); |
238 $actions = apply_filters( 'theme_action_links', $actions, $theme, 'all' ); |
205 |
239 |
206 /** This filter is documented in wp-admin/includes/class-wp-ms-themes-list-table.php */ |
240 /** This filter is documented in wp-admin/includes/class-wp-ms-themes-list-table.php */ |
207 $actions = apply_filters( "theme_action_links_$stylesheet", $actions, $theme, 'all' ); |
241 $actions = apply_filters( "theme_action_links_{$stylesheet}", $actions, $theme, 'all' ); |
208 $delete_action = isset( $actions['delete'] ) ? '<div class="delete-theme">' . $actions['delete'] . '</div>' : ''; |
242 $delete_action = isset( $actions['delete'] ) ? '<div class="delete-theme">' . $actions['delete'] . '</div>' : ''; |
209 unset( $actions['delete'] ); |
243 unset( $actions['delete'] ); |
210 |
244 |
|
245 $screenshot = $theme->get_screenshot(); |
211 ?> |
246 ?> |
212 |
247 |
213 <span class="screenshot hide-if-customize"> |
248 <span class="screenshot hide-if-customize"> |
214 <?php if ( $screenshot = $theme->get_screenshot() ) : ?> |
249 <?php if ( $screenshot ) : ?> |
215 <img src="<?php echo esc_url( $screenshot ); ?>" alt="" /> |
250 <img src="<?php echo esc_url( $screenshot ); ?>" alt="" /> |
216 <?php endif; ?> |
251 <?php endif; ?> |
217 </span> |
252 </span> |
218 <a href="<?php echo wp_customize_url( $stylesheet ); ?>" class="screenshot load-customize hide-if-no-customize"> |
253 <a href="<?php echo wp_customize_url( $stylesheet ); ?>" class="screenshot load-customize hide-if-no-customize"> |
219 <?php if ( $screenshot = $theme->get_screenshot() ) : ?> |
254 <?php if ( $screenshot ) : ?> |
220 <img src="<?php echo esc_url( $screenshot ); ?>" alt="" /> |
255 <img src="<?php echo esc_url( $screenshot ); ?>" alt="" /> |
221 <?php endif; ?> |
256 <?php endif; ?> |
222 </a> |
257 </a> |
223 |
258 |
224 <h3><?php echo $title; ?></h3> |
259 <h3><?php echo $title; ?></h3> |
225 <div class="theme-author"><?php printf( __( 'By %s' ), $author ); ?></div> |
260 <div class="theme-author"> |
|
261 <?php |
|
262 /* translators: %s: Theme author. */ |
|
263 printf( __( 'By %s' ), $author ); |
|
264 ?> |
|
265 </div> |
226 <div class="action-links"> |
266 <div class="action-links"> |
227 <ul> |
267 <ul> |
228 <?php foreach ( $actions as $action ) : ?> |
268 <?php foreach ( $actions as $action ) : ?> |
229 <li><?php echo $action; ?></li> |
269 <li><?php echo $action; ?></li> |
230 <?php endforeach; ?> |
270 <?php endforeach; ?> |
239 <p><strong><?php _e( 'Version:' ); ?></strong> <?php echo $version; ?></p> |
279 <p><strong><?php _e( 'Version:' ); ?></strong> <?php echo $version; ?></p> |
240 <p><?php echo $theme->display( 'Description' ); ?></p> |
280 <p><?php echo $theme->display( 'Description' ); ?></p> |
241 <?php |
281 <?php |
242 if ( $theme->parent() ) { |
282 if ( $theme->parent() ) { |
243 printf( |
283 printf( |
244 /* translators: %s: link to documentation on child themes */ |
284 /* translators: 1: Link to documentation on child themes, 2: Name of parent theme. */ |
245 ' <p class="howto">' . __( 'This <a href="%1$s">child theme</a> requires its parent theme, %2$s.' ) . '</p>', |
285 ' <p class="howto">' . __( 'This <a href="%1$s">child theme</a> requires its parent theme, %2$s.' ) . '</p>', |
246 __( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ), |
286 __( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ), |
247 $theme->parent()->display( 'Name' ) |
287 $theme->parent()->display( 'Name' ) |
248 ); |
288 ); |
249 } |
289 } |
258 /** |
298 /** |
259 * @param WP_Theme $theme |
299 * @param WP_Theme $theme |
260 * @return bool |
300 * @return bool |
261 */ |
301 */ |
262 public function search_theme( $theme ) { |
302 public function search_theme( $theme ) { |
263 // Search the features |
303 // Search the features. |
264 foreach ( $this->features as $word ) { |
304 foreach ( $this->features as $word ) { |
265 if ( ! in_array( $word, $theme->get( 'Tags' ) ) ) { |
305 if ( ! in_array( $word, $theme->get( 'Tags' ), true ) ) { |
266 return false; |
306 return false; |
267 } |
307 } |
268 } |
308 } |
269 |
309 |
270 // Match all phrases |
310 // Match all phrases. |
271 foreach ( $this->search_terms as $word ) { |
311 foreach ( $this->search_terms as $word ) { |
272 if ( in_array( $word, $theme->get( 'Tags' ) ) ) { |
312 if ( in_array( $word, $theme->get( 'Tags' ), true ) ) { |
273 continue; |
313 continue; |
274 } |
314 } |
275 |
315 |
276 foreach ( array( 'Name', 'Description', 'Author', 'AuthorURI' ) as $header ) { |
316 foreach ( array( 'Name', 'Description', 'Author', 'AuthorURI' ) as $header ) { |
277 // Don't mark up; Do translate. |
317 // Don't mark up; Do translate. |