本文整理汇总了PHP中bb_get_first_post函数的典型用法代码示例。如果您正苦于以下问题:PHP bb_get_first_post函数的具体用法?PHP bb_get_first_post怎么用?PHP bb_get_first_post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bb_get_first_post函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bp_get_the_topic_text
/**
* Return the text of the first post in the current topic in the loop.
*
* @return string Text of the first post in the current topic.
*/
function bp_get_the_topic_text()
{
global $forum_template;
$post = bb_get_first_post((int) $forum_template->topic->topic_id, false);
return apply_filters('bp_get_the_topic_text', esc_attr($post->post_text));
}
示例2: bp_forums_update_topic
/**
* Update a topic's details.
*
* @param array $args {
* Array of arguments.
* @type int $topic_id ID of the topic being updated.
* @type string $topic_title Updated title of the topic.
* @type string $topic_title Updated text of the topic.
* @type array|string|bool $topic_tags Array or comma-separated list of
* topic tags. False to leave empty. Default: false.
* }
* @return object Details about the new topic, as returned by
* {@link bp_forums_get_topic_details()}.
*/
function bp_forums_update_topic($args = '')
{
/** This action is documented in bp-forums/bp-forums-screens */
do_action('bbpress_init');
$r = wp_parse_args($args, array('topic_id' => false, 'topic_title' => '', 'topic_text' => '', 'topic_tags' => false));
extract($r, EXTR_SKIP);
// Check if the user is a spammer
if (bp_is_user_inactive(bp_loggedin_user_id())) {
return false;
}
// bb_insert_topic() will append tags, but not remove them. So we remove all existing tags.
bb_remove_topic_tags($topic_id);
if (!($topic_id = bb_insert_topic(array('topic_id' => $topic_id, 'topic_title' => stripslashes($topic_title), 'tags' => $topic_tags)))) {
return false;
}
if (!($post = bb_get_first_post($topic_id))) {
return false;
}
// Update the first post
if (!($post = bp_forums_insert_post(array('post_id' => $post->post_id, 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $post->post_time, 'poster_id' => $post->poster_id, 'poster_ip' => $post->poster_ip, 'post_status' => $post->post_status, 'post_position' => $post->post_position)))) {
return false;
}
return bp_forums_get_topic_details($topic_id);
}
示例3: bb_editTopic
/**
* Edits an existing topic
*
* @since 1.0
* @return array|object The topic data when successfully edited or an IXR_Error object on failure
* @param array $args Arguments passed by the XML-RPC call
* @param string $args[0] The username for authentication
* @param string $args[1] The password for authentication
* @param array $args[2] The values for the various parameters in the edited topic
* @param integer|string $args[2]['topic_id'] The topic's id or slug
* @param string $args[2]['title'] The title of the topic
* @param string $args[2]['text'] The text of the topic
*
* XML-RPC request to edit the title of a topic with the slug "insane-monkeys"
* <methodCall>
* <methodName>bb.editTopic</methodName>
* <params>
* <param><value><string>joeblow</string></value></param>
* <param><value><string>123password</string></value></param>
* <param><value><struct>
* <member>
* <name>topic_id</name>
* <value><string>insane-monkeys</string></value>
* </member>
* <member>
* <name>title</name>
* <value><string>Very insane monkeys</string></value>
* </member>
* </struct></value></param>
* </params>
* </methodCall>
*/
function bb_editTopic($args)
{
do_action('bb_xmlrpc_call', 'bb.editTopic');
// Escape args
$this->escape($args);
// Get the login credentials
$username = $args[0];
$password = (string) $args[1];
// Check the user is valid
$user = $this->authenticate($username, $password, 'edit_topics', __('You do not have permission to edit topics.'));
// Additionally they need to be able to edit posts
if (!$this->error && !bb_current_user_can('edit_posts')) {
$this->error = new IXR_Error(403, __('You do not have permission to edit posts.'));
}
do_action('bb_xmlrpc_call_authenticated', 'bb.editTopic');
// If an error was raised by authentication or by an action then return it
if ($this->error) {
return $this->error;
}
// Make sure there is something for us to do
if (!$args[2] || !is_array($args[2]) || !count($args[2])) {
$this->error = new IXR_Error(400, __('The topic data is invalid.'));
return $this->error;
}
$structure = (array) $args[2];
// Can be numeric id or slug
$topic_id = isset($structure['topic_id']) ? $structure['topic_id'] : false;
// Check for bad data
if (!$topic_id || !is_string($topic_id) && !is_integer($topic_id)) {
$this->error = new IXR_Error(400, __('The topic id is invalid.'));
return $this->error;
}
// Check the requested topic exists
if (!($topic = get_topic($topic_id))) {
$this->error = new IXR_Error(400, __('No topic found.'));
return $this->error;
}
// The topic id may have been a slug, so make sure it's an integer here
$topic_id = (int) $topic->topic_id;
// Make sure they are allowed to edit this topic
if (!bb_current_user_can('edit_topic', $topic_id)) {
$this->error = new IXR_Error(403, __('You do not have permission to edit this topic.'));
return $this->error;
}
// Get the first post in the topic (that's where the content is)
if (!($post = bb_get_first_post($topic_id))) {
$this->error = new IXR_Error(400, __('No posts found.'));
return $this->error;
}
$post_id = (int) $post->post_id;
// Make sure they are allowed to edit this post
if (!bb_current_user_can('edit_post', $post_id)) {
$this->error = new IXR_Error(403, __('You do not have permission to edit this post.'));
return $this->error;
}
// The topic requires a title
if (isset($structure['title']) && !$structure['title']) {
$this->error = new IXR_Error(400, __('The topic title is invalid.'));
return $this->error;
}
// The topic requires text
if (isset($structure['text']) && !$structure['text']) {
$this->error = new IXR_Error(400, __('The topic text is invalid.'));
return $this->error;
}
if ($structure['title']) {
if (!bb_insert_topic(array('topic_title' => (string) $structure['title'], 'topic_id' => $topic_id))) {
$this->error = new IXR_Error(500, __('The topic could not be edited.'));
//.........这里部分代码省略.........
示例4: bp_get_the_topic_text
/**
* Return the text of the first post in the current topic in the loop.
*
* @return string Text of the first post in the current topic.
*/
function bp_get_the_topic_text() {
global $forum_template;
$post = bb_get_first_post( (int) $forum_template->topic->topic_id, false );
/**
* Filters the text of the first post in the current topic in the loop.
*
* @since BuddyPress (1.1.0)
*
* @param string $post_text Text for the first post in the current topic.
*/
return apply_filters( 'bp_get_the_topic_text', esc_attr( $post->post_text ) );
}
示例5: esc_html
if (!($posts = bb_get_latest_forum_posts($feed_id))) {
die;
}
$title = esc_html(sprintf(__('%1$s » Forum: %2$s - Recent Posts'), bb_get_option('name'), get_forum_name($feed_id)));
$link = get_forum_link($feed_id);
$link_self = bb_get_forum_posts_rss_link($feed_id);
break;
// Get just the first post from the latest topics
// Get just the first post from the latest topics
case 'all-topics':
if (!($topics = get_latest_topics())) {
die;
}
$posts = array();
foreach ($topics as $topic) {
$posts[] = bb_get_first_post($topic->topic_id);
}
$title = esc_html(sprintf(__('%1$s » Recent Topics'), bb_get_option('name')));
$link = bb_get_uri();
$link_self = bb_get_topics_rss_link();
break;
// Get latest posts by default
// Get latest posts by default
case 'all-posts':
default:
if (!($posts = bb_get_latest_posts(35))) {
die;
}
$title = esc_html(sprintf(__('%1$s » Recent Posts'), bb_get_option('name')));
$link = bb_get_uri();
$link_self = bb_get_posts_rss_link();
示例6: GetBuddyPressRating
private function GetBuddyPressRating($ver, $horAlign = true)
{
RWLogger::LogEnterence('GetBuddyPressRating');
global $activities_template;
// Set current activity-comment to current activity update (recursive comments).
$this->current_comment = $activities_template->activity;
$rclass = str_replace('_', '-', bp_get_activity_type());
$is_forum_topic = $rclass === 'new-forum-topic';
if ($is_forum_topic && !$this->IsBBPressInstalled()) {
return false;
}
if (!in_array($rclass, array('forum-post', 'forum-reply', 'new-forum-post', 'user-forum-post', 'user', 'activity-update', 'user-activity-update', 'activity-comment', 'user-activity-comment'))) {
// If unknown activity type, change it to activity update.
$rclass = 'activity-update';
}
if ($is_forum_topic) {
$rclass = 'new-forum-post';
}
// Check if item rating is top positioned.
if (!isset($this->activity_align[$rclass]) || $ver !== $this->activity_align[$rclass]->ver) {
return false;
}
// Get item id.
$item_id = 'activity-update' === $rclass || 'activity-comment' === $rclass ? bp_get_activity_id() : bp_get_activity_secondary_item_id();
if ($is_forum_topic) {
// If forum topic, then we must extract post id
// from forum posts table, because secondary_item_id holds
// topic id.
if (function_exists('bb_get_first_post')) {
$post = bb_get_first_post($item_id);
} else {
// Extract post id straight from the BB DB.
global $bb_table_prefix;
// Load bbPress config file.
@(include_once WP_RW__BBP_CONFIG_LOCATION);
// Failed loading config file.
if (!defined('BBDB_NAME')) {
return false;
}
$connection = null;
if (!($connection = mysql_connect(BBDB_HOST, BBDB_USER, BBDB_PASSWORD, true))) {
return false;
}
if (!mysql_selectdb(BBDB_NAME, $connection)) {
return false;
}
$results = mysql_query("SELECT * FROM {$bb_table_prefix}posts WHERE topic_id={$item_id} AND post_position=1", $connection);
$post = mysql_fetch_object($results);
}
if (!isset($post->post_id) && empty($post->post_id)) {
return false;
}
$item_id = $post->post_id;
}
// If the item is post, queue rating with post title.
$title = 'new-blog-post' === $rclass ? get_the_title($item_id) : bp_get_activity_content_body();
// $activities_template->activity->content;
$options = array();
$owner_id = bp_get_activity_user_id();
// Add accumulator id if user accumulated rating.
if ($this->IsUserAccumulatedRating()) {
$options['uarid'] = $this->_getUserRatingGuid($owner_id);
}
return $this->EmbedRatingIfVisible($item_id, $owner_id, strip_tags($title), bp_activity_get_permalink(bp_get_activity_id()), $rclass, false, $horAlign ? $this->activity_align[$rclass]->hor : false, false, $options, false);
}
示例7: bp_forums_update_topic
function bp_forums_update_topic($args = '')
{
global $bp;
do_action('bbpress_init');
$defaults = array('topic_id' => false, 'topic_title' => '', 'topic_text' => '', 'topic_tags' => false);
$r = nxt_parse_args($args, $defaults);
extract($r, EXTR_SKIP);
// Check if the user is a spammer
if (bp_core_is_user_spammer($bp->loggedin_user->id) || bp_core_is_user_deleted($bp->loggedin_user->id)) {
return false;
}
// bb_insert_topic() will append tags, but not remove them. So we remove all existing tags.
bb_remove_topic_tags($topic_id);
if (!($topic_id = bb_insert_topic(array('topic_id' => $topic_id, 'topic_title' => stripslashes($topic_title), 'tags' => $topic_tags)))) {
return false;
}
if (!($post = bb_get_first_post($topic_id))) {
return false;
}
// Update the first post
if (!($post = bp_forums_insert_post(array('post_id' => $post->post_id, 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $post->post_time, 'poster_id' => $post->poster_id, 'poster_ip' => $post->poster_ip, 'post_status' => $post->post_status, 'post_position' => $post->post_position)))) {
return false;
}
return bp_forums_get_topic_details($topic_id);
}
示例8: _e
</th>
<th scope="col"><?php
_e('Date');
?>
</th>
<th scope="col"><?php
_e('Freshness');
?>
</th>
</tr>
</thead>
<tbody>
<?php
foreach ($topics as $topic) {
$first_post = bb_get_first_post($topic);
?>
<tr id="topic-<?php
echo $topic->topic_id;
?>
"<?php
topic_class();
?>
>
<td class="topic">
<span class="row-title"><?php
bb_topic_labels();
?>
<a href="<?php
topic_link();
?>
示例9: get_topic_author
function get_topic_author($id = 0)
{
$topic = get_topic(get_topic_id($id));
$first_post = bb_get_first_post($topic);
$user_display_name = get_post_author($first_post->post_id);
return apply_filters('get_topic_author', $user_display_name, $topic->topic_poster, $topic->topic_id);
// $topic->topic_poster = user ID
}
示例10: rfp_after_topic_title
function rfp_after_topic_title()
{
global $forum_template;
$topic_id = $forum_template->topic->topic_id;
$post = bb_get_first_post($topic_id, false);
$rating = rfp_get_post_rating_signed($post->post_id);
echo '<td class="rfp-topic-rating">' . $rating . '</td>';
}
示例11: GetBuddyPressRating
private function GetBuddyPressRating($ver, $horAlign = true)
{
if (RWLogger::IsOn()) {
$params = func_get_args();
RWLogger::LogEnterence("GetBuddyPressRating", $params);
}
global $activities_template;
// Set current activity-comment to current activity update (recursive comments).
$this->current_comment = $activities_template->activity;
$rclass = str_replace("_", "-", bp_get_activity_type());
$is_forum_topic = $rclass === "new-forum-topic";
if ($is_forum_topic && !$this->IsBBPressInstalled()) {
return false;
}
if ($is_forum_topic) {
$rclass = "new-forum-post";
}
// Check if item rating is top positioned.
if (!isset($this->activity_align[$rclass]) || $ver !== $this->activity_align[$rclass]->ver) {
return false;
}
// Get item id.
$item_id = "activity-update" === $rclass || "activity-comment" === $rclass ? bp_get_activity_id() : bp_get_activity_secondary_item_id();
if ($is_forum_topic) {
// If forum topic, then we must extract post id
// from forum posts table, because secondary_item_id holds
// topic id.
if (function_exists("bb_get_first_post")) {
$post = bb_get_first_post($item_id);
} else {
// Extract post id straight from the BB DB.
global $bb_table_prefix;
// Load bbPress config file.
@(include_once WP_RW__BBP_CONFIG_LOCATION);
// Failed loading config file.
if (!defined("BBDB_NAME")) {
return false;
}
$connection = null;
if (!($connection = mysql_connect(BBDB_HOST, BBDB_USER, BBDB_PASSWORD, true))) {
return false;
}
if (!mysql_selectdb(BBDB_NAME, $connection)) {
return false;
}
$results = mysql_query("SELECT * FROM {$bb_table_prefix}posts WHERE topic_id={$item_id} AND post_position=1", $connection);
$post = mysql_fetch_object($results);
}
if (!isset($post->post_id) && empty($post->post_id)) {
return false;
}
$item_id = $post->post_id;
}
// If the item is post, queue rating with post title.
$title = "new-blog-post" === $rclass ? get_the_title($item_id) : bp_get_activity_content_body();
// $activities_template->activity->content;
$options = array();
$owner_id = bp_get_activity_user_id();
// Add accumulator id if user accumulated rating.
if ($this->IsUserAccumulatedRating()) {
$options['uarid'] = $this->_getUserRatingGuid($owner_id);
}
return $this->EmbedRatingIfVisible($item_id, $owner_id, strip_tags($title), bp_activity_get_permalink(bp_get_activity_id()), $rclass, false, $horAlign ? $this->activity_align[$rclass]->hor : false, false, $options, false);
/*
// Queue activity rating.
$this->QueueRatingData($urid, strip_tags($title), bp_activity_get_permalink($activities_template->activity->id), $rclass);
// Return rating html container.
return '<div class="rw-ui-container rw-class-' . $rclass . ' rw-urid-' . $urid . '"></div>';*/
}
示例12: bp_forums_update_topic
function bp_forums_update_topic( $args = '' ) {
global $bp;
do_action( 'bbpress_init' );
$defaults = array(
'topic_id' => false,
'topic_title' => '',
'topic_text' => ''
);
$r = wp_parse_args( $args, $defaults );
extract( $r, EXTR_SKIP );
if ( !$topic_id = bb_insert_topic( array( 'topic_id' => $topic_id, 'topic_title' => stripslashes( $topic_title ) ) ) )
return false;
if ( !$post = bb_get_first_post( $topic_id ) )
return false;
/* Update the first post */
if ( !$post = bp_forums_insert_post( array( 'post_id' => $post->post_id, 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $post->post_time, 'poster_id' => $post->poster_id, 'poster_ip' => $post->poster_ip, 'post_status' => $post->post_status, 'post_position' => $post->post_position ) ) )
return false;
return bp_forums_get_topic_details( $topic_id );
}
示例13: rw_get_activity_rating
function rw_get_activity_rating($ver)
{
if (RWLogger::IsOn()) {
$params = func_get_args();
RWLogger::LogEnterence("rw_get_activity_rating", $params);
}
global $activities_template;
// Set current activity-comment to current activity update (recursive comments).
$this->current_comment = $activities_template->activity;
$rclass = str_replace("_", "-", $activities_template->activity->type);
$is_forum_topic = false;
if ($rclass === "new-forum-topic") {
$rclass = "new-forum-post";
$is_forum_topic = true;
}
// Check if item rating is top positioned.
if (!isset($this->activity_align[$rclass]) || $ver !== $this->activity_align[$rclass]->ver) {
return false;
}
// Get item id.
$item_id = "activity-update" === $rclass || "activity-comment" === $rclass ? $activities_template->activity->id : $activities_template->activity->secondary_item_id;
if ($is_forum_topic) {
// If forum topic, then we must extract post id
// from forum posts table, because secondary_item_id holds
// topic id.
if (function_exists("bb_get_first_post")) {
$post = bb_get_first_post($item_id);
} else {
// Extract post id straight from the BB DB.
$config_path = get_site_option("bb-config-location", "");
// bbPress is not installed.
if (empty($config_path)) {
return false;
}
global $bb_table_prefix;
// Load bbPress config file.
@(include_once $config_path);
// Failed loading config file.
if (!defined("BBDB_NAME")) {
return false;
}
$connection = null;
if (!($connection = mysql_connect(BBDB_HOST, BBDB_USER, BBDB_PASSWORD, true))) {
return false;
}
if (!mysql_selectdb(BBDB_NAME, $connection)) {
return false;
}
$results = mysql_query("SELECT * FROM {$bb_table_prefix}posts WHERE topic_id={$item_id} AND post_position=1", $connection);
$post = mysql_fetch_object($results);
}
if (!isset($post->post_id) && empty($post->post_id)) {
return false;
}
$item_id = $post->post_id;
}
// Validate that item isn't explicitly excluded.
if (false === $this->rw_validate_visibility($item_id, $rclass)) {
return false;
}
switch ($rclass) {
case "activity-update":
case "activity-comment":
// Get activity rating user-rating-id.
$urid = $this->_getActivityRatingGuid($item_id);
break;
case "new-blog-post":
// Get activity rating user-rating-id.
$urid = $this->_getPostRatingGuid($item_id);
break;
case "new-blog-comment":
// Get activity rating user-rating-id.
$urid = $this->_getCommentRatingGuid($item_id);
break;
/*case "new-forum-topic":*/
/*case "new-forum-topic":*/
case "new-forum-post":
// Get activity rating user-rating-id.
$urid = $this->_getForumPostRatingGuid($item_id);
break;
}
// If the item is post, queue rating with post title.
$title = "new-blog-post" === $rclass ? get_the_title($item_id) : $activities_template->activity->content;
// Queue activity rating.
self::QueueRatingData($urid, strip_tags($title), bp_activity_get_permalink($activities_template->activity->id), $rclass);
// Return rating html container.
return '<div class="rw-ui-container rw-class-' . $rclass . ' rw-urid-' . $urid . '"></div>';
}
示例14: bp_ning_import_process_inline_images_new
function bp_ning_import_process_inline_images_new($type, $post_ID, $post_type = 'post')
{
switch ($post_type) {
case 'post':
$post = get_post($post_ID);
$text = $post->post_content;
break;
case 'topic':
$topic = bb_get_first_post($post_ID);
$post_ID = (int) $topic->post_id;
$text = $topic->post_text;
break;
case 'topic_reply':
$reply = bb_get_post($post_ID);
$text = $reply->post_text;
break;
case 'comment':
$comment = get_comment($post_ID);
$text = $comment->comment_content;
break;
}
$ning_dir = content_url('/ning-files/');
$real_images = array();
// Only worry about local images
if (preg_match_all('#"(' . $type . '/.*?\\.(?:gif|jpg|jpeg|png|bmp))(?:\\?(?:[^"]*?))?"#', $text, $images)) {
// $images is an array of file names in import-from-ning/json/discussions. Move 'em
foreach ($images[1] as $image) {
$real_name = bp_ning_real_image_name($image);
if (!isset($real_images[$real_name])) {
$html = media_sideload_image($ning_dir . $image, $post_ID);
if (is_wp_error($html)) {
continue;
}
preg_match("#<img src='(.*?)'#", $html, $matches);
$url = $real_images[$real_name] = $matches[1];
} else {
$url = $real_images[$real_name];
}
$text = str_replace($image, $url, $text);
}
} else {
return;
}
switch ($post_type) {
case 'post':
$args = array('ID' => $post_ID, 'post_content' => $text);
$args = add_magic_quotes($args);
wp_update_post($args);
break;
case 'topic':
case 'topic_reply':
$args = array('post_id' => $post_ID, 'post_text' => $text);
bb_insert_post($args);
break;
case 'comment':
$args = array('comment_ID' => $post_ID, 'comment_content' => $text);
wp_update_comment($args);
break;
}
}