PageRenderTime 46ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/wordpress3.4.2/wp-admin/network/sites.php

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