]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/network/site-themes.php
WordPress 4.7
[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 ( ! current_user_can( 'manage_sites' ) )
14         wp_die( __( 'Sorry, you are not allowed to manage themes for this site.' ) );
15
16 get_current_screen()->add_help_tab( array(
17         'id'      => 'overview',
18         'title'   => __('Overview'),
19         'content' =>
20                 '<p>' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '</p>' .
21                 '<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>' .
22                 '<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>' .
23                 '<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>' .
24                 '<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>'
25 ) );
26
27 get_current_screen()->set_help_sidebar(
28         '<p><strong>' . __('For more information:') . '</strong></p>' .
29         '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen">Documentation on Site Management</a>') . '</p>' .
30         '<p>' . __('<a href="https://wordpress.org/support/forum/multisite/">Support Forums</a>') . '</p>'
31 );
32
33 get_current_screen()->set_screen_reader_content( array(
34         'heading_views'      => __( 'Filter site themes list' ),
35         'heading_pagination' => __( 'Site themes list navigation' ),
36         'heading_list'       => __( 'Site themes list' ),
37 ) );
38
39 $wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
40
41 $action = $wp_list_table->current_action();
42
43 $s = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
44
45 // Clean up request URI from temporary args for screen options/paging uri's to work as expected.
46 $temp_args = array( 'enabled', 'disabled', 'error' );
47 $_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] );
48 $referer = remove_query_arg( $temp_args, wp_get_referer() );
49
50 if ( ! empty( $_REQUEST['paged'] ) ) {
51         $referer = add_query_arg( 'paged', (int) $_REQUEST['paged'], $referer );
52 }
53
54 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
55
56 if ( ! $id )
57         wp_die( __('Invalid site ID.') );
58
59 $wp_list_table->prepare_items();
60
61 $details = get_site( $id );
62 if ( ! $details ) {
63         wp_die( __( 'The requested site does not exist.' ) );
64 }
65
66 if ( !can_edit_network( $details->site_id ) )
67         wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
68
69 $is_main_site = is_main_site( $id );
70
71 if ( $action ) {
72         switch_to_blog( $id );
73         $allowed_themes = get_option( 'allowedthemes' );
74
75         switch ( $action ) {
76                 case 'enable':
77                         check_admin_referer( 'enable-theme_' . $_GET['theme'] );
78                         $theme = $_GET['theme'];
79                         $action = 'enabled';
80                         $n = 1;
81                         if ( !$allowed_themes )
82                                 $allowed_themes = array( $theme => true );
83                         else
84                                 $allowed_themes[$theme] = true;
85                         break;
86                 case 'disable':
87                         check_admin_referer( 'disable-theme_' . $_GET['theme'] );
88                         $theme = $_GET['theme'];
89                         $action = 'disabled';
90                         $n = 1;
91                         if ( !$allowed_themes )
92                                 $allowed_themes = array();
93                         else
94                                 unset( $allowed_themes[$theme] );
95                         break;
96                 case 'enable-selected':
97                         check_admin_referer( 'bulk-themes' );
98                         if ( isset( $_POST['checked'] ) ) {
99                                 $themes = (array) $_POST['checked'];
100                                 $action = 'enabled';
101                                 $n = count( $themes );
102                                 foreach ( (array) $themes as $theme )
103                                         $allowed_themes[ $theme ] = true;
104                         } else {
105                                 $action = 'error';
106                                 $n = 'none';
107                         }
108                         break;
109                 case 'disable-selected':
110                         check_admin_referer( 'bulk-themes' );
111                         if ( isset( $_POST['checked'] ) ) {
112                                 $themes = (array) $_POST['checked'];
113                                 $action = 'disabled';
114                                 $n = count( $themes );
115                                 foreach ( (array) $themes as $theme )
116                                         unset( $allowed_themes[ $theme ] );
117                         } else {
118                                 $action = 'error';
119                                 $n = 'none';
120                         }
121                         break;
122                 default:
123                         if ( isset( $_POST['checked'] ) ) {
124                                 check_admin_referer( 'bulk-themes' );
125                                 $themes = (array) $_POST['checked'];
126                                 $n = count( $themes );
127                                 /**
128                                  * Fires when a custom bulk action should be handled.
129                                  *
130                                  * The redirect link should be modified with success or failure feedback
131                                  * from the action to be used to display feedback to the user.
132                                  *
133                                  * @since 4.7.0
134                                  *
135                                  * @param string $redirect_url The redirect URL.
136                                  * @param string $action       The action being taken.
137                                  * @param array  $items        The items to take the action on.
138                                  * @param int    $site_id      The site id.
139                                  */
140                                 $referer = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $referer, $action, $themes, $id );
141                         } else {
142                                 $action = 'error';
143                                 $n = 'none';
144                         }
145         }
146
147         update_option( 'allowedthemes', $allowed_themes );
148         restore_current_blog();
149
150         wp_safe_redirect( add_query_arg( array( 'id' => $id, $action => $n ), $referer ) );
151         exit;
152 }
153
154 if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) {
155         wp_safe_redirect( $referer );
156         exit();
157 }
158
159 add_thickbox();
160 add_screen_option( 'per_page' );
161
162 /* translators: %s: site name */
163 $title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) );
164
165 $parent_file = 'sites.php';
166 $submenu_file = 'sites.php';
167
168 require( ABSPATH . 'wp-admin/admin-header.php' ); ?>
169
170 <div class="wrap">
171 <h1 id="edit-site"><?php echo $title; ?></h1>
172 <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>
173 <?php
174
175 network_edit_site_nav( array(
176         'blog_id'  => $id,
177         'selected' => 'site-themes'
178 ) );
179
180 if ( isset( $_GET['enabled'] ) ) {
181         $enabled = absint( $_GET['enabled'] );
182         if ( 1 == $enabled ) {
183                 $message = __( 'Theme enabled.' );
184         } else {
185                 $message = _n( '%s theme enabled.', '%s themes enabled.', $enabled );
186         }
187         echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $enabled ) ) . '</p></div>';
188 } elseif ( isset( $_GET['disabled'] ) ) {
189         $disabled = absint( $_GET['disabled'] );
190         if ( 1 == $disabled ) {
191                 $message = __( 'Theme disabled.' );
192         } else {
193                 $message = _n( '%s theme disabled.', '%s themes disabled.', $disabled );
194         }
195         echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>';
196 } elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) {
197         echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'No theme selected.' ) . '</p></div>';
198 } ?>
199
200 <p><?php _e( 'Network enabled themes are not shown on this screen.' ) ?></p>
201
202 <form method="get">
203 <?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?>
204 <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
205 </form>
206
207 <?php $wp_list_table->views(); ?>
208
209 <form method="post" action="site-themes.php?action=update-site">
210         <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
211
212 <?php $wp_list_table->display(); ?>
213
214 </form>
215
216 </div>
217 <?php include(ABSPATH . 'wp-admin/admin-footer.php'); ?>