3 * Multisite themes administration panel.
6 * @subpackage Multisite
10 /** Load WordPress Administration Bootstrap */
11 require_once( './admin.php' );
13 if ( ! is_multisite() )
14 wp_die( __( 'Multisite support is not enabled.' ) );
16 $menu_perms = get_site_option( 'menu_items', array() );
18 if ( empty( $menu_perms['themes'] ) && ! is_super_admin() )
19 wp_die( __( 'Cheatin’ uh?' ) );
21 if ( !current_user_can('manage_network_themes') )
22 wp_die( __( 'You do not have sufficient permissions to manage network themes.' ) );
24 $wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
25 $pagenum = $wp_list_table->get_pagenum();
27 $action = $wp_list_table->current_action();
29 $s = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
31 // Clean up request URI from temporary args for screen options/paging uri's to work as expected.
32 $temp_args = array( 'enabled', 'disabled', 'deleted', 'error' );
33 $_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] );
34 $referer = remove_query_arg( $temp_args, wp_get_referer() );
37 $allowed_themes = get_site_option( 'allowedthemes' );
40 check_admin_referer('enable-theme_' . $_GET['theme']);
41 $allowed_themes[ $_GET['theme'] ] = true;
42 update_site_option( 'allowedthemes', $allowed_themes );
43 if ( false === strpos( $referer, '/network/themes.php' ) )
44 wp_redirect( network_admin_url( 'themes.php?enabled=1' ) );
46 wp_safe_redirect( add_query_arg( 'enabled', 1, $referer ) );
50 check_admin_referer('disable-theme_' . $_GET['theme']);
51 unset( $allowed_themes[ $_GET['theme'] ] );
52 update_site_option( 'allowedthemes', $allowed_themes );
53 wp_safe_redirect( add_query_arg( 'disabled', '1', $referer ) );
56 case 'enable-selected':
57 check_admin_referer('bulk-themes');
58 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
59 if ( empty($themes) ) {
60 wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) );
63 foreach( (array) $themes as $theme )
64 $allowed_themes[ $theme ] = true;
65 update_site_option( 'allowedthemes', $allowed_themes );
66 wp_safe_redirect( add_query_arg( 'enabled', count( $themes ), $referer ) );
69 case 'disable-selected':
70 check_admin_referer('bulk-themes');
71 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
72 if ( empty($themes) ) {
73 wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) );
76 foreach( (array) $themes as $theme )
77 unset( $allowed_themes[ $theme ] );
78 update_site_option( 'allowedthemes', $allowed_themes );
79 wp_safe_redirect( add_query_arg( 'disabled', count( $themes ), $referer ) );
82 case 'update-selected' :
83 check_admin_referer( 'bulk-themes' );
85 if ( isset( $_GET['themes'] ) )
86 $themes = explode( ',', $_GET['themes'] );
87 elseif ( isset( $_POST['checked'] ) )
88 $themes = (array) $_POST['checked'];
92 $title = __( 'Update Themes' );
93 $parent_file = 'themes.php';
95 require_once(ABSPATH . 'wp-admin/admin-header.php');
97 echo '<div class="wrap">';
99 echo '<h2>' . esc_html( $title ) . '</h2>';
101 $url = self_admin_url('update.php?action=update-selected-themes&themes=' . urlencode( join(',', $themes) ));
102 $url = wp_nonce_url($url, 'bulk-update-themes');
104 echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>";
106 require_once(ABSPATH . 'wp-admin/admin-footer.php');
109 case 'delete-selected':
110 if ( ! current_user_can( 'delete_themes' ) )
111 wp_die( __('You do not have sufficient permissions to delete themes for this site.') );
112 check_admin_referer( 'bulk-themes' );
114 $themes = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array();
116 unset( $themes[ get_option( 'stylesheet' ) ], $themes[ get_option( 'template' ) ] );
118 if ( empty( $themes ) ) {
119 wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) );
123 $files_to_delete = $theme_info = array();
124 foreach ( $themes as $key => $theme ) {
125 $theme_info[ $theme ] = wp_get_theme( $theme );
126 $files_to_delete = array_merge( $files_to_delete, list_files( $theme_info[ $theme ]->get_stylesheet_directory() ) );
129 if ( empty( $themes ) ) {
130 wp_safe_redirect( add_query_arg( 'error', 'main', $referer ) );
134 include(ABSPATH . 'wp-admin/update.php');
136 $parent_file = 'themes.php';
138 if ( ! isset( $_REQUEST['verify-delete'] ) ) {
139 wp_enqueue_script( 'jquery' );
140 require_once( ABSPATH . 'wp-admin/admin-header.php' );
144 $themes_to_delete = count( $themes );
146 echo '<h2>' . _n( 'Delete Theme', 'Delete Themes', $themes_to_delete ) . '</h2>';
148 <div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php echo _n( 'This theme may be active on other sites in the network.', 'These themes may be active on other sites in the network.', $themes_to_delete ); ?></p></div>
149 <p><?php echo _n( 'You are about to remove the following theme:', 'You are about to remove the following themes:', $themes_to_delete ); ?></p>
151 <?php foreach ( $theme_info as $theme )
152 echo '<li>', sprintf( __('<strong>%1$s</strong> by <em>%2$s</em>' ), $theme->display('Name'), $theme->display('Author') ), '</li>'; /* translators: 1: theme name, 2: theme author */ ?>
154 <p><?php _e('Are you sure you wish to delete these themes?'); ?></p>
155 <form method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" style="display:inline;">
156 <input type="hidden" name="verify-delete" value="1" />
157 <input type="hidden" name="action" value="delete-selected" />
159 foreach ( (array) $themes as $theme )
160 echo '<input type="hidden" name="checked[]" value="' . esc_attr($theme) . '" />';
162 <?php wp_nonce_field('bulk-themes') ?>
163 <?php submit_button( _n( 'Yes, Delete this theme', 'Yes, Delete these themes', $themes_to_delete ), 'button', 'submit', false ); ?>
165 <form method="post" action="<?php echo esc_url(wp_get_referer()); ?>" style="display:inline;">
166 <?php submit_button( __( 'No, Return me to the theme list' ), 'button', 'submit', false ); ?>
169 <p><a href="#" onclick="jQuery('#files-list').toggle(); return false;"><?php _e('Click to view entire list of files which will be deleted'); ?></a></p>
170 <div id="files-list" style="display:none;">
173 foreach ( (array) $files_to_delete as $file )
174 echo '<li>' . esc_html( str_replace( WP_CONTENT_DIR . "/themes", '', $file) ) . '</li>';
180 require_once(ABSPATH . 'wp-admin/admin-footer.php');
182 } // Endif verify-delete
184 foreach ( $themes as $theme )
185 $delete_result = delete_theme( $theme, esc_url( add_query_arg( array('verify-delete' => 1), $_SERVER['REQUEST_URI'] ) ) );
186 $paged = ( $_REQUEST['paged'] ) ? $_REQUEST['paged'] : 1;
187 wp_redirect( network_admin_url( "themes.php?deleted=".count( $themes )."&paged=$paged&s=$s" ) );
193 $wp_list_table->prepare_items();
197 add_screen_option( 'per_page', array('label' => _x( 'Themes', 'themes per page (screen options)' )) );
199 get_current_screen()->add_help_tab( array(
201 'title' => __('Overview'),
203 '<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>' .
204 '<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>' .
205 '<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>'
208 get_current_screen()->set_help_sidebar(
209 '<p><strong>' . __('For more information:') . '</strong></p>' .
210 '<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Themes_Screen" target="_blank">Documentation on Network Themes</a>') . '</p>' .
211 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
214 $title = __('Themes');
215 $parent_file = 'themes.php';
217 require_once(ABSPATH . 'wp-admin/admin-header.php');
222 <?php screen_icon('themes'); ?>
223 <h2><?php echo esc_html( $title ); if ( current_user_can('install_themes') ) { ?> <a href="theme-install.php" class="add-new-h2"><?php echo esc_html_x('Add New', 'theme'); ?></a><?php }
225 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( $s ) ); ?>
229 if ( isset( $_GET['enabled'] ) ) {
230 $_GET['enabled'] = absint( $_GET['enabled'] );
231 echo '<div id="message" class="updated"><p>' . sprintf( _n( 'Theme enabled.', '%s themes enabled.', $_GET['enabled'] ), number_format_i18n( $_GET['enabled'] ) ) . '</p></div>';
232 } elseif ( isset( $_GET['disabled'] ) ) {
233 $_GET['disabled'] = absint( $_GET['disabled'] );
234 echo '<div id="message" class="updated"><p>' . sprintf( _n( 'Theme disabled.', '%s themes disabled.', $_GET['disabled'] ), number_format_i18n( $_GET['disabled'] ) ) . '</p></div>';
235 } elseif ( isset( $_GET['deleted'] ) ) {
236 $_GET['deleted'] = absint( $_GET['deleted'] );
237 echo '<div id="message" class="updated"><p>' . sprintf( _nx( 'Theme deleted.', '%s themes deleted.', $_GET['deleted'], 'network' ), number_format_i18n( $_GET['deleted'] ) ) . '</p></div>';
238 } elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) {
239 echo '<div id="message" class="error"><p>' . __( 'No theme selected.' ) . '</p></div>';
240 } elseif ( isset( $_GET['error'] ) && 'main' == $_GET['error'] ) {
241 echo '<div class="error"><p>' . __( 'You cannot delete a theme while it is active on the main site.' ) . '</p></div>';
246 <form method="get" action="">
247 <?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?>
251 $wp_list_table->views();
253 if ( 'broken' == $status )
254 echo '<p class="clear">' . __('The following themes are installed but incomplete. Themes must have a stylesheet and a template.') . '</p>';
257 <form method="post" action="">
258 <input type="hidden" name="theme_status" value="<?php echo esc_attr($status) ?>" />
259 <input type="hidden" name="paged" value="<?php echo esc_attr($page) ?>" />
261 <?php $wp_list_table->display(); ?>
267 include(ABSPATH . 'wp-admin/admin-footer.php');