本文整理汇总了PHP中bp_forums_get_post函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_forums_get_post函数的具体用法?PHP bp_forums_get_post怎么用?PHP bp_forums_get_post使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_forums_get_post函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bfox_bp_activity_before_save
/**
* Calculates the bible references for an activity before it is saved
*
* @param $activity
*/
function bfox_bp_activity_before_save($activity)
{
global $bp;
// For blog posts, index the full post content and tags
if ($activity->component == $bp->blogs->id && $activity->type == 'new_blog_post') {
switch_to_blog($activity->item_id);
$ref = bfox_blog_post_get_ref($activity->secondary_item_id);
restore_current_blog();
} elseif ($activity->component == $bp->groups->id && ($activity->type == 'new_forum_post' || $activity->type == 'new_forum_topic')) {
// Get the forum post
if ($activity->type == 'new_forum_topic') {
list($post) = bp_forums_get_topic_posts(array('topic_id' => $activity->secondary_item_id, 'per_page' => 1));
} else {
$post = bp_forums_get_post($activity->secondary_item_id);
}
// Index the post text
$ref = bfox_ref_from_content($post->post_text);
// Only index the tags for the first post in a topic
if ($activity->type == 'new_forum_topic') {
$tags = bb_get_topic_tags($post->topic_id, array('fields' => 'names'));
foreach ($tags as $tag) {
$ref->add_ref(bfox_ref_from_tag($tag));
}
}
} else {
$ref = bfox_ref_from_content($activity->content);
}
// Add any 'Bible Tag' read passage strings
if ('activity_update' == $activity->type && isset($_REQUEST['bfox_read_ref_str'])) {
$tag_ref = new BfoxRef($_REQUEST['bfox_read_ref_str']);
if ($tag_ref->is_valid()) {
$activity->bfox_read_ref_str = $tag_ref->get_string();
$activity->action = str_replace('posted an update', __('posted an update about ', 'bfox') . $activity->bfox_read_ref_str, $activity->action);
$ref->add_ref($tag_ref);
}
}
if ($ref->is_valid()) {
$activity->bfox_ref = $ref;
}
}
示例2: bp_forums_insert_post
/**
* Create a new post.
*
* @param array $args {
* @type int $post_id Optional. ID of an existing post, if you want to
* update rather than create. Default: false.
* @type int $topic_id ID of the topic to which the post belongs.
* @type string $post_text Contents of the post.
* @type string $post_time Optional. Time when the post was recorded.
* Default: current time, as reported by {@link bp_core_current_time()}.
* @type int $poster_id Optional. ID of the user creating the post.
* Default: ID of the logged-in user.
* @type string $poster_ip Optional. IP address of the user creating the
* post. Default: the IP address found in $_SERVER['REMOTE_ADDR'].
* @type int $post_status Post status. Default: 0.
* @type int $post_position Optional. Default: false (auto).
* }
* @return int|bool ID of the new post on success, false on failure.
*/
function bp_forums_insert_post($args = '')
{
/** This action is documented in bp-forums/bp-forums-screens */
do_action('bbpress_init');
$defaults = array('post_id' => false, 'topic_id' => false, 'post_text' => '', 'post_time' => bp_core_current_time(), 'poster_id' => bp_loggedin_user_id(), 'poster_ip' => $_SERVER['REMOTE_ADDR'], 'post_status' => 0, 'post_position' => false);
$r = wp_parse_args($args, $defaults);
extract($r, EXTR_SKIP);
if (!($post = bp_forums_get_post($post_id))) {
$post_id = false;
}
if (!isset($topic_id)) {
$topic_id = $post->topic_id;
}
if (empty($post_text)) {
$post_text = $post->post_text;
}
if (!isset($post_time)) {
$post_time = $post->post_time;
}
if (!isset($post_position)) {
$post_position = $post->post_position;
}
if (empty($poster_id)) {
return false;
}
if (bp_is_user_inactive(bp_loggedin_user_id())) {
return false;
}
$post_id = bb_insert_post(array('post_id' => $post_id, 'topic_id' => $topic_id, 'post_text' => stripslashes(trim($post_text)), 'post_time' => $post_time, 'poster_id' => $poster_id, 'poster_ip' => $poster_ip, 'post_status' => $post_status, 'post_position' => $post_position));
if (!empty($post_id)) {
/**
* Fires if there was a new post created.
*
* @since BuddyPress (1.0.0)
*
* @param int $post_id ID of the newly created forum post.
*/
do_action('bp_forums_new_post', $post_id);
}
return $post_id;
}
示例3: groups_update_group_forum_post
/**
* Update an existing group forum post.
*
* Uses the bundled version of bbPress packaged with BuddyPress.
*
* @since BuddyPress (1.1.0)
*
* @param int $post_id The post ID of the existing forum post.
* @param string $post_text The text for the forum post.
* @param int $topic_id The topic ID of the existing forum topic.
* @param mixed $page The page number where the new forum post should reside. Optional.
*
* @return mixed The forum post ID on success. Boolean false on failure.
*/
function groups_update_group_forum_post($post_id, $post_text, $topic_id, $page = false)
{
$bp = buddypress();
/** This filter is documented in bp-groups/bp-groups-forums.php */
$post_text = apply_filters('group_forum_post_text_before_save', $post_text);
/** This filter is documented in bp-groups/bp-groups-forums.php */
$topic_id = apply_filters('group_forum_post_topic_id_before_save', $topic_id);
$post = bp_forums_get_post($post_id);
$post_id = bp_forums_insert_post(array('post_id' => $post_id, 'post_text' => $post_text, 'post_time' => $post->post_time, 'topic_id' => $topic_id, 'poster_id' => $post->poster_id));
if (empty($post_id)) {
return false;
}
$topic = bp_forums_get_topic_details($topic_id);
$activity_action = sprintf(__('%1$s replied to the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink($post->poster_id), '<a href="' . bp_get_group_permalink(groups_get_current_group()) . 'forum/topic/' . $topic->topic_slug . '">' . esc_attr($topic->topic_title) . '</a>', '<a href="' . bp_get_group_permalink(groups_get_current_group()) . '">' . esc_attr(bp_get_current_group_name()) . '</a>');
$activity_content = bp_create_excerpt($post_text);
$primary_link = bp_get_group_permalink(groups_get_current_group()) . 'forum/topic/' . $topic->topic_slug . '/';
if (!empty($page)) {
$primary_link .= "?topic_page=" . $page;
}
// Get the corresponding activity item
if (bp_is_active('activity')) {
$id = bp_activity_get_activity_id(array('user_id' => $post->poster_id, 'component' => $bp->groups->id, 'type' => 'new_forum_post', 'item_id' => bp_get_current_group_id(), 'secondary_item_id' => $post_id));
}
/** This filter is documented in bp-groups/bp-groups-forums.php */
$action = apply_filters_ref_array('groups_activity_new_forum_post_action', array($activity_action, $post_text, &$topic, &$topic));
/** This filter is documented in bp-groups/bp-groups-forums.php */
$content = apply_filters_ref_array('groups_activity_new_forum_post_content', array($activity_content, $post_text, &$topic, &$topic));
/** This filter is documented in bp-groups/bp-groups-forums.php */
$filtered_primary_link = apply_filters('groups_activity_new_forum_post_primary_link', $primary_link . "#post-" . $post_id);
groups_record_activity(array('id' => $id, 'action' => $action, 'content' => $content, 'primary_link' => $filtered_primary_link, 'type' => 'new_forum_post', 'item_id' => (int) bp_get_current_group_id(), 'user_id' => (int) $post->poster_id, 'secondary_item_id' => $post_id, 'recorded_time' => $post->post_time));
/**
* Fires after the update of a group forum post.
*
* @since BuddyPress (1.1.0)
*
* @param object $post Object holding current post being updated.
* @param object $topic Object holding current topic details. Passed by reference.
*/
do_action_ref_array('groups_update_group_forum_post', array($post, &$topic));
return $post_id;
}
示例4: bp_get_the_topic_post_edit_text
function bp_get_the_topic_post_edit_text() {
global $bp;
$post = bp_forums_get_post( $bp->action_variables[4] );
return apply_filters( 'bp_get_the_topic_post_edit_text', esc_attr( $post->post_text ) );
}
示例5: bp_get_the_topic_post_edit_text
/**
* Return the text to edit when editing a post.
*
* @return string Editable text.
*/
function bp_get_the_topic_post_edit_text() {
$post = bp_forums_get_post( bp_action_variable( 4 ) );
/**
* Filters the text to edit when editing a post.
*
* @since BuddyPress (1.2.4)
*
* @param string $value The text to edit when editing a post.
*/
return apply_filters( 'bp_get_the_topic_post_edit_text', esc_attr( $post->post_text ) );
}
示例6: widget
//.........这里部分代码省略.........
RWLogger::Log('BP_ACTIVITY_NOT_VISIBLE (SPAM or TRASH)');
}
// Activity marked as SPAM or TRASH.
continue;
} else {
if (!empty($activity->hide_sitewide)) {
if (RWLogger::IsOn()) {
RWLogger::Log('BP_ACTIVITY_HIDE_SITEWIDE');
}
// Activity marked as hidden in site.
continue;
}
}
}
$title = trim(strip_tags($activity->content));
$permalink = bp_activity_get_permalink($id);
} else {
if ('users' === $type) {
$id = RatingWidgetPlugin::Urid2UserId($urid);
if ($bpInstalled) {
$title = trim(strip_tags(bp_core_get_user_displayname($id)));
$permalink = bp_core_get_user_domain($id);
} else {
if ($bbInstalled) {
$title = trim(strip_tags(bbp_get_user_display_name($id)));
$permalink = bbp_get_user_profile_url($id);
} else {
continue;
}
}
} else {
if ('forum_posts' === $type || 'forum_replies' === $type) {
$id = RatingWidgetPlugin::Urid2ForumPostId($urid);
if (function_exists('bp_forums_get_post')) {
$forum_post = @bp_forums_get_post($id);
if (!is_object($forum_post)) {
continue;
}
$title = trim(strip_tags($forum_post->post_text));
$page = bb_get_page_number($forum_post->post_position);
$permalink = get_topic_link($id, $page) . "#post-{$id}";
} else {
if (function_exists('bbp_get_reply_id')) {
$forum_item = bbp_get_topic();
if (is_object($forum_item)) {
$is_topic = true;
} else {
$is_topic = false;
$forum_item = bbp_get_reply($id);
if (!is_object($forum_item)) {
if (RWLogger::IsOn()) {
RWLogger::Log('BBP_FORUM_ITEM_NOT_EXIST', $id);
}
// Invalid id (no topic nor reply).
continue;
}
if (RWLogger::IsOn()) {
RWLogger::Log('BBP_IS_TOPIC_REPLY', $is_topic ? 'FALSE' : 'TRUE');
}
}
// Visible statueses: Public or Closed.
$visible_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id());
if (!in_array($forum_item->post_status, $visible_statuses)) {
if (RWLogger::IsOn()) {
RWLogger::Log('BBP_FORUM_ITEM_HIDDEN', $forum_item->post_status);
}
示例7: bp_forums_insert_post
function bp_forums_insert_post($args = '')
{
global $bp;
do_action('bbpress_init');
$defaults = array('post_id' => false, 'topic_id' => false, 'post_text' => '', 'post_time' => bp_core_current_time(), 'poster_id' => bp_loggedin_user_id(), 'poster_ip' => $_SERVER['REMOTE_ADDR'], 'post_status' => 0, 'post_position' => false);
$r = wp_parse_args($args, $defaults);
extract($r, EXTR_SKIP);
if (!($post = bp_forums_get_post($post_id))) {
$post_id = false;
}
if (!isset($topic_id)) {
$topic_id = $post->topic_id;
}
if (empty($post_text)) {
$post_text = $post->post_text;
}
if (!isset($post_time)) {
$post_time = $post->post_time;
}
if (!isset($post_position)) {
$post_position = $post->post_position;
}
if (empty($poster_id)) {
return false;
}
if (bp_is_user_inactive(bp_loggedin_user_id())) {
return false;
}
$post_id = bb_insert_post(array('post_id' => $post_id, 'topic_id' => $topic_id, 'post_text' => stripslashes(trim($post_text)), 'post_time' => $post_time, 'poster_id' => $poster_id, 'poster_ip' => $poster_ip, 'post_status' => $post_status, 'post_position' => $post_position));
if (!empty($post_id)) {
do_action('bp_forums_new_post', $post_id);
}
return $post_id;
}
示例8: widget
function widget($args, $instance)
{
if (RWLogger::IsOn()) {
$params = func_get_args();
RWLogger::LogEnterence("RWTopRated.widget", $params, true);
}
if (!defined("WP_RW__USER_KEY") || false === WP_RW__USER_KEY) {
return;
}
if (RatingWidgetPlugin::$WP_RW__HIDE_RATINGS) {
return;
}
extract($args, EXTR_SKIP);
$types = array("posts" => array("rclass" => "blog-post", "classes" => "front-post,blog-post,new-blog-post,user-post", "options" => WP_RW__BLOG_POSTS_OPTIONS), "pages" => array("rclass" => "page", "classes" => "page,user-page", "options" => WP_RW__PAGES_OPTIONS), "comments" => array("rclass" => "comment", "classes" => "comment,new-blog-comment,user-comment", "options" => WP_RW__COMMENTS_OPTIONS), "activity_updates" => array("rclass" => "activity-update", "classes" => "activity-update,user-activity-update", "options" => WP_RW__ACTIVITY_UPDATES_OPTIONS), "activity_comments" => array("rclass" => "activity-comment", "classes" => "activity-comment,user-activity-comment", "options" => WP_RW__ACTIVITY_COMMENTS_OPTIONS), "forum_posts" => array("rclass" => "forum-post", "classes" => "forum-post,new-forum-post,user-forum-post", "options" => WP_RW__FORUM_POSTS_OPTIONS), "users" => array("rclass" => "user", "classes" => "user", "options" => WP_RW__FORUM_POSTS_OPTIONS));
$show_any = false;
foreach ($types as $type => $data) {
if (false !== $instance["show_{$type}"]) {
$show_any = true;
break;
}
}
if (false === $show_any) {
// Nothing to show.
return;
}
$details = array("uid" => WP_RW__USER_KEY);
$queries = array();
foreach ($types as $type => $type_data) {
if ($instance["show_{$type}"] && $instance["{$type}_count"] > 0) {
$options = json_decode(RatingWidgetPlugin::_getOption($type_data["options"]));
$queries[$type] = array("rclasses" => $type_data["classes"], "votes" => max(1, (int) $instance["{$type}_min_votes"]), "orderby" => $instance["{$type}_orderby"], "order" => $instance["{$type}_order"], "limit" => (int) $instance["{$type}_count"], "types" => isset($options->type) ? $options->type : "star");
}
}
$details["queries"] = urlencode(json_encode($queries));
$rw_ret_obj = RatingWidgetPlugin::RemoteCall("action/query/ratings.php", $details);
if (false === $rw_ret_obj) {
return;
}
$rw_ret_obj = json_decode($rw_ret_obj);
if (null === $rw_ret_obj || true !== $rw_ret_obj->success) {
return;
}
echo $before_widget;
$title = empty($instance['title']) ? __('Top Rated', WP_RW__ID) : apply_filters('widget_title', $instance['title']);
echo $before_title . $title . $after_title;
$empty = true;
if (count($rw_ret_obj->data) > 0) {
foreach ($rw_ret_obj->data as $type => $ratings) {
if (is_array($ratings) && count($ratings) > 0) {
echo '<div id="rw_top_rated_' . $type . '">';
if ($instance["show_{$type}_title"]) {
/* (1.3.3) - Conditional title display */
$instance["{$type}_title"] = empty($instance["{$type}_title"]) ? ucwords($type) : $instance["{$type}_title"];
echo '<p style="margin: 0;">' . $instance["{$type}_title"] . '</p>';
}
echo '<ul class="rw-top-rated-list">';
foreach ($ratings as $rating) {
$urid = $rating->urid;
$rclass = $types[$type]["rclass"];
RatingWidgetPlugin::QueueRatingData($urid, "", "", $rclass);
switch ($type) {
case "posts":
case "pages":
$id = RatingWidgetPlugin::Urid2PostId($urid);
$post = get_post($id);
$title = trim(strip_tags($post->post_title));
$permalink = get_permalink($post->ID);
break;
case "comments":
$id = RatingWidgetPlugin::Urid2CommentId($urid);
$comment = get_comment($id);
$title = trim(strip_tags($comment->comment_content));
$permalink = get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID;
break;
case "activity_updates":
case "activity_comments":
$id = RatingWidgetPlugin::Urid2ActivityId($urid);
$activity = new bp_activity_activity($id);
$title = trim(strip_tags($activity->content));
$permalink = bp_activity_get_permalink($id);
break;
case "users":
$id = RatingWidgetPlugin::Urid2UserId($urid);
$title = trim(strip_tags(bp_core_get_user_displayname($id)));
$permalink = bp_core_get_user_domain($id);
break;
case "forum_posts":
$id = RatingWidgetPlugin::Urid2ForumPostId($urid);
$forum_post = bp_forums_get_post($id);
$title = trim(strip_tags($forum_post->post_text));
$page = bb_get_page_number($forum_post->post_position);
$permalink = get_topic_link($id, $page) . "#post-{$id}";
break;
}
$short = mb_strlen($title) > 30 ? trim(mb_substr($title, 0, 30)) . "..." : $title;
echo '<li>' . '<a href="' . $permalink . '" title="' . $title . '">' . $short . '</a>' . '<br />' . '<div class="rw-ui-container rw-class-' . $rclass . ' rw-urid-' . $urid . '"></div>' . '</li>';
}
echo "</ul>";
echo "</div>";
$empty = false;
//.........这里部分代码省略.........
示例9: groups_update_group_forum_post
/**
* Update an existing group forum post.
*
* Uses the bundled version of bbPress packaged with BuddyPress.
*
* @since BuddyPress (1.1.0)
*
* @param int $post_id The post ID of the existing forum post.
* @param string $post_text The text for the forum post.
* @param int $topic_id The topic ID of the existing forum topic.
* @param mixed $page The page number where the new forum post should reside.
* Optional.
* @return mixed The forum post ID on success. Boolean false on failure.
*/
function groups_update_group_forum_post($post_id, $post_text, $topic_id, $page = false)
{
$bp = buddypress();
$post_text = apply_filters('group_forum_post_text_before_save', $post_text);
$topic_id = apply_filters('group_forum_post_topic_id_before_save', $topic_id);
$post = bp_forums_get_post($post_id);
$post_id = bp_forums_insert_post(array('post_id' => $post_id, 'post_text' => $post_text, 'post_time' => $post->post_time, 'topic_id' => $topic_id, 'poster_id' => $post->poster_id));
if (empty($post_id)) {
return false;
}
$topic = bp_forums_get_topic_details($topic_id);
$activity_action = sprintf(__('%1$s replied to the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink($post->poster_id), '<a href="' . bp_get_group_permalink(groups_get_current_group()) . 'forum/topic/' . $topic->topic_slug . '">' . esc_attr($topic->topic_title) . '</a>', '<a href="' . bp_get_group_permalink(groups_get_current_group()) . '">' . esc_attr(bp_get_current_group_name()) . '</a>');
$activity_content = bp_create_excerpt($post_text);
$primary_link = bp_get_group_permalink(groups_get_current_group()) . 'forum/topic/' . $topic->topic_slug . '/';
if (!empty($page)) {
$primary_link .= "?topic_page=" . $page;
}
// Get the corresponding activity item
if (bp_is_active('activity')) {
$id = bp_activity_get_activity_id(array('user_id' => $post->poster_id, 'component' => $bp->groups->id, 'type' => 'new_forum_post', 'item_id' => bp_get_current_group_id(), 'secondary_item_id' => $post_id));
}
// Update the entry in activity streams
groups_record_activity(array('id' => $id, 'action' => apply_filters_ref_array('groups_activity_new_forum_post_action', array($activity_action, $post_text, &$topic, &$topic)), 'content' => apply_filters_ref_array('groups_activity_new_forum_post_content', array($activity_content, $post_text, &$topic, &$topic)), 'primary_link' => apply_filters('groups_activity_new_forum_post_primary_link', $primary_link . "#post-" . $post_id), 'type' => 'new_forum_post', 'item_id' => (int) bp_get_current_group_id(), 'user_id' => (int) $post->poster_id, 'secondary_item_id' => $post_id, 'recorded_time' => $post->post_time));
do_action_ref_array('groups_update_group_forum_post', array($post, &$topic));
return $post_id;
}
示例10: forum_post_delete
function forum_post_delete($id, $id2)
{
if (!($post = bp_forums_get_post($id2))) {
return true;
}
// deleting a post don't remove it from db, it just set its status to 1
if (1 == (int) $post->post_status) {
return true;
}
if (!groups_delete_group_forum_post($id2, $post->topic_id)) {
return false;
}
//if it was the first post (topic), then the activity doesn't get delete by bp because is new_forum_topic, instead of new_forum_post
//so we check if it is the first post and then delete the activity
if (function_exists('bp_activity_delete')) {
$first_post = bp_forums_get_topic_posts(array('topic_id' => $post->topic_id, 'post_status' => 'all', 'page' => 1, 'per_page' => 1));
if ($first_post[0]->post_id == $post->post_id) {
bp_activity_delete(array('item_id' => $id, 'secondary_item_id' => $post->topic_id, 'component' => $GLOBALS['bp']->groups->id, 'type' => 'new_forum_topic'));
}
}
return true;
}
示例11: groups_update_group_forum_post
function groups_update_group_forum_post( $post_id, $post_text, $topic_id, $page = false ) {
global $bp;
$post_text = apply_filters( 'group_forum_post_text_before_save', $post_text );
$topic_id = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id );
$post = bp_forums_get_post( $post_id );
if ( $post_id = bp_forums_insert_post( array( 'post_id' => $post_id, 'post_text' => $post_text, 'post_time' => $post->post_time, 'topic_id' => $topic_id, 'poster_id' => $post->poster_id ) ) ) {
$topic = bp_forums_get_topic_details( $topic_id );
$activity_action = sprintf( __( '%s posted on the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $post->poster_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' );
$activity_content = bp_create_excerpt( $post_text );
$primary_link = bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/';
if ( $page )
$primary_link .= "?topic_page=" . $page;
/* Fetch an existing entry and update if one exists. */
if ( function_exists( 'bp_activity_get_activity_id' ) )
$id = bp_activity_get_activity_id( array( 'user_id' => $post->poster_id, 'component' => $bp->groups->id, 'type' => 'new_forum_post', 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post_id ) );
/* Update the entry in activity streams */
groups_record_activity( array(
'id' => $id,
'action' => apply_filters( 'groups_activity_new_forum_post_action', $activity_action, $post_text, &$topic, &$forum_post ),
'content' => apply_filters( 'groups_activity_new_forum_post_content', $activity_content, $post_text, &$topic, &$forum_post ),
'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', $primary_link . "#post-" . $post_id ),
'type' => 'new_forum_post',
'item_id' => (int)$bp->groups->current_group->id,
'user_id' => (int)$post->poster_id,
'secondary_item_id' => $post_id,
'recorded_time' => $post->post_time
) );
do_action( 'groups_update_group_forum_post', &$post, &$topic );
return $post_id;
}
return false;
}
示例12: bp_get_the_topic_latest_post_excerpt
function bp_get_the_topic_latest_post_excerpt()
{
global $forum_template;
$post = bp_forums_get_post($forum_template->topic->topic_last_post_id);
return apply_filters('bp_get_the_topic_latest_post_excerpt', $post['post_text']);
}
示例13: groups_format_activity
function groups_format_activity($item_id, $user_id, $action, $secondary_item_id = false, $for_secondary_user = false)
{
global $bp;
switch ($action) {
case 'joined_group':
$group = new BP_Groups_Group($item_id, false, false);
if (!$group) {
return false;
}
$user_link = bp_core_get_userlink($user_id);
$group_link = bp_get_group_permalink($group);
return array('primary_link' => $group_link, 'content' => apply_filters('bp_groups_joined_group_activity', sprintf(__('%s joined the group %s', 'buddypress'), $user_link, '<a href="' . $group_link . '">' . $group->name . '</a>') . ' <span class="time-since">%s</span>', $user_link, $group_link, $group->name));
break;
case 'created_group':
$group = new BP_Groups_Group($item_id, false, false);
if (!$group) {
return false;
}
$user_link = bp_core_get_userlink($user_id);
$group_link = bp_get_group_permalink($group);
return array('primary_link' => $group_link, 'content' => apply_filters('bp_groups_created_group_activity', sprintf(__('%s created the group %s', 'buddypress'), $user_link, '<a href="' . $group_link . '">' . $group->name . '</a>') . ' <span class="time-since">%s</span>', $user_link, $group_link, $group->name));
break;
case 'new_wire_post':
$wire_post = new BP_Wire_Post($bp->groups->table_name_wire, $item_id);
$group = new BP_Groups_Group($wire_post->item_id, false, false);
if (!$group || !$wire_post || !$wire_post->content) {
return false;
}
$user_link = bp_core_get_userlink($user_id);
$group_link = bp_get_group_permalink($group);
$post_excerpt = bp_create_excerpt($wire_post->content);
$content = sprintf(__('%s wrote on the wire of the group %s', 'buddypress'), $user_link, '<a href="' . $group_link . '">' . $group->name . '</a>') . ' <span class="time-since">%s</span>';
$content .= '<blockquote>' . $post_excerpt . '</blockquote>';
$content = apply_filters('bp_groups_new_wire_post_activity', $content, $user_link, $group_link, $group->name, $post_excerpt);
return array('primary_link' => $group_link, 'content' => $content);
break;
case 'new_forum_post':
if (function_exists('bp_forums_setup')) {
$group = new BP_Groups_Group($item_id, false, false);
$forum_post = bp_forums_get_post($secondary_item_id);
$forum_topic = bp_forums_get_topic_details($forum_post['topic_id']);
if (!$group || !$forum_post || !$forum_topic) {
return false;
}
$user_link = bp_core_get_userlink($user_id);
$group_link = bp_get_group_permalink($group);
$post_content = apply_filters('bp_the_topic_post_content', bp_create_excerpt(stripslashes($forum_post['post_text']), 55, false));
$content = sprintf(__('%s posted on the forum topic %s in the group %s:', 'buddypress'), $user_link, '<a href="' . $group_link . '/forum/topic/' . $forum_topic['topic_id'] . '">' . $forum_topic['topic_title'] . '</a>', '<a href="' . $group_link . '">' . $group->name . '</a>') . ' <span class="time-since">%s</span>';
$content .= '<blockquote>' . $post_content . '</blockquote>';
$content = apply_filters('bp_groups_new_forum_post_activity', $content, $user_link, $group_link, $forum_topic['topic_id'], $forum_topic['topic_title'], $group_link, $group->name, $post_content);
return array('primary_link' => $group_link, 'content' => $content);
}
break;
case 'new_forum_topic':
if (function_exists('bp_forums_setup')) {
$group = new BP_Groups_Group($item_id, false, false);
$forum_topic = bp_forums_get_topic_details($secondary_item_id);
$forum_post = bp_forums_get_post($forum_topic['topic_last_post_id']);
if (!$group || !$forum_post || !$forum_topic) {
return false;
}
$user_link = bp_core_get_userlink($user_id);
$group_link = bp_get_group_permalink($group);
$post_content = apply_filters('bp_the_topic_post_content', bp_create_excerpt(stripslashes($forum_post['post_text']), 55, false));
$content = sprintf(__('%s created the forum topic %s in the group %s:', 'buddypress'), $user_link, '<a href="' . $group_link . '/forum/topic/' . $forum_topic['topic_id'] . '">' . $forum_topic['topic_title'] . '</a>', '<a href="' . $group_link . '">' . $group->name . '</a>') . ' <span class="time-since">%s</span>';
$content .= '<blockquote>' . $post_content . '</blockquote>';
$content = apply_filters('bp_groups_new_forum_topic_activity', $content, $user_link, $group_link, $forum_topic['topic_id'], $forum_topic['topic_title'], $group_link, $group->name, $post_content);
return array('primary_link' => $group_link, 'content' => $content);
}
break;
}
do_action('groups_format_activity', $action, $item_id, $user_id, $action, $secondary_item_id, $for_secondary_user);
return false;
}
示例14: GetTopRated
public function GetTopRated()
{
$rw_ret_obj = $this->GetTopRatedData(array('posts', 'pages'));
if (false === $rw_ret_obj || count($rw_ret_obj->data) == 0) {
return '';
}
$html = '<div id="rw_top_rated_page">';
foreach ($rw_ret_obj->data as $type => $ratings) {
if (is_array($ratings) && count($ratings) > 0) {
$html .= '<div id="rw_top_rated_page_' . $type . '" class="rw-wp-ui-top-rated-list-container">';
if ($instance["show_{$type}_title"]) {
$instance["{$type}_title"] = empty($instance["{$type}_title"]) ? ucwords($type) : $instance["{$type}_title"];
$html .= '<p style="margin: 0;">' . $instance["{$type}_title"] . '</p>';
}
$html .= '<ul class="rw-wp-ui-top-rated-list">';
$count = 1;
foreach ($ratings as $rating) {
$urid = $rating->urid;
$rclass = $types[$type]["rclass"];
$thumbnail = '';
ratingwidget()->QueueRatingData($urid, "", "", $rclass);
switch ($type) {
case "posts":
case "pages":
$id = RatingWidgetPlugin::Urid2PostId($urid);
$post = get_post($id);
$title = trim(strip_tags($post->post_title));
$excerpt = $this->GetPostExcerpt($post, 15);
$permalink = get_permalink($post->ID);
$thumbnail = $this->GetPostFeaturedImage($post->ID);
break;
case "comments":
$id = RatingWidgetPlugin::Urid2CommentId($urid);
$comment = get_comment($id);
$title = trim(strip_tags($comment->comment_content));
$permalink = get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID;
break;
case "activity_updates":
case "activity_comments":
$id = RatingWidgetPlugin::Urid2ActivityId($urid);
$activity = new bp_activity_activity($id);
$title = trim(strip_tags($activity->content));
$permalink = bp_activity_get_permalink($id);
break;
case "users":
$id = RatingWidgetPlugin::Urid2UserId($urid);
$title = trim(strip_tags(bp_core_get_user_displayname($id)));
$permalink = bp_core_get_user_domain($id);
break;
case "forum_posts":
$id = RatingWidgetPlugin::Urid2ForumPostId($urid);
$forum_post = bp_forums_get_post($id);
$title = trim(strip_tags($forum_post->post_text));
$page = bb_get_page_number($forum_post->post_position);
$permalink = get_topic_link($id, $page) . "#post-{$id}";
break;
}
$short = mb_strlen($title) > 30 ? trim(mb_substr($title, 0, 30)) . "..." : $title;
$html .= '
<li class="rw-wp-ui-top-rated-list-item">
<div>
<b class="rw-wp-ui-top-rated-list-count">' . $count . '</b>
<img class="rw-wp-ui-top-rated-list-item-thumbnail" src="' . $thumbnail . '" alt="" />
<div class="rw-wp-ui-top-rated-list-item-data">
<div>
<a class="rw-wp-ui-top-rated-list-item-title" href="' . $permalink . '" title="' . $title . '">' . $short . '</a>
<div class="rw-ui-container rw-class-' . $rclass . ' rw-urid-' . $urid . ' rw-size-small rw-prop-readOnly-true"></div>
</div>
<p class="rw-wp-ui-top-rated-list-item-excerpt">' . $excerpt . '</p>
</div>
</div>
</li>';
$count++;
}
$html .= "</ul>";
$html .= "</div>";
}
}
// Set a flag that the widget is loaded.
RatingWidgetPlugin::TopRatedWidgetLoaded();
ob_start();
?>
<script type="text/javascript">
// Hook render widget.
if (typeof(RW_HOOK_READY) === "undefined"){ RW_HOOK_READY = []; }
RW_HOOK_READY.push(function(){
RW._foreach(RW._getByClassName("rw-wp-ui-top-rated-list", "ul"), function(list){
RW._foreach(RW._getByClassName("rw-ui-container", "div", list), function(rating){
// Deactivate rating.
RW._Class.remove(rating, "rw-active");
var i = (RW._getByClassName("rw-report-link", "a", rating))[0];
if (RW._is(i)){ i.parentNode.removeChild(i); }
});
});
});
</script>
<?php
$html .= ob_get_clean();
$html .= '</div>';
return $html;
//.........这里部分代码省略.........
示例15: bp_forums_insert_post
function bp_forums_insert_post( $args = '' ) {
global $bp;
do_action( 'bbpress_init' );
$defaults = array(
'post_id' => false,
'topic_id' => false,
'post_text' => '',
'post_time' => date( 'Y-m-d H:i:s' ),
'poster_id' => $bp->loggedin_user->id, // accepts ids or names
'poster_ip' => $_SERVER['REMOTE_ADDR'],
'post_status' => 0, // use bb_delete_post() instead
'post_position' => false
);
$r = wp_parse_args( $args, $defaults );
extract( $r, EXTR_SKIP );
if ( !$post = bp_forums_get_post( $post_id ) )
$post_id = false;
if ( !isset( $topic_id ) )
$topic_id = $post->topic_id;
if ( empty( $post_text ) )
$post_text = $post->post_text;
if ( !isset( $post_time ) )
$post_time = $post->post_time;
if ( !isset( $post_position ) )
$post_position = $post->post_position;
$post_id = bb_insert_post( array( 'post_id' => $post_id, 'topic_id' => $topic_id, 'post_text' => stripslashes( trim( $post_text ) ), 'post_time' => $post_time, 'poster_id' => $poster_id, 'poster_ip' => $poster_ip, 'post_status' => $post_status, 'post_position' => $post_position ) );
if ( $post_id )
do_action( 'bp_forums_new_post', $post_id );
return $post_id;
}