bp_media_import_submenu_page()

Import Media menu page

Description

Source

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

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.