]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/network/site-themes.php
WordPress 4.4
[autoinstalls/wordpress.git] / wp-admin / network / site-themes.php
1 <?php
2 /**
3  * Edit Site Themes Administration Screen
4  *
5  * @package WordPress
6  * @subpackage Multisite
7  * @since 3.1.0
8  */
9
10 /** Load WordPress Administration Bootstrap */
11 require_once( dirname( __FILE__ ) . '/admin.php' );
12
13 if ( ! is_multisite() )
14         wp_die( __( 'Multisite support is not enabled.' ) );
15
16 if ( ! current_user_can( 'manage_sites' ) )
17         wp_die( __( 'You do not have sufficient permissions to manage themes for this site.' ) );
18
19 get_current_screen()->add_help_tab( array(
20         'id'      => 'overview',
21         'title'   => __('Overview'),
22         'content' =>
23                 '<p>' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '</p>' .
24                 '<p>' . __('<strong>Info</strong> &mdash; The site URL is rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.') . '</p>' .
25                 '<p>' . __('<strong>Users</strong> &mdash; This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.') . '</p>' .
26                 '<p>' . sprintf( __('<strong>Themes</strong> &mdash; This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site&#8217;s Appearance menu. To enable a theme for the entire network, see the <a href="%s">Network Themes</a> screen.' ), network_admin_url( 'themes.php' ) ) . '</p>' .
27                 '<p>' . __('<strong>Settings</strong> &mdash; This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.') . '</p>'
28 ) );
29
30 get_current_screen()->set_help_sidebar(
31         '<p><strong>' . __('For more information:') . '</strong></p>' .
32         '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen" target="_blank">Documentation on Site Management</a>') . '</p>' .
33         '<p>' . __('<a href="https://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
34 );
35
36 get_current_screen()->set_screen_reader_content( array(
37         'heading_views'      => __( 'Filter site themes list' ),
38         'heading_pagination' => __( 'Site themes list navigation' ),
39         'heading_list'       => __( 'Site themes list' ),
40 ) );
41
42 $wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
43
44 $action = $wp_list_table->current_action();
45
46 $s = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
47
48 // Clean up request URI from temporary args for screen options/paging uri's to work as expected.
49 $temp_args = array( 'enabled', 'disabled', 'error' );
50 $_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] );
51 $referer = remove_query_arg( $temp_args, wp_get_referer() );
52
53 if ( ! empty( $_REQUEST['paged'] ) ) {
54         $referer = add_query_arg( 'paged', (int) $_REQUEST['paged'], $referer );
55 }
56
57 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
58
59 if ( ! $id )
60         wp_die( __('Invalid site ID.') );
61
62 $wp_list_table->prepare_items();
63
64 $details = get_blog_details( $id );
65 if ( ! $details ) {
66         wp_die( __( 'The requested site does not exist.' ) );
67 }
68
69 if ( !can_edit_network( $details->site_id ) )
70         wp_die( __( 'You do not have permission to access this page.' ), 403 );
71
72 $is_main_site = is_main_site( $id );
73
74 if ( $action ) {
75         switch_to_blog( $id );
76         $allowed_themes = get_option( 'allowedthemes' );
77
78         switch ( $action ) {
79                 case 'enable':
80                         check_admin_referer( 'enable-theme_' . $_GET['theme'] );
81                         $theme = $_GET['theme'];
82                         $action = 'enabled';
83                         $n = 1;
84                         if ( !$allowed_themes )
85                                 $allowed_themes = array( $theme => true );
86                         else
87                                 $allowed_themes[$theme] = true;
88                         break;
89                 case 'disable':
90                         check_admin_referer( 'disable-theme_' . $_GET['theme'] );
91                         $theme = $_GET['theme'];
92                         $action = 'disabled';
93                         $n = 1;
94                         if ( !$allowed_themes )
95                                 $allowed_themes = array();
96                         else
97                                 unset( $allowed_themes[$theme] );
98                         break;
99                 case 'enable-selected':
100                         check_admin_referer( 'bulk-themes' );
101                         if ( isset( $_POST['checked'] ) ) {
102                                 $themes = (array) $_POST['checked'];
103                                 $action = 'enabled';
104                                 $n = count( $themes );
105                                 foreach ( (array) $themes as $theme )
106                                         $allowed_themes[ $theme ] = true;
107                         } else {
108                                 $action = 'error';
109                                 $n = 'none';
110                         }
111                         break;
112                 case 'disable-selected':
113                         check_admin_referer( 'bulk-themes' );
114                         if ( isset( $_POST['checked'] ) ) {
115                                 $themes = (array) $_POST['checked'];
116                                 $action = 'disabled';
117                                 $n = count( $themes );
118                                 foreach ( (array) $themes as $theme )
119                                         unset( $allowed_themes[ $theme ] );
120                         } else {
121                                 $action = 'error';
122                                 $n = 'none';
123                         }
124                         break;
125         }
126
127         update_option( 'allowedthemes', $allowed_themes );
128         restore_current_blog();
129
130         wp_safe_redirect( add_query_arg( array( 'id' => $id, $action => $n ), $referer ) );
131         exit;
132 }
133
134 if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) {
135         wp_safe_redirect( $referer );
136         exit();
137 }
138
139 add_thickbox();
140 add_screen_option( 'per_page' );
141
142 $title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) );
143
144 $parent_file = 'sites.php';
145 $submenu_file = 'sites.php';
146
147 require( ABSPATH . 'wp-admin/admin-header.php' ); ?>
148
149 <div class="wrap">
150 <h1 id="edit-site"><?php echo $title; ?></h1>
151 <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>
152 <h2 class="nav-tab-wrapper nav-tab-small">
153 <?php
154 $tabs = array(
155         'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php'     ),
156         'site-users'    => array( 'label' => __( 'Users' ),    'url' => 'site-users.php'    ),
157         'site-themes'   => array( 'label' => __( 'Themes' ),   'url' => 'site-themes.php'   ),
158         'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php' ),
159 );
160 foreach ( $tabs as $tab_id => $tab ) {
161         $class = ( $tab['url'] == $pagenow ) ? ' nav-tab-active' : '';
162         echo '<a href="' . $tab['url'] . '?id=' . $id .'" class="nav-tab' . $class . '">' . esc_html( $tab['label'] ) . '</a>';
163 }
164 ?>
165 </h2><?php
166
167 if ( isset( $_GET['enabled'] ) ) {
168         $enabled = absint( $_GET['enabled'] );
169         if ( 1 == $enabled ) {
170                 $message = __( 'Theme enabled.' );
171         } else {
172                 $message = _n( '%s theme enabled.', '%s themes enabled.', $enabled );
173         }
174         echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $enabled ) ) . '</p></div>';
175 } elseif ( isset( $_GET['disabled'] ) ) {
176         $disabled = absint( $_GET['disabled'] );
177         if ( 1 == $disabled ) {
178                 $message = __( 'Theme disabled.' );
179         } else {
180                 $message = _n( '%s theme disabled.', '%s themes disabled.', $disabled );
181         }
182         echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>';
183 } elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) {
184         echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'No theme selected.' ) . '</p></div>';
185 } ?>
186
187 <p><?php _e( 'Network enabled themes are not shown on this screen.' ) ?></p>
188
189 <form method="get">
190 <?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?>
191 <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
192 </form>
193
194 <?php $wp_list_table->views(); ?>
195
196 <form method="post" action="site-themes.php?action=update-site">
197         <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
198
199 <?php $wp_list_table->display(); ?>
200
201 </form>
202
203 </div>
204 <?php include(ABSPATH . 'wp-admin/admin-footer.php'); ?>