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


PHP bp_blogs_update_blogmeta函数代码示例

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


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

示例1: bp_blogs_comments_open

/**
 * Check if a blog post's activity item should be closed from commenting.
 *
 * This mirrors the {@link comments_open()} and {@link _close_comments_for_old_post()}
 * functions, but for use with the BuddyPress activity stream to be as
 * lightweight as possible.
 *
 * By lightweight, we actually mirror a few of the blog's commenting settings
 * to blogmeta and checks the values in blogmeta instead.  This is to prevent
 * multiple {@link switch_to_blog()} calls in the activity stream.
 *
 * @since BuddyPress (2.0.0)
 *
 * @param object $activity The BP_Activity_Activity object
 * @return bool
 */
function bp_blogs_comments_open( $activity ) {
	$open = true;

	$blog_id = $activity->item_id;

	// see if we've mirrored the close comments option before
	$days_old = bp_blogs_get_blogmeta( $blog_id, 'close_comments_days_old' );

	// we've never cached these items before, so do it now
	if ( '' === $days_old ) {
		switch_to_blog( $blog_id );

		// use comments_open()
		remove_filter( 'comments_open', 'bp_comments_open', 10, 2 );
		$open = comments_open( $activity->secondary_item_id );
		add_filter( 'comments_open', 'bp_comments_open', 10, 2 );

		// might as well mirror values to blogmeta since we're here!
		$thread_depth = get_option( 'thread_comments' );
		if ( ! empty( $thread_depth ) ) {
			$thread_depth = get_option( 'thread_comments_depth' );
		} else {
			// perhaps filter this?
			$thread_depth = 1;
		}

		bp_blogs_update_blogmeta( $blog_id, 'close_comments_for_old_posts', get_option( 'close_comments_for_old_posts' ) );
		bp_blogs_update_blogmeta( $blog_id, 'close_comments_days_old',      get_option( 'close_comments_days_old' ) );
		bp_blogs_update_blogmeta( $blog_id, 'thread_comments_depth',        $thread_depth );

		restore_current_blog();

	// check blogmeta and manually check activity item
	// basically a copy of _close_comments_for_old_post()
	} else {

		// comments are closed
		if ( 'closed' == bp_activity_get_meta( $activity->id, 'post_comment_status' ) ) {
			return false;
		}

		if ( ! bp_blogs_get_blogmeta( $blog_id, 'close_comments_for_old_posts' ) ) {
			return $open;
		}

		$days_old = (int) $days_old;
		if ( ! $days_old ) {
			return $open;
		}

		/* commenting out for now - needs some more thought...
		   should we add the post type to activity meta?

		$post = get_post($post_id);

		// This filter is documented in wp-includes/comment.php
		$post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
		if ( ! in_array( $post->post_type, $post_types ) )
			return $open;
		*/

		if ( time() - strtotime( $activity->date_recorded ) > ( $days_old * DAY_IN_SECONDS ) ) {
			return false;
		}

		return $open;
	}

	return $open;
}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:86,代码来源:bp-blogs-activity.php

