bp_nouveau_ajax_albums_loader()

Load the template loop for the albums object.

Description

Return

(string) Template loop for the albums object

Source

File: bp-templates/bp-nouveau/includes/media/ajax.php

116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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
function bp_nouveau_ajax_albums_loader() {
    $response = array(
        'feedback' => sprintf(
            '<div class="bp-feedback error bp-ajax-message"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>',
            esc_html__( 'There was a problem performing this action. Please try again.', 'buddyboss' )
        ),
    );
 
    // Bail if not a POST action.
    if ( ! bp_is_post_request() ) {
        wp_send_json_error( $response );
    }
 
    if ( empty( $_POST['_wpnonce'] ) ) {
        wp_send_json_error( $response );
    }
 
    // Use default nonce
    $nonce = $_POST['_wpnonce'];
    $check = 'bp_nouveau_media';
 
    // Nonce check!
    if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, $check ) ) {
        wp_send_json_error( $response );
    }
 
    $page = ! empty( $_POST['page'] ) ? (int) $_POST['page'] : 1;
 
    ob_start();
    if ( bp_has_albums( array( 'page' => $page ) ) ) {
        while ( bp_album() ) {
            bp_the_album();
            bp_get_template_part( 'media/album-entry' );
        }
 
        if ( bp_album_has_more_items() ) : ?>
 
            <li class="load-more">
                <a class="button outline" href="<?php bp_album_has_more_items(); ?>"><?php esc_html_e( 'Load More', 'buddyboss' ); ?></a>
            </li>
 
        <?php endif;
    }
    $albums = ob_get_contents();
    ob_end_clean();
 
    wp_send_json_success( array(
        'albums' => $albums,
    ) );
}

Changelog

Changelog
Version Description
BuddyBoss 1.0.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.