]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/network/site-themes.php
WordPress 4.3
[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> - The domain and path are 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> - 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> - 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> - 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 $wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
37
38 $action = $wp_list_table->current_action();
39
40 $s = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
41
42 // Clean up request URI from temporary args for screen options/paging uri's to work as expected.
43 $temp_args = array( 'enabled', 'disabled', 'error' );
44 $_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] );
45 $referer = remove_query_arg( $temp_args, wp_get_referer() );
46
47 if ( ! empty( $_REQUEST['paged'] ) ) {
48         $referer = add_query_arg( 'paged', (int) $_REQUEST['paged'], $referer );
49 }
50
51 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
52
53 if ( ! $id )
54         wp_die( __('Invalid site ID.') );
55
56 $wp_list_table->prepare_items();
57
58 $details = get_blog_details( $id );
59 if ( ! $details ) {
60         wp_die( __( 'The requested site does not exist.' ) );
61 }
62
63 if ( !can_edit_network( $details->site_id ) )
64         wp_die( __( 'You do not have permission to access this page.' ), 403 );
65
66 $is_main_site = is_main_site( $id );
67
68 if ( $action ) {
69         switch_to_blog( $id );
70         $allowed_themes = get_option( 'allowedthemes' );
71
72         switch ( $action ) {
73                 case 'enable':
74                         check_admin_referer( 'enable-theme_' . $_GET['theme'] );
75                         $theme = $_GET['theme'];
76                         $action = 'enabled';
77                         $n = 1;
78                         if ( !$allowed_themes )
79                                 $allowed_themes = array( $theme => true );
80                         else
81                                 $allowed_themes[$theme] = true;
82                         break;
83                 case 'disable':
84                         check_admin_referer( 'disable-theme_' . $_GET['theme'] );
85                         $theme = $_GET['theme'];
86                         $action = 'disabled';
87                         $n = 1;
88                         if ( !$allowed_themes )
89                                 $allowed_themes = array();
90                         else
91                                 unset( $allowed_themes[$theme] );
92                         break;
93                 case 'enable-selected':
94                         check_admin_referer( 'bulk-themes' );
95                         if ( isset( $_POST['checked'] ) ) {
96                                 $themes = (array) $_POST['checked'];
97                                 $action = 'enabled';
98                                 $n = count( $themes );
99                                 foreach( (array) $themes as $theme )
100                                         $allowed_themes[ $theme ] = true;
101                         } else {
102                                 $action = 'error';
103                                 $n = 'none';
104                         }
105                         break;
106                 case 'disable-selected':
107                         check_admin_referer( 'bulk-themes' );
108                         if ( isset( $_POST['checked'] ) ) {
109                                 $themes = (array) $_POST['checked'];
110                                 $action = 'disabled';
111                                 $n = count( $themes );
112                                 foreach( (array) $themes as $theme )
113                                         unset( $allowed_themes[ $theme ] );
114                         } else {
115                                 $action = 'error';
116                                 $n = 'none';
117                         }
118                         break;
119         }
120
121         update_option( 'allowedthemes', $allowed_themes );
122         restore_current_blog();
123
124         wp_safe_redirect( add_query_arg( array( 'id' => $id, $action => $n ), $referer ) );
125         exit;
126 }
127
128 if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) {
129         wp_safe_redirect( $referer );
130         exit();
131 }
132
133 add_thickbox();
134 add_screen_option( 'per_page' );
135
136 $title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) );
137
138 $parent_file = 'sites.php';
139 $submenu_file = 'sites.php';
140
141 require( ABSPATH . 'wp-admin/admin-header.php' ); ?>
142
143 <div class="wrap">
144 <h1 id="edit-site"><?php echo $title; ?></h1>
145 <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>
146 <h3 class="nav-tab-wrapper">
147 <?php
148 $tabs = array(
149         'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php'     ),
150         'site-users'    => array( 'label' => __( 'Users' ),    'url' => 'site-users.php'    ),
151         'site-themes'   => array( 'label' => __( 'Themes' ),   'url' => 'site-themes.php'   ),
152         'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php' ),
153 );
154 foreach ( $tabs as $tab_id => $tab ) {
155         $class = ( $tab['url'] == $pagenow ) ? ' nav-tab-active' : '';
156         echo '<a href="' . $tab['url'] . '?id=' . $id .'" class="nav-tab' . $class . '">' . esc_html( $tab['label'] ) . '</a>';
157 }
158 ?>
159 </h3><?php
160
161 if ( isset( $_GET['enabled'] ) ) {
162         $enabled = absint( $_GET['enabled'] );
163         if ( 1 == $enabled ) {
164                 $message = __( 'Theme enabled.' );
165         } else {
166                 $message = _n( '%s theme enabled.', '%s themes enabled.', $enabled );
167         }
168         echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $enabled ) ) . '</p></div>';
169 } elseif ( isset( $_GET['disabled'] ) ) {
170         $disabled = absint( $_GET['disabled'] );
171         if ( 1 == $disabled ) {
172                 $message = __( 'Theme disabled.' );
173         } else {
174                 $message = _n( '%s theme disabled.', '%s themes disabled.', $disabled );
175         }
176         echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>';
177 } elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) {
178         echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'No theme selected.' ) . '</p></div>';
179 } ?>
180
181 <p><?php _e( 'Network enabled themes are not shown on this screen.' ) ?></p>
182
183 <form method="get">
184 <?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?>
185 <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
186 </form>
187
188 <?php $wp_list_table->views(); ?>
189
190 <form method="post" action="site-themes.php?action=update-site">
191         <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
192
193 <?php $wp_list_table->display(); ?>
194
195 </form>
196
197 </div>
198 <?php include(ABSPATH . 'wp-admin/admin-footer.php'); ?>