Пример #1
0
function bp_forums_add_admin_menu()
{
    if (!is_super_admin()) {
        return false;
    }
    $page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php';
    // Add the administration tab under the "Site Admin" tab for site administrators.
    $hook = add_submenu_page($page, __('Forums', 'buddypress'), __('Forums', 'buddypress'), 'manage_options', 'bb-forums-setup', "bp_forums_bbpress_admin");
    // Fudge the highlighted subnav item when on the BuddyPress Forums admin page.
    add_action("admin_head-{$hook}", 'bp_core_modify_admin_menu_highlight');
}
Пример #2
0
 public function test_has_htaccess()
 {
     if (!function_exists('buddydrive_admin')) {
         require_once buddydrive()->includes_dir . 'admin/buddydrive-admin.php';
     }
     // Load the admin
     buddydrive_admin();
     set_current_screen('plugins' . $this->suffix);
     $notice_hook = bp_core_do_network_admin() ? 'network_admin_notices' : 'admin_notices';
     do_action($notice_hook);
     $this->assertTrue(file_exists(buddydrive()->upload_dir . '/.htaccess'));
 }
function etivite_bp_activity_block_admin_add_action_link($links, $file)
{
    if ('buddypress-block-activity-stream-types/bp-activity-block-loader.php' != $file) {
        return $links;
    }
    if (function_exists('bp_core_do_network_admin')) {
        $settings_url = add_query_arg('page', 'bp-activity-block-settings', bp_core_do_network_admin() ? network_admin_url('admin.php') : admin_url('admin.php'));
    } else {
        $settings_url = add_query_arg('page', 'bp-activity-block-settings', is_multisite() ? network_admin_url('admin.php') : admin_url('admin.php'));
    }
    $settings_link = '<a href="' . $settings_url . '">' . __('Settings', 'bp-activity-block') . '</a>';
    array_unshift($links, $settings_link);
    return $links;
}
Пример #4
0
function invite_anyone_admin_add_action_link($links, $file)
{
    if ('invite-anyone/invite-anyone.php' != $file) {
        return $links;
    }
    if (function_exists('bp_core_do_network_admin')) {
        $settings_url = add_query_arg('page', 'invite-anyone', bp_core_do_network_admin() ? network_admin_url('admin.php') : admin_url('admin.php'));
    } else {
        $settings_url = add_query_arg('page', 'invite-anyone', is_multisite() ? network_admin_url('admin.php') : admin_url('admin.php'));
    }
    $settings_link = '<a href="' . $settings_url . '">' . __('Settings', 'invite-anyone') . '</a>';
    array_unshift($links, $settings_link);
    return $links;
}
Пример #5
0
function bp_checkins_needs_activity()
{
    if (!bp_is_active('activity')) {
        $buddy_settings_page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php';
        ?>
		<div id="message" class="updated">
			<p><?php 
        printf(__('If you want to use BP Checkins, you need to activate the Activity Stream BuddyPress component, to do so, please activate it in <a href="%s">BuddyPress settings</a>', 'bp-checkins'), bp_get_admin_url(add_query_arg(array('page' => 'bp-components'), $buddy_settings_page)));
        ?>
</p>
		</div>
		<?php 
    }
}
Пример #6
0
 /**
  * Setup our admin settings page and hooks
  */
 public function setup_admin()
 {
     // Temporary workaround for the fact that WP's settings API doesn't work with MS
     if (bp_core_do_network_admin()) {
         if (!bp_is_root_blog()) {
             return;
         }
         $parent = 'options-general.php';
     } else {
         $parent = 'bp-general-settings';
     }
     $page = add_submenu_page($parent, __('BuddyPress Reply By Email', 'bp-rbe'), __('BP Reply By Email', 'bp-rbe'), 'manage_options', 'bp-rbe', array($this, 'load'));
     add_action("admin_head-{$page}", array($this, 'head'));
     add_action("admin_footer-{$page}", array($this, 'footer'));
 }
 /**
  * Admin globals
  *
  * @since BuddyPress (1.6)
  * @access private
  */
 private function setup_globals()
 {
     $bp = buddypress();
     // Paths and URLs
     $this->admin_dir = trailingslashit($bp->plugin_dir . 'bp-core/admin');
     // Admin path
     $this->admin_url = trailingslashit($bp->plugin_url . 'bp-core/admin');
     // Admin url
     $this->images_url = trailingslashit($this->admin_url . 'images');
     // Admin images URL
     $this->css_url = trailingslashit($this->admin_url . 'css');
     // Admin css URL
     $this->js_url = trailingslashit($this->admin_url . 'js');
     // Admin css URL
     // Main settings page
     $this->settings_page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php';
 }
Пример #8
0
/**
 * Save our settings
 *
 * @since BuddyPress (1.6)
 */
function bp_core_admin_settings_save()
{
    global $wp_settings_fields;
    if (isset($_GET['page']) && 'bp-settings' == $_GET['page'] && !empty($_POST['submit'])) {
        check_admin_referer('buddypress-options');
        // Because many settings are saved with checkboxes, and thus will have no values
        // in the $_POST array when unchecked, we loop through the registered settings
        if (isset($wp_settings_fields['buddypress'])) {
            foreach ((array) $wp_settings_fields['buddypress'] as $section => $settings) {
                foreach ($settings as $setting_name => $setting) {
                    $value = isset($_POST[$setting_name]) ? $_POST[$setting_name] : '';
                    bp_update_option($setting_name, $value);
                }
            }
        }
        // Some legacy options are not registered with the Settings API
        $legacy_options = array('bp-disable-account-deletion', 'bp-disable-avatar-uploads', 'bp_disable_blogforum_comments', 'bp-disable-profile-sync', 'bp_restrict_group_creation', 'hide-loggedout-adminbar');
        foreach ($legacy_options as $legacy_option) {
            // Note: Each of these options is represented by its opposite in the UI
            // Ie, the Profile Syncing option reads "Enable Sync", so when it's checked,
            // the corresponding option should be unset
            $value = isset($_POST[$legacy_option]) ? '' : 1;
            bp_update_option($legacy_option, $value);
        }
        bp_core_redirect(add_query_arg('page', 'bp-settings', bp_core_do_network_admin() ? network_admin_url('admin.php') : admin_url('admin.php')));
    }
}
Пример #9
0
												<label><input type="checkbox" name="group-show-forum"
												              id="group-show-forum"
												              value="1"<?php 
            checked(bp_get_new_group_enable_forum(), true, true);
            ?>
 /> <?php 
            _e('Enable discussion forum', 'vibe');
            ?>
</label>
											</div>
										<?php 
        } elseif (is_super_admin()) {
            ?>

											<p><?php 
            printf(__('<strong>Attention Site Admin:</strong> Group forums require the <a href="%s">correct setup and configuration</a> of a bbPress installation.', 'vibe'), bp_core_do_network_admin() ? network_admin_url('settings.php?page=bb-forums-setup') : admin_url('admin.php?page=bb-forums-setup'));
            ?>
</p>

										<?php 
        }
        ?>

									<?php 
    }
    ?>

									<?php 
    do_action('bp_after_group_settings_creation_step');
    ?>
Пример #10
0
/**
 * Return the action name that BuddyPress nav setup callbacks should be hooked to.
 *
 * Functions used to set up BP Dashboard pages (wrapping such admin-panel
 * functions as add_submenu_page()) should use bp_core_admin_hook() for the
 * first parameter in add_action(). BuddyPress will then determine
 * automatically whether to load the panels in the Network Admin. Ie:
 *
 *     add_action( bp_core_admin_hook(), 'myplugin_dashboard_panel_setup' );
 *
 * @return string $hook The proper hook ('network_admin_menu' or 'admin_menu').
 */
