-// WP_User_Search class
-// by Mark Jaquith
-
-if ( !class_exists('WP_User_Search') ) :
-class WP_User_Search {
- var $results;
- var $search_term;
- var $page;
- var $role;
- var $raw_page;
- var $users_per_page = 50;
- var $first_user;
- var $last_user;
- var $query_limit;
- var $query_sort;
- var $query_from_where;
- var $total_users_for_query = 0;
- var $too_many_total_users = false;
- var $search_errors;
-
- function WP_User_Search ($search_term = '', $page = '', $role = '') { // constructor
- $this->search_term = $search_term;
- $this->raw_page = ( '' == $page ) ? false : (int) $page;
- $this->page = (int) ( '' == $page ) ? 1 : $page;
- $this->role = $role;
-
- $this->prepare_query();
- $this->query();
- $this->prepare_vars_for_template_usage();
- $this->do_paging();
- }
-
- function prepare_query() {
- global $wpdb;
- $this->first_user = ($this->page - 1) * $this->users_per_page;
- $this->query_limit = $wpdb->prepare(" LIMIT %d, %d", $this->first_user, $this->users_per_page);
- $this->query_sort = ' ORDER BY user_login';
- $search_sql = '';
- if ( $this->search_term ) {
- $searches = array();
- $search_sql = 'AND (';
- foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col )
- $searches[] = $col . " LIKE '%$this->search_term%'";
- $search_sql .= implode(' OR ', $searches);
- $search_sql .= ')';
- }
-
- $this->query_from_where = "FROM $wpdb->users";
- if ( $this->role )
- $this->query_from_where .= $wpdb->prepare(" INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');
- else
- $this->query_from_where .= " WHERE 1=1";
- $this->query_from_where .= " $search_sql";
-
- }
-
- function query() {
- global $wpdb;
- $this->results = $wpdb->get_col('SELECT ID ' . $this->query_from_where . $this->query_sort . $this->query_limit);
-
- if ( $this->results )
- $this->total_users_for_query = $wpdb->get_var('SELECT COUNT(ID) ' . $this->query_from_where); // no limit
- else
- $this->search_errors = new WP_Error('no_matching_users_found', __('No matching users were found!'));
- }
-
- function prepare_vars_for_template_usage() {
- $this->search_term = stripslashes($this->search_term); // done with DB, from now on we want slashes gone
- }
-
- function do_paging() {
- if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results
- $args = array();
- if( ! empty($this->search_term) )
- $args['usersearch'] = urlencode($this->search_term);
- if( ! empty($this->role) )
- $args['role'] = urlencode($this->role);
-
- $this->paging_text = paginate_links( array(
- 'total' => ceil($this->total_users_for_query / $this->users_per_page),
- 'current' => $this->page,
- 'base' => 'users.php?%_%',
- 'format' => 'userspage=%#%',
- 'add_args' => $args
- ) );
- }
- }
-
- function get_results() {
- return (array) $this->results;
+add_action('admin_init', 'default_password_nag_handler');
+/**
+ * @since 2.8.0
+ */
+function default_password_nag_handler($errors = false) {
+ global $user_ID;
+ if ( ! get_user_option('default_password_nag') ) //Short circuit it.
+ return;
+
+ //get_user_setting = JS saved UI setting. else no-js-fallback code.
+ if ( 'hide' == get_user_setting('default_password_nag') || isset($_GET['default_password_nag']) && '0' == $_GET['default_password_nag'] ) {
+ delete_user_setting('default_password_nag');
+ update_user_option($user_ID, 'default_password_nag', false, true);