/**
 * Register member types.
 *
 * If the field type is set and has options. These options will dynamically build the member type
 * Use the name to set options into the xProfile Field Admin UI eg: Has CF
 *
 * @since 1.0.0
 */
function cfbgr_register_member_types()
{
    $saved_option = (int) bp_get_option('cfbgr_xfield_id', 0);
    if (empty($saved_option)) {
        return;
    }
    $field = xprofile_get_field($saved_option);
    // This case means the option was not deleted when it oughts to be
    if (empty($field->type_obj) || !is_a($field->type_obj, 'CF_BG_Member_Type_Field_Type')) {
        bp_delete_option('cfbgr_xfield_id');
        return;
    }
    // Object cache this field
    buddypress()->groups->restrictions->member_type_field = $field;
    $options = $field->get_children(true);
    if (!is_array($options)) {
        return;
    }
    foreach ($options as $member_type) {
        if (empty($member_type->name)) {
            continue;
        }
        bp_register_member_type(sanitize_key($member_type->name), array('labels' => array('name' => $member_type->name)));
    }
}
Esempio n. 2
0
 /**
  * @group upload
  * @group check_mimes
  */
 public function test_buddydrive_upload_item_mimes()
 {
     $reset_files = $_FILES;
     $reset_post = $_POST;
     $file = trailingslashit(buddydrive()->plugin_dir) . 'readme.txt';
     $tmp_name = wp_tempnam($file);
     copy($file, $tmp_name);
     $_POST['action'] = 'buddydrive_upload';
     $_FILES['buddyfile-upload'] = array('tmp_name' => $tmp_name, 'name' => 'readme.txt', 'type' => 'text/plain', 'error' => 0, 'size' => filesize($file));
     bp_update_option('_buddydrive_allowed_extensions', array('png'));
     // Upload the file
     $upload = buddydrive_upload_item($_FILES, bp_loggedin_user_id());
     $this->assertTrue(!empty($upload['error']));
     bp_update_option('_buddydrive_allowed_extensions', array('png', 'txt|asc|c|cc|h|srt'));
     $upload = buddydrive_upload_item($_FILES, bp_loggedin_user_id());
     $this->assertTrue(file_exists($upload['file']));
     bp_delete_option('_buddydrive_allowed_extensions');
     // clean up!
     $_FILES = $reset_files;
     $_POST = $reset_post;
 }
Esempio n. 3
0
/**
 * Outputs the markup for the bb-forums-admin panel
 */