function bp_core_admin_hook()
{
    $hook = bp_core_do_network_admin() ? 'network_admin_menu' : 'admin_menu';
    return apply_filters('bp_core_admin_hook', $hook);
}
Пример #11
0
/**
* BP 1.6beta1 new admin area
*/
function bp_checkins_16_new_admin()
{
    if (defined('BP_VERSION') && version_compare(BP_VERSION, '1.6-beta2-6162', '>=')) {
        $page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php';
        return $page;
    } else {
        return 'bp-general-settings.php';
    }
}
Пример #12
0
/**
 * Verify that some BP prerequisites are set up properly, and notify the admin if not
 *
 * On every Dashboard page, this function checks the following:
 *   - that pretty permalinks are enabled
 *   - that a BP-compatible theme is activated
 *   - that every BP component that needs a WP page for a directory has one
 *   - that no WP page has multiple BP components associated with it
 * The administrator will be shown a notice for each check that fails.
 *
 * @package BuddyPress Core
 */
function bp_core_activation_notice()
{
    global $wp_rewrite, $wpdb, $bp;
    // Only the super admin gets warnings
    if (!bp_current_user_can('bp_moderate')) {
        return;
    }
    // On multisite installs, don't load on a non-root blog, unless do_network_admin is
    // overridden
    if (is_multisite() && bp_core_do_network_admin() && !bp_is_root_blog()) {
        return;
    }
    // Don't show these messages during setup or upgrade
    if (!empty($bp->maintenance_mode)) {
        return;
    }
    /**
     * Check to make sure that the blog setup routine has run. This can't happen during the
     * wizard because of the order which the components are loaded. We check for multisite here
     * on the off chance that someone has activated the blogs component and then disabled MS
     */
    if (bp_is_active('blogs')) {
        $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$bp->blogs->table_name}"));
        if (empty($count)) {
            bp_blogs_record_existing_blogs();
        }
    }
    /**
     * Are pretty permalinks enabled?
     */
    if (isset($_POST['permalink_structure'])) {
        return false;
    }
    if (empty($wp_rewrite->permalink_structure)) {
        bp_core_add_admin_notice(sprintf(__('<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress'), admin_url('options-permalink.php')));
    }
    /**
     * Are you using a BP-compatible theme?
     */
    // Get current theme info
    $ct = wp_get_theme();
    // Make sure tags is an array to suppress notices
    if (!isset($ct->tags)) {
        $ct->tags = array();
    } else {
        $ct->tags = (array) $ct->tags;
    }
    // The best way to remove this notice is to add a "buddypress" tag to
    // your active theme's CSS header.
    if (!defined('BP_SILENCE_THEME_NOTICE') && !in_array('buddypress', $ct->tags)) {
        bp_core_add_admin_notice(sprintf(__("You'll need to <a href='%s'>activate a <strong>BuddyPress-compatible theme</strong></a> to take advantage of all of BuddyPress's features. We've bundled a default theme, but you can always <a href='%s'>install some other compatible themes</a> or <a href='%s'>update your existing WordPress theme</a>.", 'buddypress'), admin_url('themes.php'), network_admin_url('theme-install.php?type=tag&s=buddypress&tab=search'), network_admin_url('plugin-install.php?type=term&tab=search&s=%22bp-template-pack%22')));
    }
    /**
     * Check for orphaned BP components (BP component is enabled, no WP page exists)
     */
    $orphaned_components = array();
    $wp_page_components = array();
    // Only components with 'has_directory' require a WP page to function
    foreach ($bp->loaded_components as $component_id => $is_active) {
        if (!empty($bp->{$component_id}->has_directory)) {
            $wp_page_components[] = array('id' => $component_id, 'name' => isset($bp->{$component_id}->name) ? $bp->{$component_id}->name : ucwords($bp->{$component_id}->id));
        }
    }
    // Activate and Register are special cases. They are not components but they need WP pages.
    // If user registration is disabled, we can skip this step.
    if (bp_get_signup_allowed()) {
        $wp_page_components[] = array('id' => 'activate', 'name' => __('Activate', 'buddypress'));
        $wp_page_components[] = array('id' => 'register', 'name' => __('Register', 'buddypress'));
    }
    foreach ($wp_page_components as $component) {
        if (!isset($bp->pages->{$component['id']})) {
            $orphaned_components[] = $component['name'];
        }
    }
    // Special case: If the Forums component is orphaned, but the bbPress 1.x installation is
    // not correctly set up, don't show a nag. (In these cases, it's probably the case that the
    // user is using bbPress 2.x; see https://buddypress.trac.wordpress.org/ticket/4292
    if (isset($bp->forums->name) && in_array($bp->forums->name, $orphaned_components) && !bp_forums_is_installed_correctly()) {
        $forum_key = array_search($bp->forums->name, $orphaned_components);
        unset($orphaned_components[$forum_key]);
        $orphaned_components = array_values($orphaned_components);
    }
    if (!empty($orphaned_components)) {
        $admin_url = bp_get_admin_url(add_query_arg(array('page' => 'bp-page-settings'), 'admin.php'));
        $notice = sprintf(__('The following active BuddyPress Components do not have associated WordPress Pages: %2$s. <a href="%1$s" class="button-secondary">Repair</a>', 'buddypress'), $admin_url, '<strong>' . implode('</strong>, <strong>', $orphaned_components) . '</strong>');
        bp_core_add_admin_notice($notice);
    }
    /**
     * BP components cannot share a single WP page. Check for duplicate assignments, and post
     * a message if found.
     */
    $dupe_names = array();
    $page_ids = (array) bp_core_get_directory_page_ids();
    $dupes = array_diff_assoc($page_ids, array_unique($page_ids));
    if (!empty($dupes)) {
        foreach ($dupes as $dupe_component => $dupe_id) {
            $dupe_names[] = $bp->pages->{$dupe_component}->title;
        }
        // Make sure that there are no duplicate duplicates :)
        $dupe_names = array_unique($dupe_names);
    }
    // If there are duplicates, post a message about them
    if (!empty($dupe_names)) {
        $admin_url = bp_get_admin_url(add_query_arg(array('page' => 'bp-page-settings'), 'admin.php'));
        $notice = sprintf(__('Each BuddyPress Component needs its own WordPress page. The following WordPress Pages have more than one component associated with them: %2$s. <a href="%1$s" class="button-secondary">Repair</a>', 'buddypress'), $admin_url, '<strong>' . implode('</strong>, <strong>', $dupe_names) . '</strong>');
        bp_core_add_admin_notice($notice);
    }
}
Пример #13
0
/**
 * Return the correct URL based on BuddyPress and NXTClass configuration
 *
 * @package BuddyPress
 * @since 1.5
 *
 * @param string $path
 * @param string $scheme
 *
 * @uses bp_core_do_network_admin()
 * @uses network_admin_url()
 * @uses admin_url()
 */
function bp_get_admin_url($path = '', $scheme = 'admin')
{
    // Links belong in network admin
    if (bp_core_do_network_admin()) {
        $url = network_admin_url($path, $scheme);
    } else {
        $url = admin_url($path, $scheme);
    }
    return $url;
}
Пример #14
0
 /**
  * Hide submenu
  *
  * @package Rendez Vous
  * @subpackage Admin
  *
  * @since Rendez Vous (1.2.0)
  */
 public function admin_head()
 {
     $page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php';
     remove_submenu_page($page, 'rendez-vous');
 }
