[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
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, false ); 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 // Used in the HTML title tag. 170 /* translators: %s: Site title. */ 171 $title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) ); 172 173 $parent_file = 'sites.php'; 174 $submenu_file = 'sites.php'; 175 176 require_once ABSPATH . 'wp-admin/admin-header.php'; 177 ?> 178 179 <div class="wrap"> 180 <h1 id="edit-site"><?php echo $title; ?></h1> 181 <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> 182 <?php 183 184 network_edit_site_nav( 185 array( 186 'blog_id' => $id, 187 'selected' => 'site-themes', 188 ) 189 ); 190 191 if ( isset( $_GET['enabled'] ) ) { 192 $enabled = absint( $_GET['enabled'] ); 193 if ( 1 === $enabled ) { 194 $message = __( 'Theme enabled.' ); 195 } else { 196 /* translators: %s: Number of themes. */ 197 $message = _n( '%s theme enabled.', '%s themes enabled.', $enabled ); 198 } 199 200 wp_admin_notice( 201 sprintf( $message, number_format_i18n( $enabled ) ), 202 array( 203 'type' => 'success', 204 'dismissible' => true, 205 'id' => 'message', 206 ) 207 ); 208 } elseif ( isset( $_GET['disabled'] ) ) { 209 $disabled = absint( $_GET['disabled'] ); 210 if ( 1 === $disabled ) { 211 $message = __( 'Theme disabled.' ); 212 } else { 213 /* translators: %s: Number of themes. */ 214 $message = _n( '%s theme disabled.', '%s themes disabled.', $disabled ); 215 } 216 217 wp_admin_notice( 218 sprintf( $message, number_format_i18n( $disabled ) ), 219 array( 220 'type' => 'success', 221 'dismissible' => true, 222 'id' => 'message', 223 ) 224 ); 225 } elseif ( isset( $_GET['error'] ) && 'none' === $_GET['error'] ) { 226 wp_admin_notice( 227 __( 'No theme selected.' ), 228 array( 229 'type' => 'error', 230 'dismissible' => true, 231 'id' => 'message', 232 ) 233 ); 234 } 235 ?> 236 237 <p><?php _e( 'Network enabled themes are not shown on this screen.' ); ?></p> 238 239 <form method="get"> 240 <?php $wp_list_table->search_box( __( 'Search installed themes' ), 'theme' ); ?> 241 <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" /> 242 </form> 243 244 <?php $wp_list_table->views(); ?> 245 246 <form method="post" action="site-themes.php?action=update-site"> 247 <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" /> 248 249 <?php $wp_list_table->display(); ?> 250 251 </form> 252 253 </div> 254 <?php require_once ABSPATH . 'wp-admin/admin-footer.php'; ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Tue Dec 24 08:20:01 2024 | Cross-referenced by PHPXref |