/wp-admin/network/sites.php

https://bitbucket.org/aqge/deptandashboard · PHP · 314 lines · 256 code · 48 blank · 10 comment · 49 complexity · f854bc48bd8a8ae3ef3b5bab34abfbfe MD5 · raw file

  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_Screens" 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. switch ( $_GET['action'] ) {
  44. case 'updateblog':
  45. // No longer used.
  46. break;
  47. case 'deleteblog':
  48. check_admin_referer('deleteblog');
  49. if ( ! ( current_user_can( 'manage_sites' ) && current_user_can( 'delete_sites' ) ) )
  50. wp_die( __( 'You do not have permission to access this page.' ) );
  51. if ( $id != '0' && $id != $current_site->blog_id && current_user_can( 'delete_site', $id ) ) {
  52. wpmu_delete_blog( $id, true );
  53. wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'delete' ), wp_get_referer() ) );
  54. } else {
  55. wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'not_deleted' ), wp_get_referer() ) );
  56. }
  57. exit();
  58. break;
  59. case 'allblogs':
  60. if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allblogs'] ) ) {
  61. check_admin_referer( 'bulk-sites' );
  62. if ( ! current_user_can( 'manage_sites' ) )
  63. wp_die( __( 'You do not have permission to access this page.' ) );
  64. if ( $_GET['action'] != -1 || $_POST['action2'] != -1 )
  65. $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
  66. $blogfunction = '';
  67. foreach ( (array) $_POST['allblogs'] as $key => $val ) {
  68. if ( $val != '0' && $val != $current_site->blog_id ) {
  69. switch ( $doaction ) {
  70. case 'delete':
  71. if ( ! current_user_can( 'delete_site', $val ) )
  72. wp_die( __( 'You are not allowed to delete the site.' ) );
  73. $blogfunction = 'all_delete';
  74. wpmu_delete_blog( $val, true );
  75. break;
  76. case 'spam':
  77. $blogfunction = 'all_spam';
  78. update_blog_status( $val, 'spam', '1' );
  79. set_time_limit( 60 );
  80. break;
  81. case 'notspam':
  82. $blogfunction = 'all_notspam';
  83. update_blog_status( $val, 'spam', '0' );
  84. set_time_limit( 60 );
  85. break;
  86. }
  87. } else {
  88. wp_die( __( 'You are not allowed to change the current site.' ) );
  89. }
  90. }
  91. wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $blogfunction ), wp_get_referer() ) );
  92. } else {
  93. wp_redirect( network_admin_url( 'sites.php' ) );
  94. }
  95. exit();
  96. break;
  97. case 'archiveblog':
  98. check_admin_referer( 'archiveblog' );
  99. if ( ! current_user_can( 'manage_sites' ) )
  100. wp_die( __( 'You do not have permission to access this page.' ) );
  101. update_blog_status( $id, 'archived', '1' );
  102. wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'archive' ), wp_get_referer() ) );
  103. exit();
  104. break;
  105. case 'unarchiveblog':
  106. check_admin_referer( 'unarchiveblog' );
  107. if ( ! current_user_can( 'manage_sites' ) )
  108. wp_die( __( 'You do not have permission to access this page.' ) );
  109. update_blog_status( $id, 'archived', '0' );
  110. wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unarchive' ), wp_get_referer() ) );
  111. exit();
  112. break;
  113. case 'activateblog':
  114. check_admin_referer( 'activateblog' );
  115. if ( ! current_user_can( 'manage_sites' ) )
  116. wp_die( __( 'You do not have permission to access this page.' ) );
  117. update_blog_status( $id, 'deleted', '0' );
  118. do_action( 'activate_blog', $id );
  119. wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'activate' ), wp_get_referer() ) );
  120. exit();
  121. break;
  122. case 'deactivateblog':
  123. check_admin_referer( 'deactivateblog' );
  124. if ( ! current_user_can( 'manage_sites' ) )
  125. wp_die( __( 'You do not have permission to access this page.' ) );
  126. do_action( 'deactivate_blog', $id );
  127. update_blog_status( $id, 'deleted', '1' );
  128. wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'deactivate' ), wp_get_referer() ) );
  129. exit();
  130. break;
  131. case 'unspamblog':
  132. check_admin_referer( 'unspamblog' );
  133. if ( ! current_user_can( 'manage_sites' ) )
  134. wp_die( __( 'You do not have permission to access this page.' ) );
  135. update_blog_status( $id, 'spam', '0' );
  136. wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unspam' ), wp_get_referer() ) );
  137. exit();
  138. break;
  139. case 'spamblog':
  140. check_admin_referer( 'spamblog' );
  141. if ( ! current_user_can( 'manage_sites' ) )
  142. wp_die( __( 'You do not have permission to access this page.' ) );
  143. update_blog_status( $id, 'spam', '1' );
  144. wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'spam' ), wp_get_referer() ) );
  145. exit();
  146. break;
  147. case 'unmatureblog':
  148. check_admin_referer( 'unmatureblog' );
  149. if ( ! current_user_can( 'manage_sites' ) )
  150. wp_die( __( 'You do not have permission to access this page.' ) );
  151. update_blog_status( $id, 'mature', '0' );
  152. wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unmature' ), wp_get_referer() ) );
  153. exit();
  154. break;
  155. case 'matureblog':
  156. check_admin_referer( 'matureblog' );
  157. if ( ! current_user_can( 'manage_sites' ) )
  158. wp_die( __( 'You do not have permission to access this page.' ) );
  159. update_blog_status( $id, 'mature', '1' );
  160. wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'mature' ), wp_get_referer() ) );
  161. exit();
  162. break;
  163. // Common
  164. case 'confirm':
  165. check_admin_referer( 'confirm' );
  166. if ( !headers_sent() ) {
  167. nocache_headers();
  168. header( 'Content-Type: text/html; charset=utf-8' );
  169. }
  170. if ( $current_site->blog_id == $id )
  171. wp_die( __( 'You are not allowed to change the current site.' ) );
  172. ?>
  173. <!DOCTYPE html>
  174. <html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) ) language_attributes(); ?>>
  175. <head>
  176. <title><?php _e( 'WordPress &rsaquo; Confirm your action' ); ?></title>
  177. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  178. <?php
  179. wp_admin_css( 'install', true );
  180. wp_admin_css( 'ie', true );
  181. ?>
  182. </head>
  183. <body>
  184. <h1 id="logo"><img alt="WordPress" src="<?php echo esc_attr( admin_url( 'images/wordpress-logo.png' ) ); ?>" /></h1>
  185. <form action="sites.php?action=<?php echo esc_attr( $_GET['action2'] ) ?>" method="post">
  186. <input type="hidden" name="action" value="<?php echo esc_attr( $_GET['action2'] ) ?>" />
  187. <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
  188. <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" />
  189. <?php wp_nonce_field( $_GET['action2'], '_wpnonce', false ); ?>
  190. <p><?php echo esc_html( stripslashes( $_GET['msg'] ) ); ?></p>
  191. <?php submit_button( __('Confirm'), 'button' ); ?>
  192. </form>
  193. </body>
  194. </html>
  195. <?php
  196. exit();
  197. break;
  198. }
  199. }
  200. $msg = '';
  201. if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $_REQUEST['action'] ) ) {
  202. switch ( $_REQUEST['action'] ) {
  203. case 'all_notspam':
  204. $msg = __( 'Sites removed from spam.' );
  205. break;
  206. case 'all_spam':
  207. $msg = __( 'Sites marked as spam.' );
  208. break;
  209. case 'all_delete':
  210. $msg = __( 'Sites deleted.' );
  211. break;
  212. case 'delete':
  213. $msg = __( 'Site deleted.' );
  214. break;
  215. case 'not_deleted':
  216. $msg = __( 'You do not have permission to delete that site.' );
  217. break;
  218. case 'archive':
  219. $msg = __( 'Site archived.' );
  220. break;
  221. case 'unarchive':
  222. $msg = __( 'Site unarchived.' );
  223. break;
  224. case 'activate':
  225. $msg = __( 'Site activated.' );
  226. break;
  227. case 'deactivate':
  228. $msg = __( 'Site deactivated.' );
  229. break;
  230. case 'unspam':
  231. $msg = __( 'Site removed from spam.' );
  232. break;
  233. case 'spam':
  234. $msg = __( 'Site marked as spam.' );
  235. break;
  236. default:
  237. $msg = apply_filters( 'network_sites_updated_message_' . $_REQUEST['action'] , __( 'Settings saved.' ) );
  238. break;
  239. }
  240. if ( $msg )
  241. $msg = '<div class="updated" id="message"><p>' . $msg . '</p></div>';
  242. }
  243. $wp_list_table->prepare_items();
  244. require_once( '../admin-header.php' );
  245. ?>
  246. <div class="wrap">
  247. <?php screen_icon('ms-admin'); ?>
  248. <h2><?php _e('Sites') ?>
  249. <?php echo $msg; ?>
  250. <?php if ( current_user_can( 'create_sites') ) : ?>
  251. <a href="<?php echo network_admin_url('site-new.php'); ?>" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'site' ); ?></a>
  252. <?php endif; ?>
  253. <?php if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] ) {
  254. printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $s ) );
  255. } ?>
  256. </h2>
  257. <form action="" method="get" id="ms-search">
  258. <?php $wp_list_table->search_box( __( 'Search Sites' ), 'site' ); ?>
  259. <input type="hidden" name="action" value="blogs" />
  260. </form>
  261. <form id="form-site-list" action="sites.php?action=allblogs" method="post">
  262. <?php $wp_list_table->display(); ?>
  263. </form>
  264. </div>
  265. <?php
  266. require_once( '../admin-footer.php' ); ?>