Пример #15
0
/**
 * Displays the settings page
 * 
 * @uses is_multisite() to check for multisite
 * @uses add_query_arg() to add arguments to query in case of multisite
 * @uses bp_get_admin_url to build the settings url in case of multisite
 * @uses screen_icon() to show BuddyDrive icon
 * @uses settings_fields()
 * @uses do_settings_sections()
 * @uses wp_nonce_field() for security reason in case of multisite
 */
function buddydrive_admin_settings()
{
    $form_action = 'options.php';
    if (bp_core_do_network_admin()) {
        do_action('buddydrive_multisite_options');
        $form_action = add_query_arg('page', 'buddydrive', bp_get_admin_url('settings.php'));
    }
    ?>

	<div class="wrap">

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

		<h2><?php 
    _e('BuddyDrive Settings', 'buddydrive');
    ?>
</h2>

		<form action="<?php 
    echo esc_url($form_action);
    ?>
" method="post">

			<?php 
    settings_fields('buddydrive');
    ?>

			<?php 
    do_settings_sections('buddydrive');
    ?>

			<p class="submit">
				<?php 
    if (bp_core_do_network_admin()) {
        ?>
					<?php 
        wp_nonce_field('buddydrive_settings', '_wpnonce_buddydrive_setting');
        ?>
				<?php 
    }
    ?>
				<input type="submit" name="submit" class="button-primary" value="<?php 
    esc_attr_e('Save Changes', 'buddydrive');
    ?>
" />
			</p>
		</form>
	</div>

<?php 
}
Пример #16
0
 function step_finish_save()
 {
     if (isset($_POST['submit'])) {
         check_admin_referer('bpwizard_finish');
         // Update the DB version in the database
         bp_version_bump();
         // Delete the setup cookie
         @setcookie('bp-wizard-step', '', time() - 3600, COOKIEPATH);
         // Redirect to the BuddyPress dashboard
         $redirect = bp_core_do_network_admin() ? network_admin_url('settings.php') : admin_url('options-general.php');
         $redirect = add_query_arg(array('page' => 'bp-components'), $redirect);
         wp_safe_redirect($redirect);
         // That's all!
         exit;
     }
     return false;
 }
Пример #17
0
 /**
  * Register site- or network-admin nav menu elements.
  *
  * Contextually hooked to site or network-admin depending on current configuration.
  *
  * @since 1.6.0
  *
  * @uses add_management_page() To add the Recount page in Tools section.
  * @uses add_options_page() To add the Forums settings page in Settings
  *       section.
  */
 public function admin_menus()
 {
     // Bail if user cannot moderate.
     if (!bp_current_user_can('manage_options')) {
         return;
     }
     // About.
     add_dashboard_page(__('Welcome to BuddyPress', 'buddypress'), __('Welcome to BuddyPress', 'buddypress'), 'manage_options', 'bp-about', array($this, 'about_screen'));
     // Credits.
     add_dashboard_page(__('Welcome to BuddyPress', 'buddypress'), __('Welcome to BuddyPress', 'buddypress'), 'manage_options', 'bp-credits', array($this, 'credits_screen'));
     $hooks = array();
     // Changed in BP 1.6 . See bp_core_admin_backpat_menu().
     $hooks[] = add_menu_page(__('BuddyPress', 'buddypress'), __('BuddyPress', 'buddypress'), $this->capability, 'bp-general-settings', 'bp_core_admin_backpat_menu', 'div');
     $hooks[] = add_submenu_page('bp-general-settings', __('BuddyPress Help', 'buddypress'), __('Help', 'buddypress'), $this->capability, 'bp-general-settings', 'bp_core_admin_backpat_page');
     // Add the option pages.
     $hooks[] = add_submenu_page($this->settings_page, __('BuddyPress Components', 'buddypress'), __('BuddyPress', 'buddypress'), $this->capability, 'bp-components', 'bp_core_admin_components_settings');
     $hooks[] = add_submenu_page($this->settings_page, __('BuddyPress Pages', 'buddypress'), __('BuddyPress Pages', 'buddypress'), $this->capability, 'bp-page-settings', 'bp_core_admin_slugs_settings');
     $hooks[] = add_submenu_page($this->settings_page, __('BuddyPress Options', 'buddypress'), __('BuddyPress Options', 'buddypress'), $this->capability, 'bp-settings', 'bp_core_admin_settings');
     // For consistency with non-Multisite, we add a Tools menu in
     // the Network Admin as a home for our Tools panel.
     if (is_multisite() && bp_core_do_network_admin()) {
         $tools_parent = 'network-tools';
         $hooks[] = add_menu_page(__('Tools', 'buddypress'), __('Tools', 'buddypress'), $this->capability, $tools_parent, 'bp_core_tools_top_level_item', '', 24);
         $hooks[] = add_submenu_page($tools_parent, __('Available Tools', 'buddypress'), __('Available Tools', 'buddypress'), $this->capability, 'available-tools', 'bp_core_admin_available_tools_page');
     } else {
         $tools_parent = 'tools.php';
     }
     $hooks[] = add_submenu_page($tools_parent, __('BuddyPress Tools', 'buddypress'), __('BuddyPress', 'buddypress'), $this->capability, 'bp-tools', 'bp_core_admin_tools');
     // For network-wide configs, add a link to (the root site's) Emails screen.
     if (is_network_admin() && bp_is_network_activated()) {
         $email_labels = bp_get_email_post_type_labels();
         $email_url = get_admin_url(bp_get_root_blog_id(), 'edit.php?post_type=' . bp_get_email_post_type());
         $hooks[] = add_menu_page($email_labels['name'], $email_labels['menu_name'], $this->capability, '', '', 'dashicons-email', 26);
         // Hack: change the link to point to the root site's admin, not the network admin.
         $GLOBALS['menu'][26][2] = esc_url_raw($email_url);
     }
     foreach ($hooks as $hook) {
         add_action("admin_head-{$hook}", 'bp_core_modify_admin_menu_highlight');
     }
 }
Пример #18
0
/**
 * Finds the url of settings page
 * @global type $wpdb
 * @return string
 * @since v 0.6
 * @author lenasterg
 * @version 1, 4/6/2013
 */
