/**
  * Include the needed file
  *
  * @since 1.0.0
  */
 private function includes()
 {
     if (!bp_is_active('groups')) {
         return;
     }
     require $this->includes_dir . 'alt-public-group-ctrl.php';
 }
Exemplo n.º 2
0
function bp_blogs_register_widgets()
{
    global $nxtdb, $bp;
    if (bp_is_active('activity') && (int) $nxtdb->blogid == bp_get_root_blog_id()) {
        add_action('widgets_init', create_function('', 'return register_widget("BP_Blogs_Recent_Posts_Widget");'));
    }
}
Exemplo n.º 3
0
 public function setup_settings()
 {
     // General
     add_settings_section('bp-docs-general', __('General', 'bp-docs'), array($this, 'general_section'), 'bp-docs-settings');
     // General - Docs slug
     add_settings_field('bp-docs-slug', __('Slug', 'bp-docs'), array($this, 'slug_setting_markup'), 'bp-docs-settings', 'bp-docs-general');
     register_setting('bp-docs-settings', 'bp-docs-slug', 'rawurlencode');
     // General - Excerpt length
     add_settings_field('bp-docs-excerpt-length', __('Directory Excerpt Length', 'bp-docs'), array($this, 'excerpt_length_setting_markup'), 'bp-docs-settings', 'bp-docs-general');
     register_setting('bp-docs-settings', 'bp-docs-excerpt-length', 'absint');
     // Users
     add_settings_section('bp-docs-users', __('Users', 'bp-docs'), array($this, 'users_section'), 'bp-docs-settings');
     // Users - Tab name
     add_settings_field('bp-docs-user-tab-name', __('User Tab Name', 'bp-docs'), array($this, 'user_tab_name_setting_markup'), 'bp-docs-settings', 'bp-docs-users');
     register_setting('bp-docs-settings', 'bp-docs-user-tab-name');
     // Groups
     if (bp_is_active('groups')) {
         add_settings_section('bp-docs-groups', __('Groups', 'bp-docs'), array($this, 'groups_section'), 'bp-docs-settings');
         // Groups - Tab name
         add_settings_field('bp-docs-tab-name', __('Group Tab Name', 'bp-docs'), array($this, 'group_tab_name_setting_markup'), 'bp-docs-settings', 'bp-docs-groups');
         register_setting('bp-docs-settings', 'bp-docs-tab-name');
     }
     // Attachments
     add_settings_section('bp-docs-attachments', __('Attachments', 'bp-docs'), array($this, 'attachments_section'), 'bp-docs-settings');
     // Users - Tab name
     add_settings_field('bp-docs-enable-attachments', __('Enable Attachments', 'bp-docs'), array($this, 'enable_attachments_setting_markup'), 'bp-docs-settings', 'bp-docs-attachments');
     register_setting('bp-docs-settings', 'bp-docs-enable-attachments');
 }
 /**
  * Includes.
  */
 public function includes($includes = array())
 {
     /**  Backwards-compatibility ******************************************/
     // template stack for BP < 1.7
     if (!class_exists('BP_Theme_Compat')) {
         require $this->path . '/backpat/template-stack.php';
     }
     // activity scope for BP < 2.2
     if (!class_exists('BP_Activity_Query')) {
         require $this->path . '/backpat/activity-scope.php';
     }
     /** Core **************************************************************/
     require $this->path . '/bp-follow-classes.php';
     require $this->path . '/bp-follow-functions.php';
     // users module
     if (true === (bool) apply_filters('bp_follow_enable_users', true)) {
         require $this->path . '/users/screens.php';
         require $this->path . '/users/actions.php';
         require $this->path . '/users/hooks.php';
         require $this->path . '/users/template.php';
         require $this->path . '/users/notifications.php';
         require $this->path . '/users/widgets.php';
     }
     // blogs module - on multisite and BP 2.0+ only
     if (function_exists('bp_add_option') && bp_is_active('blogs') && is_multisite() && bp_is_network_activated() && apply_filters('bp_follow_enable_blogs', true)) {
         require $this->path . '/modules/blogs.php';
     }
     // updater
     if (defined('WP_NETWORK_ADMIN')) {
         require $this->path . '/bp-follow-updater.php';
     }
 }
 protected function set_up_levels()
 {
     // Everyone can see 'anyone' docs
     $this->levels[] = bp_docs_get_access_term_anyone();
     // Logged-in users
     // Note that we're not verifying that the user actually exists
     // For now this kind of check is up to whoever's instantiating
     if ($this->user_id != 0) {
         $this->levels[] = bp_docs_get_access_term_loggedin();
         if (bp_is_active('groups')) {
             $this->set_up_user_groups();
             if (isset($this->user_groups['groups'])) {
                 foreach ($this->user_groups['groups'] as $member_group) {
                     $this->levels[] = bp_docs_get_access_term_group_member($member_group);
                 }
             }
             // admins-mods
             if (isset($this->user_groups['admin_mod_of'])) {
                 foreach ($this->user_groups['admin_mod_of'] as $adminmod_group) {
                     $this->levels[] = bp_docs_get_access_term_group_adminmod($adminmod_group);
                 }
             }
         }
         // no-one
         // creator
         // @todo What's the difference?
         $this->levels[] = bp_docs_get_access_term_user($this->user_id);
     }
 }
