~canonical-sysadmins/wordpress/4.9.7

« back to all changes in this revision

Viewing changes to wp-admin/network/site-users.php

  • Committer: Barry Price
  • Date: 2017-11-17 04:49:02 UTC
  • mfrom: (1.1.30 upstream)
  • Revision ID: barry.price@canonical.com-20171117044902-5frux4ycbq6g9fyf
Merge WP4.9 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
require_once( dirname( __FILE__ ) . '/admin.php' );
12
12
 
13
13
if ( ! current_user_can('manage_sites') )
14
 
        wp_die(__('Sorry, you are not allowed to edit this site.'));
 
14
        wp_die( __( 'Sorry, you are not allowed to edit this site.' ), 403 );
15
15
 
16
16
$wp_list_table = _get_list_table('WP_Users_List_Table');
17
17
$wp_list_table->prepare_items();
18
18
 
19
 
get_current_screen()->add_help_tab( array(
20
 
        'id'      => 'overview',
21
 
        'title'   => __('Overview'),
22
 
        'content' =>
23
 
                '<p>' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '</p>' .
24
 
                '<p>' . __('<strong>Info</strong> &mdash; The site URL is rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.') . '</p>' .
25
 
                '<p>' . __('<strong>Users</strong> &mdash; This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.') . '</p>' .
26
 
                '<p>' . sprintf( __('<strong>Themes</strong> &mdash; This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site&#8217;s Appearance menu. To enable a theme for the entire network, see the <a href="%s">Network Themes</a> screen.' ), network_admin_url( 'themes.php' ) ) . '</p>' .
27
 
                '<p>' . __('<strong>Settings</strong> &mdash; This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.') . '</p>'
28
 
) );
29
 
 
30
 
get_current_screen()->set_help_sidebar(
31
 
        '<p><strong>' . __('For more information:') . '</strong></p>' .
32
 
        '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen">Documentation on Site Management</a>') . '</p>' .
33
 
        '<p>' . __('<a href="https://wordpress.org/support/forum/multisite/">Support Forums</a>') . '</p>'
34
 
);
 
19
get_current_screen()->add_help_tab( get_site_screen_help_tab_args() );
 
20
get_current_screen()->set_help_sidebar( get_site_screen_help_sidebar_content() );
35
21
 
36
22
get_current_screen()->set_screen_reader_content( array(
37
23
        'heading_views'      => __( 'Filter site users list' ),
80
66
                                if ( false === $user_id ) {
81
67
                                        $update = 'err_new_dup';
82
68
                                } else {
83
 
                                        add_user_to_blog( $id, $user_id, $_POST['new_role'] );
84
 
                                        $update = 'newuser';
85
 
                                        /**
86
 
                                          * Fires after a user has been created via the network site-users.php page.
87
 
                                          *
88
 
                                          * @since 4.4.0
89
 
                                          *
90
 
                                          * @param int $user_id ID of the newly created user.
91
 
                                          */
92
 
                                        do_action( 'network_site_users_created_user', $user_id );
 
69
                                        $result = add_user_to_blog( $id, $user_id, $_POST['new_role'] );
 
70
 
 
71
                                        if ( is_wp_error( $result ) ) {
 
72
                                                $update = 'err_add_fail';
 
73
                                        } else {
 
74
                                                $update = 'newuser';
 
75
                                                /**
 
76
                                                  * Fires after a user has been created via the network site-users.php page.
 
77
                                                  *
 
78
                                                  * @since 4.4.0
 
79
                                                  *
 
80
                                                  * @param int $user_id ID of the newly created user.
 
81
                                                  */
 
82
                                                do_action( 'network_site_users_created_user', $user_id );
 
83
                                        }
93
84
                                }
94
85
                        }
95
86
                        break;
101
92
                                $newuser = $_POST['newuser'];
102
93
                                $user = get_user_by( 'login', $newuser );
103
94
                                if ( $user && $user->exists() ) {
104
 
                                        if ( ! is_user_member_of_blog( $user->ID, $id ) )
105
 
                                                add_user_to_blog( $id, $user->ID, $_POST['new_role'] );
106
 
                                        else
 
95
                                        if ( ! is_user_member_of_blog( $user->ID, $id ) ) {
 
96
                                                $result = add_user_to_blog( $id, $user->ID, $_POST['new_role'] );
 
97
 
 
98
                                                if ( is_wp_error( $result ) ) {
 
99
                                                        $update = 'err_add_fail';
 
100
                                                }
 
101
                                        } else {
107
102
                                                $update = 'err_add_member';
 
103
                                        }
108
104
                                } else {
109
105
                                        $update = 'err_add_notfound';
110
106
                                }
115
111
 
116
112
                case 'remove':
117
113
                        if ( ! current_user_can( 'remove_users' ) ) {
118
 
                                wp_die( __( 'Sorry, you are not allowed to remove users.' ) );
 
114
                                wp_die( __( 'Sorry, you are not allowed to remove users.' ), 403 );
119
115
                        }
120
116
 
121
117
                        check_admin_referer( 'bulk-users' );
146
142
                        }
147
143
 
148
144
                        if ( empty( $editable_roles[ $role ] ) ) {
149
 
                                wp_die( __( 'Sorry, you are not allowed to give users that role.' ) );
 
145
                                wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 );
150
146
                        }
151
147
 
152
148
                        if ( isset( $_REQUEST['users'] ) ) {
237
233
        case 'err_add_member':
238
234
                echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'User is already a member of this site.' ) . '</p></div>';
239
235
                break;
 
236
        case 'err_add_fail':
 
237
                echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'User could not be added to this site.' ) . '</p></div>';
 
238
                break;
240
239
        case 'err_add_notfound':
241
240
                echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'Enter the username of an existing user.' ) . '</p></div>';
242
241
                break;
299
298
                <tr>
300
299
                        <th scope="row"><label for="new_role_adduser"><?php _e( 'Role' ); ?></label></th>
301
300
                        <td><select name="new_role" id="new_role_adduser">
302
 
                        <?php wp_dropdown_roles( get_option( 'default_role' ) ); ?>
 
301
                        <?php
 
302
                        switch_to_blog( $id );
 
303
                        wp_dropdown_roles( get_option( 'default_role' ) );
 
304
                        restore_current_blog();
 
305
                        ?>
303
306
                        </select></td>
304
307
                </tr>
305
308
        </table>
332
335
                <tr>
333
336
                        <th scope="row"><label for="new_role_newuser"><?php _e( 'Role' ); ?></label></th>
334
337
                        <td><select name="new_role" id="new_role_newuser">
335
 
                        <?php wp_dropdown_roles( get_option( 'default_role' ) ); ?>
 
338
                        <?php
 
339
                        switch_to_blog( $id );
 
340
                        wp_dropdown_roles( get_option( 'default_role' ) );
 
341
                        restore_current_blog();
 
342
                        ?>
336
343
                        </select></td>
337
344
                </tr>
338
345
                <tr class="form-field">