function bp_group_documents_find_admin_location()
{
    global $wpdb;
    $bp = buddypress();
    if (!is_super_admin()) {
        return false;
    }
    // test for BP1.6+ (truncated to allow testing on beta versions)
    if (version_compare(substr(BP_VERSION, 0, 3), '1.6', '>=')) {
        // BuddyPress 1.6 moves its admin pages elsewhere, so use Settings menu
        $locationMu = 'settings.php';
    } else {
        // versions prior to 1.6 have a BuddyPress top-level menu
        $locationMu = 'bp-general-settings';
    }
    $location = bp_core_do_network_admin() ? $locationMu : 'options-general.php';
    return $location;
}
Пример #19
0
 /**
  * Add the navigational menu elements.
  *
  * @since BuddyPress (1.6)
  *
  * @uses add_management_page() To add the Recount page in Tools section.
  * @uses add_options_page() To add the Forums settings page in Settings
  *       section.
  */
 public function admin_menus()
 {
     // Bail if user cannot moderate
     if (!bp_current_user_can('manage_options')) {
         return;
     }
     // About
     add_dashboard_page(__('Welcome to BuddyPress', 'buddypress'), __('Welcome to BuddyPress', 'buddypress'), 'manage_options', 'bp-about', array($this, 'about_screen'));
     // Credits
     add_dashboard_page(__('Welcome to BuddyPress', 'buddypress'), __('Welcome to BuddyPress', 'buddypress'), 'manage_options', 'bp-credits', array($this, 'credits_screen'));
     $hooks = array();
     // Changed in BP 1.6 . See bp_core_admin_backpat_menu()
     $hooks[] = add_menu_page(__('BuddyPress', 'buddypress'), __('BuddyPress', 'buddypress'), $this->capability, 'bp-general-settings', 'bp_core_admin_backpat_menu', 'div');
     $hooks[] = add_submenu_page('bp-general-settings', __('BuddyPress Help', 'buddypress'), __('Help', 'buddypress'), $this->capability, 'bp-general-settings', 'bp_core_admin_backpat_page');
     // Add the option pages
     $hooks[] = add_submenu_page($this->settings_page, __('BuddyPress Components', 'buddypress'), __('BuddyPress', 'buddypress'), $this->capability, 'bp-components', 'bp_core_admin_components_settings');
     $hooks[] = add_submenu_page($this->settings_page, __('BuddyPress Pages', 'buddypress'), __('BuddyPress Pages', 'buddypress'), $this->capability, 'bp-page-settings', 'bp_core_admin_slugs_settings');
     $hooks[] = add_submenu_page($this->settings_page, __('BuddyPress Settings', 'buddypress'), __('BuddyPress Settings', 'buddypress'), $this->capability, 'bp-settings', 'bp_core_admin_settings');
     // For consistency with non-Multisite, we add a Tools menu in
     // the Network Admin as a home for our Tools panel
     if (is_multisite() && bp_core_do_network_admin()) {
         $tools_parent = 'network-tools';
         $hooks[] = add_menu_page(__('Tools', 'buddypress'), __('Tools', 'buddypress'), $this->capability, $tools_parent, 'bp_core_tools_top_level_item', '', 24);
         $hooks[] = add_submenu_page($tools_parent, __('Available Tools', 'buddypress'), __('Available Tools', 'buddypress'), $this->capability, 'available-tools', 'bp_core_admin_available_tools_page');
     } else {
         $tools_parent = 'tools.php';
     }
     $hooks[] = add_submenu_page($tools_parent, __('BuddyPress Tools', 'buddypress'), __('BuddyPress', 'buddypress'), $this->capability, 'bp-tools', 'bp_core_admin_tools');
     // Fudge the highlighted subnav item when on a BuddyPress admin page
     foreach ($hooks as $hook) {
         add_action("admin_head-{$hook}", 'bp_core_modify_admin_menu_highlight');
     }
 }
Пример #20
0
 /**
  * Set up the signups admin page.
  *
  * Loaded before the page is rendered, this function does all initial
  * setup, including: processing form requests, registering contextual
  * help, and setting up screen options.
  *
  * @since BuddyPress (2.0.0)
  *
  * @global $bp_members_signup_list_table
  */
 public function signups_admin_load()
 {
     global $bp_members_signup_list_table;
     // Build redirection URL
     $redirect_to = remove_query_arg(array('action', 'error', 'updated', 'activated', 'notactivated', 'deleted', 'notdeleted', 'resent', 'notresent', 'do_delete', 'do_resend', 'do_activate', '_wpnonce', 'signup_ids'), $_SERVER['REQUEST_URI']);
     $doaction = bp_admin_list_table_current_bulk_action();
     /**
      * Fires at the start of the signups admin load.
      *
      * @since BuddyPress (2.0.0)
      *
      * @param string $doaction Current bulk action being processed.
      * @param array  $_REQUEST Current $_REQUEST global.
      */
     do_action('bp_signups_admin_load', $doaction, $_REQUEST);
     /**
      * Filters the allowed actions for use in the user signups admin page.
      *
      * @since BuddyPress (2.0.0)
      *
      * @param array $value Array of allowed actions to use.
      */
     $allowed_actions = apply_filters('bp_signups_admin_allowed_actions', array('do_delete', 'do_activate', 'do_resend'));
     // Prepare the display of the Community Profile screen
     if (!in_array($doaction, $allowed_actions) || -1 == $doaction) {
         if (bp_core_do_network_admin()) {
             $bp_members_signup_list_table = self::get_list_table_class('BP_Members_MS_List_Table', 'ms-users');
         } else {
             $bp_members_signup_list_table = self::get_list_table_class('BP_Members_List_Table', 'users');
         }
         // per_page screen option
         add_screen_option('per_page', array('label' => _x('Pending Accounts', 'Pending Accounts per page (screen options)', 'buddypress')));
         get_current_screen()->add_help_tab(array('id' => 'bp-signups-overview', 'title' => __('Overview', 'buddypress'), 'content' => '<p>' . __('This is the administration screen for pending accounts on your site.', 'buddypress') . '</p>' . '<p>' . __('From the screen options, you can customize the displayed columns and the pagination of this screen.', 'buddypress') . '</p>' . '<p>' . __('You can reorder the list of your pending accounts by clicking on the Username, Email or Registered column headers.', 'buddypress') . '</p>' . '<p>' . __('Using the search form, you can find pending accounts more easily. The Username and Email fields will be included in the search.', 'buddypress') . '</p>'));
         get_current_screen()->add_help_tab(array('id' => 'bp-signups-actions', 'title' => __('Actions', 'buddypress'), 'content' => '<p>' . __('Hovering over a row in the pending accounts list will display action links that allow you to manage pending accounts. You can perform the following actions:', 'buddypress') . '</p>' . '<ul><li>' . __('"Email" takes you to the confirmation screen before being able to send the activation link to the desired pending account. You can only send the activation email once per day.', 'buddypress') . '</li>' . '<li>' . __('"Delete" allows you to delete a pending account from your site. You will be asked to confirm this deletion.', 'buddypress') . '</li></ul>' . '<p>' . __('By clicking on a Username you will be able to activate a pending account from the confirmation screen.', 'buddypress') . '</p>' . '<p>' . __('Bulk actions allow you to perform these 3 actions for the selected rows.', 'buddypress') . '</p>'));
         // Help panel - sidebar links
         get_current_screen()->set_help_sidebar('<p><strong>' . __('For more information:', 'buddypress') . '</strong></p>' . '<p>' . __('<a href="https://buddypress.org/support/">Support Forums</a>', 'buddypress') . '</p>');
     } else {
         if (!empty($_REQUEST['signup_ids'])) {
             $signups = wp_parse_id_list($_REQUEST['signup_ids']);
         }
         // Handle resent activation links
         if ('do_resend' == $doaction) {
             // nonce check
             check_admin_referer('signups_resend');
             $resent = BP_Signup::resend($signups);
             if (empty($resent)) {
                 $redirect_to = add_query_arg('error', $doaction, $redirect_to);
             } else {
                 $query_arg = array('updated' => 'resent');
                 if (!empty($resent['resent'])) {
                     $query_arg['resent'] = count($resent['resent']);
                 }
                 if (!empty($resent['errors'])) {
                     $query_arg['notsent'] = count($resent['errors']);
                     set_transient('_bp_admin_signups_errors', $resent['errors'], 30);
                 }
                 $redirect_to = add_query_arg($query_arg, $redirect_to);
             }
             bp_core_redirect($redirect_to);
             // Handle activated accounts
         } elseif ('do_activate' == $doaction) {
             // nonce check
             check_admin_referer('signups_activate');
             $activated = BP_Signup::activate($signups);
             if (empty($activated)) {
                 $redirect_to = add_query_arg('error', $doaction, $redirect_to);
             } else {
                 $query_arg = array('updated' => 'activated');
                 if (!empty($activated['activated'])) {
                     $query_arg['activated'] = count($activated['activated']);
                 }
                 if (!empty($activated['errors'])) {
                     $query_arg['notactivated'] = count($activated['errors']);
                     set_transient('_bp_admin_signups_errors', $activated['errors'], 30);
                 }
                 $redirect_to = add_query_arg($query_arg, $redirect_to);
             }
             bp_core_redirect($redirect_to);
             // Handle sign-ups delete
         } elseif ('do_delete' == $doaction) {
             // nonce check
             check_admin_referer('signups_delete');
             $deleted = BP_Signup::delete($signups);
             if (empty($deleted)) {
                 $redirect_to = add_query_arg('error', $doaction, $redirect_to);
             } else {
                 $query_arg = array('updated' => 'deleted');
                 if (!empty($deleted['deleted'])) {
                     $query_arg['deleted'] = count($deleted['deleted']);
                 }
                 if (!empty($deleted['errors'])) {
                     $query_arg['notdeleted'] = count($deleted['errors']);
                     set_transient('_bp_admin_signups_errors', $deleted['errors'], 30);
                 }
                 $redirect_to = add_query_arg($query_arg, $redirect_to);
             }
             bp_core_redirect($redirect_to);
             // Plugins can update other stuff from here
         } else {
             $this->redirect = $redirect_to;
             /**
              * Fires at end of signups admin load if doaction does not match any actions.
              *
              * @since BuddyPress (2.0.0)
              *
              * @param string $doaction Current bulk action being processed.
              * @param array  $_REQUEST Current $_REQUEST global.
              * @param string $redirect Determined redirect url to send user to.
              */
             do_action('bp_members_admin_update_signups', $doaction, $_REQUEST, $this->redirect);
             bp_core_redirect($this->redirect);
         }
     }
 }
