@@ -8,8 +8,8 @@ discard block |
||
8 | 8 | error_reporting(0); |
9 | 9 | |
10 | 10 | /** Set ABSPATH for execution */ |
11 | -define( 'ABSPATH', dirname(dirname(__FILE__)) . '/' ); |
|
12 | -define( 'WPINC', 'wp-includes' ); |
|
11 | +define('ABSPATH', dirname(dirname(__FILE__)).'/'); |
|
12 | +define('WPINC', 'wp-includes'); |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * @ignore |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | /** |
65 | 65 | * @ignore |
66 | 66 | */ |
67 | -function is_admin() {return true;} |
|
67 | +function is_admin() {return true; } |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * @ignore |
@@ -88,69 +88,69 @@ discard block |
||
88 | 88 | */ |
89 | 89 | function get_file($path) { |
90 | 90 | |
91 | - if ( function_exists('realpath') ) |
|
91 | + if (function_exists('realpath')) |
|
92 | 92 | $path = realpath($path); |
93 | 93 | |
94 | - if ( ! $path || ! @is_file($path) ) |
|
94 | + if ( ! $path || ! @is_file($path)) |
|
95 | 95 | return ''; |
96 | 96 | |
97 | 97 | return @file_get_contents($path); |
98 | 98 | } |
99 | 99 | |
100 | -require( ABSPATH . WPINC . '/script-loader.php' ); |
|
101 | -require( ABSPATH . WPINC . '/version.php' ); |
|
100 | +require(ABSPATH.WPINC.'/script-loader.php'); |
|
101 | +require(ABSPATH.WPINC.'/version.php'); |
|
102 | 102 | |
103 | -$load = preg_replace( '/[^a-z0-9,_-]+/i', '', $_GET['load'] ); |
|
104 | -$load = array_unique( explode( ',', $load ) ); |
|
103 | +$load = preg_replace('/[^a-z0-9,_-]+/i', '', $_GET['load']); |
|
104 | +$load = array_unique(explode(',', $load)); |
|
105 | 105 | |
106 | -if ( empty($load) ) |
|
106 | +if (empty($load)) |
|
107 | 107 | exit; |
108 | 108 | |
109 | -$compress = ( isset($_GET['c']) && $_GET['c'] ); |
|
110 | -$force_gzip = ( $compress && 'gzip' == $_GET['c'] ); |
|
111 | -$rtl = ( isset($_GET['dir']) && 'rtl' == $_GET['dir'] ); |
|
109 | +$compress = (isset($_GET['c']) && $_GET['c']); |
|
110 | +$force_gzip = ($compress && 'gzip' == $_GET['c']); |
|
111 | +$rtl = (isset($_GET['dir']) && 'rtl' == $_GET['dir']); |
|
112 | 112 | $expires_offset = 31536000; // 1 year |
113 | 113 | $out = ''; |
114 | 114 | |
115 | 115 | $wp_styles = new WP_Styles(); |
116 | 116 | wp_default_styles($wp_styles); |
117 | 117 | |
118 | -foreach( $load as $handle ) { |
|
119 | - if ( !array_key_exists($handle, $wp_styles->registered) ) |
|
118 | +foreach ($load as $handle) { |
|
119 | + if ( ! array_key_exists($handle, $wp_styles->registered)) |
|
120 | 120 | continue; |
121 | 121 | |
122 | 122 | $style = $wp_styles->registered[$handle]; |
123 | - $path = ABSPATH . $style->src; |
|
123 | + $path = ABSPATH.$style->src; |
|
124 | 124 | |
125 | - if ( $rtl && ! empty( $style->extra['rtl'] ) ) { |
|
125 | + if ($rtl && ! empty($style->extra['rtl'])) { |
|
126 | 126 | // All default styles have fully independent RTL files. |
127 | - $path = str_replace( '.min.css', '-rtl.min.css', $path ); |
|
127 | + $path = str_replace('.min.css', '-rtl.min.css', $path); |
|
128 | 128 | } |
129 | 129 | |
130 | - $content = get_file( $path ) . "\n"; |
|
130 | + $content = get_file($path)."\n"; |
|
131 | 131 | |
132 | - if ( strpos( $style->src, '/' . WPINC . '/css/' ) === 0 ) { |
|
133 | - $content = str_replace( '../images/', '../' . WPINC . '/images/', $content ); |
|
134 | - $content = str_replace( '../js/tinymce/', '../' . WPINC . '/js/tinymce/', $content ); |
|
135 | - $content = str_replace( '../fonts/', '../' . WPINC . '/fonts/', $content ); |
|
132 | + if (strpos($style->src, '/'.WPINC.'/css/') === 0) { |
|
133 | + $content = str_replace('../images/', '../'.WPINC.'/images/', $content); |
|
134 | + $content = str_replace('../js/tinymce/', '../'.WPINC.'/js/tinymce/', $content); |
|
135 | + $content = str_replace('../fonts/', '../'.WPINC.'/fonts/', $content); |
|
136 | 136 | $out .= $content; |
137 | 137 | } else { |
138 | - $out .= str_replace( '../images/', 'images/', $content ); |
|
138 | + $out .= str_replace('../images/', 'images/', $content); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
142 | 142 | header('Content-Type: text/css; charset=UTF-8'); |
143 | -header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT'); |
|
143 | +header('Expires: '.gmdate("D, d M Y H:i:s", time() + $expires_offset).' GMT'); |
|
144 | 144 | header("Cache-Control: public, max-age=$expires_offset"); |
145 | 145 | |
146 | -if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) { |
|
146 | +if ($compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING'])) { |
|
147 | 147 | header('Vary: Accept-Encoding'); // Handle proxies |
148 | - if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) { |
|
148 | + if (false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip) { |
|
149 | 149 | header('Content-Encoding: deflate'); |
150 | - $out = gzdeflate( $out, 3 ); |
|
151 | - } elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) { |
|
150 | + $out = gzdeflate($out, 3); |
|
151 | + } elseif (false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode')) { |
|
152 | 152 | header('Content-Encoding: gzip'); |
153 | - $out = gzencode( $out, 3 ); |
|
153 | + $out = gzencode($out, 3); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 |
@@ -88,11 +88,13 @@ discard block |
||
88 | 88 | */ |
89 | 89 | function get_file($path) { |
90 | 90 | |
91 | - if ( function_exists('realpath') ) |
|
92 | - $path = realpath($path); |
|
91 | + if ( function_exists('realpath') ) { |
|
92 | + $path = realpath($path); |
|
93 | + } |
|
93 | 94 | |
94 | - if ( ! $path || ! @is_file($path) ) |
|
95 | - return ''; |
|
95 | + if ( ! $path || ! @is_file($path) ) { |
|
96 | + return ''; |
|
97 | + } |
|
96 | 98 | |
97 | 99 | return @file_get_contents($path); |
98 | 100 | } |
@@ -103,8 +105,9 @@ discard block |
||
103 | 105 | $load = preg_replace( '/[^a-z0-9,_-]+/i', '', $_GET['load'] ); |
104 | 106 | $load = array_unique( explode( ',', $load ) ); |
105 | 107 | |
106 | -if ( empty($load) ) |
|
108 | +if ( empty($load) ) { |
|
107 | 109 | exit; |
110 | +} |
|
108 | 111 | |
109 | 112 | $compress = ( isset($_GET['c']) && $_GET['c'] ); |
110 | 113 | $force_gzip = ( $compress && 'gzip' == $_GET['c'] ); |
@@ -116,8 +119,9 @@ discard block |
||
116 | 119 | wp_default_styles($wp_styles); |
117 | 120 | |
118 | 121 | foreach( $load as $handle ) { |
119 | - if ( !array_key_exists($handle, $wp_styles->registered) ) |
|
120 | - continue; |
|
122 | + if ( !array_key_exists($handle, $wp_styles->registered) ) { |
|
123 | + continue; |
|
124 | + } |
|
121 | 125 | |
122 | 126 | $style = $wp_styles->registered[$handle]; |
123 | 127 | $path = ABSPATH . $style->src; |
@@ -6,67 +6,67 @@ discard block |
||
6 | 6 | * @subpackage Administration |
7 | 7 | */ |
8 | 8 | |
9 | -if ( isset( $_REQUEST['action'] ) && 'upload-attachment' === $_REQUEST['action'] ) { |
|
10 | - define( 'DOING_AJAX', true ); |
|
9 | +if (isset($_REQUEST['action']) && 'upload-attachment' === $_REQUEST['action']) { |
|
10 | + define('DOING_AJAX', true); |
|
11 | 11 | } |
12 | 12 | |
13 | -if ( ! defined( 'WP_ADMIN' ) ) { |
|
14 | - define( 'WP_ADMIN', true ); |
|
13 | +if ( ! defined('WP_ADMIN')) { |
|
14 | + define('WP_ADMIN', true); |
|
15 | 15 | } |
16 | 16 | |
17 | -if ( defined('ABSPATH') ) |
|
18 | - require_once(ABSPATH . 'wp-load.php'); |
|
17 | +if (defined('ABSPATH')) |
|
18 | + require_once(ABSPATH.'wp-load.php'); |
|
19 | 19 | else |
20 | - require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' ); |
|
20 | + require_once(dirname(dirname(__FILE__)).'/wp-load.php'); |
|
21 | 21 | |
22 | -if ( ! ( isset( $_REQUEST['action'] ) && 'upload-attachment' == $_REQUEST['action'] ) ) { |
|
22 | +if ( ! (isset($_REQUEST['action']) && 'upload-attachment' == $_REQUEST['action'])) { |
|
23 | 23 | // Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead |
24 | - if ( is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) ) |
|
24 | + if (is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && ! empty($_REQUEST['auth_cookie'])) |
|
25 | 25 | $_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie']; |
26 | - elseif ( empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) ) |
|
26 | + elseif (empty($_COOKIE[AUTH_COOKIE]) && ! empty($_REQUEST['auth_cookie'])) |
|
27 | 27 | $_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie']; |
28 | - if ( empty($_COOKIE[LOGGED_IN_COOKIE]) && !empty($_REQUEST['logged_in_cookie']) ) |
|
28 | + if (empty($_COOKIE[LOGGED_IN_COOKIE]) && ! empty($_REQUEST['logged_in_cookie'])) |
|
29 | 29 | $_COOKIE[LOGGED_IN_COOKIE] = $_REQUEST['logged_in_cookie']; |
30 | 30 | unset($current_user); |
31 | 31 | } |
32 | 32 | |
33 | -require_once( ABSPATH . 'wp-admin/admin.php' ); |
|
33 | +require_once(ABSPATH.'wp-admin/admin.php'); |
|
34 | 34 | |
35 | -header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
35 | +header('Content-Type: text/html; charset='.get_option('blog_charset')); |
|
36 | 36 | |
37 | -if ( isset( $_REQUEST['action'] ) && 'upload-attachment' === $_REQUEST['action'] ) { |
|
38 | - include( ABSPATH . 'wp-admin/includes/ajax-actions.php' ); |
|
37 | +if (isset($_REQUEST['action']) && 'upload-attachment' === $_REQUEST['action']) { |
|
38 | + include(ABSPATH.'wp-admin/includes/ajax-actions.php'); |
|
39 | 39 | |
40 | 40 | send_nosniff_header(); |
41 | 41 | nocache_headers(); |
42 | 42 | |
43 | 43 | wp_ajax_upload_attachment(); |
44 | - die( '0' ); |
|
44 | + die('0'); |
|
45 | 45 | } |
46 | 46 | |
47 | -if ( ! current_user_can( 'upload_files' ) ) { |
|
48 | - wp_die( __( 'You do not have permission to upload files.' ) ); |
|
47 | +if ( ! current_user_can('upload_files')) { |
|
48 | + wp_die(__('You do not have permission to upload files.')); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | // just fetch the detail form for that attachment |
52 | -if ( isset($_REQUEST['attachment_id']) && ($id = intval($_REQUEST['attachment_id'])) && $_REQUEST['fetch'] ) { |
|
53 | - $post = get_post( $id ); |
|
54 | - if ( 'attachment' != $post->post_type ) |
|
55 | - wp_die( __( 'Unknown post type.' ) ); |
|
56 | - if ( ! current_user_can( 'edit_post', $id ) ) |
|
57 | - wp_die( __( 'You are not allowed to edit this item.' ) ); |
|
58 | - |
|
59 | - switch ( $_REQUEST['fetch'] ) { |
|
52 | +if (isset($_REQUEST['attachment_id']) && ($id = intval($_REQUEST['attachment_id'])) && $_REQUEST['fetch']) { |
|
53 | + $post = get_post($id); |
|
54 | + if ('attachment' != $post->post_type) |
|
55 | + wp_die(__('Unknown post type.')); |
|
56 | + if ( ! current_user_can('edit_post', $id)) |
|
57 | + wp_die(__('You are not allowed to edit this item.')); |
|
58 | + |
|
59 | + switch ($_REQUEST['fetch']) { |
|
60 | 60 | case 3 : |
61 | - if ( $thumb_url = wp_get_attachment_image_src( $id, 'thumbnail', true ) ) |
|
62 | - echo '<img class="pinkynail" src="' . esc_url( $thumb_url[0] ) . '" alt="" />'; |
|
63 | - echo '<a class="edit-attachment" href="' . esc_url( get_edit_post_link( $id ) ) . '" target="_blank">' . _x( 'Edit', 'media item' ) . '</a>'; |
|
64 | - $title = $post->post_title ? $post->post_title : wp_basename( $post->guid ); // Title shouldn't ever be empty, but use filename just in case. |
|
65 | - echo '<div class="filename new"><span class="title">' . esc_html( wp_html_excerpt( $title, 60, '…' ) ) . '</span></div>'; |
|
61 | + if ($thumb_url = wp_get_attachment_image_src($id, 'thumbnail', true)) |
|
62 | + echo '<img class="pinkynail" src="'.esc_url($thumb_url[0]).'" alt="" />'; |
|
63 | + echo '<a class="edit-attachment" href="'.esc_url(get_edit_post_link($id)).'" target="_blank">'._x('Edit', 'media item').'</a>'; |
|
64 | + $title = $post->post_title ? $post->post_title : wp_basename($post->guid); // Title shouldn't ever be empty, but use filename just in case. |
|
65 | + echo '<div class="filename new"><span class="title">'.esc_html(wp_html_excerpt($title, 60, '…')).'</span></div>'; |
|
66 | 66 | break; |
67 | 67 | case 2 : |
68 | 68 | add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2); |
69 | - echo get_media_item($id, array( 'send' => false, 'delete' => true )); |
|
69 | + echo get_media_item($id, array('send' => false, 'delete' => true)); |
|
70 | 70 | break; |
71 | 71 | default: |
72 | 72 | add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); |
@@ -79,22 +79,22 @@ discard block |
||
79 | 79 | check_admin_referer('media-form'); |
80 | 80 | |
81 | 81 | $post_id = 0; |
82 | -if ( isset( $_REQUEST['post_id'] ) ) { |
|
83 | - $post_id = absint( $_REQUEST['post_id'] ); |
|
84 | - if ( ! get_post( $post_id ) || ! current_user_can( 'edit_post', $post_id ) ) |
|
82 | +if (isset($_REQUEST['post_id'])) { |
|
83 | + $post_id = absint($_REQUEST['post_id']); |
|
84 | + if ( ! get_post($post_id) || ! current_user_can('edit_post', $post_id)) |
|
85 | 85 | $post_id = 0; |
86 | 86 | } |
87 | 87 | |
88 | -$id = media_handle_upload( 'async-upload', $post_id ); |
|
89 | -if ( is_wp_error($id) ) { |
|
88 | +$id = media_handle_upload('async-upload', $post_id); |
|
89 | +if (is_wp_error($id)) { |
|
90 | 90 | echo '<div class="error-div error"> |
91 | - <a class="dismiss" href="#" onclick="jQuery(this).parents(\'div.media-item\').slideUp(200, function(){jQuery(this).remove();});">' . __('Dismiss') . '</a> |
|
92 | - <strong>' . sprintf(__('“%s” has failed to upload due to an error'), esc_html($_FILES['async-upload']['name']) ) . '</strong><br />' . |
|
93 | - esc_html($id->get_error_message()) . '</div>'; |
|
91 | + <a class="dismiss" href="#" onclick="jQuery(this).parents(\'div.media-item\').slideUp(200, function(){jQuery(this).remove();});">' . __('Dismiss').'</a> |
|
92 | + <strong>' . sprintf(__('“%s” has failed to upload due to an error'), esc_html($_FILES['async-upload']['name'])).'</strong><br />'. |
|
93 | + esc_html($id->get_error_message()).'</div>'; |
|
94 | 94 | exit; |
95 | 95 | } |
96 | 96 | |
97 | -if ( $_REQUEST['short'] ) { |
|
97 | +if ($_REQUEST['short']) { |
|
98 | 98 | // Short form response - attachment ID only. |
99 | 99 | echo $id; |
100 | 100 | } else { |
@@ -111,5 +111,5 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @param int $id Uploaded attachment ID. |
113 | 113 | */ |
114 | - echo apply_filters( "async_upload_{$type}", $id ); |
|
114 | + echo apply_filters("async_upload_{$type}", $id); |
|
115 | 115 | } |
@@ -14,19 +14,22 @@ discard block |
||
14 | 14 | define( 'WP_ADMIN', true ); |
15 | 15 | } |
16 | 16 | |
17 | -if ( defined('ABSPATH') ) |
|
17 | +if ( defined('ABSPATH') ) { |
|
18 | 18 | require_once(ABSPATH . 'wp-load.php'); |
19 | -else |
|
19 | +} else { |
|
20 | 20 | require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' ); |
21 | +} |
|
21 | 22 | |
22 | 23 | if ( ! ( isset( $_REQUEST['action'] ) && 'upload-attachment' == $_REQUEST['action'] ) ) { |
23 | 24 | // Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead |
24 | - if ( is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) ) |
|
25 | - $_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie']; |
|
26 | - elseif ( empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) ) |
|
27 | - $_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie']; |
|
28 | - if ( empty($_COOKIE[LOGGED_IN_COOKIE]) && !empty($_REQUEST['logged_in_cookie']) ) |
|
29 | - $_COOKIE[LOGGED_IN_COOKIE] = $_REQUEST['logged_in_cookie']; |
|
25 | + if ( is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) ) { |
|
26 | + $_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie']; |
|
27 | + } elseif ( empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) ) { |
|
28 | + $_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie']; |
|
29 | + } |
|
30 | + if ( empty($_COOKIE[LOGGED_IN_COOKIE]) && !empty($_REQUEST['logged_in_cookie']) ) { |
|
31 | + $_COOKIE[LOGGED_IN_COOKIE] = $_REQUEST['logged_in_cookie']; |
|
32 | + } |
|
30 | 33 | unset($current_user); |
31 | 34 | } |
32 | 35 | |
@@ -51,15 +54,18 @@ discard block |
||
51 | 54 | // just fetch the detail form for that attachment |
52 | 55 | if ( isset($_REQUEST['attachment_id']) && ($id = intval($_REQUEST['attachment_id'])) && $_REQUEST['fetch'] ) { |
53 | 56 | $post = get_post( $id ); |
54 | - if ( 'attachment' != $post->post_type ) |
|
55 | - wp_die( __( 'Unknown post type.' ) ); |
|
56 | - if ( ! current_user_can( 'edit_post', $id ) ) |
|
57 | - wp_die( __( 'You are not allowed to edit this item.' ) ); |
|
57 | + if ( 'attachment' != $post->post_type ) { |
|
58 | + wp_die( __( 'Unknown post type.' ) ); |
|
59 | + } |
|
60 | + if ( ! current_user_can( 'edit_post', $id ) ) { |
|
61 | + wp_die( __( 'You are not allowed to edit this item.' ) ); |
|
62 | + } |
|
58 | 63 | |
59 | 64 | switch ( $_REQUEST['fetch'] ) { |
60 | 65 | case 3 : |
61 | - if ( $thumb_url = wp_get_attachment_image_src( $id, 'thumbnail', true ) ) |
|
62 | - echo '<img class="pinkynail" src="' . esc_url( $thumb_url[0] ) . '" alt="" />'; |
|
66 | + if ( $thumb_url = wp_get_attachment_image_src( $id, 'thumbnail', true ) ) { |
|
67 | + echo '<img class="pinkynail" src="' . esc_url( $thumb_url[0] ) . '" alt="" />'; |
|
68 | + } |
|
63 | 69 | echo '<a class="edit-attachment" href="' . esc_url( get_edit_post_link( $id ) ) . '" target="_blank">' . _x( 'Edit', 'media item' ) . '</a>'; |
64 | 70 | $title = $post->post_title ? $post->post_title : wp_basename( $post->guid ); // Title shouldn't ever be empty, but use filename just in case. |
65 | 71 | echo '<div class="filename new"><span class="title">' . esc_html( wp_html_excerpt( $title, 60, '…' ) ) . '</span></div>'; |
@@ -81,9 +87,10 @@ discard block |
||
81 | 87 | $post_id = 0; |
82 | 88 | if ( isset( $_REQUEST['post_id'] ) ) { |
83 | 89 | $post_id = absint( $_REQUEST['post_id'] ); |
84 | - if ( ! get_post( $post_id ) || ! current_user_can( 'edit_post', $post_id ) ) |
|
85 | - $post_id = 0; |
|
86 | -} |
|
90 | + if ( ! get_post( $post_id ) || ! current_user_can( 'edit_post', $post_id ) ) { |
|
91 | + $post_id = 0; |
|
92 | + } |
|
93 | + } |
|
87 | 94 | |
88 | 95 | $id = media_handle_upload( 'async-upload', $post_id ); |
89 | 96 | if ( is_wp_error($id) ) { |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Media settings administration panel. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - */ |
|
3 | + * Media settings administration panel. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** WordPress Administration Bootstrap */ |
10 | 10 | require_once( dirname( __FILE__ ) . '/admin.php' ); |
@@ -7,46 +7,46 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | /** WordPress Administration Bootstrap */ |
10 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
10 | +require_once(dirname(__FILE__).'/admin.php'); |
|
11 | 11 | |
12 | -if ( ! current_user_can( 'manage_options' ) ) |
|
13 | - wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) ); |
|
12 | +if ( ! current_user_can('manage_options')) |
|
13 | + wp_die(__('You do not have sufficient permissions to manage options for this site.')); |
|
14 | 14 | |
15 | 15 | $title = __('Media Settings'); |
16 | 16 | $parent_file = 'options-general.php'; |
17 | 17 | |
18 | -$media_options_help = '<p>' . __('You can set maximum sizes for images inserted into your written content; you can also insert an image as Full Size.') . '</p>'; |
|
18 | +$media_options_help = '<p>'.__('You can set maximum sizes for images inserted into your written content; you can also insert an image as Full Size.').'</p>'; |
|
19 | 19 | |
20 | -if ( ! is_multisite() && ( get_option('upload_url_path') || ( get_option('upload_path') != 'wp-content/uploads' && get_option('upload_path') ) ) ) { |
|
21 | - $media_options_help .= '<p>' . __('Uploading Files allows you to choose the folder and path for storing your uploaded files.') . '</p>'; |
|
20 | +if ( ! is_multisite() && (get_option('upload_url_path') || (get_option('upload_path') != 'wp-content/uploads' && get_option('upload_path')))) { |
|
21 | + $media_options_help .= '<p>'.__('Uploading Files allows you to choose the folder and path for storing your uploaded files.').'</p>'; |
|
22 | 22 | } |
23 | 23 | |
24 | -$media_options_help .= '<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>'; |
|
24 | +$media_options_help .= '<p>'.__('You must click the Save Changes button at the bottom of the screen for new settings to take effect.').'</p>'; |
|
25 | 25 | |
26 | -get_current_screen()->add_help_tab( array( |
|
26 | +get_current_screen()->add_help_tab(array( |
|
27 | 27 | 'id' => 'overview', |
28 | 28 | 'title' => __('Overview'), |
29 | 29 | 'content' => $media_options_help, |
30 | -) ); |
|
30 | +)); |
|
31 | 31 | |
32 | 32 | get_current_screen()->set_help_sidebar( |
33 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
34 | - '<p>' . __('<a href="https://codex.wordpress.org/Settings_Media_Screen" target="_blank">Documentation on Media Settings</a>') . '</p>' . |
|
35 | - '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
|
33 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
34 | + '<p>'.__('<a href="https://codex.wordpress.org/Settings_Media_Screen" target="_blank">Documentation on Media Settings</a>').'</p>'. |
|
35 | + '<p>'.__('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>').'</p>' |
|
36 | 36 | ); |
37 | 37 | |
38 | -include( ABSPATH . 'wp-admin/admin-header.php' ); |
|
38 | +include(ABSPATH.'wp-admin/admin-header.php'); |
|
39 | 39 | |
40 | 40 | ?> |
41 | 41 | |
42 | 42 | <div class="wrap"> |
43 | -<h1><?php echo esc_html( $title ); ?></h1> |
|
43 | +<h1><?php echo esc_html($title); ?></h1> |
|
44 | 44 | |
45 | 45 | <form action="options.php" method="post"> |
46 | 46 | <?php settings_fields('media'); ?> |
47 | 47 | |
48 | 48 | <h3 class="title"><?php _e('Image sizes') ?></h3> |
49 | -<p><?php _e( 'The sizes listed below determine the maximum dimensions in pixels to use when adding an image to the Media Library.' ); ?></p> |
|
49 | +<p><?php _e('The sizes listed below determine the maximum dimensions in pixels to use when adding an image to the Media Library.'); ?></p> |
|
50 | 50 | |
51 | 51 | <table class="form-table"> |
52 | 52 | <tr> |
@@ -88,19 +88,19 @@ discard block |
||
88 | 88 | /** |
89 | 89 | * @global array $wp_settings |
90 | 90 | */ |
91 | -if ( isset( $GLOBALS['wp_settings']['media']['embeds'] ) ) : ?> |
|
91 | +if (isset($GLOBALS['wp_settings']['media']['embeds'])) : ?> |
|
92 | 92 | <h3 class="title"><?php _e('Embeds') ?></h3> |
93 | 93 | <table class="form-table"> |
94 | -<?php do_settings_fields( 'media', 'embeds' ); ?> |
|
94 | +<?php do_settings_fields('media', 'embeds'); ?> |
|
95 | 95 | </table> |
96 | 96 | <?php endif; ?> |
97 | 97 | |
98 | -<?php if ( !is_multisite() ) : ?> |
|
98 | +<?php if ( ! is_multisite()) : ?> |
|
99 | 99 | <h3 class="title"><?php _e('Uploading Files'); ?></h3> |
100 | 100 | <table class="form-table"> |
101 | 101 | <?php |
102 | 102 | // If upload_url_path is not the default (empty), and upload_path is not the default ('wp-content/uploads' or empty) |
103 | -if ( get_option('upload_url_path') || ( get_option('upload_path') != 'wp-content/uploads' && get_option('upload_path') ) ) : |
|
103 | +if (get_option('upload_url_path') || (get_option('upload_path') != 'wp-content/uploads' && get_option('upload_path'))) : |
|
104 | 104 | ?> |
105 | 105 | <tr> |
106 | 106 | <th scope="row"><label for="upload_path"><?php _e('Store uploads in this folder'); ?></label></th> |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | |
112 | 112 | <tr> |
113 | 113 | <th scope="row"><label for="upload_url_path"><?php _e('Full URL path to files'); ?></label></th> |
114 | -<td><input name="upload_url_path" type="text" id="upload_url_path" value="<?php echo esc_attr( get_option('upload_url_path')); ?>" class="regular-text code" /> |
|
114 | +<td><input name="upload_url_path" type="text" id="upload_url_path" value="<?php echo esc_attr(get_option('upload_url_path')); ?>" class="regular-text code" /> |
|
115 | 115 | <p class="description"><?php _e('Configuring this is optional. By default, it should be blank.'); ?></p> |
116 | 116 | </td> |
117 | 117 | </tr> |
@@ -137,4 +137,4 @@ discard block |
||
137 | 137 | |
138 | 138 | </div> |
139 | 139 | |
140 | -<?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?> |
|
140 | +<?php include(ABSPATH.'wp-admin/admin-footer.php'); ?> |
@@ -9,8 +9,9 @@ |
||
9 | 9 | /** WordPress Administration Bootstrap */ |
10 | 10 | require_once( dirname( __FILE__ ) . '/admin.php' ); |
11 | 11 | |
12 | -if ( ! current_user_can( 'manage_options' ) ) |
|
12 | +if ( ! current_user_can( 'manage_options' ) ) { |
|
13 | 13 | wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) ); |
14 | +} |
|
14 | 15 | |
15 | 16 | $title = __('Media Settings'); |
16 | 17 | $parent_file = 'options-general.php'; |
@@ -10,64 +10,64 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | /** Load WordPress Administration Bootstrap */ |
13 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
13 | +require_once(dirname(__FILE__).'/admin.php'); |
|
14 | 14 | |
15 | -if (!current_user_can('upload_files')) |
|
15 | +if ( ! current_user_can('upload_files')) |
|
16 | 16 | wp_die(__('You do not have permission to upload files.')); |
17 | 17 | |
18 | 18 | wp_enqueue_script('plupload-handlers'); |
19 | 19 | |
20 | 20 | $post_id = 0; |
21 | -if ( isset( $_REQUEST['post_id'] ) ) { |
|
22 | - $post_id = absint( $_REQUEST['post_id'] ); |
|
23 | - if ( ! get_post( $post_id ) || ! current_user_can( 'edit_post', $post_id ) ) |
|
21 | +if (isset($_REQUEST['post_id'])) { |
|
22 | + $post_id = absint($_REQUEST['post_id']); |
|
23 | + if ( ! get_post($post_id) || ! current_user_can('edit_post', $post_id)) |
|
24 | 24 | $post_id = 0; |
25 | 25 | } |
26 | 26 | |
27 | -if ( $_POST ) { |
|
27 | +if ($_POST) { |
|
28 | 28 | $location = 'upload.php'; |
29 | - if ( isset($_POST['html-upload']) && !empty($_FILES) ) { |
|
29 | + if (isset($_POST['html-upload']) && ! empty($_FILES)) { |
|
30 | 30 | check_admin_referer('media-form'); |
31 | 31 | // Upload File button was clicked |
32 | - $id = media_handle_upload( 'async-upload', $post_id ); |
|
33 | - if ( is_wp_error( $id ) ) |
|
32 | + $id = media_handle_upload('async-upload', $post_id); |
|
33 | + if (is_wp_error($id)) |
|
34 | 34 | $location .= '?message=3'; |
35 | 35 | } |
36 | - wp_redirect( admin_url( $location ) ); |
|
36 | + wp_redirect(admin_url($location)); |
|
37 | 37 | exit; |
38 | 38 | } |
39 | 39 | |
40 | 40 | $title = __('Upload New Media'); |
41 | 41 | $parent_file = 'upload.php'; |
42 | 42 | |
43 | -get_current_screen()->add_help_tab( array( |
|
43 | +get_current_screen()->add_help_tab(array( |
|
44 | 44 | 'id' => 'overview', |
45 | 45 | 'title' => __('Overview'), |
46 | 46 | 'content' => |
47 | - '<p>' . __('You can upload media files here without creating a post first. This allows you to upload files to use with posts and pages later and/or to get a web link for a particular file that you can share. There are three options for uploading files:') . '</p>' . |
|
48 | - '<ul>' . |
|
49 | - '<li>' . __('<strong>Drag and drop</strong> your files into the area below. Multiple files are allowed.') . '</li>' . |
|
50 | - '<li>' . __('Clicking <strong>Select Files</strong> opens a navigation window showing you files in your operating system. Selecting <strong>Open</strong> after clicking on the file you want activates a progress bar on the uploader screen.') . '</li>' . |
|
51 | - '<li>' . __('Revert to the <strong>Browser Uploader</strong> by clicking the link below the drag and drop box.') . '</li>' . |
|
47 | + '<p>'.__('You can upload media files here without creating a post first. This allows you to upload files to use with posts and pages later and/or to get a web link for a particular file that you can share. There are three options for uploading files:').'</p>'. |
|
48 | + '<ul>'. |
|
49 | + '<li>'.__('<strong>Drag and drop</strong> your files into the area below. Multiple files are allowed.').'</li>'. |
|
50 | + '<li>'.__('Clicking <strong>Select Files</strong> opens a navigation window showing you files in your operating system. Selecting <strong>Open</strong> after clicking on the file you want activates a progress bar on the uploader screen.').'</li>'. |
|
51 | + '<li>'.__('Revert to the <strong>Browser Uploader</strong> by clicking the link below the drag and drop box.').'</li>'. |
|
52 | 52 | '</ul>' |
53 | -) ); |
|
53 | +)); |
|
54 | 54 | get_current_screen()->set_help_sidebar( |
55 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
56 | - '<p>' . __('<a href="https://codex.wordpress.org/Media_Add_New_Screen" target="_blank">Documentation on Uploading Media Files</a>') . '</p>' . |
|
57 | - '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
|
55 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
56 | + '<p>'.__('<a href="https://codex.wordpress.org/Media_Add_New_Screen" target="_blank">Documentation on Uploading Media Files</a>').'</p>'. |
|
57 | + '<p>'.__('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>').'</p>' |
|
58 | 58 | ); |
59 | 59 | |
60 | -require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
60 | +require_once(ABSPATH.'wp-admin/admin-header.php'); |
|
61 | 61 | |
62 | 62 | $form_class = 'media-upload-form type-form validate'; |
63 | 63 | |
64 | -if ( get_user_setting('uploader') || isset( $_GET['browser-uploader'] ) ) |
|
64 | +if (get_user_setting('uploader') || isset($_GET['browser-uploader'])) |
|
65 | 65 | $form_class .= ' html-uploader'; |
66 | 66 | ?> |
67 | 67 | <div class="wrap"> |
68 | - <h1><?php echo esc_html( $title ); ?></h1> |
|
68 | + <h1><?php echo esc_html($title); ?></h1> |
|
69 | 69 | |
70 | - <form enctype="multipart/form-data" method="post" action="<?php echo admin_url('media-new.php'); ?>" class="<?php echo esc_attr( $form_class ); ?>" id="file-form"> |
|
70 | + <form enctype="multipart/form-data" method="post" action="<?php echo admin_url('media-new.php'); ?>" class="<?php echo esc_attr($form_class); ?>" id="file-form"> |
|
71 | 71 | |
72 | 72 | <?php media_upload_form(); ?> |
73 | 73 | |
@@ -81,4 +81,4 @@ discard block |
||
81 | 81 | </div> |
82 | 82 | |
83 | 83 | <?php |
84 | -include( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
84 | +include(ABSPATH.'wp-admin/admin-footer.php'); |
@@ -12,17 +12,19 @@ discard block |
||
12 | 12 | /** Load WordPress Administration Bootstrap */ |
13 | 13 | require_once( dirname( __FILE__ ) . '/admin.php' ); |
14 | 14 | |
15 | -if (!current_user_can('upload_files')) |
|
15 | +if (!current_user_can('upload_files')) { |
|
16 | 16 | wp_die(__('You do not have permission to upload files.')); |
17 | +} |
|
17 | 18 | |
18 | 19 | wp_enqueue_script('plupload-handlers'); |
19 | 20 | |
20 | 21 | $post_id = 0; |
21 | 22 | if ( isset( $_REQUEST['post_id'] ) ) { |
22 | 23 | $post_id = absint( $_REQUEST['post_id'] ); |
23 | - if ( ! get_post( $post_id ) || ! current_user_can( 'edit_post', $post_id ) ) |
|
24 | - $post_id = 0; |
|
25 | -} |
|
24 | + if ( ! get_post( $post_id ) || ! current_user_can( 'edit_post', $post_id ) ) { |
|
25 | + $post_id = 0; |
|
26 | + } |
|
27 | + } |
|
26 | 28 | |
27 | 29 | if ( $_POST ) { |
28 | 30 | $location = 'upload.php'; |
@@ -30,8 +32,9 @@ discard block |
||
30 | 32 | check_admin_referer('media-form'); |
31 | 33 | // Upload File button was clicked |
32 | 34 | $id = media_handle_upload( 'async-upload', $post_id ); |
33 | - if ( is_wp_error( $id ) ) |
|
34 | - $location .= '?message=3'; |
|
35 | + if ( is_wp_error( $id ) ) { |
|
36 | + $location .= '?message=3'; |
|
37 | + } |
|
35 | 38 | } |
36 | 39 | wp_redirect( admin_url( $location ) ); |
37 | 40 | exit; |
@@ -61,8 +64,9 @@ discard block |
||
61 | 64 | |
62 | 65 | $form_class = 'media-upload-form type-form validate'; |
63 | 66 | |
64 | -if ( get_user_setting('uploader') || isset( $_GET['browser-uploader'] ) ) |
|
67 | +if ( get_user_setting('uploader') || isset( $_GET['browser-uploader'] ) ) { |
|
65 | 68 | $form_class .= ' html-uploader'; |
69 | +} |
|
66 | 70 | ?> |
67 | 71 | <div class="wrap"> |
68 | 72 | <h1><?php echo esc_html( $title ); ?></h1> |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Users administration panel. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - */ |
|
3 | + * Users administration panel. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** WordPress Administration Bootstrap */ |
10 | 10 | require_once( dirname( __FILE__ ) . '/admin.php' ); |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | unset( $help ); |
58 | 58 | |
59 | 59 | get_current_screen()->set_help_sidebar( |
60 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
61 | - '<p>' . __('<a href="https://codex.wordpress.org/Users_Screen" target="_blank">Documentation on Managing Users</a>') . '</p>' . |
|
62 | - '<p>' . __('<a href="https://codex.wordpress.org/Roles_and_Capabilities" target="_blank">Descriptions of Roles and Capabilities</a>') . '</p>' . |
|
63 | - '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
|
60 | + '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
61 | + '<p>' . __('<a href="https://codex.wordpress.org/Users_Screen" target="_blank">Documentation on Managing Users</a>') . '</p>' . |
|
62 | + '<p>' . __('<a href="https://codex.wordpress.org/Roles_and_Capabilities" target="_blank">Descriptions of Roles and Capabilities</a>') . '</p>' . |
|
63 | + '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
|
64 | 64 | ); |
65 | 65 | |
66 | 66 | if ( empty($_REQUEST) ) { |
@@ -97,88 +97,88 @@ discard block |
||
97 | 97 | switch ( $wp_list_table->current_action() ) { |
98 | 98 | |
99 | 99 | /* Bulk Dropdown menu Role changes */ |
100 | -case 'promote': |
|
101 | - check_admin_referer('bulk-users'); |
|
100 | + case 'promote': |
|
101 | + check_admin_referer('bulk-users'); |
|
102 | 102 | |
103 | - if ( ! current_user_can( 'promote_users' ) ) |
|
104 | - wp_die( __( 'You can’t edit that user.' ) ); |
|
103 | + if ( ! current_user_can( 'promote_users' ) ) |
|
104 | + wp_die( __( 'You can’t edit that user.' ) ); |
|
105 | 105 | |
106 | - if ( empty($_REQUEST['users']) ) { |
|
107 | - wp_redirect($redirect); |
|
108 | - exit(); |
|
109 | - } |
|
110 | - |
|
111 | - $editable_roles = get_editable_roles(); |
|
112 | - if ( empty( $editable_roles[$_REQUEST['new_role']] ) ) |
|
113 | - wp_die(__('You can’t give users that role.')); |
|
114 | - |
|
115 | - $userids = $_REQUEST['users']; |
|
116 | - $update = 'promote'; |
|
117 | - foreach ( $userids as $id ) { |
|
118 | - $id = (int) $id; |
|
119 | - |
|
120 | - if ( ! current_user_can('promote_user', $id) ) |
|
121 | - wp_die(__('You can’t edit that user.')); |
|
122 | - // The new role of the current user must also have the promote_users cap or be a multisite super admin |
|
123 | - if ( $id == $current_user->ID && ! $wp_roles->role_objects[ $_REQUEST['new_role'] ]->has_cap('promote_users') |
|
124 | - && ! ( is_multisite() && is_super_admin() ) ) { |
|
125 | - $update = 'err_admin_role'; |
|
126 | - continue; |
|
106 | + if ( empty($_REQUEST['users']) ) { |
|
107 | + wp_redirect($redirect); |
|
108 | + exit(); |
|
127 | 109 | } |
128 | 110 | |
129 | - // If the user doesn't already belong to the blog, bail. |
|
130 | - if ( is_multisite() && !is_user_member_of_blog( $id ) ) |
|
131 | - wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
132 | - |
|
133 | - $user = get_userdata( $id ); |
|
134 | - $user->set_role($_REQUEST['new_role']); |
|
135 | - } |
|
111 | + $editable_roles = get_editable_roles(); |
|
112 | + if ( empty( $editable_roles[$_REQUEST['new_role']] ) ) |
|
113 | + wp_die(__('You can’t give users that role.')); |
|
136 | 114 | |
137 | - wp_redirect(add_query_arg('update', $update, $redirect)); |
|
138 | - exit(); |
|
115 | + $userids = $_REQUEST['users']; |
|
116 | + $update = 'promote'; |
|
117 | + foreach ( $userids as $id ) { |
|
118 | + $id = (int) $id; |
|
119 | + |
|
120 | + if ( ! current_user_can('promote_user', $id) ) |
|
121 | + wp_die(__('You can’t edit that user.')); |
|
122 | + // The new role of the current user must also have the promote_users cap or be a multisite super admin |
|
123 | + if ( $id == $current_user->ID && ! $wp_roles->role_objects[ $_REQUEST['new_role'] ]->has_cap('promote_users') |
|
124 | + && ! ( is_multisite() && is_super_admin() ) ) { |
|
125 | + $update = 'err_admin_role'; |
|
126 | + continue; |
|
127 | + } |
|
139 | 128 | |
140 | -case 'dodelete': |
|
141 | - if ( is_multisite() ) |
|
142 | - wp_die( __('User deletion is not allowed from this screen.') ); |
|
129 | + // If the user doesn't already belong to the blog, bail. |
|
130 | + if ( is_multisite() && !is_user_member_of_blog( $id ) ) |
|
131 | + wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
143 | 132 | |
144 | - check_admin_referer('delete-users'); |
|
133 | + $user = get_userdata( $id ); |
|
134 | + $user->set_role($_REQUEST['new_role']); |
|
135 | + } |
|
145 | 136 | |
146 | - if ( empty($_REQUEST['users']) ) { |
|
147 | - wp_redirect($redirect); |
|
137 | + wp_redirect(add_query_arg('update', $update, $redirect)); |
|
148 | 138 | exit(); |
149 | - } |
|
150 | - |
|
151 | - $userids = array_map( 'intval', (array) $_REQUEST['users'] ); |
|
152 | 139 | |
153 | - if ( empty( $_REQUEST['delete_option'] ) ) { |
|
154 | - $url = self_admin_url( 'users.php?action=delete&users[]=' . implode( '&users[]=', $userids ) . '&error=true' ); |
|
155 | - $url = str_replace( '&', '&', wp_nonce_url( $url, 'bulk-users' ) ); |
|
156 | - wp_redirect( $url ); |
|
157 | - exit; |
|
158 | - } |
|
140 | + case 'dodelete': |
|
141 | + if ( is_multisite() ) |
|
142 | + wp_die( __('User deletion is not allowed from this screen.') ); |
|
159 | 143 | |
160 | - if ( ! current_user_can( 'delete_users' ) ) |
|
161 | - wp_die(__('You can’t delete users.')); |
|
144 | + check_admin_referer('delete-users'); |
|
162 | 145 | |
163 | - $update = 'del'; |
|
164 | - $delete_count = 0; |
|
146 | + if ( empty($_REQUEST['users']) ) { |
|
147 | + wp_redirect($redirect); |
|
148 | + exit(); |
|
149 | + } |
|
165 | 150 | |
166 | - foreach ( $userids as $id ) { |
|
167 | - if ( ! current_user_can( 'delete_user', $id ) ) |
|
168 | - wp_die(__( 'You can’t delete that user.' ) ); |
|
151 | + $userids = array_map( 'intval', (array) $_REQUEST['users'] ); |
|
169 | 152 | |
170 | - if ( $id == $current_user->ID ) { |
|
171 | - $update = 'err_admin_del'; |
|
172 | - continue; |
|
173 | - } |
|
174 | - switch ( $_REQUEST['delete_option'] ) { |
|
175 | - case 'delete': |
|
176 | - wp_delete_user( $id ); |
|
177 | - break; |
|
178 | - case 'reassign': |
|
179 | - wp_delete_user( $id, $_REQUEST['reassign_user'] ); |
|
180 | - break; |
|
153 | + if ( empty( $_REQUEST['delete_option'] ) ) { |
|
154 | + $url = self_admin_url( 'users.php?action=delete&users[]=' . implode( '&users[]=', $userids ) . '&error=true' ); |
|
155 | + $url = str_replace( '&', '&', wp_nonce_url( $url, 'bulk-users' ) ); |
|
156 | + wp_redirect( $url ); |
|
157 | + exit; |
|
181 | 158 | } |
159 | + |
|
160 | + if ( ! current_user_can( 'delete_users' ) ) |
|
161 | + wp_die(__('You can’t delete users.')); |
|
162 | + |
|
163 | + $update = 'del'; |
|
164 | + $delete_count = 0; |
|
165 | + |
|
166 | + foreach ( $userids as $id ) { |
|
167 | + if ( ! current_user_can( 'delete_user', $id ) ) |
|
168 | + wp_die(__( 'You can’t delete that user.' ) ); |
|
169 | + |
|
170 | + if ( $id == $current_user->ID ) { |
|
171 | + $update = 'err_admin_del'; |
|
172 | + continue; |
|
173 | + } |
|
174 | + switch ( $_REQUEST['delete_option'] ) { |
|
175 | + case 'delete': |
|
176 | + wp_delete_user( $id ); |
|
177 | + break; |
|
178 | + case 'reassign': |
|
179 | + wp_delete_user( $id, $_REQUEST['reassign_user'] ); |
|
180 | + break; |
|
181 | + } |
|
182 | 182 | ++$delete_count; |
183 | 183 | } |
184 | 184 | |
@@ -186,250 +186,250 @@ discard block |
||
186 | 186 | wp_redirect($redirect); |
187 | 187 | exit(); |
188 | 188 | |
189 | -case 'delete': |
|
190 | - if ( is_multisite() ) |
|
191 | - wp_die( __('User deletion is not allowed from this screen.') ); |
|
189 | + case 'delete': |
|
190 | + if ( is_multisite() ) |
|
191 | + wp_die( __('User deletion is not allowed from this screen.') ); |
|
192 | 192 | |
193 | - check_admin_referer('bulk-users'); |
|
193 | + check_admin_referer('bulk-users'); |
|
194 | 194 | |
195 | - if ( empty($_REQUEST['users']) && empty($_REQUEST['user']) ) { |
|
196 | - wp_redirect($redirect); |
|
197 | - exit(); |
|
198 | - } |
|
195 | + if ( empty($_REQUEST['users']) && empty($_REQUEST['user']) ) { |
|
196 | + wp_redirect($redirect); |
|
197 | + exit(); |
|
198 | + } |
|
199 | 199 | |
200 | - if ( ! current_user_can( 'delete_users' ) ) |
|
201 | - $errors = new WP_Error( 'edit_users', __( 'You can’t delete users.' ) ); |
|
200 | + if ( ! current_user_can( 'delete_users' ) ) |
|
201 | + $errors = new WP_Error( 'edit_users', __( 'You can’t delete users.' ) ); |
|
202 | 202 | |
203 | - if ( empty($_REQUEST['users']) ) |
|
204 | - $userids = array( intval( $_REQUEST['user'] ) ); |
|
205 | - else |
|
206 | - $userids = array_map( 'intval', (array) $_REQUEST['users'] ); |
|
203 | + if ( empty($_REQUEST['users']) ) |
|
204 | + $userids = array( intval( $_REQUEST['user'] ) ); |
|
205 | + else |
|
206 | + $userids = array_map( 'intval', (array) $_REQUEST['users'] ); |
|
207 | 207 | |
208 | - add_action( 'admin_head', 'delete_users_add_js' ); |
|
208 | + add_action( 'admin_head', 'delete_users_add_js' ); |
|
209 | 209 | |
210 | - include( ABSPATH . 'wp-admin/admin-header.php' ); |
|
211 | -?> |
|
212 | -<form method="post" name="updateusers" id="updateusers"> |
|
213 | -<?php wp_nonce_field('delete-users') ?> |
|
214 | -<?php echo $referer; ?> |
|
210 | + include( ABSPATH . 'wp-admin/admin-header.php' ); |
|
211 | + ?> |
|
212 | + <form method="post" name="updateusers" id="updateusers"> |
|
213 | + <?php wp_nonce_field('delete-users') ?> |
|
214 | + <?php echo $referer; ?> |
|
215 | 215 | |
216 | 216 | <div class="wrap"> |
217 | 217 | <h1><?php _e( 'Delete Users' ); ?></h1> |
218 | -<?php if ( isset( $_REQUEST['error'] ) ) : ?> |
|
218 | + <?php if ( isset( $_REQUEST['error'] ) ) : ?> |
|
219 | 219 | <div class="error"> |
220 | 220 | <p><strong><?php _e( 'ERROR:' ); ?></strong> <?php _e( 'Please select an option.' ); ?></p> |
221 | 221 | </div> |
222 | 222 | <?php endif; ?> |
223 | - |
|
224 | -<?php if ( 1 == count( $userids ) ) : ?> |
|
225 | - <p><?php _e( 'You have specified this user for deletion:' ); ?></p> |
|
226 | -<?php else : ?> |
|
227 | - <p><?php _e( 'You have specified these users for deletion:' ); ?></p> |
|
228 | -<?php endif; ?> |
|
223 | + |
|
224 | + <?php if ( 1 == count( $userids ) ) : ?> |
|
225 | + <p><?php _e( 'You have specified this user for deletion:' ); ?></p> |
|
226 | + <?php else : ?> |
|
227 | + <p><?php _e( 'You have specified these users for deletion:' ); ?></p> |
|
228 | + <?php endif; ?> |
|
229 | 229 | |
230 | 230 | <ul> |
231 | 231 | <?php |
232 | - $go_delete = 0; |
|
233 | - foreach ( $userids as $id ) { |
|
234 | - $user = get_userdata( $id ); |
|
235 | - if ( $id == $current_user->ID ) { |
|
236 | - echo "<li>" . sprintf(__('ID #%1$s: %2$s <strong>The current user will not be deleted.</strong>'), $id, $user->user_login) . "</li>\n"; |
|
237 | - } else { |
|
238 | - echo "<li><input type=\"hidden\" name=\"users[]\" value=\"" . esc_attr($id) . "\" />" . sprintf(__('ID #%1$s: %2$s'), $id, $user->user_login) . "</li>\n"; |
|
239 | - $go_delete++; |
|
232 | + $go_delete = 0; |
|
233 | + foreach ( $userids as $id ) { |
|
234 | + $user = get_userdata( $id ); |
|
235 | + if ( $id == $current_user->ID ) { |
|
236 | + echo "<li>" . sprintf(__('ID #%1$s: %2$s <strong>The current user will not be deleted.</strong>'), $id, $user->user_login) . "</li>\n"; |
|
237 | + } else { |
|
238 | + echo "<li><input type=\"hidden\" name=\"users[]\" value=\"" . esc_attr($id) . "\" />" . sprintf(__('ID #%1$s: %2$s'), $id, $user->user_login) . "</li>\n"; |
|
239 | + $go_delete++; |
|
240 | + } |
|
240 | 241 | } |
241 | - } |
|
242 | - ?> |
|
243 | - </ul> |
|
244 | -<?php if ( $go_delete ) : ?> |
|
245 | - <?php if ( 1 == $go_delete ) : ?> |
|
246 | - <fieldset><p><legend><?php _e( 'What should be done with content owned by this user?' ); ?></legend></p> |
|
242 | + ?> |
|
243 | + </ul> |
|
244 | + <?php if ( $go_delete ) : ?> |
|
245 | + <?php if ( 1 == $go_delete ) : ?> |
|
246 | + <fieldset><p><legend><?php _e( 'What should be done with content owned by this user?' ); ?></legend></p> |
|
247 | 247 | <?php else : ?> |
248 | - <fieldset><p><legend><?php _e( 'What should be done with content owned by these users?' ); ?></legend></p> |
|
248 | + <fieldset><p><legend><?php _e( 'What should be done with content owned by these users?' ); ?></legend></p> |
|
249 | 249 | <?php endif; ?> |
250 | 250 | <ul style="list-style:none;"> |
251 | 251 | <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" /> |
252 | 252 | <?php _e('Delete all content.'); ?></label></li> |
253 | 253 | <li><input type="radio" id="delete_option1" name="delete_option" value="reassign" /> |
254 | 254 | <?php echo '<label for="delete_option1">' . __( 'Attribute all content to:' ) . '</label> '; |
255 | - wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?></li> |
|
255 | + wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?></li> |
|
256 | 256 | </ul></fieldset> |
257 | 257 | <?php |
258 | - /** |
|
258 | + /** |
|
259 | 259 | * Fires at the end of the delete users form prior to the confirm button. |
260 | 260 | * |
261 | 261 | * @since 4.0.0 |
262 | 262 | * |
263 | 263 | * @param WP_User $current_user WP_User object for the user being deleted. |
264 | 264 | */ |
265 | - do_action( 'delete_user_form', $current_user ); |
|
266 | - ?> |
|
267 | - <input type="hidden" name="action" value="dodelete" /> |
|
265 | + do_action( 'delete_user_form', $current_user ); |
|
266 | + ?> |
|
267 | + <input type="hidden" name="action" value="dodelete" /> |
|
268 | 268 | <?php submit_button( __('Confirm Deletion'), 'secondary' ); ?> |
269 | -<?php else : ?> |
|
270 | - <p><?php _e('There are no valid users selected for deletion.'); ?></p> |
|
271 | -<?php endif; ?> |
|
269 | + <?php else : ?> |
|
270 | + <p><?php _e('There are no valid users selected for deletion.'); ?></p> |
|
271 | + <?php endif; ?> |
|
272 | 272 | </div> |
273 | 273 | </form> |
274 | 274 | <?php |
275 | 275 | |
276 | -break; |
|
276 | + break; |
|
277 | 277 | |
278 | -case 'doremove': |
|
279 | - check_admin_referer('remove-users'); |
|
278 | + case 'doremove': |
|
279 | + check_admin_referer('remove-users'); |
|
280 | 280 | |
281 | - if ( ! is_multisite() ) |
|
282 | - wp_die( __( 'You can’t remove users.' ) ); |
|
281 | + if ( ! is_multisite() ) |
|
282 | + wp_die( __( 'You can’t remove users.' ) ); |
|
283 | 283 | |
284 | - if ( empty($_REQUEST['users']) ) { |
|
285 | - wp_redirect($redirect); |
|
286 | - exit; |
|
287 | - } |
|
284 | + if ( empty($_REQUEST['users']) ) { |
|
285 | + wp_redirect($redirect); |
|
286 | + exit; |
|
287 | + } |
|
288 | 288 | |
289 | - if ( ! current_user_can( 'remove_users' ) ) |
|
290 | - wp_die( __( 'You can’t remove users.' ) ); |
|
289 | + if ( ! current_user_can( 'remove_users' ) ) |
|
290 | + wp_die( __( 'You can’t remove users.' ) ); |
|
291 | 291 | |
292 | - $userids = $_REQUEST['users']; |
|
292 | + $userids = $_REQUEST['users']; |
|
293 | 293 | |
294 | - $update = 'remove'; |
|
295 | - foreach ( $userids as $id ) { |
|
296 | - $id = (int) $id; |
|
297 | - if ( $id == $current_user->ID && !is_super_admin() ) { |
|
298 | - $update = 'err_admin_remove'; |
|
299 | - continue; |
|
300 | - } |
|
301 | - if ( !current_user_can('remove_user', $id) ) { |
|
302 | - $update = 'err_admin_remove'; |
|
303 | - continue; |
|
294 | + $update = 'remove'; |
|
295 | + foreach ( $userids as $id ) { |
|
296 | + $id = (int) $id; |
|
297 | + if ( $id == $current_user->ID && !is_super_admin() ) { |
|
298 | + $update = 'err_admin_remove'; |
|
299 | + continue; |
|
300 | + } |
|
301 | + if ( !current_user_can('remove_user', $id) ) { |
|
302 | + $update = 'err_admin_remove'; |
|
303 | + continue; |
|
304 | + } |
|
305 | + remove_user_from_blog($id, $blog_id); |
|
304 | 306 | } |
305 | - remove_user_from_blog($id, $blog_id); |
|
306 | - } |
|
307 | 307 | |
308 | - $redirect = add_query_arg( array('update' => $update), $redirect); |
|
309 | - wp_redirect($redirect); |
|
310 | - exit; |
|
308 | + $redirect = add_query_arg( array('update' => $update), $redirect); |
|
309 | + wp_redirect($redirect); |
|
310 | + exit; |
|
311 | 311 | |
312 | -case 'remove': |
|
312 | + case 'remove': |
|
313 | 313 | |
314 | - check_admin_referer('bulk-users'); |
|
314 | + check_admin_referer('bulk-users'); |
|
315 | 315 | |
316 | - if ( ! is_multisite() ) |
|
317 | - wp_die( __( 'You can’t remove users.' ) ); |
|
316 | + if ( ! is_multisite() ) |
|
317 | + wp_die( __( 'You can’t remove users.' ) ); |
|
318 | 318 | |
319 | - if ( empty($_REQUEST['users']) && empty($_REQUEST['user']) ) { |
|
320 | - wp_redirect($redirect); |
|
321 | - exit(); |
|
322 | - } |
|
319 | + if ( empty($_REQUEST['users']) && empty($_REQUEST['user']) ) { |
|
320 | + wp_redirect($redirect); |
|
321 | + exit(); |
|
322 | + } |
|
323 | 323 | |
324 | - if ( !current_user_can('remove_users') ) |
|
325 | - $error = new WP_Error('edit_users', __('You can’t remove users.')); |
|
324 | + if ( !current_user_can('remove_users') ) |
|
325 | + $error = new WP_Error('edit_users', __('You can’t remove users.')); |
|
326 | 326 | |
327 | - if ( empty($_REQUEST['users']) ) |
|
328 | - $userids = array(intval($_REQUEST['user'])); |
|
329 | - else |
|
330 | - $userids = $_REQUEST['users']; |
|
327 | + if ( empty($_REQUEST['users']) ) |
|
328 | + $userids = array(intval($_REQUEST['user'])); |
|
329 | + else |
|
330 | + $userids = $_REQUEST['users']; |
|
331 | 331 | |
332 | - include( ABSPATH . 'wp-admin/admin-header.php' ); |
|
333 | -?> |
|
334 | -<form method="post" name="updateusers" id="updateusers"> |
|
335 | -<?php wp_nonce_field('remove-users') ?> |
|
336 | -<?php echo $referer; ?> |
|
332 | + include( ABSPATH . 'wp-admin/admin-header.php' ); |
|
333 | + ?> |
|
334 | + <form method="post" name="updateusers" id="updateusers"> |
|
335 | + <?php wp_nonce_field('remove-users') ?> |
|
336 | + <?php echo $referer; ?> |
|
337 | 337 | |
338 | 338 | <div class="wrap"> |
339 | 339 | <h1><?php _e( 'Remove Users from Site' ); ?></h1> |
340 | 340 | |
341 | -<?php if ( 1 == count( $userids ) ) : ?> |
|
342 | - <p><?php _e( 'You have specified this user for removal:' ); ?></p> |
|
343 | -<?php else : ?> |
|
344 | - <p><?php _e( 'You have specified these users for removal:' ); ?></p> |
|
345 | -<?php endif; ?> |
|
341 | + <?php if ( 1 == count( $userids ) ) : ?> |
|
342 | + <p><?php _e( 'You have specified this user for removal:' ); ?></p> |
|
343 | + <?php else : ?> |
|
344 | + <p><?php _e( 'You have specified these users for removal:' ); ?></p> |
|
345 | + <?php endif; ?> |
|
346 | 346 | |
347 | 347 | <ul> |
348 | 348 | <?php |
349 | - $go_remove = false; |
|
350 | - foreach ( $userids as $id ) { |
|
351 | - $id = (int) $id; |
|
352 | - $user = get_userdata( $id ); |
|
353 | - if ( $id == $current_user->ID && !is_super_admin() ) { |
|
354 | - echo "<li>" . sprintf(__('ID #%1$s: %2$s <strong>The current user will not be removed.</strong>'), $id, $user->user_login) . "</li>\n"; |
|
355 | - } elseif ( !current_user_can('remove_user', $id) ) { |
|
356 | - echo "<li>" . sprintf(__('ID #%1$s: %2$s <strong>You don\'t have permission to remove this user.</strong>'), $id, $user->user_login) . "</li>\n"; |
|
357 | - } else { |
|
358 | - echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf(__('ID #%1$s: %2$s'), $id, $user->user_login) . "</li>\n"; |
|
359 | - $go_remove = true; |
|
360 | - } |
|
361 | - } |
|
362 | - ?> |
|
363 | -</ul> |
|
364 | -<?php if ( $go_remove ) : ?> |
|
365 | - <input type="hidden" name="action" value="doremove" /> |
|
349 | + $go_remove = false; |
|
350 | + foreach ( $userids as $id ) { |
|
351 | + $id = (int) $id; |
|
352 | + $user = get_userdata( $id ); |
|
353 | + if ( $id == $current_user->ID && !is_super_admin() ) { |
|
354 | + echo "<li>" . sprintf(__('ID #%1$s: %2$s <strong>The current user will not be removed.</strong>'), $id, $user->user_login) . "</li>\n"; |
|
355 | + } elseif ( !current_user_can('remove_user', $id) ) { |
|
356 | + echo "<li>" . sprintf(__('ID #%1$s: %2$s <strong>You don\'t have permission to remove this user.</strong>'), $id, $user->user_login) . "</li>\n"; |
|
357 | + } else { |
|
358 | + echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf(__('ID #%1$s: %2$s'), $id, $user->user_login) . "</li>\n"; |
|
359 | + $go_remove = true; |
|
360 | + } |
|
361 | + } |
|
362 | + ?> |
|
363 | + </ul> |
|
364 | + <?php if ( $go_remove ) : ?> |
|
365 | + <input type="hidden" name="action" value="doremove" /> |
|
366 | 366 | <?php submit_button( __('Confirm Removal'), 'secondary' ); ?> |
367 | -<?php else : ?> |
|
368 | - <p><?php _e('There are no valid users selected for removal.'); ?></p> |
|
369 | -<?php endif; ?> |
|
367 | + <?php else : ?> |
|
368 | + <p><?php _e('There are no valid users selected for removal.'); ?></p> |
|
369 | + <?php endif; ?> |
|
370 | 370 | </div> |
371 | 371 | </form> |
372 | 372 | <?php |
373 | 373 | |
374 | -break; |
|
375 | - |
|
376 | -default: |
|
374 | + break; |
|
377 | 375 | |
378 | - if ( !empty($_GET['_wp_http_referer']) ) { |
|
379 | - wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce'), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); |
|
380 | - exit; |
|
381 | - } |
|
376 | + default: |
|
382 | 377 | |
383 | - $wp_list_table->prepare_items(); |
|
384 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
385 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
386 | - wp_redirect( add_query_arg( 'paged', $total_pages ) ); |
|
387 | - exit; |
|
388 | - } |
|
378 | + if ( !empty($_GET['_wp_http_referer']) ) { |
|
379 | + wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce'), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); |
|
380 | + exit; |
|
381 | + } |
|
389 | 382 | |
390 | - include( ABSPATH . 'wp-admin/admin-header.php' ); |
|
383 | + $wp_list_table->prepare_items(); |
|
384 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
385 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
386 | + wp_redirect( add_query_arg( 'paged', $total_pages ) ); |
|
387 | + exit; |
|
388 | + } |
|
391 | 389 | |
392 | - $messages = array(); |
|
393 | - if ( isset($_GET['update']) ) : |
|
394 | - switch($_GET['update']) { |
|
395 | - case 'del': |
|
396 | - case 'del_many': |
|
397 | - $delete_count = isset($_GET['delete_count']) ? (int) $_GET['delete_count'] : 0; |
|
398 | - if ( 1 == $delete_count ) { |
|
399 | - $message = __( 'User deleted.' ); |
|
400 | - } else { |
|
401 | - $message = _n( '%s user deleted.', '%s users deleted.', $delete_count ); |
|
390 | + include( ABSPATH . 'wp-admin/admin-header.php' ); |
|
391 | + |
|
392 | + $messages = array(); |
|
393 | + if ( isset($_GET['update']) ) : |
|
394 | + switch($_GET['update']) { |
|
395 | + case 'del': |
|
396 | + case 'del_many': |
|
397 | + $delete_count = isset($_GET['delete_count']) ? (int) $_GET['delete_count'] : 0; |
|
398 | + if ( 1 == $delete_count ) { |
|
399 | + $message = __( 'User deleted.' ); |
|
400 | + } else { |
|
401 | + $message = _n( '%s user deleted.', '%s users deleted.', $delete_count ); |
|
402 | + } |
|
403 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $delete_count ) ) . '</p></div>'; |
|
404 | + break; |
|
405 | + case 'add': |
|
406 | + if ( isset( $_GET['id'] ) && ( $user_id = $_GET['id'] ) && current_user_can( 'edit_user', $user_id ) ) { |
|
407 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( __( 'New user created. <a href="%s">Edit user</a>' ), |
|
408 | + esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), |
|
409 | + self_admin_url( 'user-edit.php?user_id=' . $user_id ) ) ) ) . '</p></div>'; |
|
410 | + } else { |
|
411 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'New user created.' ) . '</p></div>'; |
|
412 | + } |
|
413 | + break; |
|
414 | + case 'promote': |
|
415 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Changed roles.') . '</p></div>'; |
|
416 | + break; |
|
417 | + case 'err_admin_role': |
|
418 | + $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __('The current user’s role must have user editing capabilities.') . '</p></div>'; |
|
419 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Other user roles have been changed.') . '</p></div>'; |
|
420 | + break; |
|
421 | + case 'err_admin_del': |
|
422 | + $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __('You can’t delete the current user.') . '</p></div>'; |
|
423 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Other users have been deleted.') . '</p></div>'; |
|
424 | + break; |
|
425 | + case 'remove': |
|
426 | + $messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>' . __('User removed from this site.') . '</p></div>'; |
|
427 | + break; |
|
428 | + case 'err_admin_remove': |
|
429 | + $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __("You can't remove the current user.") . '</p></div>'; |
|
430 | + $messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>' . __('Other users have been removed.') . '</p></div>'; |
|
431 | + break; |
|
402 | 432 | } |
403 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $delete_count ) ) . '</p></div>'; |
|
404 | - break; |
|
405 | - case 'add': |
|
406 | - if ( isset( $_GET['id'] ) && ( $user_id = $_GET['id'] ) && current_user_can( 'edit_user', $user_id ) ) { |
|
407 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( __( 'New user created. <a href="%s">Edit user</a>' ), |
|
408 | - esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), |
|
409 | - self_admin_url( 'user-edit.php?user_id=' . $user_id ) ) ) ) . '</p></div>'; |
|
410 | - } else { |
|
411 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'New user created.' ) . '</p></div>'; |
|
412 | - } |
|
413 | - break; |
|
414 | - case 'promote': |
|
415 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Changed roles.') . '</p></div>'; |
|
416 | - break; |
|
417 | - case 'err_admin_role': |
|
418 | - $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __('The current user’s role must have user editing capabilities.') . '</p></div>'; |
|
419 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Other user roles have been changed.') . '</p></div>'; |
|
420 | - break; |
|
421 | - case 'err_admin_del': |
|
422 | - $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __('You can’t delete the current user.') . '</p></div>'; |
|
423 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Other users have been deleted.') . '</p></div>'; |
|
424 | - break; |
|
425 | - case 'remove': |
|
426 | - $messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>' . __('User removed from this site.') . '</p></div>'; |
|
427 | - break; |
|
428 | - case 'err_admin_remove': |
|
429 | - $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __("You can't remove the current user.") . '</p></div>'; |
|
430 | - $messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>' . __('Other users have been removed.') . '</p></div>'; |
|
431 | - break; |
|
432 | - } |
|
433 | 433 | endif; ?> |
434 | 434 | |
435 | 435 | <?php if ( isset($errors) && is_wp_error( $errors ) ) : ?> |
@@ -7,67 +7,67 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | /** WordPress Administration Bootstrap */ |
10 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
10 | +require_once(dirname(__FILE__).'/admin.php'); |
|
11 | 11 | |
12 | -if ( ! current_user_can( 'list_users' ) ) |
|
13 | - wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
12 | +if ( ! current_user_can('list_users')) |
|
13 | + wp_die(__('Cheatin’ uh?'), 403); |
|
14 | 14 | |
15 | 15 | $wp_list_table = _get_list_table('WP_Users_List_Table'); |
16 | 16 | $pagenum = $wp_list_table->get_pagenum(); |
17 | 17 | $title = __('Users'); |
18 | 18 | $parent_file = 'users.php'; |
19 | 19 | |
20 | -add_screen_option( 'per_page' ); |
|
20 | +add_screen_option('per_page'); |
|
21 | 21 | |
22 | 22 | // contextual help - choose Help on the top right of admin panel to preview this. |
23 | -get_current_screen()->add_help_tab( array( |
|
23 | +get_current_screen()->add_help_tab(array( |
|
24 | 24 | 'id' => 'overview', |
25 | 25 | 'title' => __('Overview'), |
26 | - 'content' => '<p>' . __('This screen lists all the existing users for your site. Each user has one of five defined roles as set by the site admin: Site Administrator, Editor, Author, Contributor, or Subscriber. Users with roles other than Administrator will see fewer options in the dashboard navigation when they are logged in, based on their role.') . '</p>' . |
|
27 | - '<p>' . __('To add a new user for your site, click the Add New button at the top of the screen or Add New in the Users menu section.') . '</p>' |
|
28 | -) ) ; |
|
26 | + 'content' => '<p>'.__('This screen lists all the existing users for your site. Each user has one of five defined roles as set by the site admin: Site Administrator, Editor, Author, Contributor, or Subscriber. Users with roles other than Administrator will see fewer options in the dashboard navigation when they are logged in, based on their role.').'</p>'. |
|
27 | + '<p>'.__('To add a new user for your site, click the Add New button at the top of the screen or Add New in the Users menu section.').'</p>' |
|
28 | +)); |
|
29 | 29 | |
30 | -get_current_screen()->add_help_tab( array( |
|
30 | +get_current_screen()->add_help_tab(array( |
|
31 | 31 | 'id' => 'screen-display', |
32 | 32 | 'title' => __('Screen Display'), |
33 | - 'content' => '<p>' . __('You can customize the display of this screen in a number of ways:') . '</p>' . |
|
34 | - '<ul>' . |
|
35 | - '<li>' . __('You can hide/display columns based on your needs and decide how many users to list per screen using the Screen Options tab.') . '</li>' . |
|
36 | - '<li>' . __('You can filter the list of users by User Role using the text links in the upper left to show All, Administrator, Editor, Author, Contributor, or Subscriber. The default view is to show all users. Unused User Roles are not listed.') . '</li>' . |
|
37 | - '<li>' . __('You can view all posts made by a user by clicking on the number under the Posts column.') . '</li>' . |
|
33 | + 'content' => '<p>'.__('You can customize the display of this screen in a number of ways:').'</p>'. |
|
34 | + '<ul>'. |
|
35 | + '<li>'.__('You can hide/display columns based on your needs and decide how many users to list per screen using the Screen Options tab.').'</li>'. |
|
36 | + '<li>'.__('You can filter the list of users by User Role using the text links in the upper left to show All, Administrator, Editor, Author, Contributor, or Subscriber. The default view is to show all users. Unused User Roles are not listed.').'</li>'. |
|
37 | + '<li>'.__('You can view all posts made by a user by clicking on the number under the Posts column.').'</li>'. |
|
38 | 38 | '</ul>' |
39 | -) ); |
|
39 | +)); |
|
40 | 40 | |
41 | -$help = '<p>' . __('Hovering over a row in the users list will display action links that allow you to manage users. You can perform the following actions:') . '</p>' . |
|
42 | - '<ul>' . |
|
43 | - '<li>' . __('Edit takes you to the editable profile screen for that user. You can also reach that screen by clicking on the username.') . '</li>'; |
|
41 | +$help = '<p>'.__('Hovering over a row in the users list will display action links that allow you to manage users. You can perform the following actions:').'</p>'. |
|
42 | + '<ul>'. |
|
43 | + '<li>'.__('Edit takes you to the editable profile screen for that user. You can also reach that screen by clicking on the username.').'</li>'; |
|
44 | 44 | |
45 | -if ( is_multisite() ) |
|
46 | - $help .= '<li>' . __( 'Remove allows you to remove a user from your site. It does not delete their content. You can also remove multiple users at once by using Bulk Actions.' ) . '</li>'; |
|
45 | +if (is_multisite()) |
|
46 | + $help .= '<li>'.__('Remove allows you to remove a user from your site. It does not delete their content. You can also remove multiple users at once by using Bulk Actions.').'</li>'; |
|
47 | 47 | else |
48 | - $help .= '<li>' . __( 'Delete brings you to the Delete Users screen for confirmation, where you can permanently remove a user from your site and delete their content. You can also delete multiple users at once by using Bulk Actions.' ) . '</li>'; |
|
48 | + $help .= '<li>'.__('Delete brings you to the Delete Users screen for confirmation, where you can permanently remove a user from your site and delete their content. You can also delete multiple users at once by using Bulk Actions.').'</li>'; |
|
49 | 49 | |
50 | 50 | $help .= '</ul>'; |
51 | 51 | |
52 | -get_current_screen()->add_help_tab( array( |
|
52 | +get_current_screen()->add_help_tab(array( |
|
53 | 53 | 'id' => 'actions', |
54 | 54 | 'title' => __('Actions'), |
55 | 55 | 'content' => $help, |
56 | -) ); |
|
57 | -unset( $help ); |
|
56 | +)); |
|
57 | +unset($help); |
|
58 | 58 | |
59 | 59 | get_current_screen()->set_help_sidebar( |
60 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
61 | - '<p>' . __('<a href="https://codex.wordpress.org/Users_Screen" target="_blank">Documentation on Managing Users</a>') . '</p>' . |
|
62 | - '<p>' . __('<a href="https://codex.wordpress.org/Roles_and_Capabilities" target="_blank">Descriptions of Roles and Capabilities</a>') . '</p>' . |
|
63 | - '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
|
60 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
61 | + '<p>'.__('<a href="https://codex.wordpress.org/Users_Screen" target="_blank">Documentation on Managing Users</a>').'</p>'. |
|
62 | + '<p>'.__('<a href="https://codex.wordpress.org/Roles_and_Capabilities" target="_blank">Descriptions of Roles and Capabilities</a>').'</p>'. |
|
63 | + '<p>'.__('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>').'</p>' |
|
64 | 64 | ); |
65 | 65 | |
66 | -if ( empty($_REQUEST) ) { |
|
67 | - $referer = '<input type="hidden" name="wp_http_referer" value="'. esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />'; |
|
68 | -} elseif ( isset($_REQUEST['wp_http_referer']) ) { |
|
69 | - $redirect = remove_query_arg(array('wp_http_referer', 'updated', 'delete_count'), wp_unslash( $_REQUEST['wp_http_referer'] ) ); |
|
70 | - $referer = '<input type="hidden" name="wp_http_referer" value="' . esc_attr($redirect) . '" />'; |
|
66 | +if (empty($_REQUEST)) { |
|
67 | + $referer = '<input type="hidden" name="wp_http_referer" value="'.esc_attr(wp_unslash($_SERVER['REQUEST_URI'])).'" />'; |
|
68 | +} elseif (isset($_REQUEST['wp_http_referer'])) { |
|
69 | + $redirect = remove_query_arg(array('wp_http_referer', 'updated', 'delete_count'), wp_unslash($_REQUEST['wp_http_referer'])); |
|
70 | + $referer = '<input type="hidden" name="wp_http_referer" value="'.esc_attr($redirect).'" />'; |
|
71 | 71 | } else { |
72 | 72 | $redirect = 'users.php'; |
73 | 73 | $referer = ''; |
@@ -94,43 +94,43 @@ discard block |
||
94 | 94 | <?php |
95 | 95 | } |
96 | 96 | |
97 | -switch ( $wp_list_table->current_action() ) { |
|
97 | +switch ($wp_list_table->current_action()) { |
|
98 | 98 | |
99 | 99 | /* Bulk Dropdown menu Role changes */ |
100 | 100 | case 'promote': |
101 | 101 | check_admin_referer('bulk-users'); |
102 | 102 | |
103 | - if ( ! current_user_can( 'promote_users' ) ) |
|
104 | - wp_die( __( 'You can’t edit that user.' ) ); |
|
103 | + if ( ! current_user_can('promote_users')) |
|
104 | + wp_die(__('You can’t edit that user.')); |
|
105 | 105 | |
106 | - if ( empty($_REQUEST['users']) ) { |
|
106 | + if (empty($_REQUEST['users'])) { |
|
107 | 107 | wp_redirect($redirect); |
108 | 108 | exit(); |
109 | 109 | } |
110 | 110 | |
111 | 111 | $editable_roles = get_editable_roles(); |
112 | - if ( empty( $editable_roles[$_REQUEST['new_role']] ) ) |
|
112 | + if (empty($editable_roles[$_REQUEST['new_role']])) |
|
113 | 113 | wp_die(__('You can’t give users that role.')); |
114 | 114 | |
115 | 115 | $userids = $_REQUEST['users']; |
116 | 116 | $update = 'promote'; |
117 | - foreach ( $userids as $id ) { |
|
117 | + foreach ($userids as $id) { |
|
118 | 118 | $id = (int) $id; |
119 | 119 | |
120 | - if ( ! current_user_can('promote_user', $id) ) |
|
120 | + if ( ! current_user_can('promote_user', $id)) |
|
121 | 121 | wp_die(__('You can’t edit that user.')); |
122 | 122 | // The new role of the current user must also have the promote_users cap or be a multisite super admin |
123 | - if ( $id == $current_user->ID && ! $wp_roles->role_objects[ $_REQUEST['new_role'] ]->has_cap('promote_users') |
|
124 | - && ! ( is_multisite() && is_super_admin() ) ) { |
|
123 | + if ($id == $current_user->ID && ! $wp_roles->role_objects[$_REQUEST['new_role']]->has_cap('promote_users') |
|
124 | + && ! (is_multisite() && is_super_admin())) { |
|
125 | 125 | $update = 'err_admin_role'; |
126 | 126 | continue; |
127 | 127 | } |
128 | 128 | |
129 | 129 | // If the user doesn't already belong to the blog, bail. |
130 | - if ( is_multisite() && !is_user_member_of_blog( $id ) ) |
|
131 | - wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
130 | + if (is_multisite() && ! is_user_member_of_blog($id)) |
|
131 | + wp_die(__('Cheatin’ uh?'), 403); |
|
132 | 132 | |
133 | - $user = get_userdata( $id ); |
|
133 | + $user = get_userdata($id); |
|
134 | 134 | $user->set_role($_REQUEST['new_role']); |
135 | 135 | } |
136 | 136 | |
@@ -138,121 +138,121 @@ discard block |
||
138 | 138 | exit(); |
139 | 139 | |
140 | 140 | case 'dodelete': |
141 | - if ( is_multisite() ) |
|
142 | - wp_die( __('User deletion is not allowed from this screen.') ); |
|
141 | + if (is_multisite()) |
|
142 | + wp_die(__('User deletion is not allowed from this screen.')); |
|
143 | 143 | |
144 | 144 | check_admin_referer('delete-users'); |
145 | 145 | |
146 | - if ( empty($_REQUEST['users']) ) { |
|
146 | + if (empty($_REQUEST['users'])) { |
|
147 | 147 | wp_redirect($redirect); |
148 | 148 | exit(); |
149 | 149 | } |
150 | 150 | |
151 | - $userids = array_map( 'intval', (array) $_REQUEST['users'] ); |
|
151 | + $userids = array_map('intval', (array) $_REQUEST['users']); |
|
152 | 152 | |
153 | - if ( empty( $_REQUEST['delete_option'] ) ) { |
|
154 | - $url = self_admin_url( 'users.php?action=delete&users[]=' . implode( '&users[]=', $userids ) . '&error=true' ); |
|
155 | - $url = str_replace( '&', '&', wp_nonce_url( $url, 'bulk-users' ) ); |
|
156 | - wp_redirect( $url ); |
|
153 | + if (empty($_REQUEST['delete_option'])) { |
|
154 | + $url = self_admin_url('users.php?action=delete&users[]='.implode('&users[]=', $userids).'&error=true'); |
|
155 | + $url = str_replace('&', '&', wp_nonce_url($url, 'bulk-users')); |
|
156 | + wp_redirect($url); |
|
157 | 157 | exit; |
158 | 158 | } |
159 | 159 | |
160 | - if ( ! current_user_can( 'delete_users' ) ) |
|
160 | + if ( ! current_user_can('delete_users')) |
|
161 | 161 | wp_die(__('You can’t delete users.')); |
162 | 162 | |
163 | 163 | $update = 'del'; |
164 | 164 | $delete_count = 0; |
165 | 165 | |
166 | - foreach ( $userids as $id ) { |
|
167 | - if ( ! current_user_can( 'delete_user', $id ) ) |
|
168 | - wp_die(__( 'You can’t delete that user.' ) ); |
|
166 | + foreach ($userids as $id) { |
|
167 | + if ( ! current_user_can('delete_user', $id)) |
|
168 | + wp_die(__('You can’t delete that user.')); |
|
169 | 169 | |
170 | - if ( $id == $current_user->ID ) { |
|
170 | + if ($id == $current_user->ID) { |
|
171 | 171 | $update = 'err_admin_del'; |
172 | 172 | continue; |
173 | 173 | } |
174 | - switch ( $_REQUEST['delete_option'] ) { |
|
174 | + switch ($_REQUEST['delete_option']) { |
|
175 | 175 | case 'delete': |
176 | - wp_delete_user( $id ); |
|
176 | + wp_delete_user($id); |
|
177 | 177 | break; |
178 | 178 | case 'reassign': |
179 | - wp_delete_user( $id, $_REQUEST['reassign_user'] ); |
|
179 | + wp_delete_user($id, $_REQUEST['reassign_user']); |
|
180 | 180 | break; |
181 | 181 | } |
182 | 182 | ++$delete_count; |
183 | 183 | } |
184 | 184 | |
185 | - $redirect = add_query_arg( array('delete_count' => $delete_count, 'update' => $update), $redirect); |
|
185 | + $redirect = add_query_arg(array('delete_count' => $delete_count, 'update' => $update), $redirect); |
|
186 | 186 | wp_redirect($redirect); |
187 | 187 | exit(); |
188 | 188 | |
189 | 189 | case 'delete': |
190 | - if ( is_multisite() ) |
|
191 | - wp_die( __('User deletion is not allowed from this screen.') ); |
|
190 | + if (is_multisite()) |
|
191 | + wp_die(__('User deletion is not allowed from this screen.')); |
|
192 | 192 | |
193 | 193 | check_admin_referer('bulk-users'); |
194 | 194 | |
195 | - if ( empty($_REQUEST['users']) && empty($_REQUEST['user']) ) { |
|
195 | + if (empty($_REQUEST['users']) && empty($_REQUEST['user'])) { |
|
196 | 196 | wp_redirect($redirect); |
197 | 197 | exit(); |
198 | 198 | } |
199 | 199 | |
200 | - if ( ! current_user_can( 'delete_users' ) ) |
|
201 | - $errors = new WP_Error( 'edit_users', __( 'You can’t delete users.' ) ); |
|
200 | + if ( ! current_user_can('delete_users')) |
|
201 | + $errors = new WP_Error('edit_users', __('You can’t delete users.')); |
|
202 | 202 | |
203 | - if ( empty($_REQUEST['users']) ) |
|
204 | - $userids = array( intval( $_REQUEST['user'] ) ); |
|
203 | + if (empty($_REQUEST['users'])) |
|
204 | + $userids = array(intval($_REQUEST['user'])); |
|
205 | 205 | else |
206 | - $userids = array_map( 'intval', (array) $_REQUEST['users'] ); |
|
206 | + $userids = array_map('intval', (array) $_REQUEST['users']); |
|
207 | 207 | |
208 | - add_action( 'admin_head', 'delete_users_add_js' ); |
|
208 | + add_action('admin_head', 'delete_users_add_js'); |
|
209 | 209 | |
210 | - include( ABSPATH . 'wp-admin/admin-header.php' ); |
|
210 | + include(ABSPATH.'wp-admin/admin-header.php'); |
|
211 | 211 | ?> |
212 | 212 | <form method="post" name="updateusers" id="updateusers"> |
213 | 213 | <?php wp_nonce_field('delete-users') ?> |
214 | 214 | <?php echo $referer; ?> |
215 | 215 | |
216 | 216 | <div class="wrap"> |
217 | -<h1><?php _e( 'Delete Users' ); ?></h1> |
|
218 | -<?php if ( isset( $_REQUEST['error'] ) ) : ?> |
|
217 | +<h1><?php _e('Delete Users'); ?></h1> |
|
218 | +<?php if (isset($_REQUEST['error'])) : ?> |
|
219 | 219 | <div class="error"> |
220 | - <p><strong><?php _e( 'ERROR:' ); ?></strong> <?php _e( 'Please select an option.' ); ?></p> |
|
220 | + <p><strong><?php _e('ERROR:'); ?></strong> <?php _e('Please select an option.'); ?></p> |
|
221 | 221 | </div> |
222 | 222 | <?php endif; ?> |
223 | 223 | |
224 | -<?php if ( 1 == count( $userids ) ) : ?> |
|
225 | - <p><?php _e( 'You have specified this user for deletion:' ); ?></p> |
|
224 | +<?php if (1 == count($userids)) : ?> |
|
225 | + <p><?php _e('You have specified this user for deletion:'); ?></p> |
|
226 | 226 | <?php else : ?> |
227 | - <p><?php _e( 'You have specified these users for deletion:' ); ?></p> |
|
227 | + <p><?php _e('You have specified these users for deletion:'); ?></p> |
|
228 | 228 | <?php endif; ?> |
229 | 229 | |
230 | 230 | <ul> |
231 | 231 | <?php |
232 | 232 | $go_delete = 0; |
233 | - foreach ( $userids as $id ) { |
|
234 | - $user = get_userdata( $id ); |
|
235 | - if ( $id == $current_user->ID ) { |
|
236 | - echo "<li>" . sprintf(__('ID #%1$s: %2$s <strong>The current user will not be deleted.</strong>'), $id, $user->user_login) . "</li>\n"; |
|
233 | + foreach ($userids as $id) { |
|
234 | + $user = get_userdata($id); |
|
235 | + if ($id == $current_user->ID) { |
|
236 | + echo "<li>".sprintf(__('ID #%1$s: %2$s <strong>The current user will not be deleted.</strong>'), $id, $user->user_login)."</li>\n"; |
|
237 | 237 | } else { |
238 | - echo "<li><input type=\"hidden\" name=\"users[]\" value=\"" . esc_attr($id) . "\" />" . sprintf(__('ID #%1$s: %2$s'), $id, $user->user_login) . "</li>\n"; |
|
238 | + echo "<li><input type=\"hidden\" name=\"users[]\" value=\"".esc_attr($id)."\" />".sprintf(__('ID #%1$s: %2$s'), $id, $user->user_login)."</li>\n"; |
|
239 | 239 | $go_delete++; |
240 | 240 | } |
241 | 241 | } |
242 | 242 | ?> |
243 | 243 | </ul> |
244 | -<?php if ( $go_delete ) : ?> |
|
245 | - <?php if ( 1 == $go_delete ) : ?> |
|
246 | - <fieldset><p><legend><?php _e( 'What should be done with content owned by this user?' ); ?></legend></p> |
|
244 | +<?php if ($go_delete) : ?> |
|
245 | + <?php if (1 == $go_delete) : ?> |
|
246 | + <fieldset><p><legend><?php _e('What should be done with content owned by this user?'); ?></legend></p> |
|
247 | 247 | <?php else : ?> |
248 | - <fieldset><p><legend><?php _e( 'What should be done with content owned by these users?' ); ?></legend></p> |
|
248 | + <fieldset><p><legend><?php _e('What should be done with content owned by these users?'); ?></legend></p> |
|
249 | 249 | <?php endif; ?> |
250 | 250 | <ul style="list-style:none;"> |
251 | 251 | <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" /> |
252 | 252 | <?php _e('Delete all content.'); ?></label></li> |
253 | 253 | <li><input type="radio" id="delete_option1" name="delete_option" value="reassign" /> |
254 | - <?php echo '<label for="delete_option1">' . __( 'Attribute all content to:' ) . '</label> '; |
|
255 | - wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?></li> |
|
254 | + <?php echo '<label for="delete_option1">'.__('Attribute all content to:').'</label> '; |
|
255 | + wp_dropdown_users(array('name' => 'reassign_user', 'exclude' => array_diff($userids, array($current_user->ID)))); ?></li> |
|
256 | 256 | </ul></fieldset> |
257 | 257 | <?php |
258 | 258 | /** |
@@ -262,10 +262,10 @@ discard block |
||
262 | 262 | * |
263 | 263 | * @param WP_User $current_user WP_User object for the user being deleted. |
264 | 264 | */ |
265 | - do_action( 'delete_user_form', $current_user ); |
|
265 | + do_action('delete_user_form', $current_user); |
|
266 | 266 | ?> |
267 | 267 | <input type="hidden" name="action" value="dodelete" /> |
268 | - <?php submit_button( __('Confirm Deletion'), 'secondary' ); ?> |
|
268 | + <?php submit_button(__('Confirm Deletion'), 'secondary'); ?> |
|
269 | 269 | <?php else : ?> |
270 | 270 | <p><?php _e('There are no valid users selected for deletion.'); ?></p> |
271 | 271 | <?php endif; ?> |
@@ -278,34 +278,34 @@ discard block |
||
278 | 278 | case 'doremove': |
279 | 279 | check_admin_referer('remove-users'); |
280 | 280 | |
281 | - if ( ! is_multisite() ) |
|
282 | - wp_die( __( 'You can’t remove users.' ) ); |
|
281 | + if ( ! is_multisite()) |
|
282 | + wp_die(__('You can’t remove users.')); |
|
283 | 283 | |
284 | - if ( empty($_REQUEST['users']) ) { |
|
284 | + if (empty($_REQUEST['users'])) { |
|
285 | 285 | wp_redirect($redirect); |
286 | 286 | exit; |
287 | 287 | } |
288 | 288 | |
289 | - if ( ! current_user_can( 'remove_users' ) ) |
|
290 | - wp_die( __( 'You can’t remove users.' ) ); |
|
289 | + if ( ! current_user_can('remove_users')) |
|
290 | + wp_die(__('You can’t remove users.')); |
|
291 | 291 | |
292 | 292 | $userids = $_REQUEST['users']; |
293 | 293 | |
294 | 294 | $update = 'remove'; |
295 | - foreach ( $userids as $id ) { |
|
295 | + foreach ($userids as $id) { |
|
296 | 296 | $id = (int) $id; |
297 | - if ( $id == $current_user->ID && !is_super_admin() ) { |
|
297 | + if ($id == $current_user->ID && ! is_super_admin()) { |
|
298 | 298 | $update = 'err_admin_remove'; |
299 | 299 | continue; |
300 | 300 | } |
301 | - if ( !current_user_can('remove_user', $id) ) { |
|
301 | + if ( ! current_user_can('remove_user', $id)) { |
|
302 | 302 | $update = 'err_admin_remove'; |
303 | 303 | continue; |
304 | 304 | } |
305 | 305 | remove_user_from_blog($id, $blog_id); |
306 | 306 | } |
307 | 307 | |
308 | - $redirect = add_query_arg( array('update' => $update), $redirect); |
|
308 | + $redirect = add_query_arg(array('update' => $update), $redirect); |
|
309 | 309 | wp_redirect($redirect); |
310 | 310 | exit; |
311 | 311 | |
@@ -313,57 +313,57 @@ discard block |
||
313 | 313 | |
314 | 314 | check_admin_referer('bulk-users'); |
315 | 315 | |
316 | - if ( ! is_multisite() ) |
|
317 | - wp_die( __( 'You can’t remove users.' ) ); |
|
316 | + if ( ! is_multisite()) |
|
317 | + wp_die(__('You can’t remove users.')); |
|
318 | 318 | |
319 | - if ( empty($_REQUEST['users']) && empty($_REQUEST['user']) ) { |
|
319 | + if (empty($_REQUEST['users']) && empty($_REQUEST['user'])) { |
|
320 | 320 | wp_redirect($redirect); |
321 | 321 | exit(); |
322 | 322 | } |
323 | 323 | |
324 | - if ( !current_user_can('remove_users') ) |
|
324 | + if ( ! current_user_can('remove_users')) |
|
325 | 325 | $error = new WP_Error('edit_users', __('You can’t remove users.')); |
326 | 326 | |
327 | - if ( empty($_REQUEST['users']) ) |
|
327 | + if (empty($_REQUEST['users'])) |
|
328 | 328 | $userids = array(intval($_REQUEST['user'])); |
329 | 329 | else |
330 | 330 | $userids = $_REQUEST['users']; |
331 | 331 | |
332 | - include( ABSPATH . 'wp-admin/admin-header.php' ); |
|
332 | + include(ABSPATH.'wp-admin/admin-header.php'); |
|
333 | 333 | ?> |
334 | 334 | <form method="post" name="updateusers" id="updateusers"> |
335 | 335 | <?php wp_nonce_field('remove-users') ?> |
336 | 336 | <?php echo $referer; ?> |
337 | 337 | |
338 | 338 | <div class="wrap"> |
339 | -<h1><?php _e( 'Remove Users from Site' ); ?></h1> |
|
339 | +<h1><?php _e('Remove Users from Site'); ?></h1> |
|
340 | 340 | |
341 | -<?php if ( 1 == count( $userids ) ) : ?> |
|
342 | - <p><?php _e( 'You have specified this user for removal:' ); ?></p> |
|
341 | +<?php if (1 == count($userids)) : ?> |
|
342 | + <p><?php _e('You have specified this user for removal:'); ?></p> |
|
343 | 343 | <?php else : ?> |
344 | - <p><?php _e( 'You have specified these users for removal:' ); ?></p> |
|
344 | + <p><?php _e('You have specified these users for removal:'); ?></p> |
|
345 | 345 | <?php endif; ?> |
346 | 346 | |
347 | 347 | <ul> |
348 | 348 | <?php |
349 | 349 | $go_remove = false; |
350 | - foreach ( $userids as $id ) { |
|
350 | + foreach ($userids as $id) { |
|
351 | 351 | $id = (int) $id; |
352 | - $user = get_userdata( $id ); |
|
353 | - if ( $id == $current_user->ID && !is_super_admin() ) { |
|
354 | - echo "<li>" . sprintf(__('ID #%1$s: %2$s <strong>The current user will not be removed.</strong>'), $id, $user->user_login) . "</li>\n"; |
|
355 | - } elseif ( !current_user_can('remove_user', $id) ) { |
|
356 | - echo "<li>" . sprintf(__('ID #%1$s: %2$s <strong>You don\'t have permission to remove this user.</strong>'), $id, $user->user_login) . "</li>\n"; |
|
352 | + $user = get_userdata($id); |
|
353 | + if ($id == $current_user->ID && ! is_super_admin()) { |
|
354 | + echo "<li>".sprintf(__('ID #%1$s: %2$s <strong>The current user will not be removed.</strong>'), $id, $user->user_login)."</li>\n"; |
|
355 | + } elseif ( ! current_user_can('remove_user', $id)) { |
|
356 | + echo "<li>".sprintf(__('ID #%1$s: %2$s <strong>You don\'t have permission to remove this user.</strong>'), $id, $user->user_login)."</li>\n"; |
|
357 | 357 | } else { |
358 | - echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf(__('ID #%1$s: %2$s'), $id, $user->user_login) . "</li>\n"; |
|
358 | + echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />".sprintf(__('ID #%1$s: %2$s'), $id, $user->user_login)."</li>\n"; |
|
359 | 359 | $go_remove = true; |
360 | 360 | } |
361 | 361 | } |
362 | 362 | ?> |
363 | 363 | </ul> |
364 | -<?php if ( $go_remove ) : ?> |
|
364 | +<?php if ($go_remove) : ?> |
|
365 | 365 | <input type="hidden" name="action" value="doremove" /> |
366 | - <?php submit_button( __('Confirm Removal'), 'secondary' ); ?> |
|
366 | + <?php submit_button(__('Confirm Removal'), 'secondary'); ?> |
|
367 | 367 | <?php else : ?> |
368 | 368 | <p><?php _e('There are no valid users selected for removal.'); ?></p> |
369 | 369 | <?php endif; ?> |
@@ -375,98 +375,98 @@ discard block |
||
375 | 375 | |
376 | 376 | default: |
377 | 377 | |
378 | - if ( !empty($_GET['_wp_http_referer']) ) { |
|
379 | - wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce'), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); |
|
378 | + if ( ! empty($_GET['_wp_http_referer'])) { |
|
379 | + wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI']))); |
|
380 | 380 | exit; |
381 | 381 | } |
382 | 382 | |
383 | 383 | $wp_list_table->prepare_items(); |
384 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
385 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
386 | - wp_redirect( add_query_arg( 'paged', $total_pages ) ); |
|
384 | + $total_pages = $wp_list_table->get_pagination_arg('total_pages'); |
|
385 | + if ($pagenum > $total_pages && $total_pages > 0) { |
|
386 | + wp_redirect(add_query_arg('paged', $total_pages)); |
|
387 | 387 | exit; |
388 | 388 | } |
389 | 389 | |
390 | - include( ABSPATH . 'wp-admin/admin-header.php' ); |
|
390 | + include(ABSPATH.'wp-admin/admin-header.php'); |
|
391 | 391 | |
392 | 392 | $messages = array(); |
393 | - if ( isset($_GET['update']) ) : |
|
394 | - switch($_GET['update']) { |
|
393 | + if (isset($_GET['update'])) : |
|
394 | + switch ($_GET['update']) { |
|
395 | 395 | case 'del': |
396 | 396 | case 'del_many': |
397 | 397 | $delete_count = isset($_GET['delete_count']) ? (int) $_GET['delete_count'] : 0; |
398 | - if ( 1 == $delete_count ) { |
|
399 | - $message = __( 'User deleted.' ); |
|
398 | + if (1 == $delete_count) { |
|
399 | + $message = __('User deleted.'); |
|
400 | 400 | } else { |
401 | - $message = _n( '%s user deleted.', '%s users deleted.', $delete_count ); |
|
401 | + $message = _n('%s user deleted.', '%s users deleted.', $delete_count); |
|
402 | 402 | } |
403 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $delete_count ) ) . '</p></div>'; |
|
403 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>'.sprintf($message, number_format_i18n($delete_count)).'</p></div>'; |
|
404 | 404 | break; |
405 | 405 | case 'add': |
406 | - if ( isset( $_GET['id'] ) && ( $user_id = $_GET['id'] ) && current_user_can( 'edit_user', $user_id ) ) { |
|
407 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( __( 'New user created. <a href="%s">Edit user</a>' ), |
|
408 | - esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), |
|
409 | - self_admin_url( 'user-edit.php?user_id=' . $user_id ) ) ) ) . '</p></div>'; |
|
406 | + if (isset($_GET['id']) && ($user_id = $_GET['id']) && current_user_can('edit_user', $user_id)) { |
|
407 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>'.sprintf(__('New user created. <a href="%s">Edit user</a>'), |
|
408 | + esc_url(add_query_arg('wp_http_referer', urlencode(wp_unslash($_SERVER['REQUEST_URI'])), |
|
409 | + self_admin_url('user-edit.php?user_id='.$user_id)))).'</p></div>'; |
|
410 | 410 | } else { |
411 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'New user created.' ) . '</p></div>'; |
|
411 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>'.__('New user created.').'</p></div>'; |
|
412 | 412 | } |
413 | 413 | break; |
414 | 414 | case 'promote': |
415 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Changed roles.') . '</p></div>'; |
|
415 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>'.__('Changed roles.').'</p></div>'; |
|
416 | 416 | break; |
417 | 417 | case 'err_admin_role': |
418 | - $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __('The current user’s role must have user editing capabilities.') . '</p></div>'; |
|
419 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Other user roles have been changed.') . '</p></div>'; |
|
418 | + $messages[] = '<div id="message" class="error notice is-dismissible"><p>'.__('The current user’s role must have user editing capabilities.').'</p></div>'; |
|
419 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>'.__('Other user roles have been changed.').'</p></div>'; |
|
420 | 420 | break; |
421 | 421 | case 'err_admin_del': |
422 | - $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __('You can’t delete the current user.') . '</p></div>'; |
|
423 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Other users have been deleted.') . '</p></div>'; |
|
422 | + $messages[] = '<div id="message" class="error notice is-dismissible"><p>'.__('You can’t delete the current user.').'</p></div>'; |
|
423 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>'.__('Other users have been deleted.').'</p></div>'; |
|
424 | 424 | break; |
425 | 425 | case 'remove': |
426 | - $messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>' . __('User removed from this site.') . '</p></div>'; |
|
426 | + $messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>'.__('User removed from this site.').'</p></div>'; |
|
427 | 427 | break; |
428 | 428 | case 'err_admin_remove': |
429 | - $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __("You can't remove the current user.") . '</p></div>'; |
|
430 | - $messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>' . __('Other users have been removed.') . '</p></div>'; |
|
429 | + $messages[] = '<div id="message" class="error notice is-dismissible"><p>'.__("You can't remove the current user.").'</p></div>'; |
|
430 | + $messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>'.__('Other users have been removed.').'</p></div>'; |
|
431 | 431 | break; |
432 | 432 | } |
433 | 433 | endif; ?> |
434 | 434 | |
435 | -<?php if ( isset($errors) && is_wp_error( $errors ) ) : ?> |
|
435 | +<?php if (isset($errors) && is_wp_error($errors)) : ?> |
|
436 | 436 | <div class="error"> |
437 | 437 | <ul> |
438 | 438 | <?php |
439 | - foreach ( $errors->get_error_messages() as $err ) |
|
439 | + foreach ($errors->get_error_messages() as $err) |
|
440 | 440 | echo "<li>$err</li>\n"; |
441 | 441 | ?> |
442 | 442 | </ul> |
443 | 443 | </div> |
444 | 444 | <?php endif; |
445 | 445 | |
446 | -if ( ! empty($messages) ) { |
|
447 | - foreach ( $messages as $msg ) |
|
446 | +if ( ! empty($messages)) { |
|
447 | + foreach ($messages as $msg) |
|
448 | 448 | echo $msg; |
449 | 449 | } ?> |
450 | 450 | |
451 | 451 | <div class="wrap"> |
452 | 452 | <h1> |
453 | 453 | <?php |
454 | -echo esc_html( $title ); |
|
455 | -if ( current_user_can( 'create_users' ) ) { ?> |
|
456 | - <a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a> |
|
457 | -<?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?> |
|
458 | - <a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a> |
|
454 | +echo esc_html($title); |
|
455 | +if (current_user_can('create_users')) { ?> |
|
456 | + <a href="user-new.php" class="page-title-action"><?php echo esc_html_x('Add New', 'user'); ?></a> |
|
457 | +<?php } elseif (is_multisite() && current_user_can('promote_users')) { ?> |
|
458 | + <a href="user-new.php" class="page-title-action"><?php echo esc_html_x('Add Existing', 'user'); ?></a> |
|
459 | 459 | <?php } |
460 | 460 | |
461 | -if ( $usersearch ) |
|
462 | - printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( $usersearch ) ); ?> |
|
461 | +if ($usersearch) |
|
462 | + printf('<span class="subtitle">'.__('Search results for “%s”').'</span>', esc_html($usersearch)); ?> |
|
463 | 463 | </h1> |
464 | 464 | |
465 | 465 | <?php $wp_list_table->views(); ?> |
466 | 466 | |
467 | 467 | <form method="get"> |
468 | 468 | |
469 | -<?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?> |
|
469 | +<?php $wp_list_table->search_box(__('Search Users'), 'user'); ?> |
|
470 | 470 | |
471 | 471 | <?php $wp_list_table->display(); ?> |
472 | 472 | </form> |
@@ -478,4 +478,4 @@ discard block |
||
478 | 478 | |
479 | 479 | } // end of the $doaction switch |
480 | 480 | |
481 | -include( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
481 | +include(ABSPATH.'wp-admin/admin-footer.php'); |
@@ -9,8 +9,9 @@ discard block |
||
9 | 9 | /** WordPress Administration Bootstrap */ |
10 | 10 | require_once( dirname( __FILE__ ) . '/admin.php' ); |
11 | 11 | |
12 | -if ( ! current_user_can( 'list_users' ) ) |
|
12 | +if ( ! current_user_can( 'list_users' ) ) { |
|
13 | 13 | wp_die( __( 'Cheatin’ uh?' ), 403 ); |
14 | +} |
|
14 | 15 | |
15 | 16 | $wp_list_table = _get_list_table('WP_Users_List_Table'); |
16 | 17 | $pagenum = $wp_list_table->get_pagenum(); |
@@ -42,10 +43,11 @@ discard block |
||
42 | 43 | '<ul>' . |
43 | 44 | '<li>' . __('Edit takes you to the editable profile screen for that user. You can also reach that screen by clicking on the username.') . '</li>'; |
44 | 45 | |
45 | -if ( is_multisite() ) |
|
46 | +if ( is_multisite() ) { |
|
46 | 47 | $help .= '<li>' . __( 'Remove allows you to remove a user from your site. It does not delete their content. You can also remove multiple users at once by using Bulk Actions.' ) . '</li>'; |
47 | -else |
|
48 | +} else { |
|
48 | 49 | $help .= '<li>' . __( 'Delete brings you to the Delete Users screen for confirmation, where you can permanently remove a user from your site and delete their content. You can also delete multiple users at once by using Bulk Actions.' ) . '</li>'; |
50 | +} |
|
49 | 51 | |
50 | 52 | $help .= '</ul>'; |
51 | 53 | |
@@ -100,8 +102,9 @@ discard block |
||
100 | 102 | case 'promote': |
101 | 103 | check_admin_referer('bulk-users'); |
102 | 104 | |
103 | - if ( ! current_user_can( 'promote_users' ) ) |
|
104 | - wp_die( __( 'You can’t edit that user.' ) ); |
|
105 | + if ( ! current_user_can( 'promote_users' ) ) { |
|
106 | + wp_die( __( 'You can’t edit that user.' ) ); |
|
107 | + } |
|
105 | 108 | |
106 | 109 | if ( empty($_REQUEST['users']) ) { |
107 | 110 | wp_redirect($redirect); |
@@ -109,16 +112,18 @@ discard block |
||
109 | 112 | } |
110 | 113 | |
111 | 114 | $editable_roles = get_editable_roles(); |
112 | - if ( empty( $editable_roles[$_REQUEST['new_role']] ) ) |
|
113 | - wp_die(__('You can’t give users that role.')); |
|
115 | + if ( empty( $editable_roles[$_REQUEST['new_role']] ) ) { |
|
116 | + wp_die(__('You can’t give users that role.')); |
|
117 | + } |
|
114 | 118 | |
115 | 119 | $userids = $_REQUEST['users']; |
116 | 120 | $update = 'promote'; |
117 | 121 | foreach ( $userids as $id ) { |
118 | 122 | $id = (int) $id; |
119 | 123 | |
120 | - if ( ! current_user_can('promote_user', $id) ) |
|
121 | - wp_die(__('You can’t edit that user.')); |
|
124 | + if ( ! current_user_can('promote_user', $id) ) { |
|
125 | + wp_die(__('You can’t edit that user.')); |
|
126 | + } |
|
122 | 127 | // The new role of the current user must also have the promote_users cap or be a multisite super admin |
123 | 128 | if ( $id == $current_user->ID && ! $wp_roles->role_objects[ $_REQUEST['new_role'] ]->has_cap('promote_users') |
124 | 129 | && ! ( is_multisite() && is_super_admin() ) ) { |
@@ -127,8 +132,9 @@ discard block |
||
127 | 132 | } |
128 | 133 | |
129 | 134 | // If the user doesn't already belong to the blog, bail. |
130 | - if ( is_multisite() && !is_user_member_of_blog( $id ) ) |
|
131 | - wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
135 | + if ( is_multisite() && !is_user_member_of_blog( $id ) ) { |
|
136 | + wp_die( __( 'Cheatin’ uh?' ), 403 ); |
|
137 | + } |
|
132 | 138 | |
133 | 139 | $user = get_userdata( $id ); |
134 | 140 | $user->set_role($_REQUEST['new_role']); |
@@ -138,8 +144,9 @@ discard block |
||
138 | 144 | exit(); |
139 | 145 | |
140 | 146 | case 'dodelete': |
141 | - if ( is_multisite() ) |
|
142 | - wp_die( __('User deletion is not allowed from this screen.') ); |
|
147 | + if ( is_multisite() ) { |
|
148 | + wp_die( __('User deletion is not allowed from this screen.') ); |
|
149 | + } |
|
143 | 150 | |
144 | 151 | check_admin_referer('delete-users'); |
145 | 152 | |
@@ -157,15 +164,17 @@ discard block |
||
157 | 164 | exit; |
158 | 165 | } |
159 | 166 | |
160 | - if ( ! current_user_can( 'delete_users' ) ) |
|
161 | - wp_die(__('You can’t delete users.')); |
|
167 | + if ( ! current_user_can( 'delete_users' ) ) { |
|
168 | + wp_die(__('You can’t delete users.')); |
|
169 | + } |
|
162 | 170 | |
163 | 171 | $update = 'del'; |
164 | 172 | $delete_count = 0; |
165 | 173 | |
166 | 174 | foreach ( $userids as $id ) { |
167 | - if ( ! current_user_can( 'delete_user', $id ) ) |
|
168 | - wp_die(__( 'You can’t delete that user.' ) ); |
|
175 | + if ( ! current_user_can( 'delete_user', $id ) ) { |
|
176 | + wp_die(__( 'You can’t delete that user.' ) ); |
|
177 | + } |
|
169 | 178 | |
170 | 179 | if ( $id == $current_user->ID ) { |
171 | 180 | $update = 'err_admin_del'; |
@@ -187,8 +196,9 @@ discard block |
||
187 | 196 | exit(); |
188 | 197 | |
189 | 198 | case 'delete': |
190 | - if ( is_multisite() ) |
|
191 | - wp_die( __('User deletion is not allowed from this screen.') ); |
|
199 | + if ( is_multisite() ) { |
|
200 | + wp_die( __('User deletion is not allowed from this screen.') ); |
|
201 | + } |
|
192 | 202 | |
193 | 203 | check_admin_referer('bulk-users'); |
194 | 204 | |
@@ -197,13 +207,15 @@ discard block |
||
197 | 207 | exit(); |
198 | 208 | } |
199 | 209 | |
200 | - if ( ! current_user_can( 'delete_users' ) ) |
|
201 | - $errors = new WP_Error( 'edit_users', __( 'You can’t delete users.' ) ); |
|
210 | + if ( ! current_user_can( 'delete_users' ) ) { |
|
211 | + $errors = new WP_Error( 'edit_users', __( 'You can’t delete users.' ) ); |
|
212 | + } |
|
202 | 213 | |
203 | - if ( empty($_REQUEST['users']) ) |
|
204 | - $userids = array( intval( $_REQUEST['user'] ) ); |
|
205 | - else |
|
206 | - $userids = array_map( 'intval', (array) $_REQUEST['users'] ); |
|
214 | + if ( empty($_REQUEST['users']) ) { |
|
215 | + $userids = array( intval( $_REQUEST['user'] ) ); |
|
216 | + } else { |
|
217 | + $userids = array_map( 'intval', (array) $_REQUEST['users'] ); |
|
218 | + } |
|
207 | 219 | |
208 | 220 | add_action( 'admin_head', 'delete_users_add_js' ); |
209 | 221 | |
@@ -223,8 +235,11 @@ discard block |
||
223 | 235 | |
224 | 236 | <?php if ( 1 == count( $userids ) ) : ?> |
225 | 237 | <p><?php _e( 'You have specified this user for deletion:' ); ?></p> |
226 | -<?php else : ?> |
|
227 | - <p><?php _e( 'You have specified these users for deletion:' ); ?></p> |
|
238 | +<?php else { |
|
239 | + : ?> |
|
240 | + <p><?php _e( 'You have specified these users for deletion:' ); |
|
241 | +} |
|
242 | +?></p> |
|
228 | 243 | <?php endif; ?> |
229 | 244 | |
230 | 245 | <ul> |
@@ -244,8 +259,11 @@ discard block |
||
244 | 259 | <?php if ( $go_delete ) : ?> |
245 | 260 | <?php if ( 1 == $go_delete ) : ?> |
246 | 261 | <fieldset><p><legend><?php _e( 'What should be done with content owned by this user?' ); ?></legend></p> |
247 | - <?php else : ?> |
|
248 | - <fieldset><p><legend><?php _e( 'What should be done with content owned by these users?' ); ?></legend></p> |
|
262 | + <?php else { |
|
263 | + : ?> |
|
264 | + <fieldset><p><legend><?php _e( 'What should be done with content owned by these users?' ); |
|
265 | +} |
|
266 | +?></legend></p> |
|
249 | 267 | <?php endif; ?> |
250 | 268 | <ul style="list-style:none;"> |
251 | 269 | <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" /> |
@@ -266,8 +284,11 @@ discard block |
||
266 | 284 | ?> |
267 | 285 | <input type="hidden" name="action" value="dodelete" /> |
268 | 286 | <?php submit_button( __('Confirm Deletion'), 'secondary' ); ?> |
269 | -<?php else : ?> |
|
270 | - <p><?php _e('There are no valid users selected for deletion.'); ?></p> |
|
287 | +<?php else { |
|
288 | + : ?> |
|
289 | + <p><?php _e('There are no valid users selected for deletion.'); |
|
290 | +} |
|
291 | +?></p> |
|
271 | 292 | <?php endif; ?> |
272 | 293 | </div> |
273 | 294 | </form> |
@@ -278,16 +299,18 @@ discard block |
||
278 | 299 | case 'doremove': |
279 | 300 | check_admin_referer('remove-users'); |
280 | 301 | |
281 | - if ( ! is_multisite() ) |
|
282 | - wp_die( __( 'You can’t remove users.' ) ); |
|
302 | + if ( ! is_multisite() ) { |
|
303 | + wp_die( __( 'You can’t remove users.' ) ); |
|
304 | + } |
|
283 | 305 | |
284 | 306 | if ( empty($_REQUEST['users']) ) { |
285 | 307 | wp_redirect($redirect); |
286 | 308 | exit; |
287 | 309 | } |
288 | 310 | |
289 | - if ( ! current_user_can( 'remove_users' ) ) |
|
290 | - wp_die( __( 'You can’t remove users.' ) ); |
|
311 | + if ( ! current_user_can( 'remove_users' ) ) { |
|
312 | + wp_die( __( 'You can’t remove users.' ) ); |
|
313 | + } |
|
291 | 314 | |
292 | 315 | $userids = $_REQUEST['users']; |
293 | 316 | |
@@ -313,21 +336,24 @@ discard block |
||
313 | 336 | |
314 | 337 | check_admin_referer('bulk-users'); |
315 | 338 | |
316 | - if ( ! is_multisite() ) |
|
317 | - wp_die( __( 'You can’t remove users.' ) ); |
|
339 | + if ( ! is_multisite() ) { |
|
340 | + wp_die( __( 'You can’t remove users.' ) ); |
|
341 | + } |
|
318 | 342 | |
319 | 343 | if ( empty($_REQUEST['users']) && empty($_REQUEST['user']) ) { |
320 | 344 | wp_redirect($redirect); |
321 | 345 | exit(); |
322 | 346 | } |
323 | 347 | |
324 | - if ( !current_user_can('remove_users') ) |
|
325 | - $error = new WP_Error('edit_users', __('You can’t remove users.')); |
|
348 | + if ( !current_user_can('remove_users') ) { |
|
349 | + $error = new WP_Error('edit_users', __('You can’t remove users.')); |
|
350 | + } |
|
326 | 351 | |
327 | - if ( empty($_REQUEST['users']) ) |
|
328 | - $userids = array(intval($_REQUEST['user'])); |
|
329 | - else |
|
330 | - $userids = $_REQUEST['users']; |
|
352 | + if ( empty($_REQUEST['users']) ) { |
|
353 | + $userids = array(intval($_REQUEST['user'])); |
|
354 | + } else { |
|
355 | + $userids = $_REQUEST['users']; |
|
356 | + } |
|
331 | 357 | |
332 | 358 | include( ABSPATH . 'wp-admin/admin-header.php' ); |
333 | 359 | ?> |
@@ -340,8 +366,11 @@ discard block |
||
340 | 366 | |
341 | 367 | <?php if ( 1 == count( $userids ) ) : ?> |
342 | 368 | <p><?php _e( 'You have specified this user for removal:' ); ?></p> |
343 | -<?php else : ?> |
|
344 | - <p><?php _e( 'You have specified these users for removal:' ); ?></p> |
|
369 | +<?php else { |
|
370 | + : ?> |
|
371 | + <p><?php _e( 'You have specified these users for removal:' ); |
|
372 | +} |
|
373 | +?></p> |
|
345 | 374 | <?php endif; ?> |
346 | 375 | |
347 | 376 | <ul> |
@@ -364,8 +393,11 @@ discard block |
||
364 | 393 | <?php if ( $go_remove ) : ?> |
365 | 394 | <input type="hidden" name="action" value="doremove" /> |
366 | 395 | <?php submit_button( __('Confirm Removal'), 'secondary' ); ?> |
367 | -<?php else : ?> |
|
368 | - <p><?php _e('There are no valid users selected for removal.'); ?></p> |
|
396 | +<?php else { |
|
397 | + : ?> |
|
398 | + <p><?php _e('There are no valid users selected for removal.'); |
|
399 | +} |
|
400 | +?></p> |
|
369 | 401 | <?php endif; ?> |
370 | 402 | </div> |
371 | 403 | </form> |
@@ -436,17 +468,19 @@ discard block |
||
436 | 468 | <div class="error"> |
437 | 469 | <ul> |
438 | 470 | <?php |
439 | - foreach ( $errors->get_error_messages() as $err ) |
|
440 | - echo "<li>$err</li>\n"; |
|
471 | + foreach ( $errors->get_error_messages() as $err ) { |
|
472 | + echo "<li>$err</li>\n"; |
|
473 | + } |
|
441 | 474 | ?> |
442 | 475 | </ul> |
443 | 476 | </div> |
444 | 477 | <?php endif; |
445 | 478 | |
446 | 479 | if ( ! empty($messages) ) { |
447 | - foreach ( $messages as $msg ) |
|
448 | - echo $msg; |
|
449 | -} ?> |
|
480 | + foreach ( $messages as $msg ) { |
|
481 | + echo $msg; |
|
482 | + } |
|
483 | + } ?> |
|
450 | 484 | |
451 | 485 | <div class="wrap"> |
452 | 486 | <h1> |
@@ -458,8 +492,10 @@ discard block |
||
458 | 492 | <a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a> |
459 | 493 | <?php } |
460 | 494 | |
461 | -if ( $usersearch ) |
|
462 | - printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( $usersearch ) ); ?> |
|
495 | +if ( $usersearch ) { |
|
496 | + printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( $usersearch ) ); |
|
497 | +} |
|
498 | +?> |
|
463 | 499 | </h1> |
464 | 500 | |
465 | 501 | <?php $wp_list_table->views(); ?> |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | ) ); |
51 | 51 | |
52 | 52 | get_current_screen()->set_help_sidebar( |
53 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
54 | - '<p>' . __('<a href="https://codex.wordpress.org/Users_Your_Profile_Screen" target="_blank">Documentation on User Profiles</a>') . '</p>' . |
|
55 | - '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
|
53 | + '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
54 | + '<p>' . __('<a href="https://codex.wordpress.org/Users_Your_Profile_Screen" target="_blank">Documentation on User Profiles</a>') . '</p>' . |
|
55 | + '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
|
56 | 56 | ); |
57 | 57 | |
58 | 58 | $wp_http_referer = remove_query_arg(array('update', 'delete_count'), $wp_http_referer ); |
@@ -276,12 +276,12 @@ discard block |
||
276 | 276 | </tr> |
277 | 277 | <?php |
278 | 278 | /** |
279 | - * Fires at the end of the 'Personal Options' settings table on the user editing screen. |
|
280 | - * |
|
281 | - * @since 2.7.0 |
|
282 | - * |
|
283 | - * @param WP_User $profileuser The current WP_User object. |
|
284 | - */ |
|
279 | + * Fires at the end of the 'Personal Options' settings table on the user editing screen. |
|
280 | + * |
|
281 | + * @since 2.7.0 |
|
282 | + * |
|
283 | + * @param WP_User $profileuser The current WP_User object. |
|
284 | + */ |
|
285 | 285 | do_action( 'personal_options', $profileuser ); |
286 | 286 | ?> |
287 | 287 | |
@@ -564,17 +564,17 @@ discard block |
||
564 | 564 | |
565 | 565 | <?php |
566 | 566 | /** |
567 | - * Filter whether to display additional capabilities for the user. |
|
568 | - * |
|
569 | - * The 'Additional Capabilities' section will only be enabled if |
|
570 | - * the number of the user's capabilities exceeds their number of |
|
571 | - * of roles. |
|
572 | - * |
|
573 | - * @since 2.8.0 |
|
574 | - * |
|
575 | - * @param bool $enable Whether to display the capabilities. Default true. |
|
576 | - * @param WP_User $profileuser The current WP_User object. |
|
577 | - */ |
|
567 | + * Filter whether to display additional capabilities for the user. |
|
568 | + * |
|
569 | + * The 'Additional Capabilities' section will only be enabled if |
|
570 | + * the number of the user's capabilities exceeds their number of |
|
571 | + * of roles. |
|
572 | + * |
|
573 | + * @since 2.8.0 |
|
574 | + * |
|
575 | + * @param bool $enable Whether to display the capabilities. Default true. |
|
576 | + * @param WP_User $profileuser The current WP_User object. |
|
577 | + */ |
|
578 | 578 | if ( count( $profileuser->caps ) > count( $profileuser->roles ) |
579 | 579 | && apply_filters( 'additional_capabilities_display', true, $profileuser ) |
580 | 580 | ) : ?> |
@@ -7,57 +7,57 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | /** WordPress Administration Bootstrap */ |
10 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
10 | +require_once(dirname(__FILE__).'/admin.php'); |
|
11 | 11 | |
12 | -wp_reset_vars( array( 'action', 'user_id', 'wp_http_referer' ) ); |
|
12 | +wp_reset_vars(array('action', 'user_id', 'wp_http_referer')); |
|
13 | 13 | |
14 | 14 | $user_id = (int) $user_id; |
15 | 15 | $current_user = wp_get_current_user(); |
16 | -if ( ! defined( 'IS_PROFILE_PAGE' ) ) |
|
17 | - define( 'IS_PROFILE_PAGE', ( $user_id == $current_user->ID ) ); |
|
16 | +if ( ! defined('IS_PROFILE_PAGE')) |
|
17 | + define('IS_PROFILE_PAGE', ($user_id == $current_user->ID)); |
|
18 | 18 | |
19 | -if ( ! $user_id && IS_PROFILE_PAGE ) |
|
19 | +if ( ! $user_id && IS_PROFILE_PAGE) |
|
20 | 20 | $user_id = $current_user->ID; |
21 | -elseif ( ! $user_id && ! IS_PROFILE_PAGE ) |
|
22 | - wp_die(__( 'Invalid user ID.' ) ); |
|
23 | -elseif ( ! get_userdata( $user_id ) ) |
|
24 | - wp_die( __('Invalid user ID.') ); |
|
21 | +elseif ( ! $user_id && ! IS_PROFILE_PAGE) |
|
22 | + wp_die(__('Invalid user ID.')); |
|
23 | +elseif ( ! get_userdata($user_id)) |
|
24 | + wp_die(__('Invalid user ID.')); |
|
25 | 25 | |
26 | 26 | wp_enqueue_script('user-profile'); |
27 | 27 | |
28 | 28 | $title = IS_PROFILE_PAGE ? __('Profile') : __('Edit User'); |
29 | -if ( current_user_can('edit_users') && !IS_PROFILE_PAGE ) |
|
29 | +if (current_user_can('edit_users') && ! IS_PROFILE_PAGE) |
|
30 | 30 | $submenu_file = 'users.php'; |
31 | 31 | else |
32 | 32 | $submenu_file = 'profile.php'; |
33 | 33 | |
34 | -if ( current_user_can('edit_users') && !is_user_admin() ) |
|
34 | +if (current_user_can('edit_users') && ! is_user_admin()) |
|
35 | 35 | $parent_file = 'users.php'; |
36 | 36 | else |
37 | 37 | $parent_file = 'profile.php'; |
38 | 38 | |
39 | -$profile_help = '<p>' . __('Your profile contains information about you (your “account”) as well as some personal options related to using WordPress.') . '</p>' . |
|
40 | - '<p>' . __('You can change your password, turn on keyboard shortcuts, change the color scheme of your WordPress administration screens, and turn off the WYSIWYG (Visual) editor, among other things. You can hide the Toolbar (formerly called the Admin Bar) from the front end of your site, however it cannot be disabled on the admin screens.') . '</p>' . |
|
41 | - '<p>' . __('Your username cannot be changed, but you can use other fields to enter your real name or a nickname, and change which name to display on your posts.') . '</p>' . |
|
42 | - '<p>' . __( 'You can log out of other devices, such as your phone or a public computer, by clicking the Log Out Everywhere Else button.' ) . '</p>' . |
|
43 | - '<p>' . __('Required fields are indicated; the rest are optional. Profile information will only be displayed if your theme is set up to do so.') . '</p>' . |
|
44 | - '<p>' . __('Remember to click the Update Profile button when you are finished.') . '</p>'; |
|
39 | +$profile_help = '<p>'.__('Your profile contains information about you (your “account”) as well as some personal options related to using WordPress.').'</p>'. |
|
40 | + '<p>'.__('You can change your password, turn on keyboard shortcuts, change the color scheme of your WordPress administration screens, and turn off the WYSIWYG (Visual) editor, among other things. You can hide the Toolbar (formerly called the Admin Bar) from the front end of your site, however it cannot be disabled on the admin screens.').'</p>'. |
|
41 | + '<p>'.__('Your username cannot be changed, but you can use other fields to enter your real name or a nickname, and change which name to display on your posts.').'</p>'. |
|
42 | + '<p>'.__('You can log out of other devices, such as your phone or a public computer, by clicking the Log Out Everywhere Else button.').'</p>'. |
|
43 | + '<p>'.__('Required fields are indicated; the rest are optional. Profile information will only be displayed if your theme is set up to do so.').'</p>'. |
|
44 | + '<p>'.__('Remember to click the Update Profile button when you are finished.').'</p>'; |
|
45 | 45 | |
46 | -get_current_screen()->add_help_tab( array( |
|
46 | +get_current_screen()->add_help_tab(array( |
|
47 | 47 | 'id' => 'overview', |
48 | 48 | 'title' => __('Overview'), |
49 | 49 | 'content' => $profile_help, |
50 | -) ); |
|
50 | +)); |
|
51 | 51 | |
52 | 52 | get_current_screen()->set_help_sidebar( |
53 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
54 | - '<p>' . __('<a href="https://codex.wordpress.org/Users_Your_Profile_Screen" target="_blank">Documentation on User Profiles</a>') . '</p>' . |
|
55 | - '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
|
53 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
54 | + '<p>'.__('<a href="https://codex.wordpress.org/Users_Your_Profile_Screen" target="_blank">Documentation on User Profiles</a>').'</p>'. |
|
55 | + '<p>'.__('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>').'</p>' |
|
56 | 56 | ); |
57 | 57 | |
58 | -$wp_http_referer = remove_query_arg(array('update', 'delete_count'), $wp_http_referer ); |
|
58 | +$wp_http_referer = remove_query_arg(array('update', 'delete_count'), $wp_http_referer); |
|
59 | 59 | |
60 | -$user_can_edit = current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ); |
|
60 | +$user_can_edit = current_user_can('edit_posts') || current_user_can('edit_pages'); |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Optional SSL preference that can be turned on by hooking to the 'personal_options' action. |
@@ -88,43 +88,43 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @param bool $allow Whether to allow editing of any user. Default true. |
90 | 90 | */ |
91 | -if ( is_multisite() |
|
92 | - && ! current_user_can( 'manage_network_users' ) |
|
91 | +if (is_multisite() |
|
92 | + && ! current_user_can('manage_network_users') |
|
93 | 93 | && $user_id != $current_user->ID |
94 | - && ! apply_filters( 'enable_edit_any_user_configuration', true ) |
|
94 | + && ! apply_filters('enable_edit_any_user_configuration', true) |
|
95 | 95 | ) { |
96 | - wp_die( __( 'You do not have permission to edit this user.' ) ); |
|
96 | + wp_die(__('You do not have permission to edit this user.')); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | // Execute confirmed email change. See send_confirmation_on_profile_email(). |
100 | -if ( is_multisite() && IS_PROFILE_PAGE && isset( $_GET[ 'newuseremail' ] ) && $current_user->ID ) { |
|
101 | - $new_email = get_option( $current_user->ID . '_new_email' ); |
|
102 | - if ( $new_email[ 'hash' ] == $_GET[ 'newuseremail' ] ) { |
|
100 | +if (is_multisite() && IS_PROFILE_PAGE && isset($_GET['newuseremail']) && $current_user->ID) { |
|
101 | + $new_email = get_option($current_user->ID.'_new_email'); |
|
102 | + if ($new_email['hash'] == $_GET['newuseremail']) { |
|
103 | 103 | $user = new stdClass; |
104 | 104 | $user->ID = $current_user->ID; |
105 | - $user->user_email = esc_html( trim( $new_email[ 'newemail' ] ) ); |
|
106 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) ) |
|
107 | - $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) ); |
|
108 | - wp_update_user( $user ); |
|
109 | - delete_option( $current_user->ID . '_new_email' ); |
|
110 | - wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) ); |
|
105 | + $user->user_email = esc_html(trim($new_email['newemail'])); |
|
106 | + if ($wpdb->get_var($wpdb->prepare("SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login))) |
|
107 | + $wpdb->query($wpdb->prepare("UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login)); |
|
108 | + wp_update_user($user); |
|
109 | + delete_option($current_user->ID.'_new_email'); |
|
110 | + wp_redirect(add_query_arg(array('updated' => 'true'), self_admin_url('profile.php'))); |
|
111 | 111 | die(); |
112 | 112 | } |
113 | -} elseif ( is_multisite() && IS_PROFILE_PAGE && !empty( $_GET['dismiss'] ) && $current_user->ID . '_new_email' == $_GET['dismiss'] ) { |
|
114 | - delete_option( $current_user->ID . '_new_email' ); |
|
115 | - wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) ); |
|
113 | +} elseif (is_multisite() && IS_PROFILE_PAGE && ! empty($_GET['dismiss']) && $current_user->ID.'_new_email' == $_GET['dismiss']) { |
|
114 | + delete_option($current_user->ID.'_new_email'); |
|
115 | + wp_redirect(add_query_arg(array('updated' => 'true'), self_admin_url('profile.php'))); |
|
116 | 116 | die(); |
117 | 117 | } |
118 | 118 | |
119 | 119 | switch ($action) { |
120 | 120 | case 'update': |
121 | 121 | |
122 | -check_admin_referer('update-user_' . $user_id); |
|
122 | +check_admin_referer('update-user_'.$user_id); |
|
123 | 123 | |
124 | -if ( !current_user_can('edit_user', $user_id) ) |
|
124 | +if ( ! current_user_can('edit_user', $user_id)) |
|
125 | 125 | wp_die(__('You do not have permission to edit this user.')); |
126 | 126 | |
127 | -if ( IS_PROFILE_PAGE ) { |
|
127 | +if (IS_PROFILE_PAGE) { |
|
128 | 128 | /** |
129 | 129 | * Fires before the page loads on the 'Your Profile' editing screen. |
130 | 130 | * |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @param int $user_id The user ID. |
136 | 136 | */ |
137 | - do_action( 'personal_options_update', $user_id ); |
|
137 | + do_action('personal_options_update', $user_id); |
|
138 | 138 | } else { |
139 | 139 | /** |
140 | 140 | * Fires before the page loads on the 'Edit User' screen. |
@@ -143,29 +143,29 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @param int $user_id The user ID. |
145 | 145 | */ |
146 | - do_action( 'edit_user_profile_update', $user_id ); |
|
146 | + do_action('edit_user_profile_update', $user_id); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | // Update the email address in signups, if present. |
150 | -if ( is_multisite() ) { |
|
151 | - $user = get_userdata( $user_id ); |
|
150 | +if (is_multisite()) { |
|
151 | + $user = get_userdata($user_id); |
|
152 | 152 | |
153 | - if ( $user->user_login && isset( $_POST[ 'email' ] ) && is_email( $_POST[ 'email' ] ) && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $user->user_login ) ) ) { |
|
154 | - $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $_POST[ 'email' ], $user_login ) ); |
|
153 | + if ($user->user_login && isset($_POST['email']) && is_email($_POST['email']) && $wpdb->get_var($wpdb->prepare("SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $user->user_login))) { |
|
154 | + $wpdb->query($wpdb->prepare("UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $_POST['email'], $user_login)); |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
158 | 158 | // Update the user. |
159 | -$errors = edit_user( $user_id ); |
|
159 | +$errors = edit_user($user_id); |
|
160 | 160 | |
161 | 161 | // Grant or revoke super admin status if requested. |
162 | -if ( is_multisite() && is_network_admin() && !IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) && empty( $_POST['super_admin'] ) == is_super_admin( $user_id ) ) { |
|
163 | - empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id ); |
|
162 | +if (is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can('manage_network_options') && ! isset($super_admins) && empty($_POST['super_admin']) == is_super_admin($user_id)) { |
|
163 | + empty($_POST['super_admin']) ? revoke_super_admin($user_id) : grant_super_admin($user_id); |
|
164 | 164 | } |
165 | 165 | |
166 | -if ( !is_wp_error( $errors ) ) { |
|
167 | - $redirect = add_query_arg( 'updated', true, get_edit_user_link( $user_id ) ); |
|
168 | - if ( $wp_http_referer ) |
|
166 | +if ( ! is_wp_error($errors)) { |
|
167 | + $redirect = add_query_arg('updated', true, get_edit_user_link($user_id)); |
|
168 | + if ($wp_http_referer) |
|
169 | 169 | $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect); |
170 | 170 | wp_redirect($redirect); |
171 | 171 | exit; |
@@ -174,55 +174,55 @@ discard block |
||
174 | 174 | default: |
175 | 175 | $profileuser = get_user_to_edit($user_id); |
176 | 176 | |
177 | -if ( !current_user_can('edit_user', $user_id) ) |
|
177 | +if ( ! current_user_can('edit_user', $user_id)) |
|
178 | 178 | wp_die(__('You do not have permission to edit this user.')); |
179 | 179 | |
180 | -$sessions = WP_Session_Tokens::get_instance( $profileuser->ID ); |
|
180 | +$sessions = WP_Session_Tokens::get_instance($profileuser->ID); |
|
181 | 181 | |
182 | -include(ABSPATH . 'wp-admin/admin-header.php'); |
|
182 | +include(ABSPATH.'wp-admin/admin-header.php'); |
|
183 | 183 | ?> |
184 | 184 | |
185 | -<?php if ( !IS_PROFILE_PAGE && is_super_admin( $profileuser->ID ) && current_user_can( 'manage_network_options' ) ) { ?> |
|
185 | +<?php if ( ! IS_PROFILE_PAGE && is_super_admin($profileuser->ID) && current_user_can('manage_network_options')) { ?> |
|
186 | 186 | <div class="updated"><p><strong><?php _e('Important:'); ?></strong> <?php _e('This user has super admin privileges.'); ?></p></div> |
187 | 187 | <?php } ?> |
188 | -<?php if ( isset($_GET['updated']) ) : ?> |
|
188 | +<?php if (isset($_GET['updated'])) : ?> |
|
189 | 189 | <div id="message" class="updated notice is-dismissible"> |
190 | - <?php if ( IS_PROFILE_PAGE ) : ?> |
|
190 | + <?php if (IS_PROFILE_PAGE) : ?> |
|
191 | 191 | <p><strong><?php _e('Profile updated.') ?></strong></p> |
192 | 192 | <?php else: ?> |
193 | 193 | <p><strong><?php _e('User updated.') ?></strong></p> |
194 | 194 | <?php endif; ?> |
195 | - <?php if ( $wp_http_referer && !IS_PROFILE_PAGE ) : ?> |
|
196 | - <p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php _e('← Back to Users'); ?></a></p> |
|
195 | + <?php if ($wp_http_referer && ! IS_PROFILE_PAGE) : ?> |
|
196 | + <p><a href="<?php echo esc_url($wp_http_referer); ?>"><?php _e('← Back to Users'); ?></a></p> |
|
197 | 197 | <?php endif; ?> |
198 | 198 | </div> |
199 | 199 | <?php endif; ?> |
200 | -<?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?> |
|
201 | -<div class="error"><p><?php echo implode( "</p>\n<p>", $errors->get_error_messages() ); ?></p></div> |
|
200 | +<?php if (isset($errors) && is_wp_error($errors)) : ?> |
|
201 | +<div class="error"><p><?php echo implode("</p>\n<p>", $errors->get_error_messages()); ?></p></div> |
|
202 | 202 | <?php endif; ?> |
203 | 203 | |
204 | 204 | <div class="wrap" id="profile-page"> |
205 | 205 | <h1> |
206 | 206 | <?php |
207 | -echo esc_html( $title ); |
|
208 | -if ( ! IS_PROFILE_PAGE ) { |
|
209 | - if ( current_user_can( 'create_users' ) ) { ?> |
|
210 | - <a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a> |
|
211 | - <?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?> |
|
212 | - <a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a> |
|
207 | +echo esc_html($title); |
|
208 | +if ( ! IS_PROFILE_PAGE) { |
|
209 | + if (current_user_can('create_users')) { ?> |
|
210 | + <a href="user-new.php" class="page-title-action"><?php echo esc_html_x('Add New', 'user'); ?></a> |
|
211 | + <?php } elseif (is_multisite() && current_user_can('promote_users')) { ?> |
|
212 | + <a href="user-new.php" class="page-title-action"><?php echo esc_html_x('Add Existing', 'user'); ?></a> |
|
213 | 213 | <?php } |
214 | 214 | } ?> |
215 | 215 | </h1> |
216 | -<form id="your-profile" action="<?php echo esc_url( self_admin_url( IS_PROFILE_PAGE ? 'profile.php' : 'user-edit.php' ) ); ?>" method="post" novalidate="novalidate"<?php |
|
216 | +<form id="your-profile" action="<?php echo esc_url(self_admin_url(IS_PROFILE_PAGE ? 'profile.php' : 'user-edit.php')); ?>" method="post" novalidate="novalidate"<?php |
|
217 | 217 | /** |
218 | 218 | * Fires inside the your-profile form tag on the user editing screen. |
219 | 219 | * |
220 | 220 | * @since 3.0.0 |
221 | 221 | */ |
222 | - do_action( 'user_edit_form_tag' ); |
|
222 | + do_action('user_edit_form_tag'); |
|
223 | 223 | ?>> |
224 | -<?php wp_nonce_field('update-user_' . $user_id) ?> |
|
225 | -<?php if ( $wp_http_referer ) : ?> |
|
224 | +<?php wp_nonce_field('update-user_'.$user_id) ?> |
|
225 | +<?php if ($wp_http_referer) : ?> |
|
226 | 226 | <input type="hidden" name="wp_http_referer" value="<?php echo esc_url($wp_http_referer); ?>" /> |
227 | 227 | <?php endif; ?> |
228 | 228 | <p> |
@@ -233,13 +233,13 @@ discard block |
||
233 | 233 | <h3><?php _e('Personal Options'); ?></h3> |
234 | 234 | |
235 | 235 | <table class="form-table"> |
236 | -<?php if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : ?> |
|
236 | +<?php if ( ! (IS_PROFILE_PAGE && ! $user_can_edit)) : ?> |
|
237 | 237 | <tr class="user-rich-editing-wrap"> |
238 | - <th scope="row"><?php _e( 'Visual Editor' ); ?></th> |
|
239 | - <td><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php if ( ! empty( $profileuser->rich_editing ) ) checked( 'false', $profileuser->rich_editing ); ?> /> <?php _e( 'Disable the visual editor when writing' ); ?></label></td> |
|
238 | + <th scope="row"><?php _e('Visual Editor'); ?></th> |
|
239 | + <td><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php if ( ! empty($profileuser->rich_editing)) checked('false', $profileuser->rich_editing); ?> /> <?php _e('Disable the visual editor when writing'); ?></label></td> |
|
240 | 240 | </tr> |
241 | 241 | <?php endif; ?> |
242 | -<?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?> |
|
242 | +<?php if (count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker')) : ?> |
|
243 | 243 | <tr class="user-admin-color-wrap"> |
244 | 244 | <th scope="row"><?php _e('Admin Color Scheme')?></th> |
245 | 245 | <td><?php |
@@ -254,23 +254,23 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @param int $user_id The user ID. |
256 | 256 | */ |
257 | - do_action( 'admin_color_scheme_picker', $user_id ); |
|
257 | + do_action('admin_color_scheme_picker', $user_id); |
|
258 | 258 | ?></td> |
259 | 259 | </tr> |
260 | 260 | <?php |
261 | 261 | endif; // $_wp_admin_css_colors |
262 | -if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) : ?> |
|
262 | +if ( ! (IS_PROFILE_PAGE && ! $user_can_edit)) : ?> |
|
263 | 263 | <tr class="user-comment-shortcuts-wrap"> |
264 | -<th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th> |
|
265 | -<td><label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php if ( ! empty( $profileuser->comment_shortcuts ) ) checked( 'true', $profileuser->comment_shortcuts ); ?> /> <?php _e('Enable keyboard shortcuts for comment moderation.'); ?></label> <?php _e('<a href="https://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">More information</a>'); ?></td> |
|
264 | +<th scope="row"><?php _e('Keyboard Shortcuts'); ?></th> |
|
265 | +<td><label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php if ( ! empty($profileuser->comment_shortcuts)) checked('true', $profileuser->comment_shortcuts); ?> /> <?php _e('Enable keyboard shortcuts for comment moderation.'); ?></label> <?php _e('<a href="https://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">More information</a>'); ?></td> |
|
266 | 266 | </tr> |
267 | 267 | <?php endif; ?> |
268 | 268 | <tr class="show-admin-bar user-admin-bar-front-wrap"> |
269 | -<th scope="row"><?php _e( 'Toolbar' ); ?></th> |
|
269 | +<th scope="row"><?php _e('Toolbar'); ?></th> |
|
270 | 270 | <td><fieldset><legend class="screen-reader-text"><span><?php _e('Toolbar') ?></span></legend> |
271 | 271 | <label for="admin_bar_front"> |
272 | -<input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1"<?php checked( _get_admin_bar_pref( 'front', $profileuser->ID ) ); ?> /> |
|
273 | -<?php _e( 'Show Toolbar when viewing site' ); ?></label><br /> |
|
272 | +<input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1"<?php checked(_get_admin_bar_pref('front', $profileuser->ID)); ?> /> |
|
273 | +<?php _e('Show Toolbar when viewing site'); ?></label><br /> |
|
274 | 274 | </fieldset> |
275 | 275 | </td> |
276 | 276 | </tr> |
@@ -282,12 +282,12 @@ discard block |
||
282 | 282 | * |
283 | 283 | * @param WP_User $profileuser The current WP_User object. |
284 | 284 | */ |
285 | -do_action( 'personal_options', $profileuser ); |
|
285 | +do_action('personal_options', $profileuser); |
|
286 | 286 | ?> |
287 | 287 | |
288 | 288 | </table> |
289 | 289 | <?php |
290 | - if ( IS_PROFILE_PAGE ) { |
|
290 | + if (IS_PROFILE_PAGE) { |
|
291 | 291 | /** |
292 | 292 | * Fires after the 'Personal Options' settings table on the 'Your Profile' editing screen. |
293 | 293 | * |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @param WP_User $profileuser The current WP_User object. |
299 | 299 | */ |
300 | - do_action( 'profile_personal_options', $profileuser ); |
|
300 | + do_action('profile_personal_options', $profileuser); |
|
301 | 301 | } |
302 | 302 | ?> |
303 | 303 | |
@@ -309,33 +309,33 @@ discard block |
||
309 | 309 | <td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr($profileuser->user_login); ?>" disabled="disabled" class="regular-text" /> <span class="description"><?php _e('Usernames cannot be changed.'); ?></span></td> |
310 | 310 | </tr> |
311 | 311 | |
312 | -<?php if ( !IS_PROFILE_PAGE && !is_network_admin() ) : ?> |
|
312 | +<?php if ( ! IS_PROFILE_PAGE && ! is_network_admin()) : ?> |
|
313 | 313 | <tr class="user-role-wrap"><th><label for="role"><?php _e('Role') ?></label></th> |
314 | 314 | <td><select name="role" id="role"> |
315 | 315 | <?php |
316 | 316 | // Compare user role against currently editable roles |
317 | -$user_roles = array_intersect( array_values( $profileuser->roles ), array_keys( get_editable_roles() ) ); |
|
318 | -$user_role = reset( $user_roles ); |
|
317 | +$user_roles = array_intersect(array_values($profileuser->roles), array_keys(get_editable_roles())); |
|
318 | +$user_role = reset($user_roles); |
|
319 | 319 | |
320 | 320 | // print the full list of roles with the primary one selected. |
321 | 321 | wp_dropdown_roles($user_role); |
322 | 322 | |
323 | 323 | // print the 'no role' option. Make it selected if the user has no role yet. |
324 | -if ( $user_role ) |
|
325 | - echo '<option value="">' . __('— No role for this site —') . '</option>'; |
|
324 | +if ($user_role) |
|
325 | + echo '<option value="">'.__('— No role for this site —').'</option>'; |
|
326 | 326 | else |
327 | - echo '<option value="" selected="selected">' . __('— No role for this site —') . '</option>'; |
|
327 | + echo '<option value="" selected="selected">'.__('— No role for this site —').'</option>'; |
|
328 | 328 | ?> |
329 | 329 | </select></td></tr> |
330 | 330 | <?php endif; //!IS_PROFILE_PAGE |
331 | 331 | |
332 | -if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) ) { ?> |
|
332 | +if (is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can('manage_network_options') && ! isset($super_admins)) { ?> |
|
333 | 333 | <tr class="user-super-admin-wrap"><th><?php _e('Super Admin'); ?></th> |
334 | 334 | <td> |
335 | -<?php if ( $profileuser->user_email != get_site_option( 'admin_email' ) || ! is_super_admin( $profileuser->ID ) ) : ?> |
|
336 | -<p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profileuser->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.' ); ?></label></p> |
|
335 | +<?php if ($profileuser->user_email != get_site_option('admin_email') || ! is_super_admin($profileuser->ID)) : ?> |
|
336 | +<p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked(is_super_admin($profileuser->ID)); ?> /> <?php _e('Grant this user super admin privileges for the Network.'); ?></label></p> |
|
337 | 337 | <?php else : ?> |
338 | -<p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p> |
|
338 | +<p><?php _e('Super admin privileges cannot be removed because this user has the network admin email.'); ?></p> |
|
339 | 339 | <?php endif; ?> |
340 | 340 | </td></tr> |
341 | 341 | <?php } ?> |
@@ -364,26 +364,26 @@ discard block |
||
364 | 364 | $public_display['display_nickname'] = $profileuser->nickname; |
365 | 365 | $public_display['display_username'] = $profileuser->user_login; |
366 | 366 | |
367 | - if ( !empty($profileuser->first_name) ) |
|
367 | + if ( ! empty($profileuser->first_name)) |
|
368 | 368 | $public_display['display_firstname'] = $profileuser->first_name; |
369 | 369 | |
370 | - if ( !empty($profileuser->last_name) ) |
|
370 | + if ( ! empty($profileuser->last_name)) |
|
371 | 371 | $public_display['display_lastname'] = $profileuser->last_name; |
372 | 372 | |
373 | - if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
374 | - $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
375 | - $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
373 | + if ( ! empty($profileuser->first_name) && ! empty($profileuser->last_name)) { |
|
374 | + $public_display['display_firstlast'] = $profileuser->first_name.' '.$profileuser->last_name; |
|
375 | + $public_display['display_lastfirst'] = $profileuser->last_name.' '.$profileuser->first_name; |
|
376 | 376 | } |
377 | 377 | |
378 | - if ( !in_array( $profileuser->display_name, $public_display ) ) // Only add this if it isn't duplicated elsewhere |
|
379 | - $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display; |
|
378 | + if ( ! in_array($profileuser->display_name, $public_display)) // Only add this if it isn't duplicated elsewhere |
|
379 | + $public_display = array('display_displayname' => $profileuser->display_name) + $public_display; |
|
380 | 380 | |
381 | - $public_display = array_map( 'trim', $public_display ); |
|
382 | - $public_display = array_unique( $public_display ); |
|
381 | + $public_display = array_map('trim', $public_display); |
|
382 | + $public_display = array_unique($public_display); |
|
383 | 383 | |
384 | - foreach ( $public_display as $id => $item ) { |
|
384 | + foreach ($public_display as $id => $item) { |
|
385 | 385 | ?> |
386 | - <option <?php selected( $profileuser->display_name, $item ); ?>><?php echo $item; ?></option> |
|
386 | + <option <?php selected($profileuser->display_name, $item); ?>><?php echo $item; ?></option> |
|
387 | 387 | <?php |
388 | 388 | } |
389 | 389 | ?> |
@@ -397,16 +397,16 @@ discard block |
||
397 | 397 | <table class="form-table"> |
398 | 398 | <tr class="user-email-wrap"> |
399 | 399 | <th><label for="email"><?php _e('E-mail'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th> |
400 | - <td><input type="email" name="email" id="email" value="<?php echo esc_attr( $profileuser->user_email ) ?>" class="regular-text ltr" /> |
|
400 | + <td><input type="email" name="email" id="email" value="<?php echo esc_attr($profileuser->user_email) ?>" class="regular-text ltr" /> |
|
401 | 401 | <?php |
402 | - $new_email = get_option( $current_user->ID . '_new_email' ); |
|
403 | - if ( $new_email && $new_email['newemail'] != $current_user->user_email && $profileuser->ID == $current_user->ID ) : ?> |
|
402 | + $new_email = get_option($current_user->ID.'_new_email'); |
|
403 | + if ($new_email && $new_email['newemail'] != $current_user->user_email && $profileuser->ID == $current_user->ID) : ?> |
|
404 | 404 | <div class="updated inline"> |
405 | 405 | <p><?php |
406 | 406 | printf( |
407 | - __( 'There is a pending change of your e-mail to %1$s. <a href="%2$s">Cancel</a>' ), |
|
408 | - '<code>' . $new_email['newemail'] . '</code>', |
|
409 | - esc_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ) ) |
|
407 | + __('There is a pending change of your e-mail to %1$s. <a href="%2$s">Cancel</a>'), |
|
408 | + '<code>'.$new_email['newemail'].'</code>', |
|
409 | + esc_url(self_admin_url('profile.php?dismiss='.$current_user->ID.'_new_email')) |
|
410 | 410 | ); ?></p> |
411 | 411 | </div> |
412 | 412 | <?php endif; ?> |
@@ -415,11 +415,11 @@ discard block |
||
415 | 415 | |
416 | 416 | <tr class="user-url-wrap"> |
417 | 417 | <th><label for="url"><?php _e('Website') ?></label></th> |
418 | - <td><input type="url" name="url" id="url" value="<?php echo esc_attr( $profileuser->user_url ) ?>" class="regular-text code" /></td> |
|
418 | + <td><input type="url" name="url" id="url" value="<?php echo esc_attr($profileuser->user_url) ?>" class="regular-text code" /></td> |
|
419 | 419 | </tr> |
420 | 420 | |
421 | 421 | <?php |
422 | - foreach ( wp_get_user_contact_methods( $profileuser ) as $name => $desc ) { |
|
422 | + foreach (wp_get_user_contact_methods($profileuser) as $name => $desc) { |
|
423 | 423 | ?> |
424 | 424 | <tr class="user-<?php echo $name; ?>-wrap"> |
425 | 425 | <th><label for="<?php echo $name; ?>"> |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | * |
435 | 435 | * @param string $desc The translatable label for the contactmethod. |
436 | 436 | */ |
437 | - echo apply_filters( "user_{$name}_label", $desc ); |
|
437 | + echo apply_filters("user_{$name}_label", $desc); |
|
438 | 438 | ?> |
439 | 439 | </label></th> |
440 | 440 | <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($profileuser->$name) ?>" class="regular-text" /></td> |
@@ -455,81 +455,81 @@ discard block |
||
455 | 455 | |
456 | 456 | <?php |
457 | 457 | /** This filter is documented in wp-admin/user-new.php */ |
458 | -$show_password_fields = apply_filters( 'show_password_fields', true, $profileuser ); |
|
459 | -if ( $show_password_fields ) : |
|
458 | +$show_password_fields = apply_filters('show_password_fields', true, $profileuser); |
|
459 | +if ($show_password_fields) : |
|
460 | 460 | ?> |
461 | 461 | </table> |
462 | 462 | |
463 | 463 | <h3><?php _e('Account Management'); ?></h3> |
464 | 464 | <table class="form-table"> |
465 | 465 | <tr id="password" class="user-pass1-wrap"> |
466 | - <th><label for="pass1"><?php _e( 'New Password' ); ?></label></th> |
|
466 | + <th><label for="pass1"><?php _e('New Password'); ?></label></th> |
|
467 | 467 | <td> |
468 | 468 | <input class="hidden" value=" " /><!-- #24364 workaround --> |
469 | - <button type="button" class="button button-secondary wp-generate-pw hide-if-no-js"><?php _e( 'Generate Password' ); ?></button> |
|
469 | + <button type="button" class="button button-secondary wp-generate-pw hide-if-no-js"><?php _e('Generate Password'); ?></button> |
|
470 | 470 | <div class="wp-pwd hide-if-js"> |
471 | 471 | <span class="password-input-wrapper"> |
472 | - <input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="off" data-pw="<?php echo esc_attr( wp_generate_password( 24 ) ); ?>" aria-describedby="pass-strength-result" /> |
|
472 | + <input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="off" data-pw="<?php echo esc_attr(wp_generate_password(24)); ?>" aria-describedby="pass-strength-result" /> |
|
473 | 473 | </span> |
474 | - <button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>"> |
|
474 | + <button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e('Hide password'); ?>"> |
|
475 | 475 | <span class="dashicons dashicons-hidden"></span> |
476 | - <span class="text"><?php _e( 'Hide' ); ?></span> |
|
476 | + <span class="text"><?php _e('Hide'); ?></span> |
|
477 | 477 | </button> |
478 | - <button type="button" class="button button-secondary wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel password change' ); ?>"> |
|
479 | - <span class="text"><?php _e( 'Cancel' ); ?></span> |
|
478 | + <button type="button" class="button button-secondary wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e('Cancel password change'); ?>"> |
|
479 | + <span class="text"><?php _e('Cancel'); ?></span> |
|
480 | 480 | </button> |
481 | 481 | <div style="display:none" id="pass-strength-result" aria-live="polite"></div> |
482 | 482 | </div> |
483 | 483 | </td> |
484 | 484 | </tr> |
485 | 485 | <tr class="user-pass2-wrap hide-if-js"> |
486 | - <th scope="row"><label for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th> |
|
486 | + <th scope="row"><label for="pass2"><?php _e('Repeat New Password'); ?></label></th> |
|
487 | 487 | <td> |
488 | 488 | <input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="off" /> |
489 | - <p class="description"><?php _e( 'Type your new password again.' ); ?></p> |
|
489 | + <p class="description"><?php _e('Type your new password again.'); ?></p> |
|
490 | 490 | </td> |
491 | 491 | </tr> |
492 | 492 | <tr class="pw-weak"> |
493 | - <th><?php _e( 'Confirm Password' ); ?></th> |
|
493 | + <th><?php _e('Confirm Password'); ?></th> |
|
494 | 494 | <td> |
495 | 495 | <label> |
496 | 496 | <input type="checkbox" name="pw_weak" class="pw-checkbox" /> |
497 | - <?php _e( 'Confirm use of weak password' ); ?> |
|
497 | + <?php _e('Confirm use of weak password'); ?> |
|
498 | 498 | </label> |
499 | 499 | </td> |
500 | 500 | </tr> |
501 | 501 | <?php endif; ?> |
502 | 502 | |
503 | 503 | <?php |
504 | -if ( IS_PROFILE_PAGE && count( $sessions->get_all() ) === 1 ) : ?> |
|
504 | +if (IS_PROFILE_PAGE && count($sessions->get_all()) === 1) : ?> |
|
505 | 505 | <tr class="user-sessions-wrap hide-if-no-js"> |
506 | - <th><?php _e( 'Sessions' ); ?></th> |
|
506 | + <th><?php _e('Sessions'); ?></th> |
|
507 | 507 | <td aria-live="assertive"> |
508 | - <div class="destroy-sessions"><button type="button" disabled class="button button-secondary"><?php _e( 'Log Out Everywhere Else' ); ?></button></div> |
|
508 | + <div class="destroy-sessions"><button type="button" disabled class="button button-secondary"><?php _e('Log Out Everywhere Else'); ?></button></div> |
|
509 | 509 | <p class="description"> |
510 | - <?php _e( 'You are only logged in at this location.' ); ?> |
|
510 | + <?php _e('You are only logged in at this location.'); ?> |
|
511 | 511 | </p> |
512 | 512 | </td> |
513 | 513 | </tr> |
514 | -<?php elseif ( IS_PROFILE_PAGE && count( $sessions->get_all() ) > 1 ) : ?> |
|
514 | +<?php elseif (IS_PROFILE_PAGE && count($sessions->get_all()) > 1) : ?> |
|
515 | 515 | <tr class="user-sessions-wrap hide-if-no-js"> |
516 | - <th><?php _e( 'Sessions' ); ?></th> |
|
516 | + <th><?php _e('Sessions'); ?></th> |
|
517 | 517 | <td aria-live="assertive"> |
518 | - <div class="destroy-sessions"><button type="button" class="button button-secondary" id="destroy-sessions"><?php _e( 'Log Out Everywhere Else' ); ?></button></div> |
|
518 | + <div class="destroy-sessions"><button type="button" class="button button-secondary" id="destroy-sessions"><?php _e('Log Out Everywhere Else'); ?></button></div> |
|
519 | 519 | <p class="description"> |
520 | - <?php _e( 'Did you lose your phone or leave your account logged in at a public computer? You can log out everywhere else, and stay logged in here.' ); ?> |
|
520 | + <?php _e('Did you lose your phone or leave your account logged in at a public computer? You can log out everywhere else, and stay logged in here.'); ?> |
|
521 | 521 | </p> |
522 | 522 | </td> |
523 | 523 | </tr> |
524 | -<?php elseif ( ! IS_PROFILE_PAGE && $sessions->get_all() ) : ?> |
|
524 | +<?php elseif ( ! IS_PROFILE_PAGE && $sessions->get_all()) : ?> |
|
525 | 525 | <tr class="user-sessions-wrap hide-if-no-js"> |
526 | - <th><?php _e( 'Sessions' ); ?></th> |
|
526 | + <th><?php _e('Sessions'); ?></th> |
|
527 | 527 | <td> |
528 | - <p><button type="button" class="button button-secondary" id="destroy-sessions"><?php _e( 'Log Out Everywhere' ); ?></button></p> |
|
528 | + <p><button type="button" class="button button-secondary" id="destroy-sessions"><?php _e('Log Out Everywhere'); ?></button></p> |
|
529 | 529 | <p class="description"> |
530 | 530 | <?php |
531 | 531 | /* translators: 1: User's display name. */ |
532 | - printf( __( 'Log %s out of all locations.' ), $profileuser->display_name ); |
|
532 | + printf(__('Log %s out of all locations.'), $profileuser->display_name); |
|
533 | 533 | ?> |
534 | 534 | </p> |
535 | 535 | </td> |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | </table> |
540 | 540 | |
541 | 541 | <?php |
542 | - if ( IS_PROFILE_PAGE ) { |
|
542 | + if (IS_PROFILE_PAGE) { |
|
543 | 543 | /** |
544 | 544 | * Fires after the 'About Yourself' settings table on the 'Your Profile' editing screen. |
545 | 545 | * |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | * |
550 | 550 | * @param WP_User $profileuser The current WP_User object. |
551 | 551 | */ |
552 | - do_action( 'show_user_profile', $profileuser ); |
|
552 | + do_action('show_user_profile', $profileuser); |
|
553 | 553 | } else { |
554 | 554 | /** |
555 | 555 | * Fires after the 'About the User' settings table on the 'Edit User' screen. |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | * |
559 | 559 | * @param WP_User $profileuser The current WP_User object. |
560 | 560 | */ |
561 | - do_action( 'edit_user_profile', $profileuser ); |
|
561 | + do_action('edit_user_profile', $profileuser); |
|
562 | 562 | } |
563 | 563 | ?> |
564 | 564 | |
@@ -575,21 +575,21 @@ discard block |
||
575 | 575 | * @param bool $enable Whether to display the capabilities. Default true. |
576 | 576 | * @param WP_User $profileuser The current WP_User object. |
577 | 577 | */ |
578 | -if ( count( $profileuser->caps ) > count( $profileuser->roles ) |
|
579 | - && apply_filters( 'additional_capabilities_display', true, $profileuser ) |
|
578 | +if (count($profileuser->caps) > count($profileuser->roles) |
|
579 | + && apply_filters('additional_capabilities_display', true, $profileuser) |
|
580 | 580 | ) : ?> |
581 | -<h3><?php _e( 'Additional Capabilities' ); ?></h3> |
|
581 | +<h3><?php _e('Additional Capabilities'); ?></h3> |
|
582 | 582 | <table class="form-table"> |
583 | 583 | <tr class="user-capabilities-wrap"> |
584 | - <th scope="row"><?php _e( 'Capabilities' ); ?></th> |
|
584 | + <th scope="row"><?php _e('Capabilities'); ?></th> |
|
585 | 585 | <td> |
586 | 586 | <?php |
587 | 587 | $output = ''; |
588 | - foreach ( $profileuser->caps as $cap => $value ) { |
|
589 | - if ( ! $wp_roles->is_role( $cap ) ) { |
|
590 | - if ( '' != $output ) |
|
588 | + foreach ($profileuser->caps as $cap => $value) { |
|
589 | + if ( ! $wp_roles->is_role($cap)) { |
|
590 | + if ('' != $output) |
|
591 | 591 | $output .= ', '; |
592 | - $output .= $value ? $cap : sprintf( __( 'Denied: %s' ), $cap ); |
|
592 | + $output .= $value ? $cap : sprintf(__('Denied: %s'), $cap); |
|
593 | 593 | } |
594 | 594 | } |
595 | 595 | echo $output; |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | <input type="hidden" name="action" value="update" /> |
603 | 603 | <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr($user_id); ?>" /> |
604 | 604 | |
605 | -<?php submit_button( IS_PROFILE_PAGE ? __('Update Profile') : __('Update User') ); ?> |
|
605 | +<?php submit_button(IS_PROFILE_PAGE ? __('Update Profile') : __('Update User')); ?> |
|
606 | 606 | |
607 | 607 | </form> |
608 | 608 | </div> |
@@ -616,4 +616,4 @@ discard block |
||
616 | 616 | } |
617 | 617 | </script> |
618 | 618 | <?php |
619 | -include( ABSPATH . 'wp-admin/admin-footer.php'); |
|
619 | +include(ABSPATH.'wp-admin/admin-footer.php'); |
@@ -13,28 +13,32 @@ discard block |
||
13 | 13 | |
14 | 14 | $user_id = (int) $user_id; |
15 | 15 | $current_user = wp_get_current_user(); |
16 | -if ( ! defined( 'IS_PROFILE_PAGE' ) ) |
|
16 | +if ( ! defined( 'IS_PROFILE_PAGE' ) ) { |
|
17 | 17 | define( 'IS_PROFILE_PAGE', ( $user_id == $current_user->ID ) ); |
18 | +} |
|
18 | 19 | |
19 | -if ( ! $user_id && IS_PROFILE_PAGE ) |
|
20 | +if ( ! $user_id && IS_PROFILE_PAGE ) { |
|
20 | 21 | $user_id = $current_user->ID; |
21 | -elseif ( ! $user_id && ! IS_PROFILE_PAGE ) |
|
22 | +} elseif ( ! $user_id && ! IS_PROFILE_PAGE ) { |
|
22 | 23 | wp_die(__( 'Invalid user ID.' ) ); |
23 | -elseif ( ! get_userdata( $user_id ) ) |
|
24 | +} elseif ( ! get_userdata( $user_id ) ) { |
|
24 | 25 | wp_die( __('Invalid user ID.') ); |
26 | +} |
|
25 | 27 | |
26 | 28 | wp_enqueue_script('user-profile'); |
27 | 29 | |
28 | 30 | $title = IS_PROFILE_PAGE ? __('Profile') : __('Edit User'); |
29 | -if ( current_user_can('edit_users') && !IS_PROFILE_PAGE ) |
|
31 | +if ( current_user_can('edit_users') && !IS_PROFILE_PAGE ) { |
|
30 | 32 | $submenu_file = 'users.php'; |
31 | -else |
|
33 | +} else { |
|
32 | 34 | $submenu_file = 'profile.php'; |
35 | +} |
|
33 | 36 | |
34 | -if ( current_user_can('edit_users') && !is_user_admin() ) |
|
37 | +if ( current_user_can('edit_users') && !is_user_admin() ) { |
|
35 | 38 | $parent_file = 'users.php'; |
36 | -else |
|
39 | +} else { |
|
37 | 40 | $parent_file = 'profile.php'; |
41 | +} |
|
38 | 42 | |
39 | 43 | $profile_help = '<p>' . __('Your profile contains information about you (your “account”) as well as some personal options related to using WordPress.') . '</p>' . |
40 | 44 | '<p>' . __('You can change your password, turn on keyboard shortcuts, change the color scheme of your WordPress administration screens, and turn off the WYSIWYG (Visual) editor, among other things. You can hide the Toolbar (formerly called the Admin Bar) from the front end of your site, however it cannot be disabled on the admin screens.') . '</p>' . |
@@ -103,8 +107,9 @@ discard block |
||
103 | 107 | $user = new stdClass; |
104 | 108 | $user->ID = $current_user->ID; |
105 | 109 | $user->user_email = esc_html( trim( $new_email[ 'newemail' ] ) ); |
106 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) ) |
|
107 | - $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) ); |
|
110 | + if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) ) { |
|
111 | + $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) ); |
|
112 | + } |
|
108 | 113 | wp_update_user( $user ); |
109 | 114 | delete_option( $current_user->ID . '_new_email' ); |
110 | 115 | wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) ); |
@@ -121,8 +126,9 @@ discard block |
||
121 | 126 | |
122 | 127 | check_admin_referer('update-user_' . $user_id); |
123 | 128 | |
124 | -if ( !current_user_can('edit_user', $user_id) ) |
|
129 | +if ( !current_user_can('edit_user', $user_id) ) { |
|
125 | 130 | wp_die(__('You do not have permission to edit this user.')); |
131 | +} |
|
126 | 132 | |
127 | 133 | if ( IS_PROFILE_PAGE ) { |
128 | 134 | /** |
@@ -165,8 +171,9 @@ discard block |
||
165 | 171 | |
166 | 172 | if ( !is_wp_error( $errors ) ) { |
167 | 173 | $redirect = add_query_arg( 'updated', true, get_edit_user_link( $user_id ) ); |
168 | - if ( $wp_http_referer ) |
|
169 | - $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect); |
|
174 | + if ( $wp_http_referer ) { |
|
175 | + $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect); |
|
176 | + } |
|
170 | 177 | wp_redirect($redirect); |
171 | 178 | exit; |
172 | 179 | } |
@@ -174,8 +181,9 @@ discard block |
||
174 | 181 | default: |
175 | 182 | $profileuser = get_user_to_edit($user_id); |
176 | 183 | |
177 | -if ( !current_user_can('edit_user', $user_id) ) |
|
184 | +if ( !current_user_can('edit_user', $user_id) ) { |
|
178 | 185 | wp_die(__('You do not have permission to edit this user.')); |
186 | +} |
|
179 | 187 | |
180 | 188 | $sessions = WP_Session_Tokens::get_instance( $profileuser->ID ); |
181 | 189 | |
@@ -189,9 +197,12 @@ discard block |
||
189 | 197 | <div id="message" class="updated notice is-dismissible"> |
190 | 198 | <?php if ( IS_PROFILE_PAGE ) : ?> |
191 | 199 | <p><strong><?php _e('Profile updated.') ?></strong></p> |
192 | - <?php else: ?> |
|
200 | + <?php else { |
|
201 | + : ?> |
|
193 | 202 | <p><strong><?php _e('User updated.') ?></strong></p> |
194 | - <?php endif; ?> |
|
203 | + <?php endif; |
|
204 | +} |
|
205 | +?> |
|
195 | 206 | <?php if ( $wp_http_referer && !IS_PROFILE_PAGE ) : ?> |
196 | 207 | <p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php _e('← Back to Users'); ?></a></p> |
197 | 208 | <?php endif; ?> |
@@ -236,7 +247,10 @@ discard block |
||
236 | 247 | <?php if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : ?> |
237 | 248 | <tr class="user-rich-editing-wrap"> |
238 | 249 | <th scope="row"><?php _e( 'Visual Editor' ); ?></th> |
239 | - <td><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php if ( ! empty( $profileuser->rich_editing ) ) checked( 'false', $profileuser->rich_editing ); ?> /> <?php _e( 'Disable the visual editor when writing' ); ?></label></td> |
|
250 | + <td><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php if ( ! empty( $profileuser->rich_editing ) ) { |
|
251 | + checked( 'false', $profileuser->rich_editing ); |
|
252 | +} |
|
253 | +?> /> <?php _e( 'Disable the visual editor when writing' ); ?></label></td> |
|
240 | 254 | </tr> |
241 | 255 | <?php endif; ?> |
242 | 256 | <?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?> |
@@ -262,7 +276,10 @@ discard block |
||
262 | 276 | if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) : ?> |
263 | 277 | <tr class="user-comment-shortcuts-wrap"> |
264 | 278 | <th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th> |
265 | -<td><label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php if ( ! empty( $profileuser->comment_shortcuts ) ) checked( 'true', $profileuser->comment_shortcuts ); ?> /> <?php _e('Enable keyboard shortcuts for comment moderation.'); ?></label> <?php _e('<a href="https://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">More information</a>'); ?></td> |
|
279 | +<td><label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php if ( ! empty( $profileuser->comment_shortcuts ) ) { |
|
280 | + checked( 'true', $profileuser->comment_shortcuts ); |
|
281 | +} |
|
282 | +?> /> <?php _e('Enable keyboard shortcuts for comment moderation.'); ?></label> <?php _e('<a href="https://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">More information</a>'); ?></td> |
|
266 | 283 | </tr> |
267 | 284 | <?php endif; ?> |
268 | 285 | <tr class="show-admin-bar user-admin-bar-front-wrap"> |
@@ -321,10 +338,11 @@ discard block |
||
321 | 338 | wp_dropdown_roles($user_role); |
322 | 339 | |
323 | 340 | // print the 'no role' option. Make it selected if the user has no role yet. |
324 | -if ( $user_role ) |
|
341 | +if ( $user_role ) { |
|
325 | 342 | echo '<option value="">' . __('— No role for this site —') . '</option>'; |
326 | -else |
|
343 | +} else { |
|
327 | 344 | echo '<option value="" selected="selected">' . __('— No role for this site —') . '</option>'; |
345 | +} |
|
328 | 346 | ?> |
329 | 347 | </select></td></tr> |
330 | 348 | <?php endif; //!IS_PROFILE_PAGE |
@@ -334,8 +352,11 @@ discard block |
||
334 | 352 | <td> |
335 | 353 | <?php if ( $profileuser->user_email != get_site_option( 'admin_email' ) || ! is_super_admin( $profileuser->ID ) ) : ?> |
336 | 354 | <p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profileuser->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.' ); ?></label></p> |
337 | -<?php else : ?> |
|
338 | -<p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p> |
|
355 | +<?php else { |
|
356 | + : ?> |
|
357 | +<p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); |
|
358 | +} |
|
359 | +?></p> |
|
339 | 360 | <?php endif; ?> |
340 | 361 | </td></tr> |
341 | 362 | <?php } ?> |
@@ -364,19 +385,23 @@ discard block |
||
364 | 385 | $public_display['display_nickname'] = $profileuser->nickname; |
365 | 386 | $public_display['display_username'] = $profileuser->user_login; |
366 | 387 | |
367 | - if ( !empty($profileuser->first_name) ) |
|
368 | - $public_display['display_firstname'] = $profileuser->first_name; |
|
388 | + if ( !empty($profileuser->first_name) ) { |
|
389 | + $public_display['display_firstname'] = $profileuser->first_name; |
|
390 | + } |
|
369 | 391 | |
370 | - if ( !empty($profileuser->last_name) ) |
|
371 | - $public_display['display_lastname'] = $profileuser->last_name; |
|
392 | + if ( !empty($profileuser->last_name) ) { |
|
393 | + $public_display['display_lastname'] = $profileuser->last_name; |
|
394 | + } |
|
372 | 395 | |
373 | 396 | if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
374 | 397 | $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
375 | 398 | $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
376 | 399 | } |
377 | 400 | |
378 | - if ( !in_array( $profileuser->display_name, $public_display ) ) // Only add this if it isn't duplicated elsewhere |
|
401 | + if ( !in_array( $profileuser->display_name, $public_display ) ) { |
|
402 | + // Only add this if it isn't duplicated elsewhere |
|
379 | 403 | $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display; |
404 | + } |
|
380 | 405 | |
381 | 406 | $public_display = array_map( 'trim', $public_display ); |
382 | 407 | $public_display = array_unique( $public_display ); |
@@ -587,8 +612,9 @@ discard block |
||
587 | 612 | $output = ''; |
588 | 613 | foreach ( $profileuser->caps as $cap => $value ) { |
589 | 614 | if ( ! $wp_roles->is_role( $cap ) ) { |
590 | - if ( '' != $output ) |
|
591 | - $output .= ', '; |
|
615 | + if ( '' != $output ) { |
|
616 | + $output .= ', '; |
|
617 | + } |
|
592 | 618 | $output .= $value ? $cap : sprintf( __( 'Denied: %s' ), $cap ); |
593 | 619 | } |
594 | 620 | } |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Multisite upgrade administration panel. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Multisite |
|
7 | - * @since 3.0.0 |
|
8 | - */ |
|
3 | + * Multisite upgrade administration panel. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Multisite |
|
7 | + * @since 3.0.0 |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | require_once( dirname( __FILE__ ) . '/admin.php' ); |
11 | 11 |
@@ -7,7 +7,7 @@ |
||
7 | 7 | * @since 3.0.0 |
8 | 8 | */ |
9 | 9 | |
10 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
10 | +require_once(dirname(__FILE__).'/admin.php'); |
|
11 | 11 | |
12 | -wp_redirect( network_admin_url('upgrade.php') ); |
|
12 | +wp_redirect(network_admin_url('upgrade.php')); |
|
13 | 13 | exit; |
@@ -8,166 +8,166 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | /** Load WordPress Administration Bootstrap */ |
11 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
11 | +require_once(dirname(__FILE__).'/admin.php'); |
|
12 | 12 | |
13 | -if ( ! is_multisite() ) |
|
14 | - wp_die( __( 'Multisite support is not enabled.' ) ); |
|
13 | +if ( ! is_multisite()) |
|
14 | + wp_die(__('Multisite support is not enabled.')); |
|
15 | 15 | |
16 | -if ( ! current_user_can( 'manage_sites' ) ) |
|
17 | - wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
|
16 | +if ( ! current_user_can('manage_sites')) |
|
17 | + wp_die(__('You do not have permission to access this page.'), 403); |
|
18 | 18 | |
19 | -$wp_list_table = _get_list_table( 'WP_MS_Sites_List_Table' ); |
|
19 | +$wp_list_table = _get_list_table('WP_MS_Sites_List_Table'); |
|
20 | 20 | $pagenum = $wp_list_table->get_pagenum(); |
21 | 21 | |
22 | -$title = __( 'Sites' ); |
|
22 | +$title = __('Sites'); |
|
23 | 23 | $parent_file = 'sites.php'; |
24 | 24 | |
25 | -add_screen_option( 'per_page' ); |
|
25 | +add_screen_option('per_page'); |
|
26 | 26 | |
27 | -get_current_screen()->add_help_tab( array( |
|
27 | +get_current_screen()->add_help_tab(array( |
|
28 | 28 | 'id' => 'overview', |
29 | 29 | 'title' => __('Overview'), |
30 | 30 | 'content' => |
31 | - '<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>' . |
|
32 | - '<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>' . |
|
33 | - '<p>' . __('Hovering over each site reveals seven options (three for the primary site):') . '</p>' . |
|
34 | - '<ul><li>' . __('An Edit link to a separate Edit Site screen.') . '</li>' . |
|
35 | - '<li>' . __('Dashboard leads to the Dashboard for that site.') . '</li>' . |
|
36 | - '<li>' . __('Deactivate, Archive, and Spam which lead to confirmation screens. These actions can be reversed later.') . '</li>' . |
|
37 | - '<li>' . __('Delete which is a permanent action after the confirmation screens.') . '</li>' . |
|
38 | - '<li>' . __('Visit to go to the frontend site live.') . '</li></ul>' . |
|
39 | - '<p>' . __('The site ID is used internally, and is not shown on the front end of the site or to users/viewers.') . '</p>' . |
|
40 | - '<p>' . __('Clicking on bold headings can re-sort this table.') . '</p>' |
|
41 | -) ); |
|
31 | + '<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>'. |
|
32 | + '<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>'. |
|
33 | + '<p>'.__('Hovering over each site reveals seven options (three for the primary site):').'</p>'. |
|
34 | + '<ul><li>'.__('An Edit link to a separate Edit Site screen.').'</li>'. |
|
35 | + '<li>'.__('Dashboard leads to the Dashboard for that site.').'</li>'. |
|
36 | + '<li>'.__('Deactivate, Archive, and Spam which lead to confirmation screens. These actions can be reversed later.').'</li>'. |
|
37 | + '<li>'.__('Delete which is a permanent action after the confirmation screens.').'</li>'. |
|
38 | + '<li>'.__('Visit to go to the frontend site live.').'</li></ul>'. |
|
39 | + '<p>'.__('The site ID is used internally, and is not shown on the front end of the site or to users/viewers.').'</p>'. |
|
40 | + '<p>'.__('Clicking on bold headings can re-sort this table.').'</p>' |
|
41 | +)); |
|
42 | 42 | |
43 | 43 | get_current_screen()->set_help_sidebar( |
44 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
45 | - '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen" target="_blank">Documentation on Site Management</a>') . '</p>' . |
|
46 | - '<p>' . __('<a href="https://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>' |
|
44 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
45 | + '<p>'.__('<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen" target="_blank">Documentation on Site Management</a>').'</p>'. |
|
46 | + '<p>'.__('<a href="https://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>').'</p>' |
|
47 | 47 | ); |
48 | 48 | |
49 | -$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; |
|
49 | +$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; |
|
50 | 50 | |
51 | -if ( isset( $_GET['action'] ) ) { |
|
51 | +if (isset($_GET['action'])) { |
|
52 | 52 | /** This action is documented in wp-admin/network/edit.php */ |
53 | - do_action( 'wpmuadminedit' ); |
|
53 | + do_action('wpmuadminedit'); |
|
54 | 54 | |
55 | 55 | // A list of valid actions and their associated messaging for confirmation output. |
56 | 56 | $manage_actions = array( |
57 | - 'activateblog' => __( 'You are about to activate the site %s' ), |
|
58 | - 'deactivateblog' => __( 'You are about to deactivate the site %s' ), |
|
59 | - 'unarchiveblog' => __( 'You are about to unarchive the site %s.' ), |
|
60 | - 'archiveblog' => __( 'You are about to archive the site %s.' ), |
|
61 | - 'unspamblog' => __( 'You are about to unspam the site %s.' ), |
|
62 | - 'spamblog' => __( 'You are about to mark the site %s as spam.' ), |
|
63 | - 'deleteblog' => __( 'You are about to delete the site %s.' ), |
|
64 | - 'unmatureblog' => __( 'You are about to mark the site %s as mature.' ), |
|
65 | - 'matureblog' => __( 'You are about to mark the site %s as not mature.' ), |
|
57 | + 'activateblog' => __('You are about to activate the site %s'), |
|
58 | + 'deactivateblog' => __('You are about to deactivate the site %s'), |
|
59 | + 'unarchiveblog' => __('You are about to unarchive the site %s.'), |
|
60 | + 'archiveblog' => __('You are about to archive the site %s.'), |
|
61 | + 'unspamblog' => __('You are about to unspam the site %s.'), |
|
62 | + 'spamblog' => __('You are about to mark the site %s as spam.'), |
|
63 | + 'deleteblog' => __('You are about to delete the site %s.'), |
|
64 | + 'unmatureblog' => __('You are about to mark the site %s as mature.'), |
|
65 | + 'matureblog' => __('You are about to mark the site %s as not mature.'), |
|
66 | 66 | ); |
67 | 67 | |
68 | - if ( 'confirm' === $_GET['action'] ) { |
|
68 | + if ('confirm' === $_GET['action']) { |
|
69 | 69 | // The action2 parameter contains the action being taken on the site. |
70 | 70 | $site_action = $_GET['action2']; |
71 | 71 | |
72 | - if ( ! array_key_exists( $site_action, $manage_actions ) ) { |
|
73 | - wp_die( __( 'The requested action is not valid.' ) ); |
|
72 | + if ( ! array_key_exists($site_action, $manage_actions)) { |
|
73 | + wp_die(__('The requested action is not valid.')); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | // The mature/unmature UI exists only as external code. Check the "confirm" nonce for backward compatibility. |
77 | - if ( 'matureblog' === $site_action || 'unmatureblog' === $site_action ) { |
|
78 | - check_admin_referer( 'confirm' ); |
|
77 | + if ('matureblog' === $site_action || 'unmatureblog' === $site_action) { |
|
78 | + check_admin_referer('confirm'); |
|
79 | 79 | } else { |
80 | - check_admin_referer( $site_action . '_' . $id ); |
|
80 | + check_admin_referer($site_action.'_'.$id); |
|
81 | 81 | } |
82 | 82 | |
83 | - if ( ! headers_sent() ) { |
|
83 | + if ( ! headers_sent()) { |
|
84 | 84 | nocache_headers(); |
85 | - header( 'Content-Type: text/html; charset=utf-8' ); |
|
85 | + header('Content-Type: text/html; charset=utf-8'); |
|
86 | 86 | } |
87 | 87 | |
88 | - if ( $current_site->blog_id == $id ) { |
|
89 | - wp_die( __( 'You are not allowed to change the current site.' ) ); |
|
88 | + if ($current_site->blog_id == $id) { |
|
89 | + wp_die(__('You are not allowed to change the current site.')); |
|
90 | 90 | } |
91 | 91 | |
92 | - $site_details = get_blog_details( $id ); |
|
93 | - $site_address = untrailingslashit( $site_details->domain . $site_details->path ); |
|
92 | + $site_details = get_blog_details($id); |
|
93 | + $site_address = untrailingslashit($site_details->domain.$site_details->path); |
|
94 | 94 | |
95 | - require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
95 | + require_once(ABSPATH.'wp-admin/admin-header.php'); |
|
96 | 96 | ?> |
97 | 97 | <div class="wrap"> |
98 | - <h1><?php _e( 'Confirm your action' ); ?></h1> |
|
99 | - <form action="sites.php?action=<?php echo esc_attr( $site_action ); ?>" method="post"> |
|
100 | - <input type="hidden" name="action" value="<?php echo esc_attr( $site_action ); ?>" /> |
|
101 | - <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" /> |
|
102 | - <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" /> |
|
103 | - <?php wp_nonce_field( $site_action . '_' . $id, '_wpnonce', false ); ?> |
|
104 | - <p><?php echo sprintf( $manage_actions[ $site_action ], $site_address ); ?></p> |
|
105 | - <?php submit_button( __( 'Confirm' ), 'button' ); ?> |
|
98 | + <h1><?php _e('Confirm your action'); ?></h1> |
|
99 | + <form action="sites.php?action=<?php echo esc_attr($site_action); ?>" method="post"> |
|
100 | + <input type="hidden" name="action" value="<?php echo esc_attr($site_action); ?>" /> |
|
101 | + <input type="hidden" name="id" value="<?php echo esc_attr($id); ?>" /> |
|
102 | + <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr(wp_get_referer()); ?>" /> |
|
103 | + <?php wp_nonce_field($site_action.'_'.$id, '_wpnonce', false); ?> |
|
104 | + <p><?php echo sprintf($manage_actions[$site_action], $site_address); ?></p> |
|
105 | + <?php submit_button(__('Confirm'), 'button'); ?> |
|
106 | 106 | </form> |
107 | 107 | </div> |
108 | 108 | <?php |
109 | - require_once( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
109 | + require_once(ABSPATH.'wp-admin/admin-footer.php'); |
|
110 | 110 | exit(); |
111 | - } elseif ( array_key_exists( $_GET['action'], $manage_actions ) ) { |
|
111 | + } elseif (array_key_exists($_GET['action'], $manage_actions)) { |
|
112 | 112 | $action = $_GET['action']; |
113 | - check_admin_referer( $action . '_' . $id ); |
|
114 | - } elseif ( 'allblogs' === $_GET['action'] ) { |
|
115 | - check_admin_referer( 'bulk-sites' ); |
|
113 | + check_admin_referer($action.'_'.$id); |
|
114 | + } elseif ('allblogs' === $_GET['action']) { |
|
115 | + check_admin_referer('bulk-sites'); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | $updated_action = ''; |
119 | 119 | |
120 | - switch ( $_GET['action'] ) { |
|
120 | + switch ($_GET['action']) { |
|
121 | 121 | |
122 | 122 | case 'deleteblog': |
123 | - if ( ! current_user_can( 'delete_sites' ) ) |
|
124 | - wp_die( __( 'You do not have permission to access this page.' ), '', array( 'response' => 403 ) ); |
|
123 | + if ( ! current_user_can('delete_sites')) |
|
124 | + wp_die(__('You do not have permission to access this page.'), '', array('response' => 403)); |
|
125 | 125 | |
126 | 126 | $updated_action = 'not_deleted'; |
127 | - if ( $id != '0' && $id != $current_site->blog_id && current_user_can( 'delete_site', $id ) ) { |
|
128 | - wpmu_delete_blog( $id, true ); |
|
127 | + if ($id != '0' && $id != $current_site->blog_id && current_user_can('delete_site', $id)) { |
|
128 | + wpmu_delete_blog($id, true); |
|
129 | 129 | $updated_action = 'delete'; |
130 | 130 | } |
131 | 131 | break; |
132 | 132 | |
133 | 133 | case 'allblogs': |
134 | - if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allblogs'] ) ) { |
|
134 | + if ((isset($_POST['action']) || isset($_POST['action2'])) && isset($_POST['allblogs'])) { |
|
135 | 135 | $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2']; |
136 | 136 | |
137 | - foreach ( (array) $_POST['allblogs'] as $key => $val ) { |
|
138 | - if ( $val != '0' && $val != $current_site->blog_id ) { |
|
139 | - switch ( $doaction ) { |
|
137 | + foreach ((array) $_POST['allblogs'] as $key => $val) { |
|
138 | + if ($val != '0' && $val != $current_site->blog_id) { |
|
139 | + switch ($doaction) { |
|
140 | 140 | case 'delete': |
141 | - if ( ! current_user_can( 'delete_site', $val ) ) |
|
142 | - wp_die( __( 'You are not allowed to delete the site.' ) ); |
|
141 | + if ( ! current_user_can('delete_site', $val)) |
|
142 | + wp_die(__('You are not allowed to delete the site.')); |
|
143 | 143 | |
144 | 144 | $updated_action = 'all_delete'; |
145 | - wpmu_delete_blog( $val, true ); |
|
145 | + wpmu_delete_blog($val, true); |
|
146 | 146 | break; |
147 | 147 | |
148 | 148 | case 'spam': |
149 | 149 | case 'notspam': |
150 | - $updated_action = ( 'spam' === $doaction ) ? 'all_spam' : 'all_notspam'; |
|
151 | - update_blog_status( $val, 'spam', ( 'spam' === $doaction ) ? '1' : '0' ); |
|
150 | + $updated_action = ('spam' === $doaction) ? 'all_spam' : 'all_notspam'; |
|
151 | + update_blog_status($val, 'spam', ('spam' === $doaction) ? '1' : '0'); |
|
152 | 152 | break; |
153 | 153 | } |
154 | 154 | } else { |
155 | - wp_die( __( 'You are not allowed to change the current site.' ) ); |
|
155 | + wp_die(__('You are not allowed to change the current site.')); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | } else { |
159 | - wp_redirect( network_admin_url( 'sites.php' ) ); |
|
159 | + wp_redirect(network_admin_url('sites.php')); |
|
160 | 160 | exit(); |
161 | 161 | } |
162 | 162 | break; |
163 | 163 | |
164 | 164 | case 'archiveblog': |
165 | 165 | case 'unarchiveblog': |
166 | - update_blog_status( $id, 'archived', ( 'archiveblog' === $_GET['action'] ) ? '1' : '0' ); |
|
166 | + update_blog_status($id, 'archived', ('archiveblog' === $_GET['action']) ? '1' : '0'); |
|
167 | 167 | break; |
168 | 168 | |
169 | 169 | case 'activateblog': |
170 | - update_blog_status( $id, 'deleted', '0' ); |
|
170 | + update_blog_status($id, 'deleted', '0'); |
|
171 | 171 | |
172 | 172 | /** |
173 | 173 | * Fires after a network site is activated. |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @param string $id The ID of the activated site. |
178 | 178 | */ |
179 | - do_action( 'activate_blog', $id ); |
|
179 | + do_action('activate_blog', $id); |
|
180 | 180 | break; |
181 | 181 | |
182 | 182 | case 'deactivateblog': |
@@ -187,66 +187,66 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @param string $id The ID of the site being deactivated. |
189 | 189 | */ |
190 | - do_action( 'deactivate_blog', $id ); |
|
191 | - update_blog_status( $id, 'deleted', '1' ); |
|
190 | + do_action('deactivate_blog', $id); |
|
191 | + update_blog_status($id, 'deleted', '1'); |
|
192 | 192 | break; |
193 | 193 | |
194 | 194 | case 'unspamblog': |
195 | 195 | case 'spamblog': |
196 | - update_blog_status( $id, 'spam', ( 'spamblog' === $_GET['action'] ) ? '1' : '0' ); |
|
196 | + update_blog_status($id, 'spam', ('spamblog' === $_GET['action']) ? '1' : '0'); |
|
197 | 197 | break; |
198 | 198 | |
199 | 199 | case 'unmatureblog': |
200 | 200 | case 'matureblog': |
201 | - update_blog_status( $id, 'mature', ( 'matureblog' === $_GET['action'] ) ? '1' : '0' ); |
|
201 | + update_blog_status($id, 'mature', ('matureblog' === $_GET['action']) ? '1' : '0'); |
|
202 | 202 | break; |
203 | 203 | } |
204 | 204 | |
205 | - if ( empty( $updated_action ) && array_key_exists( $_GET['action'], $manage_actions ) ) { |
|
205 | + if (empty($updated_action) && array_key_exists($_GET['action'], $manage_actions)) { |
|
206 | 206 | $updated_action = $_GET['action']; |
207 | 207 | } |
208 | 208 | |
209 | - if ( ! empty( $updated_action ) ) { |
|
210 | - wp_safe_redirect( add_query_arg( array( 'updated' => $updated_action ), wp_get_referer() ) ); |
|
209 | + if ( ! empty($updated_action)) { |
|
210 | + wp_safe_redirect(add_query_arg(array('updated' => $updated_action), wp_get_referer())); |
|
211 | 211 | exit(); |
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | 215 | $msg = ''; |
216 | -if ( isset( $_GET['updated'] ) ) { |
|
217 | - switch ( $_GET['updated'] ) { |
|
216 | +if (isset($_GET['updated'])) { |
|
217 | + switch ($_GET['updated']) { |
|
218 | 218 | case 'all_notspam': |
219 | - $msg = __( 'Sites removed from spam.' ); |
|
219 | + $msg = __('Sites removed from spam.'); |
|
220 | 220 | break; |
221 | 221 | case 'all_spam': |
222 | - $msg = __( 'Sites marked as spam.' ); |
|
222 | + $msg = __('Sites marked as spam.'); |
|
223 | 223 | break; |
224 | 224 | case 'all_delete': |
225 | - $msg = __( 'Sites deleted.' ); |
|
225 | + $msg = __('Sites deleted.'); |
|
226 | 226 | break; |
227 | 227 | case 'delete': |
228 | - $msg = __( 'Site deleted.' ); |
|
228 | + $msg = __('Site deleted.'); |
|
229 | 229 | break; |
230 | 230 | case 'not_deleted': |
231 | - $msg = __( 'You do not have permission to delete that site.' ); |
|
231 | + $msg = __('You do not have permission to delete that site.'); |
|
232 | 232 | break; |
233 | 233 | case 'archiveblog': |
234 | - $msg = __( 'Site archived.' ); |
|
234 | + $msg = __('Site archived.'); |
|
235 | 235 | break; |
236 | 236 | case 'unarchiveblog': |
237 | - $msg = __( 'Site unarchived.' ); |
|
237 | + $msg = __('Site unarchived.'); |
|
238 | 238 | break; |
239 | 239 | case 'activateblog': |
240 | - $msg = __( 'Site activated.' ); |
|
240 | + $msg = __('Site activated.'); |
|
241 | 241 | break; |
242 | 242 | case 'deactivateblog': |
243 | - $msg = __( 'Site deactivated.' ); |
|
243 | + $msg = __('Site deactivated.'); |
|
244 | 244 | break; |
245 | 245 | case 'unspamblog': |
246 | - $msg = __( 'Site removed from spam.' ); |
|
246 | + $msg = __('Site removed from spam.'); |
|
247 | 247 | break; |
248 | 248 | case 'spamblog': |
249 | - $msg = __( 'Site marked as spam.' ); |
|
249 | + $msg = __('Site marked as spam.'); |
|
250 | 250 | break; |
251 | 251 | default: |
252 | 252 | /** |
@@ -259,35 +259,35 @@ discard block |
||
259 | 259 | * |
260 | 260 | * @param string $msg The update message. Default 'Settings saved'. |
261 | 261 | */ |
262 | - $msg = apply_filters( 'network_sites_updated_message_' . $_GET['updated'], __( 'Settings saved.' ) ); |
|
262 | + $msg = apply_filters('network_sites_updated_message_'.$_GET['updated'], __('Settings saved.')); |
|
263 | 263 | break; |
264 | 264 | } |
265 | 265 | |
266 | - if ( ! empty( $msg ) ) |
|
267 | - $msg = '<div class="updated" id="message notice is-dismissible"><p>' . $msg . '</p></div>'; |
|
266 | + if ( ! empty($msg)) |
|
267 | + $msg = '<div class="updated" id="message notice is-dismissible"><p>'.$msg.'</p></div>'; |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | $wp_list_table->prepare_items(); |
271 | 271 | |
272 | -require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
272 | +require_once(ABSPATH.'wp-admin/admin-header.php'); |
|
273 | 273 | ?> |
274 | 274 | |
275 | 275 | <div class="wrap"> |
276 | -<h1><?php _e( 'Sites' ); ?> |
|
276 | +<h1><?php _e('Sites'); ?> |
|
277 | 277 | |
278 | -<?php if ( current_user_can( 'create_sites') ) : ?> |
|
279 | - <a href="<?php echo network_admin_url('site-new.php'); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'site' ); ?></a> |
|
278 | +<?php if (current_user_can('create_sites')) : ?> |
|
279 | + <a href="<?php echo network_admin_url('site-new.php'); ?>" class="page-title-action"><?php echo esc_html_x('Add New', 'site'); ?></a> |
|
280 | 280 | <?php endif; ?> |
281 | 281 | |
282 | -<?php if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] ) { |
|
283 | - printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $s ) ); |
|
282 | +<?php if (isset($_REQUEST['s']) && $_REQUEST['s']) { |
|
283 | + printf('<span class="subtitle">'.__('Search results for “%s”').'</span>', esc_html($s)); |
|
284 | 284 | } ?> |
285 | 285 | </h1> |
286 | 286 | |
287 | 287 | <?php echo $msg; ?> |
288 | 288 | |
289 | 289 | <form method="get" id="ms-search"> |
290 | -<?php $wp_list_table->search_box( __( 'Search Sites' ), 'site' ); ?> |
|
290 | +<?php $wp_list_table->search_box(__('Search Sites'), 'site'); ?> |
|
291 | 291 | <input type="hidden" name="action" value="blogs" /> |
292 | 292 | </form> |
293 | 293 | |
@@ -297,4 +297,4 @@ discard block |
||
297 | 297 | </div> |
298 | 298 | <?php |
299 | 299 | |
300 | -require_once( ABSPATH . 'wp-admin/admin-footer.php' ); ?> |
|
300 | +require_once(ABSPATH.'wp-admin/admin-footer.php'); ?> |
@@ -10,11 +10,13 @@ discard block |
||
10 | 10 | /** Load WordPress Administration Bootstrap */ |
11 | 11 | require_once( dirname( __FILE__ ) . '/admin.php' ); |
12 | 12 | |
13 | -if ( ! is_multisite() ) |
|
13 | +if ( ! is_multisite() ) { |
|
14 | 14 | wp_die( __( 'Multisite support is not enabled.' ) ); |
15 | +} |
|
15 | 16 | |
16 | -if ( ! current_user_can( 'manage_sites' ) ) |
|
17 | +if ( ! current_user_can( 'manage_sites' ) ) { |
|
17 | 18 | wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
19 | +} |
|
18 | 20 | |
19 | 21 | $wp_list_table = _get_list_table( 'WP_MS_Sites_List_Table' ); |
20 | 22 | $pagenum = $wp_list_table->get_pagenum(); |
@@ -120,8 +122,9 @@ discard block |
||
120 | 122 | switch ( $_GET['action'] ) { |
121 | 123 | |
122 | 124 | case 'deleteblog': |
123 | - if ( ! current_user_can( 'delete_sites' ) ) |
|
124 | - wp_die( __( 'You do not have permission to access this page.' ), '', array( 'response' => 403 ) ); |
|
125 | + if ( ! current_user_can( 'delete_sites' ) ) { |
|
126 | + wp_die( __( 'You do not have permission to access this page.' ), '', array( 'response' => 403 ) ); |
|
127 | + } |
|
125 | 128 | |
126 | 129 | $updated_action = 'not_deleted'; |
127 | 130 | if ( $id != '0' && $id != $current_site->blog_id && current_user_can( 'delete_site', $id ) ) { |
@@ -138,8 +141,9 @@ discard block |
||
138 | 141 | if ( $val != '0' && $val != $current_site->blog_id ) { |
139 | 142 | switch ( $doaction ) { |
140 | 143 | case 'delete': |
141 | - if ( ! current_user_can( 'delete_site', $val ) ) |
|
142 | - wp_die( __( 'You are not allowed to delete the site.' ) ); |
|
144 | + if ( ! current_user_can( 'delete_site', $val ) ) { |
|
145 | + wp_die( __( 'You are not allowed to delete the site.' ) ); |
|
146 | + } |
|
143 | 147 | |
144 | 148 | $updated_action = 'all_delete'; |
145 | 149 | wpmu_delete_blog( $val, true ); |
@@ -263,9 +267,10 @@ discard block |
||
263 | 267 | break; |
264 | 268 | } |
265 | 269 | |
266 | - if ( ! empty( $msg ) ) |
|
267 | - $msg = '<div class="updated" id="message notice is-dismissible"><p>' . $msg . '</p></div>'; |
|
268 | -} |
|
270 | + if ( ! empty( $msg ) ) { |
|
271 | + $msg = '<div class="updated" id="message notice is-dismissible"><p>' . $msg . '</p></div>'; |
|
272 | + } |
|
273 | + } |
|
269 | 274 | |
270 | 275 | $wp_list_table->prepare_items(); |
271 | 276 |
@@ -8,89 +8,89 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | /** Load WordPress Administration Bootstrap */ |
11 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
11 | +require_once(dirname(__FILE__).'/admin.php'); |
|
12 | 12 | |
13 | -if ( ! is_multisite() ) |
|
14 | - wp_die( __( 'Multisite support is not enabled.' ) ); |
|
13 | +if ( ! is_multisite()) |
|
14 | + wp_die(__('Multisite support is not enabled.')); |
|
15 | 15 | |
16 | -if ( ! current_user_can( 'manage_network_users' ) ) |
|
17 | - wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
|
16 | +if ( ! current_user_can('manage_network_users')) |
|
17 | + wp_die(__('You do not have permission to access this page.'), 403); |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * |
21 | 21 | * @param array $users |
22 | 22 | */ |
23 | -function confirm_delete_users( $users ) { |
|
23 | +function confirm_delete_users($users) { |
|
24 | 24 | $current_user = wp_get_current_user(); |
25 | - if ( ! is_array( $users ) || empty( $users ) ) { |
|
25 | + if ( ! is_array($users) || empty($users)) { |
|
26 | 26 | return false; |
27 | 27 | } |
28 | 28 | ?> |
29 | - <h1><?php esc_html_e( 'Users' ); ?></h1> |
|
29 | + <h1><?php esc_html_e('Users'); ?></h1> |
|
30 | 30 | |
31 | - <?php if ( 1 == count( $users ) ) : ?> |
|
32 | - <p><?php _e( 'You have chosen to delete the user from all networks and sites.' ); ?></p> |
|
31 | + <?php if (1 == count($users)) : ?> |
|
32 | + <p><?php _e('You have chosen to delete the user from all networks and sites.'); ?></p> |
|
33 | 33 | <?php else : ?> |
34 | - <p><?php _e( 'You have chosen to delete the following users from all networks and sites.' ); ?></p> |
|
34 | + <p><?php _e('You have chosen to delete the following users from all networks and sites.'); ?></p> |
|
35 | 35 | <?php endif; ?> |
36 | 36 | |
37 | 37 | <form action="users.php?action=dodelete" method="post"> |
38 | 38 | <input type="hidden" name="dodelete" /> |
39 | 39 | <?php |
40 | - wp_nonce_field( 'ms-users-delete' ); |
|
40 | + wp_nonce_field('ms-users-delete'); |
|
41 | 41 | $site_admins = get_super_admins(); |
42 | - $admin_out = '<option value="' . esc_attr( $current_user->ID ) . '">' . $current_user->user_login . '</option>'; ?> |
|
42 | + $admin_out = '<option value="'.esc_attr($current_user->ID).'">'.$current_user->user_login.'</option>'; ?> |
|
43 | 43 | <table class="form-table"> |
44 | - <?php foreach ( ( $allusers = (array) $_POST['allusers'] ) as $user_id ) { |
|
45 | - if ( $user_id != '' && $user_id != '0' ) { |
|
46 | - $delete_user = get_userdata( $user_id ); |
|
44 | + <?php foreach (($allusers = (array) $_POST['allusers']) as $user_id) { |
|
45 | + if ($user_id != '' && $user_id != '0') { |
|
46 | + $delete_user = get_userdata($user_id); |
|
47 | 47 | |
48 | - if ( ! current_user_can( 'delete_user', $delete_user->ID ) ) { |
|
49 | - wp_die( sprintf( __( 'Warning! User %s cannot be deleted.' ), $delete_user->user_login ) ); |
|
48 | + if ( ! current_user_can('delete_user', $delete_user->ID)) { |
|
49 | + wp_die(sprintf(__('Warning! User %s cannot be deleted.'), $delete_user->user_login)); |
|
50 | 50 | } |
51 | 51 | |
52 | - if ( in_array( $delete_user->user_login, $site_admins ) ) { |
|
53 | - wp_die( sprintf( __( 'Warning! User cannot be deleted. The user %s is a network administrator.' ), '<em>' . $delete_user->user_login . '</em>' ) ); |
|
52 | + if (in_array($delete_user->user_login, $site_admins)) { |
|
53 | + wp_die(sprintf(__('Warning! User cannot be deleted. The user %s is a network administrator.'), '<em>'.$delete_user->user_login.'</em>')); |
|
54 | 54 | } |
55 | 55 | ?> |
56 | 56 | <tr> |
57 | 57 | <th scope="row"><?php echo $delete_user->user_login; ?> |
58 | - <?php echo '<input type="hidden" name="user[]" value="' . esc_attr( $user_id ) . '" />' . "\n"; ?> |
|
58 | + <?php echo '<input type="hidden" name="user[]" value="'.esc_attr($user_id).'" />'."\n"; ?> |
|
59 | 59 | </th> |
60 | - <?php $blogs = get_blogs_of_user( $user_id, true ); |
|
60 | + <?php $blogs = get_blogs_of_user($user_id, true); |
|
61 | 61 | |
62 | - if ( ! empty( $blogs ) ) { |
|
62 | + if ( ! empty($blogs)) { |
|
63 | 63 | ?> |
64 | 64 | <td><fieldset><p><legend><?php printf( |
65 | 65 | /* translators: user login */ |
66 | - __( 'What should be done with content owned by %s?' ), |
|
67 | - '<em>' . $delete_user->user_login . '</em>' |
|
66 | + __('What should be done with content owned by %s?'), |
|
67 | + '<em>'.$delete_user->user_login.'</em>' |
|
68 | 68 | ); ?></legend></p> |
69 | 69 | <?php |
70 | - foreach ( (array) $blogs as $key => $details ) { |
|
71 | - $blog_users = get_users( array( 'blog_id' => $details->userblog_id, 'fields' => array( 'ID', 'user_login' ) ) ); |
|
72 | - if ( is_array( $blog_users ) && !empty( $blog_users ) ) { |
|
73 | - $user_site = "<a href='" . esc_url( get_home_url( $details->userblog_id ) ) . "'>{$details->blogname}</a>"; |
|
74 | - $user_dropdown = '<label for="reassign_user" class="screen-reader-text">' . __( 'Select a user' ) . '</label>'; |
|
70 | + foreach ((array) $blogs as $key => $details) { |
|
71 | + $blog_users = get_users(array('blog_id' => $details->userblog_id, 'fields' => array('ID', 'user_login'))); |
|
72 | + if (is_array($blog_users) && ! empty($blog_users)) { |
|
73 | + $user_site = "<a href='".esc_url(get_home_url($details->userblog_id))."'>{$details->blogname}</a>"; |
|
74 | + $user_dropdown = '<label for="reassign_user" class="screen-reader-text">'.__('Select a user').'</label>'; |
|
75 | 75 | $user_dropdown .= "<select name='blog[$user_id][$key]' id='reassign_user'>"; |
76 | 76 | $user_list = ''; |
77 | - foreach ( $blog_users as $user ) { |
|
78 | - if ( ! in_array( $user->ID, $allusers ) ) { |
|
77 | + foreach ($blog_users as $user) { |
|
78 | + if ( ! in_array($user->ID, $allusers)) { |
|
79 | 79 | $user_list .= "<option value='{$user->ID}'>{$user->user_login}</option>"; |
80 | 80 | } |
81 | 81 | } |
82 | - if ( '' == $user_list ) { |
|
82 | + if ('' == $user_list) { |
|
83 | 83 | $user_list = $admin_out; |
84 | 84 | } |
85 | 85 | $user_dropdown .= $user_list; |
86 | 86 | $user_dropdown .= "</select>\n"; |
87 | 87 | ?> |
88 | 88 | <ul style="list-style:none;"> |
89 | - <li><?php printf( __( 'Site: %s' ), $user_site ); ?></li> |
|
90 | - <li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="delete" checked="checked" /> |
|
91 | - <?php _e( 'Delete all content.' ); ?></label></li> |
|
92 | - <li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="reassign" /> |
|
93 | - <?php _e( 'Attribute all content to:' ) . "</label>\n" . $user_dropdown; ?></li> |
|
89 | + <li><?php printf(__('Site: %s'), $user_site); ?></li> |
|
90 | + <li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id.']['.$delete_user->ID ?>]" value="delete" checked="checked" /> |
|
91 | + <?php _e('Delete all content.'); ?></label></li> |
|
92 | + <li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id.']['.$delete_user->ID ?>]" value="reassign" /> |
|
93 | + <?php _e('Attribute all content to:')."</label>\n".$user_dropdown; ?></li> |
|
94 | 94 | </ul> |
95 | 95 | <?php |
96 | 96 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | echo "</fieldset></td></tr>"; |
99 | 99 | } else { |
100 | 100 | ?> |
101 | - <td><fieldset><p><legend><?php _e( 'User has no sites or content and will be deleted.' ); ?></legend></p> |
|
101 | + <td><fieldset><p><legend><?php _e('User has no sites or content and will be deleted.'); ?></legend></p> |
|
102 | 102 | <?php } ?> |
103 | 103 | </tr> |
104 | 104 | <?php |
@@ -109,141 +109,141 @@ discard block |
||
109 | 109 | </table> |
110 | 110 | <?php |
111 | 111 | /** This action is documented in wp-admin/users.php */ |
112 | - do_action( 'delete_user_form', $current_user ); |
|
112 | + do_action('delete_user_form', $current_user); |
|
113 | 113 | |
114 | - if ( 1 == count( $users ) ) : ?> |
|
115 | - <p><?php _e( 'Once you hit “Confirm Deletion”, the user will be permanently removed.' ); ?></p> |
|
114 | + if (1 == count($users)) : ?> |
|
115 | + <p><?php _e('Once you hit “Confirm Deletion”, the user will be permanently removed.'); ?></p> |
|
116 | 116 | <?php else : ?> |
117 | - <p><?php _e( 'Once you hit “Confirm Deletion”, these users will be permanently removed.' ); ?></p> |
|
117 | + <p><?php _e('Once you hit “Confirm Deletion”, these users will be permanently removed.'); ?></p> |
|
118 | 118 | <?php endif; |
119 | 119 | |
120 | - submit_button( __('Confirm Deletion'), 'delete' ); |
|
120 | + submit_button(__('Confirm Deletion'), 'delete'); |
|
121 | 121 | ?> |
122 | 122 | </form> |
123 | 123 | <?php |
124 | 124 | return true; |
125 | 125 | } |
126 | 126 | |
127 | -if ( isset( $_GET['action'] ) ) { |
|
127 | +if (isset($_GET['action'])) { |
|
128 | 128 | /** This action is documented in wp-admin/network/edit.php */ |
129 | - do_action( 'wpmuadminedit' ); |
|
129 | + do_action('wpmuadminedit'); |
|
130 | 130 | |
131 | - switch ( $_GET['action'] ) { |
|
131 | + switch ($_GET['action']) { |
|
132 | 132 | case 'deleteuser': |
133 | - if ( ! current_user_can( 'manage_network_users' ) ) |
|
134 | - wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
|
133 | + if ( ! current_user_can('manage_network_users')) |
|
134 | + wp_die(__('You do not have permission to access this page.'), 403); |
|
135 | 135 | |
136 | - check_admin_referer( 'deleteuser' ); |
|
136 | + check_admin_referer('deleteuser'); |
|
137 | 137 | |
138 | - $id = intval( $_GET['id'] ); |
|
139 | - if ( $id != '0' && $id != '1' ) { |
|
140 | - $_POST['allusers'] = array( $id ); // confirm_delete_users() can only handle with arrays |
|
141 | - $title = __( 'Users' ); |
|
138 | + $id = intval($_GET['id']); |
|
139 | + if ($id != '0' && $id != '1') { |
|
140 | + $_POST['allusers'] = array($id); // confirm_delete_users() can only handle with arrays |
|
141 | + $title = __('Users'); |
|
142 | 142 | $parent_file = 'users.php'; |
143 | - require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
143 | + require_once(ABSPATH.'wp-admin/admin-header.php'); |
|
144 | 144 | echo '<div class="wrap">'; |
145 | - confirm_delete_users( $_POST['allusers'] ); |
|
145 | + confirm_delete_users($_POST['allusers']); |
|
146 | 146 | echo '</div>'; |
147 | - require_once( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
147 | + require_once(ABSPATH.'wp-admin/admin-footer.php'); |
|
148 | 148 | } else { |
149 | - wp_redirect( network_admin_url( 'users.php' ) ); |
|
149 | + wp_redirect(network_admin_url('users.php')); |
|
150 | 150 | } |
151 | 151 | exit(); |
152 | 152 | |
153 | 153 | case 'allusers': |
154 | - if ( !current_user_can( 'manage_network_users' ) ) |
|
155 | - wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
|
154 | + if ( ! current_user_can('manage_network_users')) |
|
155 | + wp_die(__('You do not have permission to access this page.'), 403); |
|
156 | 156 | |
157 | - if ( ( isset( $_POST['action']) || isset($_POST['action2'] ) ) && isset( $_POST['allusers'] ) ) { |
|
158 | - check_admin_referer( 'bulk-users-network' ); |
|
157 | + if ((isset($_POST['action']) || isset($_POST['action2'])) && isset($_POST['allusers'])) { |
|
158 | + check_admin_referer('bulk-users-network'); |
|
159 | 159 | |
160 | 160 | $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2']; |
161 | 161 | $userfunction = ''; |
162 | 162 | |
163 | - foreach ( (array) $_POST['allusers'] as $user_id ) { |
|
164 | - if ( !empty( $user_id ) ) { |
|
165 | - switch ( $doaction ) { |
|
163 | + foreach ((array) $_POST['allusers'] as $user_id) { |
|
164 | + if ( ! empty($user_id)) { |
|
165 | + switch ($doaction) { |
|
166 | 166 | case 'delete': |
167 | - if ( ! current_user_can( 'delete_users' ) ) |
|
168 | - wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
|
169 | - $title = __( 'Users' ); |
|
167 | + if ( ! current_user_can('delete_users')) |
|
168 | + wp_die(__('You do not have permission to access this page.'), 403); |
|
169 | + $title = __('Users'); |
|
170 | 170 | $parent_file = 'users.php'; |
171 | - require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
171 | + require_once(ABSPATH.'wp-admin/admin-header.php'); |
|
172 | 172 | echo '<div class="wrap">'; |
173 | - confirm_delete_users( $_POST['allusers'] ); |
|
173 | + confirm_delete_users($_POST['allusers']); |
|
174 | 174 | echo '</div>'; |
175 | - require_once( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
175 | + require_once(ABSPATH.'wp-admin/admin-footer.php'); |
|
176 | 176 | exit(); |
177 | 177 | |
178 | 178 | case 'spam': |
179 | - $user = get_userdata( $user_id ); |
|
180 | - if ( is_super_admin( $user->ID ) ) |
|
181 | - wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a network administrator.' ), esc_html( $user->user_login ) ) ); |
|
179 | + $user = get_userdata($user_id); |
|
180 | + if (is_super_admin($user->ID)) |
|
181 | + wp_die(sprintf(__('Warning! User cannot be modified. The user %s is a network administrator.'), esc_html($user->user_login))); |
|
182 | 182 | |
183 | 183 | $userfunction = 'all_spam'; |
184 | - $blogs = get_blogs_of_user( $user_id, true ); |
|
185 | - foreach ( (array) $blogs as $details ) { |
|
186 | - if ( $details->userblog_id != $current_site->blog_id ) // main blog not a spam ! |
|
187 | - update_blog_status( $details->userblog_id, 'spam', '1' ); |
|
184 | + $blogs = get_blogs_of_user($user_id, true); |
|
185 | + foreach ((array) $blogs as $details) { |
|
186 | + if ($details->userblog_id != $current_site->blog_id) // main blog not a spam ! |
|
187 | + update_blog_status($details->userblog_id, 'spam', '1'); |
|
188 | 188 | } |
189 | - update_user_status( $user_id, 'spam', '1' ); |
|
189 | + update_user_status($user_id, 'spam', '1'); |
|
190 | 190 | break; |
191 | 191 | |
192 | 192 | case 'notspam': |
193 | 193 | $userfunction = 'all_notspam'; |
194 | - $blogs = get_blogs_of_user( $user_id, true ); |
|
195 | - foreach ( (array) $blogs as $details ) |
|
196 | - update_blog_status( $details->userblog_id, 'spam', '0' ); |
|
194 | + $blogs = get_blogs_of_user($user_id, true); |
|
195 | + foreach ((array) $blogs as $details) |
|
196 | + update_blog_status($details->userblog_id, 'spam', '0'); |
|
197 | 197 | |
198 | - update_user_status( $user_id, 'spam', '0' ); |
|
198 | + update_user_status($user_id, 'spam', '0'); |
|
199 | 199 | break; |
200 | 200 | } |
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
204 | - wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $userfunction ), wp_get_referer() ) ); |
|
204 | + wp_safe_redirect(add_query_arg(array('updated' => 'true', 'action' => $userfunction), wp_get_referer())); |
|
205 | 205 | } else { |
206 | - $location = network_admin_url( 'users.php' ); |
|
206 | + $location = network_admin_url('users.php'); |
|
207 | 207 | |
208 | - if ( ! empty( $_REQUEST['paged'] ) ) |
|
209 | - $location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location ); |
|
210 | - wp_redirect( $location ); |
|
208 | + if ( ! empty($_REQUEST['paged'])) |
|
209 | + $location = add_query_arg('paged', (int) $_REQUEST['paged'], $location); |
|
210 | + wp_redirect($location); |
|
211 | 211 | } |
212 | 212 | exit(); |
213 | 213 | |
214 | 214 | case 'dodelete': |
215 | - check_admin_referer( 'ms-users-delete' ); |
|
216 | - if ( ! ( current_user_can( 'manage_network_users' ) && current_user_can( 'delete_users' ) ) ) |
|
217 | - wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
|
218 | - |
|
219 | - if ( ! empty( $_POST['blog'] ) && is_array( $_POST['blog'] ) ) { |
|
220 | - foreach ( $_POST['blog'] as $id => $users ) { |
|
221 | - foreach ( $users as $blogid => $user_id ) { |
|
222 | - if ( ! current_user_can( 'delete_user', $id ) ) |
|
215 | + check_admin_referer('ms-users-delete'); |
|
216 | + if ( ! (current_user_can('manage_network_users') && current_user_can('delete_users'))) |
|
217 | + wp_die(__('You do not have permission to access this page.'), 403); |
|
218 | + |
|
219 | + if ( ! empty($_POST['blog']) && is_array($_POST['blog'])) { |
|
220 | + foreach ($_POST['blog'] as $id => $users) { |
|
221 | + foreach ($users as $blogid => $user_id) { |
|
222 | + if ( ! current_user_can('delete_user', $id)) |
|
223 | 223 | continue; |
224 | 224 | |
225 | - if ( ! empty( $_POST['delete'] ) && 'reassign' == $_POST['delete'][$blogid][$id] ) |
|
226 | - remove_user_from_blog( $id, $blogid, $user_id ); |
|
225 | + if ( ! empty($_POST['delete']) && 'reassign' == $_POST['delete'][$blogid][$id]) |
|
226 | + remove_user_from_blog($id, $blogid, $user_id); |
|
227 | 227 | else |
228 | - remove_user_from_blog( $id, $blogid ); |
|
228 | + remove_user_from_blog($id, $blogid); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | } |
232 | 232 | $i = 0; |
233 | - if ( is_array( $_POST['user'] ) && ! empty( $_POST['user'] ) ) |
|
234 | - foreach( $_POST['user'] as $id ) { |
|
235 | - if ( ! current_user_can( 'delete_user', $id ) ) |
|
233 | + if (is_array($_POST['user']) && ! empty($_POST['user'])) |
|
234 | + foreach ($_POST['user'] as $id) { |
|
235 | + if ( ! current_user_can('delete_user', $id)) |
|
236 | 236 | continue; |
237 | - wpmu_delete_user( $id ); |
|
237 | + wpmu_delete_user($id); |
|
238 | 238 | $i++; |
239 | 239 | } |
240 | 240 | |
241 | - if ( $i == 1 ) |
|
241 | + if ($i == 1) |
|
242 | 242 | $deletefunction = 'delete'; |
243 | 243 | else |
244 | 244 | $deletefunction = 'all_delete'; |
245 | 245 | |
246 | - wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $deletefunction ), network_admin_url( 'users.php' ) ) ); |
|
246 | + wp_redirect(add_query_arg(array('updated' => 'true', 'action' => $deletefunction), network_admin_url('users.php'))); |
|
247 | 247 | exit(); |
248 | 248 | } |
249 | 249 | } |
@@ -251,56 +251,56 @@ discard block |
||
251 | 251 | $wp_list_table = _get_list_table('WP_MS_Users_List_Table'); |
252 | 252 | $pagenum = $wp_list_table->get_pagenum(); |
253 | 253 | $wp_list_table->prepare_items(); |
254 | -$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
254 | +$total_pages = $wp_list_table->get_pagination_arg('total_pages'); |
|
255 | 255 | |
256 | -if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
257 | - wp_redirect( add_query_arg( 'paged', $total_pages ) ); |
|
256 | +if ($pagenum > $total_pages && $total_pages > 0) { |
|
257 | + wp_redirect(add_query_arg('paged', $total_pages)); |
|
258 | 258 | exit; |
259 | 259 | } |
260 | -$title = __( 'Users' ); |
|
260 | +$title = __('Users'); |
|
261 | 261 | $parent_file = 'users.php'; |
262 | 262 | |
263 | -add_screen_option( 'per_page' ); |
|
263 | +add_screen_option('per_page'); |
|
264 | 264 | |
265 | -get_current_screen()->add_help_tab( array( |
|
265 | +get_current_screen()->add_help_tab(array( |
|
266 | 266 | 'id' => 'overview', |
267 | 267 | 'title' => __('Overview'), |
268 | 268 | 'content' => |
269 | - '<p>' . __('This table shows all users across the network and the sites to which they are assigned.') . '</p>' . |
|
270 | - '<p>' . __('Hover over any user on the list to make the edit links appear. The Edit link on the left will take you to their Edit User profile page; the Edit link on the right by any site name goes to an Edit Site screen for that site.') . '</p>' . |
|
271 | - '<p>' . __('You can also go to the user’s profile page by clicking on the individual username.') . '</p>' . |
|
272 | - '<p>' . __('You can sort the table by clicking on any of the bold headings and switch between list and excerpt views by using the icons in the upper right.') . '</p>' . |
|
273 | - '<p>' . __('The bulk action will permanently delete selected users, or mark/unmark those selected as spam. Spam users will have posts removed and will be unable to sign up again with the same email addresses.') . '</p>' . |
|
274 | - '<p>' . __('You can make an existing user an additional super admin by going to the Edit User profile page and checking the box to grant that privilege.') . '</p>' |
|
275 | -) ); |
|
269 | + '<p>'.__('This table shows all users across the network and the sites to which they are assigned.').'</p>'. |
|
270 | + '<p>'.__('Hover over any user on the list to make the edit links appear. The Edit link on the left will take you to their Edit User profile page; the Edit link on the right by any site name goes to an Edit Site screen for that site.').'</p>'. |
|
271 | + '<p>'.__('You can also go to the user’s profile page by clicking on the individual username.').'</p>'. |
|
272 | + '<p>'.__('You can sort the table by clicking on any of the bold headings and switch between list and excerpt views by using the icons in the upper right.').'</p>'. |
|
273 | + '<p>'.__('The bulk action will permanently delete selected users, or mark/unmark those selected as spam. Spam users will have posts removed and will be unable to sign up again with the same email addresses.').'</p>'. |
|
274 | + '<p>'.__('You can make an existing user an additional super admin by going to the Edit User profile page and checking the box to grant that privilege.').'</p>' |
|
275 | +)); |
|
276 | 276 | |
277 | 277 | get_current_screen()->set_help_sidebar( |
278 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
279 | - '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Users_Screen" target="_blank">Documentation on Network Users</a>') . '</p>' . |
|
280 | - '<p>' . __('<a href="https://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>' |
|
278 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
279 | + '<p>'.__('<a href="https://codex.wordpress.org/Network_Admin_Users_Screen" target="_blank">Documentation on Network Users</a>').'</p>'. |
|
280 | + '<p>'.__('<a href="https://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>').'</p>' |
|
281 | 281 | ); |
282 | 282 | |
283 | -require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
283 | +require_once(ABSPATH.'wp-admin/admin-header.php'); |
|
284 | 284 | |
285 | -if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $_REQUEST['action'] ) ) { |
|
285 | +if (isset($_REQUEST['updated']) && $_REQUEST['updated'] == 'true' && ! empty($_REQUEST['action'])) { |
|
286 | 286 | ?> |
287 | 287 | <div id="message" class="updated notice is-dismissible"><p> |
288 | 288 | <?php |
289 | - switch ( $_REQUEST['action'] ) { |
|
289 | + switch ($_REQUEST['action']) { |
|
290 | 290 | case 'delete': |
291 | - _e( 'User deleted.' ); |
|
291 | + _e('User deleted.'); |
|
292 | 292 | break; |
293 | 293 | case 'all_spam': |
294 | - _e( 'Users marked as spam.' ); |
|
294 | + _e('Users marked as spam.'); |
|
295 | 295 | break; |
296 | 296 | case 'all_notspam': |
297 | - _e( 'Users removed from spam.' ); |
|
297 | + _e('Users removed from spam.'); |
|
298 | 298 | break; |
299 | 299 | case 'all_delete': |
300 | - _e( 'Users deleted.' ); |
|
300 | + _e('Users deleted.'); |
|
301 | 301 | break; |
302 | 302 | case 'add': |
303 | - _e( 'User added.' ); |
|
303 | + _e('User added.'); |
|
304 | 304 | break; |
305 | 305 | } |
306 | 306 | ?> |
@@ -309,20 +309,20 @@ discard block |
||
309 | 309 | } |
310 | 310 | ?> |
311 | 311 | <div class="wrap"> |
312 | - <h1><?php esc_html_e( 'Users' ); |
|
313 | - if ( current_user_can( 'create_users') ) : ?> |
|
314 | - <a href="<?php echo network_admin_url('user-new.php'); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a><?php |
|
312 | + <h1><?php esc_html_e('Users'); |
|
313 | + if (current_user_can('create_users')) : ?> |
|
314 | + <a href="<?php echo network_admin_url('user-new.php'); ?>" class="page-title-action"><?php echo esc_html_x('Add New', 'user'); ?></a><?php |
|
315 | 315 | endif; |
316 | 316 | |
317 | - if ( !empty( $usersearch ) ) |
|
318 | - printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $usersearch ) ); |
|
317 | + if ( ! empty($usersearch)) |
|
318 | + printf('<span class="subtitle">'.__('Search results for “%s”').'</span>', esc_html($usersearch)); |
|
319 | 319 | ?> |
320 | 320 | </h1> |
321 | 321 | |
322 | 322 | <?php $wp_list_table->views(); ?> |
323 | 323 | |
324 | 324 | <form method="get" class="search-form"> |
325 | - <?php $wp_list_table->search_box( __( 'Search Users' ), 'all-user' ); ?> |
|
325 | + <?php $wp_list_table->search_box(__('Search Users'), 'all-user'); ?> |
|
326 | 326 | </form> |
327 | 327 | |
328 | 328 | <form id="form-user-list" action="users.php?action=allusers" method="post"> |
@@ -330,4 +330,4 @@ discard block |
||
330 | 330 | </form> |
331 | 331 | </div> |
332 | 332 | |
333 | -<?php require_once( ABSPATH . 'wp-admin/admin-footer.php' ); ?> |
|
333 | +<?php require_once(ABSPATH.'wp-admin/admin-footer.php'); ?> |
@@ -10,11 +10,13 @@ discard block |
||
10 | 10 | /** Load WordPress Administration Bootstrap */ |
11 | 11 | require_once( dirname( __FILE__ ) . '/admin.php' ); |
12 | 12 | |
13 | -if ( ! is_multisite() ) |
|
13 | +if ( ! is_multisite() ) { |
|
14 | 14 | wp_die( __( 'Multisite support is not enabled.' ) ); |
15 | +} |
|
15 | 16 | |
16 | -if ( ! current_user_can( 'manage_network_users' ) ) |
|
17 | +if ( ! current_user_can( 'manage_network_users' ) ) { |
|
17 | 18 | wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
19 | +} |
|
18 | 20 | |
19 | 21 | /** |
20 | 22 | * |
@@ -30,8 +32,11 @@ discard block |
||
30 | 32 | |
31 | 33 | <?php if ( 1 == count( $users ) ) : ?> |
32 | 34 | <p><?php _e( 'You have chosen to delete the user from all networks and sites.' ); ?></p> |
33 | - <?php else : ?> |
|
34 | - <p><?php _e( 'You have chosen to delete the following users from all networks and sites.' ); ?></p> |
|
35 | + <?php else { |
|
36 | + : ?> |
|
37 | + <p><?php _e( 'You have chosen to delete the following users from all networks and sites.' ); |
|
38 | +} |
|
39 | +?></p> |
|
35 | 40 | <?php endif; ?> |
36 | 41 | |
37 | 42 | <form action="users.php?action=dodelete" method="post"> |
@@ -113,8 +118,11 @@ discard block |
||
113 | 118 | |
114 | 119 | if ( 1 == count( $users ) ) : ?> |
115 | 120 | <p><?php _e( 'Once you hit “Confirm Deletion”, the user will be permanently removed.' ); ?></p> |
116 | - <?php else : ?> |
|
117 | - <p><?php _e( 'Once you hit “Confirm Deletion”, these users will be permanently removed.' ); ?></p> |
|
121 | + <?php else { |
|
122 | + : ?> |
|
123 | + <p><?php _e( 'Once you hit “Confirm Deletion”, these users will be permanently removed.' ); |
|
124 | +} |
|
125 | +?></p> |
|
118 | 126 | <?php endif; |
119 | 127 | |
120 | 128 | submit_button( __('Confirm Deletion'), 'delete' ); |
@@ -130,8 +138,9 @@ discard block |
||
130 | 138 | |
131 | 139 | switch ( $_GET['action'] ) { |
132 | 140 | case 'deleteuser': |
133 | - if ( ! current_user_can( 'manage_network_users' ) ) |
|
134 | - wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
|
141 | + if ( ! current_user_can( 'manage_network_users' ) ) { |
|
142 | + wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
|
143 | + } |
|
135 | 144 | |
136 | 145 | check_admin_referer( 'deleteuser' ); |
137 | 146 | |
@@ -151,8 +160,9 @@ discard block |
||
151 | 160 | exit(); |
152 | 161 | |
153 | 162 | case 'allusers': |
154 | - if ( !current_user_can( 'manage_network_users' ) ) |
|
155 | - wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
|
163 | + if ( !current_user_can( 'manage_network_users' ) ) { |
|
164 | + wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
|
165 | + } |
|
156 | 166 | |
157 | 167 | if ( ( isset( $_POST['action']) || isset($_POST['action2'] ) ) && isset( $_POST['allusers'] ) ) { |
158 | 168 | check_admin_referer( 'bulk-users-network' ); |
@@ -164,8 +174,9 @@ discard block |
||
164 | 174 | if ( !empty( $user_id ) ) { |
165 | 175 | switch ( $doaction ) { |
166 | 176 | case 'delete': |
167 | - if ( ! current_user_can( 'delete_users' ) ) |
|
168 | - wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
|
177 | + if ( ! current_user_can( 'delete_users' ) ) { |
|
178 | + wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
|
179 | + } |
|
169 | 180 | $title = __( 'Users' ); |
170 | 181 | $parent_file = 'users.php'; |
171 | 182 | require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
@@ -177,14 +188,17 @@ discard block |
||
177 | 188 | |
178 | 189 | case 'spam': |
179 | 190 | $user = get_userdata( $user_id ); |
180 | - if ( is_super_admin( $user->ID ) ) |
|
181 | - wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a network administrator.' ), esc_html( $user->user_login ) ) ); |
|
191 | + if ( is_super_admin( $user->ID ) ) { |
|
192 | + wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a network administrator.' ), esc_html( $user->user_login ) ) ); |
|
193 | + } |
|
182 | 194 | |
183 | 195 | $userfunction = 'all_spam'; |
184 | 196 | $blogs = get_blogs_of_user( $user_id, true ); |
185 | 197 | foreach ( (array) $blogs as $details ) { |
186 | - if ( $details->userblog_id != $current_site->blog_id ) // main blog not a spam ! |
|
198 | + if ( $details->userblog_id != $current_site->blog_id ) { |
|
199 | + // main blog not a spam ! |
|
187 | 200 | update_blog_status( $details->userblog_id, 'spam', '1' ); |
201 | + } |
|
188 | 202 | } |
189 | 203 | update_user_status( $user_id, 'spam', '1' ); |
190 | 204 | break; |
@@ -192,8 +206,9 @@ discard block |
||
192 | 206 | case 'notspam': |
193 | 207 | $userfunction = 'all_notspam'; |
194 | 208 | $blogs = get_blogs_of_user( $user_id, true ); |
195 | - foreach ( (array) $blogs as $details ) |
|
196 | - update_blog_status( $details->userblog_id, 'spam', '0' ); |
|
209 | + foreach ( (array) $blogs as $details ) { |
|
210 | + update_blog_status( $details->userblog_id, 'spam', '0' ); |
|
211 | + } |
|
197 | 212 | |
198 | 213 | update_user_status( $user_id, 'spam', '0' ); |
199 | 214 | break; |
@@ -205,43 +220,49 @@ discard block |
||
205 | 220 | } else { |
206 | 221 | $location = network_admin_url( 'users.php' ); |
207 | 222 | |
208 | - if ( ! empty( $_REQUEST['paged'] ) ) |
|
209 | - $location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location ); |
|
223 | + if ( ! empty( $_REQUEST['paged'] ) ) { |
|
224 | + $location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location ); |
|
225 | + } |
|
210 | 226 | wp_redirect( $location ); |
211 | 227 | } |
212 | 228 | exit(); |
213 | 229 | |
214 | 230 | case 'dodelete': |
215 | 231 | check_admin_referer( 'ms-users-delete' ); |
216 | - if ( ! ( current_user_can( 'manage_network_users' ) && current_user_can( 'delete_users' ) ) ) |
|
217 | - wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
|
232 | + if ( ! ( current_user_can( 'manage_network_users' ) && current_user_can( 'delete_users' ) ) ) { |
|
233 | + wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
|
234 | + } |
|
218 | 235 | |
219 | 236 | if ( ! empty( $_POST['blog'] ) && is_array( $_POST['blog'] ) ) { |
220 | 237 | foreach ( $_POST['blog'] as $id => $users ) { |
221 | 238 | foreach ( $users as $blogid => $user_id ) { |
222 | - if ( ! current_user_can( 'delete_user', $id ) ) |
|
223 | - continue; |
|
239 | + if ( ! current_user_can( 'delete_user', $id ) ) { |
|
240 | + continue; |
|
241 | + } |
|
224 | 242 | |
225 | - if ( ! empty( $_POST['delete'] ) && 'reassign' == $_POST['delete'][$blogid][$id] ) |
|
226 | - remove_user_from_blog( $id, $blogid, $user_id ); |
|
227 | - else |
|
228 | - remove_user_from_blog( $id, $blogid ); |
|
243 | + if ( ! empty( $_POST['delete'] ) && 'reassign' == $_POST['delete'][$blogid][$id] ) { |
|
244 | + remove_user_from_blog( $id, $blogid, $user_id ); |
|
245 | + } else { |
|
246 | + remove_user_from_blog( $id, $blogid ); |
|
247 | + } |
|
229 | 248 | } |
230 | 249 | } |
231 | 250 | } |
232 | 251 | $i = 0; |
233 | - if ( is_array( $_POST['user'] ) && ! empty( $_POST['user'] ) ) |
|
234 | - foreach( $_POST['user'] as $id ) { |
|
252 | + if ( is_array( $_POST['user'] ) && ! empty( $_POST['user'] ) ) { |
|
253 | + foreach( $_POST['user'] as $id ) { |
|
235 | 254 | if ( ! current_user_can( 'delete_user', $id ) ) |
236 | 255 | continue; |
256 | + } |
|
237 | 257 | wpmu_delete_user( $id ); |
238 | 258 | $i++; |
239 | 259 | } |
240 | 260 | |
241 | - if ( $i == 1 ) |
|
242 | - $deletefunction = 'delete'; |
|
243 | - else |
|
244 | - $deletefunction = 'all_delete'; |
|
261 | + if ( $i == 1 ) { |
|
262 | + $deletefunction = 'delete'; |
|
263 | + } else { |
|
264 | + $deletefunction = 'all_delete'; |
|
265 | + } |
|
245 | 266 | |
246 | 267 | wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $deletefunction ), network_admin_url( 'users.php' ) ) ); |
247 | 268 | exit(); |
@@ -314,8 +335,9 @@ discard block |
||
314 | 335 | <a href="<?php echo network_admin_url('user-new.php'); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a><?php |
315 | 336 | endif; |
316 | 337 | |
317 | - if ( !empty( $usersearch ) ) |
|
318 | - printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $usersearch ) ); |
|
338 | + if ( !empty( $usersearch ) ) { |
|
339 | + printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $usersearch ) ); |
|
340 | + } |
|
319 | 341 | ?> |
320 | 342 | </h1> |
321 | 343 |