2010-07-30 22:34:54 +02:00
< ? php
/**
* Multisite themes administration panel .
*
* @ package WordPress
* @ subpackage Multisite
2010-10-31 10:37:15 +01:00
* @ since 3.1 . 0
2010-07-30 22:34:54 +02:00
*/
2010-11-10 15:27:15 +01:00
/** Load WordPress Administration Bootstrap */
2010-07-30 22:34:54 +02:00
require_once ( './admin.php' );
2010-11-10 15:27:15 +01:00
if ( ! is_multisite () )
wp_die ( __ ( 'Multisite support is not enabled.' ) );
2010-12-15 20:24:42 +01:00
$menu_perms = get_site_option ( 'menu_items' , array () );
2010-12-16 09:43:22 +01:00
if ( empty ( $menu_perms [ 'themes' ] ) && ! is_super_admin () )
wp_die ( __ ( 'Cheatin’ uh?' ) );
2010-12-15 20:24:42 +01:00
if ( ! current_user_can ( 'manage_network_themes' ) )
wp_die ( __ ( 'You do not have sufficient permissions to manage network themes.' ) );
2010-11-04 09:07:03 +01:00
$wp_list_table = get_list_table ( 'WP_MS_Themes_List_Table' );
2010-07-30 22:34:54 +02:00
2010-10-31 10:37:15 +01: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-11-08 22:52:54 +01:00
$_SERVER [ 'REQUEST_URI' ] = remove_query_arg ( array ( 'enable' , 'disable' , 'enable-selected' , 'disable-selected' ), $_SERVER [ 'REQUEST_URI' ]);
2010-10-31 10:37:15 +01:00
if ( $action ) {
$allowed_themes = get_site_option ( 'allowedthemes' );
switch ( $action ) {
2010-11-08 22:52:54 +01:00
case 'enable' :
2010-11-08 20:40:05 +01:00
$allowed_themes [ $_GET [ 'theme' ] ] = true ;
2010-10-31 10:37:15 +01:00
update_site_option ( 'allowedthemes' , $allowed_themes );
wp_redirect ( wp_get_referer () ); // @todo add_query_arg for update message
exit ;
break ;
2010-11-08 22:52:54 +01:00
case 'disable' :
2010-10-31 10:37:15 +01:00
unset ( $allowed_themes [ $_GET [ 'theme' ] ] );
update_site_option ( 'allowedthemes' , $allowed_themes );
wp_redirect ( wp_get_referer () ); // @todo add_query_arg for update message
exit ;
break ;
2010-11-08 22:52:54 +01:00
case 'enable-selected' :
2010-10-31 10:37:15 +01:00
$themes = isset ( $_POST [ 'checked' ] ) ? ( array ) $_POST [ 'checked' ] : array ();
if ( empty ( $themes ) ) {
wp_redirect ( wp_get_referer () );
exit ;
}
foreach ( ( array ) $themes as $theme )
2010-11-08 20:40:05 +01:00
$allowed_themes [ $theme ] = true ;
2010-10-31 10:37:15 +01:00
update_site_option ( 'allowedthemes' , $allowed_themes );
break ;
2010-11-08 22:52:54 +01:00
case 'disable-selected' :
2010-11-04 21:11:08 +01:00
$themes = isset ( $_POST [ 'checked' ] ) ? ( array ) $_POST [ 'checked' ] : array ();
if ( empty ( $themes ) ) {
wp_redirect ( wp_get_referer () );
exit ;
}
foreach ( ( array ) $themes as $theme )
unset ( $allowed_themes [ $theme ] );
update_site_option ( 'allowedthemes' , $allowed_themes );
break ;
2010-10-31 10:37:15 +01:00
}
2010-07-30 22:34:54 +02:00
}
2010-10-31 10:37:15 +01:00
$wp_list_table -> prepare_items ();
2010-11-01 21:08:25 +01:00
add_thickbox ();
2010-10-31 10:37:15 +01:00
2010-11-04 21:49:30 +01:00
add_screen_option ( 'per_page' , array ( 'label' => _x ( 'Themes' , 'themes per page (screen options)' )) );
2010-10-31 10:37:15 +01:00
2010-12-18 19:27:12 +01:00
add_contextual_help ( $current_screen ,
'<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 you go to via the Edit action link on the Sites screen. Only network admins are able to install or edit themes.' ) . '</p>' .
'<p><strong>' . __ ( 'For more information:' ) . '</strong></p>' .
'<p>' . __ ( '<a href="http://codex.wordpress.org/Network_Admin_Themes_Screen" target="_blank">Documentation on Network Themes</a>' ) . '</p>' .
'<p>' . __ ( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
2010-11-01 00:23:32 +01:00
);
2010-10-31 10:37:15 +01:00
$title = __ ( 'Themes' );
$parent_file = 'themes.php' ;
require_once ( ABSPATH . 'wp-admin/admin-header.php' );
2010-07-30 22:34:54 +02:00
?>
2010-10-31 10:37:15 +01:00
2010-07-30 22:34:54 +02:00
< div class = " wrap " >
2010-10-31 10:37:15 +01:00
< ? php screen_icon ( 'themes' ); ?>
2010-12-19 02:11:38 +01:00
< h2 >< ? php echo esc_html ( $title ); if ( current_user_can ( 'install_themes' ) ) { ?> <a href="theme-install.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'theme'); ?></a><?php }
if ( $s )
printf ( '<span class="subtitle">' . __ ( 'Search results for “%s”' ) . '</span>' , esc_html ( $s ) ); ?>
</ h2 >
2010-10-31 10:37:15 +01:00
< form method = " get " action = " " >
2010-12-16 21:45:10 +01:00
< ? php $wp_list_table -> search_box ( __ ( 'Search Installed Themes' ), 'theme' ); ?>
2010-10-31 10:37:15 +01:00
</ form >
< ? php $wp_list_table -> views (); ?>
< form method = " post " action = " " >
< 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 22:34:54 +02:00
</ div >
2010-10-31 10:37:15 +01:00
< ? php
2010-12-16 21:45:10 +01:00
include ( ABSPATH . 'wp-admin/admin-footer.php' );