"Fossies" - the Fresh Open Source Software Archive 
Member "wordpress/wp-admin/network/site-themes.php" (8 Oct 2020, 6715 Bytes) of package /linux/www/wordpress-5.7-RC1.tar.gz:
The requested HTML page contains a <FORM> tag that is unusable on "Fossies" in "automatic" (rendered) mode so that page is shown as HTML source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file. For more information about "site-themes.php" see the
Fossies "Dox" file reference documentation and the last
Fossies "Diffs" side-by-side code changes report:
5.5.3_vs_5.6.
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 __DIR__ . '/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
17 get_current_screen()->add_help_tab( get_site_screen_help_tab_args() );
18 get_current_screen()->set_help_sidebar( get_site_screen_help_sidebar_content() );
19
20 get_current_screen()->set_screen_reader_content(
21 array(
22 'heading_views' => __( 'Filter site themes list' ),
23 'heading_pagination' => __( 'Site themes list navigation' ),
24 'heading_list' => __( 'Site themes list' ),
25 )
26 );
27
28 $wp_list_table = _get_list_table( 'WP_MS_Themes_List_Table' );
29
30 $action = $wp_list_table->current_action();
31
32 $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
33
34 // Clean up request URI from temporary args for screen options/paging uri's to work as expected.
35 $temp_args = array( 'enabled', 'disabled', 'error' );
36 $_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] );
37 $referer = remove_query_arg( $temp_args, wp_get_referer() );
38
39 if ( ! empty( $_REQUEST['paged'] ) ) {
40 $referer = add_query_arg( 'paged', (int) $_REQUEST['paged'], $referer );
41 }
42
43 $id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0;
44
45 if ( ! $id ) {
46 wp_die( __( 'Invalid site ID.' ) );
47 }
48
49 $wp_list_table->prepare_items();
50
51 $details = get_site( $id );
52 if ( ! $details ) {
53 wp_die( __( 'The requested site does not exist.' ) );
54 }
55
56 if ( ! can_edit_network( $details->site_id ) ) {
57 wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
58 }
59
60 $is_main_site = is_main_site( $id );
61
62 if ( $action ) {
63 switch_to_blog( $id );
64 $allowed_themes = get_option( 'allowedthemes' );
65
66 switch ( $action ) {
67 case 'enable':
68 check_admin_referer( 'enable-theme_' . $_GET['theme'] );
69 $theme = $_GET['theme'];
70 $action = 'enabled';
71 $n = 1;
72 if ( ! $allowed_themes ) {
73 $allowed_themes = array( $theme => true );
74 } else {
75 $allowed_themes[ $theme ] = true;
76 }
77 break;
78 case 'disable':
79 check_admin_referer( 'disable-theme_' . $_GET['theme'] );
80 $theme = $_GET['theme'];
81 $action = 'disabled';
82 $n = 1;
83 if ( ! $allowed_themes ) {
84 $allowed_themes = array();
85 } else {
86 unset( $allowed_themes[ $theme ] );
87 }
88 break;
89 case 'enable-selected':
90 check_admin_referer( 'bulk-themes' );
91 if ( isset( $_POST['checked'] ) ) {
92 $themes = (array) $_POST['checked'];
93 $action = 'enabled';
94 $n = count( $themes );
95 foreach ( (array) $themes as $theme ) {
96 $allowed_themes[ $theme ] = true;
97 }
98 } else {
99 $action = 'error';
100 $n = 'none';
101 }
102 break;
103 case 'disable-selected':
104 check_admin_referer( 'bulk-themes' );
105 if ( isset( $_POST['checked'] ) ) {
106 $themes = (array) $_POST['checked'];
107 $action = 'disabled';
108 $n = count( $themes );
109 foreach ( (array) $themes as $theme ) {
110 unset( $allowed_themes[ $theme ] );
111 }
112 } else {
113 $action = 'error';
114 $n = 'none';
115 }
116 break;
117 default:
118 if ( isset( $_POST['checked'] ) ) {
119 check_admin_referer( 'bulk-themes' );
120 $themes = (array) $_POST['checked'];
121 $n = count( $themes );
122 $screen = get_current_screen()->id;
123
124 /**
125 * Fires when a custom bulk action should be handled.
126 *
127 * The redirect link should be modified with success or failure feedback
128 * from the action to be used to display feedback to the user.
129 *
130 * The dynamic portion of the hook name, `$screen`, refers to the current screen ID.
131 *
132 * @since 4.7.0
133 *
134 * @param string $redirect_url The redirect URL.
135 * @param string $action The action being taken.
136 * @param array $items The items to take the action on.
137 * @param int $site_id The site ID.
138 */
139 $referer = apply_filters( "handle_network_bulk_actions-{$screen}", $referer, $action, $themes, $id ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
140 } else {
141 $action = 'error';
142 $n = 'none';
143 }
144 }
145
146 update_option( 'allowedthemes', $allowed_themes );
147 restore_current_blog();
148
149 wp_safe_redirect(
150 add_query_arg(
151 array(
152 'id' => $id,
153 $action => $n,
154 ),
155 $referer
156 )
157 );
158 exit;
159 }
160
161 if ( isset( $_GET['action'] ) && 'update-site' === $_GET['action'] ) {
162 wp_safe_redirect( $referer );
163 exit;
164 }
165
166 add_thickbox();
167 add_screen_option( 'per_page' );
168
169 /* translators: %s: Site title. */
170 $title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) );
171
172 $parent_file = 'sites.php';
173 $submenu_file = 'sites.php';
174
175 require_once ABSPATH . 'wp-admin/admin-header.php'; ?>
176
177 <div class="wrap">
178 <h1 id="edit-site"><?php echo $title; ?></h1>
179 <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>
180 <?php
181
182 network_edit_site_nav(
183 array(
184 'blog_id' => $id,
185 'selected' => 'site-themes',
186 )
187 );
188
189 if ( isset( $_GET['enabled'] ) ) {
190 $enabled = absint( $_GET['enabled'] );
191 if ( 1 === $enabled ) {
192 $message = __( 'Theme enabled.' );
193 } else {
194 /* translators: %s: Number of themes. */
195 $message = _n( '%s theme enabled.', '%s themes enabled.', $enabled );
196 }
197 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $enabled ) ) . '</p></div>';
198 } elseif ( isset( $_GET['disabled'] ) ) {
199 $disabled = absint( $_GET['disabled'] );
200 if ( 1 === $disabled ) {
201 $message = __( 'Theme disabled.' );
202 } else {
203 /* translators: %s: Number of themes. */
204 $message = _n( '%s theme disabled.', '%s themes disabled.', $disabled );
205 }
206 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>';
207 } elseif ( isset( $_GET['error'] ) && 'none' === $_GET['error'] ) {
208 echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'No theme selected.' ) . '</p></div>';
209 }
210 ?>
211
212 <p><?php _e( 'Network enabled themes are not shown on this screen.' ); ?></p>
213
214 <form method="get">
215 <?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?>
216 <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
217 </form>
218
219 <?php $wp_list_table->views(); ?>
220
221 <form method="post" action="site-themes.php?action=update-site">
222 <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
223
224 <?php $wp_list_table->display(); ?>
225
226 </form>
227
228 </div>
229 <?php require_once ABSPATH . 'wp-admin/admin-footer.php'; ?>