Пример #21
0
/**
 * Verify that some BP prerequisites are set up properly, and notify the admin if not
 *
 * On every Dashboard page, this function checks the following:
 *   - that pretty permalinks are enabled
 *   - that every BP component that needs a WP page for a directory has one
 *   - that no WP page has multiple BP components associated with it
 * The administrator will be shown a notice for each check that fails.
 *
 * @global WPDB $wpdb WordPress DB object
 * @global WP_Rewrite $wp_rewrite
 * @since BuddyPress (1.2)
 */
function bp_core_activation_notice()
{
    global $wp_rewrite, $wpdb;
    // Only the super admin gets warnings
    if (!bp_current_user_can('bp_moderate')) {
        return;
    }
    // Bail in user admin
    if (is_user_admin()) {
        return;
    }
    // On multisite installs, don't load on a non-root blog, unless do_network_admin is overridden
    if (is_multisite() && bp_core_do_network_admin() && !bp_is_root_blog()) {
        return;
    }
    // Bail if in network admin, and BuddyPress is not network activated
    if (is_network_admin() && !bp_is_network_activated()) {
        return;
    }
    /**
     * Check to make sure that the blog setup routine has run. This can't
     * happen during the wizard because of the order which the components
     * are loaded.
     */
    if (bp_is_active('blogs')) {
        $bp = buddypress();
        $count = $wpdb->get_var("SELECT COUNT(*) FROM {$bp->blogs->table_name}");
        if (empty($count)) {
            bp_blogs_record_existing_blogs();
        }
    }
    // Add notice if no rewrite rules are enabled
    if (empty($wp_rewrite->permalink_structure)) {
        bp_core_add_admin_notice(sprintf(__('<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress'), admin_url('options-permalink.php')));
    }
    // Get BuddyPress instance
    $bp = buddypress();
    /**
     * Check for orphaned BP components (BP component is enabled, no WP page exists)
     */
    $orphaned_components = array();
    $wp_page_components = array();
    // Only components with 'has_directory' require a WP page to function
    foreach (array_keys($bp->loaded_components) as $component_id) {
        if (!empty($bp->{$component_id}->has_directory)) {
            $wp_page_components[] = array('id' => $component_id, 'name' => isset($bp->{$component_id}->name) ? $bp->{$component_id}->name : ucwords($bp->{$component_id}->id));
        }
    }
    // Activate and Register are special cases. They are not components but they need WP pages.
    // If user registration is disabled, we can skip this step.
    if (bp_get_signup_allowed()) {
        $wp_page_components[] = array('id' => 'activate', 'name' => __('Activate', 'buddypress'));
        $wp_page_components[] = array('id' => 'register', 'name' => __('Register', 'buddypress'));
    }
    // On the first admin screen after a new installation, this isn't set, so grab it to supress a misleading error message.
    if (empty($bp->pages->members)) {
        $bp->pages = bp_core_get_directory_pages();
    }
    foreach ($wp_page_components as $component) {
        if (!isset($bp->pages->{$component['id']})) {
            $orphaned_components[] = $component['name'];
        }
    }
    // Special case: If the Forums component is orphaned, but the bbPress 1.x installation is
    // not correctly set up, don't show a nag. (In these cases, it's probably the case that the
    // user is using bbPress 2.x; see https://buddypress.trac.wordpress.org/ticket/4292
    if (isset($bp->forums->name) && in_array($bp->forums->name, $orphaned_components) && !bp_forums_is_installed_correctly()) {
        $forum_key = array_search($bp->forums->name, $orphaned_components);
        unset($orphaned_components[$forum_key]);
        $orphaned_components = array_values($orphaned_components);
    }
    if (!empty($orphaned_components)) {
        $admin_url = bp_get_admin_url(add_query_arg(array('page' => 'bp-page-settings'), 'admin.php'));
        $notice = sprintf(__('The following active BuddyPress Components do not have associated WordPress Pages: %2$s. <a href="%1$s">Repair</a>', 'buddypress'), $admin_url, '<strong>' . implode('</strong>, <strong>', $orphaned_components) . '</strong>');
        bp_core_add_admin_notice($notice);
    }
    // BP components cannot share a single WP page. Check for duplicate assignments, and post a message if found.
    $dupe_names = array();
    $page_ids = (array) bp_core_get_directory_page_ids();
    $dupes = array_diff_assoc($page_ids, array_unique($page_ids));
    if (!empty($dupes)) {
        foreach (array_keys($dupes) as $dupe_component) {
            $dupe_names[] = $bp->pages->{$dupe_component}->title;
        }
        // Make sure that there are no duplicate duplicates :)
        $dupe_names = array_unique($dupe_names);
    }
    // If there are duplicates, post a message about them
    if (!empty($dupe_names)) {
        $admin_url = bp_get_admin_url(add_query_arg(array('page' => 'bp-page-settings'), 'admin.php'));
        $notice = sprintf(__('Each BuddyPress Component needs its own WordPress page. The following WordPress Pages have more than one component associated with them: %2$s. <a href="%1$s">Repair</a>', 'buddypress'), $admin_url, '<strong>' . implode('</strong>, <strong>', $dupe_names) . '</strong>');
        bp_core_add_admin_notice($notice);
    }
}
Пример #22
0
/**
 * Return the action name that BuddyPress nav setup callbacks should be hooked to.
 *
 * Functions used to set up BP Dashboard pages (wrapping such admin-panel
 * functions as add_submenu_page()) should use bp_core_admin_hook() for the
 * first parameter in add_action(). BuddyPress will then determine
 * automatically whether to load the panels in the Network Admin. Ie:
 *
 *     add_action( bp_core_admin_hook(), 'myplugin_dashboard_panel_setup' );
 *
 * @return string $hook The proper hook ('network_admin_menu' or 'admin_menu').
 */
