[ Index ] |
PHP Cross Reference of WordPress |
[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 ); 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 <div class="wrap"> 179 <h1 id="edit-site"><?php echo $title; ?></h1> 180 <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> 181 <?php 182 183 network_edit_site_nav( 184 array( 185 'blog_id' => $id, 186 'selected' => 'site-themes', 187 ) 188 ); 189 190 if ( isset( $_GET['enabled'] ) ) { 191 $enabled = absint( $_GET['enabled'] ); 192 if ( 1 === $enabled ) { 193 $message = __( 'Theme enabled.' ); 194 } else { 195 /* translators: %s: Number of themes. */ 196 $message = _n( '%s theme enabled.', '%s themes enabled.', $enabled ); 197 } 198 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $enabled ) ) . '</p></div>'; 199 } elseif ( isset( $_GET['disabled'] ) ) { 200 $disabled = absint( $_GET['disabled'] ); 201 if ( 1 === $disabled ) { 202 $message = __( 'Theme disabled.' ); 203 } else { 204 /* translators: %s: Number of themes. */ 205 $message = _n( '%s theme disabled.', '%s themes disabled.', $disabled ); 206 } 207 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>'; 208 } elseif ( isset( $_GET['error'] ) && 'none' === $_GET['error'] ) { 209 echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'No theme selected.' ) . '</p></div>'; 210 } 211 ?> 212 213 <p><?php _e( 'Network enabled themes are not shown on this screen.' ); ?></p> 214 215 <form method="get"> 216 <?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?> 217 <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" /> 218 </form> 219 220 <?php $wp_list_table->views(); ?> 221 222 <form method="post" action="site-themes.php?action=update-site"> 223 <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" /> 224 225 <?php $wp_list_table->display(); ?> 226 227 </form> 228 229 </div> 230 <?php require_once ABSPATH . 'wp-admin/admin-footer.php'; ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Nov 21 01:00:03 2024 | Cross-referenced by PHPXref 0.7.1 |