BP_Document_Folder_Template::__construct( array $args )

Constructor method.

Description

The arguments passed to this class constructor are of the same format as BP_Document_Folder::get().

See also

Parameters

$args

(Required) Array of arguments. Supports all arguments from BP_Document_Folder::get(), as well as 'page_arg' and 'include'. Default values for 'per_page' differ from the originating function, and are described below

Source

File: bp-document/classes/class-bp-document-folder-template.php

133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
public function __construct( $args ) {
 
    $defaults = array(
        'page'         => 1,
        'per_page'     => 20,
        'page_arg'     => 'acpage',
        'max'          => false,
        'user_id'      => false,
        'fields'       => 'all',
        'count_total'  => false,
        'sort'         => false,
        'include'      => false,
        'exclude'      => false,
        'privacy'      => false,
        'search_terms' => false,
    );
    $r        = wp_parse_args( $args, $defaults );
    extract( $r );
 
    $this->pag_arg  = sanitize_key( $r['page_arg'] );
    $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $r['page'] );
    $this->pag_num  = bp_sanitize_pagination_arg( 'num', $r['per_page'] );
 
    // Get an array of the logged in user's favorite folder.
    $this->my_favs = bp_get_user_meta( bp_loggedin_user_id(), 'bp_favorite_folder', true );
 
    // Fetch specific folder items based on ID's.
    if ( ! empty( $include ) ) {
        $this->folders = bp_folder_get_specific(
            array(
                'folder_ids'  => explode( ',', $include ),
                'max'         => $max,
                'count_total' => $count_total,
                'page'        => $this->pag_page,
                'per_page'    => $this->pag_num,
                'sort'        => $sort,
                'user_id'     => $user_id,
            )
        );
 
        // Fetch all folder.
    } else {
        $this->folders = bp_folder_get(
            array(
                'max'          => $max,
                'count_total'  => $count_total,
                'per_page'     => $this->pag_num,
                'page'         => $this->pag_page,
                'sort'         => $sort,
                'search_terms' => $search_terms,
                'user_id'      => $user_id,
                'group_id'     => $group_id,
                'exclude'      => $exclude,
                'privacy'      => $privacy,
            )
        );
    }
 
    // The total_folder_count property will be set only if a
    // 'count_total' query has taken place.
    if ( ! is_null( $this->folders['total'] ) ) {
        if ( ! $max || $max >= (int) $this->folders['total'] ) {
            $this->total_folder_count = (int) $this->folders['total'];
        } else {
            $this->total_folder_count = (int) $max;
        }
    }
 
    $this->has_more_items = $this->folders['has_more_items'];
 
    $this->folders = $this->folders['folders'];
 
    if ( $max ) {
        if ( $max >= count( $this->folders ) ) {
            $this->folder_count = count( $this->folders );
        } else {
            $this->folder_count = (int) $max;
        }
    } else {
        $this->folder_count = count( $this->folders );
    }
 
    if ( (int) $this->total_folder_count && (int) $this->pag_num ) {
        $this->pag_links = paginate_links(
            array(
                'base'      => add_query_arg( $this->pag_arg, '%#%' ),
                'format'    => '',
                'total'     => ceil( (int) $this->total_folder_count / (int) $this->pag_num ),
                'current'   => (int) $this->pag_page,
                'prev_text' => __( '←', 'buddyboss' ),
                'next_text' => __( '→', 'buddyboss' ),
                'mid_size'  => 1,
                'add_args'  => array(),
            )
        );
    }
}

Changelog

Changelog
Version Description
BuddyBoss 1.4.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.