本文整理汇总了PHP中bp_activity_add_user_favorite函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_activity_add_user_favorite函数的具体用法?PHP bp_activity_add_user_favorite怎么用?PHP bp_activity_add_user_favorite使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_activity_add_user_favorite函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_bp_has_activities_favorites_action_filter
/**
* Make sure that action filters ('activity_update', etc) work when
* limiting query to user favorites
*
* @ticket BP4872
* @group scope
*/
public function test_bp_has_activities_favorites_action_filter()
{
$user_id = $this->factory->user->create(array('role' => 'subscriber'));
$now = time();
$a1 = $this->factory->activity->create(array('type' => 'activity_update', 'recorded_time' => date('Y-m-d H:i:s', $now)));
$a2 = $this->factory->activity->create(array('type' => 'joined_group', 'recorded_time' => date('Y-m-d H:i:s', $now - 100)));
$current_user = bp_loggedin_user_id();
$this->set_current_user($user_id);
bp_activity_add_user_favorite($a1, $user_id);
bp_activity_add_user_favorite($a2, $user_id);
$this->set_current_user($current_user);
// groan. It sucks that you have to invoke the global
global $activities_template;
// Case 1: no action filter
bp_has_activities(array('user_id' => $user_id, 'scope' => 'favorites'));
// The formatting of $activities_template->activities is messed
// up, so we're just going to look at the IDs. This should be
// fixed in BP at some point
$ids = wp_list_pluck($activities_template->activities, 'id');
$this->assertEquals(array($a1, $a2), $ids);
$activities_template = null;
// Case 2: action filter
bp_has_activities(array('user_id' => $user_id, 'scope' => 'favorites', 'action' => 'activity_update'));
$ids = wp_list_pluck($activities_template->activities, 'id');
$this->assertEquals(array($a1), $ids);
$activities_template = null;
}
示例2: bp_dtheme_mark_activity_favorite
function bp_dtheme_mark_activity_favorite()
{
global $bp;
bp_activity_add_user_favorite($_POST['id']);
_e('Remove Favorite', 'buddypress');
}
示例3: bp_dtheme_mark_activity_favorite
function bp_dtheme_mark_activity_favorite()
{
// Bail if not a POST action
if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
return;
}
bp_activity_add_user_favorite($_POST['id']);
_e('Remove Favorite', 'buddypress');
}
示例4: bp_dtheme_mark_activity_favorite
/**
* Mark an activity as a favourite via a POST request.
*
* @return string HTML
* @since BuddyPress (1.2)
*/
function bp_dtheme_mark_activity_favorite()
{
// Bail if not a POST action
if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
return;
}
if (bp_activity_add_user_favorite($_POST['id'])) {
_e('Remove Favorite', 'logicalboneshug');
} else {
_e('Favorite', 'logicalboneshug');
}
exit;
}
示例5: bp_activity_action_mark_favorite
/**
* Mark activity as favorite.
*
* @since 1.2.0
*
* @uses is_user_logged_in()
* @uses bp_is_activity_component()
* @uses bp_is_current_action()
* @uses check_admin_referer()
* @uses bp_activity_add_user_favorite()
* @uses bp_action_variable()
* @uses bp_core_add_message()
* @uses bp_core_redirect()
* @uses wp_get_referer()
*
* @return bool False on failure.
*/
function bp_activity_action_mark_favorite()
{
if (!is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action('favorite')) {
return false;
}
// Check the nonce.
check_admin_referer('mark_favorite');
if (bp_activity_add_user_favorite(bp_action_variable(0))) {
bp_core_add_message(__('Activity marked as favorite.', 'buddypress'));
} else {
bp_core_add_message(__('There was an error marking that activity as a favorite. Please try again.', 'buddypress'), 'error');
}
bp_core_redirect(wp_get_referer() . '#activity-' . bp_action_variable(0));
}
示例6: bp_legacy_theme_mark_activity_favorite
/**
* Mark an activity as a favourite via a POST request.
*
* @since 1.2.0
*
* @return string HTML
*/
function bp_legacy_theme_mark_activity_favorite()
{
// Bail if not a POST action.
if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
return;
}
if (bp_activity_add_user_favorite($_POST['id'])) {
_e('Remove Favorite', 'buddypress');
} else {
_e('Favorite', 'buddypress');
}
exit;
}
示例7: catch_mark_favorite
/**
* Screen function for grabbing a favorite request
*
* If redirect_to is found, it comes from a single blog post page, so
* we handle it. Otherwise fall through to the BP native function
*/
public function catch_mark_favorite()
{
// Let BP handle regular favoriting
if (!isset($_GET['redirect_to'])) {
return;
}
if (!is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action('favorite')) {
if (!is_user_logged_in()) {
# Not logged in? Get them to log in.
$post_url = stripslashes(urldecode($_GET['redirect_to']));
$url = wp_login_url($post_url);
$url = add_query_arg(array('tcfav' => 'ready'), $url);
wp_redirect($url);
exit;
} else {
return false;
}
}
remove_action('bp_actions', 'bp_activity_action_mark_favorite');
// Check the nonce
check_admin_referer('mark_favorite');
bp_activity_add_user_favorite(bp_action_variable(0));
wp_redirect(stripslashes(urldecode($_GET['redirect_to'])));
}
示例8: test_remove_user_favorite_bad_activity_id
/**
* @group favorites
* @group bp_activity_remove_user_favorite
*/
public function test_remove_user_favorite_bad_activity_id()
{
$u1 = $this->factory->user->create();
$u2 = $this->factory->user->create();
$a = $this->factory->activity->create();
// bp_activity_add_user_favorite() requires a logged-in user.
$current_user = bp_loggedin_user_id();
$this->set_current_user($u1);
// Only favorite for user 1
bp_activity_add_user_favorite($a, $u1);
// Removing for user 2 should fail
$this->assertFalse(bp_activity_remove_user_favorite($a, $u2));
$this->assertEquals(1, bp_activity_get_meta($a, 'favorite_count'));
$this->set_current_user($current_user);
}
示例9: bp_activity_action_mark_favorite
function bp_activity_action_mark_favorite() {
global $bp;
if ( !is_user_logged_in() || $bp->current_component != $bp->activity->slug || $bp->current_action != 'favorite' )
return false;
/* Check the nonce */
check_admin_referer( 'mark_favorite' );
if ( bp_activity_add_user_favorite( $bp->action_variables[0] ) )
bp_core_add_message( __( 'Activity marked as favorite.', 'buddypress' ) );
else
bp_core_add_message( __( 'There was an error marking that activity as a favorite, please try again.', 'buddypress' ), 'error' );
bp_core_redirect( wp_get_referer() . '#activity-' . $bp->action_variables[0] );
}
示例10: buddyboss_mark_activity_favorite
/**
* Mark an activity as a favourite via a POST request.
*
* @return string HTML
* @since BuddyBoss 3.0
*/
function buddyboss_mark_activity_favorite()
{
// Bail if not a POST action
if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
return;
}
if (bp_activity_add_user_favorite($_POST['id'])) {
$resp['but_text'] = __('Unlike', 'buddyboss');
} else {
$resp['but_text'] = __('Like', 'buddyboss');
}
$resp['num_likes'] = get_wall_add_likes_comments((int) $_POST['id']);
$resp['like_count'] = (int) bp_activity_get_meta((int) $_POST['id'], 'favorite_count');
echo json_encode($resp);
exit;
}
示例11: bp_dtheme_mark_activity_favorite_product
function bp_dtheme_mark_activity_favorite_product()
{
global $bp;
bp_activity_add_user_favorite($_POST['id']);
_e('Remove Favorite', 'product');
}