2010-07-30 20:34:54 +00:00
<? php
/**
* Multisite themes administration panel.
*
* @package WordPress
* @subpackage Multisite
2010-10-31 09:37:15 +00:00
* @since 3.1.0
2010-07-30 20:34:54 +00:00
*/
2010-11-10 14:27:15 +00:00
/** Load WordPress Administration Bootstrap */
2013-09-25 00:18:11 +00:00
require_once ( dirname ( __FILE__ ) . '/admin.php' );
2010-07-30 20:34:54 +00:00
2017-11-30 23:11:00 +00:00
if ( ! current_user_can ( 'manage_network_themes' ) ) {
2016-06-29 15:16:29 +00:00
wp_die ( __ ( 'Sorry, you are not allowed to manage network themes.' ) );
2017-11-30 23:11:00 +00:00
}
2010-12-15 19:24:42 +00:00
2017-11-30 23:11:00 +00:00
$wp_list_table = _get_list_table ( 'WP_MS_Themes_List_Table' );
$pagenum = $wp_list_table -> get_pagenum ();
2010-07-30 20:34:54 +00:00
2010-10-31 09:37:15 +00:00
$action = $wp_list_table -> current_action ();
2017-11-30 23:11:00 +00:00
$s = isset ( $_REQUEST [ 's' ] ) ? $_REQUEST [ 's' ] : '' ;
2010-10-31 09:37:15 +00:00
// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
2017-11-30 23:11:00 +00:00
$temp_args = array ( 'enabled' , 'disabled' , 'deleted' , 'error' );
2010-12-24 17:41:36 +00:00
$_SERVER [ 'REQUEST_URI' ] = remove_query_arg ( $temp_args , $_SERVER [ 'REQUEST_URI' ] );
2017-11-30 23:11:00 +00:00
$referer = remove_query_arg ( $temp_args , wp_get_referer () );
2010-10-31 09:37:15 +00:00
if ( $action ) {
switch ( $action ) {
2010-11-08 21:52:54 +00:00
case 'enable' :
2017-11-30 23:11:00 +00:00
check_admin_referer ( 'enable-theme_' . $_GET [ 'theme' ] );
2016-04-14 03:40:27 +00:00
WP_Theme :: network_enable_theme ( $_GET [ 'theme' ] );
2017-11-30 23:11:00 +00:00
if ( false === strpos ( $referer , '/network/themes.php' ) ) {
2012-06-12 15:31:25 +00:00
wp_redirect ( network_admin_url ( 'themes.php?enabled=1' ) );
2017-11-30 23:11:00 +00:00
} else {
2012-06-12 15:31:25 +00:00
wp_safe_redirect ( add_query_arg ( 'enabled' , 1 , $referer ) );
2017-11-30 23:11:00 +00:00
}
2010-12-24 17:41:36 +00:00
exit ;
2010-11-08 21:52:54 +00:00
case 'disable' :
2017-11-30 23:11:00 +00:00
check_admin_referer ( 'disable-theme_' . $_GET [ 'theme' ] );
2016-04-14 03:40:27 +00:00
WP_Theme :: network_disable_theme ( $_GET [ 'theme' ] );
2011-12-10 18:26:48 +00:00
wp_safe_redirect ( add_query_arg ( 'disabled' , '1' , $referer ) );
2010-10-31 09:37:15 +00:00
exit ;
2010-11-08 21:52:54 +00:00
case 'enable-selected' :
2017-11-30 23:11:00 +00:00
check_admin_referer ( 'bulk-themes' );
2010-10-31 09:37:15 +00:00
$themes = isset ( $_POST [ 'checked' ] ) ? ( array ) $_POST [ 'checked' ] : array ();
2017-11-30 23:11:00 +00:00
if ( empty ( $themes ) ) {
2011-12-10 18:26:48 +00:00
wp_safe_redirect ( add_query_arg ( 'error' , 'none' , $referer ) );
2010-10-31 09:37:15 +00:00
exit ;
2010-12-24 17:41:36 +00:00
}
2016-04-14 03:40:27 +00:00
WP_Theme :: network_enable_theme ( ( array ) $themes );
2011-12-10 18:26:48 +00:00
wp_safe_redirect ( add_query_arg ( 'enabled' , count ( $themes ), $referer ) );
2010-12-24 17:41:36 +00:00
exit ;
2010-11-08 21:52:54 +00:00
case 'disable-selected' :
2017-11-30 23:11:00 +00:00
check_admin_referer ( 'bulk-themes' );
2010-11-04 20:11:08 +00:00
$themes = isset ( $_POST [ 'checked' ] ) ? ( array ) $_POST [ 'checked' ] : array ();
2017-11-30 23:11:00 +00:00
if ( empty ( $themes ) ) {
2011-12-10 18:26:48 +00:00
wp_safe_redirect ( add_query_arg ( 'error' , 'none' , $referer ) );
2010-11-04 20:11:08 +00:00
exit ;
2010-12-24 17:41:36 +00:00
}
2016-04-14 03:40:27 +00:00
WP_Theme :: network_disable_theme ( ( array ) $themes );
2011-12-10 18:26:48 +00:00
wp_safe_redirect ( add_query_arg ( 'disabled' , count ( $themes ), $referer ) );
2010-12-24 17:41:36 +00:00
exit ;
2017-11-30 23:11:00 +00:00
case 'update-selected' :
2011-10-03 14:35:43 +00:00
check_admin_referer ( 'bulk-themes' );
2017-11-30 23:11:00 +00:00
if ( isset ( $_GET [ 'themes' ] ) ) {
2011-10-03 14:35:43 +00:00
$themes = explode ( ',' , $_GET [ 'themes' ] );
2017-11-30 23:11:00 +00:00
} elseif ( isset ( $_POST [ 'checked' ] ) ) {
2011-10-03 14:35:43 +00:00
$themes = ( array ) $_POST [ 'checked' ];
2017-11-30 23:11:00 +00:00
} else {
2011-10-03 14:35:43 +00:00
$themes = array ();
2017-11-30 23:11:00 +00:00
}
2011-10-03 14:35:43 +00:00
2017-11-30 23:11:00 +00:00
$title = __ ( 'Update Themes' );
2011-10-03 14:35:43 +00:00
$parent_file = 'themes.php' ;
2017-11-30 23:11:00 +00:00
require_once ( ABSPATH . 'wp-admin/admin-header.php' );
2011-10-03 14:35:43 +00:00
echo '<div class="wrap">' ;
2015-06-27 15:41:25 +00:00
echo '<h1>' . esc_html ( $title ) . '</h1>' ;
2011-10-03 14:35:43 +00:00
2017-11-30 23:11:00 +00:00
$url = self_admin_url ( 'update.php?action=update-selected-themes&themes=' . urlencode ( join ( ',' , $themes ) ) );
$url = wp_nonce_url ( $url , 'bulk-update-themes' );
2011-10-03 14:35:43 +00:00
echo "<iframe src=' $url ' style='width: 100%; height:100%; min-height:850px;'></iframe>" ;
echo '</div>' ;
2017-11-30 23:11:00 +00:00
require_once ( ABSPATH . 'wp-admin/admin-footer.php' );
2011-10-03 14:35:43 +00:00
exit ;
2010-12-21 16:50:16 +00:00
case 'delete-selected' :
2014-10-08 19:05:20 +00:00
if ( ! current_user_can ( 'delete_themes' ) ) {
2017-11-30 23:11:00 +00:00
wp_die ( __ ( 'Sorry, you are not allowed to delete themes for this site.' ) );
2014-10-08 19:05:20 +00:00
}
2010-12-23 18:53:44 +00:00
check_admin_referer ( 'bulk-themes' );
2010-12-21 16:50:16 +00:00
$themes = isset ( $_REQUEST [ 'checked' ] ) ? ( array ) $_REQUEST [ 'checked' ] : array ();
2010-12-24 17:41:36 +00:00
2010-12-21 16:50:16 +00:00
if ( empty ( $themes ) ) {
2011-12-10 18:26:48 +00:00
wp_safe_redirect ( add_query_arg ( 'error' , 'none' , $referer ) );
2010-12-21 16:50:16 +00:00
exit ;
}
2014-10-05 20:37:17 +00:00
$themes = array_diff ( $themes , array ( get_option ( 'stylesheet' ), get_option ( 'template' ) ) );
2011-12-08 23:02:33 +00:00
2010-12-21 16:50:16 +00:00
if ( empty ( $themes ) ) {
2011-12-10 18:26:48 +00:00
wp_safe_redirect ( add_query_arg ( 'error' , 'main' , $referer ) );
2010-12-21 16:50:16 +00:00
exit ;
}
2010-12-23 15:56:32 +00:00
2015-12-17 18:35:26 +00:00
$theme_info = array ();
2014-10-05 20:37:17 +00:00
foreach ( $themes as $key => $theme ) {
$theme_info [ $theme ] = wp_get_theme ( $theme );
}
2017-11-30 23:11:00 +00:00
include ( ABSPATH . 'wp-admin/update.php' );
2010-12-21 16:50:16 +00:00
$parent_file = 'themes.php' ;
if ( ! isset ( $_REQUEST [ 'verify-delete' ] ) ) {
wp_enqueue_script ( 'jquery' );
require_once ( ABSPATH . 'wp-admin/admin-header.php' );
2015-03-31 18:45:28 +00:00
$themes_to_delete = count ( $themes );
2010-12-21 16:50:16 +00:00
?>
<div class="wrap">
2015-03-31 18:45:28 +00:00
<?php if ( 1 == $themes_to_delete ) : ?>
2015-06-27 15:41:25 +00:00
<h1><?php _e( 'Delete Theme' ); ?></h1>
2015-03-31 18:45:28 +00:00
<div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'This theme may be active on other sites in the network.' ); ?></p></div>
<p><?php _e( 'You are about to remove the following theme:' ); ?></p>
<?php else : ?>
2015-06-27 15:41:25 +00:00
<h1><?php _e( 'Delete Themes' ); ?></h1>
2015-03-31 18:45:28 +00:00
<div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'These themes may be active on other sites in the network.' ); ?></p></div>
<p><?php _e( 'You are about to remove the following themes:' ); ?></p>
<?php endif; ?>
2010-12-21 16:50:16 +00:00
<ul class="ul-disc">
2014-10-08 19:05:20 +00:00
<?php
2017-11-30 23:11:00 +00:00
foreach ( $theme_info as $theme ) {
echo '<li>' . sprintf(
/* translators: 1: theme name, 2: theme author */
_x( '%1$s by %2$s', 'theme' ),
'<strong>' . $theme->display( 'Name' ) . '</strong>',
'<em>' . $theme->display( 'Author' ) . '</em>'
) . '</li>';
}
2014-10-08 19:05:20 +00:00
?>
2010-12-21 16:50:16 +00:00
</ul>
2015-03-31 18:45:28 +00:00
<?php if ( 1 == $themes_to_delete ) : ?>
<p><?php _e( 'Are you sure you wish to delete this theme?' ); ?></p>
<?php else : ?>
<p><?php _e( 'Are you sure you wish to delete these themes?' ); ?></p>
<?php endif; ?>
2017-11-30 23:11:00 +00:00
<form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" style="display:inline;">
2010-12-21 16:50:16 +00:00
<input type="hidden" name="verify-delete" value="1" />
<input type="hidden" name="action" value="delete-selected" />
<?php
2017-11-30 23:11:00 +00:00
foreach ( (array) $themes as $theme ) {
echo '<input type="hidden" name="checked[]" value="' . esc_attr( $theme ) . '" />';
}
2015-03-31 18:45:28 +00:00
wp_nonce_field( 'bulk-themes' );
2017-11-30 23:11:00 +00:00
if ( 1 == $themes_to_delete ) {
submit_button( __( 'Yes, delete this theme' ), '', 'submit', false );
} else {
submit_button( __( 'Yes, delete these themes' ), '', 'submit', false );
}
2010-12-21 16:50:16 +00:00
?>
</form>
2015-03-09 02:11:28 +00:00
<?php
$referer = wp_get_referer();
?>
<form method="post" action="<?php echo $referer ? esc_url( $referer ) : ''; ?>" style="display:inline;">
2016-09-28 19:54:28 +00:00
<?php submit_button( __( 'No, return me to the theme list' ), '', 'submit', false ); ?>
2010-12-21 16:50:16 +00:00
</form>
</div>
<?php
2017-11-30 23:11:00 +00:00
require_once( ABSPATH . 'wp-admin/admin-footer.php' );
2010-12-21 16:50:16 +00:00
exit;
2010-12-23 15:56:32 +00:00
} // Endif verify-delete
2010-12-23 19:40:32 +00:00
2012-09-29 01:36:14 +00:00
foreach ( $themes as $theme ) {
2017-11-30 23:11:00 +00:00
$delete_result = delete_theme(
2018-08-17 01:51:36 +00:00
$theme,
esc_url(
2017-11-30 23:11:00 +00:00
add_query_arg(
array(
'verify-delete' => 1,
'action' => 'delete-selected',
'checked' => $_REQUEST['checked'],
'_wpnonce' => $_REQUEST['_wpnonce'],
2018-08-17 01:51:36 +00:00
),
network_admin_url( 'themes.php' )
2017-11-30 23:11:00 +00:00
)
)
);
2012-09-29 01:36:14 +00:00
}
2014-05-06 18:08:14 +00:00
2011-12-08 23:02:33 +00:00
$paged = ( $_REQUEST['paged'] ) ? $_REQUEST['paged'] : 1;
2017-11-30 23:11:00 +00:00
wp_redirect(
add_query_arg(
array(
'deleted' => count( $themes ),
'paged' => $paged,
's' => $s,
2018-08-17 01:51:36 +00:00
),
network_admin_url( 'themes.php' )
2017-11-30 23:11:00 +00:00
)
);
2010-12-21 16:50:16 +00:00
exit;
2016-09-23 20:33:30 +00:00
default:
$themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
if ( empty( $themes ) ) {
wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) );
exit;
}
check_admin_referer( 'bulk-themes' );
2016-10-26 14:37:29 +00:00
/** This action is documented in wp-admin/network/site-themes.php */
$referer = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $referer, $action, $themes );
2016-09-23 20:33:30 +00:00
wp_safe_redirect( $referer );
exit;
2010-10-31 09:37:15 +00:00
}
2010-07-30 20:34:54 +00:00
}
2010-10-31 09:37:15 +00:00
$wp_list_table->prepare_items();
2011-01-13 00:03:38 +00:00
2010-11-01 20:08:25 +00:00
add_thickbox();
2010-10-31 09:37:15 +00:00
2015-03-10 15:32:27 +00:00
add_screen_option( 'per_page' );
2011-10-02 06:59:36 +00:00
2017-11-30 23:11:00 +00:00
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'<p>' . __( 'This screen enables and disables the inclusion of themes available to choose in the Appearance menu for each site. It does not activate or deactivate which theme a site is currently using.' ) . '</p>' .
'<p>' . __( 'If the network admin disables a theme that is in use, it can still remain selected on that site. If another theme is chosen, the disabled theme will not appear in the site’s Appearance > Themes screen.' ) . '</p>' .
'<p>' . __( 'Themes can be enabled on a site by site basis by the network admin on the Edit Site screen (which has a Themes tab); get there via the Edit action link on the All Sites screen. Only network admins are able to install or edit themes.' ) . '</p>',
)
);
2011-11-02 05:33:53 +00:00
2011-11-02 21:32:16 +00:00
get_current_screen()->set_help_sidebar(
2017-11-30 23:11:00 +00:00
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
'<p>' . __( '<a href="https://codex.wordpress.org/Network_Admin_Themes_Screen">Documentation on Network Themes</a>' ) . '</p>' .
'<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
2010-10-31 23:23:32 +00:00
);
2017-11-30 23:11:00 +00:00
get_current_screen()->set_screen_reader_content(
array(
'heading_views' => __( 'Filter themes list' ),
'heading_pagination' => __( 'Themes list navigation' ),
'heading_list' => __( 'Themes list' ),
)
);
2015-10-07 01:28:25 +00:00
2017-11-30 23:11:00 +00:00
$title = __( 'Themes' );
2010-10-31 09:37:15 +00:00
$parent_file = 'themes.php';
2016-06-15 16:37:29 +00:00
wp_enqueue_script( 'updates' );
2013-12-06 16:11:10 +00:00
wp_enqueue_script( 'theme-preview' );
2013-07-05 15:15:58 +00:00
2017-11-30 23:11:00 +00:00
require_once( ABSPATH . 'wp-admin/admin-header.php' );
2010-10-31 09:37:15 +00:00
2010-07-30 20:34:54 +00:00
?>
2010-10-31 09:37:15 +00:00
2010-07-30 20:34:54 +00:00
<div class="wrap">
2016-12-09 18:57:42 +00:00
<h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1>
<?php if ( current_user_can( 'install_themes' ) ) : ?>
<a href="theme-install.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'theme' ); ?></a>
<?php endif; ?>
<?php
2016-01-14 20:06:25 +00:00
if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
/* translators: %s: search keywords */
printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $s ) );
}
?>
2016-12-09 18:57:42 +00:00
<hr class="wp-header-end">
2010-10-31 09:37:15 +00:00
2010-12-24 17:41:36 +00:00
<?php
if ( isset( $_GET['enabled'] ) ) {
2015-03-31 18:45:28 +00:00
$enabled = absint( $_GET['enabled'] );
if ( 1 == $enabled ) {
$message = __( 'Theme enabled.' );
} else {
$message = _n( '%s theme enabled.', '%s themes enabled.', $enabled );
}
2015-04-01 22:06:28 +00:00
echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $enabled ) ) . '</p></div>';
2010-12-24 17:41:36 +00:00
} elseif ( isset( $_GET['disabled'] ) ) {
2015-03-31 18:45:28 +00:00
$disabled = absint( $_GET['disabled'] );
if ( 1 == $disabled ) {
$message = __( 'Theme disabled.' );
} else {
$message = _n( '%s theme disabled.', '%s themes disabled.', $disabled );
}
2015-04-01 22:06:28 +00:00
echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>';
2010-12-24 17:41:36 +00:00
} elseif ( isset( $_GET['deleted'] ) ) {
2015-03-31 18:45:28 +00:00
$deleted = absint( $_GET['deleted'] );
if ( 1 == $deleted ) {
$message = __( 'Theme deleted.' );
} else {
$message = _n( '%s theme deleted.', '%s themes deleted.', $deleted );
}
2015-04-01 22:06:28 +00:00
echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $deleted ) ) . '</p></div>';
2010-12-24 17:41:36 +00:00
} elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) {
2015-04-01 22:06:28 +00:00
echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'No theme selected.' ) . '</p></div>';
2010-12-24 17:41:36 +00:00
} elseif ( isset( $_GET['error'] ) && 'main' == $_GET['error'] ) {
2015-04-01 22:06:28 +00:00
echo '<div class="error notice is-dismissible"><p>' . __( 'You cannot delete a theme while it is active on the main site.' ) . '</p></div>';
2010-12-24 17:41:36 +00:00
}
?>
2015-01-16 04:16:24 +00:00
<form method="get">
2010-12-16 20:45:10 +00:00
<?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?>
2010-10-31 09:37:15 +00:00
</form>
2012-03-08 07:32:42 +00:00
<?php
$wp_list_table->views();
2017-11-30 23:11:00 +00:00
if ( 'broken' == $status ) {
2016-02-23 17:20:27 +00:00
echo '<p class="clear">' . __( 'The following themes are installed but incomplete.' ) . '</p>';
2017-11-30 23:11:00 +00:00
}
2012-03-08 07:32:42 +00:00
?>
2010-10-31 09:37:15 +00:00
2016-06-15 16:37:29 +00:00
<form id="bulk-action-form" method="post">
2017-11-30 23:11:00 +00:00
<input type="hidden" name="theme_status" value="<?php echo esc_attr( $status ); ?>" />
<input type="hidden" name="paged" value="<?php echo esc_attr( $page ); ?>" />
2010-10-31 09:37:15 +00:00
<?php $wp_list_table->display(); ?>
</form>
2010-07-30 20:34:54 +00:00
</div>
2010-10-31 09:37:15 +00:00
<?php
2016-06-15 16:37:29 +00:00
wp_print_request_filesystem_credentials_modal();
wp_print_admin_notice_templates();
wp_print_update_row_templates();
2017-11-30 23:11:00 +00:00
include( ABSPATH . 'wp-admin/admin-footer.php' );