bp_media_import_submenu_page()

Import Media menu page

Description

Source

File: bp-media/bp-media-filters.php

1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
function bp_media_import_submenu_page() {
    global $wpdb, $background_updater;
 
    $bp_media_import_status = get_option( 'bp_media_import_status' );
 
    if ( isset( $_POST['bp-media-import-submit'] ) && ! empty( $background_updater ) ) {
        $update_queued          = false;
 
        if ( 'done' != $bp_media_import_status ) {
            foreach ( bp_media_get_import_callbacks() as $update_callback ) {
                error_log( sprintf( 'Queuing %s', $update_callback ) );
                $background_updater->push_to_queue( $update_callback );
                $update_queued = true;
            }
        }
 
        if ( $update_queued ) {
            $background_updater->save()->dispatch();
        }
    }
 
    $check                        = false;
    $buddyboss_media_table        = $wpdb->prefix . 'buddyboss_media';
    $buddyboss_media_albums_table = $wpdb->prefix . 'buddyboss_media_albums';
    if ( empty( $wpdb->get_results( "SHOW TABLES LIKE '{$buddyboss_media_table}' ;" ) ) || empty( $wpdb->get_results( "SHOW TABLES LIKE '{$buddyboss_media_albums_table}' ;" ) ) ) {
        $check = true;
    }
 
    ?>
    <div class="wrap">
        <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Tools', 'buddyboss' ) ); ?></h2>
        <div class="nav-settings-subsubsub">
            <ul class="subsubsub">
                <?php bp_core_tools_settings_admin_tabs(); ?>
            </ul>
        </div>
    </div>
    <div class="wrap">
        <div class="bp-admin-card section-bp-member-type-import">
            <div class="boss-import-area">
                <form id="bp-member-type-import-form" method="post" action="">
                    <div class="import-panel-content">
                        <h2><?php _e( 'Import Media', 'buddyboss' ); ?></h2>
 
                        <?php if ( $check ) {
                            ?>
                            <p><?php _e( 'BuddyBoss Media plugin database tables do not exist, meaning you have nothing to import.', 'buddyboss' ); ?></p>
                            <?php
                        } else if ( ! empty( $background_updater ) && $background_updater->is_updating() ) {
                            $total_media   = get_option( 'bp_media_import_total_media', 0 );
                            $total_albums  = get_option( 'bp_media_import_total_albums', 0 );
                            $albums_done   = get_option( 'bp_media_import_albums_done', 0 );
                            $media_done    = get_option( 'bp_media_import_media_done', 0 );
                            ?>
                            <p>
                                <?php esc_html_e( 'Your database is being updated in the background.', 'buddyboss' ); ?>
                            </p>
                            <table>
                                <tr>
                                    <td><h4><?php _e( 'Albums', 'buddyboss' ); ?></h4></td>
                                    <td><span id="bp-media-import-albums-done"><?php echo $albums_done; ?></span> <?php _e( 'out of', 'buddyboss' ); ?> <span id="bp-media-import-albums-total"><?php echo $total_albums; ?></span></td>
                                </tr>
                                <tr>
                                    <td><h4><?php _e( 'Media', 'buddyboss' ); ?></h4></td>
                                    <td><span id="bp-media-import-media-done"><?php echo $media_done; ?></span> <?php _e( 'out of', 'buddyboss' ); ?> <span id="bp-media-import-media-total"><?php echo $total_media; ?></span></td>
                                </tr>
                            </table>
                            <p>
                                <label id="bp-media-import-msg"></label>
                            </p>
                            <input type="hidden" value="bp-media-import-updating" id="bp-media-import-updating" />
                            <?php
                        } else if ( 'done' == $bp_media_import_status ) {
                            ?>
                            <p><?php _e( 'BuddyBoss Media data update is complete! Any previously uploaded member photos should display in their profiles now.', 'buddyboss' ); ?></p>
                            <?php
                        } else { ?>
                            <p><?php _e( 'Import your existing members photo uploads, if you were previously using <a href="https://www.buddyboss.com/product/buddyboss-media/">BuddyBoss Media</a> with BuddyPress. Click "Run Migration" below to migrate your old photos into the new Media component.', 'buddyboss' ); ?></p>
                            <input type="submit" value="<?php _e('Run Migration', 'buddyboss'); ?>" id="bp-media-import-submit" name="bp-media-import-submit" class="button-primary"/>
                        <?php } ?>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <br />
 
    <?php
}

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.