| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Edit Site Themes Administration Screen | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @package WordPress | 
					
						
							|  |  |  |  * @subpackage Multisite | 
					
						
							|  |  |  |  * @since 3.1.0 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** Load WordPress Administration Bootstrap */ | 
					
						
							|  |  |  | require_once( dirname( __FILE__ ) . '/admin.php' ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | if ( ! current_user_can( 'manage_sites' ) ) { | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 	wp_die( __( 'Sorry, you are not allowed to manage themes for this site.' ) ); | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | get_current_screen()->add_help_tab( get_site_screen_help_tab_args() ); | 
					
						
							|  |  |  | get_current_screen()->set_help_sidebar( get_site_screen_help_sidebar_content() ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | get_current_screen()->set_screen_reader_content( | 
					
						
							|  |  |  | 	array( | 
					
						
							|  |  |  | 		'heading_views'      => __( 'Filter site themes list' ), | 
					
						
							|  |  |  | 		'heading_pagination' => __( 'Site themes list navigation' ), | 
					
						
							|  |  |  | 		'heading_list'       => __( 'Site themes list' ), | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | ); | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | $wp_list_table = _get_list_table( 'WP_MS_Themes_List_Table' ); | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | $action = $wp_list_table->current_action(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Clean up request URI from temporary args for screen options/paging uri's to work as expected.
 | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | $temp_args              = array( 'enabled', 'disabled', 'error' ); | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | $_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] ); | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | $referer                = remove_query_arg( $temp_args, wp_get_referer() ); | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | if ( ! empty( $_REQUEST['paged'] ) ) { | 
					
						
							|  |  |  | 	$referer = add_query_arg( 'paged', (int) $_REQUEST['paged'], $referer ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | if ( ! $id ) { | 
					
						
							|  |  |  | 	wp_die( __( 'Invalid site ID.' ) ); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | $wp_list_table->prepare_items(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $details = get_site( $id ); | 
					
						
							|  |  |  | if ( ! $details ) { | 
					
						
							|  |  |  | 	wp_die( __( 'The requested site does not exist.' ) ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | if ( ! can_edit_network( $details->site_id ) ) { | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 	wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 ); | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | $is_main_site = is_main_site( $id ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if ( $action ) { | 
					
						
							|  |  |  | 	switch_to_blog( $id ); | 
					
						
							|  |  |  | 	$allowed_themes = get_option( 'allowedthemes' ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	switch ( $action ) { | 
					
						
							|  |  |  | 		case 'enable': | 
					
						
							|  |  |  | 			check_admin_referer( 'enable-theme_' . $_GET['theme'] ); | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 			$theme  = $_GET['theme']; | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 			$action = 'enabled'; | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 			$n      = 1; | 
					
						
							|  |  |  | 			if ( ! $allowed_themes ) { | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 				$allowed_themes = array( $theme => true ); | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				$allowed_themes[ $theme ] = true; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 		case 'disable': | 
					
						
							|  |  |  | 			check_admin_referer( 'disable-theme_' . $_GET['theme'] ); | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 			$theme  = $_GET['theme']; | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 			$action = 'disabled'; | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 			$n      = 1; | 
					
						
							|  |  |  | 			if ( ! $allowed_themes ) { | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 				$allowed_themes = array(); | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				unset( $allowed_themes[ $theme ] ); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 		case 'enable-selected': | 
					
						
							|  |  |  | 			check_admin_referer( 'bulk-themes' ); | 
					
						
							|  |  |  | 			if ( isset( $_POST['checked'] ) ) { | 
					
						
							|  |  |  | 				$themes = (array) $_POST['checked']; | 
					
						
							|  |  |  | 				$action = 'enabled'; | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 				$n      = count( $themes ); | 
					
						
							|  |  |  | 				foreach ( (array) $themes as $theme ) { | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 					$allowed_themes[ $theme ] = true; | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				$action = 'error'; | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 				$n      = 'none'; | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case 'disable-selected': | 
					
						
							|  |  |  | 			check_admin_referer( 'bulk-themes' ); | 
					
						
							|  |  |  | 			if ( isset( $_POST['checked'] ) ) { | 
					
						
							|  |  |  | 				$themes = (array) $_POST['checked']; | 
					
						
							|  |  |  | 				$action = 'disabled'; | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 				$n      = count( $themes ); | 
					
						
							|  |  |  | 				foreach ( (array) $themes as $theme ) { | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 					unset( $allowed_themes[ $theme ] ); | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				$action = 'error'; | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 				$n      = 'none'; | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		default: | 
					
						
							|  |  |  | 			if ( isset( $_POST['checked'] ) ) { | 
					
						
							|  |  |  | 				check_admin_referer( 'bulk-themes' ); | 
					
						
							|  |  |  | 				$themes = (array) $_POST['checked']; | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 				$n      = count( $themes ); | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 				$screen = get_current_screen()->id; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				/** | 
					
						
							|  |  |  | 				 * Fires when a custom bulk action should be handled. | 
					
						
							|  |  |  | 				 * | 
					
						
							|  |  |  | 				 * The redirect link should be modified with success or failure feedback | 
					
						
							|  |  |  | 				 * from the action to be used to display feedback to the user. | 
					
						
							|  |  |  | 				 * | 
					
						
							|  |  |  | 				 * The dynamic portion of the hook name, `$screen`, refers to the current screen ID. | 
					
						
							|  |  |  | 				 * | 
					
						
							|  |  |  | 				 * @since 4.7.0 | 
					
						
							|  |  |  | 				 * | 
					
						
							|  |  |  | 				 * @param string $redirect_url The redirect URL. | 
					
						
							|  |  |  | 				 * @param string $action       The action being taken. | 
					
						
							|  |  |  | 				 * @param array  $items        The items to take the action on. | 
					
						
							|  |  |  | 				 * @param int    $site_id      The site ID. | 
					
						
							|  |  |  | 				 */ | 
					
						
							|  |  |  | 				$referer = apply_filters( "handle_network_bulk_actions-{$screen}", $referer, $action, $themes, $id ); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$action = 'error'; | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 				$n      = 'none'; | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	update_option( 'allowedthemes', $allowed_themes ); | 
					
						
							|  |  |  | 	restore_current_blog(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 	wp_safe_redirect( | 
					
						
							|  |  |  | 		add_query_arg( | 
					
						
							|  |  |  | 			array( | 
					
						
							|  |  |  | 				'id'    => $id, | 
					
						
							|  |  |  | 				$action => $n, | 
					
						
							|  |  |  | 			), | 
					
						
							|  |  |  | 			$referer | 
					
						
							|  |  |  | 		) | 
					
						
							|  |  |  | 	); | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 	exit; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) { | 
					
						
							|  |  |  | 	wp_safe_redirect( $referer ); | 
					
						
							|  |  |  | 	exit(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | add_thickbox(); | 
					
						
							|  |  |  | add_screen_option( 'per_page' ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* translators: %s: site name */ | 
					
						
							|  |  |  | $title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | $parent_file  = 'sites.php'; | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | $submenu_file = 'sites.php'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | require( ABSPATH . 'wp-admin/admin-header.php' ); ?>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <div class="wrap"> | 
					
						
							|  |  |  | <h1 id="edit-site"><?php echo $title; ?></h1>
 | 
					
						
							|  |  |  | <p class="edit-site-actions"><a href="<?php echo esc_url( get_home_url( $id, '/' ) ); ?>"><?php _e( 'Visit' ); ?></a> | <a href="<?php echo esc_url( get_admin_url( $id ) ); ?>"><?php _e( 'Dashboard' ); ?></a></p>
 | 
					
						
							|  |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | network_edit_site_nav( | 
					
						
							|  |  |  | 	array( | 
					
						
							|  |  |  | 		'blog_id'  => $id, | 
					
						
							|  |  |  | 		'selected' => 'site-themes', | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | ); | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | if ( isset( $_GET['enabled'] ) ) { | 
					
						
							|  |  |  | 	$enabled = absint( $_GET['enabled'] ); | 
					
						
							|  |  |  | 	if ( 1 == $enabled ) { | 
					
						
							|  |  |  | 		$message = __( 'Theme enabled.' ); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		$message = _n( '%s theme enabled.', '%s themes enabled.', $enabled ); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $enabled ) ) . '</p></div>'; | 
					
						
							|  |  |  | } elseif ( isset( $_GET['disabled'] ) ) { | 
					
						
							|  |  |  | 	$disabled = absint( $_GET['disabled'] ); | 
					
						
							|  |  |  | 	if ( 1 == $disabled ) { | 
					
						
							|  |  |  | 		$message = __( 'Theme disabled.' ); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		$message = _n( '%s theme disabled.', '%s themes disabled.', $disabled ); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>'; | 
					
						
							|  |  |  | } elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) { | 
					
						
							|  |  |  | 	echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'No theme selected.' ) . '</p></div>'; | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | } | 
					
						
							|  |  |  | ?>
 | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | <p><?php _e( 'Network enabled themes are not shown on this screen.' ); ?></p>
 | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | <form method="get"> | 
					
						
							|  |  |  | <?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?>
 | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" /> | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | </form> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <?php $wp_list_table->views(); ?>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <form method="post" action="site-themes.php?action=update-site"> | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 	<input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" /> | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | <?php $wp_list_table->display(); ?>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | </form> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | </div> | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | <?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?>
 |