当前位置: 首页>>代码示例>>PHP>>正文


PHP bp_create_excerpt函数代码示例

本文整理汇总了PHP中bp_create_excerpt函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_create_excerpt函数的具体用法?PHP bp_create_excerpt怎么用?PHP bp_create_excerpt使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了bp_create_excerpt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: bp_blogs_record_activity

function bp_blogs_record_activity($args = '')
{
    global $bp;
    if (!bp_is_active('activity')) {
        return false;
    }
    $defaults = array('user_id' => bp_loggedin_user_id(), 'action' => '', 'content' => '', 'primary_link' => '', 'component' => $bp->blogs->id, 'type' => false, 'item_id' => false, 'secondary_item_id' => false, 'recorded_time' => bp_core_current_time(), 'hide_sitewide' => false);
    $r = wp_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    // Remove large images and replace them with just one image thumbnail
    if (bp_is_active('activity') && !empty($content)) {
        $content = bp_activity_thumbnail_content_images($content, $primary_link);
    }
    if (!empty($action)) {
        $action = apply_filters('bp_blogs_record_activity_action', $action);
    }
    if (!empty($content)) {
        $content = apply_filters('bp_blogs_record_activity_content', bp_create_excerpt($content), $content);
    }
    // Check for an existing entry and update if one exists.
    $id = bp_activity_get_activity_id(array('user_id' => $user_id, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id));
    return bp_activity_add(array('id' => $id, 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide));
}
开发者ID:newington,项目名称:buddypress,代码行数:23,代码来源:bp-blogs-activity.php

示例2: mark_activity_private

 /**
  * Add or edit activities so that they are private
  *
  * @package WP Idea Stream
  * @subpackage buddypress/activity
  *
  * @since 2.0.0
  *
  * @param  int     $idea_id     the idea ID
  * @param  WP_Post $idea        the idea object
  * @uses   get_post()           to get the idea object if not set
  * @uses   WP_Idea_Stream_Activity->get_idea_and_comments() to get activities to manage
  * @uses   self::bulk_edit_activity to mark activities as private
  * @uses   get_current_blog_id() to get the current blog ID
  * @uses   buddypress() to get BuddyPress instance
  * @uses   add_query_arg(), get_home_url() to build the link to the idea.
  * @uses   bp_activity_thumbnail_content_images() to take content, remove images, and replace them with a single thumbnail image
  * @uses   bp_create_excerpt() to generate the content of the activity
  * @uses   bp_activity_add() to save the private activity
  * @uses   apply_filters() call 'bp_blogs_record_activity_content' to apply the filters on blog posts for private ideas
  *                         call 'wp_idea_stream_buddypress_activity_post_private' to override the private activity args
  */
 public function mark_activity_private($idea_id = 0, $idea = null)
 {
     if (empty($idea)) {
         $idea = get_post($idea_id);
     }
     // Get activities
     $activities = $this->get_idea_and_comments($idea_id, $idea->post_status);
     // If activities, then update their visibility status
     if (!empty($activities)) {
         // Do not update activities if they all are already marked as private.
         if (!empty($this->private_activities[$idea_id]) && !array_diff($activities, $this->private_activities[$idea_id])) {
             return;
         }
         self::bulk_edit_activity($activities, 1);
         // Otherwise, we need to create the activity
     } else {
         /**
          * Here we can't use bp_blogs_record_activity() as we need
          * to allow the groups component to eventually override the
          * component argument. As a result, we need to set a fiew vars
          */
         $bp = buddypress();
         $bp_activity_actions = new stdClass();
         $bp_activity_actions = $bp->activity->actions;
         // First the item id: the current blog
         $blog_id = get_current_blog_id();
         // Then all needed args except content
         $args = array('component' => buddypress()->blogs->id, 'type' => 'new_' . $this->post_type, 'primary_link' => add_query_arg('p', $idea_id, trailingslashit(get_home_url($blog_id))), 'user_id' => (int) $idea->post_author, 'item_id' => $blog_id, 'secondary_item_id' => $idea_id, 'recorded_time' => $idea->post_date_gmt, 'hide_sitewide' => 1);
         // The content will require to use functions that bp_blogs_record_activity()
         // is using to format it.
         $content = '';
         if (!empty($idea->post_content)) {
             $content = bp_activity_thumbnail_content_images($idea->post_content, $args['primary_link'], $args);
             $content = bp_create_excerpt($content);
         }
         // Add the content to the activity args
         $args['content'] = $content;
         /**
          * Filter is used internally to override ideas posted within a private or hidden group
          *
          * @param array   $args    the private activity arguments
          * @param WP_Post $idea    the idea object
          */
         $args = apply_filters('wp_idea_stream_buddypress_activity_post_private', $args, $idea);
         // Define the corresponding index
         $activity_type = $args['type'];
         $activity_component = $args['component'];
         // override the activity type
         $args['type'] = $this->activity_actions[$activity_type]->type;
         if (empty($bp->activity->actions->{$activity_component}->{$activity_type}['format_callback'])) {
             bp_activity_set_action($this->activity_actions[$activity_type]->component, $this->activity_actions[$activity_type]->type, $this->activity_actions[$activity_type]->admin_caption, $this->activity_actions[$activity_type]->action_callback);
         }
         /**
          * Finally publish the private activity
          * and reset BuddyPress activity actions
          */
         $private_activity_id = bp_activity_add($args);
         // Check for comments
         if (!empty($private_activity_id)) {
             $activities = $this->get_idea_and_comments($idea_id, $idea->post_status);
             $activities = array_diff($activities, array($private_activity_id));
             // Update comments visibility
             if (!empty($activities)) {
                 $test = self::bulk_edit_activity($activities, 1);
             }
         }
         $bp->activity->actions = $bp_activity_actions;
         // Reset edited activities
         $this->edit_activities = array();
     }
 }
