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 */
2010-07-30 16:34:54 -04:00
require_once ( './admin.php' );
2010-11-10 09:27:15 -05:00
if ( ! is_multisite () )
wp_die ( __ ( 'Multisite support is not enabled.' ) );
2010-11-04 04:07:03 -04:00
$wp_list_table = get_list_table ( 'WP_MS_Themes_List_Table' );
2010-10-31 05:37:15 -04:00
$wp_list_table -> check_permissions ();
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-11-08 16:52:54 -05:00
$_SERVER [ 'REQUEST_URI' ] = remove_query_arg ( array ( 'enable' , 'disable' , 'enable-selected' , 'disable-selected' ), $_SERVER [ 'REQUEST_URI' ]);
2010-10-31 05:37:15 -04:00
if ( $action ) {
$allowed_themes = get_site_option ( 'allowedthemes' );
switch ( $action ) {
2010-11-08 16:52:54 -05:00
case 'enable' :
2010-11-08 14:40:05 -05:00
$allowed_themes [ $_GET [ 'theme' ] ] = true ;
2010-10-31 05:37:15 -04:00
update_site_option ( 'allowedthemes' , $allowed_themes );
wp_redirect ( wp_get_referer () ); // @todo add_query_arg for update message
exit ;
break ;
2010-11-08 16:52:54 -05:00
case 'disable' :
2010-10-31 05:37:15 -04: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 16:52:54 -05:00
case 'enable-selected' :
2010-10-31 05:37:15 -04: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 14:40:05 -05:00
$allowed_themes [ $theme ] = true ;
2010-10-31 05:37:15 -04:00
update_site_option ( 'allowedthemes' , $allowed_themes );
break ;
2010-11-08 16:52:54 -05:00
case 'disable-selected' :
2010-11-04 16:11:08 -04: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 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 ();
2010-11-01 16:08:25 -04:00
add_thickbox ();
2010-10-31 05:37:15 -04:00
2010-11-04 16:49:30 -04:00
add_screen_option ( 'per_page' , array ( 'label' => _x ( 'Themes' , 'themes per page (screen options)' )) );
2010-10-31 05:37:15 -04:00
2010-10-31 19:23:32 -04: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.' ) . '</p>' .
'<p><strong>' . __ ( 'For more information:' ) . '</strong></p>' .
'<p>' . __ ( '<a href="http://codex.wordpress.org/Super_Admin_Themes_SubPanel" target="_blank">Documentation on Network Themes</a>' ) . '</p>' .
'<p>' . __ ( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
);
2010-10-31 05:37:15 -04:00
$title = __ ( 'Themes' );
$parent_file = 'themes.php' ;
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 " >
2010-10-31 05:37:15 -04:00
< ? php screen_icon ( 'themes' ); ?>
< 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 } ?></h2>
< form method = " get " action = " " >
< p class = " search-box " >
< label class = " screen-reader-text " for = " theme-search-input " >< ? php _e ( 'Search Themes' ); ?> :</label>
< input type = " text " id = " theme-search-input " name = " s " value = " <?php _admin_search_query(); ?> " />
< ? php submit_button ( __ ( 'Search Installed Themes' ), 'button' , '' , false ); ?>
</ p >
</ 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 16:34:54 -04:00
</ div >
2010-10-31 05:37:15 -04:00
< ? php
include ( ABSPATH . 'wp-admin/admin-footer.php' );