function bp_forums_bbpress_admin()
{
    // The text and URL of the Site Wide Forums button differs depending on whether bbPress
    // is running
    if (is_plugin_active('bbpress/bbpress.php')) {
        // The bbPress admin page will always be on the root blog. switch_to_blog() will
        // pass through if we're already there.
        switch_to_blog(bp_get_root_blog_id());
        $button_url = admin_url(add_query_arg(array('page' => 'bbpress'), 'options-general.php'));
        restore_current_blog();
        $button_text = __('Configure bbPress', 'buddypress');
    } else {
        $button_url = bp_get_admin_url(add_query_arg(array('tab' => 'plugin-information', 'plugin' => 'bbpress', 'TB_iframe' => 'true', 'width' => '640', 'height' => '500'), 'plugin-install.php'));
        $button_text = __('Install bbPress', 'buddypress');
    }
    $action = bp_get_admin_url('admin.php?page=bb-forums-setup&reinstall=1');
    ?>

	<div class="wrap">
		<?php 
    screen_icon('buddypress');
    ?>

		<h2 class="nav-tab-wrapper"><?php 
    bp_core_admin_tabs(__('Forums', 'buddypress'));
    ?>
</h2>

		<?php 
    if (isset($_POST['submit'])) {
        ?>

			<div id="message" class="updated fade">
				<p><?php 
        _e('Settings Saved.', 'buddypress');
        ?>
</p>
			</div>

		<?php 
    }
    ?>

		<?php 
    if (isset($_REQUEST['reinstall']) || !bp_forums_is_installed_correctly()) {
        // Delete the bb-config.php location option
        bp_delete_option('bb-config-location');
        // Now delete the bb-config.php file
        @unlink(ABSPATH . 'bb-config.php');
        // show the updated wizard
        bp_forums_bbpress_install_wizard();
    } else {
        ?>

			<div style="width: 45%; float: left; margin-top: 20px;">
				<h3><?php 
        _e('(Installed)', 'buddypress');
        ?>
 <?php 
        _e('Forums for Groups', 'buddypress');
        ?>
</h3>

				<p><?php 
        _e('Give each individual group its own discussion forum. Choose this if you\'d like to keep your members\' conversations separated into distinct areas.', 'buddypress');
        ?>
</p>

				<p><?php 
        _e('Note: This component is retired and will not be receiving any updates in the future.  Only use this component if your current site relies on it.', 'buddypress');
        ?>
</p>

				<h4 style="margin-bottom: 10px;"><?php 
        _e('Features', 'buddypress');
        ?>
</h4>
				<ul class="description" style="list-style: square; margin-left: 30px;">
					<li><?php 
        _e('Group Integration', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Member Profile Integration', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Activity Stream Integration', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('@ Mention Integration', 'buddypress');
        ?>
</p></li>
				</ul>

				<div>
					<a class="button button-primary confirm" href="<?php 
        echo $action;
        ?>
"><?php 
        _e('Uninstall Group Forums', 'buddypress');
        ?>
</a> &nbsp;
				</div>
			</div>

			<div style="width: 45%; float: left; margin: 20px 0 20px 20px; padding: 0 20px 20px 20px; border: 1px solid #ddd; background-color: #fff;">
				<h3><?php 
        _e('New! bbPress', 'buddypress');
        ?>
</h3>
				<p><?php 
        _e('bbPress is a brand-new forum plugin from one of the lead developers of BuddyPress.', 'buddypress');
        ?>
</p>

				<p><?php 
        _e('It boasts a bunch of cool features that the BP Legacy Discussion Forums does not have including:', 'buddypress');
        ?>
</p>

				<ul class="description" style="list-style: square; margin-left: 30px;">
					<li><?php 
        _e('Non-group specific forum creation', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Moderation via the WP admin dashboard', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Topic splitting', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Revisions', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Spam management', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Subscriptions', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('And more!', 'buddypress');
        ?>
</p></li>
				</ul>

				<p><?php 
        printf(__('If you decide to use bbPress, you will need to deactivate the legacy group forum component.  For more info, <a href="%s">read this codex article</a>.', 'buddypress'), 'http://codex.buddypress.org/user/setting-up-a-new-installation/installing-group-and-sitewide-forums/using-bbpress-2-2-with-buddypress/');
        ?>
</p>

				<div>
					<a class="button thickbox button-primary" href="<?php 
        echo esc_attr($button_url);
        ?>
"><?php 
        echo esc_html($button_text);
        ?>
</a> &nbsp;
				</div>
			</div>

		<?php 
    }
    ?>

	</div>
<?php 
}
/**
 * Save the profile field that will hold the member types
 *
 * @param  BP_XProfile_Field $field
 */
function cfbgr_set_xprofile_member_types_field($field = null)
{
    if (empty($field->id)) {
        return;
    }
    $saved_option = (int) bp_get_option('cfbgr_xfield_id', 0);
    if (!empty($saved_option) && $saved_option !== (int) $field->id) {
        return;
    }
    if (!empty($saved_option) && $saved_option === (int) $field->id) {
        if ('member_type' !== $field->type) {
            bp_delete_option('cfbgr_xfield_id');
        }
    }
    // First time
    if (empty($saved_option) && 'member_type' === $field->type) {
        bp_update_option('cfbgr_xfield_id', (int) $field->id);
    }
}
Esempio n. 5
0
/**
 * Outputs the markup for the bb-forums-admin panel
 */
function bp_forums_bbpress_admin()
{
    global $bp;
    // The text and URL of the Site Wide Forums button differs depending on whether bbPress
    // is running
    if (is_plugin_active('bbpress/bbpress.php')) {
        // The bbPress admin page will always be on the root blog. switch_to_blog() will
        // pass through if we're already there.
        switch_to_blog(bp_get_root_blog_id());
        $button_url = admin_url(add_query_arg(array('page' => 'bbpress'), 'options-general.php'));
        restore_current_blog();
        $button_text = __('Configure Site Wide Forums', 'buddypress');
    } else {
        $button_url = bp_get_admin_url(add_query_arg(array('tab' => 'plugin-information', 'plugin' => 'bbpress', 'TB_iframe' => 'true', 'width' => '640', 'height' => '500'), 'plugin-install.php'));
        $button_text = __('Install Site Wide Forums', 'buddypress');
    }
    $action = bp_get_admin_url('admin.php?page=bb-forums-setup&reinstall=1');
    ?>

	<div class="wrap">
		<?php 
    screen_icon('buddypress');
    ?>

		<h2 class="nav-tab-wrapper"><?php 
    bp_core_admin_tabs(__('Forums', 'buddypress'));
    ?>
</h2>

		<?php 
    if (isset($_POST['submit'])) {
        ?>

			<div id="message" class="updated fade">
				<p><?php 
        _e('Settings Saved.', 'buddypress');
        ?>
</p>
			</div>

		<?php 
    }
    ?>

		<?php 
    if (isset($_REQUEST['reinstall']) || !bp_forums_is_installed_correctly()) {
        // Delete the bb-config.php location option
        bp_delete_option('bb-config-location');
        bp_forums_bbpress_install_wizard();
    } else {
        ?>

			<div style="width: 45%; float: left; margin-top: 20px;">
				<h3><?php 
        _e('(Installed)', 'buddypress');
        ?>
 <?php 
        _e('Forums for Groups', 'buddypress');
        ?>
</h3>

				<p><?php 
        _e('Give each individual group its own discussion forum. Choose this if you\'d like to keep your members\' conversations separated into distinct areas.', 'buddypress');
        ?>
</p>
				<p class="description"><?php 
        _e('You may use an existing bbPress installation if you have one.', 'buddypress');
        ?>
</p>

				<h4 style="margin-bottom: 10px;"><?php 
        _e('Features', 'buddypress');
        ?>
</h4>
				<ul class="description" style="list-style: square; margin-left: 30px;">
					<li><?php 
        _e('Group Integration', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Member Profile Integration', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Activity Stream Integration', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('@ Mention Integration', 'buddypress');
        ?>
</p></li>
				</ul>

				<div>
					<a class="button button-primary" href="<?php 
        echo $action;
        ?>
"><?php 
        _e('Uninstall Group Forums', 'buddypress');
        ?>
</a> &nbsp;
				</div>
			</div>

			<div style="width: 45%; float: left; margin: 20px 0 20px 20px; padding: 0 20px 20px 20px; border: 1px solid #ddd; background-color: #fff;">
				<h3><?php 
        _e('New! Site Wide Forums', 'buddypress');
        ?>
</h3>
				<p><?php 
        _e('Your site will have central forums that are not isolated to any specific group. Choose this if you\'d like to have a central forum area for your members.', 'buddypress');
        ?>
</p>
				<p class="description"><?php 
        _e('You may activate both Group and Site Wide forums, but this may create a poor experience for your members.', 'buddypress');
        ?>
</p>

				<h4 style="margin-bottom: 10px;"><?php 
        _e('Features', 'buddypress');
        ?>
</h4>
				<ul class="description" style="list-style: square; margin-left: 30px;">
					<li><?php 
        _e('Central Discussion Area', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Forum Plugins Available', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Activity Stream Integration', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('@ Mention Integration', 'buddypress');
        ?>
</p></li>
				</ul>

				<div>
					<a class="button thickbox button-primary" href="<?php 
        echo esc_attr($button_url);
        ?>
"><?php 
        echo esc_html($button_text);
        ?>
</a> &nbsp;
				</div>
			</div>

		<?php 
    }
    ?>

		<p class="clear description"><?php 
    printf(__('Need help deciding between Group Forums and Site Wide Forums? Visit <a href="%s">the BuddyPress codex</a> for more information.', 'buddypress'), 'http://codex.buddypress.org/getting-started/installing-group-and-sitewide-forums/');
    ?>
</p>
	</div>
<?php 
}
Esempio n. 6
0
function bp_forums_bbpress_admin()
{
    global $bp;
    $action = bp_get_admin_url('admin.php?page=bb-forums-setup&reinstall=1');
    ?>

	<div class="wrap">
		<?php 
    screen_icon('buddypress');
    ?>

		<h2 class="nav-tab-wrapper"><?php 
    bp_core_admin_tabs(__('Forums', 'buddypress'));
    ?>
</h2>

		<?php 
    if (isset($_POST['submit'])) {
        ?>

			<div id="message" class="updated fade">
				<p><?php 
        _e('Settings Saved.', 'buddypress');
        ?>
</p>
			</div>

		<?php 
    }
    ?>

		<?php 
    if (isset($_REQUEST['reinstall']) || !bp_forums_is_installed_correctly()) {
        // Delete the bb-config.php location option
        bp_delete_option('bb-config-location');
        bp_forums_bbpress_install_wizard();
    } else {
        ?>

			<div style="width: 45%; float: left; margin-top: 20px;">
				<h3><?php 
        _e('(Installed)', 'buddypress');
        ?>
 <?php 
        _e('Forums for Groups', 'buddypress');
        ?>
</h3>

				<p><?php 
        _e('Give each individual group its own discussion forum. Choose this if you\'d like to keep your members\' conversations separated into distinct areas.', 'buddypress');
        ?>
</p>
				<p class="description"><?php 
        _e('You may use an existing bbPress installation if you have one.', 'buddypress');
        ?>
</p>

				<h4 style="margin-bottom: 10px;"><?php 
        _e('Features', 'buddypress');
        ?>
</h4>
				<ul class="description" style="list-style: square; margin-left: 30px;">
					<li><?php 
        _e('Group Integration', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Member Profile Integration', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Activity Stream Integration', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('@ Mention Integration', 'buddypress');
        ?>
</p></li>
				</ul>

				<div>
					<a class="button button-primary" href="<?php 
        echo $action;
        ?>
"><?php 
        _e('Uninstall Group Forums', 'buddypress');
        ?>
</a> &nbsp;
				</div>
			</div>

			<div style="width: 45%; float: left; margin: 20px 0 20px 20px; padding: 0 20px 20px 20px; border: 1px solid #ddd; background-color: #fff;">
				<h3><?php 
        _e('New! Site Wide Forums', 'buddypress');
        ?>
</h3>
				<p><?php 
        _e('Your site will have central forums that are not isolated to any specific group. Choose this if you\'d like to have a central forum area for your members.', 'buddypress');
        ?>
</p>
				<p class="description"><?php 
        _e('You may activate both Group and Site Wide forums, but this may create a poor experience for your members.', 'buddypress');
        ?>
</p>

				<h4 style="margin-bottom: 10px;"><?php 
        _e('Features', 'buddypress');
        ?>
</h4>
				<ul class="description" style="list-style: square; margin-left: 30px;">
					<li><?php 
        _e('Central Discussion Area', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Forum Plugins Available', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('Activity Stream Integration', 'buddypress');
        ?>
</p></li>
					<li><?php 
        _e('@ Mention Integration', 'buddypress');
        ?>
</p></li>
				</ul>
				<div>
					<a class="button thickbox button-primary" href="<?php 
        bp_admin_url(add_query_arg(array('tab' => 'plugin-information', 'plugin' => 'bbpress', 'TB_iframe' => 'true', 'width' => '640', 'height' => '500'), 'plugin-install.php'));
        ?>
"><?php 
        _e('Install Site Wide Forums', 'buddypress');
        ?>
</a> &nbsp;
				</div>
			</div>

		<?php 
    }
    ?>

	</div>
<?php 
}
/**
 * Cleanup RBE.
 *
 * Clears RBE's scheduled hook from WP, as well as any DB entries and
 * files.
 *
 * @since 1.0-RC1
 */
function bp_rbe_cleanup()
{
    // remove remnants from any previous failed attempts to stop the inbox
    bp_rbe_should_stop();
    bp_rbe_remove_imap_lock();
    bp_rbe_remove_imap_connection_marker();
    // we don't use these options anymore
    bp_delete_option('bp_rbe_is_connected');
    bp_delete_option('bp_rbe_spawn_cron');
    bp_delete_option('bp_rbe_lock');
    delete_site_transient('bp_rbe_is_connected');
    delete_site_transient('bp_rbe_lock');
    // we don't use WP's cron feature anymore, but we clear RBE's old scheduled
    // hook just in case
    wp_clear_scheduled_hook('bp_rbe_schedule');
}
Esempio n. 8
0
/**
 * Renders the Settings admin panel.
 *
 * @package BuddyPress Core
 * @since {@internal Unknown}}
 */
function bp_core_admin_settings()
{
    global $wpdb, $bp;
    $ud = get_userdata(bp_loggedin_user_id());
    if (isset($_POST['bp-admin-submit']) && isset($_POST['bp-admin'])) {
        if (!check_admin_referer('bp-admin')) {
            return false;
        }
        // "Switch to Admin Bar" is an optional option, so handle it here
        if (!empty($_POST['bp-admin']['bp-force-buddybar'])) {
            unset($_POST['bp-admin']['bp-force-buddybar']);
            // Switch to the WP Admin Bar by removing the BuddyBar override
            bp_delete_option('bp-force-buddybar');
        }
        // Settings form submitted, now save the settings.
        foreach ((array) $_POST['bp-admin'] as $key => $value) {
            bp_update_option($key, $value);
        }
    }
    ?>

	<div class="wrap">

		<?php 
    screen_icon('buddypress');
    ?>

		<h2 class="nav-tab-wrapper"><?php 
    bp_core_admin_tabs(__('Settings', 'buddypress'));
    ?>
</h2>

		<?php 
    if (isset($_POST['bp-admin'])) {
        ?>

			<div id="message" class="updated fade">
				<p><?php 
        _e('Settings Saved', 'buddypress');
        ?>
</p>
			</div>

		<?php 
    }
    ?>

		<form action="" method="post" id="bp-admin-form">

			<table class="form-table">
				<tbody>

					<?php 
    if (bp_is_active('xprofile')) {
        ?>

						<tr>
							<th scope="row"><?php 
        _e('Disable BuddyPress to WordPress profile syncing?', 'buddypress');
        ?>
</th>
							<td>
								<input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php 
        if ((int) bp_get_option('bp-disable-profile-sync')) {
            ?>
 checked="checked"<?php 
        }
        ?>
 id="bp-disable-profile-sync" value="1" /> <?php 
        _e('Yes', 'buddypress');
        ?>
 &nbsp;
								<input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php 
        if (!(int) bp_get_option('bp-disable-profile-sync') || '' == bp_get_option('bp-disable-profile-sync')) {
            ?>
 checked="checked"<?php 
        }
        ?>
 id="bp-disable-profile-sync" value="0" /> <?php 
        _e('No', 'buddypress');
        ?>
							</td>
						</tr>

					<?php 
    }
    ?>

					<tr>
						<th scope="row"><?php 
    _e('Hide admin bar for logged out users?', 'buddypress');
    ?>
</th>
						<td>
							<input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php 
    if ((int) bp_get_option('hide-loggedout-adminbar')) {
        ?>
 checked="checked"<?php 
    }
    ?>
 id="bp-admin-hide-loggedout-adminbar-yes" value="1" /> <?php 
    _e('Yes', 'buddypress');
    ?>
 &nbsp;
							<input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php 
    if (!(int) bp_get_option('hide-loggedout-adminbar')) {
        ?>
 checked="checked"<?php 
    }
    ?>
 id="bp-admin-hide-loggedout-adminbar-no" value="0" /> <?php 
    _e('No', 'buddypress');
    ?>
						</td>
					</tr>

					<tr>
						<th scope="row"><?php 
    _e('Disable avatar uploads? (Gravatars will still work)', 'buddypress');
    ?>
</th>
						<td>
							<input type="radio" name="bp-admin[bp-disable-avatar-uploads]"<?php 
    if ((int) bp_get_option('bp-disable-avatar-uploads')) {
        ?>
 checked="checked"<?php 
    }
    ?>
 id="bp-admin-disable-avatar-uploads-yes" value="1" /> <?php 
    _e('Yes', 'buddypress');
    ?>
 &nbsp;
							<input type="radio" name="bp-admin[bp-disable-avatar-uploads]"<?php 
    if (!(int) bp_get_option('bp-disable-avatar-uploads')) {
        ?>
 checked="checked"<?php 
    }
    ?>
 id="bp-admin-disable-avatar-uploads-no" value="0" /> <?php 
    _e('No', 'buddypress');
    ?>
						</td>
					</tr>

					<tr>
						<th scope="row"><?php 
    _e('Disable user account deletion?', 'buddypress');
    ?>
</th>
						<td>
							<input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php 
    if ((int) bp_get_option('bp-disable-account-deletion')) {
        ?>
 checked="checked"<?php 
    }
    ?>
 id="bp-disable-account-deletion" value="1" /> <?php 
    _e('Yes', 'buddypress');
    ?>
 &nbsp;
							<input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php 
    if (!(int) bp_get_option('bp-disable-account-deletion')) {
        ?>
 checked="checked"<?php 
    }
    ?>
 id="bp-disable-account-deletion" value="0" /> <?php 
    _e('No', 'buddypress');
    ?>
						</td>
					</tr>

					<?php 
    if (bp_is_active('activity')) {
        ?>

						<tr>
							<th scope="row"><?php 
        _e('Disable activity stream commenting on blog and forum posts?', 'buddypress');
        ?>
</th>
							<td>
								<input type="radio" name="bp-admin[bp-disable-blogforum-comments]"<?php 
        if ((int) bp_get_option('bp-disable-blogforum-comments') || false === bp_get_option('bp-disable-blogforum-comments')) {
            ?>
 checked="checked"<?php 
        }
        ?>
 id="bp-disable-blogforum-comments" value="1" /> <?php 
        _e('Yes', 'buddypress');
        ?>
 &nbsp;
								<input type="radio" name="bp-admin[bp-disable-blogforum-comments]"<?php 
        if (!(int) bp_get_option('bp-disable-blogforum-comments')) {
            ?>
 checked="checked"<?php 
        }
        ?>
 id="bp-disable-blogforum-comments" value="0" /> <?php 
        _e('No', 'buddypress');
        ?>
							</td>
						</tr>

					<?php 
    }
    ?>

					<?php 
    if (bp_is_active('groups')) {
        ?>

						<tr>
							<th scope="row"><?php 
        _e('Restrict group creation to Site Admins?', 'buddypress');
        ?>
</th>
							<td>
								<input type="radio" name="bp-admin[bp_restrict_group_creation]"<?php 
        checked('1', bp_get_option('bp_restrict_group_creation', '0'));
        ?>
id="bp-restrict-group-creation" value="1" /> <?php 
        _e('Yes', 'buddypress');
        ?>
 &nbsp;
								<input type="radio" name="bp-admin[bp_restrict_group_creation]"<?php 
        checked('0', bp_get_option('bp_restrict_group_creation', '0'));
        ?>
id="bp-restrict-group-creation" value="0" /> <?php 
        _e('No', 'buddypress');
        ?>
							</td>
						</tr>

					<?php 
    }
    ?>

 					<?php 
    if ((bool) bp_get_option('bp-force-buddybar', false)) {
        ?>
						<tr>
							<th scope="row"><?php 
        _e('Switch the site to the WordPress Admin Bar?', 'buddypress');
        ?>
</th>
							<td>
								<input type="checkbox" name="bp-admin[bp-force-buddybar]" value="1" id="bp-switch-to-admin-bar" />
							</td>
						</tr>
					<?php 
    }
    ?>

					<?php 
    do_action('bp_core_admin_screen_fields');
    ?>

				</tbody>
			</table>

			<?php 
    do_action('bp_core_admin_screen');
    ?>

			<p class="submit">
				<input class="button-primary" type="submit" name="bp-admin-submit" id="bp-admin-submit" value="<?php 
    _e('Save Settings', 'buddypress');
    ?>
" />
			</p>

			<?php 
    wp_nonce_field('bp-admin');
    ?>

		</form>

	</div>

<?php 
}
/**
 * Populate the BP blogs table with existing blogs.
 *
 * Warning: By default, this will remove all existing records from the BP
 * blogs and blogmeta tables before re-populating the tables.
 *
 * @since 1.0.0
 * @since 2.6.0 Accepts $args as a parameter.
 *
 * @param array $args {
 *     Array of arguments.
 *     @type int   $offset   The offset to use.
 *     @type int   $limit    The number of blogs to record at one time.
 *     @type array $blog_ids Blog IDs to record. If empty, all blogs will be recorded.
 *     @type array $site_id  The network site ID to use.
 * }
 *
 * @return bool
 */
function bp_blogs_record_existing_blogs($args = array())
{
    global $wpdb;
    // Query for all sites in network.
    $r = bp_parse_args($args, array('offset' => false === bp_get_option('_bp_record_blogs_offset') ? 0 : bp_get_option('_bp_record_blogs_offset'), 'limit' => 50, 'blog_ids' => array(), 'site_id' => $wpdb->siteid), 'record_existing_blogs');
    // Truncate all BP blogs tables if starting fresh
    if (empty($r['offset']) && empty($r['blog_ids'])) {
        $bp = buddypress();
        // Truncate user blogs table
        $truncate = $wpdb->query("TRUNCATE {$bp->blogs->table_name}");
        if (is_wp_error($truncate)) {
            return false;
        }
        // Truncate user blogmeta table
        $truncate = $wpdb->query("TRUNCATE {$bp->blogs->table_name_blogmeta}");
        if (is_wp_error($truncate)) {
            return false;
        }
    }
    // Multisite
    if (is_multisite()) {
        $sql = array();
        $sql['select'] = $wpdb->prepare("SELECT blog_id, last_updated FROM {$wpdb->base_prefix}blogs WHERE mature = 0 AND spam = 0 AND deleted = 0 AND site_id = %d", $r['site_id']);
        // Omit root blog if large network
        if (wp_is_large_network('users')) {
            $sql['omit_root_blog'] = $wpdb->prepare("AND blog_id != %d", bp_get_root_blog_id());
        }
        // Filter by selected blog IDs
        if (!empty($r['blog_ids'])) {
            $in = implode(',', wp_parse_id_list($r['blog_ids']));
            $sql['in'] = "AND blog_id IN ({$in})";
        }
        $sql['orderby'] = 'ORDER BY blog_id ASC';
        $sql['limit'] = $wpdb->prepare("LIMIT %d", $r['limit']);
        if (!empty($r['offset'])) {
            $sql['offset'] = $wpdb->prepare("OFFSET %d", $r['offset']);
        }
        $blogs = $wpdb->get_results(implode(' ', $sql));
        // Record a single site.
    } else {
        // Just record blog for the current user only.
        $record = bp_blogs_record_blog($wpdb->blogid, get_current_user_id(), true);
        if (false === $record) {
            return false;
        } else {
            return true;
        }
    }
    // Bail if there are no blogs
    if (empty($blogs)) {
        // Make sure we remove our offset marker
        if (is_multisite()) {
            bp_delete_option('_bp_record_blogs_offset');
        }
        return false;
    }
    // Loop through users of blogs and record the relationship.
    foreach ((array) $blogs as $blog) {
        // Ensure that the cache is clear after the table TRUNCATE above.
        wp_cache_delete($blog->blog_id, 'blog_meta');
        // Get all users.
        $users = get_users(array('blog_id' => $blog->blog_id, 'fields' => 'ID'));
        // Continue on if no users exist for this site (how did this happen?).
        if (empty($users)) {
            continue;
        }
        // Loop through users and record their relationship to this blog.
        foreach ((array) $users as $user_id) {
            bp_blogs_add_user_to_blog($user_id, false, $blog->blog_id);
            // Clear cache
            bp_blogs_clear_blog_object_cache($blog->blog_id, $user_id);
        }
        // Update blog last activity timestamp
        if (!empty($blog->last_updated) && false !== strtotime($blog->last_updated)) {
            bp_blogs_update_blogmeta($blog->blog_id, 'last_activity', $blog->last_updated);
        }
    }
    // See if we need to do this again
    if (is_multisite() && empty($r['blog_ids'])) {
        $sql['offset'] = $wpdb->prepare(" OFFSET %d", $r['limit'] + $r['offset']);
        // Check if there are more blogs to record
        $blog_ids = $wpdb->get_results(implode(' ', $sql));
        // We have more blogs; record offset and re-run function
        if (!empty($blog_ids)) {
            bp_update_option('_bp_record_blogs_offset', $r['limit'] + $r['offset']);
            bp_blogs_record_existing_blogs(array('offset' => $r['limit'] + $r['offset'], 'limit' => $r['limit'], 'blog_ids' => $r['blog_ids'], 'site_id' => $r['site_id']));
            // Bail since we have more blogs to record.
            return;
            // No more blogs; delete offset marker
        } else {
            bp_delete_option('_bp_record_blogs_offset');
        }
    }
    /**
     * Fires after the BP blogs tables have been populated with existing blogs.
     *
     * @since 2.4.0
     */
    do_action('bp_blogs_recorded_existing_blogs');
    // No errors.
    return true;
}