本文整理汇总了PHP中buddypress函数的典型用法代码示例。如果您正苦于以下问题:PHP buddypress函数的具体用法?PHP buddypress怎么用?PHP buddypress使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了buddypress函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate_captcha_registration_field
/**
* Verify the captcha answer
*
* @since 1.0.3
*
* @return void Adds error element to BP's signup errors object.
*/
public static function validate_captcha_registration_field()
{
if (!isset($_POST['g-recaptcha-response']) || !($validated = self::captcha_verification())) {
buddypress()->signup->errors['failed_recaptcha_verification'] = self::$error_message;
}
do_action('ncr_failed_recaptcha_verification', $validated);
}
示例2: xprofile_add_admin_js
/**
* Enqueue the jQuery libraries for handling drag/drop/sort.
*
* @since 1.5.0
*/
function xprofile_add_admin_js()
{
if (!empty($_GET['page']) && strpos($_GET['page'], 'bp-profile-setup') !== false) {
wp_enqueue_script('jquery-ui-core');
wp_enqueue_script('jquery-ui-tabs');
wp_enqueue_script('jquery-ui-mouse');
wp_enqueue_script('jquery-ui-draggable');
wp_enqueue_script('jquery-ui-droppable');
wp_enqueue_script('jquery-ui-sortable');
$min = bp_core_get_minified_asset_suffix();
wp_enqueue_script('xprofile-admin-js', buddypress()->plugin_url . "bp-xprofile/admin/js/admin{$min}.js", array('jquery', 'jquery-ui-sortable'), bp_get_version());
// Localize strings.
// supports_options_field_types is a dynamic list of field
// types that support options, for use in showing/hiding the
// "please enter options for this field" section.
$strings = array('do_settings_section_field_types' => array(), 'do_autolink' => '');
foreach (bp_xprofile_get_field_types() as $field_type => $field_type_class) {
$field = new $field_type_class();
if ($field->do_settings_section()) {
$strings['do_settings_section_field_types'][] = $field_type;
}
}
// Load 'autolink' setting into JS so that we can provide smart defaults when switching field type.
if (!empty($_GET['field_id'])) {
$field_id = intval($_GET['field_id']);
// Pull the raw data from the DB so we can tell whether the admin has saved a value yet.
$strings['do_autolink'] = bp_xprofile_get_meta($field_id, 'field', 'do_autolink');
}
wp_localize_script('xprofile-admin-js', 'XProfileAdmin', $strings);
}
}
示例3: bp_mute_load_component
/**
* Load the component into the $bp global.
*
* @since 1.0.0
*/
function bp_mute_load_component()
{
if (!bp_is_active('activity')) {
return;
}
buddypress()->mute = new Mute_Component();
}
示例4: test_last_activity_should_bust_activity_with_last_activity_cache
/**
* @ticket BP7237
* @ticket BP6643
* @ticket BP7245
*/
public function test_last_activity_should_bust_activity_with_last_activity_cache()
{
global $wpdb;
$u1 = $this->factory->user->create();
$u2 = $this->factory->user->create();
$time_1 = date('Y-m-d H:i:s', time() - HOUR_IN_SECONDS);
$time_2 = date('Y-m-d H:i:s', time() - HOUR_IN_SECONDS * 2);
bp_update_user_last_activity($u1, $time_1);
bp_update_user_last_activity($u2, $time_2);
$activity_args_a = array('filter' => array('object' => buddypress()->members->id, 'action' => 'last_activity'), 'max' => 1);
$activity_args_b = array('filter' => array('action' => 'new_member'), 'fields' => 'ids');
// Prime bp_activity and bp_activity_with_last_activity caches.
$a1 = bp_activity_get($activity_args_a);
$expected = array($u1, $u2);
$found = array_map('intval', wp_list_pluck($a1['activities'], 'user_id'));
$this->assertSame($expected, $found);
$b1 = bp_activity_get($activity_args_b);
// Bump u2 activity so it should appear first.
$new_time = date('Y-m-d H:i:s', time() - HOUR_IN_SECONDS);
bp_update_user_last_activity($u2, $new_time);
$a2 = bp_activity_get($activity_args_a);
$expected = array($u2, $u1);
$found = array_map('intval', wp_list_pluck($a2['activities'], 'user_id'));
$this->assertSame($expected, $found);
$num_queries = $wpdb->num_queries;
// bp_activity cache should not have been touched.
$b2 = bp_activity_get($activity_args_b);
$this->assertEqualSets($b1, $b2);
$this->assertSame($num_queries, $wpdb->num_queries);
}
示例5: setUp
public function setUp()
{
parent::setUp();
buddypress()->members->types = array();
$this->old_current_user = get_current_user_id();
$this->set_current_user($this->factory->user->create(array('user_login' => 'paulgibbs', 'role' => 'subscriber')));
}
示例6: bp_activity_mentions_script
/**
* Enqueue @mentions JS.
*
* @since 2.1.0
*/
function bp_activity_mentions_script()
{
if (!bp_activity_maybe_load_mentions_scripts()) {
return;
}
// Special handling for New/Edit screens in wp-admin.
if (is_admin()) {
if (!get_current_screen() || !in_array(get_current_screen()->base, array('page', 'post')) || !post_type_supports(get_current_screen()->post_type, 'editor')) {
return;
}
}
$min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
wp_enqueue_script('bp-mentions', buddypress()->plugin_url . "bp-activity/js/mentions{$min}.js", array('jquery', 'jquery-atwho'), bp_get_version(), true);
wp_enqueue_style('bp-mentions-css', buddypress()->plugin_url . "bp-activity/css/mentions{$min}.css", array(), bp_get_version());
wp_style_add_data('bp-mentions-css', 'rtl', true);
if ($min) {
wp_style_add_data('bp-mentions-css', 'suffix', $min);
}
// If the script has been enqueued, let's attach our mentions TinyMCE init callback.
add_filter('tiny_mce_before_init', 'bp_add_mentions_on_tinymce_init', 10, 2);
/**
* Fires at the end of the Activity Mentions script.
*
* This is the hook where BP components can add their own prefetched results
* friends to the page for quicker @mentions lookups.
*
* @since 2.1.0
*/
do_action('bp_activity_mentions_prime_results');
}
示例7: cfbgr_register_member_types
/**
* 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)));
}
}
示例8: templatepack_maybe_change_nav_position
/**
* Profile is default component so let's make it the first tab of xprofile nav
*/
function templatepack_maybe_change_nav_position()
{
$bp = buddypress();
if (defined('BP_DEFAULT_COMPONENT') && 'profile' == BP_DEFAULT_COMPONENT) {
$bp->bp_nav['profile']['position'] = 1;
}
}
示例9: test_bp_core_ajax_url
function test_bp_core_ajax_url()
{
$forced = force_ssl_admin();
// (1) HTTPS off
force_ssl_admin(false);
$_SERVER['HTTPS'] = 'off';
// (1a) Front-end
$this->go_to('/');
$this->assertEquals(bp_core_ajax_url(), get_site_url(bp_get_root_blog_id(), '/wp-admin/admin-ajax.php', 'http'));
// (1b) Dashboard
$this->go_to('/wp-admin');
$this->assertEquals(bp_core_ajax_url(), get_site_url(bp_get_root_blog_id(), '/wp-admin/admin-ajax.php', 'http'));
// (2) FORCE_SSL_ADMIN
force_ssl_admin(true);
// (2a) Front-end
$this->go_to('/');
$this->assertEquals(bp_core_ajax_url(), get_site_url(bp_get_root_blog_id(), '/wp-admin/admin-ajax.php', 'http'));
// (2b) Dashboard
$this->go_to('/wp-admin');
$this->assertEquals(bp_core_ajax_url(), get_site_url(bp_get_root_blog_id(), '/wp-admin/admin-ajax.php', 'https'));
force_ssl_admin($forced);
// (3) Multisite, root blog other than 1
if (is_multisite()) {
$original_root_blog = bp_get_root_blog_id();
$blog_id = $this->factory->blog->create(array('path' => '/path' . rand() . time() . '/'));
buddypress()->root_blog_id = $blog_id;
$blog_url = get_blog_option($blog_id, 'siteurl');
$this->go_to(trailingslashit($blog_url));
buddypress()->root_blog_id = $original_root_blog;
$ajax_url = bp_core_ajax_url();
$this->go_to('/');
$this->assertEquals($blog_url . '/wp-admin/admin-ajax.php', $ajax_url);
}
}
示例10: mpp_current_component_type_for_groups
/**
* set current component_type to groups if we are on groups page
* @see mpp_get_current_component()
* @param type $component
* @return type
*/
function mpp_current_component_type_for_groups($component)
{
if (bp_is_active('groups') && bp_is_group()) {
return buddypress()->groups->id;
}
return $component;
}
示例11: bp_setup_xprofile
/**
* Bootstrap the XProfile component.
*/
function bp_setup_xprofile()
{
$bp = buddypress();
if (!isset($bp->profile->id)) {
$bp->profile = new BP_XProfile_Component();
}
}
示例12: mpp_gallery_archive_redirect
function mpp_gallery_archive_redirect()
{
if (is_post_type_archive(mpp_get_gallery_post_type()) && mediapress()->is_bp_active() && mpp_get_option('has_gallery_directory') && isset(buddypress()->pages->mediapress->id)) {
wp_safe_redirect(get_permalink(buddypress()->pages->mediapress->id), 301);
exit(0);
}
}
示例13: test_get_total_count_null_component_name
/**
* @group get_total_count
* @ticket BP5300
*/
public function test_get_total_count_null_component_name()
{
$u = $this->factory->user->create();
$n1 = $this->factory->notification->create(array('component_name' => 'groups', 'user_id' => $u));
$n2 = $this->factory->notification->create(array('component_name' => 'messages', 'user_id' => $u));
// temporarily turn on groups, shut off messages
$groups_toggle = isset(buddypress()->active_components['groups']);
$messages_toggle = isset(buddypress()->active_components['messages']);
buddypress()->active_components['groups'] = 1;
unset(buddypress()->active_components['messages']);
$n = BP_Notifications_Notification::get_total_count(array('user_id' => $u));
// Check that the correct items are pulled up
$this->assertEquals(1, $n);
// reset copmonent toggles
if ($groups_toggle) {
buddypress()->active_components['groups'] = 1;
} else {
unset(buddypress()->active_components['groups']);
}
if ($messages_toggle) {
buddypress()->active_components['messages'] = 1;
} else {
unset(buddypress()->active_components['messages']);
}
}
示例14: bp_members_admin_bar_user_admin_menu
/**
* Add the User Admin top-level menu to user pages.
*
* @since 1.5.0
*/
function bp_members_admin_bar_user_admin_menu()
{
global $wp_admin_bar;
// Only show if viewing a user
if (!bp_is_user()) {
return false;
}
// Don't show this menu to non site admins or if you're viewing your own profile
if (!current_user_can('edit_users') || bp_is_my_profile()) {
return false;
}
$bp = buddypress();
// Unique ID for the 'My Account' menu
$bp->user_admin_menu_id = 'user-admin';
// Add the top-level User Admin button
$wp_admin_bar->add_menu(array('id' => $bp->user_admin_menu_id, 'title' => __('Edit Member', 'buddypress'), 'href' => bp_displayed_user_domain()));
if (bp_is_active('xprofile')) {
// User Admin > Edit this user's profile
$wp_admin_bar->add_menu(array('parent' => $bp->user_admin_menu_id, 'id' => $bp->user_admin_menu_id . '-edit-profile', 'title' => __("Edit Profile", 'buddypress'), 'href' => bp_get_members_component_link('profile', 'edit')));
// User Admin > Edit this user's avatar
if (buddypress()->avatar->show_avatars) {
$wp_admin_bar->add_menu(array('parent' => $bp->user_admin_menu_id, 'id' => $bp->user_admin_menu_id . '-change-avatar', 'title' => __("Edit Profile Photo", 'buddypress'), 'href' => bp_get_members_component_link('profile', 'change-avatar')));
}
}
if (bp_is_active('settings')) {
// User Admin > Spam/unspam
$wp_admin_bar->add_menu(array('parent' => $bp->user_admin_menu_id, 'id' => $bp->user_admin_menu_id . '-user-capabilities', 'title' => __('User Capabilities', 'buddypress'), 'href' => bp_displayed_user_domain() . 'settings/capabilities/'));
// User Admin > Delete Account
$wp_admin_bar->add_menu(array('parent' => $bp->user_admin_menu_id, 'id' => $bp->user_admin_menu_id . '-delete-user', 'title' => __('Delete Account', 'buddypress'), 'href' => bp_displayed_user_domain() . 'settings/delete-account/'));
}
}
示例15: xprofile_add_admin_js
/**
* Enqueue the jQuery libraries for handling drag/drop/sort.
*
* @since 1.5.0
*/
function xprofile_add_admin_js()
{
if (!empty($_GET['page']) && strpos($_GET['page'], 'bp-profile-setup') !== false) {
wp_enqueue_script('jquery-ui-core');
wp_enqueue_script('jquery-ui-tabs');
wp_enqueue_script('jquery-ui-mouse');
wp_enqueue_script('jquery-ui-draggable');
wp_enqueue_script('jquery-ui-droppable');
wp_enqueue_script('jquery-ui-sortable');
$min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
wp_enqueue_script('xprofile-admin-js', buddypress()->plugin_url . "bp-xprofile/admin/js/admin{$min}.js", array('jquery', 'jquery-ui-sortable'), bp_get_version());
// Localize strings.
// supports_options_field_types is a dynamic list of field
// types that support options, for use in showing/hiding the
// "please enter options for this field" section.
$strings = array('supports_options_field_types' => array());
foreach (bp_xprofile_get_field_types() as $field_type => $field_type_class) {
$field = new $field_type_class();
if ($field->supports_options) {
$strings['supports_options_field_types'][] = $field_type;
}
}
wp_localize_script('xprofile-admin-js', 'XProfileAdmin', $strings);
}
}