2010-07-30 16:34:54 -04:00
< ? php
/**
* Multisite themes administration panel .
*
* @ package WordPress
* @ subpackage Multisite
2010-10-31 05:37:15 -04:00
* @ since 3.1 . 0
2010-07-30 16:34:54 -04:00
*/
2010-11-10 09:27:15 -05:00
/** Load WordPress Administration Bootstrap */
2013-09-24 20:18:11 -04:00
require_once ( dirname ( __FILE__ ) . '/admin.php' );
2010-07-30 16:34:54 -04:00
2010-11-10 09:27:15 -05:00
if ( ! is_multisite () )
wp_die ( __ ( 'Multisite support is not enabled.' ) );
2010-12-15 14:24:42 -05:00
if ( ! current_user_can ( 'manage_network_themes' ) )
2016-06-29 11:16:29 -04:00
wp_die ( __ ( 'Sorry, you are not allowed to manage network themes.' ) );
2010-12-15 14:24:42 -05:00
2011-01-16 16:47:24 -05:00
$wp_list_table = _get_list_table ( 'WP_MS_Themes_List_Table' );
2011-01-12 19:03:38 -05:00
$pagenum = $wp_list_table -> get_pagenum ();
2010-07-30 16:34:54 -04:00
2010-10-31 05:37:15 -04:00
$action = $wp_list_table -> current_action ();
$s = isset ( $_REQUEST [ 's' ]) ? $_REQUEST [ 's' ] : '' ;
// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
2010-12-25 08:44:03 -05:00
$temp_args = array ( 'enabled' , 'disabled' , 'deleted' , 'error' );
2010-12-24 12:41:36 -05:00
$_SERVER [ 'REQUEST_URI' ] = remove_query_arg ( $temp_args , $_SERVER [ 'REQUEST_URI' ] );
$referer = remove_query_arg ( $temp_args , wp_get_referer () );
2010-10-31 05:37:15 -04:00
if ( $action ) {
switch ( $action ) {
2010-11-08 16:52:54 -05:00
case 'enable' :
2010-12-23 11:20:36 -05:00
check_admin_referer ( 'enable-theme_' . $_GET [ 'theme' ]);
2016-04-13 23:40:27 -04:00
WP_Theme :: network_enable_theme ( $_GET [ 'theme' ] );
2012-06-12 11:31:25 -04:00
if ( false === strpos ( $referer , '/network/themes.php' ) )
wp_redirect ( network_admin_url ( 'themes.php?enabled=1' ) );
else
wp_safe_redirect ( add_query_arg ( 'enabled' , 1 , $referer ) );
2010-12-24 12:41:36 -05:00
exit ;
2010-11-08 16:52:54 -05:00
case 'disable' :
2010-12-23 11:20:36 -05:00
check_admin_referer ( 'disable-theme_' . $_GET [ 'theme' ]);
2016-04-13 23:40:27 -04:00
WP_Theme :: network_disable_theme ( $_GET [ 'theme' ] );
2011-12-10 13:26:48 -05:00
wp_safe_redirect ( add_query_arg ( 'disabled' , '1' , $referer ) );
2010-10-31 05:37:15 -04:00
exit ;
2010-11-08 16:52:54 -05:00
case 'enable-selected' :
2010-12-23 11:20:36 -05:00
check_admin_referer ( 'bulk-themes' );
2010-10-31 05:37:15 -04:00
$themes = isset ( $_POST [ 'checked' ] ) ? ( array ) $_POST [ 'checked' ] : array ();
if ( empty ( $themes ) ) {
2011-12-10 13:26:48 -05:00
wp_safe_redirect ( add_query_arg ( 'error' , 'none' , $referer ) );
2010-10-31 05:37:15 -04:00
exit ;
2010-12-24 12:41:36 -05:00
}
2016-04-13 23:40:27 -04:00
WP_Theme :: network_enable_theme ( ( array ) $themes );
2011-12-10 13:26:48 -05:00
wp_safe_redirect ( add_query_arg ( 'enabled' , count ( $themes ), $referer ) );
2010-12-24 12:41:36 -05:00
exit ;
2010-11-08 16:52:54 -05:00
case 'disable-selected' :
2010-12-23 11:20:36 -05:00
check_admin_referer ( 'bulk-themes' );
2010-11-04 16:11:08 -04:00
$themes = isset ( $_POST [ 'checked' ] ) ? ( array ) $_POST [ 'checked' ] : array ();
if ( empty ( $themes ) ) {
2011-12-10 13:26:48 -05:00
wp_safe_redirect ( add_query_arg ( 'error' , 'none' , $referer ) );
2010-11-04 16:11:08 -04:00
exit ;
2010-12-24 12:41:36 -05:00
}
2016-04-13 23:40:27 -04:00
WP_Theme :: network_disable_theme ( ( array ) $themes );
2011-12-10 13:26:48 -05:00
wp_safe_redirect ( add_query_arg ( 'disabled' , count ( $themes ), $referer ) );
2010-12-24 12:41:36 -05:00
exit ;
2011-10-03 10:35:43 -04:00
case 'update-selected' :
check_admin_referer ( 'bulk-themes' );
if ( isset ( $_GET [ 'themes' ] ) )
$themes = explode ( ',' , $_GET [ 'themes' ] );
elseif ( isset ( $_POST [ 'checked' ] ) )
$themes = ( array ) $_POST [ 'checked' ];
else
$themes = array ();
$title = __ ( 'Update Themes' );
$parent_file = 'themes.php' ;
require_once ( ABSPATH . 'wp-admin/admin-header.php' );
echo '<div class="wrap">' ;
2015-06-27 11:41:25 -04:00
echo '<h1>' . esc_html ( $title ) . '</h1>' ;
2011-10-03 10:35:43 -04:00
$url = self_admin_url ( 'update.php?action=update-selected-themes&themes=' . urlencode ( join ( ',' , $themes ) ));
$url = wp_nonce_url ( $url , 'bulk-update-themes' );
echo " <iframe src=' $url ' style='width: 100%; height:100%; min-height:850px;'></iframe> " ;
echo '</div>' ;
require_once ( ABSPATH . 'wp-admin/admin-footer.php' );
exit ;
2010-12-21 11:50:16 -05:00
case 'delete-selected' :
2014-10-08 15:05:20 -04:00
if ( ! current_user_can ( 'delete_themes' ) ) {
2016-06-29 11:16:29 -04:00
wp_die ( __ ( 'Sorry, you are not allowed to delete themes for this site.' ) );
2014-10-08 15:05:20 -04:00
}
2010-12-23 13:53:44 -05:00
check_admin_referer ( 'bulk-themes' );
2010-12-21 11:50:16 -05:00
$themes = isset ( $_REQUEST [ 'checked' ] ) ? ( array ) $_REQUEST [ 'checked' ] : array ();
2010-12-24 12:41:36 -05:00
2010-12-21 11:50:16 -05:00
if ( empty ( $themes ) ) {
2011-12-10 13:26:48 -05:00
wp_safe_redirect ( add_query_arg ( 'error' , 'none' , $referer ) );
2010-12-21 11:50:16 -05:00
exit ;
}
2014-10-05 16:37:17 -04:00
$themes = array_diff ( $themes , array ( get_option ( 'stylesheet' ), get_option ( 'template' ) ) );
2011-12-08 18:02:33 -05:00
2010-12-21 11:50:16 -05:00
if ( empty ( $themes ) ) {
2011-12-10 13:26:48 -05:00
wp_safe_redirect ( add_query_arg ( 'error' , 'main' , $referer ) );
2010-12-21 11:50:16 -05:00
exit ;
}
2010-12-23 10:56:32 -05:00
2015-12-17 13:35:26 -05:00
$theme_info = array ();
2014-10-05 16:37:17 -04:00
foreach ( $themes as $key => $theme ) {
$theme_info [ $theme ] = wp_get_theme ( $theme );
}
2010-12-21 11:50:16 -05:00
include ( ABSPATH . 'wp-admin/update.php' );
$parent_file = 'themes.php' ;
if ( ! isset ( $_REQUEST [ 'verify-delete' ] ) ) {
wp_enqueue_script ( 'jquery' );
require_once ( ABSPATH . 'wp-admin/admin-header.php' );
2015-03-31 14:45:28 -04:00
$themes_to_delete = count ( $themes );
2010-12-21 11:50:16 -05:00
?>
< div class = " wrap " >
2015-03-31 14:45:28 -04:00
< ? php if ( 1 == $themes_to_delete ) : ?>
2015-06-27 11:41:25 -04:00
< h1 >< ? php _e ( 'Delete Theme' ); ?> </h1>
2015-03-31 14:45:28 -04: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 11:41:25 -04:00
< h1 >< ? php _e ( 'Delete Themes' ); ?> </h1>
2015-03-31 14:45:28 -04: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 11:50:16 -05:00
< ul class = " ul-disc " >
2014-10-08 15:05:20 -04:00
< ? php
foreach ( $theme_info as $theme ) {
2016-02-28 21:38:26 -05:00
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 15:05:20 -04:00
}
?>
2010-12-21 11:50:16 -05:00
</ ul >
2015-03-31 14:45:28 -04: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 ; ?>
2010-12-21 11:50:16 -05:00
< form method = " post " action = " <?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?> " style = " display:inline; " >
< input type = " hidden " name = " verify-delete " value = " 1 " />
< input type = " hidden " name = " action " value = " delete-selected " />
< ? php
2014-10-08 15:05:20 -04:00
foreach ( ( array ) $themes as $theme ) {
2010-12-21 11:50:16 -05:00
echo '<input type="hidden" name="checked[]" value="' . esc_attr ( $theme ) . '" />' ;
2014-10-08 15:05:20 -04:00
}
2015-03-31 14:45:28 -04:00
wp_nonce_field ( 'bulk-themes' );
if ( 1 == $themes_to_delete ) {
2015-07-03 20:50:25 -04:00
submit_button ( __ ( 'Yes, delete this theme' ), 'button' , 'submit' , false );
2015-03-31 14:45:28 -04:00
} else {
2015-07-03 20:50:25 -04:00
submit_button ( __ ( 'Yes, delete these themes' ), 'button' , 'submit' , false );
2015-03-31 14:45:28 -04:00
}
2010-12-21 11:50:16 -05:00
?>
</ form >
2015-03-08 22:11:28 -04:00
< ? php
$referer = wp_get_referer ();
?>
< form method = " post " action = " <?php echo $referer ? esc_url( $referer ) : ''; ?> " style = " display:inline; " >
2015-07-03 20:50:25 -04:00
< ? php submit_button ( __ ( 'No, return me to the theme list' ), 'button' , 'submit' , false ); ?>
2010-12-21 11:50:16 -05:00
</ form >
</ div >
< ? php
require_once ( ABSPATH . 'wp-admin/admin-footer.php' );
exit ;
2010-12-23 10:56:32 -05:00
} // Endif verify-delete
2010-12-23 14:40:32 -05:00
2012-09-28 21:36:14 -04:00
foreach ( $themes as $theme ) {
$delete_result = delete_theme ( $theme , esc_url ( add_query_arg ( array (
'verify-delete' => 1 ,
'action' => 'delete-selected' ,
'checked' => $_REQUEST [ 'checked' ],
'_wpnonce' => $_REQUEST [ '_wpnonce' ]
), network_admin_url ( 'themes.php' ) ) ) );
}
2014-05-06 14:08:14 -04:00
2011-12-08 18:02:33 -05:00
$paged = ( $_REQUEST [ 'paged' ] ) ? $_REQUEST [ 'paged' ] : 1 ;
2012-09-28 21:36:14 -04:00
wp_redirect ( add_query_arg ( array (
'deleted' => count ( $themes ),
'paged' => $paged ,
's' => $s
), network_admin_url ( 'themes.php' ) ) );
2010-12-21 11:50:16 -05:00
exit ;
2010-10-31 05:37:15 -04:00
}
2010-07-30 16:34:54 -04:00
}
2010-10-31 05:37:15 -04:00
$wp_list_table -> prepare_items ();
2011-01-12 19:03:38 -05:00
2010-11-01 16:08:25 -04:00
add_thickbox ();
2010-10-31 05:37:15 -04:00
2015-03-10 11:32:27 -04:00
add_screen_option ( 'per_page' );
2011-10-02 02:59:36 -04:00
2011-11-30 21:22:07 -05: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 01:33:53 -04:00
2011-11-02 17:32:16 -04:00
get_current_screen () -> set_help_sidebar (
2010-12-18 13:27:12 -05:00
'<p><strong>' . __ ( 'For more information:' ) . '</strong></p>' .
2015-04-12 17:29:32 -04:00
'<p>' . __ ( '<a href="https://codex.wordpress.org/Network_Admin_Themes_Screen" target="_blank">Documentation on Network Themes</a>' ) . '</p>' .
2014-03-07 23:14:15 -05:00
'<p>' . __ ( '<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
2010-10-31 19:23:32 -04:00
);
2015-10-06 21:28:25 -04:00
get_current_screen () -> set_screen_reader_content ( array (
'heading_views' => __ ( 'Filter themes list' ),
'heading_pagination' => __ ( 'Themes list navigation' ),
'heading_list' => __ ( 'Themes list' ),
) );
2010-10-31 05:37:15 -04:00
$title = __ ( 'Themes' );
$parent_file = 'themes.php' ;
Update/Install: Shiny Updates v2.
Gone are the days of isolation and feelings of "meh", brought on by The Bleak Screen of Sadness. For a shiny knight has arrived to usher our plugins and themes along their arduous journey of installation, updates, and the inevitable fate of ultimate deletion.
Props swissspidy, adamsilverstein, mapk, afragen, ocean90, ryelle, j-falk, michael-arestad, melchoyce, DrewAPicture, AdamSoucie, ethitter, pento, dd32, kraftbj, Ipstenu, jorbin, afercia, stephdau, paulwilde, jipmoors, khag7, svovaf, jipmoors, obenland.
Fixes #22029, #25828, #31002, #31529, #31530, #31773, #33637, #35032.
Built from https://develop.svn.wordpress.org/trunk@37714
git-svn-id: http://core.svn.wordpress.org/trunk@37680 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-15 12:37:29 -04:00
wp_enqueue_script ( 'updates' );
No-JavaScript and no-Customizer support for the new Themes screen.
JavaScript is rarely disabled, but graceful degradation is still important. For example, syntax errors can occur, usually with major WP updates that overhaul entire experiences and update external libraries combined with themes or plugins doing weird or old things. If this error is due to their current theme, a user needs to be able to access the themes screen to switch away from the theme. A more subtle issue could make things painful to diagnose.
This commit renders the grid in PHP (the template is duplicated, but it lightweight, fairly mundane, and easy to sync). On Backbone render, the grid is then re-rendered from JavaScript so searches can occur. Customize and Live Preview is disabled if JS fails to kick in. If JS is disabled, old-school "Preview" links are displayed.
No-Customizer support: The customizer is only supported when the browser supports postMessage (IE8+), and if the frontend is a different domain, CORS (IE10+). We use the .hide-if-no-customize class for this. Pre-customize "Preview" links should use .hide-if-customize.
The .load-customize class should be used to declare a link that opens the customizer. This enables customize-loader.js to intercept this link and load the customizer on top of the current window, making for a smoother experience.
fixes #25964.
Built from https://develop.svn.wordpress.org/trunk@26726
git-svn-id: http://core.svn.wordpress.org/trunk@26615 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-06 11:11:10 -05:00
wp_enqueue_script ( 'theme-preview' );
2013-07-05 11:15:58 -04:00
2010-10-31 05:37:15 -04:00
require_once ( ABSPATH . 'wp-admin/admin-header.php' );
2010-07-30 16:34:54 -04:00
?>
2010-10-31 05:37:15 -04:00
2010-07-30 16:34:54 -04:00
< div class = " wrap " >
2015-07-03 12:42:24 -04:00
< h1 >< ? php echo esc_html ( $title ); 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 }
2016-01-14 15:06:25 -05:00
if ( isset ( $_REQUEST [ 's' ] ) && strlen ( $_REQUEST [ 's' ] ) ) {
/* translators: %s: search keywords */
printf ( '<span class="subtitle">' . __ ( 'Search results for “%s”' ) . '</span>' , esc_html ( $s ) );
}
?>
2015-06-27 11:41:25 -04:00
</ h1 >
2010-10-31 05:37:15 -04:00
2010-12-24 12:41:36 -05:00
< ? php
if ( isset ( $_GET [ 'enabled' ] ) ) {
2015-03-31 14:45:28 -04:00
$enabled = absint ( $_GET [ 'enabled' ] );
if ( 1 == $enabled ) {
$message = __ ( 'Theme enabled.' );
} else {
$message = _n ( '%s theme enabled.' , '%s themes enabled.' , $enabled );
}
2015-04-01 18:06:28 -04:00
echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf ( $message , number_format_i18n ( $enabled ) ) . '</p></div>' ;
2010-12-24 12:41:36 -05:00
} elseif ( isset ( $_GET [ 'disabled' ] ) ) {
2015-03-31 14:45:28 -04:00
$disabled = absint ( $_GET [ 'disabled' ] );
if ( 1 == $disabled ) {
$message = __ ( 'Theme disabled.' );
} else {
$message = _n ( '%s theme disabled.' , '%s themes disabled.' , $disabled );
}
2015-04-01 18:06:28 -04:00
echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf ( $message , number_format_i18n ( $disabled ) ) . '</p></div>' ;
2010-12-24 12:41:36 -05:00
} elseif ( isset ( $_GET [ 'deleted' ] ) ) {
2015-03-31 14:45:28 -04:00
$deleted = absint ( $_GET [ 'deleted' ] );
if ( 1 == $deleted ) {
$message = __ ( 'Theme deleted.' );
} else {
$message = _n ( '%s theme deleted.' , '%s themes deleted.' , $deleted );
}
2015-04-01 18:06:28 -04:00
echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf ( $message , number_format_i18n ( $deleted ) ) . '</p></div>' ;
2010-12-24 12:41:36 -05:00
} elseif ( isset ( $_GET [ 'error' ] ) && 'none' == $_GET [ 'error' ] ) {
2015-04-01 18:06:28 -04:00
echo '<div id="message" class="error notice is-dismissible"><p>' . __ ( 'No theme selected.' ) . '</p></div>' ;
2010-12-24 12:41:36 -05:00
} elseif ( isset ( $_GET [ 'error' ] ) && 'main' == $_GET [ 'error' ] ) {
2015-04-01 18:06:28 -04: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 12:41:36 -05:00
}
?>
2015-01-15 23:16:24 -05:00
< form method = " get " >
2010-12-16 15:45:10 -05:00
< ? php $wp_list_table -> search_box ( __ ( 'Search Installed Themes' ), 'theme' ); ?>
2010-10-31 05:37:15 -04:00
</ form >
2012-03-08 02:32:42 -05:00
< ? php
$wp_list_table -> views ();
if ( 'broken' == $status )
2016-02-23 12:20:27 -05:00
echo '<p class="clear">' . __ ( 'The following themes are installed but incomplete.' ) . '</p>' ;
2012-03-08 02:32:42 -05:00
?>
2010-10-31 05:37:15 -04:00
Update/Install: Shiny Updates v2.
Gone are the days of isolation and feelings of "meh", brought on by The Bleak Screen of Sadness. For a shiny knight has arrived to usher our plugins and themes along their arduous journey of installation, updates, and the inevitable fate of ultimate deletion.
Props swissspidy, adamsilverstein, mapk, afragen, ocean90, ryelle, j-falk, michael-arestad, melchoyce, DrewAPicture, AdamSoucie, ethitter, pento, dd32, kraftbj, Ipstenu, jorbin, afercia, stephdau, paulwilde, jipmoors, khag7, svovaf, jipmoors, obenland.
Fixes #22029, #25828, #31002, #31529, #31530, #31773, #33637, #35032.
Built from https://develop.svn.wordpress.org/trunk@37714
git-svn-id: http://core.svn.wordpress.org/trunk@37680 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-15 12:37:29 -04:00
< form id = " bulk-action-form " method = " post " >
2010-10-31 05:37:15 -04:00
< input type = " hidden " name = " theme_status " value = " <?php echo esc_attr( $status ) ?> " />
< input type = " hidden " name = " paged " value = " <?php echo esc_attr( $page ) ?> " />
< ? php $wp_list_table -> display (); ?>
</ form >
2010-07-30 16:34:54 -04:00
</ div >
2010-10-31 05:37:15 -04:00
< ? php
Update/Install: Shiny Updates v2.
Gone are the days of isolation and feelings of "meh", brought on by The Bleak Screen of Sadness. For a shiny knight has arrived to usher our plugins and themes along their arduous journey of installation, updates, and the inevitable fate of ultimate deletion.
Props swissspidy, adamsilverstein, mapk, afragen, ocean90, ryelle, j-falk, michael-arestad, melchoyce, DrewAPicture, AdamSoucie, ethitter, pento, dd32, kraftbj, Ipstenu, jorbin, afercia, stephdau, paulwilde, jipmoors, khag7, svovaf, jipmoors, obenland.
Fixes #22029, #25828, #31002, #31529, #31530, #31773, #33637, #35032.
Built from https://develop.svn.wordpress.org/trunk@37714
git-svn-id: http://core.svn.wordpress.org/trunk@37680 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-15 12:37:29 -04:00
wp_print_request_filesystem_credentials_modal ();
wp_print_admin_notice_templates ();
wp_print_update_row_templates ();
2010-12-16 15:45:10 -05:00
include ( ABSPATH . 'wp-admin/admin-footer.php' );