示例2: test_get_order_by

 /**
  * @group get_order_by
  */
 public function test_get_order_by()
 {
     if (!is_multisite()) {
         return;
     }
     $old_user = get_current_user_id();
     $u = $this->factory->user->create();
     $this->set_current_user($u);
     $bs = array('foobar' => $this->factory->blog->create(array('title' => 'Foo Bar Blog', 'user_id' => $u, 'path' => '/path' . rand() . time() . '/')), 'barfoo' => $this->factory->blog->create(array('title' => 'Bar foo Blog', 'user_id' => $u, 'path' => '/path' . rand() . time() . '/')));
     bp_blogs_record_existing_blogs();
     // make the blog public or it won't turn up in generic results
     foreach ($bs as $b) {
         update_blog_option($b, 'blog_public', '1');
     }
     // Used to make sure barfoo is older than foobar
     $b_time = date_i18n('Y-m-d H:i:s', strtotime('-5 minutes'));
     /* Alphabetical */
     $blogs = BP_Blogs_Blog::get('alphabetical', false, false, $u);
     $blog_ids = wp_list_pluck($blogs['blogs'], 'blog_id');
     $this->assertEquals(array($bs['barfoo'], $bs['foobar']), $blog_ids);
     /* Newest */
     update_blog_details($bs['barfoo'], array('registered' => $b_time));
     $blogs = BP_Blogs_Blog::get('newest', false, false, $u);
     $blog_ids = wp_list_pluck($blogs['blogs'], 'blog_id');
     $this->assertEquals(array($bs['foobar'], $bs['barfoo']), $blog_ids);
     /* Active */
     bp_blogs_update_blogmeta($bs['barfoo'], 'last_activity', $b_time);
     $blogs = BP_Blogs_Blog::get('active', false, false, $u);
     $blog_ids = wp_list_pluck($blogs['blogs'], 'blog_id');
     $this->assertEquals(array($bs['foobar'], $bs['barfoo']), $blog_ids);
     /* Random */
     $blogs = BP_Blogs_Blog::get('random', false, false, $u);
     $this->assertTrue(2 == count($blogs['blogs']));
     $this->set_current_user($old_user);
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:38,代码来源:class-bp-blogs-blog.php

示例3: bp_blogs_record_comment

/**
 * Record blog comment activity. Checks if blog is public and post is not
 * password protected.
 *
 * @param int $comment_id
 * @param mixed $is_approved
 * @return mixed
 */
function bp_blogs_record_comment($comment_id, $is_approved = true)
{
    // Get the users comment
    $recorded_comment = get_comment($comment_id);
    // Don't record activity if the comment hasn't been approved
    if (empty($is_approved)) {
        return false;
    }
    // Don't record activity if no email address has been included
    if (empty($recorded_comment->comment_author_email)) {
        return false;
    }
    // Don't record activity if the comment has already been marked as spam
    if ('spam' === $is_approved) {
        return false;
    }
    // Get the user by the comment author email.
    $user = get_user_by('email', $recorded_comment->comment_author_email);
    // If user isn't registered, don't record activity
    if (empty($user)) {
        return false;
    }
    // Get the user_id
    $user_id = (int) $user->ID;
    // Get blog and post data
    $blog_id = get_current_blog_id();
    $recorded_comment->post = get_post($recorded_comment->comment_post_ID);
    if (empty($recorded_comment->post) || is_wp_error($recorded_comment->post)) {
        return false;
    }
    // If this is a password protected post, don't record the comment
    if (!empty($recorded_comment->post->post_password)) {
        return false;
    }
    // Don't record activity if the comment's associated post isn't a WordPress Post
    if (!in_array($recorded_comment->post->post_type, apply_filters('bp_blogs_record_comment_post_types', array('post')))) {
        return false;
    }
    $is_blog_public = apply_filters('bp_is_blog_public', (int) get_blog_option($blog_id, 'blog_public'));
    // If blog is public allow activity to be posted
    if ($is_blog_public) {
        // Get activity related links
        $post_permalink = get_permalink($recorded_comment->comment_post_ID);
        $comment_link = htmlspecialchars(get_comment_link($recorded_comment->comment_ID));
        // Prepare to record in activity streams
        if (is_multisite()) {
            $activity_action = sprintf(__('%1$s commented on the post, %2$s, on the site %3$s', 'buddypress'), bp_core_get_userlink($user_id), '<a href="' . $post_permalink . '">' . apply_filters('the_title', $recorded_comment->post->post_title) . '</a>', '<a href="' . get_blog_option($blog_id, 'home') . '">' . get_blog_option($blog_id, 'blogname') . '</a>');
        } else {
            $activity_action = sprintf(__('%1$s commented on the post, %2$s', 'buddypress'), bp_core_get_userlink($user_id), '<a href="' . $post_permalink . '">' . apply_filters('the_title', $recorded_comment->post->post_title) . '</a>');
        }
        $activity_content = $recorded_comment->comment_content;
        // Record in activity streams
        bp_blogs_record_activity(array('user_id' => $user_id, 'action' => apply_filters_ref_array('bp_blogs_activity_new_comment_action', array($activity_action, &$recorded_comment, $comment_link)), 'content' => apply_filters_ref_array('bp_blogs_activity_new_comment_content', array($activity_content, &$recorded_comment, $comment_link)), 'primary_link' => apply_filters_ref_array('bp_blogs_activity_new_comment_primary_link', array($comment_link, &$recorded_comment)), 'type' => 'new_blog_comment', 'item_id' => $blog_id, 'secondary_item_id' => $comment_id, 'recorded_time' => $recorded_comment->comment_date_gmt));
        // Update the blogs last active date
        bp_blogs_update_blogmeta($blog_id, 'last_activity', bp_core_current_time());
    }
    return $recorded_comment;
}
开发者ID:vsalx,项目名称:rattieinfo,代码行数:66,代码来源:bp-blogs-functions.php

示例4: bp_blogs_record_comment


//.........这里部分代码省略.........
    if (!bp_blogs_is_blog_trackable($blog_id, $user_id)) {
        return false;
    }
    $recorded_comment->post = get_post($recorded_comment->comment_post_ID);
    if (empty($recorded_comment->post) || is_wp_error($recorded_comment->post)) {
        return false;
    }
    // If this is a password protected post, don't record the comment
    if (!empty($recorded_comment->post->post_password)) {
        return false;
    }
    // Don't record activity if the comment's associated post isn't a WordPress Post
    if (!in_array($recorded_comment->post->post_type, apply_filters('bp_blogs_record_comment_post_types', array('post')))) {
        return false;
    }
    $is_blog_public = apply_filters('bp_is_blog_public', (int) get_blog_option($blog_id, 'blog_public'));
    // If blog is public allow activity to be posted
    if ($is_blog_public) {
        // Get activity related links
        $post_permalink = get_permalink($recorded_comment->comment_post_ID);
        $comment_link = get_comment_link($recorded_comment->comment_ID);
        // Setup activity args
        $args = array();
        $args['user_id'] = $user_id;
        $args['content'] = apply_filters_ref_array('bp_blogs_activity_new_comment_content', array($recorded_comment->comment_content, &$recorded_comment, $comment_link));
        $args['primary_link'] = apply_filters_ref_array('bp_blogs_activity_new_comment_primary_link', array($comment_link, &$recorded_comment));
        $args['recorded_time'] = $recorded_comment->comment_date_gmt;
        // Setup some different activity args depending if activity commenting is
        // enabled or not
        // if cannot comment, record separate activity entry
        // this is the old way of doing things
        if (bp_disable_blogforum_comments()) {
            $args['type'] = 'new_blog_comment';
            $args['item_id'] = $blog_id;
            $args['secondary_item_id'] = $comment_id;
            // record the activity entry
            $activity_id = bp_blogs_record_activity($args);
            // add some post info in activity meta
            bp_activity_update_meta($activity_id, 'post_title', $recorded_comment->post->post_title);
            bp_activity_update_meta($activity_id, 'post_url', add_query_arg('p', $recorded_comment->post->ID, home_url('/')));
            // record comment as BP activity comment under the parent 'new_blog_post'
            // activity item
        } else {
            // this is a comment edit
            // check to see if corresponding activity entry already exists
            if (!empty($_REQUEST['action'])) {
                $existing_activity_id = get_comment_meta($comment_id, 'bp_activity_comment_id', true);
                if (!empty($existing_activity_id)) {
                    $args['id'] = $existing_activity_id;
                }
            }
            // find the parent 'new_blog_post' activity entry
            $parent_activity_id = bp_activity_get_activity_id(array('component' => 'blogs', 'type' => 'new_blog_post', 'item_id' => $blog_id, 'secondary_item_id' => $recorded_comment->comment_post_ID));
            // we found the parent activity entry
            // so let's go ahead and reconfigure some activity args
            if (!empty($parent_activity_id)) {
                // set the 'item_id' with the parent activity entry ID
                $args['item_id'] = $parent_activity_id;
                // now see if the WP parent comment has a BP activity ID
                $comment_parent = 0;
                if (!empty($recorded_comment->comment_parent)) {
                    $comment_parent = get_comment_meta($recorded_comment->comment_parent, 'bp_activity_comment_id', true);
                }
                // WP parent comment does not have a BP activity ID
                // so set to 'new_blog_post' activity ID
                if (empty($comment_parent)) {
                    $comment_parent = $parent_activity_id;
                }
                $args['secondary_item_id'] = $comment_parent;
                $args['component'] = 'activity';
                $args['type'] = 'activity_comment';
                // could not find corresponding parent activity entry
                // so wipe out $args array
            } else {
                $args = array();
            }
            // Record in activity streams
            if (!empty($args)) {
                // @todo should we use bp_activity_new_comment()? that function will also send
                // an email to people in the activity comment thread
                //
                // what if a site already has some comment email notification plugin setup?
                // this is why I decided to go with bp_activity_add() to avoid any conflict
                // with existing comment email notification plugins
                $comment_activity_id = bp_activity_add($args);
                if (empty($args['id'])) {
                    // add meta to activity comment
                    bp_activity_update_meta($comment_activity_id, 'bp_blogs_post_comment_id', $comment_id);
                    bp_activity_update_meta($comment_activity_id, 'post_title', $recorded_comment->post->post_title);
                    bp_activity_update_meta($comment_activity_id, 'post_url', add_query_arg('p', $recorded_comment->post->ID, home_url('/')));
                    // add meta to comment
                    add_comment_meta($comment_id, 'bp_activity_comment_id', $comment_activity_id);
                }
            }
        }
        // Update the blogs last active date
        bp_blogs_update_blogmeta($blog_id, 'last_activity', bp_core_current_time());
    }
    return $recorded_comment;
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:101,代码来源:bp-blogs-functions.php

示例5: dwqa_replace_activity_meta

function dwqa_replace_activity_meta()
{
    global $activities_template;
    $blog_url = bp_blogs_get_blogmeta($activity->item_id, 'url');
    $blog_name = bp_blogs_get_blogmeta($activity->item_id, 'name');
    if (empty($blog_url) || empty($blog_name)) {
        $blog_url = get_home_url($activity->item_id);
        $blog_name = get_blog_option($activity->item_id, 'blogname');
        bp_blogs_update_blogmeta($activity->item_id, 'url', $blog_url);
        bp_blogs_update_blogmeta($activity->item_id, 'name', $blog_name);
    }
    $post_url = add_query_arg('p', $activities_template->activity->secondary_item_id, trailingslashit($blog_url));
    $post_title = bp_activity_get_meta($activities_template->activity->id, 'post_title');
    if (empty($post_title)) {
        $post = get_post($activities_template->activity->secondary_item_id);
        if (is_a($post, 'WP_Post')) {
            $post_title = $post->post_title;
            bp_activity_update_meta($activities_template->activity->id, 'post_title', $post_title);
        }
    }
    $post_link = '<a href="' . $post_url . '">' . $post_title . '</a>';
    $user_link = bp_core_get_userlink($activities_template->activity->user_id);
    if ($activities_template->activity->type == 'new_question') {
        $action = sprintf(__('%1$s asked a new question: %2$s', 'dwqa'), $user_link, $post_link);
    } elseif ($activities_template->activity->type == 'new_answer') {
        $action = sprintf(__('%1$s answered the question: %2$s', 'dwqa'), $user_link, $post_link);
    } elseif ($activities_template->activity->type == 'comment_question') {
        $action = sprintf(__('%1$s commented on the question: %2$s', 'dwqa'), $user_link, $post_link);
    } elseif ($activities_template->activity->type == 'comment_answer') {
        $action = sprintf(__('%1$s commented on the answer at: %2$s', 'dwqa'), $user_link, $post_link);
    } else {
        $action = $activities_template->activity->action;
    }
    // Strip any legacy time since placeholders from BP 1.0-1.1
    $content = str_replace('<span class="time-since">%s</span>', '', $content);
    // Insert the time since.
    $time_since = apply_filters_ref_array('bp_activity_time_since', array('<span class="time-since">' . bp_core_time_since($activities_template->activity->date_recorded) . '</span>', &$activities_template->activity));
    // Insert the permalink
    if (!bp_is_single_activity()) {
        $content = apply_filters_ref_array('bp_activity_permalink', array(sprintf('%1$s <a href="%2$s" class="view activity-time-since" title="%3$s">%4$s</a>', $content, bp_activity_get_permalink($activities_template->activity->id, $activities_template->activity), esc_attr__('View Discussion', 'buddypress'), $time_since), &$activities_template->activity));
    } else {
        $content .= str_pad($time_since, strlen($time_since) + 2, ' ', STR_PAD_BOTH);
    }
    echo $action . ' ' . $content;
    // echo 'abc';
    // echo $activities_template->activity->content;
}
开发者ID:linkinf88k,项目名称:dw-question-answer,代码行数:47,代码来源:buddypress.php

示例6: bp_blogs_record_comment

/**
 * bp_blogs_record_comment()
 *
 * Record blog comment activity. Checks if blog is public and post is not
 * password protected.
 *
 * @global object $wpdb
 * @global $bp $bp
 * @param int $comment_id
 * @param bool $is_approved
 * @return mixed
 */

function bp_blogs_record_comment( $comment_id, $is_approved = true ) {
	global $wpdb, $bp;

	// Get the users comment
	$recorded_comment = get_comment( $comment_id );

	// Don't record activity if the comment hasn't been approved
	if ( empty( $is_approved ) )
		return false;

	// Don't record activity if no email address has been included
	if ( empty( $recorded_comment->comment_author_email ) )
		return false;
	
	// Get the user_id from the comment author email.
	$user = get_user_by_email( $recorded_comment->comment_author_email );
	$user_id = (int)$user->ID;

	// If there's no registered user id, don't record activity
	if ( empty( $user_id ) )
		return false;

	// Get blog and post data
	$blog_id = (int)$wpdb->blogid;
	$recorded_comment->post = get_post( $recorded_comment->comment_post_ID );

	// If this is a password protected post, don't record the comment
	if ( !empty( $recorded_comment->post->post_password ) )
		return false;

	// If blog is public allow activity to be posted
	if ( get_blog_option( $blog_id, 'blog_public' ) ) {

		// Get activity related links
		$post_permalink = get_permalink( $recorded_comment->comment_post_ID );
		$comment_link   = htmlspecialchars( get_comment_link( $recorded_comment->comment_ID ) );

		// Prepare to record in activity streams
		$activity_action	= sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . apply_filters( 'the_title', $recorded_comment->post->post_title ) . '</a>' );
		$activity_content	= $recorded_comment->comment_content;

		// Record in activity streams
		bp_blogs_record_activity( array(
			'user_id'           => $user_id,
			'action'            => apply_filters( 'bp_blogs_activity_new_comment_action', $activity_action, &$recorded_comment, $comment_link ),
			'content'           => apply_filters( 'bp_blogs_activity_new_comment_content', $activity_content, &$recorded_comment, $comment_link ),
			'primary_link'      => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$recorded_comment ),
			'type'              => 'new_blog_comment',
			'item_id'           => $blog_id,
			'secondary_item_id' => $comment_id,
			'recorded_time'     => $recorded_comment->comment_date_gmt
		) );

		// Update the blogs last active date
		bp_blogs_update_blogmeta( $blog_id, 'last_activity', bp_core_current_time() );
	}

	return $recorded_comment;
}
开发者ID:n-sane,项目名称:zaroka,代码行数:72,代码来源:bp-blogs.php