function bp_core_admin_hook()
{
    $hook = bp_core_do_network_admin() ? 'network_admin_menu' : 'admin_menu';
    /**
     * Filters the action name that BuddyPress nav setup callbacks should be hooked to.
     *
     * @since BuddyPress (1.5.0)
     *
     * @param string $hook Action name to be attached to.
     */
    return apply_filters('bp_core_admin_hook', $hook);
}
/**
 * In admin emails list, for non-en_US locales, add notice explaining how to reinstall emails.
 *
 * If BuddyPress installs before its translations are in place, tell people how to reinstall
 * the emails so they have their contents in their site's language.
 *
 * @since 2.5.0
 */
function bp_admin_email_maybe_add_translation_notice()
{
    if (get_current_screen()->post_type !== bp_get_email_post_type() || get_locale() === 'en_US') {
        return;
    }
    // If user can't access BP Tools, there's no point showing the message.
    if (!current_user_can(buddypress()->admin->capability)) {
        return;
    }
    if (bp_core_do_network_admin()) {
        $admin_page = 'admin.php';
    } else {
        $admin_page = 'tools.php';
    }
    bp_core_add_admin_notice(sprintf(__('Are your emails in the wrong language? Go to <a href="%s">BuddyPress Tools and run the "reinstall emails"</a> tool.', 'buddypress'), esc_url(add_query_arg('page', 'bp-tools', bp_get_admin_url($admin_page)))), 'updated');
}
Пример #24
0
function bp_reshare_16_new_admin()
{
    global $bp;
    if (!defined('BP_VERSION')) {
        $version = BP_VERSION;
    } else {
        $version = $bp->version;
    }
    if (version_compare($version, '1.6', '>=')) {
        $page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php';
        return $page;
    } else {
        return 'bp-general-settings.php';
    }
}
/**
 * Creates reusable markup for component setup on the Components and Pages dashboard panel.
 *
 * @since 1.6.0
 *
 * @todo Use settings API
 */
function bp_core_admin_components_options()
{
    // Declare local variables.
    $deactivated_components = array();
    /**
     * Filters the array of available components.
     *
     * @since 1.5.0
     *
     * @param mixed $value Active components.
     */
    $active_components = apply_filters('bp_active_components', bp_get_option('bp-active-components'));
    // The default components (if none are previously selected).
    $default_components = array('xprofile' => array('title' => __('Extended Profiles', 'buddypress'), 'description' => __('Customize your community with fully editable profile fields that allow your users to describe themselves.', 'buddypress')), 'settings' => array('title' => __('Account Settings', 'buddypress'), 'description' => __('Allow your users to modify their account and notification settings directly from within their profiles.', 'buddypress')), 'notifications' => array('title' => __('Notifications', 'buddypress'), 'description' => __('Notify members of relevant activity with a toolbar bubble and/or via email, and allow them to customize their notification settings.', 'buddypress')));
    $optional_components = bp_core_admin_get_components('optional');
    $required_components = bp_core_admin_get_components('required');
    $retired_components = bp_core_admin_get_components('retired');
    // Don't show Forums component in optional components if it's disabled.
    if (!bp_is_active('forums')) {
        unset($optional_components['forums']);
    }
    // Merge optional and required together.
    $all_components = $optional_components + $required_components;
    // If this is an upgrade from before BuddyPress 1.5, we'll have to convert
    // deactivated components into activated ones.
    if (empty($active_components)) {
        $deactivated_components = bp_get_option('bp-deactivated-components');
        if (!empty($deactivated_components)) {
            // Trim off namespace and filename.
            $trimmed = array();
            foreach (array_keys((array) $deactivated_components) as $component) {
                $trimmed[] = str_replace('.php', '', str_replace('bp-', '', $component));
            }
            // Loop through the optional components to create an active component array.
            foreach (array_keys((array) $optional_components) as $ocomponent) {
                if (!in_array($ocomponent, $trimmed)) {
                    $active_components[$ocomponent] = 1;
                }
            }
        }
    }
    // On new install, set active components to default.
    if (empty($active_components)) {
        $active_components = $default_components;
    }
    // Core component is always active.
    $active_components['core'] = $all_components['core'];
    $inactive_components = array_diff(array_keys($all_components), array_keys($active_components));
    /** Display **************************************************************
     */
    // Get the total count of all plugins.
    $all_count = count($all_components);
    $page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php';
    $action = !empty($_GET['action']) ? $_GET['action'] : 'all';
    switch ($action) {
        case 'all':
            $current_components = $all_components;
            break;
        case 'active':
            foreach (array_keys($active_components) as $component) {
                $current_components[$component] = $all_components[$component];
            }
            break;
        case 'inactive':
            foreach ($inactive_components as $component) {
                $current_components[$component] = $all_components[$component];
            }
            break;
        case 'mustuse':
            $current_components = $required_components;
            break;
        case 'retired':
            $current_components = $retired_components;
            break;
    }
    ?>

	<h3 class="screen-reader-text"><?php 
    /* translators: accessibility text */
    _e('Filter components list', 'buddypress');
    ?>
</h3>

	<ul class="subsubsub">
		<li><a href="<?php 
    echo esc_url(add_query_arg(array('page' => 'bp-components', 'action' => 'all'), bp_get_admin_url($page)));
    ?>
" <?php 
    if ($action === 'all') {
        ?>
class="current"<?php 
    }
    ?>
><?php 
    printf(_nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $all_count, 'plugins', 'buddypress'), number_format_i18n($all_count));
    ?>
</a> | </li>
		<li><a href="<?php 
    echo esc_url(add_query_arg(array('page' => 'bp-components', 'action' => 'active'), bp_get_admin_url($page)));
    ?>
" <?php 
    if ($action === 'active') {
        ?>
class="current"<?php 
    }
    ?>
><?php 
    printf(_n('Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', count($active_components), 'buddypress'), number_format_i18n(count($active_components)));
    ?>
</a> | </li>
		<li><a href="<?php 
    echo esc_url(add_query_arg(array('page' => 'bp-components', 'action' => 'inactive'), bp_get_admin_url($page)));
    ?>
" <?php 
    if ($action === 'inactive') {
        ?>
class="current"<?php 
    }
    ?>
><?php 
    printf(_n('Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', count($inactive_components), 'buddypress'), number_format_i18n(count($inactive_components)));
    ?>
</a> | </li>
		<li><a href="<?php 
    echo esc_url(add_query_arg(array('page' => 'bp-components', 'action' => 'mustuse'), bp_get_admin_url($page)));
    ?>
" <?php 
    if ($action === 'mustuse') {
        ?>
class="current"<?php 
    }
    ?>
><?php 
    printf(_n('Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', count($required_components), 'buddypress'), number_format_i18n(count($required_components)));
    ?>
</a> | </li>
		<li><a href="<?php 
    echo esc_url(add_query_arg(array('page' => 'bp-components', 'action' => 'retired'), bp_get_admin_url($page)));
    ?>
" <?php 
    if ($action === 'retired') {
        ?>
class="current"<?php 
    }
    ?>
><?php 
    printf(_n('Retired <span class="count">(%s)</span>', 'Retired <span class="count">(%s)</span>', count($retired_components), 'buddypress'), number_format_i18n(count($retired_components)));
    ?>
</a></li>
	</ul>

	<h3 class="screen-reader-text"><?php 
    /* translators: accessibility text */
    _e('Components list', 'buddypress');
    ?>
