/** * Add Cover Photos to BuddyPress. */ function wff_theme_cover_photos() { if (bp_is_user() || bp_is_group()) { if (function_exists('bp_disable_cover_image_uploads') && bp_disable_cover_image_uploads() == false && !bp_is_group_create()) { get_template_part('buddypress/parts/cover-photo'); } } }
/** * * @global type $bp * @return type */ function bcg_is_disabled_for_group() { $bp = buddypress(); $group_id = false; if (bp_is_group_create()) { $group_id = $_COOKIE['bp_new_group_id']; } elseif (bp_is_group()) { $group_id = $bp->groups->current_group->id; } return apply_filters('bcg_is_disabled_for_group', bcg_is_disabled($group_id)); }
/** * Load the js only when needed * * @return bool */ function cfbgr_is_restriction_js() { // Group create if (bp_is_group_create() && bp_is_group_creation_step('group-settings')) { return true; } // Group manage if (bp_is_group() && bp_is_group_admin_screen('group-settings')) { return true; } return false; }
/** * Add the Group Admin top-level menu when viewing group pages. * * @since 1.5.0 * * @todo Add dynamic menu items for group extensions. * * @return false|null False if not on a group page, or if user does not have * access to group admin options. */ function bp_groups_group_admin_menu() { global $wp_admin_bar; $bp = buddypress(); // Only show if viewing a group. if (!bp_is_group() || bp_is_group_create()) { return false; } // Only show this menu to group admins and super admins. if (!bp_current_user_can('bp_moderate') && !bp_group_is_admin()) { return false; } // Unique ID for the 'Edit Group' menu. $bp->group_admin_menu_id = 'group-admin'; // Add the top-level Group Admin button. $wp_admin_bar->add_menu(array('id' => $bp->group_admin_menu_id, 'title' => __('Edit Group', 'buddypress'), 'href' => bp_get_group_permalink($bp->groups->current_group))); // Index of the Manage tabs parent slug. $nav_index = $bp->groups->current_group->slug . '_manage'; // Check if current group has Manage tabs. if (empty($bp->bp_options_nav[$nav_index])) { return; } // Build the Group Admin menus. foreach ($bp->bp_options_nav[$nav_index] as $menu) { /** * Should we add the current manage link in the Group's "Edit" Admin Bar menu ? * * All core items will be added, plugins can use a new parameter in the BP Group Extension API * to also add the link to the "edit screen" of their group component. To do so, set the * the 'show_in_admin_bar' argument of your edit screen to true */ if ($menu['show_in_admin_bar']) { $title = sprintf(_x('Edit Group %s', 'Group WP Admin Bar manage links', 'buddypress'), $menu['name']); // Title is specific for delete. if ('delete-group' == $menu['slug']) { $title = sprintf(_x('%s Group', 'Group WP Admin Bar delete link', 'buddypress'), $menu['name']); } $wp_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => $menu['slug'], 'title' => $title, 'href' => bp_get_groups_action_link('admin/' . $menu['slug']))); } } }
/** * Should we show the group's custom front page ? */ private function show_front_page() { $retval = false; if (bp_is_group_create()) { return $retval; } if (!bp_is_group()) { return $retval; } $group_id = bp_get_current_group_id(); if (empty($group_id)) { return $retval; } if (bp_is_item_admin()) { return $retval; } if (!groups_is_user_member(bp_loggedin_user_id(), $group_id) && $this->has_front_page($group_id)) { $retval = true; } return $retval; }
/** * Checks whether Avatar UI should be loaded. * * @since 2.3.0 * * @return bool True if Avatar UI should load, false otherwise. */ function bp_avatar_is_front_edit() { $retval = false; // No need to carry on if the current WordPress version is not supported. if (!bp_attachments_is_wp_version_supported()) { return $retval; } if (bp_is_user_change_avatar() && 'crop-image' !== bp_get_avatar_admin_step()) { $retval = !bp_core_get_root_option('bp-disable-avatar-uploads'); } if (bp_is_active('groups')) { // Group creation if (bp_is_group_create() && bp_is_group_creation_step('group-avatar') && 'crop-image' !== bp_get_avatar_admin_step()) { $retval = !bp_disable_group_avatar_uploads(); // Group Manage } elseif (bp_is_group_admin_page() && bp_is_group_admin_screen('group-avatar') && 'crop-image' !== bp_get_avatar_admin_step()) { $retval = !bp_disable_group_avatar_uploads(); } } /** * Use this filter if you need to : * - Load the avatar UI for a component that is !groups or !user (return true regarding your conditions) * - Completely disable the avatar UI introduced in 2.3 (eg: __return_false()) * * @since 2.3.0 * * @param bool whether to load the Avatar UI. */ return apply_filters('bp_avatar_is_front_edit', $retval); }
/** * Are we on a page to edit a cover image ? * * @since 2.4.0 * * @return bool True if on a page to edit a cover image, false otherwise */ function bp_attachments_cover_image_is_edit() { $retval = false; $current_component = bp_current_component(); if ('profile' === $current_component) { $current_component = 'xprofile'; } if (!bp_is_active($current_component, 'cover_image')) { return $retval; } if (bp_is_user_change_cover_image()) { $retval = !bp_disable_cover_image_uploads(); } if (bp_is_group_admin_page() && 'group-cover-image' == bp_get_group_current_admin_tab() || bp_is_group_create() && bp_is_group_creation_step('group-cover-image')) { $retval = !bp_disable_group_cover_image_uploads(); } return apply_filters('bp_attachments_cover_image_is_edit', $retval, $current_component); }
/** * Customize the body class, according to the currently displayed BP content. * * Uses the above is_() functions to output a body class for each scenario. * * @since 1.1.0 * * @param array $wp_classes The body classes coming from WP. * @param array|bool $custom_classes Classes that were passed to get_body_class(). * @return array $classes The BP-adjusted body classes. */ function bp_get_the_body_class($wp_classes = array(), $custom_classes = false) { $bp_classes = array(); /* Pages *************************************************************/ if (is_front_page()) { $bp_classes[] = 'home-page'; } if (bp_is_directory()) { $bp_classes[] = 'directory'; } if (bp_is_single_item()) { $bp_classes[] = 'single-item'; } /* Components ********************************************************/ if (!bp_is_blog_page()) { if (bp_is_user_profile()) { $bp_classes[] = 'xprofile'; } if (bp_is_activity_component()) { $bp_classes[] = 'activity'; } if (bp_is_blogs_component()) { $bp_classes[] = 'blogs'; } if (bp_is_messages_component()) { $bp_classes[] = 'messages'; } if (bp_is_friends_component()) { $bp_classes[] = 'friends'; } if (bp_is_groups_component()) { $bp_classes[] = 'groups'; } if (bp_is_settings_component()) { $bp_classes[] = 'settings'; } } /* User **************************************************************/ if (bp_is_user()) { $bp_classes[] = 'bp-user'; // Add current user member types. if ($member_types = bp_get_member_type(bp_displayed_user_id(), false)) { foreach ($member_types as $member_type) { $bp_classes[] = sprintf('member-type-%s', esc_attr($member_type)); } } } if (!bp_is_directory()) { if (bp_is_user_blogs()) { $bp_classes[] = 'my-blogs'; } if (bp_is_user_groups()) { $bp_classes[] = 'my-groups'; } if (bp_is_user_activity()) { $bp_classes[] = 'my-activity'; } } else { if (bp_get_current_member_type()) { $bp_classes[] = 'type'; } } if (bp_is_my_profile()) { $bp_classes[] = 'my-account'; } if (bp_is_user_profile()) { $bp_classes[] = 'my-profile'; } if (bp_is_user_friends()) { $bp_classes[] = 'my-friends'; } if (bp_is_user_messages()) { $bp_classes[] = 'my-messages'; } if (bp_is_user_recent_commments()) { $bp_classes[] = 'recent-comments'; } if (bp_is_user_recent_posts()) { $bp_classes[] = 'recent-posts'; } if (bp_is_user_change_avatar()) { $bp_classes[] = 'change-avatar'; } if (bp_is_user_profile_edit()) { $bp_classes[] = 'profile-edit'; } if (bp_is_user_friends_activity()) { $bp_classes[] = 'friends-activity'; } if (bp_is_user_groups_activity()) { $bp_classes[] = 'groups-activity'; } /* Messages **********************************************************/ if (bp_is_messages_inbox()) { $bp_classes[] = 'inbox'; } if (bp_is_messages_sentbox()) { $bp_classes[] = 'sentbox'; } if (bp_is_messages_compose_screen()) { $bp_classes[] = 'compose'; } if (bp_is_notices()) { $bp_classes[] = 'notices'; } if (bp_is_user_friend_requests()) { $bp_classes[] = 'friend-requests'; } if (bp_is_create_blog()) { $bp_classes[] = 'create-blog'; } /* Groups ************************************************************/ if (bp_is_group()) { $bp_classes[] = 'group-' . groups_get_current_group()->slug; // Add current group types. if ($group_types = bp_groups_get_group_type(bp_get_current_group_id(), false)) { foreach ($group_types as $group_type) { $bp_classes[] = sprintf('group-type-%s', esc_attr($group_type)); } } } if (bp_is_group_leave()) { $bp_classes[] = 'leave-group'; } if (bp_is_group_invites()) { $bp_classes[] = 'group-invites'; } if (bp_is_group_members()) { $bp_classes[] = 'group-members'; } if (bp_is_group_forum_topic()) { $bp_classes[] = 'group-forum-topic'; } if (bp_is_group_forum_topic_edit()) { $bp_classes[] = 'group-forum-topic-edit'; } if (bp_is_group_forum()) { $bp_classes[] = 'group-forum'; } if (bp_is_group_admin_page()) { $bp_classes[] = 'group-admin'; $bp_classes[] = bp_get_group_current_admin_tab(); } if (bp_is_group_create()) { $bp_classes[] = 'group-create'; $bp_classes[] = bp_get_groups_current_create_step(); } if (bp_is_group_home()) { $bp_classes[] = 'group-home'; } if (bp_is_single_activity()) { $bp_classes[] = 'activity-permalink'; } /* Registration ******************************************************/ if (bp_is_register_page()) { $bp_classes[] = 'registration'; } if (bp_is_activation_page()) { $bp_classes[] = 'activation'; } /* Current Component & Action ****************************************/ if (!bp_is_blog_page()) { $bp_classes[] = bp_current_component(); $bp_classes[] = bp_current_action(); } /* Clean up ***********************************************************/ // Add BuddyPress class if we are within a BuddyPress page. if (!bp_is_blog_page()) { $bp_classes[] = 'buddypress'; } // Merge WP classes with BuddyPress classes and remove any duplicates. $classes = array_unique(array_merge((array) $bp_classes, (array) $wp_classes)); /** * Filters the BuddyPress classes to be added to body_class() * * @since 1.1.0 * * @param array $classes Array of body classes to add. * @param array $bp_classes Array of BuddyPress-based classes. * @param array $wp_classes Array of WordPress-based classes. * @param array $custom_classes Array of classes that were passed to get_body_class(). */ return apply_filters('bp_get_the_body_class', $classes, $bp_classes, $wp_classes, $custom_classes); }
/** * Runs through the various buddyPress conditional tags to check the current page being viewed. Once * a condition is met, add items to the $items array. * * @since 0.6.0 * @access public * @return void */ public function do_trail_items() { global $bp; /* Add the network and site home links. */ $this->do_network_home_link(); $this->do_site_home_link(); $trail_end = ''; if (!empty($bp->displayed_user->fullname)) { // looking at a user or self $this->items[] = '<a href="' . bp_get_members_directory_permalink() . '">' . get_the_title($bp->pages->members->id) . '</a>'; $this->items[] = '<a href="' . $bp->displayed_user->domain . '" title="' . strip_tags($bp->displayed_user->userdata->display_name) . '">' . strip_tags($bp->displayed_user->userdata->display_name) . '</a>'; } else { if ($bp->is_single_item) { // we're on a single item page $this->items[] = '<a href="' . get_permalink($bp->pages->{$bp->current_component}->id) . '" title="' . esc_attr(strip_tags(get_the_title($bp->pages->{$bp->current_component}->id))) . '">' . get_the_title($bp->pages->{$bp->current_component}->id) . '</a>'; $this->items[] = '<a href="' . get_permalink() . '" title="' . esc_attr($bp->bp_options_title) . '">' . $bp->bp_options_title . '</a>'; } else { if ($bp->is_directory) { // this is a top level directory page $trail_end = get_the_title($bp->pages->{$bp->current_component}->id); } else { if (bp_is_register_page()) { $trail_end = __('Create an Account', 'buddypress'); } else { if (bp_is_activation_page()) { $trail_end = __('Activate your Account', 'buddypress'); } else { if (bp_is_group_create()) { $this->items[] = '<a href="' . get_permalink($bp->pages->groups->id) . '" title="' . esc_attr(get_the_title($bp->pages->groups->id)) . '">' . get_the_title($bp->pages->groups->id) . '</a>'; $trail_end = __('Create a Group', 'buddypress'); } else { if (bp_is_create_blog()) { $this->items[] = '<a href="' . home_url() . '/' . $bp->current_component . '" title="' . ucwords($bp->current_component) . '">' . ucwords($bp->current_component) . '</a>'; $trail_end = __('Create a Blog', 'buddypress'); } } } } } } } if ($trail_end) { $this->items[] = $trail_end; } /* Return the bbPress breadcrumb trail items. */ $this->items = apply_filters('breadcrumb_trail_get_buddypress_items', $this->items, $this->args); }
/** * bp_groupblog_signup_blog($blogname = '', $blog_title = '', $errors = '') * * This function is called from the template and initiates the blog creation. */ function bp_groupblog_signup_blog($blogname = '', $blog_title = '', $errors = '') { global $current_user, $current_site, $groupblog_create_screen; global $bp, $filtered_results; if (!is_wp_error($errors)) { $errors = new WP_Error(); } // allow definition of default variables $filtered_results = apply_filters('signup_blog_init', array('blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $errors)); $blogname = $filtered_results['blogname']; $blog_title = $filtered_results['blog_title']; $errors = $filtered_results['errors']; if (!isset($groupblog_create_screen)) { $groupblog_create_screen = false; } // Get the group id, which is fetched differently depending on whether this is a group // Create or Edit screen $group_id = bp_is_group_create() ? bp_get_new_group_id() : bp_get_current_group_id(); $disabled = !bp_groupblog_silent_add($group_id) || !bp_groupblog_is_blog_enabled($group_id) ? ' disabled="true" ' : ''; if (!$groupblog_create_screen) { ?> <h2><?php _e('Group Blog', 'groupblog'); ?> </h2> <form id="setupform" method="post" action="<?php bp_groupblog_admin_form_action('group-blog'); ?> "> <input type="hidden" name="stage" value="gimmeanotherblog" /> <?php do_action("signup_hidden_fields"); ?> <?php } ?> <div class="checkbox"> <label><input type="checkbox" name="groupblog-enable-blog" id="groupblog-enable-blog" value="1"<?php bp_groupblog_show_enabled($group_id); ?> /> <?php _e('Enable group blog', 'groupblog'); ?> </label> </div> <?php bp_groupblog_show_blog_form($blogname, $blog_title, $errors); ?> <br /> <div id="groupblog-member-options"> <h3><?php _e('Member Options', 'groupblog'); ?> </h3> <p><?php _e('Enable blog posting to allow adding of group members to the blog with the roles set below.', 'groupblog'); ?> <br /><?php _e('When disabled, all members will temporarily be set to subscribers, disabling posting.', 'groupblog'); ?> </p> <div class="checkbox"> <label><input<?php if (!bp_groupblog_is_blog_enabled($group_id)) { ?> disabled="true"<?php } ?> type="checkbox" name="groupblog-silent-add" id="groupblog-silent-add" value="1"<?php if (bp_groupblog_silent_add($group_id)) { ?> checked="checked"<?php } ?> /> <?php _e('Enable member blog posting', 'groupblog'); ?> </label> </div> <?php // Assign our default roles to variables. // If nothing has been saved in the groupmeta yet, then we assign our own defalt values. if (!($groupblog_default_admin_role = groups_get_groupmeta($bp->groups->current_group->id, 'groupblog_default_admin_role'))) { $groupblog_default_admin_role = $bp->groupblog->default_admin_role; } if (!($groupblog_default_mod_role = groups_get_groupmeta($bp->groups->current_group->id, 'groupblog_default_mod_role'))) { $groupblog_default_mod_role = $bp->groupblog->default_mod_role; } if (!($groupblog_default_member_role = groups_get_groupmeta($bp->groups->current_group->id, 'groupblog_default_member_role'))) { $groupblog_default_member_role = $bp->groupblog->default_member_role; } ?> <label><strong><?php _e('Default Administrator Role:', 'groupblog'); ?> </strong></label> <input type="radio" <?php checked($groupblog_default_admin_role, 'administrator'); ?> value="administrator" name="default-administrator"<?php echo $disabled; ?> /><span> <?php _e('Administrator', 'groupblog'); ?> </span> <input type="radio" <?php checked($groupblog_default_admin_role, 'editor'); ?> value="editor" name="default-administrator"<?php echo $disabled; ?> /><span> <?php _e('Editor', 'groupblog'); ?> </span> <input type="radio" <?php checked($groupblog_default_admin_role, 'author'); ?> value="author" name="default-administrator"<?php echo $disabled; ?> /><span> <?php _e('Author', 'groupblog'); ?> </span> <input type="radio" <?php checked($groupblog_default_admin_role, 'contributor'); ?> value="contributor" name="default-administrator"<?php echo $disabled; ?> /><span> <?php _e('Contributor', 'groupblog'); ?> </span> <input type="radio" <?php checked($groupblog_default_admin_role, 'subscriber'); ?> value="subscriber" name="default-administrator"<?php echo $disabled; ?> /><span> <?php _e('Subscriber', 'groupblog'); ?> </span> <label><strong><?php _e('Default Moderator Role:', 'groupblog'); ?> </strong></label> <input type="radio" <?php checked($groupblog_default_mod_role, 'administrator'); ?> value="administrator" name="default-moderator"<?php echo $disabled; ?> /><span> <?php _e('Administrator', 'groupblog'); ?> </span> <input type="radio" <?php checked($groupblog_default_mod_role, 'editor'); ?> value="editor" name="default-moderator"<?php echo $disabled; ?> /><span> <?php _e('Editor', 'groupblog'); ?> </span> <input type="radio" <?php checked($groupblog_default_mod_role, 'author'); ?> value="author" name="default-moderator"<?php echo $disabled; ?> /><span> <?php _e('Author', 'groupblog'); ?> </span> <input type="radio" <?php checked($groupblog_default_mod_role, 'contributor'); ?> value="contributor" name="default-moderator"<?php echo $disabled; ?> /><span> <?php _e('Contributor', 'groupblog'); ?> </span> <input type="radio" <?php checked($groupblog_default_mod_role, 'subscriber'); ?> value="subscriber" name="default-moderator"<?php echo $disabled; ?> /><span> <?php _e('Subscriber', 'groupblog'); ?> </span> <label><strong><?php _e('Default Member Role:', 'groupblog'); ?> </strong></label> <input type="radio" <?php checked($groupblog_default_member_role, 'administrator'); ?> value="administrator" name="default-member"<?php echo $disabled; ?> /><span> <?php _e('Administrator', 'groupblog'); ?> </span> <input type="radio" <?php checked($groupblog_default_member_role, 'editor'); ?> value="editor" name="default-member"<?php echo $disabled; ?> /><span> <?php _e('Editor', 'groupblog'); ?> </span> <input type="radio" <?php checked($groupblog_default_member_role, 'author'); ?> value="author" name="default-member"<?php echo $disabled; ?> /><span> <?php _e('Author', 'groupblog'); ?> </span> <input type="radio" <?php checked($groupblog_default_member_role, 'contributor'); ?> value="contributor" name="default-member"<?php echo $disabled; ?> /><span> <?php _e('Contributor', 'groupblog'); ?> </span> <input type="radio" <?php checked($groupblog_default_member_role, 'subscriber'); ?> value="subscriber" name="default-member"<?php echo $disabled; ?> /><span> <?php _e('Subscriber', 'groupblog'); ?> </span> <div id="groupblog-member-roles"> <label><strong><?php _e('A bit about WordPress member roles:', 'groupblog'); ?> </strong></label> <ul id="groupblog-members"> <li><?php _e('Administrator', 'groupblog'); ?> - <?php _e("Somebody who has access to all the administration features.", 'groupblog'); ?> </li> <li><?php _e('Editor', 'groupblog'); ?> - <?php _e("Somebody who can publish posts, manage posts as well as manage other people's posts, etc.", 'groupblog'); ?> </li> <li><?php _e('Author', 'groupblog'); ?> - <?php _e("Somebody who can publish and manage their own posts.", 'groupblog'); ?> </li> <li><?php _e('Contributor', 'groupblog'); ?> - <?php _e("Somebody who can write and manage their posts but not publish posts.", 'groupblog'); ?> </li> <li><?php _e('Subscriber', 'groupblog'); ?> - <?php _e("Somebody who can read comments/comment/receive news letters, etc.", 'groupblog'); ?> </li> </ul> </div> </div> <br /> <?php if (bp_groupblog_allow_group_admin_layout()) { ?> <?php if (!($page_template_layout = groups_get_groupmeta($bp->groups->current_group->id, 'page_template_layout'))) { $page_template_layout = groupblog_get_page_template_layout(); } ?> <div id="groupblog-layout-options"> <h3><?php _e('Select Layout', 'groupblog'); ?> </h3> <p class="enabled"><?php _e('Please select a Layout which you would like to use for your Group Blog.', 'groupblog'); ?> </p> <table class="enabled" id="availablethemes" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="available-theme top left"> <?php echo '<img src="' . WP_PLUGIN_URL . '/bp-groupblog/inc/i/screenshot-mag.png">'; ?> <br /><br /> <input<?php if (!bp_groupblog_is_blog_enabled($group_id)) { ?> disabled="true"<?php } ?> name="page_template_layout" id="page_template_layout" value="magazine" type="radio" <?php if ($page_template_layout == 'magazine') { echo 'checked="checked"'; } ?> /><label style="display:inline;"> <?php _e('Magazine', 'groupblog'); ?> </label> <p class="description"><?php _e('Balanced template for groups with diverse postings.', 'groupblog'); ?> </p> </td> <td class="available-theme top"> <?php echo '<img src="' . WP_PLUGIN_URL . '/bp-groupblog/inc/i/screenshot-micro.png">'; ?> <br /><br /> <input<?php if (!bp_groupblog_is_blog_enabled($group_id)) { ?> disabled="true"<?php } ?> name="page_template_layout" id="page_template_layout" value="microblog" type="radio" <?php if ($page_template_layout == 'microblog') { echo 'checked="checked"'; } ?> /><label style="display:inline;"> <?php _e('Microblog', 'groupblog'); ?> </label> <p class="description"><?php _e('Great for simple listing of posts in a chronological order.', 'groupblog'); ?> </p> </td> </tr> </tbody> </table> </div> <br /> <?php } ?> <?php if (!$groupblog_create_screen) { ?> <p> <input id="save" type="submit" name="save" class="submit" value="<?php _e('Save Changes »', 'groupblog'); ?> "/> </p> </form> <?php } }
function body_class($wp_classes, $custom_classes = false) { global $bp; $bp_classes = array(); if (bp_is_directory()) { $bp_classes[] = 'directory'; } elseif (bp_is_single_item()) { $bp_classes[] = 'single-item'; } elseif (bp_is_activity_component() || $this->show_activity_page) { $bp_classes[] = 'activity'; } if ($this->adminbar && $this->theme->have_adminbar()) { $bp_classes[] = 'adminbar'; } if (!is_page() && is_front_page() && is_file(CHILD_DIR . '/home.php')) { $bp_classes[] = 'home'; } if ($this->show_activity_page) { $bp_classes[] = 'internal-page'; } elseif (!bp_is_blog_page()) { $wp_classes = array(); if (!bp_is_directory()) { $bp_classes[] = 'internal-page'; } if (bp_is_user_profile()) { $bp_classes[] = 'profile'; } elseif (bp_is_blogs_component()) { $bp_classes[] = 'blogs'; } elseif (bp_is_messages_component()) { $bp_classes[] = 'messages'; } elseif (bp_is_friends_component()) { $bp_classes[] = 'friends'; } elseif (bp_is_groups_component()) { $bp_classes[] = 'groups'; } elseif (bp_is_settings_component()) { $bp_classes[] = 'settings'; } } if (is_user_logged_in()) { $bp_classes[] = 'logged-in'; if (!bp_is_directory()) { if (bp_is_user_friends()) { $bp_classes[] = 'my-friends'; } elseif (bp_is_user_activity()) { $bp_classes[] = 'my-activity'; } elseif (bp_is_user_blogs()) { $bp_classes[] = 'my-blogs'; } elseif (bp_is_user_groups()) { $bp_classes[] = 'my-groups'; } elseif (bp_is_messages_inbox()) { $bp_classes[] = 'inbox'; } elseif (bp_is_messages_sentbox()) { $bp_classes[] = 'sentbox'; } elseif (bp_is_messages_compose_screen()) { $bp_classes[] = 'compose'; } elseif (bp_is_notices()) { $bp_classes[] = 'notices'; } elseif (bp_is_user_friend_requests()) { $bp_classes[] = 'friend-requests'; } elseif (bp_is_create_blog()) { $bp_classes[] = 'create-blog'; } elseif (bp_is_group_leave()) { $bp_classes[] = 'leave-group'; } elseif (bp_is_group_invites()) { $bp_classes[] = 'group-invites'; } elseif (bp_is_group_forum_topic_edit()) { $bp_classes[] = 'group-forum-topic-edit'; } elseif (bp_is_group_admin_page()) { $bp_classes[] = 'group-admin'; } elseif (bp_is_group_create()) { $bp_classes[] = 'group-create'; } elseif (bp_is_user_change_avatar()) { $bp_classes[] = 'change-avatar'; } elseif (bp_is_user_profile_edit()) { $bp_classes[] = 'profile-edit'; } } } else { $bp_classes[] = 'visitor'; } if (bp_is_group_members()) { $bp_classes[] = 'group-members'; } elseif (bp_is_group_home()) { $bp_classes[] = 'group-home'; } elseif (bp_is_group_forum()) { $bp_classes[] = 'group-forum'; if (bp_is_group_forum_topic()) { $bp_classes[] = 'group-forum-topic'; } } else { if (bp_is_user_recent_commments()) { $bp_classes[] = 'recent-comments'; } if (bp_is_user_recent_posts()) { $bp_classes[] = 'recent-posts'; } if (bp_is_user_friends_activity()) { $bp_classes[] = 'friends-activity'; } elseif (bp_is_single_activity()) { $bp_classes[] = 'activity-permalink'; } elseif (bp_is_register_page()) { $bp_classes[] = 'registration'; } elseif (bp_is_activation_page()) { $bp_classes[] = 'activation'; } } /* Add the current_component, current_action into the bp classes */ if (!bp_is_blog_page()) { if (!empty($bp->current_component)) { $bp_classes[] = $bp->current_component; } if (!empty($bp->current_action)) { $bp_classes[] = $bp->current_action; } } if ((!bp_is_blog_page() || is_home()) && !empty($custom_classes)) { $wp_classes = (array) $custom_classes; } /* Merge WP classes with BP classes */ $classes = array_merge((array) $bp_classes, (array) $wp_classes); /* Remove any duplicates */ $classes = array_unique($classes); return apply_filters('bp_get_the_body_class', $classes, $bp_classes, $wp_classes, $custom_classes); }
function invite_anyone_create_screen_content($event) { if (function_exists('bp_post_get_permalink')) { // ugly ugly ugly hack to check for pre-1.2 versions of BP add_action('wp_footer', 'invite_anyone_add_old_css'); ?> <?php if (bp_has_groups()) { while (bp_groups()) { bp_the_group(); ?> <?php do_action('bp_before_group_send_invites_content'); ?> <?php if ($event != 'create') { ?> <form action="<?php bp_group_send_invite_form_action(); ?> " method="post" id="send-invite-form"> <?php } ?> <div class="left-menu"> <p><?php _e("Search for members to invite:", 'bp-invite-anyone'); ?> <span class="ajax-loader"></span></p> <ul class="first acfb-holder"> <li> <input type="text" name="send-to-input" class="send-to-input" id="send-to-input" /> </li> </ul> <p><?php _e('Select members from the directory:', 'bp-invite-anyone'); ?> <span class="ajax-loader"></span></p> <div id="invite-anyone-member-list"> <ul> <?php bp_new_group_invite_member_list(); ?> </ul> <?php wp_nonce_field('groups_invite_uninvite_user', '_wpnonce_invite_uninvite_user'); ?> </div> </div> <div class="main-column"> <div id="message" class="info"> <p><?php _e('Select people to invite.', 'bp-invite-anyone'); ?> </p> </div> <?php do_action('bp_before_group_send_invites_list'); ?> <?php /* The ID 'friend-list' is important for AJAX support. */ ?> <ul id="invite-anyone-invite-list" class="item-list"> <?php if (bp_group_has_invites()) { ?> <?php while (bp_group_invites()) { bp_group_the_invite(); ?> <li id="<?php bp_group_invite_item_id(); ?> "> <?php bp_group_invite_user_avatar(); ?> <h4><?php bp_group_invite_user_link(); ?> </h4> <span class="activity"><?php bp_group_invite_user_last_active(); ?> </span> <?php do_action('bp_group_send_invites_item'); ?> <div class="action"> <a class="remove" href="<?php bp_group_invite_user_remove_invite_url(); ?> " id="<?php bp_group_invite_item_id(); ?> "><?php _e('Remove Invite', 'buddypress'); ?> </a> <?php do_action('bp_group_send_invites_item_action'); ?> </div> </li> <?php } ?> <?php } ?> </ul> <?php do_action('bp_after_group_send_invites_list'); ?> </div> <div class="clear"></div> <?php if ($event != 'create') { ?> <p class="clear"><input type="submit" name="submit" id="submit" value="<?php _e('Send Invites', 'buddypress'); ?> " /></p> <?php wp_nonce_field('groups_send_invites', '_wpnonce_send_invites'); ?> <?php } ?> <input type="hidden" name="group_id" id="group_id" value="<?php bp_group_id(); ?> " /> <?php if ($event != 'create') { ?> </form> <?php } ?> <?php do_action('bp_before_group_send_invites_content'); ?> <?php } } } else { // Begin BP 1.2 code ?> <?php do_action('bp_before_group_send_invites_content'); ?> <?php if (invite_anyone_access_test() && !bp_is_group_create()) { ?> <p><?php _e('Want to invite someone to the group who is not yet a member of the site?', 'bp-invite-anyone'); ?> <a href="<?php echo bp_loggedin_user_domain() . BP_INVITE_ANYONE_SLUG . '/invite-new-members/group-invites/' . bp_get_group_id(); ?> "><?php _e('Send invitations by email.', 'bp-invite-anyone'); ?> </a></p> <?php } ?> <?php if ($event != 'create') { ?> <form action="send" method="post" id="send-invite-form"> <?php } ?> <div class="left-menu"> <p><?php _e("Search for members to invite:", 'bp-invite-anyone'); ?> <span class="ajax-loader"></span></p> <ul class="first acfb-holder"> <li> <input type="text" name="send-to-input" class="send-to-input" id="send-to-input" /> </li> </ul> <p><?php _e('Select members from the directory:', 'bp-invite-anyone'); ?> <span class="ajax-loader"></span></p> <div id="invite-anyone-member-list"> <ul> <?php bp_new_group_invite_member_list(); ?> </ul> <?php wp_nonce_field('groups_invite_uninvite_user', '_wpnonce_invite_uninvite_user'); ?> </div> </div> <div class="main-column"> <div id="message" class="info"> <p><?php _e('Select people to invite from your friends list.', 'buddypress'); ?> </p> </div> <?php do_action('bp_before_group_send_invites_list'); ?> <?php /* The ID 'friend-list' is important for AJAX support. */ ?> <ul id="invite-anyone-invite-list" class="item-list"> <?php if (bp_group_has_invites()) { ?> <?php while (bp_group_invites()) { bp_group_the_invite(); ?> <li id="<?php bp_group_invite_item_id(); ?> "> <?php bp_group_invite_user_avatar(); ?> <h4><?php bp_group_invite_user_link(); ?> </h4> <span class="activity"><?php bp_group_invite_user_last_active(); ?> </span> <?php do_action('bp_group_send_invites_item'); ?> <div class="action"> <a class="remove" href="<?php bp_group_invite_user_remove_invite_url(); ?> " id="<?php bp_group_invite_item_id(); ?> "><?php _e('Remove Invite', 'buddypress'); ?> </a> <?php do_action('bp_group_send_invites_item_action'); ?> </div> </li> <?php } ?> <?php } ?> </ul> <?php do_action('bp_after_group_send_invites_list'); ?> </div> <div class="clear"></div> <?php if ($event != 'create') { ?> <div class="submit"> <input type="submit" name="submit" id="submit" value="<?php _e('Send Invites', 'buddypress'); ?> " /> </div> <?php } ?> <?php wp_nonce_field('groups_send_invites', '_wpnonce_send_invites'); ?> <!-- Don't leave out this sweet field --> <?php if (!bp_get_new_group_id()) { ?> <input type="hidden" name="group_id" id="group_id" value="<?php bp_group_id(); ?> " /><?php } else { ?> <input type="hidden" name="group_id" id="group_id" value="<?php bp_new_group_id(); ?> " /><?php } ?> <?php if ($event != 'create') { ?> </form> <?php } ?> <?php do_action('bp_after_group_send_invites_content'); ?> <?php } }
function submit_guild(&$group) { // If the user is allowed to delete posts, then they can also create guilds and bypass validation requirements if (!bp_is_group_create() || current_user_can('delete_others_posts')) { return; } // Get the BP object global $bp; // Retrieve and sanitize submission data $group->server = $_POST['group-server']; $group->interests = implode(',', $_POST['group-interests']); $group->faction = $_POST['group-faction']; $group->website = esc_url($_POST['group-website']); $group->style = $_POST['group-style']; // Validate submitted data if ('' === $group->server) { $error = 'Please select your guild's platform and server.'; } elseif (empty($group->interests)) { $error = 'Please select your guild's primary interests.'; } elseif (empty($group->faction)) { $error = 'Please select your guild's primary alliance.'; } // Assign the current group to the group object $bp->groups->current_group = $group; // If there was an error, display it and redirect if (isset($error)) { bp_core_add_message($error, 'error'); bp_core_redirect(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . bp_get_groups_current_create_step() . '/'); } else { // Get the current user $user = new WP_User(get_current_user_id()); $username = $user->display_name; $user_email = $user->user_email; $profile = bp_core_get_userlink($user->ID); // Set email headers $emailto = '*****@*****.**'; $subject = 'Guild Creation Request From ' . $username; $headers[] = "From: {$username} <{$user_email}>\r\n"; $headers[] = "Content-Type: text/html; charset=UTF-8"; // User Information $body = "<h3>Submitting User</h3>"; $body .= "<ul>"; $body .= '<li>Guild Leader: ' . $profile . '</li>'; $body .= '<li>Email: ' . $user_email . '</li>'; $body .= "</ul>"; // Guild Information $body .= "<h3>Guild Information</h3>"; $body .= "<ul>"; $body .= '<li>Guild Name: ' . $group->name . '</li>'; $body .= '<li>Website: ' . $group->website . '</li>'; $body .= '<li>Server: ' . $group->server . '</li>'; $body .= '<li>Faction: ' . $group->faction . '</li>'; $body .= '<li>Interests: ' . $group->interests . '</li>'; $body .= '<li>Style: ' . $group->style . '</li>'; $body .= "</ul>"; // Guild Description $body .= "<h3>Guild Description</h3>"; $body .= '<div>' . stripslashes($group->description) . '</div>'; // Send the mail! wp_mail($emailto, $subject, $body, $headers); // Redirect bp_core_add_message('Thank you for submitting your guild, ' . $user->fullname . '. Your request was successfully sent. We will review it and respond as soon as possible. If your request is approved, you will be added to your group, and promoted to guild leader. We will contact you via email regarding your guild request once it has been processed. Thank you for contributing to Tamriel Foundry!'); bp_core_redirect(SITEURL . '/' . bp_get_groups_root_slug()); } }
/** * Check if this is a BuddyPress page or not. * Returns true or false (boolean) */ function shoestrap_is_bp() { $bp = false; /** Pages *************************************************************/ if (!$bp && bp_is_directory()) { $bp = true; } elseif (!$bp && bp_is_single_item()) { $bp = true; } elseif (!$bp && bp_is_user_profile()) { $bp = true; } elseif (!$bp && bp_is_activity_component()) { $bp = true; } elseif (!$bp && bp_is_blogs_component()) { $bp = true; } elseif (!$bp && bp_is_messages_component()) { $bp = true; } elseif (!$bp && bp_is_friends_component()) { $bp = true; } elseif (!$bp && bp_is_groups_component()) { $bp = true; } elseif (!$bp && bp_is_settings_component()) { $bp = true; } elseif (!$bp && bp_is_user()) { $bp = true; } elseif (!$bp && bp_is_user_blogs()) { $bp = true; } elseif (!$bp && bp_is_user_groups()) { $bp = true; } elseif (!$bp && bp_is_user_activity()) { $bp = true; } elseif (!$bp && bp_is_my_profile()) { $bp = true; } elseif (!$bp && bp_is_user_profile()) { $bp = true; } elseif (!$bp && bp_is_user_friends()) { $bp = true; } elseif (!$bp && bp_is_user_messages()) { $bp = true; } elseif (!$bp && bp_is_user_recent_commments()) { $bp = true; } elseif (!$bp && bp_is_user_recent_posts()) { $bp = true; } elseif (!$bp && bp_is_user_change_avatar()) { $bp = true; } elseif (!$bp && bp_is_user_profile_edit()) { $bp = true; } elseif (!$bp && bp_is_user_friends_activity()) { $bp = true; } elseif (!$bp && bp_is_user_groups_activity()) { $bp = true; } elseif (!$bp && is_user_logged_in()) { $bp = true; } elseif (!$bp && bp_is_messages_inbox()) { $bp = true; } elseif (!$bp && bp_is_messages_sentbox()) { $bp = true; } elseif (!$bp && bp_is_messages_compose_screen()) { $bp = true; } elseif (!$bp && bp_is_notices()) { $bp = true; } elseif (!$bp && bp_is_user_friend_requests()) { $bp = true; } elseif (!$bp && bp_is_create_blog()) { $bp = true; } elseif (!$bp && bp_is_group_leave()) { $bp = true; } elseif (!$bp && bp_is_group_invites()) { $bp = true; } elseif (!$bp && bp_is_group_members()) { $bp = true; } elseif (!$bp && bp_is_group_forum_topic()) { $bp = true; } elseif (!$bp && bp_is_group_forum_topic_edit()) { $bp = true; } elseif (!$bp && bp_is_group_forum()) { $bp = true; } elseif (!$bp && bp_is_group_admin_page()) { $bp = true; } elseif (!$bp && bp_is_group_create()) { $bp = true; } elseif (!$bp && bp_is_group_home()) { $bp = true; } elseif (!$bp && bp_is_single_activity()) { $bp = true; } elseif (!$bp && bp_is_register_page()) { $bp = true; } elseif (!$bp && bp_is_activation_page()) { $bp = true; } elseif (!$bp && !bp_is_blog_page()) { $bp = true; } return $bp; }
/** * Reset the week parameter of the WordPress main query if needed * * When cropping an avatar, a $_POST['w'] var is sent, setting the 'week' * parameter of the WordPress main query to this posted var. To avoid * notices, we need to make sure this 'week' query var is reset to 0 * * @since BuddyPress (2.2.0) * * @param WP_Query $posts_query the main query object * @uses bp_is_group_create() * @uses bp_is_group_admin_page() * @uses bp_is_group_admin_screen() to check for a group admin screen * @uses bp_action_variable() to check for the group's avatar creation step * @uses bp_is_user_change_avatar() to check for the user's change profile screen */ function bp_core_avatar_reset_query($posts_query = null) { $reset_w = false; // Group's avatar edit screen if (bp_is_group_admin_page()) { $reset_w = bp_is_group_admin_screen('group-avatar'); // Group's avatar create screen } elseif (bp_is_group_create()) { /** * we can't use bp_get_groups_current_create_step() * as it's not set yet */ $reset_w = 'group-avatar' === bp_action_variable(1); // User's change avatar screen } else { $reset_w = bp_is_user_change_avatar(); } // A user or a group is cropping an avatar if (true === $reset_w && isset($_POST['avatar-crop-submit'])) { $posts_query->set('w', 0); } }
/** * Get the page context * @version 2.0 */ function get_context() { // Setup placeholders $title = SITENAME; $desc = get_bloginfo('description'); $classes = get_body_class(); $crumbs = array(); // Get some data $id = $this->queried_object_id; $object = $this->queried_object; $sep = " • "; /*-------------------------------------------- DEFAULT CONTEXT ---------------------------------------------*/ $classes[] = 0 == get_current_user_id() ? 'logged-out' : 'logged-in'; $crumbs[] = '<a href="' . SITEURL . '" title="' . SITENAME . '" rel="home" class="trail-home">Home</a>'; // Homepage if (is_home()) { $title = SITENAME . $sep . 'Home'; $classes[] = 'home'; $classes[] = 'sidebar'; $classes[] = 'archive'; /*-------------------------------------------- BUDDYPRESS CONTEXT ---------------------------------------------*/ } elseif (class_exists('BuddyPress') && is_buddypress()) { // BuddyPress Defaults $title = "BuddyPress Page"; $desc = "This is a BuddyPress page."; $classes[] = 'buddypress'; // User Profiles if (bp_is_user()) { $title = bp_get_displayed_user_fullname() . $sep . "User Profile"; $desc = SITENAME . " user profile for member " . bp_get_displayed_user_fullname(); // Your own profile if (bp_is_my_profile()) { $crumbs[] = 'Your Profile'; } else { $crumbs[] = '<a href="' . bp_get_members_directory_permalink() . '" title="Members Directory">Members</a>'; $crumbs[] = '<a href="' . bp_displayed_user_domain() . '" title="' . bp_get_displayed_user_fullname() . '">' . bp_get_displayed_user_fullname() . '</a>'; } // Display the profile component if it isnt the profile home if (!bp_is_user_profile()) { $crumbs[] = ucfirst(bp_current_component()); } // Display the current action if it is not the default public profile if (!in_array(bp_current_action(), array('public', 'just-me', 'my-friends'))) { $crumbs[] = ucfirst(bp_current_action()); } // Single Group } elseif (bp_is_group() || bp_is_group_create()) { // Group Creation if (bp_is_group_create()) { $title = 'Submit New Group'; $desc = 'Submit a new user group for listing on the ' . SITENAME . ' community groups directory.'; $crumbs[] = '<a href="' . SITEURL . '/' . bp_get_groups_root_slug() . '" title="Groups Directory">Groups</a>'; $crumbs[] = 'Create Group'; } elseif (bp_is_group()) { // Default entries $title = bp_get_group_name(); $desc = SITENAME . ' guild profile for ' . bp_get_group_name(); $classes = array_diff($classes, array('page', 'page-template-default')); $crumbs[] = '<a href="' . bp_get_groups_directory_permalink() . '" title="Groups Directory">Groups</a>'; // Group Profile Home if (bp_is_group_home()) { $title = $title . $sep . 'Profile'; $crumbs[] = bp_get_group_name(); // Advanced Component } else { // Link back to group profile $crumbs[] = '<a href="' . bp_get_group_permalink() . '" title="Return to Group Profile">' . bp_get_group_name() . '</a>'; // Members if (bp_is_group_members()) { $title = $title . $sep . 'Members'; $crumbs[] = 'Members'; // Activity } elseif (bp_is_group_activity()) { $title = $title . $sep . 'Activity'; $crumbs[] = 'Activity'; // Invites } elseif (bp_is_group_invites()) { $title = $title . $sep . 'Invitations'; $crumbs[] = 'Invitations'; // Admin } elseif (bp_is_group_admin_page()) { $title = $title . $sep . 'Admin'; $crumbs[] = 'Admin'; // Forum } else { // Forum Root if (NULL == bp_action_variable()) { $title = $title . $sep . 'Forum'; $crumbs[] = 'Forum'; // Sub-Component } else { $crumbs[] = '<a href="' . bp_get_group_permalink() . 'forum/" title="Group Forum">Forum</a>'; // Retrieve topic information from the database global $bp; global $wpdb; // Single Topic if (bp_is_action_variable('topic', 0)) { // Get the topic $topic = $wpdb->get_row($wpdb->prepare("SELECT post_title AS title, post_name AS url\n\t\t\t\t\t\t\t\t\t\tFROM {$wpdb->posts} \n\t\t\t\t\t\t\t\t\t\tWHERE post_name = %s", $bp->action_variables[1])); $title = $topic->title; $crumbs[] = $topic->title; // Replies } elseif (bp_is_action_variable('reply', 0)) { // Get the reply parent topic $topic = $wpdb->get_row($wpdb->prepare("SELECT post_title AS title, post_name AS url\n\t\t\t\t\t\t\t\t\t\tFROM {$wpdb->posts} \n\t\t\t\t\t\t\t\t\t\tWHERE ID = ( \n\t\t\t\t\t\t\t\t\t\t\tSELECT post_parent\n\t\t\t\t\t\t\t\t\t\t\tFROM {$wpdb->posts}\n\t\t\t\t\t\t\t\t\t\t\tWHERE post_name = %s \n\t\t\t\t\t\t\t\t\t\t)", $bp->action_variables[1])); $title = $topic->title; $crumbs[] = $topic->title; } // Topic and Reply Edits if (bp_is_action_variable('edit', 2)) { $crumbs[] = 'Edit'; } } } } } // Directories } elseif (bp_is_directory()) { // Sitewide Activity if (bp_is_activity_component()) { $title = SITENAME . ' Sitewide Activity Feed'; $desc = 'A listing of all recent activity happening throughout the ' . SITENAME . ' community.'; $crumbs[] = 'Sitewide Activity'; // Members Directory } elseif (bp_is_members_component()) { $title = SITENAME . ' Members Directory'; $desc = 'A listing of all registered members in the ' . SITENAME . ' community.'; $crumbs[] = 'Members Directory'; // Groups Directory } elseif (bp_is_groups_component()) { $title = SITENAME . ' Guilds Directory'; $desc = 'A directory listing of guilds active within in the ' . SITENAME . ' community.'; $crumbs[] = 'Guilds Directory'; } // Registration } elseif (bp_is_register_page()) { $title = SITENAME . ' User Registration'; $desc = "Register to join the " . SITENAME . " community."; $crumbs[] = "User Registration"; // Activation } elseif (bp_is_activation_page()) { $title = SITENAME . ' Account Activation'; $desc = "Activate a pending " . SITENAME . " user account."; $crumbs[] = "Account Activation"; } /*-------------------------------------------- BBPRESS CONTEXT ---------------------------------------------*/ } elseif (class_exists('bbPress') && is_bbpress()) { // bbPress Defaults $classes[] = 'bbpress'; $classes[] = 'forums'; $crumbs[] = bbp_is_forum_archive() ? "Forums" : '<a href="' . get_post_type_archive_link('forum') . '">Forums</a>'; // Main Forum Archive if (bbp_is_forum_archive()) { $title = SITENAME . " Forums"; $desc = "Get involved in the community on the " . SITENAME . " forums."; // Recent Topics } elseif (bbp_is_topic_archive()) { $title = "Recent Topics in the " . SITENAME . " Forums"; $desc = "Browse a list of the most recent topics in the " . SITENAME . " Forums."; $crumbs[] = "Recent Topics"; // Single Forum } elseif (bbp_is_single_forum()) { $title = $object->post_title; $desc = $object->post_content; // Loop through parent forums $parent_id = bbp_get_forum_parent_id($id); if (0 != $parent_id) { $crumbs = array_merge($crumbs, $this->parent_crumbs($parent_id)); } $crumbs[] = $object->post_title; // Single Topic } elseif (bbp_is_single_topic()) { $title = $object->post_title; $desc = bbp_get_topic_excerpt($id); $crumbs = array_merge($crumbs, $this->parent_crumbs(bbp_get_topic_forum_id($id))); $crumbs[] = $object->post_title; // Edit Topic } elseif (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) { $title = 'Edit Topic' . $sep . $object->post_title; $desc = bbp_get_topic_excerpt($id); $crumbs = array_merge($crumbs, $this->parent_crumbs($id)); // Tag the specific task if (bbp_is_topic_split()) { $crumbs[] = 'Split Topic'; } elseif (bbp_is_topic_merge()) { $crumbs[] = 'Merge Topic'; } elseif (bbp_is_topic_edit()) { $crumbs[] = 'Edit Topic'; } // Edit Reply } elseif (bbp_is_reply_edit()) { $title = 'Edit Reply' . $sep . bbp_get_reply_topic_title($id); $desc = bbp_get_reply_excerpt($id); $crumbs = array_merge($crumbs, $this->parent_crumbs(bbp_get_reply_topic_id($id))); $crumbs[] = 'Edit Reply'; } /*-------------------------------------------- WORDPRESS CONTEXT ---------------------------------------------*/ } else { // Singular Posts and Pages if (is_singular()) { $title = $object->post_title; $desc = get_post_meta($id, 'description', true); // If no description is found, use an excerpt if (empty($desc)) { $desc = get_post_field('post_excerpt', $id); } // Check for custom template $template = get_post_meta($id, "_wp_{$object->post_type}_template", true); if ('' != $template) { $template = str_replace(array("{$object->post_type}-template-", "{$object->post_type}-"), '', basename($template, '.php')); $classes[] = "{$template}-template"; } // Generate breadcrumbs by post type switch ($object->post_type) { // Single Posts case 'post': // Is the post in a category? $categories = get_the_category(); if ($categories) { // Start with the first category $term = $categories[0]; // If the category has a parent, add it to the trail. if (0 != $term->parent) { $crumbs = array_merge($crumbs, $this->parent_crumbs($term->parent, 'category')); } // Add the category archive link to the trail. $crumbs[] = '<a href="' . get_term_link($term) . '" title="' . esc_attr($term->name) . '">' . $term->name . '</a>'; } // Does the post have an ancestor? if ($object->post_parent) { $crumbs = array_merge($crumbs, $this->parent_crumbs($object->post_parent)); } // Editing a comment on this post if (is_comment_edit()) { $crumbs[] = '<a href="' . get_permalink() . '" title="Return to article">' . get_the_title() . '</a>'; $crumbs[] = 'Edit Comment'; // Reading the post } else { $crumbs[] = get_the_title(); } break; // Pages // Pages case 'page': // Does the page have an ancestor? if ($object->post_parent) { $crumbs = array_merge($crumbs, $this->parent_crumbs($object->post_parent)); } // Otherwise, viewing the page $crumbs[] = get_the_title(); break; // Events // Events case 'event': // Get the calendar the event belongs to $calendar = get_the_terms($object->ID, 'calendar'); $calendar = array_shift($calendar); $desc = 'Upcoming event on the ' . $calendar->name . ' calendar.'; $crumbs[] = '<a href="' . SITEURL . '/calendar/' . $calendar->slug . '" title="' . $calendar->name . ' Calendar">' . $calendar->name . ' Calendar</a>'; $crumbs[] = get_the_title(); break; } // Archives } elseif (is_archive()) { // Category Archives if (is_category()) { $crumbs[] = 'Category'; // If the category has a parent, add it to the trail. if ($object->parent != 0) { $crumbs = array_merge($crumbs, $this->trail_parents($object->parent)); } // Finish up with the term name $crumbs[] = $object->name; // Author Archive } elseif (is_author()) { $title = 'Author Archive' . $sep . $object->display_name; $desc = 'An archive of articles written by ' . $object->display_name; $crumbs[] = 'Author'; $crumbs[] = $object->display_name; // Advanced Search Page } elseif (is_search()) { $title = SITENAME . " Advanced Search"; $desc = "Search for a variety of content types throughout " . SITENAME; $crumbs[] = 'Advanced Search'; $classes[] = 'page'; // Calendar } elseif (is_calendar()) { $title = $object->name . " Calendar"; $desc = "Upcoming events on the " . $object->name . " calendar."; $crumbs[] = $object->name . " Calendar"; } // 404 } elseif (is_404()) { $title = "Error" . $sep . "Page Not Found"; $desc = "Sorry, but this page does not exist, or is not accessible at this time."; $classes[] = 'page'; $crumbs[] = '404 Page Not Found'; } } /*-------------------------------------------- RETURN DATA ---------------------------------------------*/ $this->title = html_entity_decode($title); $this->description = html_entity_decode($desc); $this->classes = $classes; $this->crumbs = $crumbs; }
/** * Filter the page title for BuddyPress pages * * @global object $bp BuddyPress global settings * @param string $title Original page title * @param string $sep How to separate the various items within the page title. * @param string $seplocation Direction to display title * @return string new page title * @see wp_title() * @since BuddyPress (1.5) */ function bp_modify_page_title($title, $sep, $seplocation) { global $bp; // If this is not a BP page, just return the title produced by WP if (bp_is_blog_page()) { return $title; } // If this is the front page of the site, return WP's title if (is_front_page() || is_home()) { return $title; } $title = ''; // Displayed user if (bp_get_displayed_user_fullname() && !is_404()) { // Get the component's ID to try and get it's name $component_id = $component_name = bp_current_component(); // Use the actual component name if (!empty($bp->{$component_id}->name)) { $component_name = $bp->{$component_id}->name; // Fall back on the component ID (probably same as current_component) } elseif (!empty($bp->{$component_id}->id)) { $component_name = $bp->{$component_id}->id; } // translators: "displayed user's name | canonicalised component name" $title = strip_tags(sprintf(__('%1$s | %2$s', 'buddypress'), bp_get_displayed_user_fullname(), ucwords($component_name))); // A single group } elseif (bp_is_active('groups') && !empty($bp->groups->current_group) && !empty($bp->bp_options_nav[$bp->groups->current_group->slug])) { $subnav = isset($bp->bp_options_nav[$bp->groups->current_group->slug][bp_current_action()]['name']) ? $bp->bp_options_nav[$bp->groups->current_group->slug][bp_current_action()]['name'] : ''; // translators: "group name | group nav section name" $title = sprintf(__('%1$s | %2$s', 'buddypress'), $bp->bp_options_title, $subnav); // A single item from a component other than groups } elseif (bp_is_single_item()) { // translators: "component item name | component nav section name | root component name" $title = sprintf(__('%1$s | %2$s | %3$s', 'buddypress'), $bp->bp_options_title, $bp->bp_options_nav[bp_current_item()][bp_current_action()]['name'], bp_get_name_from_root_slug(bp_get_root_slug())); // An index or directory } elseif (bp_is_directory()) { if (!bp_current_component()) { $title = sprintf(__('%s Directory', 'buddypress'), bp_get_name_from_root_slug()); } else { $title = sprintf(__('%s Directory', 'buddypress'), bp_get_name_from_root_slug()); } // Sign up page } elseif (bp_is_register_page()) { $title = __('Create an Account', 'buddypress'); // Activation page } elseif (bp_is_activation_page()) { $title = __('Activate your Account', 'buddypress'); // Group creation page } elseif (bp_is_group_create()) { $title = __('Create a Group', 'buddypress'); // Blog creation page } elseif (bp_is_create_blog()) { $title = __('Create a Site', 'buddypress'); } // Some BP nav items contain item counts. Remove them $title = preg_replace('|<span>[0-9]+</span>|', '', $title); return apply_filters('bp_modify_page_title', $title . ' ' . $sep . ' ', $title, $sep, $seplocation); }
function bp_get_the_body_class($wp_classes = array(), $custom_classes = false) { $bp_classes = array(); /** Pages *************************************************************/ if (is_front_page()) { $bp_classes[] = 'home-page'; } if (bp_is_directory()) { $bp_classes[] = 'directory'; } if (bp_is_single_item()) { $bp_classes[] = 'single-item'; } /** Components ********************************************************/ if (!bp_is_blog_page()) { if (bp_is_user_profile()) { $bp_classes[] = 'xprofile'; } if (bp_is_activity_component()) { $bp_classes[] = 'activity'; } if (bp_is_blogs_component()) { $bp_classes[] = 'blogs'; } if (bp_is_messages_component()) { $bp_classes[] = 'messages'; } if (bp_is_friends_component()) { $bp_classes[] = 'friends'; } if (bp_is_groups_component()) { $bp_classes[] = 'groups'; } if (bp_is_settings_component()) { $bp_classes[] = 'settings'; } } /** User **************************************************************/ if (bp_is_user()) { $bp_classes[] = 'bp-user'; } if (!bp_is_directory()) { if (bp_is_user_blogs()) { $bp_classes[] = 'my-blogs'; } if (bp_is_user_groups()) { $bp_classes[] = 'my-groups'; } if (bp_is_user_activity()) { $bp_classes[] = 'my-activity'; } } if (bp_is_my_profile()) { $bp_classes[] = 'my-account'; } if (bp_is_user_profile()) { $bp_classes[] = 'my-profile'; } if (bp_is_user_friends()) { $bp_classes[] = 'my-friends'; } if (bp_is_user_messages()) { $bp_classes[] = 'my-messages'; } if (bp_is_user_recent_commments()) { $bp_classes[] = 'recent-comments'; } if (bp_is_user_recent_posts()) { $bp_classes[] = 'recent-posts'; } if (bp_is_user_change_avatar()) { $bp_classes[] = 'change-avatar'; } if (bp_is_user_profile_edit()) { $bp_classes[] = 'profile-edit'; } if (bp_is_user_friends_activity()) { $bp_classes[] = 'friends-activity'; } if (bp_is_user_groups_activity()) { $bp_classes[] = 'groups-activity'; } /** Messages **********************************************************/ if (bp_is_messages_inbox()) { $bp_classes[] = 'inbox'; } if (bp_is_messages_sentbox()) { $bp_classes[] = 'sentbox'; } if (bp_is_messages_compose_screen()) { $bp_classes[] = 'compose'; } if (bp_is_notices()) { $bp_classes[] = 'notices'; } if (bp_is_user_friend_requests()) { $bp_classes[] = 'friend-requests'; } if (bp_is_create_blog()) { $bp_classes[] = 'create-blog'; } /** Groups ************************************************************/ if (bp_is_group()) { $bp_classes[] = 'group-' . groups_get_current_group()->slug; } if (bp_is_group_leave()) { $bp_classes[] = 'leave-group'; } if (bp_is_group_invites()) { $bp_classes[] = 'group-invites'; } if (bp_is_group_members()) { $bp_classes[] = 'group-members'; } if (bp_is_group_forum_topic()) { $bp_classes[] = 'group-forum-topic'; } if (bp_is_group_forum_topic_edit()) { $bp_classes[] = 'group-forum-topic-edit'; } if (bp_is_group_forum()) { $bp_classes[] = 'group-forum'; } if (bp_is_group_admin_page()) { $bp_classes[] = 'group-admin'; $bp_classes[] = bp_get_group_current_admin_tab(); } if (bp_is_group_create()) { $bp_classes[] = 'group-create'; $bp_classes[] = bp_get_groups_current_create_step(); } if (bp_is_group_home()) { $bp_classes[] = 'group-home'; } if (bp_is_single_activity()) { $bp_classes[] = 'activity-permalink'; } /** Registration ******************************************************/ if (bp_is_register_page()) { $bp_classes[] = 'registration'; } if (bp_is_activation_page()) { $bp_classes[] = 'activation'; } /** Current Component & Action ****************************************/ if (!bp_is_blog_page()) { $bp_classes[] = bp_current_component(); $bp_classes[] = bp_current_action(); } /** Clean up ***********************************************************/ // Add BuddyPress class if we are within a BuddyPress page if (!bp_is_blog_page()) { $bp_classes[] = 'buddypress'; } // Merge WP classes with BuddyPress classes and remove any duplicates $classes = array_unique(array_merge((array) $bp_classes, (array) $wp_classes)); return apply_filters('bp_get_the_body_class', $classes, $bp_classes, $wp_classes, $custom_classes); }
function bp_get_the_body_class($nxt_classes, $custom_classes = false) { $bp_classes = array(); /** Pages *************************************************************/ if (is_front_page()) { $bp_classes[] = 'home-page'; } if (bp_is_directory()) { $bp_classes[] = 'directory'; } if (bp_is_single_item()) { $bp_classes[] = 'single-item'; } /** Components ********************************************************/ if (!bp_is_blog_page()) { if (bp_is_user_profile()) { $bp_classes[] = 'xprofile'; } if (bp_is_activity_component()) { $bp_classes[] = 'activity'; } if (bp_is_blogs_component()) { $bp_classes[] = 'blogs'; } if (bp_is_messages_component()) { $bp_classes[] = 'messages'; } if (bp_is_friends_component()) { $bp_classes[] = 'friends'; } if (bp_is_groups_component()) { $bp_classes[] = 'groups'; } if (bp_is_settings_component()) { $bp_classes[] = 'settings'; } } /** User **************************************************************/ if (!bp_is_directory()) { if (bp_is_user_blogs()) { $bp_classes[] = 'my-blogs'; } if (bp_is_user_groups()) { $bp_classes[] = 'my-groups'; } if (bp_is_user_activity()) { $bp_classes[] = 'my-activity'; } } if (bp_is_my_profile()) { $bp_classes[] = 'my-account'; } if (bp_is_user_profile()) { $bp_classes[] = 'my-profile'; } if (bp_is_user_friends()) { $bp_classes[] = 'my-friends'; } if (bp_is_user_messages()) { $bp_classes[] = 'my-messages'; } if (bp_is_user_recent_commments()) { $bp_classes[] = 'recent-comments'; } if (bp_is_user_recent_posts()) { $bp_classes[] = 'recent-posts'; } if (bp_is_user_change_avatar()) { $bp_classes[] = 'change-avatar'; } if (bp_is_user_profile_edit()) { $bp_classes[] = 'profile-edit'; } if (bp_is_user_friends_activity()) { $bp_classes[] = 'friends-activity'; } if (bp_is_user_groups_activity()) { $bp_classes[] = 'groups-activity'; } if (is_user_logged_in()) { $bp_classes[] = 'logged-in'; } /** Messages **********************************************************/ if (bp_is_messages_inbox()) { $bp_classes[] = 'inbox'; } if (bp_is_messages_sentbox()) { $bp_classes[] = 'sentbox'; } if (bp_is_messages_compose_screen()) { $bp_classes[] = 'compose'; } if (bp_is_notices()) { $bp_classes[] = 'notices'; } if (bp_is_user_friend_requests()) { $bp_classes[] = 'friend-requests'; } if (bp_is_create_blog()) { $bp_classes[] = 'create-blog'; } /** Groups ************************************************************/ if (bp_is_group_leave()) { $bp_classes[] = 'leave-group'; } if (bp_is_group_invites()) { $bp_classes[] = 'group-invites'; } if (bp_is_group_members()) { $bp_classes[] = 'group-members'; } if (bp_is_group_forum_topic()) { $bp_classes[] = 'group-forum-topic'; } if (bp_is_group_forum_topic_edit()) { $bp_classes[] = 'group-forum-topic-edit'; } if (bp_is_group_forum()) { $bp_classes[] = 'group-forum'; } if (bp_is_group_admin_page()) { $bp_classes[] = 'group-admin'; } if (bp_is_group_create()) { $bp_classes[] = 'group-create'; } if (bp_is_group_home()) { $bp_classes[] = 'group-home'; } if (bp_is_single_activity()) { $bp_classes[] = 'activity-permalink'; } /** Registration ******************************************************/ if (bp_is_register_page()) { $bp_classes[] = 'registration'; } if (bp_is_activation_page()) { $bp_classes[] = 'activation'; } /** Current Component & Action ****************************************/ if (!bp_is_blog_page()) { $bp_classes[] = bp_current_component(); $bp_classes[] = bp_current_action(); } /** Clean up***********************************************************/ // We don't want NXTClass blog classes to appear on non-blog pages. if (!bp_is_blog_page()) { // Preserve any custom classes already set if (!empty($custom_classes)) { $nxt_classes = (array) $custom_classes; } else { $nxt_classes = array(); } } // Merge nxt classes with BP classes $classes = array_merge((array) $bp_classes, (array) $nxt_classes); // Remove any duplicates $classes = array_unique($classes); return apply_filters('bp_get_the_body_class', $classes, $bp_classes, $nxt_classes, $custom_classes); }
/** * Check the current user's capability to edit an avatar for a given object. * * @since 2.3.0 * * @param string $capability The capability to check. * @param array $args An array containing the item_id and the object to check. * * @return bool */ function bp_attachments_current_user_can($capability, $args = array()) { $can = false; if ('edit_avatar' === $capability) { /** * Needed avatar arguments are set. */ if (isset($args['item_id']) && isset($args['object'])) { // Group profile photo if (bp_is_active('groups') && 'group' === $args['object']) { if (bp_is_group_create()) { $can = (bool) groups_is_user_creator(bp_loggedin_user_id(), $args['item_id']) || bp_current_user_can('bp_moderate'); } else { $can = (bool) groups_is_user_admin(bp_loggedin_user_id(), $args['item_id']) || bp_current_user_can('bp_moderate'); } // User profile photo } elseif (bp_is_active('xprofile') && 'user' === $args['object']) { $can = bp_loggedin_user_id() === (int) $args['item_id'] || bp_current_user_can('bp_moderate'); } /** * No avatar arguments, fallback to bp_user_can_create_groups() * or bp_is_item_admin() */ } else { if (bp_is_group_create()) { $can = bp_user_can_create_groups(); } else { $can = bp_is_item_admin(); } } } return apply_filters('bp_attachments_current_user_can', $can, $capability, $args); }
/** * Set the directory when uploading a file * * @since 2.4.0 * * @param array $upload_dir The original Uploads dir. * @return array upload data (path, url, basedir...) */ public function upload_dir_filter($upload_dir = array()) { // Default values are for profiles $object_id = bp_displayed_user_id(); if (empty($object_id)) { $object_id = bp_loggedin_user_id(); } $object_directory = 'members'; // We're in a group, edit default values if (bp_is_group() || bp_is_group_create()) { $object_id = bp_get_current_group_id(); $object_directory = 'groups'; } // Set the subdir $subdir = '/' . $object_directory . '/' . $object_id . '/cover-image'; /** * Filters the cover image upload directory. * * @since 2.4.0 * * @param array $value Array containing the path, URL, and other helpful settings. * @param array $upload_dir The original Uploads dir. */ return apply_filters('bp_attachments_cover_image_upload_dir', array('path' => $this->upload_path . $subdir, 'url' => $this->url . $subdir, 'subdir' => $subdir, 'basedir' => $this->upload_path, 'baseurl' => $this->url, 'error' => false), $upload_dir); }
function invite_anyone_group_invite_access_test() { global $current_user, $bp; if (!is_user_logged_in() || empty($bp->groups->current_group)) { return 'noone'; } if (!($iaoptions = get_option('invite_anyone'))) { $iaoptions = array(); } if (bp_is_group_create()) { if (empty($iaoptions['group_invites_can_group_admin']) || $iaoptions['group_invites_can_group_admin'] == 'anyone' || !$iaoptions['group_invites_can_group_admin']) { return 'anyone'; } if ($iaoptions['group_invites_can_group_admin'] == 'friends') { return 'friends'; } if ($iaoptions['group_invites_can_group_admin'] == 'noone') { return 'noone'; } } if (!groups_is_user_member($bp->loggedin_user->id, $bp->groups->current_group->id)) { return 'noone'; } if (is_super_admin()) { if (empty($iaoptions['group_invites_can_admin']) || $iaoptions['group_invites_can_admin'] == 'anyone' || !$iaoptions['group_invites_can_admin']) { return 'anyone'; } if ($iaoptions['group_invites_can_admin'] == 'friends') { return 'friends'; } if ($iaoptions['group_invites_can_admin'] == 'noone') { return 'noone'; } } else { if (bp_group_is_admin() || bp_is_group_create()) { if (empty($iaoptions['group_invites_can_group_admin']) || $iaoptions['group_invites_can_group_admin'] == 'anyone' || !$iaoptions['group_invites_can_group_admin']) { return 'anyone'; } if ($iaoptions['group_invites_can_group_admin'] == 'friends') { return 'friends'; } if ($iaoptions['group_invites_can_group_admin'] == 'noone') { return 'noone'; } } else { if (bp_group_is_mod()) { if (empty($iaoptions['group_invites_can_group_mod']) || $iaoptions['group_invites_can_group_mod'] == 'anyone' || !$iaoptions['group_invites_can_group_mod']) { return 'anyone'; } if ($iaoptions['group_invites_can_group_mod'] == 'friends') { return 'friends'; } if ($iaoptions['group_invites_can_group_mod'] == 'noone') { return 'noone'; } } else { if (empty($iaoptions['group_invites_can_group_member']) || $iaoptions['group_invites_can_group_member'] == 'anyone' || !$iaoptions['group_invites_can_group_member']) { return 'anyone'; } if ($iaoptions['group_invites_can_group_member'] == 'friends') { return 'friends'; } if ($iaoptions['group_invites_can_group_member'] == 'noone') { return 'noone'; } } } } return 'noone'; }
/** * Filter the page title for BuddyPress pages. * * @since BuddyPress (1.5.0) * * @see wp_title() * @global object $bp BuddyPress global settings. * * @param string $title Original page title. * @param string $sep How to separate the various items within the page title. * @param string $seplocation Direction to display title. * @return string New page title. */ function bp_modify_page_title( $title, $sep = '', $seplocation = '' ) { global $bp; // If this is not a BP page, just return the title produced by WP if ( bp_is_blog_page() ) { return $title; } // If this is a 404, let WordPress handle it if ( is_404() ) { return $title; } // If this is the front page of the site, return WP's title if ( is_front_page() || is_home() ) { return $title; } $title = ''; // Displayed user if ( bp_get_displayed_user_fullname() && ! is_404() ) { // Get the component's ID to try and get its name $component_id = $component_name = bp_current_component(); // Use the component nav name if ( ! empty( $bp->bp_nav[$component_id] ) ) { // Remove counts that are added by the nav item $span = strpos( $bp->bp_nav[ $component_id ]['name'], '<span' ); if ( false !== $span ) { $component_name = substr( $bp->bp_nav[ $component_id ]['name'], 0, $span - 1 ); } else { $component_name = $bp->bp_nav[ $component_id ]['name']; } // Fall back on the component ID } elseif ( ! empty( $bp->{$component_id}->id ) ) { $component_name = ucwords( $bp->{$component_id}->id ); } // Append action name if we're on a member component sub-page if ( ! empty( $bp->bp_options_nav[ $component_id ] ) && ! empty( $bp->canonical_stack['action'] ) ) { $component_subnav_name = wp_filter_object_list( $bp->bp_options_nav[ $component_id ], array( 'slug' => bp_current_action() ), 'and', 'name' ); if ( $component_subnav_name ) { $component_subnav_name = array_shift( $component_subnav_name ); } else { $component_subnav_name = ''; } } else { $component_subnav_name = ''; } // If on the user profile's landing page, just use the fullname if ( bp_is_current_component( $bp->default_component ) && bp_get_requested_url() === bp_displayed_user_domain() ) { $title = bp_get_displayed_user_fullname(); // Use component name on member pages } else { // If we have a subnav name, add it separately for localization if ( ! empty( $component_subnav_name ) ) { // translators: construct the page title. 1 = user name, 2 = component name, 3 = separator, 4 = component subnav name $title = strip_tags( sprintf( __( '%1$s %3$s %2$s %3$s %4$s', 'buddypress' ), bp_get_displayed_user_fullname(), $component_name, $sep, $component_subnav_name ) ); } else { // translators: construct the page title. 1 = user name, 2 = component name, 3 = separator $title = strip_tags( sprintf( __( '%1$s %3$s %2$s', 'buddypress' ), bp_get_displayed_user_fullname(), $component_name, $sep ) ); } } // A single group } elseif ( bp_is_active( 'groups' ) && ! empty( $bp->groups->current_group ) && ! empty( $bp->bp_options_nav[ $bp->groups->current_group->slug ] ) ) { $subnav = isset( $bp->bp_options_nav[ $bp->groups->current_group->slug ][ bp_current_action() ]['name'] ) ? $bp->bp_options_nav[ $bp->groups->current_group->slug ][ bp_current_action() ]['name'] : ''; // translators: 1 = group name, 2 = group nav section name, 3 = separator $title = sprintf( __( '%1$s %3$s %2$s', 'buddypress' ), $bp->bp_options_title, $subnav, $sep ); // A single item from a component other than groups } elseif ( bp_is_single_item() ) { // translators: 1 = component item name, 2 = component nav section name, 3 = separator $title = sprintf( __( '%1$s %3$s %2$s', 'buddypress' ), $bp->bp_options_title, $bp->bp_options_nav[ bp_current_item() ][ bp_current_action() ]['name'], $sep ); // An index or directory } elseif ( bp_is_directory() ) { $current_component = bp_current_component(); // No current component (when does this happen?) if ( empty( $current_component ) ) { $title = _x( 'Directory', 'component directory title', 'buddypress' ); } else { $title = bp_get_directory_title( $current_component ); } // Sign up page } elseif ( bp_is_register_page() ) { $title = __( 'Create an Account', 'buddypress' ); // Activation page } elseif ( bp_is_activation_page() ) { $title = __( 'Activate your Account', 'buddypress' ); // Group creation page } elseif ( bp_is_group_create() ) { $title = __( 'Create a Group', 'buddypress' ); // Blog creation page } elseif ( bp_is_create_blog() ) { $title = __( 'Create a Site', 'buddypress' ); } // Some BP nav items contain item counts. Remove them $title = preg_replace( '|<span>[0-9]+</span>|', '', $title ); return apply_filters( 'bp_modify_page_title', $title . ' ' . $sep . ' ', $title, $sep, $seplocation ); }
/** * */ function miss_is_bp() { if (function_exists('bp_is_group') && (bp_is_blog_page() || bp_is_my_profile() || bp_is_my_profile() || is_front_page() || bp_is_component_front_page('activity') || bp_is_directory() || bp_is_profile_component() || bp_is_activity_component() || bp_is_blogs_component() || bp_is_messages_component() || bp_is_friends_component() || bp_is_groups_component() || bp_is_settings_component() || bp_is_user_activity() || bp_is_user_friends_activity() || bp_is_activity_permalink() || bp_is_user_profile() || bp_is_profile_edit() || bp_is_change_avatar() || bp_is_user_groups() || bp_is_group() || bp_is_group_home() || bp_is_group_create() || bp_is_group_admin_page() || bp_is_group_forum() || bp_is_group_activity() || bp_is_group_forum_topic() || bp_is_group_forum_topic_edit() || bp_is_group_members() || bp_is_group_invites() || bp_is_group_membership_request() || bp_is_group_leave() || bp_is_group_single() || bp_is_user_blogs() || bp_is_user_recent_posts() || bp_is_user_recent_commments() || bp_is_create_blog() || bp_is_user_friends() || bp_is_friend_requests() || bp_is_user_messages() || bp_is_messages_inbox() || bp_is_messages_sentbox() || bp_is_notices() || bp_is_messages_compose_screen() || bp_is_activation_page() || bp_is_register_page())) { return true; } return false; }
/* Add custom HTML to BP page bottom set from Page options */ add_action('kleo_after_main_content', 'kleo_bp_bottom', 12); /* Custom menu page option */ add_filter('wp_nav_menu_args', 'kleo_bp_set_custom_menu'); get_header(); ?> <?php //remove title in main content area since it is handled by Buddypress setting in Theme options - Buddypress remove_action('kleo_before_main_content', 'kleo_title_main_content'); $title_arr = array(); if (in_array(sq_option('bp_title_location', 'breadcrumb'), array('disabled', 'main')) || sq_option('bp_title_location', 'breadcrumb') == 'default' && sq_option('title_location', 'breadcrumb') == 'main') { $title_arr['show_title'] = false; } $title = get_the_title(); if (bp_is_group_create()) { $title = preg_replace("/<a\\b[^>]*>(.*?)<\\/a>/i", "", $title); } $title_arr['title'] = $title; if (sq_option('bp_breadcrumb_status', 1) == 0) { $title_arr['show_breadcrumb'] = false; } if (sq_option('bp_custom_info', 0) == 1) { $extra_info = sq_option('bp_title_info', ''); } else { $extra_info = sq_option('title_info', ''); } if ($extra_info == '') { $title_arr['extra'] = ''; } else { $title_arr['extra'] = '<p class="page-info">' . $extra_info . '</p>';
function check_if_create_group_limit() { global $bp; $create_limit_enable = get_option('tn_wpmu_create_group_status'); $create_limit_redirect = get_option('tn_wpmu_create_group_redirect'); if ($create_limit_enable == "yes") { if (bp_is_group_create()) { if (current_user_can('delete_others_posts')) { //only admins and editors } else { if ($create_limit_redirect == '') { bp_core_redirect($bp->root_domain . '/'); } else { bp_core_redirect($create_limit_redirect); } } } } //off }
/** * Determine access setting for a group/user pair. * * @param int $group_id Group ID. Default: current group ID. * @param int $user_id User ID. Default: current user ID. */ function invite_anyone_group_invite_access_test($group_id = 0, $user_id = 0) { global $current_user, $bp; if (empty($group_id)) { $group_id = bp_is_group() ? bp_get_current_group_id() : 0; } if (empty($group_id) && !bp_is_group_create()) { return 'noone'; } if (empty($user_id)) { $user_id = bp_loggedin_user_id(); } if (empty($user_id)) { return 'noone'; } $iaoptions = invite_anyone_options(); if (bp_is_group_create()) { if (empty($iaoptions['group_invites_can_group_admin']) || $iaoptions['group_invites_can_group_admin'] == 'anyone' || !$iaoptions['group_invites_can_group_admin']) { return 'anyone'; } if ($iaoptions['group_invites_can_group_admin'] == 'friends') { return 'friends'; } if ($iaoptions['group_invites_can_group_admin'] == 'noone') { return 'noone'; } } if (!groups_is_user_member($user_id, $group_id)) { return 'noone'; } if (user_can($user_id, 'bp_moderate')) { if (empty($iaoptions['group_invites_can_admin']) || $iaoptions['group_invites_can_admin'] == 'anyone' || !$iaoptions['group_invites_can_admin']) { return 'anyone'; } if ($iaoptions['group_invites_can_admin'] == 'friends') { return 'friends'; } if ($iaoptions['group_invites_can_admin'] == 'noone') { return 'noone'; } } else { if (groups_is_user_admin($user_id, $group_id)) { if (empty($iaoptions['group_invites_can_group_admin']) || $iaoptions['group_invites_can_group_admin'] == 'anyone' || !$iaoptions['group_invites_can_group_admin']) { return 'anyone'; } if ($iaoptions['group_invites_can_group_admin'] == 'friends') { return 'friends'; } if ($iaoptions['group_invites_can_group_admin'] == 'noone') { return 'noone'; } } else { if (groups_is_user_mod($user_id, $group_id)) { if (empty($iaoptions['group_invites_can_group_mod']) || $iaoptions['group_invites_can_group_mod'] == 'anyone' || !$iaoptions['group_invites_can_group_mod']) { return 'anyone'; } if ($iaoptions['group_invites_can_group_mod'] == 'friends') { return 'friends'; } if ($iaoptions['group_invites_can_group_mod'] == 'noone') { return 'noone'; } } else { if (empty($iaoptions['group_invites_can_group_member']) || $iaoptions['group_invites_can_group_member'] == 'anyone' || !$iaoptions['group_invites_can_group_member']) { return 'anyone'; } if ($iaoptions['group_invites_can_group_member'] == 'friends') { return 'friends'; } if ($iaoptions['group_invites_can_group_member'] == 'noone') { return 'noone'; } } } } return 'noone'; }
/** * Filter the page title for BuddyPress pages. * * @since 1.5.0 * * @see wp_title() * @global object $bp BuddyPress global settings. * * @param string $title Original page title. * @param string $sep How to separate the various items within the page title. * @param string $seplocation Direction to display title. * @return string New page title. */ function bp_modify_page_title($title = '', $sep = '»', $seplocation = 'right') { global $bp, $paged, $page, $_wp_theme_features; // If this is not a BP page, just return the title produced by WP. if (bp_is_blog_page()) { return $title; } // If this is a 404, let WordPress handle it. if (is_404()) { return $title; } // If this is the front page of the site, return WP's title. if (is_front_page() || is_home()) { return $title; } // Return WP's title if not a BuddyPress page. if (!is_buddypress()) { return $title; } // Setup an empty title parts array. $title_parts = array(); // Is there a displayed user, and do they have a name? $displayed_user_name = bp_get_displayed_user_fullname(); // Displayed user. if (!empty($displayed_user_name) && !is_404()) { // Get the component's ID to try and get its name. $component_id = $component_name = bp_current_component(); // Set empty subnav name. $component_subnav_name = ''; // Use the component nav name. if (!empty($bp->bp_nav[$component_id])) { $component_name = _bp_strip_spans_from_title($bp->bp_nav[$component_id]['name']); // Fall back on the component ID. } elseif (!empty($bp->{$component_id}->id)) { $component_name = ucwords($bp->{$component_id}->id); } // Append action name if we're on a member component sub-page. if (!empty($bp->bp_options_nav[$component_id]) && !empty($bp->canonical_stack['action'])) { $component_subnav_name = wp_filter_object_list($bp->bp_options_nav[$component_id], array('slug' => bp_current_action()), 'and', 'name'); if (!empty($component_subnav_name)) { $component_subnav_name = array_shift($component_subnav_name); } } // If on the user profile's landing page, just use the fullname. if (bp_is_current_component($bp->default_component) && bp_get_requested_url() === bp_displayed_user_domain()) { $title_parts[] = $displayed_user_name; // Use component name on member pages. } else { $title_parts = array_merge($title_parts, array_map('strip_tags', array($displayed_user_name, $component_name))); // If we have a subnav name, add it separately for localization. if (!empty($component_subnav_name)) { $title_parts[] = strip_tags($component_subnav_name); } } // A single group. } elseif (bp_is_active('groups') && !empty($bp->groups->current_group) && !empty($bp->bp_options_nav[$bp->groups->current_group->slug])) { $subnav = isset($bp->bp_options_nav[$bp->groups->current_group->slug][bp_current_action()]['name']) ? $bp->bp_options_nav[$bp->groups->current_group->slug][bp_current_action()]['name'] : ''; $title_parts = array($bp->bp_options_title, $subnav); // A single item from a component other than groups. } elseif (bp_is_single_item()) { $title_parts = array($bp->bp_options_title, $bp->bp_options_nav[bp_current_item()][bp_current_action()]['name']); // An index or directory. } elseif (bp_is_directory()) { $current_component = bp_current_component(); // No current component (when does this happen?). $title_parts = array(_x('Directory', 'component directory title', 'buddypress')); if (!empty($current_component)) { $title_parts = array(bp_get_directory_title($current_component)); } // Sign up page. } elseif (bp_is_register_page()) { $title_parts = array(__('Create an Account', 'buddypress')); // Activation page. } elseif (bp_is_activation_page()) { $title_parts = array(__('Activate Your Account', 'buddypress')); // Group creation page. } elseif (bp_is_group_create()) { $title_parts = array(__('Create a Group', 'buddypress')); // Blog creation page. } elseif (bp_is_create_blog()) { $title_parts = array(__('Create a Site', 'buddypress')); } // Strip spans. $title_parts = array_map('_bp_strip_spans_from_title', $title_parts); // Sep on right, so reverse the order. if ('right' == $seplocation) { $title_parts = array_reverse($title_parts); } // Get the blog name, so we can check if the original $title included it. $blogname = get_bloginfo('name', 'display'); /** * Are we going to fake 'title-tag' theme functionality? * * @link https://buddypress.trac.wordpress.org/ticket/6107 * @see wp_title() */ $title_tag_compatibility = (bool) (!empty($_wp_theme_features['title-tag']) || strstr($title, $blogname)); // Append the site title to title parts if theme supports title tag. if (true === $title_tag_compatibility) { $title_parts[] = $blogname; if (($paged >= 2 || $page >= 2) && !is_404()) { $title_parts[] = sprintf(__('Page %s', 'buddypress'), max($paged, $page)); } } // Pad the separator with 1 space on each side. $prefix = str_pad($sep, strlen($sep) + 2, ' ', STR_PAD_BOTH); // Join the parts together. $new_title = join($prefix, array_filter($title_parts)); // Append the prefix for pre `title-tag` compatibility. if (false === $title_tag_compatibility) { $new_title = $new_title . $prefix; } /** * Filters the page title for BuddyPress pages. * * @since 1.5.0 * * @param string $new_title The BuddyPress page title. * @param string $title The original WordPress page title. * @param string $sep The title parts separator. * @param string $seplocation Location of the separator (left or right). */ return apply_filters('bp_modify_page_title', $new_title, $title, $sep, $seplocation); }
<?php do_action('bp_before_group_send_invites_content'); ?> <?php } } } else { // Begin BP 1.2 code ?> <?php do_action('bp_before_group_send_invites_content'); ?> <?php if (invite_anyone_access_test() && !bp_is_group_create()) { ?> <p><?php _e('Want to invite someone to the group who is not yet a member of the site?', 'bp-invite-anyone'); ?> <a href="<?php echo bp_loggedin_user_domain() . BP_INVITE_ANYONE_SLUG . '/invite-new-members/group-invites/' . bp_get_group_id(); ?> "><?php _e('Send invitations by email.', 'bp-invite-anyone'); ?> </a></p> <?php } ?>
function wff_add_groups_intro() { if (!bp_is_user() && bp_is_current_component('groups') && !bp_is_group() && !bp_is_group_create()) { $group_intro = get_theme_mod('wf_plus_buddypress_groups_intro', 'default'); ?> <div id="item-meta" class="directory-intro margin-bottom-full margin-top-full"> <?php if ($group_intro == 'default') { ?> <?php _e(' This is your Group Introduction text. Use this space to tell your members something about the groups displayed below! You can edit this text via the WordPress customizer.', 'wefoster'); ?> <?php } else { echo wp_kses($group_intro, array('br' => array(), 'em' => array(), 'strong' => array(), 'a' => array('href' => true, 'rel' => true, 'rev' => true, 'name' => true, 'target' => true))); ?> <?php } ?> </div> <?php } ?> <?php }