wp/wp-admin/network/themes.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
child 22 8c2e4d02f4ef
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
    37 if ( $action ) {
    37 if ( $action ) {
    38 	switch ( $action ) {
    38 	switch ( $action ) {
    39 		case 'enable':
    39 		case 'enable':
    40 			check_admin_referer( 'enable-theme_' . $_GET['theme'] );
    40 			check_admin_referer( 'enable-theme_' . $_GET['theme'] );
    41 			WP_Theme::network_enable_theme( $_GET['theme'] );
    41 			WP_Theme::network_enable_theme( $_GET['theme'] );
    42 			if ( false === strpos( $referer, '/network/themes.php' ) ) {
    42 			if ( ! str_contains( $referer, '/network/themes.php' ) ) {
    43 				wp_redirect( network_admin_url( 'themes.php?enabled=1' ) );
    43 				wp_redirect( network_admin_url( 'themes.php?enabled=1' ) );
    44 			} else {
    44 			} else {
    45 				wp_safe_redirect( add_query_arg( 'enabled', 1, $referer ) );
    45 				wp_safe_redirect( add_query_arg( 'enabled', 1, $referer ) );
    46 			}
    46 			}
    47 			exit;
    47 			exit;
   133 				$themes_to_delete = count( $themes );
   133 				$themes_to_delete = count( $themes );
   134 				?>
   134 				?>
   135 				<div class="wrap">
   135 				<div class="wrap">
   136 				<?php if ( 1 === $themes_to_delete ) : ?>
   136 				<?php if ( 1 === $themes_to_delete ) : ?>
   137 					<h1><?php _e( 'Delete Theme' ); ?></h1>
   137 					<h1><?php _e( 'Delete Theme' ); ?></h1>
   138 					<div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'This theme may be active on other sites in the network.' ); ?></p></div>
   138 					<?php
       
   139 					wp_admin_notice(
       
   140 						'<strong>' . __( 'Caution:' ) . '</strong> ' . __( 'This theme may be active on other sites in the network.' ),
       
   141 						array(
       
   142 							'additional_classes' => array( 'error' ),
       
   143 						)
       
   144 					);
       
   145 					?>
   139 					<p><?php _e( 'You are about to remove the following theme:' ); ?></p>
   146 					<p><?php _e( 'You are about to remove the following theme:' ); ?></p>
   140 				<?php else : ?>
   147 				<?php else : ?>
   141 					<h1><?php _e( 'Delete Themes' ); ?></h1>
   148 					<h1><?php _e( 'Delete Themes' ); ?></h1>
   142 					<div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'These themes may be active on other sites in the network.' ); ?></p></div>
   149 					<?php
       
   150 					wp_admin_notice(
       
   151 						'<strong>' . __( 'Caution:' ) . '</strong> ' . __( 'These themes may be active on other sites in the network.' ),
       
   152 						array(
       
   153 							'additional_classes' => array( 'error' ),
       
   154 						)
       
   155 					);
       
   156 					?>
   143 					<p><?php _e( 'You are about to remove the following themes:' ); ?></p>
   157 					<p><?php _e( 'You are about to remove the following themes:' ); ?></p>
   144 				<?php endif; ?>
   158 				<?php endif; ?>
   145 					<ul class="ul-disc">
   159 					<ul class="ul-disc">
   146 					<?php
   160 					<?php
   147 					foreach ( $theme_info as $theme ) {
   161 					foreach ( $theme_info as $theme ) {
   314 				'<p>' . __( 'Auto-updates can be enabled or disabled for each individual theme. Themes with auto-updates enabled will display the estimated date of the next auto-update. Auto-updates depends on the WP-Cron task scheduling system.' ) . '</p>' .
   328 				'<p>' . __( 'Auto-updates can be enabled or disabled for each individual theme. Themes with auto-updates enabled will display the estimated date of the next auto-update. Auto-updates depends on the WP-Cron task scheduling system.' ) . '</p>' .
   315 				'<p>' . __( 'Please note: Third-party themes and plugins, or custom code, may override WordPress scheduling.' ) . '</p>',
   329 				'<p>' . __( 'Please note: Third-party themes and plugins, or custom code, may override WordPress scheduling.' ) . '</p>',
   316 		)
   330 		)
   317 	);
   331 	);
   318 
   332 
   319 	$help_sidebar_autoupdates = '<p>' . __( '<a href="https://wordpress.org/support/article/plugins-themes-auto-updates/">Learn more: Auto-updates documentation</a>' ) . '</p>';
   333 	$help_sidebar_autoupdates = '<p>' . __( '<a href="https://wordpress.org/documentation/article/plugins-themes-auto-updates/">Documentation on Auto-updates</a>' ) . '</p>';
   320 }
   334 }
   321 
   335 
   322 get_current_screen()->set_help_sidebar(
   336 get_current_screen()->set_help_sidebar(
   323 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
   337 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
   324 	'<p>' . __( '<a href="https://codex.wordpress.org/Network_Admin_Themes_Screen">Documentation on Network Themes</a>' ) . '</p>' .
   338 	'<p>' . __( '<a href="https://codex.wordpress.org/Network_Admin_Themes_Screen">Documentation on Network Themes</a>' ) . '</p>' .
   325 	$help_sidebar_autoupdates .
   339 	$help_sidebar_autoupdates .
   326 	'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
   340 	'<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
   327 );
   341 );
   328 
   342 
   329 get_current_screen()->set_screen_reader_content(
   343 get_current_screen()->set_screen_reader_content(
   330 	array(
   344 	array(
   331 		'heading_views'      => __( 'Filter themes list' ),
   345 		'heading_views'      => __( 'Filter themes list' ),
   347 
   361 
   348 <div class="wrap">
   362 <div class="wrap">
   349 <h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1>
   363 <h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1>
   350 
   364 
   351 <?php if ( current_user_can( 'install_themes' ) ) : ?>
   365 <?php if ( current_user_can( 'install_themes' ) ) : ?>
   352 	<a href="theme-install.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'theme' ); ?></a>
   366 	<a href="theme-install.php" class="page-title-action"><?php echo esc_html__( 'Add New Theme' ); ?></a>
   353 <?php endif; ?>
   367 <?php endif; ?>
   354 
   368 
   355 <?php
   369 <?php
   356 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
   370 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
   357 	echo '<span class="subtitle">';
   371 	echo '<span class="subtitle">';
   365 ?>
   379 ?>
   366 
   380 
   367 <hr class="wp-header-end">
   381 <hr class="wp-header-end">
   368 
   382 
   369 <?php
   383 <?php
       
   384 $message = '';
       
   385 $type    = 'success';
       
   386 
   370 if ( isset( $_GET['enabled'] ) ) {
   387 if ( isset( $_GET['enabled'] ) ) {
   371 	$enabled = absint( $_GET['enabled'] );
   388 	$enabled = absint( $_GET['enabled'] );
   372 	if ( 1 === $enabled ) {
   389 	if ( 1 === $enabled ) {
   373 		$message = __( 'Theme enabled.' );
   390 		$message = __( 'Theme enabled.' );
   374 	} else {
   391 	} else {
   375 		/* translators: %s: Number of themes. */
   392 		$message = sprintf(
   376 		$message = _n( '%s theme enabled.', '%s themes enabled.', $enabled );
   393 			/* translators: %s: Number of themes. */
   377 	}
   394 			_n( '%s theme enabled.', '%s themes enabled.', $enabled ),
   378 	echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $enabled ) ) . '</p></div>';
   395 			number_format_i18n( $enabled )
       
   396 		);
       
   397 	}
   379 } elseif ( isset( $_GET['disabled'] ) ) {
   398 } elseif ( isset( $_GET['disabled'] ) ) {
   380 	$disabled = absint( $_GET['disabled'] );
   399 	$disabled = absint( $_GET['disabled'] );
   381 	if ( 1 === $disabled ) {
   400 	if ( 1 === $disabled ) {
   382 		$message = __( 'Theme disabled.' );
   401 		$message = __( 'Theme disabled.' );
   383 	} else {
   402 	} else {
   384 		/* translators: %s: Number of themes. */
   403 		$message = sprintf(
   385 		$message = _n( '%s theme disabled.', '%s themes disabled.', $disabled );
   404 			/* translators: %s: Number of themes. */
   386 	}
   405 			_n( '%s theme disabled.', '%s themes disabled.', $disabled ),
   387 	echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>';
   406 			number_format_i18n( $disabled )
       
   407 		);
       
   408 	}
   388 } elseif ( isset( $_GET['deleted'] ) ) {
   409 } elseif ( isset( $_GET['deleted'] ) ) {
   389 	$deleted = absint( $_GET['deleted'] );
   410 	$deleted = absint( $_GET['deleted'] );
   390 	if ( 1 === $deleted ) {
   411 	if ( 1 === $deleted ) {
   391 		$message = __( 'Theme deleted.' );
   412 		$message = __( 'Theme deleted.' );
   392 	} else {
   413 	} else {
   393 		/* translators: %s: Number of themes. */
   414 		$message = sprintf(
   394 		$message = _n( '%s theme deleted.', '%s themes deleted.', $deleted );
   415 			/* translators: %s: Number of themes. */
   395 	}
   416 			_n( '%s theme deleted.', '%s themes deleted.', $deleted ),
   396 	echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $deleted ) ) . '</p></div>';
   417 			number_format_i18n( $deleted )
       
   418 		);
       
   419 	}
   397 } elseif ( isset( $_GET['enabled-auto-update'] ) ) {
   420 } elseif ( isset( $_GET['enabled-auto-update'] ) ) {
   398 	$enabled = absint( $_GET['enabled-auto-update'] );
   421 	$enabled = absint( $_GET['enabled-auto-update'] );
   399 	if ( 1 === $enabled ) {
   422 	if ( 1 === $enabled ) {
   400 		$message = __( 'Theme will be auto-updated.' );
   423 		$message = __( 'Theme will be auto-updated.' );
   401 	} else {
   424 	} else {
   402 		/* translators: %s: Number of themes. */
   425 		$message = sprintf(
   403 		$message = _n( '%s theme will be auto-updated.', '%s themes will be auto-updated.', $enabled );
   426 			/* translators: %s: Number of themes. */
   404 	}
   427 			_n( '%s theme will be auto-updated.', '%s themes will be auto-updated.', $enabled ),
   405 	echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $enabled ) ) . '</p></div>';
   428 			number_format_i18n( $enabled )
       
   429 		);
       
   430 	}
   406 } elseif ( isset( $_GET['disabled-auto-update'] ) ) {
   431 } elseif ( isset( $_GET['disabled-auto-update'] ) ) {
   407 	$disabled = absint( $_GET['disabled-auto-update'] );
   432 	$disabled = absint( $_GET['disabled-auto-update'] );
   408 	if ( 1 === $disabled ) {
   433 	if ( 1 === $disabled ) {
   409 		$message = __( 'Theme will no longer be auto-updated.' );
   434 		$message = __( 'Theme will no longer be auto-updated.' );
   410 	} else {
   435 	} else {
   411 		/* translators: %s: Number of themes. */
   436 		$message = sprintf(
   412 		$message = _n( '%s theme will no longer be auto-updated.', '%s themes will no longer be auto-updated.', $disabled );
   437 			/* translators: %s: Number of themes. */
   413 	}
   438 			_n( '%s theme will no longer be auto-updated.', '%s themes will no longer be auto-updated.', $disabled ),
   414 	echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>';
   439 			number_format_i18n( $disabled )
       
   440 		);
       
   441 	}
   415 } elseif ( isset( $_GET['error'] ) && 'none' === $_GET['error'] ) {
   442 } elseif ( isset( $_GET['error'] ) && 'none' === $_GET['error'] ) {
   416 	echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'No theme selected.' ) . '</p></div>';
   443 	$message = __( 'No theme selected.' );
       
   444 	$type    = 'error';
   417 } elseif ( isset( $_GET['error'] ) && 'main' === $_GET['error'] ) {
   445 } elseif ( isset( $_GET['error'] ) && 'main' === $_GET['error'] ) {
   418 	echo '<div class="error notice is-dismissible"><p>' . __( 'You cannot delete a theme while it is active on the main site.' ) . '</p></div>';
   446 	$message = __( 'You cannot delete a theme while it is active on the main site.' );
   419 }
   447 	$type    = 'error';
   420 
   448 }
       
   449 
       
   450 if ( '' !== $message ) {
       
   451 	wp_admin_notice(
       
   452 		$message,
       
   453 		array(
       
   454 			'type'        => $type,
       
   455 			'dismissible' => true,
       
   456 			'id'          => 'message',
       
   457 		)
       
   458 	);
       
   459 }
   421 ?>
   460 ?>
   422 
   461 
   423 <form method="get">
   462 <form method="get">
   424 <?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?>
   463 <?php $wp_list_table->search_box( __( 'Search installed themes' ), 'theme' ); ?>
   425 </form>
   464 </form>
   426 
   465 
   427 <?php
   466 <?php
   428 $wp_list_table->views();
   467 $wp_list_table->views();
   429 
   468