diff --git a/src/wp-admin/includes/class-wp-ms-themes-list-table.php b/src/wp-admin/includes/class-wp-ms-themes-list-table.php
index 70187f44d446b..3aaa0d2d9a4a2 100644
--- a/src/wp-admin/includes/class-wp-ms-themes-list-table.php
+++ b/src/wp-admin/includes/class-wp-ms-themes-list-table.php
@@ -118,6 +118,7 @@ public function prepare_items() {
'disabled' => array(),
'upgrade' => array(),
'broken' => $this->is_site_themes ? array() : wp_get_themes( array( 'errors' => true ) ),
+ 'default' => array( wp_get_theme( WP_Theme::network_get_default_theme() ) ),
);
if ( $this->show_autoupdates ) {
@@ -436,6 +437,9 @@ protected function get_views() {
$count
);
break;
+ case 'default':
+ $text = __( 'Default' ) . ' (1)';
+ break;
}
if ( $this->is_site_themes ) {
@@ -562,6 +566,7 @@ public function column_name( $theme ) {
'enable' => '',
'disable' => '',
'delete' => '',
+ 'default' => '',
);
$stylesheet = $theme->get_stylesheet();
@@ -949,9 +954,19 @@ public function single_row_columns( $item ) {
if ( $stylesheet !== $template && $item->get_stylesheet() === $stylesheet ) {
$active_theme_label = ' — ' . __( 'Active Child Theme' );
}
+
+ /* In case this is the network default theme */
+ if ( $item->get_stylesheet() === $item->network_get_default_theme() ) {
+ $active_theme_label = ' — ' . __( 'Default Theme' );
+ }
}
- echo "
" . $item->display( 'Name' ) . $active_theme_label . '';
+ printf(
+ " | %s%s",
+ $extra_classes,
+ $item->display( 'Name' ),
+ $active_theme_label
+ );
$this->column_name( $item );
diff --git a/src/wp-admin/network/themes.php b/src/wp-admin/network/themes.php
index 9794c08f8f5e0..07b3bdbe87f93 100644
--- a/src/wp-admin/network/themes.php
+++ b/src/wp-admin/network/themes.php
@@ -50,6 +50,11 @@
WP_Theme::network_disable_theme( $_GET['theme'] );
wp_safe_redirect( add_query_arg( 'disabled', '1', $referer ) );
exit;
+ case 'default':
+ check_admin_referer( 'default-theme_' . $_GET['theme'] );
+ WP_Theme::network_set_default_theme( $_GET['theme'] );
+ wp_safe_redirect( add_query_arg( 'default', '1', $referer ) );
+ exit;
case 'enable-selected':
check_admin_referer( 'bulk-themes' );
$themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
diff --git a/src/wp-includes/class-wp-theme.php b/src/wp-includes/class-wp-theme.php
index ee74099766160..0d00d8a294a9e 100644
--- a/src/wp-includes/class-wp-theme.php
+++ b/src/wp-includes/class-wp-theme.php
@@ -2097,6 +2097,39 @@ public static function network_disable_theme( $stylesheets ) {
update_site_option( 'allowedthemes', $allowed_themes );
}
+ /**
+ * Set the network default theme.
+ *
+ * @since 5.0.0
+ * @access public
+ * @static
+ *
+ * @param string $stylesheet name.
+ */
+ public static function network_set_default_theme( $stylesheet ) {
+ if ( ! is_multisite() ) {
+ return;
+ }
+
+ $theme = wp_get_theme( $stylesheet );
+ if ( ! $theme->exists() || ! $theme->is_allowed() ) {
+ return;
+ }
+
+ update_network_option( null, 'default_theme', $stylesheet );
+ }
+
+ /**
+ * Get the network default theme.
+ *
+ * @since 5.0.0
+ * @access public
+ * @static
+ */
+ public static function network_get_default_theme() {
+ return get_network_option( null, 'default_theme', WP_DEFAULT_THEME );
+ }
+
/**
* Sorts themes by name.
*
|