</h3>

	<table class="wp-list-table widefat plugins">
		<thead>
			<tr>
				<td id="cb" class="manage-column column-cb check-column"><input id="cb-select-all-1" type="checkbox" disabled><label class="screen-reader-text" for="cb-select-all-1"><?php 
    /* translators: accessibility text */
    _e('Bulk selection is disabled', 'buddypress');
    ?>
</label></td>
				<th scope="col" id="name" class="manage-column column-title column-primary"><?php 
    _e('Component', 'buddypress');
    ?>
</th>
				<th scope="col" id="description" class="manage-column column-description"><?php 
    _e('Description', 'buddypress');
    ?>
</th>
			</tr>
		</thead>

		<tbody id="the-list">

			<?php 
    if (!empty($current_components)) {
        ?>

				<?php 
        foreach ($current_components as $name => $labels) {
            ?>

					<?php 
            if (!in_array($name, array('core', 'members'))) {
                $class = isset($active_components[esc_attr($name)]) ? 'active' : 'inactive';
            } else {
                $class = 'active';
            }
            ?>

					<tr id="<?php 
            echo esc_attr($name);
            ?>
" class="<?php 
            echo esc_attr($name) . ' ' . esc_attr($class);
            ?>
">
						<th scope="row" class="check-column">

							<?php 
            if (!in_array($name, array('core', 'members'))) {
                ?>

								<input type="checkbox" id="<?php 
                echo esc_attr("bp_components[{$name}]");
                ?>
" name="<?php 
                echo esc_attr("bp_components[{$name}]");
                ?>
" value="1"<?php 
                checked(isset($active_components[esc_attr($name)]));
                ?>
 /><label for="<?php 
                echo esc_attr("bp_components[{$name}]");
                ?>
" class="screen-reader-text"><?php 
                /* translators: accessibility text */
                printf(__('Select %s', 'buddypress'), esc_html($labels['title']));
                ?>
</label>

							<?php 
            } else {
                ?>

								<input type="checkbox" id="<?php 
                echo esc_attr("bp_components[{$name}]");
                ?>
" name="<?php 
                echo esc_attr("bp_components[{$name}]");
                ?>
" value="1" checked="checked" disabled><label for="<?php 
                echo esc_attr("bp_components[{$name}]");
                ?>
" class="screen-reader-text"><?php 
                /* translators: accessibility text */
                printf(__('%s is a required component', 'buddypress'), esc_html($labels['title']));
                ?>
</label>

							<?php 
            }
            ?>

						</th>
						<td class="plugin-title column-primary">
							<span aria-hidden="true"></span>
							<strong><?php 
            echo esc_html($labels['title']);
            ?>
</strong>
						</td>

						<td class="column-description desc">
							<div class="plugin-description">
								<p><?php 
            echo $labels['description'];
            ?>
</p>
							</div>

						</td>
					</tr>

				<?php 
        }
        ?>

			<?php 
    } else {
        ?>

				<tr class="no-items">
					<td class="colspanchange" colspan="3"><?php 
        _e('No components found.', 'buddypress');
        ?>
</td>
				</tr>

			<?php 
    }
    ?>

		</tbody>

		<tfoot>
			<tr>
				<td class="manage-column column-cb check-column"><input id="cb-select-all-2" type="checkbox" disabled><label class="screen-reader-text" for="cb-select-all-2"><?php 
    /* translators: accessibility text */
    _e('Bulk selection is disabled', 'buddypress');
    ?>
</label></td>
				<th class="manage-column column-title column-primary"><?php 
    _e('Component', 'buddypress');
    ?>
</th>
				<th class="manage-column column-description"><?php 
    _e('Description', 'buddypress');
    ?>
</th>
			</tr>
		</tfoot>

	</table>

	<input type="hidden" name="bp_components[members]" value="1" />

	<?php 
}
Пример #26
0
        /**
         * Add any admin notices we might need, mostly for update or new installs
         *
         * @since BuddyPress (1.6)
         *
         * @global string $pagenow
         * @return If no notice is needed
         */
        public function admin_notices()
        {
            global $pagenow;
            // Bail if not in maintenance mode
            if (!bp_get_maintenance_mode()) {
                return;
            }
            // Bail if user cannot manage options
            if (!current_user_can('manage_options')) {
                return;
            }
            // Are we looking at a network?
            if (bp_core_do_network_admin()) {
                // Bail if looking at wizard page
                if ('admin.php' == $pagenow && (!empty($_GET['page']) && 'bp-wizard' == $_GET['page'])) {
                    return;
                }
                // Set the url for the nag
                $url = network_admin_url('admin.php?page=bp-wizard');
                // Single site
            } else {
                // Bail if looking at wizard page
                if ('index.php' == $pagenow && (!empty($_GET['page']) && 'bp-wizard' == $_GET['page'])) {
                    return;
                }
                // Set the url for the nag
                $url = admin_url('index.php?page=bp-wizard');
            }
            // What does the nag say?
            switch (bp_get_maintenance_mode()) {
                // Update text
                case 'update':
                    $msg = sprintf(__('BuddyPress has been updated! Please run the <a href="%s">update wizard</a>.', 'buddypress'), $url);
                    break;
                    // First install text
                // First install text
                case 'install':
                default:
                    $msg = sprintf(__('BuddyPress was successfully activated! Please run the <a href="%s">installation wizard</a>.', 'buddypress'), $url);
                    break;
            }
            ?>

		<div class="update-nag"><?php 
            echo $msg;
            ?>
</div>

		<?php 
        }
Пример #27
0
/**
 * Render an introduction of BuddyPress tools on Available Tools page.
 *
 * @since BuddyPress (2.0.0)
 */
