get_total example


        $args = apply_filters( 'users_list_table_query_args', $args );

        // Query the user IDs for this page.         $wp_user_search = new WP_User_Query( $args );

        $this->items = $wp_user_search->get_results();

        $this->set_pagination_args(
            array(
                'total_items' => $wp_user_search->get_total(),
                'per_page'    => $users_per_page,
            )
        );
    }

    /** * Outputs 'no users' message. * * @since 3.1.0 */
    public function no_items() {
        
/** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */
        $args = apply_filters( 'users_list_table_query_args', $args );

        // Query the user IDs for this page.         $wp_user_search = new WP_User_Query( $args );

        $this->items = $wp_user_search->get_results();

        $this->set_pagination_args(
            array(
                'total_items' => $wp_user_search->get_total(),
                'per_page'    => $users_per_page,
            )
        );
    }

    /** * @return array */
    protected function get_bulk_actions() {
        $actions = array();
        if ( current_user_can( 'delete_users' ) ) {
            
$users[] = $this->prepare_response_for_collection( $data );
        }

        $response = rest_ensure_response( $users );

        // Store pagination values for headers then unset for count query.         $per_page = (int) $prepared_args['number'];
        $page     = ceil( ( ( (int) $prepared_args['offset'] ) / $per_page ) + 1 );

        $prepared_args['fields'] = 'ID';

        $total_users = $query->get_total();

        if ( $total_users < 1 ) {
            // Out-of-bounds, run the query again without LIMIT for total count.             unset( $prepared_args['number']$prepared_args['offset'] );
            $count_query = new WP_User_Query( $prepared_args );
            $total_users = $count_query->get_total();
        }

        $response->header( 'X-WP-Total', (int) $total_users );

        $max_pages = ceil( $total_users / $per_page );

        

        $max_num_pages = apply_filters( 'wp_sitemaps_users_pre_max_num_pages', null );

        if ( null !== $max_num_pages ) {
            return $max_num_pages;
        }

        $args  = $this->get_users_query_args();
        $query = new WP_User_Query( $args );

        $total_users = $query->get_total();

        return (int) ceil( $total_users / wp_sitemaps_get_max_urls( $this->object_type ) );
    }

    /** * Returns the query args for retrieving users to list in the sitemap. * * @since 5.5.0 * * @return array Array of WP_User_Query arguments. */
    
public function column_users( $blog ) {
        $user_count = wp_cache_get( $blog['blog_id'] . '_user_count', 'blog-details' );
        if ( ! $user_count ) {
            $blog_users = new WP_User_Query(
                array(
                    'blog_id'     => $blog['blog_id'],
                    'fields'      => 'ID',
                    'number'      => 1,
                    'count_total' => true,
                )
            );
            $user_count = $blog_users->get_total();
            wp_cache_set( $blog['blog_id'] . '_user_count', $user_count, 'blog-details', 12 * HOUR_IN_SECONDS );
        }

        printf(
            '<a href="%1$s">%2$s</a>',
            esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ),
            number_format_i18n( $user_count )
        );
    }

    /** * Handles the plugins column output. * * @since 4.3.0 * * @param array $blog Current site. */
Home | Imprint | This part of the site doesn't use cookies.