/**
 * Adds the User Admin top-level menu to user pages
 *
 * @package BuddyPress
 * @since BuddyPress (1.5)
 */
function bp_members_admin_bar_user_admin_menu()
{
    global $bp, $wp_admin_bar;
    // Only show if viewing a user
    if (!bp_is_user()) {
        return false;
    }
    // Don't show this menu to non site admins or if you're viewing your own profile
    if (!current_user_can('edit_users') || bp_is_my_profile()) {
        return false;
    }
    // Unique ID for the 'My Account' menu
    $bp->user_admin_menu_id = 'user-admin';
    // Add the top-level User Admin button
    $wp_admin_bar->add_menu(array('id' => $bp->user_admin_menu_id, 'title' => __('Edit Member', 'buddypress'), 'href' => bp_displayed_user_domain()));
    // User Admin > Edit this user's profile
    $wp_admin_bar->add_menu(array('parent' => $bp->user_admin_menu_id, 'id' => $bp->user_admin_menu_id . '-edit-profile', 'title' => __("Edit Profile", 'buddypress'), 'href' => bp_get_members_component_link('profile', 'edit')));
    // User Admin > Edit this user's avatar
    $wp_admin_bar->add_menu(array('parent' => $bp->user_admin_menu_id, 'id' => $bp->user_admin_menu_id . '-change-avatar', 'title' => __("Edit Avatar", 'buddypress'), 'href' => bp_get_members_component_link('profile', 'change-avatar')));
    if (bp_is_active('settings')) {
        // User Admin > Spam/unspam
        $wp_admin_bar->add_menu(array('parent' => $bp->user_admin_menu_id, 'id' => $bp->user_admin_menu_id . '-user-capabilities', 'title' => __('User Capabilities', 'buddypress'), 'href' => bp_displayed_user_domain() . 'settings/capabilities/'));
        // User Admin > Delete Account
        $wp_admin_bar->add_menu(array('parent' => $bp->user_admin_menu_id, 'id' => $bp->user_admin_menu_id . '-delete-user', 'title' => __('Delete Account', 'buddypress'), 'href' => bp_displayed_user_domain() . 'settings/delete-account/'));
    }
}
Exemplo n.º 7
0
 function __construct()
 {
     // The plugin won't run without groups
     // For now, reviews are pegged to activity. Todo: move to cpts
     if (!bp_is_active('groups') || !bp_is_active('activity')) {
         return false;
     }
     $this->includes();
     add_action('bp_init', array($this, 'maybe_update'));
     add_action('bp_setup_globals', array($this, 'setup_globals'));
     add_action('groups_setup_nav', array($this, 'current_group_set_available'));
     add_action('groups_setup_nav', array($this, 'setup_current_group_globals'));
     add_action('wp_print_scripts', array($this, 'load_js'));
     add_action('wp_head', array($this, 'maybe_previous_data'), 999);
     add_action('wp_print_styles', array($this, 'load_styles'));
     add_action('bp_actions', array($this, 'grab_cookie'), 1);
     add_filter('bp_has_activities', array($this, 'activities_template_data'));
     add_filter('bp_has_groups', array($this, 'groups_template_data'));
     // For BP 1.5+
     add_action('bp_activity_before_action_delete_activity', array($this, 'delete_activity'), 10, 2);
     // For BP < 1.5
     add_action('bp_activity_action_delete_activity', array($this, 'delete_activity'), 10, 2);
     add_action('bp_activity_excerpt_length', array($this, 'activity_excerpt_length'));
     add_action('bp_get_activity_content_body', array($this, 'strip_star_tags'));
 }
 /**
  * bpsp_check()
  * Will check for Courseware dependencies and active components
  *
  * @return True on errors
  * @uses `admin_notices`
  */
 function bpsp_check()
 {
     $messages = array();
     if (apply_filters('bpsp_require_buddypress', true)) {
         if (function_exists('bp_get_version')) {
             // @todo make sure that bbpress is enabled? or ignore?
             //foreach( array( 'groups', 'activity', 'xprofile', 'forums', 'messages' ) as $c )
             foreach (array('groups', 'activity', 'xprofile', 'messages') as $c) {
                 if (!bp_is_active($c)) {
                     $messages[] = sprintf(__('BuddyPress Courseware dependency error: <a href="%1$s">%2$s has to be activated</a>!', 'bpsp'), admin_url('admin.php?page=bp-general-settings'), $c);
                 }
             }
         } else {
             $messages[] = sprintf(__('BuddyPress Courseware dependency error: Please <a href="%1$s">install BuddyPress</a>!', 'bpsp'), admin_url('plugins.php'));
         }
     }
     if (!empty($messages)) {
         echo '<div id="message" class="error fade">';
         foreach ($messages as $m) {
             echo "<p>{$m}</p>";
         }
         echo '</div>';
         return false;
     }
     return true;
 }
