PageRenderTime 38ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-admin/network/sites.php

https://bitbucket.org/julianelve/vendor-wordpress
PHP | 257 lines | 208 code | 41 blank | 8 comment | 37 complexity | b1b5731df54d956d132c4ac9f7337132 MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.1, GPL-2.0
  1. <?php
  2. /**
  3. * Multisite sites administration panel.
  4. *
  5. * @package WordPress
  6. * @subpackage Multisite
  7. * @since 3.0.0
  8. */
  9. /** Load WordPress Administration Bootstrap */
  10. require_once( './admin.php' );
  11. if ( ! is_multisite() )
  12. wp_die( __( 'Multisite support is not enabled.' ) );
  13. if ( ! current_user_can( 'manage_sites' ) )
  14. wp_die( __( 'You do not have permission to access this page.' ) );
  15. $wp_list_table = _get_list_table( 'WP_MS_Sites_List_Table' );
  16. $pagenum = $wp_list_table->get_pagenum();
  17. $title = __( 'Sites' );
  18. $parent_file = 'sites.php';
  19. add_screen_option( 'per_page', array( 'label' => _x( 'Sites', 'sites per page (screen options)' ) ) );
  20. get_current_screen()->add_help_tab( array(
  21. 'id' => 'overview',
  22. 'title' => __('Overview'),
  23. 'content' =>
  24. '<p>' . __('Add New takes you to the Add New Site screen. You can search for a site by Name, ID number, or IP address. Screen Options allows you to choose how many sites to display on one page.') . '</p>' .
  25. '<p>' . __('This is the main table of all sites on this network. Switch between list and excerpt views by using the icons above the right side of the table.') . '</p>' .
  26. '<p>' . __('Hovering over each site reveals seven options (three for the primary site):') . '</p>' .
  27. '<ul><li>' . __('An Edit link to a separate Edit Site screen.') . '</li>' .
  28. '<li>' . __('Dashboard leads to the Dashboard for that site.') . '</li>' .
  29. '<li>' . __('Deactivate, Archive, and Spam which lead to confirmation screens. These actions can be reversed later.') . '</li>' .
  30. '<li>' . __('Delete which is a permanent action after the confirmation screens.') . '</li>' .
  31. '<li>' . __('Visit to go to the frontend site live.') . '</li></ul>' .
  32. '<p>' . __('The site ID is used internally, and is not shown on the front end of the site or to users/viewers.') . '</p>' .
  33. '<p>' . __('Clicking on bold headings can re-sort this table.') . '</p>'
  34. ) );
  35. get_current_screen()->set_help_sidebar(
  36. '<p><strong>' . __('For more information:') . '</strong></p>' .
  37. '<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Sites_Screen" target="_blank">Documentation on Site Management</a>') . '</p>' .
  38. '<p>' . __('<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
  39. );
  40. $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
  41. if ( isset( $_GET['action'] ) ) {
  42. do_action( 'wpmuadminedit' , '' );
  43. if ( 'confirm' === $_GET['action'] ) {
  44. check_admin_referer( 'confirm' );
  45. if ( ! headers_sent() ) {
  46. nocache_headers();
  47. header( 'Content-Type: text/html; charset=utf-8' );
  48. }
  49. if ( $current_site->blog_id == $id )
  50. wp_die( __( 'You are not allowed to change the current site.' ) );
  51. ?>
  52. <!DOCTYPE html>
  53. <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
  54. <head>
  55. <title><?php _e( 'WordPress &rsaquo; Confirm your action' ); ?></title>
  56. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  57. <?php
  58. wp_admin_css( 'install', true );
  59. wp_admin_css( 'ie', true );
  60. ?>
  61. </head>
  62. <body class="wp-core-ui">
  63. <h1 id="logo"><a href="<?php esc_attr_e( 'http://wordpress.org/' ); ?>"><?php _e( 'WordPress' ); ?></a></h1>
  64. <form action="sites.php?action=<?php echo esc_attr( $_GET['action2'] ) ?>" method="post">
  65. <input type="hidden" name="action" value="<?php echo esc_attr( $_GET['action2'] ) ?>" />
  66. <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
  67. <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" />
  68. <?php wp_nonce_field( $_GET['action2'], '_wpnonce', false ); ?>
  69. <p><?php echo esc_html( stripslashes( $_GET['msg'] ) ); ?></p>
  70. <?php submit_button( __('Confirm'), 'button' ); ?>
  71. </form>
  72. </body>
  73. </html>
  74. <?php
  75. exit();
  76. }
  77. $updated_action = '';
  78. $manage_actions = array( 'deleteblog', 'allblogs', 'archiveblog', 'unarchiveblog', 'activateblog', 'deactivateblog', 'unspamblog', 'spamblog', 'unmatureblog', 'matureblog' );
  79. if ( in_array( $_GET['action'], $manage_actions ) ) {
  80. $action = $_GET['action'];
  81. if ( 'allblogs' === $action )
  82. $action = 'bulk-sites';
  83. check_admin_referer( $action );
  84. }
  85. switch ( $_GET['action'] ) {
  86. case 'deleteblog':
  87. if ( ! current_user_can( 'delete_sites' ) )
  88. wp_die( __( 'You do not have permission to access this page.' ) );
  89. $updated_action = 'not_deleted';
  90. if ( $id != '0' && $id != $current_site->blog_id && current_user_can( 'delete_site', $id ) ) {
  91. wpmu_delete_blog( $id, true );
  92. $updated_action = 'delete';
  93. }
  94. break;
  95. case 'allblogs':
  96. if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allblogs'] ) ) {
  97. $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
  98. foreach ( (array) $_POST['allblogs'] as $key => $val ) {
  99. if ( $val != '0' && $val != $current_site->blog_id ) {
  100. switch ( $doaction ) {
  101. case 'delete':
  102. if ( ! current_user_can( 'delete_site', $val ) )
  103. wp_die( __( 'You are not allowed to delete the site.' ) );
  104. $updated_action = 'all_delete';
  105. wpmu_delete_blog( $val, true );
  106. break;
  107. case 'spam':
  108. case 'notspam':
  109. $updated_action = ( 'spam' === $doaction ) ? 'all_spam' : 'all_notspam';
  110. update_blog_status( $val, 'spam', ( 'spam' === $doaction ) ? '1' : '0' );
  111. break;
  112. }
  113. } else {
  114. wp_die( __( 'You are not allowed to change the current site.' ) );
  115. }
  116. }
  117. } else {
  118. wp_redirect( network_admin_url( 'sites.php' ) );
  119. exit();
  120. }
  121. break;
  122. case 'archiveblog':
  123. case 'unarchiveblog':
  124. update_blog_status( $id, 'archived', ( 'archiveblog' === $_GET['action'] ) ? '1' : '0' );
  125. break;
  126. case 'activateblog':
  127. update_blog_status( $id, 'deleted', '0' );
  128. do_action( 'activate_blog', $id );
  129. break;
  130. case 'deactivateblog':
  131. do_action( 'deactivate_blog', $id );
  132. update_blog_status( $id, 'deleted', '1' );
  133. break;
  134. case 'unspamblog':
  135. case 'spamblog':
  136. update_blog_status( $id, 'spam', ( 'spamblog' === $_GET['action'] ) ? '1' : '0' );
  137. break;
  138. case 'unmatureblog':
  139. case 'matureblog':
  140. update_blog_status( $id, 'mature', ( 'matureblog' === $_GET['action'] ) ? '1' : '0' );
  141. break;
  142. }
  143. if ( empty( $updated_action ) && in_array( $_GET['action'], $manage_actions ) )
  144. $updated_action = $_GET['action'];
  145. if ( ! empty( $updated_action ) ) {
  146. wp_safe_redirect( add_query_arg( array( 'updated' => $updated_action ), wp_get_referer() ) );
  147. exit();
  148. }
  149. }
  150. $msg = '';
  151. if ( isset( $_GET['updated'] ) ) {
  152. switch ( $_GET['updated'] ) {
  153. case 'all_notspam':
  154. $msg = __( 'Sites removed from spam.' );
  155. break;
  156. case 'all_spam':
  157. $msg = __( 'Sites marked as spam.' );
  158. break;
  159. case 'all_delete':
  160. $msg = __( 'Sites deleted.' );
  161. break;
  162. case 'delete':
  163. $msg = __( 'Site deleted.' );
  164. break;
  165. case 'not_deleted':
  166. $msg = __( 'You do not have permission to delete that site.' );
  167. break;
  168. case 'archiveblog':
  169. $msg = __( 'Site archived.' );
  170. break;
  171. case 'unarchiveblog':
  172. $msg = __( 'Site unarchived.' );
  173. break;
  174. case 'activateblog':
  175. $msg = __( 'Site activated.' );
  176. break;
  177. case 'deactivateblog':
  178. $msg = __( 'Site deactivated.' );
  179. break;
  180. case 'unspamblog':
  181. $msg = __( 'Site removed from spam.' );
  182. break;
  183. case 'spamblog':
  184. $msg = __( 'Site marked as spam.' );
  185. break;
  186. default:
  187. $msg = apply_filters( 'network_sites_updated_message_' . $_GET['updated'], __( 'Settings saved.' ) );
  188. break;
  189. }
  190. if ( ! empty( $msg ) )
  191. $msg = '<div class="updated" id="message"><p>' . $msg . '</p></div>';
  192. }
  193. $wp_list_table->prepare_items();
  194. require_once( '../admin-header.php' );
  195. ?>
  196. <div class="wrap">
  197. <?php screen_icon( 'ms-admin' ); ?>
  198. <h2><?php _e( 'Sites' ) ?>
  199. <?php if ( current_user_can( 'create_sites') ) : ?>
  200. <a href="<?php echo network_admin_url('site-new.php'); ?>" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'site' ); ?></a>
  201. <?php endif; ?>
  202. <?php if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] ) {
  203. printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $s ) );
  204. } ?>
  205. </h2>
  206. <?php echo $msg; ?>
  207. <form action="" method="get" id="ms-search">
  208. <?php $wp_list_table->search_box( __( 'Search Sites' ), 'site' ); ?>
  209. <input type="hidden" name="action" value="blogs" />
  210. </form>
  211. <form id="form-site-list" action="sites.php?action=allblogs" method="post">
  212. <?php $wp_list_table->display(); ?>
  213. </form>
  214. </div>
  215. <?php
  216. require_once( '../admin-footer.php' ); ?>