[ Index ]

WordPress Cross Reference

title

Body

[close]

/wp-admin/network/ -> site-info.php (source)

   1  <?php
   2  /**
   3   * Edit Site Info 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 edit 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="http://codex.wordpress.org/Network_Admin_Sites_Screen" target="_blank">Documentation on Site Management</a>') . '</p>' .
  33      '<p>' . __('<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
  34  );
  35  
  36  $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
  37  
  38  if ( ! $id )
  39      wp_die( __('Invalid site ID.') );
  40  
  41  $details = get_blog_details( $id );
  42  if ( !can_edit_network( $details->site_id ) )
  43      wp_die( __( 'You do not have permission to access this page.' ) );
  44  
  45  $is_main_site = is_main_site( $id );
  46  
  47  if ( isset($_REQUEST['action']) && 'update-site' == $_REQUEST['action'] ) {
  48      check_admin_referer( 'edit-site' );
  49  
  50      switch_to_blog( $id );
  51  
  52      if ( isset( $_POST['update_home_url'] ) && $_POST['update_home_url'] == 'update' ) {
  53          $blog_address = esc_url_raw( $_POST['blog']['domain'] . $_POST['blog']['path'] );
  54          if ( get_option( 'siteurl' ) != $blog_address )
  55              update_option( 'siteurl', $blog_address );
  56  
  57          if ( get_option( 'home' ) != $blog_address )
  58              update_option( 'home', $blog_address );
  59      }
  60  
  61      // rewrite rules can't be flushed during switch to blog
  62      delete_option( 'rewrite_rules' );
  63  
  64      // update blogs table
  65      $blog_data = wp_unslash( $_POST['blog'] );
  66      $existing_details = get_blog_details( $id, false );
  67      $blog_data_checkboxes = array( 'public', 'archived', 'spam', 'mature', 'deleted' );
  68      foreach ( $blog_data_checkboxes as $c ) {
  69          if ( ! in_array( $existing_details->$c, array( 0, 1 ) ) )
  70              $blog_data[ $c ] = $existing_details->$c;
  71          else
  72              $blog_data[ $c ] = isset( $_POST['blog'][ $c ] ) ? 1 : 0;
  73      }
  74      update_blog_details( $id, $blog_data );
  75  
  76      restore_current_blog();
  77      wp_redirect( add_query_arg( array( 'update' => 'updated', 'id' => $id ), 'site-info.php') );
  78      exit;
  79  }
  80  
  81  if ( isset($_GET['update']) ) {
  82      $messages = array();
  83      if ( 'updated' == $_GET['update'] )
  84          $messages[] = __('Site info updated.');
  85  }
  86  
  87  $site_url_no_http = preg_replace( '#^http(s)?://#', '', get_blogaddress_by_id( $id ) );
  88  $title_site_url_linked = sprintf( __('Edit Site: <a href="%1$s">%2$s</a>'), get_blogaddress_by_id( $id ), $site_url_no_http );
  89  $title = sprintf( __('Edit Site: %s'), $site_url_no_http );
  90  
  91  $parent_file = 'sites.php';
  92  $submenu_file = 'sites.php';
  93  
  94  require ( ABSPATH . 'wp-admin/admin-header.php' );
  95  
  96  ?>
  97  
  98  <div class="wrap">
  99  <h2 id="edit-site"><?php echo $title_site_url_linked ?></h2>
 100  <h3 class="nav-tab-wrapper">
 101  <?php
 102  $tabs = array(
 103      'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php'     ),
 104      'site-users'    => array( 'label' => __( 'Users' ),    'url' => 'site-users.php'    ),
 105      'site-themes'   => array( 'label' => __( 'Themes' ),   'url' => 'site-themes.php'   ),
 106      'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php' ),
 107  );
 108  foreach ( $tabs as $tab_id => $tab ) {
 109      $class = ( $tab['url'] == $pagenow ) ? ' nav-tab-active' : '';
 110      echo '<a href="' . $tab['url'] . '?id=' . $id .'" class="nav-tab' . $class . '">' . esc_html( $tab['label'] ) . '</a>';
 111  }
 112  ?>
 113  </h3>
 114  <?php
 115  if ( ! empty( $messages ) ) {
 116      foreach ( $messages as $msg )
 117          echo '<div id="message" class="updated"><p>' . $msg . '</p></div>';
 118  } ?>
 119  <form method="post" action="site-info.php?action=update-site">
 120      <?php wp_nonce_field( 'edit-site' ); ?>
 121      <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
 122      <table class="form-table">
 123          <tr class="form-field form-required">
 124              <th scope="row"><?php _e( 'Domain' ) ?></th>
 125              <?php
 126              $protocol = is_ssl() ? 'https://' : 'http://';
 127              if ( $is_main_site ) { ?>
 128              <td><code><?php echo $protocol; echo esc_attr( $details->domain ) ?></code></td>
 129              <?php } else { ?>
 130              <td><?php echo $protocol; ?><input name="blog[domain]" type="text" id="domain" value="<?php echo esc_attr( $details->domain ) ?>" size="33" /></td>
 131              <?php } ?>
 132          </tr>
 133          <tr class="form-field form-required">
 134              <th scope="row"><?php _e( 'Path' ) ?></th>
 135              <?php if ( $is_main_site ) { ?>
 136              <td><code><?php echo esc_attr( $details->path ) ?></code></td>
 137              <?php
 138              } else {
 139                  switch_to_blog( $id );
 140              ?>
 141              <td><input name="blog[path]" type="text" id="path" value="<?php echo esc_attr( $details->path ) ?>" size="40" style='margin-bottom:5px;' />
 142              <br /><input type="checkbox" style="width:20px;" name="update_home_url" value="update" <?php if ( get_option( 'siteurl' ) == untrailingslashit( get_blogaddress_by_id ($id ) ) || get_option( 'home' ) == untrailingslashit( get_blogaddress_by_id( $id ) ) ) echo 'checked="checked"'; ?> /> <?php _e( 'Update <code>siteurl</code> and <code>home</code> as well.' ); ?></td>
 143              <?php
 144                  restore_current_blog();
 145              } ?>
 146          </tr>
 147          <tr class="form-field">
 148              <th scope="row"><?php _ex( 'Registered', 'site' ) ?></th>
 149              <td><input name="blog[registered]" type="text" id="blog_registered" value="<?php echo esc_attr( $details->registered ) ?>" size="40" /></td>
 150          </tr>
 151          <tr class="form-field">
 152              <th scope="row"><?php _e( 'Last Updated' ); ?></th>
 153              <td><input name="blog[last_updated]" type="text" id="blog_last_updated" value="<?php echo esc_attr( $details->last_updated ) ?>" size="40" /></td>
 154          </tr>
 155          <?php
 156          $attribute_fields = array( 'public' => __( 'Public' ) );
 157          if ( ! $is_main_site ) {
 158              $attribute_fields['archived'] = __( 'Archived' );
 159              $attribute_fields['spam']     = _x( 'Spam', 'site' );
 160              $attribute_fields['deleted']  = __( 'Deleted' );
 161          }
 162          $attribute_fields['mature'] = __( 'Mature' );
 163          ?>
 164          <tr>
 165              <th scope="row"><?php _e( 'Attributes' ); ?></th>
 166              <td>
 167              <?php foreach ( $attribute_fields as $field_key => $field_label ) : ?>
 168                  <label><input type="checkbox" name="blog[<?php echo $field_key; ?>]" value="1" <?php checked( (bool) $details->$field_key, true ); disabled( ! in_array( $details->$field_key, array( 0, 1 ) ) ); ?> />
 169                  <?php echo $field_label; ?></label><br/>
 170              <?php endforeach; ?>
 171              </td>
 172          </tr>
 173      </table>
 174      <?php submit_button(); ?>
 175  </form>
 176  
 177  </div>
 178  <?php
 179  require ( ABSPATH . 'wp-admin/admin-footer.php' );


Generated: Tue Mar 25 01:41:18 2014 WordPress honlapkészítés: online1.hu