'user', 'plural' => 'users', 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, ) ); add_filter( 'manage_users_custom_column', array( $this, 'fourlogin_user_info_column' ) ,10 ,3 ); add_filter( 'users_list_table_query_args', array( $this, 'fourlogin_where_fourlogininfo' ) ); } /** * Get a list of columns for the fourlogin users list table. * * @return array Array in which the key is the ID of the column, * and the value is the description. */ /* public function get_columns() { $c = array( 'cb' => '', 'username' => __( 'Username', '4login-for-wp' ), 'email' => __( 'Email', '4login-for-wp' ), 'role' => __( 'Role', '4login-for-wp' ), 'made_by_fourlogin' => __( '4Login info', '4login-for-wp' ), 'fourlogin_sent' => __('Sent 4Login Code', '4login-for-wp'), ); return $c; } /** * Get a list of sortable columns for the fourlogin users list table. * * @access protected * @return array Array of sortable columns. */ /* protected function get_sortable_columns() { $c = array( 'username' => 'login', 'email' => 'email', ); return $c; } /** * Return an associative array listing all the views that can be used * with this table. * * Provides a list of info about fourlogin login. * * @access protected * @return array An array of HTML links, one for each view. */ /* protected function get_views() { $fourlogin_info = array( 1, 3, 0 ); $url = 'admin.php?page=fourlogin_manage_users'; // Append nonce field to url. $nonce = wp_create_nonce('fourlogininfo_action'); $url_with_nonce = add_query_arg(array( 'fourlogininfo_nonce' => $nonce ), $url); $total_users = $this -> fourlogin_count_users(); $class = ! isset( $_GET['fourlogininfo'] ) && wp_verify_nonce($_GET['fourlogininfo_nonce'], 'fourlogininfo_action')? ' class="current"' : ''; $fourlogin_info_links = array(); $fourlogin_info_links['all'] = "" . sprintf( /* translators: %s: The number of 4login users in your site */ /* __( 'All (%s)', '4login-for-wp' ), number_format_i18n( $total_users ) ) . ''; foreach ( $fourlogin_info as $made_by_fourlogin ) { $class = ''; $fourlogin_users = $this -> fourlogin_count_users( $made_by_fourlogin ); if ( isset( $_GET['fourlogininfo'] ) && $made_by_fourlogin == $_GET['fourlogininfo'] && wp_verify_nonce($_GET['fourlogininfo_nonce'], 'fourlogininfo_action') ) { $class = ' class="current"'; } // translators: fourlogininfo name with count $name = $this -> fourlogin_get_text_fourlogininfo( $made_by_fourlogin ); $name = sprintf( /* translators: 1: Message for user_meta 'made_by_fourlogin' 2: The number of fourlogin_users */ /* __('%1$s (%2$s)', '4login-for-wp'), $name, number_format_i18n( $fourlogin_users ) ); // Append the number of fourlogin_users to url. $url_with_params = add_query_arg(array( 'fourlogininfo' => $made_by_fourlogin, ), $url_with_nonce); $fourlogin_info_links[$made_by_fourlogin] = "$name"; } return $fourlogin_info_links; } /** * Get count of total users for current page. * @param string $made_by_fourlogin * @return number */ /* private function fourlogin_count_users( $made_by_fourlogin = '' ){ if ( $made_by_fourlogin ){ $args = array( 'meta_key' => 'made_by_fourlogin', 'meta_value' => 1 == $made_by_fourlogin? array( 1, 2 ) : $made_by_fourlogin, 'meta_compare' => 'IN', 'count_total' => true, 'fields' => 'ID', ); } elseif ( 0 === $made_by_fourlogin ) { $args = array( 'meta_key' => 'made_by_fourlogin', 'meta_compare' => 'NOT EXISTS', 'count_total' => true, 'fields' => 'ID', ); } else { $args = array( 'count_total' => true, 'fields' => 'ID', ); } $fourlogin_count = new WP_User_Query( $args ); return $fourlogin_count -> total_users; } /** * Make the content of "FourLogin info" and "Sent FourLogin Code" * * @param string $output * @param string $column_name * @param int $user_id * @return Ambigous */ /* public function fourlogin_user_info_column( $output, $column_name, $user_id ){ if ( 'made_by_fourlogin' == $column_name ){ $output = get_user_meta( $user_id, 'made_by_fourlogin', true); $output = $this -> fourlogin_get_text_fourlogininfo( $output ); } elseif ('fourlogin_sent'){ $output = get_user_meta( $user_id, 'fourlogin_sent_fourlogincode', true); if( $output ){ $output = esc_attr( $output ); } else { $output = ''; } } return $output; } /** * Translate 'made_by_fourlogin' to display message. * * @param int||blank $made_by_fourlogin 1, 2, 3 or '' * @return string message for user_meta 'made_by_fourlogin' */ /* static function fourlogin_get_text_fourlogininfo( $made_by_fourlogin ){ switch ( $made_by_fourlogin ){ case 1: case 2: return __( 'Made by 4Login', '4login-for-wp' ); break; case 3: return __( 'Already logged in with 4Login(Existing User)', '4login-for-wp' ); break; default: return __( 'Not yet logged in with 4Login', '4login-for-wp' ); break; } } /** * Make sql query to select users who used fourlogin or not. * @param unknown $args * @return multitype:number string */ /* public function fourlogin_where_fourlogininfo( $args ){ if ( isset( $_GET['fourlogininfo'] ) && wp_verify_nonce($_GET['fourlogininfo_nonce'],'fourlogininfo_action')){ switch ( $_GET['fourlogininfo'] && wp_verify_nonce($_GET['fourlogininfo_nonce'],'fourlogininfo_action')){ case 1: case 2: $args['meta_value'] = array( 1, 2 ); $args['meta_key'] = 'made_by_fourlogin'; $args['meta_compare'] = 'IN'; break; case 3: $args['meta_value'] = 3; $args['meta_key'] = 'made_by_fourlogin'; $args['meta_compare'] = '='; break; default: $args['meta_key'] = 'made_by_fourlogin'; $args['meta_compare'] = 'NOT EXISTS'; break; } } return $args; } /** * Retrieve an associative array of bulk actions available on this table. * * @access protected * @return array Array of bulk actions. */ /* protected function get_bulk_actions() { return $actions; } protected function extra_tablenav( $which ) { } protected function bulk_actions( $which = '' ) { wp_nonce_field('fourlogin_send_mail_action','fourlogin_send_mail_nonce'); echo ''; submit_button( __( 'Send 4Login Code', '4login-for-wp' ), 'action', '', false, array( 'id' => "doaction" ) ); echo "\n"; } } */