开发者ID:BoweFrankema,项目名称:wp-idea-stream,代码行数:93,代码来源:activity.php

示例3: bp_get_group_description_excerpt

/**
 * Get an excerpt of a group description.
 *
 * @param object $group Optional. The group being referenced. Defaults
 *        to the group currently being iterated on in the groups loop.
 * @return string Excerpt.
 */
function bp_get_group_description_excerpt($group = false)
{
    global $groups_template;
    if (empty($group)) {
        $group =& $groups_template->group;
    }
    return apply_filters('bp_get_group_description_excerpt', bp_create_excerpt($group->description), $group);
}
开发者ID:kd5ytx,项目名称:Empirical-Wordpress,代码行数:15,代码来源:bp-groups-template.php

示例4: bp_get_group_description_excerpt

/**
 * Get an excerpt of a group description.
 *
 * @since 1.0.0
 *
 * @param object|bool $group Optional. The group being referenced.
 *                           Defaults to the group currently being
 *                           iterated on in the groups loop.
 * @return string Excerpt.
 */
function bp_get_group_description_excerpt($group = false)
{
    global $groups_template;
    if (empty($group)) {
        $group =& $groups_template->group;
    }
    /**
     * Filters the excerpt of a group description.
     *
     * @since 1.0.0
     *
     * @param string $value Excerpt of a group description.
     * @param object $group Object for group whose description is made into an excerpt.
     */
    return apply_filters('bp_get_group_description_excerpt', bp_create_excerpt($group->description), $group);
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:26,代码来源:bp-groups-template.php

示例5: bp_blogs_record_activity

/**
 * Record blog-related activity to the activity stream.
 *
 * @since BuddyPress (1.0.0)
 *
 * @see bp_activity_add() for description of parameters.
 * @global object $bp The BuddyPress global settings object.
 *
 * @param array $args {
 *     See {@link bp_activity_add()} for complete description of arguments.
 *     The arguments listed here have different default values from
 *     bp_activity_add().
 *     @type string $component Default: 'blogs'.
 * }
 * @return int|bool On success, returns the activity ID. False on failure.
 */
function bp_blogs_record_activity( $args = '' ) {
	global $bp;

	// Bail if activity is not active
	if ( ! bp_is_active( 'activity' ) ) {
		return false;
	}

	$defaults = array(
		'user_id'           => bp_loggedin_user_id(),
		'action'            => '',
		'content'           => '',
		'primary_link'      => '',
		'component'         => $bp->blogs->id,
		'type'              => false,
		'item_id'           => false,
		'secondary_item_id' => false,
		'recorded_time'     => bp_core_current_time(),
		'hide_sitewide'     => false
	);

	$r = wp_parse_args( $args, $defaults );

	// Remove large images and replace them with just one image thumbnail
	if ( ! empty( $r['content'] ) ) {
		$r['content'] = bp_activity_thumbnail_content_images( $r['content'], $r['primary_link'], $r );
	}

	if ( ! empty( $r['action'] ) ) {

		/**
		 * Filters the action associated with activity for activity stream.
		 *
		 * @since BuddyPress (1.2.0)
		 *
		 * @param string $value Action for the activity stream.
		 */
		$r['action'] = apply_filters( 'bp_blogs_record_activity_action', $r['action'] );
	}

	if ( ! empty( $r['content'] ) ) {

		/**
		 * Filters the content associated with activity for activity stream.
		 *
		 * @since BuddyPress (1.2.0)
		 *
		 * @param string $value Generated excerpt from content for the activity stream.
		 * @param string $value Content for the activity stream.
		 * @param array  $r     Array of arguments used for the activity stream item.
		 */
		$r['content'] = apply_filters( 'bp_blogs_record_activity_content', bp_create_excerpt( $r['content'] ), $r['content'], $r );
	}

	// Check for an existing entry and update if one exists.
	$id = bp_activity_get_activity_id( array(
		'user_id'           => $r['user_id'],
		'component'         => $r['component'],
		'type'              => $r['type'],
		'item_id'           => $r['item_id'],
		'secondary_item_id' => $r['secondary_item_id'],
	) );

	return bp_activity_add( array( 'id' => $id, 'user_id' => $r['user_id'], 'action' => $r['action'], 'content' => $r['content'], 'primary_link' => $r['primary_link'], 'component' => $r['component'], 'type' => $r['type'], 'item_id' => $r['item_id'], 'secondary_item_id' => $r['secondary_item_id'], 'recorded_time' => $r['recorded_time'], 'hide_sitewide' => $r['hide_sitewide'] ) );
}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:81,代码来源:bp-blogs-activity.php

示例6: bp_get_message_thread_excerpt

function bp_get_message_thread_excerpt()
{
    global $messages_template;
    return apply_filters('bp_get_message_thread_excerpt', bp_create_excerpt($messages_template->thread->last_message_message, 20));
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:5,代码来源:bp-messages-templatetags.php

示例7: reply_create

 /**
  * Record an activity stream entry when a reply is created
  *
  * @since bbPress (r3395)
  * @param int $topic_id
  * @param int $forum_id
  * @param array $anonymous_data
  * @param int $topic_author_id
  * @uses bbp_get_reply_id()
  * @uses bbp_get_topic_id()
  * @uses bbp_get_forum_id()
  * @uses bbp_get_user_profile_link()
  * @uses bbp_get_reply_url()
  * @uses bbp_get_reply_content()
  * @uses bbp_get_topic_permalink()
  * @uses bbp_get_topic_title()
  * @uses bbp_get_forum_permalink()
  * @uses bbp_get_forum_title()
  * @uses bp_create_excerpt()
  * @uses apply_filters()
  * @return Bail early if topic is by anonywous user
  */
 public function reply_create($reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author_id)
 {
     // Do not log activity of anonymous users
     if (!empty($anonymous_data)) {
         return;
     }
     // Bail if site is private
     if (!bbp_is_site_public()) {
         return;
     }
     // Validate activity data
     $user_id = $reply_author_id;
     $reply_id = bbp_get_reply_id($reply_id);
     $topic_id = bbp_get_topic_id($topic_id);
     $forum_id = bbp_get_forum_id($forum_id);
     // Bail if user is not active
     if (bbp_is_user_inactive($user_id)) {
         return;
     }
     // Bail if reply is not published
     if (!bbp_is_reply_published($reply_id)) {
         return;
     }
     // Setup links for activity stream
     $user_link = bbp_get_user_profile_link($user_id);
     // Reply
     $reply_url = bbp_get_reply_url($reply_id);
     $reply_content = get_post_field('post_content', $reply_id, 'raw');
     // Topic
     $topic_permalink = bbp_get_topic_permalink($topic_id);
     $topic_title = get_post_field('post_title', $topic_id, 'raw');
     $topic_link = '<a href="' . $topic_permalink . '" title="' . $topic_title . '">' . $topic_title . '</a>';
     // Forum
     $forum_permalink = bbp_get_forum_permalink($forum_id);
     $forum_title = get_post_field('post_title', $forum_id, 'raw');
     $forum_link = '<a href="' . $forum_permalink . '" title="' . $forum_title . '">' . $forum_title . '</a>';
     // Activity action & text
     $activity_text = sprintf(__('%1$s replied to the topic %2$s in the forum %3$s', 'bbpress'), $user_link, $topic_link, $forum_link);
     $activity_action = apply_filters('bbp_activity_reply_create', $activity_text, $user_id, $reply_id, $topic_id);
     $activity_content = apply_filters('bbp_activity_reply_create_excerpt', bp_create_excerpt($reply_content), $reply_content);
     // Compile the activity stream results
     $activity = array('id' => $this->get_activity_id($reply_id), 'user_id' => $user_id, 'action' => $activity_action, 'content' => $activity_content, 'primary_link' => $reply_url, 'type' => $this->reply_create, 'item_id' => $reply_id, 'secondary_item_id' => $topic_id, 'recorded_time' => get_post_time('Y-m-d H:i:s', true, $reply_id), 'hide_sitewide' => !bbp_is_forum_public($forum_id, false));
     // Record the activity
     $activity_id = $this->record_activity($activity);
     // Add the activity entry ID as a meta value to the reply
     if (!empty($activity_id)) {
         update_post_meta($reply_id, '_bbp_activity_id', $activity_id);
     }
 }
开发者ID:hscale,项目名称:webento,代码行数:71,代码来源:activity.php

示例8: bp_get_group_description_excerpt

	function bp_get_group_description_excerpt( $group = false ) {
		global $groups_template;

		if ( !$group )
			$group =& $groups_template->group;

		return apply_filters( 'bp_get_group_description_excerpt', bp_create_excerpt( $group->description, 20 ) );
	}
开发者ID:n-sane,项目名称:zaroka,代码行数:8,代码来源:bp-groups-templatetags.php

示例9: bp_activity_create_summary


//.........这里部分代码省略.........
    /**
     * Filter the arguments passed to the media extractor when creating an Activity summary.
     *
     * @since 2.3.0
     *
     * @param array              $args      Array of bespoke data for the media extractor.
     * @param string             $content   The content of the activity item.
     * @param array              $activity  The data passed to bp_activity_add() or the values from an Activity obj.
     * @param BP_Media_Extractor $extractor The media extractor object.
     */
    $args = apply_filters('bp_activity_create_summary_extractor_args', $args, $content, $activity, $extractor);
    // Extract media information from the $content.
    $media = $extractor->extract($content, BP_Media_Extractor::ALL, $args);
    // If we converted $content to an object earlier, flip it back to a string.
    if (is_a($content, 'WP_Post')) {
        $content = $content->post_content;
    }
    $para_count = substr_count(strtolower(wpautop($content)), '<p>');
    $has_audio = !empty($media['has']['audio']) && $media['has']['audio'];
    $has_videos = !empty($media['has']['videos']) && $media['has']['videos'];
    $has_feat_image = !empty($media['has']['featured_images']) && $media['has']['featured_images'];
    $has_galleries = !empty($media['has']['galleries']) && $media['has']['galleries'];
    $has_images = !empty($media['has']['images']) && $media['has']['images'];
    $has_embeds = false;
    // Embeds must be subtracted from the paragraph count.
    if (!empty($media['has']['embeds'])) {
        $has_embeds = $media['has']['embeds'] > 0;
        $para_count -= count($media['has']['embeds']);
    }
    $extracted_media = array();
    $use_media_type = '';
    $image_source = '';
    // If it's a short article and there's an embed/audio/video, use it.
    if ($para_count <= 3) {
        if ($has_embeds) {
            $use_media_type = 'embeds';
        } elseif ($has_audio) {
            $use_media_type = 'audio';
        } elseif ($has_videos) {
            $use_media_type = 'videos';
        }
    }
    // If not, or in any other situation, try to use an image.
    if (!$use_media_type && $has_images) {
        $use_media_type = 'images';
        $image_source = 'html';
        // Featured Image > Galleries > inline <img>.
        if ($has_feat_image) {
            $image_source = 'featured_images';
        } elseif ($has_galleries) {
            $image_source = 'galleries';
        }
    }
    // Extract an item from the $media results.
    if ($use_media_type) {
        if ($use_media_type === 'images') {
            $extracted_media = wp_list_filter($media[$use_media_type], array('source' => $image_source));
            $extracted_media = array_shift($extracted_media);
        } else {
            $extracted_media = array_shift($media[$use_media_type]);
        }
        /**
         * Filter the results of the media extractor when creating an Activity summary.
         *
         * @since 2.3.0
         *
         * @param array  $extracted_media Extracted media item. See {@link BP_Media_Extractor::extract()} for format.
         * @param string $content         Content of the activity item.
         * @param array  $activity        The data passed to bp_activity_add() or the values from an Activity obj.
         * @param array  $media           All results from the media extraction.
         *                                See {@link BP_Media_Extractor::extract()} for format.
         * @param string $use_media_type  The kind of media item that was preferentially extracted.
         * @param string $image_source    If $use_media_type was "images", the preferential source of the image.
         *                                Otherwise empty.
         */
        $extracted_media = apply_filters('bp_activity_create_summary_extractor_result', $extracted_media, $content, $activity, $media, $use_media_type, $image_source);
    }
    // Generate a text excerpt for this activity item (and remove any oEmbeds URLs).
    $summary = strip_shortcodes(html_entity_decode(strip_tags($content)));
    $summary = bp_create_excerpt(preg_replace('#^\\s*(https?://[^\\s"]+)\\s*$#im', '', $summary));
    if ($use_media_type === 'embeds') {
        $summary .= PHP_EOL . PHP_EOL . $extracted_media['url'];
    } elseif ($use_media_type === 'images') {
        $summary .= sprintf(' <img src="%s">', esc_url($extracted_media['url']));
    } elseif (in_array($use_media_type, array('audio', 'videos'), true)) {
        $summary .= PHP_EOL . PHP_EOL . $extracted_media['original'];
        // Full shortcode.
    }
    /**
     * Filters the newly-generated summary for the activity item.
     *
     * @since 2.3.0
     *
     * @param string $summary         Activity summary HTML.
     * @param string $content         Content of the activity item.
     * @param array  $activity        The data passed to bp_activity_add() or the values from an Activity obj.
     * @param array  $extracted_media Media item extracted. See {@link BP_Media_Extractor::extract()} for format.
     */
    return apply_filters('bp_activity_create_summary', $summary, $content, $activity, $extracted_media);
}
开发者ID:humanmade,项目名称:BuddyPress,代码行数:101,代码来源:bp-activity-functions.php

示例10: bp_get_activity_feed_item_title

/**
 * Returns the activity feed item title
 *
 * @since 1.0.0
 *
 * @global object $activities_template {@link BP_Activity_Template}
 * @uses ent2ncr()
 * @uses convert_chars()
 * @uses bp_create_excerpt()
 * @uses apply_filters() To call the 'bp_get_activity_feed_item_title' hook
 *
 * @return string $title The activity feed item title
 */
function bp_get_activity_feed_item_title()
{
    global $activities_template;
    if (!empty($activities_template->activity->action)) {
        $content = $activities_template->activity->action;
    } else {
        $content = $activities_template->activity->content;
    }
    $content = explode('<span', $content);
    $title = strip_tags(ent2ncr(trim(convert_chars($content[0]))));
    if (':' == substr($title, -1)) {
        $title = substr($title, 0, -1);
    }
    if ('activity_update' == $activities_template->activity->type) {
        $title .= ': ' . strip_tags(ent2ncr(trim(convert_chars(bp_create_excerpt($activities_template->activity->content, 70, array('ending' => " [&#133;]"))))));
    }
    return apply_filters('bp_get_activity_feed_item_title', $title);
}
开发者ID:nxtclass,项目名称:NXTClass,代码行数:31,代码来源:bp-activity-template.php

示例11: bp_get_message_thread_excerpt

function bp_get_message_thread_excerpt()
{
    global $messages_template;
    return apply_filters('bp_get_message_thread_excerpt', strip_tags(bp_create_excerpt($messages_template->thread->last_message_content, 75)));
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:5,代码来源:bp-messages-template.php

示例12: bp_activity_truncate_entry

/**
 * Truncates long activity entries when viewed in activity streams
 *
 * @since 1.5.0
 *
 * @param $text The original activity entry text
 *
 * @uses bp_is_single_activity()
 * @uses apply_filters() To call the 'bp_activity_excerpt_append_text' hook
 * @uses apply_filters() To call the 'bp_activity_excerpt_length' hook
 * @uses bp_create_excerpt()
 * @uses bp_get_activity_id()
 * @uses bp_get_activity_thread_permalink()
 * @uses apply_filters() To call the 'bp_activity_truncate_entry' hook
 *
 * @return string $excerpt The truncated text
 */
function bp_activity_truncate_entry($text)
{
    global $activities_template;
    // The full text of the activity update should always show on the single activity screen
    if (bp_is_single_activity()) {
        return $text;
    }
    $append_text = apply_filters('bp_activity_excerpt_append_text', __('[Read more]', 'buddypress'));
    $excerpt_length = apply_filters('bp_activity_excerpt_length', 358);
    // Run the text through the excerpt function. If it's too short, the original text will be
    // returned.
    $excerpt = bp_create_excerpt($text, $excerpt_length, array('ending' => __('&hellip;', 'buddypress')));
    // If the text returned by bp_create_excerpt() is different from the original text (ie it's
    // been truncated), add the "Read More" link.
    if ($excerpt != $text) {
        $id = !empty($activities_template->activity->current_comment->id) ? 'acomment-read-more-' . $activities_template->activity->current_comment->id : 'activity-read-more-' . bp_get_activity_id();
        $excerpt = sprintf('%1$s<span class="activity-read-more" id="%2$s"><a href="%3$s" rel="nofollow">%4$s</a></span>', $excerpt, $id, bp_get_activity_thread_permalink(), $append_text);
    }
    return apply_filters('bp_activity_truncate_entry', $excerpt, $text, $append_text);
}
开发者ID:nxtclass,项目名称:NXTClass,代码行数:37,代码来源:bp-activity-filters.php

示例13: 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;
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:40,代码来源:bp-groups-forums.php

示例14: bp_album_get_picture_desc_truncate

function bp_album_get_picture_desc_truncate($words = 55)
{
    global $pictures_template;
    $exc = bp_create_excerpt($pictures_template->picture->description, $words, true);
    return apply_filters('bp_album_get_picture_desc_truncate', $exc, $pictures_template->picture->description, $words);
}
开发者ID:narabikke,项目名称:wordpress,代码行数:6,代码来源:bpa.template.tags.php

示例15: bp_groupblogs_fetch_group_feeds

 /**
  * Function to fetch group feeds and save RSS entries as BP activity items.
  *
  * @param int $group_id The group ID.
  */
 function bp_groupblogs_fetch_group_feeds($group_id = false)
 {
     if (empty($group_id)) {
         $group_id = bp_get_current_group_id();
     }
     if ($group_id == bp_get_current_group_id()) {
         $group = groups_get_current_group();
     } else {
         $group = new BP_Groups_Group($group_id);
     }
     if (!$group) {
         return false;
     }
     $group_blogs = groups_get_groupmeta($group_id, 'blogfeeds');
     $items = array();
     foreach ((array) $group_blogs as $feed_url) {
         $feed_url = trim($feed_url);
         if (empty($feed_url)) {
             continue;
         }
         // Make sure the feed is accessible
         $test = wp_remote_get($feed_url);
         if (is_wp_error($test)) {
             continue;
         }
         try {
             $rss = new SimpleXmlElement($test['body']);
         } catch (Exception $e) {
             continue;
         }
         $rss = fetch_feed(trim($feed_url));
         if (!is_wp_error($rss)) {
             $maxitems = $rss->get_item_quantity(10);
             $rss_items = $rss->get_items(0, $maxitems);
             foreach ($rss_items as $item) {
                 $key = $item->get_date('U');
                 $items[$key]['title'] = $item->get_title();
                 $items[$key]['subtitle'] = $item->get_title();
                 //$items[$key]['author'] = $item->get_author()->get_name();
                 $items[$key]['blogname'] = $item->get_feed()->get_title();
                 $items[$key]['link'] = $item->get_permalink();
                 $items[$key]['blogurl'] = $item->get_feed()->get_link();
                 $items[$key]['description'] = $item->get_description();
                 $items[$key]['source'] = $item->get_source();
                 $items[$key]['copyright'] = $item->get_copyright();
                 $items[$key]['primary_link'] = $item->get_link();
                 $items[$key]['guid'] = $item->get_id();
                 $items[$key]['feedurl'] = $feed_url;
             }
         }
     }
     if (!empty($items)) {
         ksort($items);
         $items = array_reverse($items, true);
     } else {
         return false;
     }
     /* Set the visibility */
     $hide_sitewide = 'public' != $group->status ? true : false;
     /* Record found blog posts in activity streams */
     foreach ((array) $items as $post_date => $post) {
         $activity_action = sprintf(__('Blog: %s from %s in the group %s', 'bp-groups-externalblogs'), '<a class="feed-link" href="' . esc_attr($post['link']) . '">' . esc_attr($post['title']) . '</a>', '<a class="feed-author" href="' . esc_attr($post['blogurl']) . '">' . esc_attr($post['blogname']) . '</a>', '<a href="' . bp_get_group_permalink($group) . '">' . esc_attr($group->name) . '</a>');
         $activity_content = '<div>' . strip_tags(bp_create_excerpt($post['description'], 175)) . '</div>';
         $activity_content = apply_filters('bp_groupblogs_activity_content', $activity_content, $post, $group);
         /* Fetch an existing activity_id if one exists. */
         // backpat
         $id = bp_activity_get_activity_id(array('user_id' => false, 'action' => $activity_action, 'component' => 'groups', 'type' => 'exb', 'item_id' => $group_id, 'secondary_item_id' => wp_hash($post['blogurl'])));
         // new method
         if (empty($id)) {
             $existing = bp_activity_get(array('user_id' => false, 'component' => 'groups', 'type' => 'exb', 'item_id' => $group_id, 'update_meta_cache' => false, 'display_comments' => false, 'meta_query' => array(array('key' => 'exb_guid', 'value' => $post['guid']))));
             // we've found an existing entry
             if (!empty($existing['activities'])) {
                 $id = (int) $existing['activities'][0]->id;
             }
         }
         /* Record or update in activity streams. */
         // Skip if it already exists
         if (empty($id)) {
             $aid = groups_record_activity(array('id' => $id, 'user_id' => false, 'action' => $activity_action, 'content' => $activity_content, 'primary_link' => $post['primary_link'], 'type' => 'exb', 'item_id' => $group_id, 'recorded_time' => gmdate("Y-m-d H:i:s", $post_date), 'hide_sitewide' => $hide_sitewide));
             // save rss guid as activity meta
             bp_activity_update_meta($aid, 'exb_guid', $post['guid']);
             bp_activity_update_meta($aid, 'exb_feedurl', $post['feedurl']);
         }
     }
     return $items;
 }
开发者ID:rpi-virtuell,项目名称:external-group-blogs,代码行数:91,代码来源:bp-groups-externalblogs.php


注:本文中的bp_create_excerpt函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。