Exemplo n.º 9
0
/**
 * Register the widgets for the Blogs component.
 */
function bp_blogs_register_widgets()
{
    global $wpdb;
    if (bp_is_active('activity') && bp_is_root_blog($wpdb->blogid)) {
        add_action('widgets_init', create_function('', 'return register_widget("BP_Blogs_Recent_Posts_Widget");'));
    }
}
function friends_notification_accepted_request($friendship_id, $initiator_id, $friend_id)
{
    $friend_name = bp_core_get_user_displayname($friend_id);
    if ('no' == bp_get_user_meta((int) $initiator_id, 'notification_friends_friendship_accepted', true)) {
        return false;
    }
    $ud = get_userdata($initiator_id);
    $friend_link = bp_core_get_user_domain($friend_id);
    $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
    $settings_link = trailingslashit(bp_core_get_user_domain($initiator_id) . $settings_slug . '/notifications');
    // Set up and send the message
    $to = $ud->user_email;
    $subject = bp_get_email_subject(array('text' => sprintf(__('%s accepted your friendship request', 'buddypress'), $friend_name)));
    $message = sprintf(__('%1$s accepted your friend request.

To view %2$s\'s profile: %3$s

---------------------
', 'buddypress'), $friend_name, $friend_name, $friend_link);
    // Only show the disable notifications line if the settings component is enabled
    if (bp_is_active('settings')) {
        $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
    }
    /* Send the message */
    $to = apply_filters('friends_notification_accepted_request_to', $to);
    $subject = apply_filters('friends_notification_accepted_request_subject', $subject, $friend_name);
    $message = apply_filters('friends_notification_accepted_request_message', $message, $friend_name, $friend_link, $settings_link);
    wp_mail($to, $subject, $message);
    do_action('bp_friends_sent_accepted_email', $initiator_id, $subject, $message, $friendship_id, $friend_id);
}
/**
 * Legacy loader for BP < 1.2
 *
 * This function will be unhooked by ass_loader() when possible
 */
function activitysub_load_buddypress()
{
    global $ass_activities;
    if (function_exists('bp_core_setup_globals')) {
        // Don't load the plugin if activity and groups are not both active
        if (function_exists('bp_is_active') && (!bp_is_active('groups') || !bp_is_active('activity'))) {
            return false;
        }
        require_once 'bp-activity-subscription-main.php';
        return true;
    }
    /* Get the list of active sitewide plugins */
    $active_sitewide_plugins = maybe_unserialize(get_site_option('active_sitewide_plugins'));
    if (!isset($active_sidewide_plugins['buddypress/bp-loader.php'])) {
        return false;
    }
    if (isset($active_sidewide_plugins['buddypress/bp-loader.php']) && !function_exists('bp_core_setup_globals')) {
        require_once WP_PLUGIN_DIR . '/buddypress/bp-loader.php';
        // Don't load the plugin if activity and groups are not both active
        if (function_exists('bp_is_active') && (!bp_is_active('groups') || !bp_is_active('activity'))) {
            return false;
        }
        require_once 'bp-activity-subscription-main.php';
        return true;
    }
    return false;
}
 /**
  * Validate and sanitise the parameters for the suggestion service query.
  *
  * @since 2.1.0
  *
  * @return true|WP_Error If validation fails, return a WP_Error object. On success, return true (bool).
  */
 public function validate()
 {
     $this->args['group_id'] = (int) $this->args['group_id'];
     /**
      * Filters the arguments used to validate and sanitize suggestion service query.
      *
      * @since 2.1.0
      *
      * @param array                        $args  Array of arguments for the suggestion service query.
      * @param BP_Groups_Member_Suggestions $this  Instance of the current suggestion class.
      */
     $this->args = apply_filters('bp_groups_member_suggestions_args', $this->args, $this);
     // Check for invalid or missing mandatory parameters.
     if (!$this->args['group_id'] || !bp_is_active('groups')) {
         return new WP_Error('missing_requirement');
     }
     // Check that the specified group_id exists, and that the current user can access it.
     $the_group = groups_get_group(array('group_id' => absint($this->args['group_id']), 'populate_extras' => true));
     if ($the_group->id === 0 || !$the_group->user_has_access) {
         return new WP_Error('access_denied');
     }
     /**
      * Filters the validation results for the suggestion service query.
      *
      * @since 2.1.0
      *
      * @param bool|WP_Error                $value True if valid, WP_Error if not.
      * @param BP_Groups_Member_Suggestions $this  Instance of the current suggestion class.
      */
     return apply_filters('bp_groups_member_suggestions_validate_args', parent::validate(), $this);
 }
Exemplo n.º 13
0
/**
 * Sets up NXTClass theme for BuddyPress support.
 *
 * @since 1.2
 */
function bp_tpack_theme_setup()
{
    global $bp;
    // Load the default BuddyPress AJAX functions if it isn't explicitly disabled
    if (!(int) get_option('bp_tpack_disable_js')) {
        require_once BP_PLUGIN_DIR . '/bp-themes/bp-default/_inc/ajax.php';
    }
    if (!is_admin()) {
        // Register buttons for the relevant component templates
        // Friends button
        if (bp_is_active('friends')) {
            add_action('bp_member_header_actions', 'bp_add_friend_button');
        }
        // Activity button
        if (bp_is_active('activity')) {
            add_action('bp_member_header_actions', 'bp_send_public_message_button');
        }
        // Messages button
        if (bp_is_active('messages')) {
            add_action('bp_member_header_actions', 'bp_send_private_message_button');
        }
        // Group buttons
        if (bp_is_active('groups')) {
            add_action('bp_group_header_actions', 'bp_group_join_button');
            add_action('bp_group_header_actions', 'bp_group_new_topic_button');
            add_action('bp_directory_groups_actions', 'bp_group_join_button');
        }
        // Blog button
        if (bp_is_active('blogs')) {
            add_action('bp_directory_blogs_actions', 'bp_blogs_visit_blog_button');
        }
    }
}
 /**
  * Validate and sanitise the parameters for the suggestion service query.
  *
  * @since 2.1.0
  *
  * @return true|WP_Error If validation fails, return a WP_Error object. On success, return true (bool).
  */
 public function validate()
 {
     $this->args['only_friends'] = (bool) $this->args['only_friends'];
     /**
      * Filters the members suggestions args for the current user.
      *
      * @since 2.1.0
      *
      * @param array                  $args Array of arguments for the member suggestions.
      * @param BP_Members_Suggestions $this Current BP_Members_Suggestions instance.
      */
     $this->args = apply_filters('bp_members_suggestions_args', $this->args, $this);
     // Check for invalid or missing mandatory parameters.
     if ($this->args['only_friends'] && (!bp_is_active('friends') || !is_user_logged_in())) {
         return new WP_Error('missing_requirement');
     }
     /**
      * Filters the validation status for the suggestion service query.
      *
      * @since 2.1.0
      *
      * @param bool|WP_Error          $value Results of validation check.
      * @param BP_Members_Suggestions $this  Current BP_Members_Suggestions instance.
      */
     return apply_filters('bp_members_suggestions_validate_args', parent::validate(), $this);
 }
Exemplo n.º 15
0
/**
 * Loads CP's BuddyPress functionality
 *
 * A few things are required for BuddyPress functionality to work:
 * - Must be running at least BP 1.5
 * - Must have the Groups component enabled
 */
function cp_load_bp_functions()
{
    $error_message = '';
    if (!bp_is_active('groups')) {
        $error_type = 'no_bp_groups';
        $error_message = __('CollabPress BuddyPress integration requires the BP Groups component to be activated. Not using BP Groups? No problem - you&#8217ll still be able to use CollabPress on the Dashboard.', 'collabpress');
    } else {
        if (version_compare(BP_VERSION, '1.5', '<')) {
            $error_type = 'no_bp_15';
            $error_message = __('CollabPress BuddyPress integration requires v1.5+ of BuddyPress to work. Download a copy from <a href="http://buddypress.org">buddypress.org</a>. Not ready to upgrade to BuddyPress 1.5? No problem. You can continue to use CollabPress - you just won&#8217t get any BuddyPress integration yet.', 'collabpress');
        }
    }
    // If an error message has been set, see whether we should throw an
    // an error, then bail
    if ($error_message && $error_type) {
        if (current_user_can('activate_plugins')) {
            $dismissed = (array) get_option('cp_dismissed_messages');
            if (!isset($dismissed[$error_type])) {
                // Groan
                $dismiss_url = add_query_arg('cp_dismiss', $error_type, $_SERVER['REQUEST_URI']);
                $dismiss_url = wp_nonce_url($dismiss_url, 'cp_dismiss_notice');
                $error_message .= ' <span class="description"><a href="' . $dismiss_url . '">' . __('Dismiss this message.', 'collabpress') . '</a></span>';
                add_action('admin_notices', create_function('', 'echo \'<div class="updated fade"><p>' . $error_message . '</p></div>\';'));
            }
        }
        return;
    }
    // Still here? Load BP functionality
    require_once COLLABPRESS_PLUGIN_DIR . 'includes/cp-bp.php';
}
Exemplo n.º 16
0
/**
 * set current component_type to groups if we are on groups page
 * @see mpp_get_current_component()
 * @param type $component
 * @return type
 */
function mpp_current_component_type_for_groups($component)
{
    if (bp_is_active('groups') && bp_is_group()) {
        return buddypress()->groups->id;
    }
    return $component;
}
Exemplo n.º 17
0
 /**
  * Sets up theme defaults and registers support for various WordPress and BuddyPress features.
  *
  * Note that this function is hooked into the after_setup_theme hook, which runs
  * before the init hook. The init hook is too late for some features, such as indicating
  * support post thumbnails.
  *
  * To override bp_dtheme_setup() in a child theme, add your own bp_dtheme_setup to your child theme's
  * functions.php file.
  *
  * @global object $bp Global BuddyPress settings object
  * @since 1.5
  */
 function bp_dtheme_setup()
 {
     global $bp;
     // Load the AJAX functions for the theme
     require TEMPLATEPATH . '/_inc/ajax.php';
     if (!is_admin()) {
         // Register buttons for the relevant component templates
         // Friends button
         if (bp_is_active('friends')) {
             add_action('bp_member_header_actions', 'bp_add_friend_button');
         }
         // Activity button
         if (bp_is_active('activity')) {
             add_action('bp_member_header_actions', 'bp_send_public_message_button');
         }
         // Messages button
         if (bp_is_active('messages')) {
             add_action('bp_member_header_actions', 'bp_send_private_message_button');
         }
         // Group buttons
         if (bp_is_active('groups')) {
             add_action('bp_group_header_actions', 'bp_group_join_button');
             add_action('bp_group_header_actions', 'bp_group_new_topic_button');
             add_action('bp_directory_groups_actions', 'bp_group_join_button');
         }
         // Blog button
         if (bp_is_active('blogs')) {
             add_action('bp_directory_blogs_actions', 'bp_blogs_visit_blog_button');
         }
     }
 }
Exemplo n.º 18
0
 /**
  * Load
  * @since 0.1
  * @version 1.3.1
  */
 public function load()
 {
     // Admin Styling
     add_action('admin_head', array($this, 'admin_header'));
     add_action('admin_notices', array($this, 'admin_notices'));
     // Custom Columns
     add_filter('manage_users_columns', array($this, 'custom_user_column'));
     add_action('manage_users_custom_column', array($this, 'custom_user_column_content'), 10, 3);
     // User Edit
     global $bp;
     // Check if BuddyPress is being used
     if (is_object($bp) && isset($bp->version) && bp_is_active('xprofile')) {
         $this->using_bp = true;
     }
     // Edit Profile
     if (!$this->using_bp) {
         add_action('edit_user_profile', array($this, 'user_nav'));
     }
     add_action('personal_options', array($this, 'show_my_balance'));
     add_filter('mycred_admin_pages', array($this, 'edit_profile_menu'), 10, 2);
     add_action('mycred_init', array($this, 'edit_profile_actions'));
     // Sortable Column
     add_filter('manage_users_sortable_columns', array($this, 'sortable_points_column'));
     add_action('pre_user_query', array($this, 'sort_by_points'));
     // Inline Editing
     add_action('wp_ajax_mycred-inline-edit-users-balance', array($this, 'inline_edit_user_balance'));
     add_action('in_admin_footer', array($this, 'admin_footer'));
 }
Exemplo n.º 19
0
/**
 * bp_course_nav_menu()
 * Navigation menu for BuddyPress course
 */
function bp_course_nav_menu()
{
    $nav = bp_course_get_nav_permalinks();
    $defaults = array('' => array('id' => 'home', 'label' => __('Home', 'vibe'), 'action' => '', 'link' => bp_get_course_permalink()), 'curriculum' => array('id' => 'curriculum', 'label' => __('Curriculum', 'vibe'), 'can_view' => 1, 'action' => empty($nav['curriculum_slug']) ? __('curriculum', 'vibe') : $nav['curriculum_slug'], 'link' => bp_get_course_permalink()), 'members' => array('id' => 'members', 'label' => __('Members', 'vibe'), 'can_view' => 1, 'action' => empty($nav['members_slug']) ? __('members', 'vibe') : $nav['members_slug'], 'link' => bp_get_course_permalink()), 'activity' => array('id' => 'activity', 'label' => __('Activity', 'vibe'), 'can_view' => 1, 'action' => empty($nav['activity_slug']) ? __('activity', 'vibe') : $nav['activity_slug'], 'link' => bp_get_course_permalink()));
    global $post;
    if ($post->post_type == 'course') {
        if (function_exists('bp_is_active') && bp_is_active('groups')) {
            $vgroup = get_post_meta(get_the_ID(), 'vibe_group', true);
            if (!empty($vgroup)) {
                $group = groups_get_group(array('group_id' => $vgroup));
                $defaults['group'] = array('id' => 'group', 'label' => __('Group', 'vibe'), 'action' => 'group', 'can_view' => 1, 'link' => bp_get_group_permalink($group), 'external' => true);
            }
        }
        if (in_array('bbpress/bbpress.php', apply_filters('active_plugins', get_option('active_plugins'))) || function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('bbpress/bbpress.php')) {
            $forum = get_post_meta(get_the_ID(), 'vibe_forum', true);
            if (!empty($forum)) {
                $defaults['forum'] = array('id' => 'forum', 'label' => __('Forum', 'vibe'), 'action' => 'forum', 'can_view' => 1, 'link' => get_permalink($forum), 'external' => true);
            }
        }
    }
    $nav_menu = apply_filters('wplms_course_nav_menu', $defaults);
    global $bp;
    $action = bp_current_action();
    if (empty($action)) {
        !empty($_GET['action']) ? $action = $_GET['action'] : ($action = '');
    }
    if (is_array($nav_menu)) {
        foreach ($nav_menu as $key => $menu_item) {
            $menu_item['action'] = str_replace('/', '', $menu_item['action']);
            if ($key == $action) {
                $class = 'class="current"';
            } else {
                $class = '';
            }
            global $wp_query;
            if (!empty($nav[$menu_item['id'] . '_slug'])) {
                echo '<li id="' . $menu_item['id'] . '" ' . $class . '><a href="' . $menu_item['link'] . '' . (isset($menu_item['action']) && !isset($menu_item['external']) ? $menu_item['action'] : '') . '">' . $menu_item['label'] . '</a></li>';
            } else {
                echo '<li id="' . $menu_item['id'] . '" ' . $class . '><a href="' . $menu_item['link'] . '' . (!empty($menu_item['action']) && !isset($menu_item['external']) ? (strpos($menu_item['link'], '?') ? '&' : '?') . 'action=' . $menu_item['action'] : '') . '">' . $menu_item['label'] . '</a></li>';
            }
        }
    }
    if (is_super_admin() || is_instructor()) {
        $admin_slug = empty($nav['admin_slug']) ? _x('admin', 'course admin slug', 'vibe') : $nav['admin_slug'];
        $admin_slug = apply_filters('wplms_course_admin_slug', str_replace('/', '', $admin_slug));
        ?>
      <li id="admin" class="<?php 
        echo !empty($action) && ($action == 'admin' || $action == 'submission' || $action == 'stats') ? 'selected current' : '';
        ?>
"><a href="<?php 
        bp_course_permalink();
        echo $admin_slug;
        ?>
"><?php 
        _e('Admin', 'vibe');
        ?>
</a></li>
      <?php 
    }
}
function bp_mutual_friends_init()
{
    // Because our loader file uses BP_Component, it requires BP 1.5 or greater.
    if (version_compare(BP_VERSION, '1.3', '>') && bp_is_active('friends')) {
        require BP_MUTUAL_FRIENDS_PLUGIN_DIR . '/includes/bp-mutual-friends-loader.php';
    }
}
Exemplo n.º 21
0
/**
 * Sets up WordPress theme for BuddyPress support.
 *
 * @since 1.3
 */
function bp_compat_theme_setup()
{
    global $bp;
    // Load the default BuddyPress AJAX functions
    require_once TEMPLATEPATH . '/bp/ajax.php';
    /* Register Sidebars */
    register_sidebar(array('name' => __('BuddyPress Sidebar', 'dp'), 'id' => 'buddypress', 'description' => __('This sidebar will displayed on BuddyPress pages.', 'dp'), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<div class="widget-header"><h3 class="widget-title">', 'after_title' => '</h3></div>'));
    if (!is_admin()) {
        // Register buttons for the relevant component templates
        // Friends button
        if (bp_is_active('friends')) {
            add_action('bp_member_header_actions', 'bp_add_friend_button');
        }
        // Activity button
        if (bp_is_active('activity')) {
            add_action('bp_member_header_actions', 'bp_send_public_message_button');
        }
        // Messages button
        if (bp_is_active('messages')) {
            add_action('bp_member_header_actions', 'bp_send_private_message_button');
        }
        // Group buttons
        if (bp_is_active('groups')) {
            add_action('bp_group_header_actions', 'bp_group_join_button');
            add_action('bp_group_header_actions', 'bp_group_new_topic_button');
            add_action('bp_directory_groups_actions', 'bp_group_join_button');
        }
        // Blog button
        if (bp_is_active('blogs')) {
            add_action('bp_directory_blogs_actions', 'bp_blogs_visit_blog_button');
        }
    }
}
Exemplo n.º 22
0
 public function init()
 {
     //Register status
     //if friends component is active, only then
     mpp_register_status(array('key' => 'friendsonly', 'label' => __('Friends Only', 'mediapress'), 'labels' => array('singular_name' => __('Friends Only', 'mediapress'), 'plural_name' => __('Friends Only', 'mediapress')), 'description' => __('Friends Only Privacy Type', 'mediapress'), 'callback' => 'mpp_check_friends_access', 'activity_privacy' => 'friends'));
     //if followers component is active only then
     if (function_exists('bp_follow_is_following')) {
         mpp_register_status(array('key' => 'followersonly', 'label' => __('Followers Only', 'mediapress'), 'labels' => array('singular_name' => __('Followers Only', 'mediapress'), 'plural_name' => __('Followers Only', 'mediapress')), 'description' => __('Followers Only Privacy Type', 'mediapress'), 'callback' => 'mpp_check_followers_access', 'activity_privacy' => 'followers'));
         mpp_register_status(array('key' => 'followingonly', 'label' => __('Persons I Follow', 'mediapress'), 'labels' => array('singular_name' => __('Persons I Follow', 'mediapress'), 'plural_name' => __('Persons I Follow', 'mediapress')), 'description' => __('Following Only Privacy Type', 'mediapress'), 'callback' => 'mpp_check_following_access', 'activity_privacy' => 'following'));
     }
     //end of check for followers plugin
     mpp_register_component(array('key' => 'members', 'label' => __('User Galleries', 'mediapress'), 'labels' => array('singular_name' => __('User Gallery', 'mediapress'), 'plural_name' => __('User Galleries', 'mediapress')), 'description' => __('User Galleries', 'mediapress')));
     //add support
     mpp_component_add_status_support('members', 'public');
     mpp_component_add_status_support('members', 'private');
     mpp_component_add_status_support('members', 'loggedin');
     if (function_exists('bp_is_active') && bp_is_active('friends')) {
         mpp_component_add_status_support('members', 'friendsonly');
     }
     //allow members component to support the followers privacy
     if (function_exists('bp_follow_is_following')) {
         mpp_component_add_status_support('members', 'followersonly');
         mpp_component_add_status_support('members', 'followingonly');
     }
     //register type support
     mpp_component_init_type_support('members');
     mpp_register_component(array('key' => 'groups', 'label' => __('Group Galleries', 'mediapress'), 'labels' => array('singular_name' => __('Group Galleries', 'mediapress'), 'plural_name' => __('Group Gallery', 'mediapress')), 'description' => __('Groups Galleries', 'mediapress')));
     mpp_component_add_status_support('groups', 'public');
     mpp_component_add_status_support('groups', 'private');
     mpp_component_add_status_support('groups', 'loggedin');
     mpp_component_add_status_support('groups', 'groupsonly');
     //register media sizes
     //initialize type support for groups component
     mpp_component_init_type_support('groups');
 }
Exemplo n.º 23
0
/**
 * Load the Forums directory.
 */
function bp_forums_directory_forums_setup()
{
    // Get BuddyPress once
    $bp = buddypress();
    if (bp_is_forums_component() && (!bp_current_action() || 'tag' == bp_current_action() && bp_action_variables()) && !bp_current_item()) {
        if (!bp_forums_has_directory()) {
            return false;
        }
        if (!bp_forums_is_installed_correctly()) {
            bp_core_add_message(__('The forums component has not been set up yet.', 'buddypress'), 'error');
            bp_core_redirect(bp_get_root_domain());
        }
        bp_update_is_directory(true, 'forums');
        do_action('bbpress_init');
        // Check to see if the user has posted a new topic from the forums page.
        if (isset($_POST['submit_topic']) && bp_is_active('forums')) {
            check_admin_referer('bp_forums_new_topic');
            $bp->groups->current_group = groups_get_group(array('group_id' => $_POST['topic_group_id']));
            if (!empty($bp->groups->current_group->id)) {
                // Auto join this user if they are not yet a member of this group
                if (!bp_current_user_can('bp_moderate') && 'public' == $bp->groups->current_group->status && !groups_is_user_member(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
                    groups_join_group($bp->groups->current_group->id);
                }
                $error_message = '';
                $forum_id = groups_get_groupmeta($bp->groups->current_group->id, 'forum_id');
                if (!empty($forum_id)) {
                    if (empty($_POST['topic_title'])) {
                        $error_message = __('Please provide a title for your forum topic.', 'buddypress');
                    } else {
                        if (empty($_POST['topic_text'])) {
                            $error_message = __('Forum posts cannot be empty. Please enter some text.', 'buddypress');
                        }
                    }
                    if ($error_message) {
                        bp_core_add_message($error_message, 'error');
                        $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum';
                    } else {
                        if (!($topic = groups_new_group_forum_topic($_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id))) {
                            bp_core_add_message(__('There was an error when creating the topic', 'buddypress'), 'error');
                            $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum';
                        } else {
                            bp_core_add_message(__('The topic was created successfully', 'buddypress'));
                            $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum/topic/' . $topic->topic_slug . '/';
                        }
                    }
                    bp_core_redirect($redirect);
                } else {
                    bp_core_add_message(__('Please pick the group forum where you would like to post this topic.', 'buddypress'), 'error');
                    bp_core_redirect(add_query_arg('new', '', bp_get_forums_directory_permalink()));
                }
            } else {
                bp_core_add_message(__('Please pick the group forum where you would like to post this topic.', 'buddypress'), 'error');
                bp_core_redirect(add_query_arg('new', '', bp_get_forums_directory_permalink()));
            }
        }
        do_action('bp_forums_directory_forums_setup');
        bp_core_load_template(apply_filters('bp_forums_template_directory_forums_setup', 'forums/index'));
    }
}
 /**
  * Register the Folders taxonomies.
  *
  * - bp_docs_doc_in_folder contains relationships between Docs and
  *   Folders
  * - bp_docs_folder_in_user contains relationships between Folders
  *   and Users
  * - bp_docs_folder_in_group contains relationships between Folders
  *   and Groups
  *
  * @since 1.9
  */
 public function register_taxonomies()
 {
     register_taxonomy('bp_docs_doc_in_folder', bp_docs_get_post_type_name(), array('public' => false));
     register_taxonomy('bp_docs_folder_in_user', 'bp_docs_folder', array('public' => true));
     if (bp_is_active('groups')) {
         register_taxonomy('bp_docs_folder_in_group', 'bp_docs_folder', array('public' => true));
     }
 }
 /**
  * Integrate Achievements into the BuddyPress Activity component.
  *
  * @since Achievements (3.2)
  */
 public function init_components()
 {
     if (!bp_is_active('activity')) {
         return;
     }
     require achievements()->includes_dir . 'class-dpa-buddypress-activity.php';
     achievements()->extensions->buddypress_activity = new DPA_BuddyPress_Activity();
 }
Exemplo n.º 26
0
 /**
  *  Hooked to bp_init.
  */
 function init()
 {
     if (bp_is_active('notifications')) {
         add_filter('rtmedia_like_notifications', array($this, 'format_like_notifications'));
         add_action('rtmedia_after_like_media', array($this, 'add_like_notify'));
         add_action('rtmedia_after_media', array($this, 'mark_notification_unread'));
     }
 }
 /**
  *  Hooked to bp_init.
  */
 function init()
 {
     if (bp_is_active('notifications')) {
         add_filter('rtmedia_comment_notifications', array($this, 'format_comment_notifications'));
         add_action('rtmedia_after_add_comment', array($this, 'add_comment_notify'));
         add_action('rtmedia_after_media', array($this, 'mark_notification_unread'));
         add_action('rtmedia_before_remove_comment', array($this, 'remove_comment_notification'));
     }
 }
Exemplo n.º 28
0
/**
 * Get user profile URL to add our Google Drive options.
 *
 * If BuddyPress is enabled and the BP Settings component is enabled, we'll
 * use the user settings URL.  Otherwise, we'll use the admin dashboard
 * profile link from the main site.
 *
 * @return string
 */
function mexp_gdrive_get_user_profile_url()
{
    if (function_exists('buddypress') && bp_is_active('settings')) {
        $url = trailingslashit(bp_loggedin_user_domain() . bp_get_settings_slug());
    } else {
        $url = get_admin_url($GLOBALS['current_site']->blog_id, 'profile.php');
    }
    return apply_filters('mexp_gdrive_get_user_profile_url', $url . '#gauth');
}
Exemplo n.º 29
0
function friends_register_activity_actions()
{
    global $bp;
    if (!bp_is_active('activity')) {
        return false;
    }
    bp_activity_set_action($bp->friends->id, 'friends_register_activity_action', __('New friendship created', 'buddypress'));
    do_action('friends_register_activity_actions');
}
Exemplo n.º 30
-1
/**
 * When a Notepad is edited, record the fact to the activity stream
 *
 * @since 1.0
 * @param int $post_id
 * @param object $post
 * @return int The id of the activity item posted
 */
function participad_notepad_record_notepad_activity($post_id, $post)
{
    global $bp;
    // Run only for participad_notebook post type
    if (empty($post->post_type) || participad_notepad_post_type_name() != $post->post_type) {
        return;
    }
    // Throttle activity updates: No duplicate posts (same user, same
    // notepad) within 60 minutes
    $already_args = array('max' => 1, 'sort' => 'DESC', 'show_hidden' => 1, 'filter' => array('user_id' => get_current_user_id(), 'action' => 'participad_notepad_edited', 'secondary_id' => $post_id));
    $already_activity = bp_activity_get($already_args);
    // If any activity items are found, compare its date_recorded with time() to
    // see if it's within the allotted throttle time. If so, don't record the
    // activity item
    if (!empty($already_activity['activities'])) {
        $date_recorded = $already_activity['activities'][0]->date_recorded;
        $drunix = strtotime($date_recorded);
        if (time() - $drunix <= apply_filters('participad_notepad_edit_activity_throttle_time', 60 * 60)) {
            return;
        }
    }
    $post_permalink = get_permalink($post_id);
    $action = sprintf(__('%1$s edited a notepad %2$s on the site %3$s', 'participad'), bp_core_get_userlink(get_current_user_id()), '<a href="' . $post_permalink . '">' . esc_html($post->post_title) . '</a>', '<a href="' . get_option('siteurl') . '">' . get_option('blogname') . '</a>');
    $activity_id = bp_activity_add(array('user_id' => get_current_user_id(), 'component' => bp_is_active('blogs') ? $bp->blogs->id : 'blogs', 'action' => $action, 'primary_link' => $post_permalink, 'type' => 'participad_notepad_edited', 'item_id' => get_current_blog_id(), 'secondary_item_id' => $post_id, 'recorded_time' => $post->post_modified_gmt, 'hide_sitewide' => get_option('blog_public') <= 0));
    if (function_exists('bp_blogs_update_blogmeta')) {
        bp_blogs_update_blogmeta(get_current_blog_id(), 'last_activity', bp_core_current_time());
    }
    return $activity_id;
}