本文整理汇总了PHP中bp_activity_get_actions函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_activity_get_actions函数的具体用法?PHP bp_activity_get_actions怎么用?PHP bp_activity_get_actions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_activity_get_actions函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bp_activity_generate_action_string
/**
* Generate an activity action string for an activity item.
*
* @since 2.0.0
*
* @param object $activity Activity data object.
* @return string|bool Returns false if no callback is found, otherwise returns
* the formatted action string.
*/
function bp_activity_generate_action_string($activity)
{
// Check for valid input.
if (empty($activity->component) || empty($activity->type)) {
return false;
}
// Check for registered format callback.
$actions = bp_activity_get_actions();
if (empty($actions->{$activity->component}->{$activity->type}['format_callback'])) {
return false;
}
// We apply the format_callback as a filter.
add_filter('bp_activity_generate_action_string', $actions->{$activity->component}->{$activity->type}['format_callback'], 10, 2);
/**
* Filters the string for the activity action being returned.
*
* @since 2.0.0
*
* @param BP_Activity_Activity $action Action string being requested.
* @param BP_Activity_Activity $activity Activity item object.
*/
$action = apply_filters('bp_activity_generate_action_string', $activity->action, $activity);
// Remove the filter for future activity items.
remove_filter('bp_activity_generate_action_string', $actions->{$activity->component}->{$activity->type}['format_callback'], 10, 2);
return $action;
}
示例2: extra_tablenav
/**
* Markup for the "filter" part of the form (i.e. which activity type to display).
*
* @since BuddyPress (1.6.0)
*
* @param string $which 'top' or 'bottom'.
*/
function extra_tablenav($which)
{
// Bail on bottom table nav
if ('bottom' === $which) {
return;
}
// Is any filter currently selected?
$selected = !empty($_REQUEST['activity_type']) ? $_REQUEST['activity_type'] : '';
// Get the actions
$activity_actions = bp_activity_get_actions();
?>
<div class="alignleft actions">
<select name="activity_type">
<option value="" <?php
selected(!$selected);
?>
><?php
_e('View all actions', 'buddypress');
?>
</option>
<?php
foreach ($activity_actions as $component => $actions) {
?>
<optgroup label="<?php
echo ucfirst($component);
?>
">
<?php
foreach ($actions as $action_key => $action_values) {
?>
<?php
// Skip the incorrectly named pre-1.6 action
if ('friends_register_activity_action' !== $action_key) {
?>
<option value="<?php
echo esc_attr($action_key);
?>
" <?php
selected($action_key, $selected);
?>
><?php
echo esc_html($action_values['value']);
?>
</option>
<?php
}
?>
<?php
}
?>
</optgroup>
<?php
}
?>
</select>
<?php
submit_button(__('Filter', 'buddypress'), 'secondary', false, false, array('id' => 'post-query-submit'));
?>
</div>
<?php
}
示例3: bp_activity_admin_edit_metabox_type
/**
* Activity type metabox for the Activity admin edit screen.
*
* @since 1.6.0
*
* @param object $item Activity item.
*/
function bp_activity_admin_edit_metabox_type($item)
{
$bp = buddypress();
$actions = array();
$selected = $item->type;
// Walk through the registered actions, and build an array of actions/values.
foreach (bp_activity_get_actions() as $action) {
$action = array_values((array) $action);
for ($i = 0, $i_count = count($action); $i < $i_count; $i++) {
$actions[$action[$i]['key']] = $action[$i]['value'];
}
}
// This was a mis-named activity type from before BP 1.6.
unset($actions['friends_register_activity_action']);
// Sort array by the human-readable value.
natsort($actions);
/*
* If the activity type is not registered properly (eg, a plugin has
* not called bp_activity_set_action()), add the raw type to the end
* of the list.
*/
if (!isset($actions[$selected])) {
_doing_it_wrong(__FUNCTION__, sprintf(__('This activity item has a type (%s) that is not registered using bp_activity_set_action(), so no label is available.', 'buddypress'), $selected), '2.0.0');
$actions[$selected] = $selected;
}
?>
<label for="bp-activities-type" class="screen-reader-text"><?php
/* translators: accessibility text */
esc_html_e('Select activity type', 'buddypress');
?>
</label>
<select name="bp-activities-type" id="bp-activities-type">
<?php
foreach ($actions as $k => $v) {
?>
<option value="<?php
echo esc_attr($k);
?>
" <?php
selected($k, $selected);
?>
><?php
echo esc_html($v);
?>
</option>
<?php
}
?>
</select>
<?php
}
示例4: test_bp_activity_get_actions
/**
* @goup bp_activity_get_actions
*/
public function test_bp_activity_get_actions()
{
$activity_actions = bp_activity_get_actions();
$this->assertTrue(!isset($activity_actions->activity->new_using_old_filter), 'Post types registering using the bp_blogs_record_post_post_types filter should not have a specific action');
}
示例5: test_sort_no_post_type_registered
/**
* @ticket BP6865
*/
public function test_sort_no_post_type_registered()
{
bp_activity_set_action('foo', 'new_foo', 'Did a foo', '', '', array(), 10);
bp_activity_set_action('foo', 'new_bar', 'Did a bar', '', '', array(), 5);
remove_post_type_support('post', 'buddypress-activity');
$actions = bp_activity_get_actions();
$expected = array('new_bar' => 'new_bar', 'new_foo' => 'new_foo');
$this->assertSame($expected, wp_list_pluck((array) $actions->foo, 'key'));
// Clean up.
add_post_type_support('post', 'buddypress-activity');
}
示例6: bp_get_activity_show_filters
/**
* Get available filters depending on the scope.
*
* @since BuddyPress (2.1.0)
*
* @param string $context The current context. 'activity', 'member',
* 'member_groups', 'group'
* @return string HTML for <option> values.
*/
function bp_get_activity_show_filters($context = '')
{
// Set default context based on current page
if (empty($context)) {
// On member pages, default to 'member', unless this
// is a user's Groups activity
if (bp_is_user()) {
if (bp_is_active('groups') && bp_is_current_action(bp_get_groups_slug())) {
$context = 'member_groups';
} else {
$context = 'member';
}
// On individual group pages, default to 'group'
} elseif (bp_is_active('groups') && bp_is_group()) {
$context = 'group';
// 'activity' everywhere else
} else {
$context = 'activity';
}
}
$filters = array();
// Walk through the registered actions, and prepare an the
// select box options.
foreach (bp_activity_get_actions() as $actions) {
foreach ($actions as $action) {
if (!in_array($context, (array) $action['context'])) {
continue;
}
// Friends activity collapses two filters into one
if (in_array($action['key'], array('friendship_accepted', 'friendship_created'))) {
$action['key'] = 'friendship_accepted,friendship_created';
}
$filters[$action['key']] = $action['label'];
}
}
/**
* Filters the options available in the activity filter dropdown.
*
* @since BuddyPress (2.2.0)
*
* @param array $filters Array of filter options for the given context, in the following format: $option_value => $option_name.
* @param string $context Context for the filter. 'activity', 'member', 'member_groups', 'group'.
*/
$filters = apply_filters('bp_get_activity_show_filters_options', $filters, $context);
// Build the options output
$output = '';
if (!empty($filters)) {
foreach ($filters as $value => $filter) {
$output .= '<option value="' . esc_attr($value) . '">' . esc_html($filter) . '</option>' . "\n";
}
}
/**
* Filters the HTML markup result for the activity filter dropdown.
*
* @since BuddyPress (2.1.0)
*
* @param string $output HTML output for the activity filter dropdown.
* @param array $filters Array of filter options for the given context, in the following format: $option_value => $option_name.
* @param string $context Context for the filter. 'activity', 'member', 'member_groups', 'group'.
*/
return apply_filters('bp_get_activity_show_filters', $output, $filters, $context);
}
示例7: test_bp_activity_set_post_type_tracking_args
/**
* @group bp_activity_set_post_type_tracking_args
* @group activity_tracking
*/
public function test_bp_activity_set_post_type_tracking_args()
{
$bp = buddypress();
add_post_type_support('page', 'buddypress-activity');
bp_activity_set_post_type_tracking_args('page', array('component_id' => $bp->blogs->id, 'dummy' => 'dummy value'));
// Build the actions to fetch the tracking args
bp_activity_get_actions();
$u = $this->factory->user->create();
$post_id = $this->factory->post->create(array('post_author' => $u, 'post_status' => 'publish', 'post_type' => 'page'));
$a = bp_activity_get(array('action' => 'new_page', 'item_id' => get_current_blog_id(), 'secondary_item_id' => $post_id));
$this->assertSame($bp->blogs->id, $a['activities'][0]->component);
remove_post_type_support('page', 'buddypress-activity');
// Reset globals
unset($bp->activity->actions->blogs->new_page);
$bp->activity->track = array();
}
示例8: extra_tablenav
/**
* Markup for the "filter" part of the form (i.e. which activity type to display).
*
* @since 1.6.0
*
* @param string $which 'top' or 'bottom'.
*/
function extra_tablenav($which)
{
// Bail on bottom table nav.
if ('bottom' === $which) {
return;
}
// Is any filter currently selected?
$selected = !empty($_REQUEST['activity_type']) ? $_REQUEST['activity_type'] : '';
// Get the actions.
$activity_actions = bp_activity_get_actions();
?>
<div class="alignleft actions">
<label for="activity-type" class="screen-reader-text"><?php
/* translators: accessibility text */
_e('Filter by activity type', 'buddypress');
?>
</label>
<select name="activity_type" id="activity-type">
<option value="" <?php
selected(!$selected);
?>
><?php
_e('View all actions', 'buddypress');
?>
</option>
<?php
foreach ($activity_actions as $component => $actions) {
?>
<?php
// Older avatar activity items use 'profile' for component. See r4273.
if ($component === 'profile') {
$component = 'xprofile';
}
if (bp_is_active($component)) {
if ($component === 'xprofile') {
$component_name = buddypress()->profile->name;
} else {
$component_name = buddypress()->{$component}->name;
}
} else {
// Prevent warnings by other plugins if a component is disabled but the activity type has been registered.
$component_name = ucfirst($component);
}
?>
<optgroup label="<?php
echo esc_html($component_name);
?>
">
<?php
foreach ($actions as $action_key => $action_values) {
?>
<?php
// Skip the incorrectly named pre-1.6 action.
if ('friends_register_activity_action' !== $action_key) {
?>
<option value="<?php
echo esc_attr($action_key);
?>
" <?php
selected($action_key, $selected);
?>
><?php
echo esc_html($action_values['value']);
?>
</option>
<?php
}
?>
<?php
}
?>
</optgroup>
<?php
}
?>
</select>
<?php
submit_button(__('Filter', 'buddypress'), 'secondary', false, false, array('id' => 'post-query-submit'));
?>
</div>
//.........这里部分代码省略.........
示例9: test_wp_idea_stream_idea_activity_actions
/**
* @group activity_action
*/
public function test_wp_idea_stream_idea_activity_actions()
{
bp_activity_get_actions();
$u = $this->factory->user->create();
$i = $this->factory->idea->create(array('author' => $u));
$user = $this->factory->user->get_object_by_id($u);
// Create comment
$c = $this->factory->idea_comment->create(array('user_id' => $u, 'comment_author_email' => $user->user_email, 'comment_post_ID' => $i));
$user_link = bp_core_get_userlink($u);
$blog_url = get_home_url();
$post_url = add_query_arg('p', $i, trailingslashit($blog_url));
$comment_link = wp_idea_stream_comments_get_comment_link($c);
$a = $this->factory->activity->create(array('component' => buddypress()->blogs->id, 'type' => 'new_ideas', 'user_id' => $u, 'item_id' => get_current_blog_id(), 'secondary_item_id' => $i, 'primary_link' => $post_url));
$expected = sprintf('%1$s wrote a new %2$s', $user_link, '<a href="' . esc_url($post_url) . '">idea</a>');
$a_obj = new BP_Activity_Activity($a);
$this->assertSame($expected, $a_obj->action);
// Comment
$a = $this->factory->activity->create(array('component' => buddypress()->blogs->id, 'type' => 'new_ideas_comment', 'user_id' => $u, 'item_id' => get_current_blog_id(), 'secondary_item_id' => $c));
$expected = sprintf('%1$s replied to this %2$s', $user_link, '<a href="' . esc_url($comment_link) . '">idea</a>');
$a_obj = new BP_Activity_Activity($a);
$this->assertSame($expected, $a_obj->action);
/** Group */
$g = $this->factory->group->create();
$a = $this->factory->activity->create(array('component' => buddypress()->groups->id, 'type' => 'new_ideas', 'user_id' => $u, 'item_id' => $g, 'secondary_item_id' => $i, 'primary_link' => $post_url));
$group = $this->factory->group->get_object_by_id($g);
$group_link = '<a href="' . bp_get_group_permalink($group) . '">' . $group->name . '</a>';
$expected = sprintf('%1$s wrote a new %2$s in the group %3$s', $user_link, '<a href="' . esc_url($post_url) . '">idea</a>', $group_link);
$a_obj = new BP_Activity_Activity($a);
$this->assertSame($expected, $a_obj->action);
// Comment
$a = $this->factory->activity->create(array('component' => buddypress()->groups->id, 'type' => 'new_ideas_comment', 'user_id' => $u, 'item_id' => $g, 'secondary_item_id' => $c));
$expected = sprintf('%1$s replied to this %2$s posted in the group %3$s', $user_link, '<a href="' . esc_url($comment_link) . '">idea</a>', $group_link);
$a_obj = new BP_Activity_Activity($a);
$this->assertSame($expected, $a_obj->action);
}
示例10: test_bp_blogs_format_activity_action_new_blog_post_updated_without_title
/**
* @group activity_action
* @group bp_blogs_format_activity_action_new_blog_post
*/
public function test_bp_blogs_format_activity_action_new_blog_post_updated_without_title()
{
if (is_multisite()) {
return;
}
$bp = buddypress();
$activity_actions = $bp->activity->actions;
$bp->activity->actions = new stdClass();
$u = $this->factory->user->create();
$p = wp_insert_post(array('post_author' => $u, 'post_title' => 'foo', 'post_status' => 'publish', 'post_content' => 'foo bar'));
$user_link = bp_core_get_userlink($u);
$blog_url = get_home_url();
$post_url = add_query_arg('p', $p, trailingslashit($blog_url));
$post_title = get_the_title($p);
$post_link = '<a href="' . $post_url . '">' . $post_title . '</a>';
// Set actions
bp_activity_get_actions();
$a_obj = bp_activity_get(array('item_id' => 1, 'secondary_item_id' => $p));
$expected = sprintf('%s wrote a new post, %s', $user_link, $post_link);
$this->assertSame($expected, $a_obj['activities'][0]->action);
// Update the post by removing its title
wp_update_post(array('ID' => $p, 'post_title' => ''));
// we now expect the (no title) post link
$post_link = '<a href="' . $post_url . '">(no title)</a>';
$expected = sprintf('%s wrote a new post, %s', $user_link, $post_link);
$a_obj = bp_activity_get(array('item_id' => 1, 'secondary_item_id' => $p));
$this->assertSame($expected, $a_obj['activities'][0]->action);
// Reset activity actions
$bp->activity->actions = $activity_actions;
$bp->activity->track = array();
}
示例11: test_bp_activity_format_activity_action_custom_post_type_comment
/**
* @group activity_action
* @group bp_activity_format_activity_action_custom_post_type_post_ms
* @group post_type_comment_activities
*/
public function test_bp_activity_format_activity_action_custom_post_type_comment()
{
if (is_multisite()) {
$b = $this->factory->blog->create();
switch_to_blog($b);
add_filter('comment_flood_filter', '__return_false');
} else {
$b = get_current_blog_id();
}
$u = $this->factory->user->create();
$userdata = get_userdata($u);
$labels = array('name' => 'bars', 'singular_name' => 'bar', 'bp_activity_new_comment' => __('%1$s commented on the <a href="%2$s">bar</a>', 'buddypress'), 'bp_activity_new_comment_ms' => __('%1$s commented on the <a href="%2$s">bar</a>, on the site %3$s', 'buddypress'));
register_post_type('foo', array('labels' => $labels, 'public' => true, 'supports' => array('buddypress-activity', 'comments'), 'bp_activity' => array('action_id' => 'new_bar', 'comment_action_id' => 'new_bar_comment')));
// Build the actions to fetch the tracking args
bp_activity_get_actions();
$p = $this->factory->post->create(array('post_author' => $u, 'post_type' => 'foo'));
$c = wp_new_comment(array('comment_post_ID' => $p, 'comment_author' => $userdata->user_nicename, 'comment_author_url' => 'http://buddypress.org', 'comment_author_email' => $userdata->user_email, 'comment_content' => 'this is a blog comment', 'comment_type' => '', 'comment_parent' => 0, 'user_id' => $u));
$a = bp_activity_get_activity_id(array('type' => 'new_bar_comment'));
$a_obj = new BP_Activity_Activity($a);
$user_link = bp_core_get_userlink($u);
$comment_url = get_comment_link($c);
_unregister_post_type('foo');
if (is_multisite()) {
$blog_url = get_blog_option($a_obj->item_id, 'home');
restore_current_blog();
remove_filter('comment_flood_filter', '__return_false');
$expected = sprintf($labels['bp_activity_new_comment_ms'], $user_link, $comment_url, '<a href="' . $blog_url . '">' . get_blog_option($a_obj->item_id, 'blogname') . '</a>');
} else {
$expected = sprintf($labels['bp_activity_new_comment'], $user_link, $comment_url);
}
$this->assertSame($expected, $a_obj->action);
}