Changeset 42343 for trunk/src/wp-admin/network/site-settings.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/network/site-settings.php
r41065 r42343 11 11 require_once( dirname( __FILE__ ) . '/admin.php' ); 12 12 13 if ( ! current_user_can( 'manage_sites' ) ) 13 if ( ! current_user_can( 'manage_sites' ) ) { 14 14 wp_die( __( 'Sorry, you are not allowed to edit this site.' ) ); 15 } 15 16 16 17 get_current_screen()->add_help_tab( get_site_screen_help_tab_args() ); … … 19 20 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; 20 21 21 if ( ! $id ) 22 wp_die( __('Invalid site ID.') ); 22 if ( ! $id ) { 23 wp_die( __( 'Invalid site ID.' ) ); 24 } 23 25 24 26 $details = get_site( $id ); … … 27 29 } 28 30 29 if ( ! can_edit_network( $details->site_id ) )31 if ( ! can_edit_network( $details->site_id ) ) { 30 32 wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 ); 33 } 31 34 32 35 $is_main_site = is_main_site( $id ); 33 36 34 if ( isset( $_REQUEST['action']) && 'update-site' == $_REQUEST['action'] && is_array( $_POST['option'] ) ) {37 if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] && is_array( $_POST['option'] ) ) { 35 38 check_admin_referer( 'edit-site' ); 36 39 … … 41 44 $key = wp_unslash( $key ); 42 45 $val = wp_unslash( $val ); 43 if ( $key === 0 || is_array( $val ) || in_array( $key, $skip_options) )46 if ( $key === 0 || is_array( $val ) || in_array( $key, $skip_options ) ) { 44 47 continue; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options 48 } 45 49 update_option( $key, $val ); 46 50 } … … 57 61 58 62 restore_current_blog(); 59 wp_redirect( add_query_arg( array( 'update' => 'updated', 'id' => $id ), 'site-settings.php') ); 63 wp_redirect( 64 add_query_arg( 65 array( 66 'update' => 'updated', 67 'id' => $id, 68 ), 'site-settings.php' 69 ) 70 ); 60 71 exit; 61 72 } 62 73 63 if ( isset( $_GET['update']) ) {74 if ( isset( $_GET['update'] ) ) { 64 75 $messages = array(); 65 if ( 'updated' == $_GET['update'] ) 66 $messages[] = __('Site options updated.'); 76 if ( 'updated' == $_GET['update'] ) { 77 $messages[] = __( 'Site options updated.' ); 78 } 67 79 } 68 80 … … 70 82 $title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) ); 71 83 72 $parent_file = 'sites.php';84 $parent_file = 'sites.php'; 73 85 $submenu_file = 'sites.php'; 74 86 … … 83 95 <?php 84 96 85 network_edit_site_nav( array( 86 'blog_id' => $id, 87 'selected' => 'site-settings' 88 ) ); 97 network_edit_site_nav( 98 array( 99 'blog_id' => $id, 100 'selected' => 'site-settings', 101 ) 102 ); 89 103 90 104 if ( ! empty( $messages ) ) { 91 foreach ( $messages as $msg ) 105 foreach ( $messages as $msg ) { 92 106 echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>'; 93 } ?> 107 } 108 } 109 ?> 94 110 <form method="post" action="site-settings.php?action=update-site"> 95 111 <?php wp_nonce_field( 'edit-site' ); ?> 96 <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />112 <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" /> 97 113 <table class="form-table"> 98 114 <?php 99 115 $blog_prefix = $wpdb->get_blog_prefix( $id ); 100 $sql = "SELECT * FROM {$blog_prefix}options116 $sql = "SELECT * FROM {$blog_prefix}options 101 117 WHERE option_name NOT LIKE %s 102 118 AND option_name NOT LIKE %s"; 103 $query = $wpdb->prepare( $sql, 119 $query = $wpdb->prepare( 120 $sql, 104 121 $wpdb->esc_like( '_' ) . '%', 105 122 '%' . $wpdb->esc_like( 'user_roles' ) 106 123 ); 107 $options = $wpdb->get_results( $query );124 $options = $wpdb->get_results( $query ); 108 125 foreach ( $options as $option ) { 109 if ( $option->option_name == 'default_role' ) 126 if ( $option->option_name == 'default_role' ) { 110 127 $editblog_default_role = $option->option_value; 128 } 111 129 $disabled = false; 112 $class = 'all-options';130 $class = 'all-options'; 113 131 if ( is_serialized( $option->option_value ) ) { 114 132 if ( is_serialized_string( $option->option_value ) ) { … … 116 134 } else { 117 135 $option->option_value = 'SERIALIZED DATA'; 118 $disabled = true;119 $class = 'all-options disabled';136 $disabled = true; 137 $class = 'all-options disabled'; 120 138 } 121 139 } … … 123 141 ?> 124 142 <tr class="form-field"> 125 <th scope="row"><label for="<?php echo esc_attr( $option->option_name ) ?>"><?php echo ucwords( str_replace( "_", " ", $option->option_name ) )?></label></th>126 <td><textarea class="<?php echo $class; ?>" rows="5" cols="40" name="option[<?php echo esc_attr( $option->option_name ) ?>]" id="<?php echo esc_attr( $option->option_name ) ?>"<?php disabled( $disabled ) ?>><?php echo esc_textarea( $option->option_value )?></textarea></td>143 <th scope="row"><label for="<?php echo esc_attr( $option->option_name ); ?>"><?php echo ucwords( str_replace( '_', ' ', $option->option_name ) ); ?></label></th> 144 <td><textarea class="<?php echo $class; ?>" rows="5" cols="40" name="option[<?php echo esc_attr( $option->option_name ); ?>]" id="<?php echo esc_attr( $option->option_name ); ?>"<?php disabled( $disabled ); ?>><?php echo esc_textarea( $option->option_value ); ?></textarea></td> 127 145 </tr> 128 146 <?php … … 130 148 ?> 131 149 <tr class="form-field"> 132 <th scope="row"><label for="<?php echo esc_attr( $option->option_name ) ?>"><?php echo esc_html( ucwords( str_replace( "_", " ", $option->option_name ) ) ); ?></label></th>150 <th scope="row"><label for="<?php echo esc_attr( $option->option_name ); ?>"><?php echo esc_html( ucwords( str_replace( '_', ' ', $option->option_name ) ) ); ?></label></th> 133 151 <?php if ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ) ) ) { ?> 134 <td><code><?php echo esc_html( $option->option_value ) ?></code></td>152 <td><code><?php echo esc_html( $option->option_value ); ?></code></td> 135 153 <?php } else { ?> 136 <td><input class="<?php echo $class; ?>" name="option[<?php echo esc_attr( $option->option_name ) ?>]" type="text" id="<?php echo esc_attr( $option->option_name ) ?>" value="<?php echo esc_attr( $option->option_value ) ?>" size="40" <?php disabled( $disabled )?> /></td>154 <td><input class="<?php echo $class; ?>" name="option[<?php echo esc_attr( $option->option_name ); ?>]" type="text" id="<?php echo esc_attr( $option->option_name ); ?>" value="<?php echo esc_attr( $option->option_value ); ?>" size="40" <?php disabled( $disabled ); ?> /></td> 137 155 <?php } ?> 138 156 </tr>
Note: See TracChangeset
for help on using the changeset viewer.