示例7: test_bp_blogs_update_meta_prev_value

 /**
  * @group blogmeta
  * @group bp_blogs_update_blogmeta
  */
 public function test_bp_blogs_update_meta_prev_value()
 {
     bp_blogs_add_blogmeta(1, 'foo', 'bar');
     // In earlier versions of WordPress, bp_activity_update_meta()
     // returns true even on failure. However, we know that in these
     // cases the update is failing as expected, so we skip this
     // assertion just to keep our tests passing
     // See https://core.trac.wordpress.org/ticket/24933
     if (version_compare($GLOBALS['wp_version'], '3.7', '>=')) {
         $this->assertFalse(bp_blogs_update_blogmeta(1, 'foo', 'bar2', 'baz'));
     }
     $this->assertTrue(bp_blogs_update_blogmeta(1, 'foo', 'bar2', 'bar'));
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:17,代码来源:functions.php

示例8: bp_get_blog_avatar

/**
 * Get a blog's avatar.
 *
 * At the moment, blog avatars are simply the user avatars of the blog
 * admin. Filter 'bp_get_blog_avatar_' . $blog_id to customize.
 *
 * @since 2.4.0 Introduced `$title` argument.
 *
 * @see bp_core_fetch_avatar() For a description of arguments and
 *      return values.
 *
 * @param array|string $args  {
 *     Arguments are listed here with an explanation of their defaults.
 *     For more information about the arguments, see
 *     {@link bp_core_fetch_avatar()}.
 *     @type string   $alt     Default: 'Profile picture of site author [user name]'.
 *     @type string   $class   Default: 'avatar'.
 *     @type string   $title   Default: 'Profile picture of site author [user name]'.
 *     @type string   $type    Default: 'full'.
 *     @type int|bool $width   Default: false.
 *     @type int|bool $height  Default: false.
 *     @type bool     $id      Currently unused.
 *     @type bool     $no_grav Default: true.
 * }
 * @return string User avatar string.
 */
function bp_get_blog_avatar($args = '')
{
    global $blogs_template;
    // Bail if avatars are turned off
    // @todo Should we maybe still filter this?
    if (!buddypress()->avatar->show_avatars) {
        return false;
    }
    $author_displayname = bp_core_get_user_displayname($blogs_template->blog->admin_user_id);
    // Parse the arguments.
    $r = bp_parse_args($args, array('type' => 'full', 'width' => false, 'height' => false, 'class' => 'avatar', 'title' => sprintf(__('Profile picture of site author %s', 'buddypress'), esc_attr($author_displayname)), 'id' => false, 'alt' => sprintf(__('Profile picture of site author %s', 'buddypress'), esc_attr($author_displayname)), 'no_grav' => true));
    // Use site icon if available.
    $avatar = '';
    if (bp_is_active('blogs', 'site-icon') && function_exists('has_site_icon')) {
        $site_icon = bp_blogs_get_blogmeta(bp_get_blog_id(), "site_icon_url_{$r['type']}");
        // Never attempted to fetch site icon before; do it now!
        if ('' === $site_icon) {
            switch_to_blog(bp_get_blog_id());
            // Fetch the other size first.
            if ('full' === $r['type']) {
                $size = bp_core_avatar_thumb_width();
                $save_size = 'thumb';
            } else {
                $size = bp_core_avatar_full_width();
                $save_size = 'full';
            }
            $site_icon = get_site_icon_url($size);
            // Empty site icons get saved as integer 0.
            if (empty($site_icon)) {
                $site_icon = 0;
            }
            // Sync site icon for other size to blogmeta.
            bp_blogs_update_blogmeta(bp_get_blog_id(), "site_icon_url_{$save_size}", $site_icon);
            // Now, fetch the size we want.
            if (0 !== $site_icon) {
                $size = 'full' === $r['type'] ? bp_core_avatar_full_width() : bp_core_avatar_thumb_width();
                $site_icon = get_site_icon_url($size);
            }
            // Sync site icon to blogmeta.
            bp_blogs_update_blogmeta(bp_get_blog_id(), "site_icon_url_{$r['type']}", $site_icon);
            restore_current_blog();
        }
        // We have a site icon.
        if (!is_numeric($site_icon)) {
            if (empty($r['width']) && !isset($size)) {
                $size = 'full' === $r['type'] ? bp_core_avatar_full_width() : bp_core_avatar_thumb_width();
            } else {
                $size = (int) $r['width'];
            }
            $avatar = sprintf('<img src="%1$s" class="%2$s" width="%3$s" height="%3$s" alt="%4$s" title="%4$s" />', esc_url($site_icon), esc_attr("{$r['class']} avatar-{$size}"), esc_attr($size), sprintf(esc_attr__('Site icon for %s', 'buddypress'), bp_get_blog_name()));
        }
    }
    // Fallback to user ID avatar.
    if ('' === $avatar) {
        $avatar = bp_core_fetch_avatar(array('item_id' => $blogs_template->blog->admin_user_id, 'title' => $r['title'], 'type' => $r['type'], 'alt' => $r['alt'], 'css_id' => $r['id'], 'class' => $r['class'], 'width' => $r['width'], 'height' => $r['height']));
    }
    /**
     * In future BuddyPress versions you will be able to set the avatar for a blog.
     * Right now you can use a filter with the ID of the blog to change it if you wish.
     * By default it will return the avatar for the primary blog admin.
     *
     * This filter is deprecated as of BuddyPress 1.5 and may be removed in a future version.
     * Use the 'bp_get_blog_avatar' filter instead.
     */
    $avatar = apply_filters('bp_get_blog_avatar_' . $blogs_template->blog->blog_id, $avatar);
    /**
     * Filters a blog's avatar.
     *
     * @since 1.5.0
     *
     * @param string $avatar  Formatted HTML <img> element, or raw avatar
     *                        URL based on $html arg.
     * @param int    $blog_id ID of the blog whose avatar is being displayed.
     * @param array  $r       Array of arguments used when fetching avatar.
//.........这里部分代码省略.........
开发者ID:buddypress,项目名称:BuddyPress-build,代码行数:101,代码来源:bp-blogs-template.php

示例9: geodir_buddypress_new_listing_comment_activity

/**
 * action for listing post type comment.
 *
 * @since 1.0.0
 * @package GeoDirectory_BuddyPress_Integration
 *
 * @param string $action BuddyPress Constructed activity action.
 * @param object $activity BuddyPress Activity data object.
 * @return mixed|void Modified Action.
 */
function geodir_buddypress_new_listing_comment_activity($action, $activity)
{
    $posy_info = NULL;
    switch_to_blog($activity->item_id);
    $comment = get_comment($activity->secondary_item_id);
    $posy_info = !empty($comment->comment_post_ID) ? get_post($comment->comment_post_ID) : NULL;
    $post_type = !empty($posy_info) ? $posy_info->post_type : '';
    restore_current_blog();
    $gd_post_types = geodir_get_posttypes('array');
    if (!empty($post_type) && array_key_exists($post_type, $gd_post_types)) {
        $blog_url = bp_blogs_get_blogmeta($activity->item_id, 'url');
        $blog_name = bp_blogs_get_blogmeta($activity->item_id, 'name');
        if (empty($blog_url) || empty($blog_name)) {
            $blog_url = get_home_url($activity->item_id);
            $blog_name = get_blog_option($activity->item_id, 'blogname');
            bp_blogs_update_blogmeta($activity->item_id, 'url', $blog_url);
            bp_blogs_update_blogmeta($activity->item_id, 'name', $blog_name);
        }
        $post_url = bp_activity_get_meta($activity->id, 'post_url');
        $post_title = bp_activity_get_meta($activity->id, 'post_title');
        // Should only be empty at the time of post creation
        if (empty($post_url) || empty($post_title)) {
            if (!empty($comment->comment_post_ID)) {
                $post_url = esc_url(add_query_arg('p', $comment->comment_post_ID, trailingslashit($blog_url)));
                bp_activity_update_meta($activity->id, 'post_url', $post_url);
                if (is_a($posy_info, 'WP_Post')) {
                    $post_title = $post->post_title;
                    bp_activity_update_meta($activity->id, 'post_title', $post_title);
                }
            }
        }
        $post_link = '<a href="' . $post_url . '">' . $post_title . '</a>';
        $user_link = bp_core_get_userlink($activity->user_id);
        $post_type_name = __(strtolower($gd_post_types[$post_type]['labels']['singular_name']), GDBUDDYPRESS_TEXTDOMAIN);
        if (is_multisite()) {
            $action = sprintf(__('%1$s commented on the %2$s, %3$s, on the site %4$s', GDBUDDYPRESS_TEXTDOMAIN), $user_link, $post_type_name, $post_link, '<a href="' . esc_url($blog_url) . '">' . esc_html($blog_name) . '</a>');
        } else {
            $action = sprintf(__('%1$s commented on the %2$s, %3$s', GDBUDDYPRESS_TEXTDOMAIN), $user_link, $post_type_name, $post_link);
        }
    }
    return apply_filters('geodir_buddypress_new_listing_comment_activity', $action, $activity, $post_type);
}
开发者ID:poweronio,项目名称:mbsite,代码行数:52,代码来源:gdbuddypress_functions.php

示例10: bp_blogs_record_comment

function bp_blogs_record_comment($comment_id, $is_approved)
{
    global $wpdb;
    if (!$is_approved) {
        return false;
    }
    $comment = get_comment($comment_id);
    /* Get the user_id from the author email. */
    $user = get_user_by_email($comment->comment_author_email);
    $user_id = (int) $user->ID;
    if (!$user_id) {
        return false;
    }
    $recorded_comment = new BP_Blogs_Comment();
    $recorded_comment->user_id = $user_id;
    $recorded_comment->blog_id = $wpdb->blogid;
    $recorded_comment->comment_id = $comment_id;
    $recorded_comment->comment_post_id = $comment->comment_post_ID;
    $recorded_comment->date_created = strtotime($comment->comment_date);
    $recorded_commment_id = $recorded_comment->save();
    bp_blogs_update_blogmeta($recorded_comment->blog_id, 'last_activity', time());
    bp_blogs_record_activity(array('item_id' => $recorded_comment->blog_id, 'secondary_item_id' => $recorded_commment_id, 'component_name' => 'blogs', 'component_action' => 'new_blog_comment', 'is_private' => $is_private, 'user_id' => $recorded_comment->user_id, 'recorded_time' => $recorded_comment->date_created));
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:23,代码来源:bp-blogs.php

示例11: bp_blogs_comment_sync_activity_comment

/**
 * Update Activity and blogs meta and eventually sync comment with activity comment
 *
 * @since  2.5.0
 *
 * @param  int|bool        $activity_id          ID of recorded activity, or false if sync is active.
 * @param  WP_Comment|null $comment              The comment object.
 * @param  array           $activity_args        Array of activity arguments.
 * @param  object|null     $activity_post_object The post type tracking args object.
 * @return int|bool Returns false if no activity, the activity id otherwise.
 */
function bp_blogs_comment_sync_activity_comment(&$activity_id, $comment = null, $activity_args = array(), $activity_post_object = null)
{
    if (empty($activity_args) || empty($comment->post->ID) || empty($activity_post_object->comment_action_id)) {
        return false;
    }
    // Set the current blog id.
    $blog_id = get_current_blog_id();
    // These activity metadatas are used to build the new_blog_comment action string
    if (!empty($activity_id) && !empty($activity_args['item_id']) && 'new_blog_comment' === $activity_post_object->comment_action_id) {
        // add some post info in activity meta
        bp_activity_update_meta($activity_id, 'post_title', $comment->post->post_title);
        bp_activity_update_meta($activity_id, 'post_url', esc_url_raw(add_query_arg('p', $comment->post->ID, home_url('/'))));
    }
    // Sync comment - activity comment
    if (!bp_disable_blogforum_comments()) {
        if (!empty($_REQUEST['action'])) {
            $existing_activity_id = get_comment_meta($comment->comment_ID, 'bp_activity_comment_id', true);
            if (!empty($existing_activity_id)) {
                $activity_args['id'] = $existing_activity_id;
            }
        }
        if (empty($activity_post_object)) {
            $activity_post_object = bp_activity_get_post_type_tracking_args($comment->post->post_type);
        }
        if (isset($activity_post_object->action_id) && isset($activity_post_object->component_id)) {
            // find the parent 'new_post_type' activity entry
            $parent_activity_id = bp_activity_get_activity_id(array('component' => $activity_post_object->component_id, 'type' => $activity_post_object->action_id, 'item_id' => $blog_id, 'secondary_item_id' => $comment->comment_post_ID));
            // Try to create a new activity item for the parent blog post.
            if (empty($parent_activity_id)) {
                $parent_activity_id = bp_activity_post_type_publish($comment->post->ID, $comment->post);
            }
        }
        // we found the parent activity entry
        // so let's go ahead and reconfigure some activity args
        if (!empty($parent_activity_id)) {
            // set the parent activity entry ID
            $activity_args['activity_id'] = $parent_activity_id;
            // now see if the WP parent comment has a BP activity ID
            $comment_parent = 0;
            if (!empty($comment->comment_parent)) {
                $comment_parent = get_comment_meta($comment->comment_parent, 'bp_activity_comment_id', true);
            }
            // WP parent comment does not have a BP activity ID
            // so set to 'new_' . post_type activity ID
            if (empty($comment_parent)) {
                $comment_parent = $parent_activity_id;
            }
            $activity_args['parent_id'] = $comment_parent;
            $activity_args['skip_notification'] = true;
            // could not find corresponding parent activity entry
            // so wipe out $args array
        } else {
            $activity_args = array();
        }
        // Record in activity streams
        if (!empty($activity_args)) {
            $activity_id = bp_activity_new_comment($activity_args);
            if (empty($activity_args['id'])) {
                // The activity metadata to inform about the corresponding comment ID
                bp_activity_update_meta($activity_id, "bp_blogs_{$comment->post->post_type}_comment_id", $comment->comment_ID);
                // The comment metadata to inform about the corresponding activity ID
                add_comment_meta($comment->comment_ID, 'bp_activity_comment_id', $activity_id);
                // These activity metadatas are used to build the new_blog_comment action string
                if ('new_blog_comment' === $activity_post_object->comment_action_id) {
                    bp_activity_update_meta($activity_id, 'post_title', $comment->post->post_title);
                    bp_activity_update_meta($activity_id, 'post_url', esc_url_raw(add_query_arg('p', $comment->post->ID, home_url('/'))));
                }
            }
            /**
             * Fires after an activity comment is added from a WP post comment.
             *
             * @since 2.6.0
             *
             * @param int        $activity_id          The activity comment ID.
             * @param WP_Comment $post_type_comment    WP Comment object.
             * @param array      $activity_args        Activity comment arguments.
             * @param object     $activity_post_object The post type tracking args object.
             */
            do_action('bp_blogs_comment_sync_activity_comment', $activity_id, $comment, $activity_args, $activity_post_object);
        }
    }
    // Update the blogs last active date
    bp_blogs_update_blogmeta($blog_id, 'last_activity', bp_core_current_time());
    if ('new_blog_comment' === $activity_post_object->comment_action_id) {
        /**
         * Fires after BuddyPress has recorded metadata about a published blog post comment.
         *
         * @since 2.5.0
         *
//.........这里部分代码省略.........
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:101,代码来源:bp-blogs-functions.php

示例12: participad_notepad_record_notepad_activity

/**
 * When a Notepad is edited, record the fact to the activity stream
 *
 * @since 1.0
 * @param int $post_id
 * @param object $post
 * @return int The id of the activity item posted
 */
function participad_notepad_record_notepad_activity($post_id, $post)
{
    global $bp;
    // Run only for participad_notebook post type
    if (empty($post->post_type) || participad_notepad_post_type_name() != $post->post_type) {
        return;
    }
    // Throttle activity updates: No duplicate posts (same user, same
    // notepad) within 60 minutes
    $already_args = array('max' => 1, 'sort' => 'DESC', 'show_hidden' => 1, 'filter' => array('user_id' => get_current_user_id(), 'action' => 'participad_notepad_edited', 'secondary_id' => $post_id));
    $already_activity = bp_activity_get($already_args);
    // If any activity items are found, compare its date_recorded with time() to
    // see if it's within the allotted throttle time. If so, don't record the
    // activity item
    if (!empty($already_activity['activities'])) {
        $date_recorded = $already_activity['activities'][0]->date_recorded;
        $drunix = strtotime($date_recorded);
        if (time() - $drunix <= apply_filters('participad_notepad_edit_activity_throttle_time', 60 * 60)) {
            return;
        }
    }
    $post_permalink = get_permalink($post_id);
    $action = sprintf(__('%1$s edited a notepad %2$s on the site %3$s', 'participad'), bp_core_get_userlink(get_current_user_id()), '<a href="' . $post_permalink . '">' . esc_html($post->post_title) . '</a>', '<a href="' . get_option('siteurl') . '">' . get_option('blogname') . '</a>');
    $activity_id = bp_activity_add(array('user_id' => get_current_user_id(), 'component' => bp_is_active('blogs') ? $bp->blogs->id : 'blogs', 'action' => $action, 'primary_link' => $post_permalink, 'type' => 'participad_notepad_edited', 'item_id' => get_current_blog_id(), 'secondary_item_id' => $post_id, 'recorded_time' => $post->post_modified_gmt, 'hide_sitewide' => get_option('blog_public') <= 0));
    if (function_exists('bp_blogs_update_blogmeta')) {
        bp_blogs_update_blogmeta(get_current_blog_id(), 'last_activity', bp_core_current_time());
    }
    return $activity_id;
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:37,代码来源:bp-integration.php


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