function bp_core_admin_available_tools_intro()
{
    $query_arg = array('page' => 'bp-tools');
    $page = bp_core_do_network_admin() ? 'admin.php' : 'tools.php';
    $url = add_query_arg($query_arg, bp_get_admin_url($page));
    ?>
	<div class="tool-box">
		<h3 class="title"><?php 
    esc_html_e('BuddyPress Tools', 'buddypress');
    ?>
</h3>
		<p>
			<?php 
    esc_html_e('BuddyPress keeps track of various relationships between users, groups, and activity items. Occasionally these relationships become out of sync, most often after an import, update, or migration.', 'buddypress');
    ?>
			<?php 
    printf(esc_html_x('Use the %s to repair these relationships.', 'buddypress tools intro', 'buddypress'), '<a href="' . esc_url($url) . '">' . esc_html__('BuddyPress Tools', 'buddypress') . '</a>');
    ?>
		</p>
	</div>
	<?php 
}
Пример #28
0
    /**
     * Method to produce the admin page for a specific component of Welcome Pack (friends, groups, welcome message, and so on)
     *
     * @global object $bp BuddyPress settings object
     * @global wpdb $wpdb WordPress database object
     * @param string $tab Name of the component (groups, members, welcomemessage, startpage)
     * @param array $settings Plugin settings (from DB)
     * @param bool $updated Have settings been updated on the previous page submission?
     * @since 3.0
     */
    protected function admin_page_component($tab, $settings, $updated)
    {
        global $bp, $wpdb;
        $data = array();
        // Depending on which $tab we're displaying, maybe fetch some information from the database.
        if ('groups' == $tab && bp_is_active('groups')) {
            $data = $wpdb->get_results($wpdb->prepare("SELECT id, name FROM {$bp->groups->table_name} ORDER BY name ASC"));
        } elseif ('members' == $tab && bp_is_active('friends') || 'welcomemessage' == $tab && bp_is_active('messages')) {
            $data = get_users(array('fields' => array('ID', 'display_name'), 'orderby' => 'display_name'));
        }
        $url = add_query_arg(array('page' => 'welcome-pack', 'tab' => $tab), bp_core_do_network_admin() ? network_admin_url('settings.php') : admin_url('options-general.php'));
        ?>

		<form method="post" action="<?php 
        echo esc_attr($url);
        ?>
" id="dpw-form">
			<?php 
        wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
        ?>
			<?php 
        wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
        ?>
			<?php 
        wp_nonce_field('dpw-admin', 'dpw-admin-nonce', false);
        ?>

			<!-- Friends tab -->
			<?php 
        if ('members' == $tab && bp_is_active('friends')) {
            ?>
				<p><?php 
            _e('Invite the new user to become friends with these people:', 'dpw');
            ?>
</p>

				<select multiple="multiple" name="friends[]" style="overflow-y: hidden">
					<?php 
            foreach ((array) $data as $member) {
                ?>
						<option value="<?php 
                echo esc_attr($member->ID);
                ?>
"<?php 
                foreach ((array) $settings['friends'] as $id) {
                    if ($member->ID == $id) {
                        echo " selected='selected'";
                    }
                }
                ?>
><?php 
                echo apply_filters('bp_core_get_user_displayname', $member->display_name, $member->ID);
                ?>
</option>
					<?php 
            }
            ?>
				</select>

			<!-- Groups tab -->
			<?php 
        } elseif ('groups' == $tab && bp_is_active('groups')) {
            ?>
				<p><?php 
            _e("Ask the new user if they'd like to join these groups:", 'dpw');
            ?>
</p>

				<select multiple="multiple" name="groups[]">
					<?php 
            foreach ((array) $data as $group) {
                ?>
						<option value="<?php 
                echo esc_attr($group->id);
                ?>
"<?php 
                foreach ((array) $settings['groups'] as $id) {
                    if ($group->id == $id) {
                        echo " selected='selected'";
                    }
                }
                ?>
><?php 
                echo apply_filters('bp_get_group_name', $group->name);
                ?>
</option>
					<?php 
            }
            ?>
				</select>

			<!-- Start Page tab -->
			<?php 
        } elseif ('startpage' == $tab) {
            ?>

				<p><?php 
            _e("When the new user logs into your site for the very first time, redirect them to this URL:", 'dpw');
            ?>
</p>
				<input type="url" name="startpage" value="<?php 
            echo esc_attr($settings['startpage']);
            ?>
" />

			<!-- Welcome Message tab -->
			<?php 
        } elseif ('welcomemessage' == $tab && bp_is_active('messages')) {
            ?>

				<p><?php 
            _e('When a user logs in to your site for the first time, send them a message:', 'dpw');
            ?>
</p>
				<textarea name="welcomemsg"><?php 
            echo esc_textarea($settings['welcomemsg']);
            ?>
</textarea>

				<p><?php 
            _e('Message subject:', 'dpw');
            ?>
</p>
				<input type="text" name="welcomemsgsubject" value="<?php 
            echo esc_attr($settings['welcomemsgsubject']);
            ?>
" />

				<p><?php 
            _e('Send message from this user:'******'dpw');
            ?>
</p>
				<select name="welcomemsgsender">
					<?php 
            foreach ((array) $data as $member) {
                ?>
						<option value="<?php 
                echo esc_attr($member->ID);
                ?>
"<?php 
                if ((int) $settings['welcomemsgsender'] && $member->ID == (int) $settings['welcomemsgsender']) {
                    echo " selected='selected'";
                }
                ?>
><?php 
                echo apply_filters('bp_core_get_user_displayname', $member->display_name, $member->ID);
                ?>
</option>
					<?php 
            }
            ?>
				</select>

			<?php 
        }
        ?>
				<p><input type="submit" class="button-primary" value="<?php 
        _e('Save Changes', 'dpw');
        ?>
" /></p>
			<?php 
        ?>

		</form>
		<?php 
    }
 /**
  * Set admin-related actions and filters.
  *
  * @since 2.0.0
  */
 private function setup_actions()
 {
     /** Extended Profile *************************************************
      */
     // Enqueue all admin JS and CSS.
     add_action('bp_admin_enqueue_scripts', array($this, 'enqueue_scripts'));
     // Add some page specific output to the <head>.
     add_action('bp_admin_head', array($this, 'admin_head'), 999);
     // Add menu item to all users menu.
     add_action('admin_menu', array($this, 'admin_menus'), 5);
     add_action('network_admin_menu', array($this, 'admin_menus'), 5);
     add_action('user_admin_menu', array($this, 'user_profile_menu'), 5);
     // Create the Profile Navigation (Profile/Extended Profile).
     add_action('edit_user_profile', array($this, 'profile_nav'), 99, 1);
     add_action('show_user_profile', array($this, 'profile_nav'), 99, 1);
     // Editing users of a specific site.
     add_action("admin_head-site-users.php", array($this, 'profile_admin_head'));
     // Add a row action to users listing.
     if (bp_core_do_network_admin()) {
         add_filter('ms_user_row_actions', array($this, 'row_actions'), 10, 2);
         add_action('admin_init', array($this, 'add_edit_profile_url_filter'));
         add_action('wp_after_admin_bar_render', array($this, 'remove_edit_profile_url_filter'));
     }
     // Add user row actions for single site.
     add_filter('user_row_actions', array($this, 'row_actions'), 10, 2);
     // Process changes to member type.
     add_action('bp_members_admin_load', array($this, 'process_member_type_update'));
     /** Signups **********************************************************
      */
     if (is_admin()) {
         // Filter non multisite user query to remove sign-up users.
         if (!is_multisite()) {
             add_action('pre_user_query', array($this, 'remove_signups_from_user_query'), 10, 1);
         }
         // Reorganise the views navigation in users.php and signups page.
         if (current_user_can($this->capability)) {
             $user_screen = $this->users_screen;
             /**
              * Users screen on multiblog is users, but signups
              * need to be managed in the network for this case
              */
             if (bp_is_network_activated() && bp_is_multiblog_mode() && false === strpos($user_screen, '-network')) {
                 $user_screen .= '-network';
             }
             add_filter("views_{$user_screen}", array($this, 'signup_filter_view'), 10, 1);
             add_filter('set-screen-option', array($this, 'signup_screen_options'), 10, 3);
         }
         // Registration is turned on.
         add_action('update_site_option_registration', array($this, 'multisite_registration_on'), 10, 2);
         add_action('update_option_users_can_register', array($this, 'single_site_registration_on'), 10, 2);
     }
     /** Users List - Members Types ***************************************
      */
     if (is_admin() && bp_get_member_types()) {
         // Add "Change type" <select> to WP admin users list table and process bulk members type changes.
         add_action('restrict_manage_users', array($this, 'users_table_output_type_change_select'));
         add_action('load-users.php', array($this, 'users_table_process_bulk_type_change'));
         // Add the member type column to the WP admin users list table.
         add_filter('manage_users_columns', array($this, 'users_table_add_type_column'));
         add_filter('manage_users_custom_column', array($this, 'users_table_populate_type_cell'), 10, 3);
         // Filter WP admin users list table to include users of the specified type.
         add_filter('pre_get_users', array($this, 'users_table_filter_by_type'));
     }
 }
 public function add_menu_page()
 {
     $hook = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php';
     $this->_page_hook = add_submenu_page($hook, __('BuddyPress Activity Plus', 'bpfb'), __('Activity Plus', 'bpfb'), $this->_capability, 'bpfb-settings', array($this, 'settings_page'));
     $this->_save_settings();
 }