Changeset 11140
- Timestamp:
- 09/21/2016 05:38:04 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-members/classes/class-bp-members-admin.php
r11120 r11140 2064 2064 2065 2065 // Bail if current user cannot promote users. 2066 if ( ! current_user_can( 'promote_users' ) ) {2066 if ( ! bp_current_user_can( 'promote_users' ) ) { 2067 2067 return; 2068 2068 } … … 2085 2085 <?php foreach( $types as $type ) : ?> 2086 2086 2087 <option value="<?php echo esc_attr( $type->name ); ?>"><?php e cho $type->labels['name']; ?></option>2087 <option value="<?php echo esc_attr( $type->name ); ?>"><?php esc_html_e( $type->labels['singular_name'] ); ?></option> 2088 2088 2089 2089 <?php endforeach; ?> … … 2106 2106 $this->users_type_change_notice(); 2107 2107 2108 // Bail if no users specified. 2109 if ( empty( $_REQUEST['users'] ) ) { 2110 return; 2111 } 2112 2113 // Bail if this isn't a BuddyPress action. 2114 if ( ( empty( $_REQUEST['bp_change_type'] ) && empty( $_REQUEST['bp_change_type2'] ) ) 2108 // Bail if no users are specified or if this isn't a BuddyPress action. 2109 if ( empty( $_REQUEST['users'] ) 2110 || ( empty( $_REQUEST['bp_change_type'] ) && empty( $_REQUEST['bp_change_type2'] ) ) 2115 2111 || empty( $_REQUEST['bp_change_member_type'] ) 2116 2112 ) { … … 2122 2118 2123 2119 // Bail if current user cannot promote users. 2124 if ( ! current_user_can( 'promote_users' ) ) {2120 if ( ! bp_current_user_can( 'promote_users' ) ) { 2125 2121 return; 2126 2122 } … … 2134 2130 2135 2131 // Check that the selected type actually exists. 2136 if ( 'remove_member_type' != $new_type && null == bp_get_member_type_object( $new_type ) ) {2137 return;2138 } 2139 2140 // Run through user ids.2141 $error = false;2142 foreach ( (array) $_REQUEST['users'] as $user_id ) {2143 $user_id = (int) $user_id; 2144 2145 // Get the old member type to check against.2146 $member_type = bp_get_member_type( $user_id ); 2147 2148 if ( 'remove_member_type' == $new_type ) {2149 // Remove the current member type, if there's one to remove.2150 if ( $member_type ) {2151 $removed = bp_remove_member_type( $user_id, $member_type );2152 if ( false == $removed || is_wp_error( $removed ) ) {2153 $error = true;2132 if ( 'remove_member_type' != $new_type && null === bp_get_member_type_object( $new_type ) ) { 2133 $error = true; 2134 } else { 2135 // Run through user ids. 2136 $error = false; 2137 foreach ( (array) $_REQUEST['users'] as $user_id ) { 2138 $user_id = (int) $user_id; 2139 2140 // Get the old member type to check against. 2141 $member_type = bp_get_member_type( $user_id ); 2142 2143 if ( 'remove_member_type' === $new_type ) { 2144 // Remove the current member type, if there's one to remove. 2145 if ( $member_type ) { 2146 $removed = bp_remove_member_type( $user_id, $member_type ); 2147 if ( false === $removed || is_wp_error( $removed ) ) { 2148 $error = true; 2149 } 2154 2150 } 2155 } 2156 } else {2157 // Set the new member type.2158 if ( $new_type !== $member_type ) {2159 $set = bp_set_member_type( $user_id, $new_type );2160 if ( false == $set || is_wp_error( $set ) ) {2161 $error = true;2151 } else { 2152 // Set the new member type. 2153 if ( $new_type !== $member_type ) { 2154 $set = bp_set_member_type( $user_id, $new_type ); 2155 if ( false === $set || is_wp_error( $set ) ) { 2156 $error = true; 2157 } 2162 2158 } 2163 2159 } … … 2185 2181 2186 2182 // Display feedback. 2187 if ( $updated && in_array( $updated, array( 'member-type-change-error', 'member-type-change-success' ) ) ) {2183 if ( $updated && in_array( $updated, array( 'member-type-change-error', 'member-type-change-success' ), true ) ) { 2188 2184 2189 2185 if ( 'member-type-change-error' === $updated ) { 2190 2186 $notice = __( 'There was an error while changing member type. Please try again.', 'buddypress' ); 2187 $type = 'error'; 2191 2188 } else { 2192 2189 $notice = __( 'Member type was changed successfully.', 'buddypress' ); 2190 $type = 'updated'; 2193 2191 } 2194 2192 2195 bp_core_add_admin_notice( $notice );2193 bp_core_add_admin_notice( $notice, $type ); 2196 2194 } 2197 2195 } … … 2235 2233 if ( $type_obj = bp_get_member_type_object( $type ) ) { 2236 2234 $url = add_query_arg( array( 'bp-member-type' => urlencode( $type ) ) ); 2237 $retval = '<a href="' . esc_url( $url ) . '">' . $type_obj->labels['singular_name']. '</a>';2235 $retval = '<a href="' . esc_url( $url ) . '">' . esc_html( $type_obj->labels['singular_name'] ) . '</a>'; 2238 2236 } 2239 2237
Note: See TracChangeset
for help on using the changeset viewer.