/** * Set up the constants we need for avatar support. */ function bp_core_set_avatar_constants() { $bp = buddypress(); if (!defined('BP_AVATAR_THUMB_WIDTH')) { define('BP_AVATAR_THUMB_WIDTH', 100); } if (!defined('BP_AVATAR_THUMB_HEIGHT')) { define('BP_AVATAR_THUMB_HEIGHT', 100); } if (!defined('BP_AVATAR_FULL_WIDTH')) { define('BP_AVATAR_FULL_WIDTH', 150); } if (!defined('BP_AVATAR_FULL_HEIGHT')) { define('BP_AVATAR_FULL_HEIGHT', 150); } if (!defined('BP_AVATAR_ORIGINAL_MAX_WIDTH')) { define('BP_AVATAR_ORIGINAL_MAX_WIDTH', 450); } if (!defined('BP_AVATAR_ORIGINAL_MAX_FILESIZE')) { define('BP_AVATAR_ORIGINAL_MAX_FILESIZE', bp_attachments_get_max_upload_file_size('avatar')); } if (!defined('BP_SHOW_AVATARS')) { define('BP_SHOW_AVATARS', bp_get_option('show_avatars')); } }
/** * Initializes the class when called upon. */ public function init() { /** Settings *****************************************************/ $this->settings = bp_get_option('bp-rbe'); /** Includes *****************************************************/ $this->includes(); /** Constants ****************************************************/ $this->constants(); /** Localization *************************************************/ // we place this here instead of in hooks() because we want to // localize even before our requirements are fulfilled $this->localization(); /** Requirements check *******************************************/ // If requirements are not fulfilled, then throw an admin notice and stop now! if (!bp_rbe_is_required_completed($this->settings)) { add_action('admin_notices', array(&$this, 'admin_notice')); return; } /** Post-requirements routine ************************************/ // load inbound provider if (bp_rbe_is_inbound()) { $this->load_inbound_provider(); } // load the hooks! $this->hooks(); }
private function bootstrap() { global $bp; /** * At this point in the stack, BuddyPress core has been loaded but * individual components (friends/activity/groups/etc...) have not. * * The 'bp_core_loaded' action lets you execute code ahead of the * other components. */ do_action('bp_core_loaded'); /** Components ********************************************************/ // Set the included and optional components. $bp->optional_components = apply_filters('bp_optional_components', array('activity', 'blogs', 'forums', 'friends', 'groups', 'messages', 'settings', 'xprofile')); // Set the required components $bp->required_components = apply_filters('bp_required_components', array('members')); // Get a list of activated components if ($active_components = bp_get_option('bp-active-components')) { $bp->active_components = apply_filters('bp_active_components', $active_components); $bp->deactivated_components = apply_filters('bp_deactivated_components', array_values(array_diff(array_values(array_merge($bp->optional_components, $bp->required_components)), array_keys($bp->active_components)))); // Pre 1.5 Backwards compatibility } elseif ($deactivated_components = bp_get_option('bp-deactivated-components')) { // Trim off namespace and filename foreach ((array) $deactivated_components as $component => $value) { $trimmed[] = str_replace('.php', '', str_replace('bp-', '', $component)); } // Set globals $bp->deactivated_components = apply_filters('bp_deactivated_components', $trimmed); // Setup the active components $active_components = array_flip(array_diff(array_values(array_merge($bp->optional_components, $bp->required_components)), array_values($bp->deactivated_components))); // Loop through active components and set the values $bp->active_components = array_map('__return_true', $active_components); // Set the active component global $bp->active_components = apply_filters('bp_active_components', $bp->active_components); // Default to all components active } else { // Set globals $bp->deactivated_components = array(); // Setup the active components $active_components = array_flip(array_values(array_merge($bp->optional_components, $bp->required_components))); // Loop through active components and set the values $bp->active_components = array_map('__return_true', $active_components); // Set the active component global $bp->active_components = apply_filters('bp_active_components', $bp->active_components); } // Loop through optional components foreach ($bp->optional_components as $component) { if (bp_is_active($component) && file_exists(BP_PLUGIN_DIR . '/bp-' . $component . '/bp-' . $component . '-loader.php')) { include BP_PLUGIN_DIR . '/bp-' . $component . '/bp-' . $component . '-loader.php'; } } // Loop through required components foreach ($bp->required_components as $component) { if (file_exists(BP_PLUGIN_DIR . '/bp-' . $component . '/bp-' . $component . '-loader.php')) { include BP_PLUGIN_DIR . '/bp-' . $component . '/bp-' . $component . '-loader.php'; } } // Add Core to required components $bp->required_components[] = 'core'; }
/** * @group invite_anyone_group_invite_access_test * * Using this as a proxy for testing every possible combination */ public function test_group_access_test_friends() { $settings = bp_get_option('invite_anyone'); bp_update_option('invite_anyone', array('group_invites_can_admin' => 'friends', 'group_invites_can_group_admin' => 'friends', 'group_invites_can_group_mod' => 'friends', 'group_invites_can_group_member' => 'friends')); unset($GLOBALS['iaoptions']); $g = $this->factory->group->create(); $u1 = $this->factory->user->create(array('role' => 'administrator')); $this->add_user_to_group($u1, $g); $u2 = $this->factory->user->create(); $this->add_user_to_group($u2, $g); $u3 = $this->factory->user->create(); $this->add_user_to_group($u3, $g); $m3 = new BP_Groups_Member($u3, $g); $m3->promote('mod'); $u4 = $this->factory->user->create(); $this->add_user_to_group($u4, $g); $m4 = new BP_Groups_Member($u4, $g); $m4->promote('admin'); $user = new WP_User($u1); $this->assertSame('friends', invite_anyone_group_invite_access_test($g, $u1)); $this->assertSame('friends', invite_anyone_group_invite_access_test($g, $u2)); $this->assertSame('friends', invite_anyone_group_invite_access_test($g, $u3)); $this->assertSame('friends', invite_anyone_group_invite_access_test($g, $u4)); bp_update_option('invite_anyone', $settings); }
/** * Include component files. * * @since 1.5.0 * * @see BP_Component::includes() for a description of arguments. * * @param array $includes See BP_Component::includes() for a description. */ public function includes($includes = array()) { // Files to include. $includes = array('cssjs', 'actions', 'screens', 'filters', 'adminbar', 'template', 'functions', 'cache'); // Notifications support. if (bp_is_active('notifications')) { $includes[] = 'notifications'; } if (!buddypress()->do_autoload) { $includes[] = 'classes'; } // Load Akismet support if Akismet is configured. $akismet_key = bp_get_option('wordpress_api_key'); /** This filter is documented in bp-activity/bp-activity-akismet.php */ if (defined('AKISMET_VERSION') && class_exists('Akismet') && (!empty($akismet_key) || defined('WPCOM_API_KEY')) && apply_filters('bp_activity_use_akismet', bp_is_akismet_active())) { $includes[] = 'akismet'; } // Embeds - only applicable for WP 4.5+ if (version_compare($GLOBALS['wp_version'], '4.5', '>=') && bp_is_active($this->id, 'embeds')) { $includes[] = 'embeds'; } if (is_admin()) { $includes[] = 'admin'; } parent::includes($includes); }
/** * Register member types. * * If the field type is set and has options. These options will dynamically build the member type * Use the name to set options into the xProfile Field Admin UI eg: Has CF * * @since 1.0.0 */ function cfbgr_register_member_types() { $saved_option = (int) bp_get_option('cfbgr_xfield_id', 0); if (empty($saved_option)) { return; } $field = xprofile_get_field($saved_option); // This case means the option was not deleted when it oughts to be if (empty($field->type_obj) || !is_a($field->type_obj, 'CF_BG_Member_Type_Field_Type')) { bp_delete_option('cfbgr_xfield_id'); return; } // Object cache this field buddypress()->groups->restrictions->member_type_field = $field; $options = $field->get_children(true); if (!is_array($options)) { return; } foreach ($options as $member_type) { if (empty($member_type->name)) { continue; } bp_register_member_type(sanitize_key($member_type->name), array('labels' => array('name' => $member_type->name))); } }
private function bp_avatar_is_disable() { if (!function_exists('bp-disable-avatar-uploads')) { return get_option('bp-disable-avatar-uploads'); } return bp_get_option('bp-disable-avatar-uploads'); }
function __construct() { global $bp; $this->client_id = bp_get_option('foursquare-client-id'); $this->client_secret = bp_get_option('foursquare-client-secret'); $this->redirect_uri = isset($bp->pages->{BP_CHECKINS_SLUG}->slug) ? site_url($bp->pages->{BP_CHECKINS_SLUG}->slug) : site_url(BP_CHECKINS_SLUG); }
function cfbgr_migrate_xprofile_as_member_types() { global $wpdb; $buddypress = buddypress(); // Description of this tool, displayed to the user $statement = __('Migrating/Resetting xProfile data as member types: %s', 'buddypress-group-restrictions'); // Default to failure text $result = __('No xProfile data needs to be migrated or reset.', 'buddypress-group-restrictions'); // Default to unrepaired $repair = 0; $field = (int) bp_get_option('cfbgr_xfield_id', 0); if (empty($field)) { return array(0, sprintf($statement, $result)); } $member_types = bp_get_member_types(); // Walk through all users on the site $user_ids = $wpdb->get_col("SELECT ID FROM {$wpdb->users}"); foreach ($user_ids as $user_id) { $value = sanitize_key(xprofile_get_field_data($field, $user_id)); // Do we have a matching member type ? if (isset($member_types[$value])) { // Set member types if empty or different if ($value !== bp_get_member_type($user_id)) { bp_set_member_type($user_id, $value); $repair += 1; } } } $result = sprintf(__('%d migrated or reset', 'buddypress-group-restrictions'), $repair); // All done! return array(0, sprintf($statement, $result)); }
function bp_core_set_avatar_constants() { $bp = buddypress(); if (!defined('BP_AVATAR_THUMB_WIDTH')) { define('BP_AVATAR_THUMB_WIDTH', 50); } if (!defined('BP_AVATAR_THUMB_HEIGHT')) { define('BP_AVATAR_THUMB_HEIGHT', 50); } if (!defined('BP_AVATAR_FULL_WIDTH')) { define('BP_AVATAR_FULL_WIDTH', 150); } if (!defined('BP_AVATAR_FULL_HEIGHT')) { define('BP_AVATAR_FULL_HEIGHT', 150); } if (!defined('BP_AVATAR_ORIGINAL_MAX_WIDTH')) { define('BP_AVATAR_ORIGINAL_MAX_WIDTH', 450); } if (!defined('BP_AVATAR_ORIGINAL_MAX_FILESIZE')) { if (!isset($bp->site_options['fileupload_maxk'])) { define('BP_AVATAR_ORIGINAL_MAX_FILESIZE', 5120000); // 5mb } else { define('BP_AVATAR_ORIGINAL_MAX_FILESIZE', $bp->site_options['fileupload_maxk'] * 1024); } } if (!defined('BP_SHOW_AVATARS')) { define('BP_SHOW_AVATARS', bp_get_option('show_avatars')); } }
function bp_core_install_extended_profiles() { global $nxtdb; $charset_collate = bp_core_set_charset(); $bp_prefix = bp_core_get_table_prefix(); // These values should only be updated if they are not already present if (!($base_group_name = bp_get_option('bp-xprofile-base-group-name'))) { bp_update_option('bp-xprofile-base-group-name', _x('Base', 'First XProfile group name', 'buddypress')); } if (!($fullname_field_name = bp_get_option('bp-xprofile-fullname-field-name'))) { bp_update_option('bp-xprofile-fullname-field-name', _x('Name', 'XProfile fullname field name', 'buddypress')); } $sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_groups (\n\t\t\t id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t name varchar(150) NOT NULL,\n\t\t\t description mediumtext NOT NULL,\n\t\t\t group_order bigint(20) NOT NULL DEFAULT '0',\n\t\t\t can_delete tinyint(1) NOT NULL,\n\t\t\t KEY can_delete (can_delete)\n\t\t\t ) {$charset_collate};"; $sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_fields (\n\t\t\t id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t group_id bigint(20) unsigned NOT NULL,\n\t\t\t parent_id bigint(20) unsigned NOT NULL,\n\t\t\t type varchar(150) NOT NULL,\n\t\t\t name varchar(150) NOT NULL,\n\t\t\t description longtext NOT NULL,\n\t\t\t is_required tinyint(1) NOT NULL DEFAULT '0',\n\t\t\t is_default_option tinyint(1) NOT NULL DEFAULT '0',\n\t\t\t field_order bigint(20) NOT NULL DEFAULT '0',\n\t\t\t option_order bigint(20) NOT NULL DEFAULT '0',\n\t\t\t order_by varchar(15) NOT NULL DEFAULT '',\n\t\t\t can_delete tinyint(1) NOT NULL DEFAULT '1',\n\t\t\t KEY group_id (group_id),\n\t\t\t KEY parent_id (parent_id),\n\t\t\t KEY field_order (field_order),\n\t\t\t KEY can_delete (can_delete),\n\t\t\t KEY is_required (is_required)\n\t\t\t ) {$charset_collate};"; $sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_data (\n\t\t\t id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t field_id bigint(20) unsigned NOT NULL,\n\t\t\t user_id bigint(20) unsigned NOT NULL,\n\t\t\t value longtext NOT NULL,\n\t\t\t last_updated datetime NOT NULL,\n\t\t\t KEY field_id (field_id),\n\t\t\t KEY user_id (user_id)\n\t\t\t ) {$charset_collate};"; $sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_meta (\n\t\t\t\tid bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\tobject_id bigint(20) NOT NULL,\n\t\t\t\tobject_type varchar(150) NOT NULL,\n\t\t\t\tmeta_key varchar(255) DEFAULT NULL,\n\t\t\t\tmeta_value longtext DEFAULT NULL,\n\t\t\t\tKEY object_id (object_id),\n\t\t\t\tKEY meta_key (meta_key)\n\t\t \t ) {$charset_collate};"; dbDelta($sql); // Insert the default group and fields $insert_sql = array(); if (!$nxtdb->get_var("SELECT id FROM {$bp_prefix}bp_xprofile_groups WHERE id = 1")) { $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_groups ( name, description, can_delete ) VALUES ( " . $nxtdb->prepare('%s', stripslashes(bp_get_option('bp-xprofile-base-group-name'))) . ", '', 0 );"; } if (!$nxtdb->get_var("SELECT id FROM {$bp_prefix}bp_xprofile_fields WHERE id = 1")) { $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_fields ( group_id, parent_id, type, name, description, is_required, can_delete ) VALUES ( 1, 0, 'textbox', " . $nxtdb->prepare('%s', stripslashes(bp_get_option('bp-xprofile-fullname-field-name'))) . ", '', 1, 0 );"; } dbDelta($insert_sql); }
function invite_anyone_options() { global $iaoptions; // We set our own options cache because of some stupid limitations in the way that page // loads work if (!empty($iaoptions)) { $options = $iaoptions; } else { if (function_exists('bp_update_option')) { $options = bp_get_option('invite_anyone'); } else { $options = get_option('invite_anyone'); } } if (!$options) { $options = array(); } $defaults_array = array('max_invites' => 5, 'allow_email_invitations' => 'all', 'message_is_customizable' => 'yes', 'subject_is_customizable' => 'no', 'can_send_group_invites_email' => 'yes', 'bypass_registration_lock' => 'yes', 'email_visibility_toggle' => 'nolimit', 'email_since_toggle' => 'no', 'days_since' => 0, 'email_role_toggle' => 'no', 'minimum_role' => 'subscriber', 'email_blacklist_toggle' => 'no', 'email_blacklist' => '', 'group_invites_can_admin' => 'anyone', 'group_invites_can_group_admin' => 'anyone', 'group_invites_can_group_mod' => 'anyone', 'group_invites_can_group_member' => 'anyone', 'cloudsponge_enabled' => 'off', 'email_limit_invites_toggle' => 'no', 'limit_invites_per_user' => 10); foreach ($defaults_array as $key => $value) { if (!isset($options[$key])) { $options[$key] = $value; } } $iaoptions = $options; return apply_filters('invite_anyone_options', $options); }
/** * Compare the BuddyPress version to the DB version to determine if updating * * @since BuddyPress (1.6) * * @uses get_option() * @uses bp_get_db_version() To get BuddyPress's database version * @return bool True if update, False if not */ function bp_is_update() { // Current DB version of this site (per site in a multisite network) $current_db = bp_get_option('_bp_db_version'); $current_live = bp_get_db_version(); // Compare versions (cast as int and bool to be safe) $is_update = (bool) ((int) $current_db < (int) $current_live); // Return the product of version comparison return $is_update; }
/** * @todo make independent of BP * * @since 1.1.0 * * @return array */ function bpchat_get_all_options() { $default = array('notification_volume' => 20, 'notification_enabled' => true, 'notification_sound_enabled' => true, 'allow_prefernce_change' => true, 'default_chat_preference' => 'all', 'is_disabled' => false); if (function_exists('bp_get_option')) { $options = bp_get_option('bpchat-settings', $default); } else { $options = get_option('bpchat-settings', $default); } return apply_filters('bpchat_settings', $options); }
/** * Setup settings */ function setup_settings() { // Save a query if we can help it if (!bp_is_user()) { return; } // Pull up the existing values $settings = bp_get_option('bp_smp_settings'); $defaults = array('display' => array('inline'), 'label' => __('Follow me online: ', 'bp-smp')); $this->settings = wp_parse_args($settings, $defaults); }
public function setUp() { if (is_multisite()) { $this->signup_allowed = get_site_option('registration'); update_site_option('registration', 'all'); } else { bp_get_option('users_can_register'); bp_update_option('users_can_register', 1); } parent::setUp(); }
public static function setUpBeforeClass() { /* * WP's test suite wipes out BP's directory page mappings with `_delete_all_posts()`. * We must reestablish them before our tests can be successfully run. */ bp_core_add_page_mappings(bp_get_option('bp-active-components'), 'delete'); // Fake WP mail globals, to avoid errors add_filter('wp_mail', array('BP_UnitTestCase', 'setUp_wp_mail')); add_filter('wp_mail_from', array('BP_UnitTestCase', 'tearDown_wp_mail')); }
/** * Setup our items when a user is in the WP backend. */ public function admin_init() { // grab our settings when we're in the admin area only $this->settings = bp_get_option($this->name); // handles niceties like nonces and form submission register_setting($this->name, $this->name, array($this, 'validate')); // add extra action links for our plugin add_filter('plugin_action_links', array($this, 'add_plugin_action_links'), 10, 2); // include github updater only if CBOX isn't installed // or if CBOX is installed and expert mode is on if (!function_exists('cbox') || function_exists('cbox') && defined('CBOX_OVERRIDE_PLUGINS') && constant('CBOX_OVERRIDE_PLUGINS') === true) { $this->github_updater(); } }
/** * Include component files. * * @since BuddyPress (1.5) * * @see BP_Component::includes() for a description of arguments. * * @param array $includes See BP_Component::includes() for a description. */ public function includes($includes = array()) { // Files to include $includes = array('actions', 'screens', 'filters', 'classes', 'template', 'functions', 'notifications', 'cache'); // Load Akismet support if Akismet is configured $akismet_key = bp_get_option('wordpress_api_key'); if (defined('AKISMET_VERSION') && (!empty($akismet_key) || defined('WPCOM_API_KEY')) && apply_filters('bp_activity_use_akismet', bp_is_akismet_active())) { $includes[] = 'akismet'; } if (is_admin()) { $includes[] = 'admin'; } parent::includes($includes); }
function inject_css() { $group_cover_html_tag = apply_filters('bpcp_group_tag', 'div#item-header'); /* Default cover check */ $default_cover = bp_get_option('bpcp-group-default'); if ($this->group_id > 0 && $default_cover) { ?> <style type="text/css"> body.buddypress.bp-default-cover <?php echo $group_cover_html_tag; ?> { background-image: url("<?php echo $default_cover; ?> "); background-repeat: no-repeat; background-size: cover; background-position: center center; } </style> <?php } $image_url = $this->get_cover(); if (empty($image_url)) { return; } $position = $this->get_cover_position(); ?> <style type="text/css"> body.buddypress.is-user-profile <?php echo $group_cover_html_tag; ?> { background-image: url("<?php echo $image_url; ?> "); background-repeat: no-repeat; background-size: cover; background-position: <?php echo $position; ?> ; } </style> <?php }
/** * Check for flooding. * * Check to make sure that a user is not making too many posts in a short amount * of time. * * @since 1.6.0 * * @uses current_user_can() To check if the current user can throttle. * @uses bp_get_option() To get the throttle time. * @uses get_transient() To get the last posted transient of the ip. * @uses get_user_meta() To get the last posted meta of the user. * * @param int $user_id User id to check for flood. * @return bool True if there is no flooding, false if there is. */ function bp_core_check_for_flood($user_id = 0) { // Option disabled. No flood checks. if (!($throttle_time = bp_get_option('_bp_throttle_time'))) { return true; } // Bail if no user ID passed. if (empty($user_id)) { return false; } $last_posted = get_user_meta($user_id, '_bp_last_posted', true); if (isset($last_posted) && time() < $last_posted + $throttle_time && !current_user_can('throttle')) { return false; } return true; }
/** * Adds the Group Admin top-level menu to group pages * * @package BuddyPress * @since 1.5 * * @todo Add dynamic menu items for group extensions */ function bp_groups_group_admin_menu() { global $nxt_admin_bar, $bp; // Only show if viewing a group if (!bp_is_group()) { return false; } // Only show this menu to group admins and super admins if (!is_super_admin() && !bp_group_is_admin()) { return false; } if ('3.2' == bp_get_major_nxt_version()) { // Group avatar $avatar = bp_core_fetch_avatar(array('object' => 'group', 'type' => 'thumb', 'avatar_dir' => 'group-avatars', 'item_id' => $bp->groups->current_group->id, 'width' => 16, 'height' => 16)); // Unique ID for the 'My Account' menu $bp->group_admin_menu_id = !empty($avatar) ? 'group-admin-with-avatar' : 'group-admin'; // Add the top-level Group Admin button $nxt_admin_bar->add_menu(array('id' => $bp->group_admin_menu_id, 'title' => $avatar . bp_get_current_group_name(), 'href' => bp_get_group_permalink($bp->groups->current_group))); } elseif ('3.3' == bp_get_major_nxt_version()) { // Unique ID for the 'My Account' menu $bp->group_admin_menu_id = 'group-admin'; // Add the top-level Group Admin button $nxt_admin_bar->add_menu(array('id' => $bp->group_admin_menu_id, 'title' => __('Edit Group', 'buddypress'), 'href' => bp_get_group_permalink($bp->groups->current_group))); } // Group Admin > Edit details $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'edit-details', 'title' => __('Edit Details', 'buddypress'), 'href' => bp_get_groups_action_link('admin/edit-details'))); // Group Admin > Group settings $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'group-settings', 'title' => __('Edit Settings', 'buddypress'), 'href' => bp_get_groups_action_link('admin/group-settings'))); // Group Admin > Group avatar if (!(int) bp_get_option('bp-disable-avatar-uploads')) { $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'group-avatar', 'title' => __('Edit Avatar', 'buddypress'), 'href' => bp_get_groups_action_link('admin/group-avatar'))); } // Group Admin > Manage invitations if (bp_is_active('friends')) { $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'manage-invitations', 'title' => __('Manage Invitations', 'buddypress'), 'href' => bp_get_groups_action_link('send-invites'))); } // Group Admin > Manage members $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'manage-members', 'title' => __('Manage Members', 'buddypress'), 'href' => bp_get_groups_action_link('admin/manage-members'))); // Group Admin > Membership Requests if (bp_get_group_status($bp->groups->current_group) == 'private') { $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'membership-requests', 'title' => __('Membership Requests', 'buddypress'), 'href' => bp_get_groups_action_link('admin/membership-requests'))); } // Delete Group $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'delete-group', 'title' => __('Delete Group', 'buddypress'), 'href' => bp_get_groups_action_link('admin/delete-group'))); }
function bp_checkins_init() { global $bp; /* we don't take any risk at all !!! */ if (!bp_is_active('activity')) { return; } require BP_CHECKINS_PLUGIN_DIR . '/includes/bp-checkins-shared.php'; if (!(int) bp_get_option('bp-checkins-disable-activity-checkins') || '' == bp_get_option('bp-checkins-disable-activity-checkins')) { require BP_CHECKINS_PLUGIN_DIR . '/includes/bp-checkins-activity.php'; } if ((int) bp_get_option('bp-checkins-activate-component')) { require BP_CHECKINS_PLUGIN_DIR . '/includes/bp-checkins-component.php'; } if (is_admin()) { require BP_CHECKINS_PLUGIN_DIR . '/includes/bp-checkins-admin.php'; } }
/** * Get an individual setting from RBE's settings array. * * @since 1.0-RC3 * * @param string $setting The setting parameter. * @param array $args { * Misc settings. * @type bool $refetch Whether to refetch RBE's settings. Handy when you * need to ensure the settings are updated. Defaults to false. * } * @return string|bool */ function bp_rbe_get_setting($setting = '', $args = array()) { if (empty($setting) || !is_string($setting)) { return false; } $r = wp_parse_args($args, array('refetch' => false)); global $bp_rbe; // refetches RBE options if (true === $r['refetch']) { // flush cache if necessary if (!wp_using_ext_object_cache()) { wp_cache_flush(); } // refetch option $bp_rbe->settings = bp_get_option('bp-rbe'); } return isset($bp_rbe->settings[$setting]) ? $bp_rbe->settings[$setting] : false; }
/** * Include component files. * * @since 1.5.0 * * @see BP_Component::includes() for a description of arguments. * * @param array $includes See BP_Component::includes() for a description. */ public function includes($includes = array()) { // Files to include. $includes = array('cssjs', 'actions', 'screens', 'filters', 'template', 'functions', 'notifications', 'cache'); if (!buddypress()->do_autoload) { $includes[] = 'classes'; } // Load Akismet support if Akismet is configured. $akismet_key = bp_get_option('wordpress_api_key'); /** This filter is documented in bp-activity/bp-activity-actions.php */ if (defined('AKISMET_VERSION') && class_exists('Akismet') && (!empty($akismet_key) || defined('WPCOM_API_KEY')) && apply_filters('bp_activity_use_akismet', bp_is_akismet_active())) { $includes[] = 'akismet'; } if (is_admin()) { $includes[] = 'admin'; } parent::includes($includes); }
function etivite_bp_activity_hashtags_init() { if (!bp_is_active('activity')) { return; } if (file_exists(dirname(__FILE__) . '/languages/' . get_locale() . '.mo')) { load_textdomain('bp-activity-hashtags', dirname(__FILE__) . '/languages/' . get_locale() . '.mo'); } $data = bp_get_option('etivite_bp_activity_stream_hashtags'); if (empty($data['slug'])) { $data['slug'] = 'hashtag'; } //if you want to change up the /activity/tag/myhashtag if (!defined('BP_ACTIVITY_HASHTAGS_SLUG')) { define('BP_ACTIVITY_HASHTAGS_SLUG', $data['slug']); } require dirname(__FILE__) . '/bp-activity-hashtags.php'; //same set used for atme mentions add_filter('bp_activity_comment_content', 'etivite_bp_activity_hashtags_filter'); add_filter('bp_activity_new_update_content', 'etivite_bp_activity_hashtags_filter'); add_filter('group_forum_topic_text_before_save', 'etivite_bp_activity_hashtags_filter'); add_filter('group_forum_post_text_before_save', 'etivite_bp_activity_hashtags_filter'); add_filter('groups_activity_new_update_content', 'etivite_bp_activity_hashtags_filter'); //what about blog posts in the activity stream if (!empty($data['blogactivity']['enabled'])) { add_filter('bp_blogs_activity_new_post_content', 'etivite_bp_activity_hashtags_filter'); add_filter('bp_blogs_activity_new_comment_content', 'etivite_bp_activity_hashtags_filter'); } //what about general blog posts/comments? if (!empty($data['blogposts']['enabled'])) { add_filter('get_comment_text', 'etivite_bp_activity_hashtags_filter', 9999); add_filter('the_content', 'etivite_bp_activity_hashtags_filter', 9999); } //support edit activity stream plugin add_filter('bp_edit_activity_action_edit_content', 'etivite_bp_activity_hashtags_filter'); //ignore this - if we wanted to filter after - this would be it //but then we can't search by the #hashtag via search_terms (since the trick is the ending </a>) //as the search_term uses LIKE %%term%% so we would match #child #children //add_filter( 'bp_get_activity_content_body', 'etivite_bp_activity_hashtags_filter' ); // Add the component's administration tab under the "BuddyPress" menu for site administrators if (is_admin()) { add_action('init', create_function('', "\n\t\t\trequire ( dirname( __FILE__ ) . '/admin/bp-activity-hashtags-admin.php' );\n\t\t")); } }
public function setUp() { parent::setUp(); /* * WP's test suite wipes out BP's directory page mappings with `_delete_all_posts()`. * We must reestablish them before our tests can be successfully run. */ bp_core_add_page_mappings(bp_get_option('bp-active-components'), 'delete'); $this->factory = new BP_UnitTest_Factory(); // Fixes warnings in multisite functions $_SERVER['REMOTE_ADDR'] = ''; global $wpdb; // Clean up after autocommits. add_action('bp_blogs_recorded_existing_blogs', array($this, 'set_autocommit_flag')); // Make sure Activity actions are reset before each test $this->reset_bp_activity_actions(); // Make sure all Post types activities globals are reset before each test $this->reset_bp_activity_post_types_globals(); }
/** * Handle the Toolbar/BuddyBar business. * * @since BuddyPress (1.2.0) * * @global string $wp_version * @uses bp_get_option() * @uses is_user_logged_in() * @uses bp_use_wp_admin_bar() * @uses show_admin_bar() * @uses add_action() To hook 'bp_adminbar_logo' to 'bp_adminbar_logo'. * @uses add_action() To hook 'bp_adminbar_login_menu' to 'bp_adminbar_menus'. * @uses add_action() To hook 'bp_adminbar_account_menu' to 'bp_adminbar_menus'. * @uses add_action() To hook 'bp_adminbar_thisblog_menu' to 'bp_adminbar_menus'. * @uses add_action() To hook 'bp_adminbar_random_menu' to 'bp_adminbar_menus'. * @uses add_action() To hook 'bp_core_admin_bar' to 'wp_footer'. * @uses add_action() To hook 'bp_core_admin_bar' to 'admin_footer'. */ function bp_core_load_admin_bar() { // Show the Toolbar for logged out users if (!is_user_logged_in() && (int) bp_get_option('hide-loggedout-adminbar') != 1) { show_admin_bar(true); } // Hide the WordPress Toolbar and show the BuddyBar if (!bp_use_wp_admin_bar()) { // Keep the WP Toolbar from loading show_admin_bar(false); // Actions used to build the BP Toolbar add_action('bp_adminbar_logo', 'bp_adminbar_logo'); add_action('bp_adminbar_menus', 'bp_adminbar_login_menu', 2); add_action('bp_adminbar_menus', 'bp_adminbar_account_menu', 4); add_action('bp_adminbar_menus', 'bp_adminbar_thisblog_menu', 6); add_action('bp_adminbar_menus', 'bp_adminbar_random_menu', 100); // Actions used to append BP Toolbar to footer add_action('wp_footer', 'bp_core_admin_bar', 8); add_action('admin_footer', 'bp_core_admin_bar'); } }
function settings_field_auto_embed_callback() { $include_location = bp_get_option('bppp-auto-embed', 'display-profile'); ?> <p> <input name="bppp-auto-embed" type="radio" value="display-profile" <?php checked($include_location, 'display-profile'); ?> /> <label for="bppp-auto-embed"><?php _e('When displaying a profile', 'bppp'); ?> </label> <br/> <input name="bppp-auto-embed" type="radio" value="edit-profile" <?php checked($include_location, 'edit-profile'); ?> /> <label for="bppp-auto-embed"><?php _e('When editing a profile', 'bppp'); ?> </label> <br/> <input name="bppp-auto-embed" type="radio" value="0" <?php checked(empty($include_location)); ?> /> <label for="bppp-auto-embed"><?php _e('No auto embed', 'bppp'); ?> </label> </p> <p class="description"> <?php printf(__('Use function %s to display the profile progression block in your templates.', 'bppp'), '<code>bppp_progression_block()</code>'); ?> </p> <?php }
/** * Handle the Toolbar/BuddyBar business. * * @since BuddyPress (1.2.0) * * @global string $wp_version * @uses bp_get_option() * @uses is_user_logged_in() * @uses bp_use_wp_admin_bar() * @uses show_admin_bar() * @uses add_action() To hook 'bp_adminbar_logo' to 'bp_adminbar_logo'. * @uses add_action() To hook 'bp_adminbar_login_menu' to 'bp_adminbar_menus'. * @uses add_action() To hook 'bp_adminbar_account_menu' to 'bp_adminbar_menus'. * @uses add_action() To hook 'bp_adminbar_thisblog_menu' to 'bp_adminbar_menus'. * @uses add_action() To hook 'bp_adminbar_random_menu' to 'bp_adminbar_menus'. * @uses add_action() To hook 'bp_core_admin_bar' to 'wp_footer'. * @uses add_action() To hook 'bp_core_admin_bar' to 'admin_footer'. */ function bp_core_load_admin_bar() { // Show the Toolbar for logged out users if (!is_user_logged_in() && (int) bp_get_option('hide-loggedout-adminbar') != 1) { show_admin_bar(true); } // Hide the WordPress Toolbar and show the BuddyBar if (!bp_use_wp_admin_bar()) { _doing_it_wrong(__FUNCTION__, __('The BuddyBar is no longer supported. Please migrate to the WordPress toolbar as soon as possible.', 'buddypress'), '2.1.0'); // Keep the WP Toolbar from loading show_admin_bar(false); // Actions used to build the BP Toolbar add_action('bp_adminbar_logo', 'bp_adminbar_logo'); add_action('bp_adminbar_menus', 'bp_adminbar_login_menu', 2); add_action('bp_adminbar_menus', 'bp_adminbar_account_menu', 4); add_action('bp_adminbar_menus', 'bp_adminbar_thisblog_menu', 6); add_action('bp_adminbar_menus', 'bp_adminbar_random_menu', 100); // Actions used to append BP Toolbar to footer add_action('wp_footer', 'bp_core_admin_bar', 8); add_action('admin_footer', 'bp_core_admin_bar'); } }