本文整理汇总了PHP中bbp_get_private_status_id函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_get_private_status_id函数的具体用法?PHP bbp_get_private_status_id怎么用?PHP bbp_get_private_status_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bbp_get_private_status_id函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: SavePost
public static function SavePost($post_id, $post, $update)
{
if (wp_is_post_revision($post_id) || $post->post_status != 'publish' || $post->post_type != 'namaste_course') {
return;
}
$meta = get_post_meta($post_id, 'buddypress_id', true);
if (empty($meta)) {
$group_id = groups_create_group(array('creator_id' => get_current_user_id(), 'name' => $post->post_title, 'description' => 'Обсуждение курса ' . $post->post_title, 'enable_forum' => 1));
update_post_meta($post_id, 'buddypress_id', $group_id);
groups_edit_group_settings($group_id, 1, 'private', 'mods');
$forum_id = bbp_insert_forum($forum_data = array('post_status' => bbp_get_private_status_id(), 'post_type' => bbp_get_forum_post_type(), 'post_author' => bbp_get_current_user_id(), 'post_content' => 'Обсуждение курса ' . $post->post_title, 'post_title' => $post->post_title), $forum_meta = array());
bbp_update_group_forum_ids($group_id, (array) $forum_id);
bbp_update_forum_group_ids($forum_id, (array) $group_id);
}
bbp_add_user_forum_subscription(bbp_get_current_user_id(), $forum_id);
update_post_meta($forum_id, '_forum_course_id', $post_id);
}
开发者ID:Bnei-Baruch,项目名称:mailchimpNamasteIntegration,代码行数:17,代码来源:CreateGroupAndForumForCourse.php
示例2: tehnik_bpp_filter_forums_by_permissions
/**
* This function filters the list of forums based on the users rank as set by the Mebmers plugin
*/
function tehnik_bpp_filter_forums_by_permissions($args = '')
{
$bbp = bbpress();
// Setup possible post__not_in array
$post_stati[] = bbp_get_public_status_id();
// Check if user can read private forums
if (current_user_can('read_private_forums')) {
$post_stati[] = bbp_get_private_status_id();
}
// Check if user can read hidden forums
if (current_user_can('read_hidden_forums')) {
$post_stati[] = bbp_get_hidden_status_id();
}
// The default forum query for most circumstances
$meta_query = array('post_type' => bbp_get_forum_post_type(), 'post_parent' => bbp_is_forum_archive() ? 0 : bbp_get_forum_id(), 'post_status' => implode(',', $post_stati), 'posts_per_page' => get_option('_bbp_forums_per_page', 50), 'orderby' => 'menu_order', 'order' => 'ASC');
//Get an array of IDs which the current user has permissions to view
$allowed_forums = tehnik_bpp_get_permitted_post_ids(new WP_Query($meta_query));
// The default forum query with allowed forum ids array added
$meta_query['post__in'] = $allowed_forums;
$bbp_f = bbp_parse_args($args, $meta_query, 'has_forums');
// Run the query
$bbp->forum_query = new WP_Query($bbp_f);
return apply_filters('bpp_filter_forums_by_permissions', $bbp->forum_query->have_posts(), $bbp->forum_query);
}
开发者ID:dnaleor,项目名称:Tehnik-bbPress-Permissions,代码行数:27,代码来源:tehnik_bpp_forum.php
示例3: bbp_is_reply_private
/**
* Is the reply private?
*
* @since 2.6.0 bbPress (r5507)
*
* @param int $reply_id Optional. Topic id
* @uses bbp_get_reply_id() To get the reply id
* @uses bbp_get_reply_status() To get the reply status
* @uses apply_filters() Calls 'bbp_is_reply_private' with the reply id
* @return bool True if private, false if not.
*/
function bbp_is_reply_private($reply_id = 0)
{
$reply_status = bbp_get_reply_status(bbp_get_reply_id($reply_id)) === bbp_get_private_status_id();
return (bool) apply_filters('bbp_is_reply_private', (bool) $reply_status, $reply_id);
}
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:16,代码来源:template.php
示例4: bbp_is_forum_private
/**
* Is the forum private?
*
* @since 2.0.0 bbPress (r2746)
*
* @param int $forum_id Optional. Forum id
* @param bool $check_ancestors Check if the ancestors are private
* @uses bbp_get_forum_id() To get the forum ID
* @uses bbp_is_forum_visibility() To check the forum visibility ID
* @return bool True if private, false if not
*/
function bbp_is_forum_private($forum_id = 0, $check_ancestors = true)
{
// Get the forum ID
$forum_id = bbp_get_forum_id($forum_id);
// Check if the forum or one of it's ancestors is private
$retval = bbp_is_forum_visibility($forum_id, bbp_get_private_status_id(), $check_ancestors, 'OR');
return (bool) apply_filters('bbp_is_forum_private', (bool) $retval, $forum_id, $check_ancestors);
}
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:19,代码来源:template.php
示例5: create_screen_save
/**
* Save the Group Forum data on create
*
* @since bbPress (r3465)
*/
public function create_screen_save()
{
check_admin_referer('groups_create_save_' . $this->slug);
$create_forum = !empty($_POST['bbp-create-group-forum']) ? true : false;
$forum_id = 0;
$forum_ids = bbp_get_group_forum_ids(bp_get_new_group_id());
if (!empty($forum_ids)) {
$forum_id = (int) is_array($forum_ids) ? $forum_ids[0] : $forum_ids;
}
// Create a forum, or not
switch ($create_forum) {
case true:
// Bail if initial content was already created
if (!empty($forum_id)) {
return;
}
// Set the default forum status
switch (bp_get_new_group_status()) {
case 'hidden':
$status = bbp_get_hidden_status_id();
break;
case 'private':
$status = bbp_get_private_status_id();
break;
case 'public':
default:
$status = bbp_get_public_status_id();
break;
}
// Create the initial forum
$forum_id = bbp_insert_forum(array('post_parent' => bbp_get_group_forums_root_id(), 'post_title' => bp_get_new_group_name(), 'post_content' => bp_get_new_group_description(), 'post_status' => $status));
// Run the BP-specific functions for new groups
$this->new_forum(array('forum_id' => $forum_id));
break;
case false:
// Forum was created but is now being undone
if (!empty($forum_id)) {
wp_delete_post($forum_id, true);
groups_delete_groupmeta(bp_get_new_group_id(), 'forum_id');
}
break;
}
}
开发者ID:hscale,项目名称:webento,代码行数:48,代码来源:bbp-extend-buddypress.php
示例6: bbp_pre_get_posts_normalize_forum_visibility
/**
* Adjusts forum, topic, and reply queries to exclude items that might be
* contained inside hidden or private forums that the user does not have the
* capability to view.
*
* Doing it with an action allows us to trap all WP_Query's rather than needing
* to hardcode this logic into each query. It also protects forum content for
* plugins that might be doing their own queries.
*
* @since bbPress (r3291)
*
* @param WP_Query $posts_query
*
* @uses apply_filters()
* @uses bbp_exclude_forum_ids()
* @uses bbp_get_topic_post_type()
* @uses bbp_get_reply_post_type()
* @return WP_Query
*/
function bbp_pre_get_posts_normalize_forum_visibility($posts_query = null)
{
// Bail if all forums are explicitly allowed
if (true === apply_filters('bbp_include_all_forums', false, $posts_query)) {
return;
}
// Bail if $posts_query is not an object or of incorrect class
if (!is_object($posts_query) || !is_a($posts_query, 'WP_Query')) {
return;
}
// Get query post types array .
$post_types = (array) $posts_query->get('post_type');
// Forums
if (bbp_get_forum_post_type() === implode('', $post_types)) {
// Prevent accidental wp-admin post_row override
if (is_admin() && isset($_REQUEST['post_status'])) {
return;
}
/** Default ***********************************************************/
// Get any existing post status
$post_stati = $posts_query->get('post_status');
// Default to public status
if (empty($post_stati)) {
$post_stati[] = bbp_get_public_status_id();
// Split the status string
} elseif (is_string($post_stati)) {
$post_stati = explode(',', $post_stati);
}
/** Private ***********************************************************/
// Remove bbp_get_private_status_id() if user is not capable
if (!current_user_can('read_private_forums')) {
$key = array_search(bbp_get_private_status_id(), $post_stati);
if (!empty($key)) {
unset($post_stati[$key]);
}
// ...or add it if they are
} else {
$post_stati[] = bbp_get_private_status_id();
}
/** Hidden ************************************************************/
// Remove bbp_get_hidden_status_id() if user is not capable
if (!current_user_can('read_hidden_forums')) {
$key = array_search(bbp_get_hidden_status_id(), $post_stati);
if (!empty($key)) {
unset($post_stati[$key]);
}
// ...or add it if they are
} else {
$post_stati[] = bbp_get_hidden_status_id();
}
// Add the statuses
$posts_query->set('post_status', array_unique(array_filter($post_stati)));
}
// Topics Or Replies
if (array_intersect(array(bbp_get_topic_post_type(), bbp_get_reply_post_type()), $post_types)) {
// Get forums to exclude
$forum_ids = bbp_exclude_forum_ids('meta_query');
// Bail if no forums to exclude
if (!array_filter($forum_ids)) {
return;
}
// Get any existing meta queries
$meta_query = $posts_query->get('meta_query');
// Add our meta query to existing
$meta_query[] = $forum_ids;
// Set the meta_query var
$posts_query->set('meta_query', $meta_query);
}
}
开发者ID:jenia-buianov,项目名称:all_my_sites,代码行数:88,代码来源:functions.php
示例7: bbp_has_replies
/**
* The main reply loop. WordPress makes this easy for us
*
* @since bbPress (r2553)
*
* @param mixed $args All the arguments supported by {@link WP_Query}
* @uses bbp_show_lead_topic() Are we showing the topic as a lead?
* @uses bbp_get_topic_id() To get the topic id
* @uses bbp_get_reply_post_type() To get the reply post type
* @uses bbp_get_topic_post_type() To get the topic post type
* @uses get_option() To get the replies per page option
* @uses bbp_get_paged() To get the current page value
* @uses current_user_can() To check if the current user is capable of editing
* others' replies
* @uses WP_Query To make query and get the replies
* @uses WP_Rewrite::using_permalinks() To check if the blog is using permalinks
* @uses get_permalink() To get the permalink
* @uses add_query_arg() To add custom args to the url
* @uses apply_filters() Calls 'bbp_replies_pagination' with the pagination args
* @uses paginate_links() To paginate the links
* @uses apply_filters() Calls 'bbp_has_replies' with
* bbPres::reply_query::have_posts()
* and bbPres::reply_query
* @return object Multidimensional array of reply information
*/
function bbp_has_replies($args = '')
{
global $wp_rewrite;
/** Defaults **************************************************************/
// Other defaults
$default_reply_search = !empty($_REQUEST['rs']) ? $_REQUEST['rs'] : false;
$default_post_parent = bbp_is_single_topic() ? bbp_get_topic_id() : 'any';
$default_post_type = bbp_is_single_topic() && bbp_show_lead_topic() ? bbp_get_reply_post_type() : array(bbp_get_topic_post_type(), bbp_get_reply_post_type());
$default_thread_replies = (bool) (bbp_is_single_topic() && bbp_thread_replies());
// Default query args
$default = array('post_type' => $default_post_type, 'post_parent' => $default_post_parent, 'posts_per_page' => bbp_get_replies_per_page(), 'paged' => bbp_get_paged(), 'orderby' => 'date', 'order' => 'ASC', 'hierarchical' => $default_thread_replies, 'ignore_sticky_posts' => true, 's' => $default_reply_search);
// What are the default allowed statuses (based on user caps)
if (bbp_get_view_all()) {
// Default view=all statuses
$post_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id());
// Add support for private status
if (current_user_can('read_private_replies')) {
$post_statuses[] = bbp_get_private_status_id();
}
// Join post statuses together
$default['post_status'] = implode(',', $post_statuses);
// Lean on the 'perm' query var value of 'readable' to provide statuses
} else {
$default['perm'] = 'readable';
}
/** Setup *****************************************************************/
// Parse arguments against default values
$r = bbp_parse_args($args, $default, 'has_replies');
// Set posts_per_page value if replies are threaded
$replies_per_page = $r['posts_per_page'];
if (true === $r['hierarchical']) {
$r['posts_per_page'] = -1;
}
// Get bbPress
$bbp = bbpress();
// Call the query
$bbp->reply_query = new WP_Query($r);
// Add pagination values to query object
$bbp->reply_query->posts_per_page = $replies_per_page;
$bbp->reply_query->paged = $r['paged'];
// Never home, regardless of what parse_query says
$bbp->reply_query->is_home = false;
// Reset is_single if single topic
if (bbp_is_single_topic()) {
$bbp->reply_query->is_single = true;
}
// Only add reply to if query returned results
if ((int) $bbp->reply_query->found_posts) {
// Get reply to for each reply
foreach ($bbp->reply_query->posts as &$post) {
// Check for reply post type
if (bbp_get_reply_post_type() === $post->post_type) {
$reply_to = bbp_get_reply_to($post->ID);
// Make sure it's a reply to a reply
if (empty($reply_to) || bbp_get_reply_topic_id($post->ID) === $reply_to) {
$reply_to = 0;
}
// Add reply_to to the post object so we can walk it later
$post->reply_to = $reply_to;
}
}
}
// Only add pagination if query returned results
if ((int) $bbp->reply_query->found_posts && (int) $bbp->reply_query->posts_per_page) {
// If pretty permalinks are enabled, make our pagination pretty
if ($wp_rewrite->using_permalinks()) {
// User's replies
if (bbp_is_single_user_replies()) {
$base = bbp_get_user_replies_created_url(bbp_get_displayed_user_id());
// Root profile page
} elseif (bbp_is_single_user()) {
$base = bbp_get_user_profile_url(bbp_get_displayed_user_id());
// Page or single post
} elseif (is_page() || is_single()) {
$base = get_permalink();
//.........这里部分代码省略.........
开发者ID:danielcoats,项目名称:schoolpress,代码行数:101,代码来源:template.php
示例8: test_bbp_get_all_child_ids
/**
* @covers ::bbp_get_all_child_ids
*/
public function test_bbp_get_all_child_ids()
{
$f = $this->factory->forum->create();
// Test initial forum public child counts
$count = count(bbp_get_all_child_ids($f, bbp_get_forum_post_type()));
$this->assertSame(0, $count);
$count = count(bbp_get_all_child_ids($f, bbp_get_topic_post_type()));
$this->assertSame(0, $count);
/* Sub-Forums *********************************************************/
$this->factory->forum->create_many(3, array('post_parent' => $f));
$this->factory->forum->create(array('post_parent' => $f, 'post_status' => bbp_get_private_status_id()));
$count = count(bbp_get_all_child_ids($f, bbp_get_forum_post_type()));
$this->assertSame(4, $count);
$this->factory->forum->create_many(2, array('post_parent' => $f));
$count = count(bbp_get_all_child_ids($f, bbp_get_forum_post_type()));
$this->assertSame(6, $count);
/* Topics *************************************************************/
$t1 = $this->factory->topic->create_many(3, array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f)));
$this->factory->topic->create(array('post_parent' => $f, 'post_status' => bbp_get_spam_status_id(), 'topic_meta' => array('forum_id' => $f)));
$count = count(bbp_get_all_child_ids($f, bbp_get_topic_post_type()));
$this->assertSame(4, $count);
$this->factory->topic->create_many(2, array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f)));
$count = count(bbp_get_all_child_ids($f, bbp_get_topic_post_type()));
$this->assertSame(6, $count);
$this->factory->topic->create(array('post_parent' => $f, 'post_status' => bbp_get_pending_status_id(), 'topic_meta' => array('forum_id' => $f)));
$count = count(bbp_get_all_child_ids($f, bbp_get_topic_post_type()));
$this->assertSame(7, $count);
/* Replies ************************************************************/
$this->factory->reply->create_many(3, array('post_parent' => $t1[0], 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t1[0])));
$this->factory->reply->create(array('post_parent' => $t1[0], 'post_status' => bbp_get_spam_status_id(), 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t1[0])));
$count = count(bbp_get_all_child_ids($t1[0], bbp_get_reply_post_type()));
$this->assertSame(4, $count);
$this->factory->reply->create_many(2, array('post_parent' => $t1[0], 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t1[0])));
$count = count(bbp_get_all_child_ids($t1[0], bbp_get_reply_post_type()));
$this->assertSame(6, $count);
$this->factory->reply->create(array('post_parent' => $t1[0], 'post_status' => bbp_get_pending_status_id(), 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t1[0])));
$count = count(bbp_get_all_child_ids($t1[0], bbp_get_reply_post_type()));
$this->assertSame(7, $count);
}
开发者ID:joeyblake,项目名称:bbpress,代码行数:42,代码来源:query.php
示例9: bbp_get_form_forum_visibility_dropdown
/**
* Return the forum visibility dropdown
*
* @since bbPress (r3563)
*
* @param int $forum_id The forum id to use
* @uses bbp_is_topic_edit() To check if it's the topic edit page
* @uses bbp_get_forum_visibility() To get the forum visibility
* @uses apply_filters()
* @return string HTML select list for selecting forum visibility
*/
function bbp_get_form_forum_visibility_dropdown($forum_id = 0)
{
$forum_id = bbp_get_forum_id($forum_id);
$forum_attr = apply_filters('bbp_forum_visibilities', array(bbp_get_public_status_id() => __('Public', 'bbpress'), bbp_get_private_status_id() => __('Private', 'bbpress'), bbp_get_hidden_status_id() => __('Hidden', 'bbpress')));
$visibility_output = '<select name="bbp_forum_visibility" id="bbp_forum_visibility_select">' . "\n";
foreach ($forum_attr as $value => $label) {
$visibility_output .= "\t" . '<option value="' . $value . '"' . selected(bbp_get_forum_visibility($forum_id), $value, false) . '>' . esc_html($label) . '</option>' . "\n";
}
$visibility_output .= '</select>';
return apply_filters('bbp_get_form_forum_visibility_dropdown', $visibility_output, $forum_id, $forum_attr);
}
开发者ID:hscale,项目名称:webento,代码行数:22,代码来源:bbp-forum-template.php
示例10: create_screen_save_notab
public function create_screen_save_notab($group_id = 0)
{
// No nonce check, since there's no tab
// Check for possibly empty group_id
if (empty($group_id)) {
$group_id = bp_get_new_group_id();
}
// We always set this true, because we always create a forum (the user doesn't get to choose whether they want it or not anymore)
$create_forum = true;
//!empty( $_POST['bbp-create-group-forum'] ) ? true : false;
$forum_id = 0;
$forum_ids = bbp_get_group_forum_ids($group_id);
if (!empty($forum_ids)) {
$forum_id = (int) is_array($forum_ids) ? $forum_ids[0] : $forum_ids;
}
// Create a forum, or not
switch ($create_forum) {
case true:
// Bail if initial content was already created
if (!empty($forum_id)) {
return;
}
// Set the default forum status
switch (bp_get_new_group_status()) {
case 'hidden':
$status = bbp_get_hidden_status_id();
break;
case 'private':
$status = bbp_get_private_status_id();
break;
case 'public':
default:
$status = bbp_get_public_status_id();
break;
}
// Create the initial forum
$forum_id = bbp_insert_forum(array('post_parent' => bbp_get_group_forums_root_id(), 'post_title' => bp_get_new_group_name(), 'post_content' => bp_get_new_group_description(), 'post_status' => $status));
// Run the BP-specific functions for new groups
$this->new_forum(array('forum_id' => $forum_id));
// Update forum active
groups_update_groupmeta(bp_get_new_group_id(), '_bbp_forum_enabled_' . $forum_id, true);
// Toggle forum on
$this->toggle_group_forum(bp_get_new_group_id(), true);
break;
case false:
// Forum was created but is now being undone
if (!empty($forum_id)) {
// Delete the forum
wp_delete_post($forum_id, true);
// Delete meta values
groups_delete_groupmeta(bp_get_new_group_id(), 'forum_id');
groups_delete_groupmeta(bp_get_new_group_id(), '_bbp_forum_enabled_' . $forum_id);
// Toggle forum off
$this->toggle_group_forum(bp_get_new_group_id(), false);
}
break;
}
}
开发者ID:paulmedwal,项目名称:edxforumspublic,代码行数:58,代码来源:groups.php
示例11: bbp_admin_repair_forum_visibility
/**
* Recaches the private and hidden forums
*
* @since bbPress (r4104)
*
* @uses delete_option() to delete private and hidden forum pointers
* @uses WP_Query() To query post IDs
* @uses is_wp_error() To return if error occurred
* @uses update_option() To update the private and hidden post ID pointers
* @return array An array of the status code and the message
*/
function bbp_admin_repair_forum_visibility()
{
$statement = __('Recalculating forum visibility … %s', 'bbpress');
$result = __('Failed!', 'bbpress');
// First, delete everything.
delete_option('_bbp_private_forums');
delete_option('_bbp_hidden_forums');
// Next, get all the private and hidden forums
$private_forums = new WP_Query(array('suppress_filters' => true, 'nopaging' => true, 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_private_status_id(), 'fields' => 'ids'));
$hidden_forums = new WP_Query(array('suppress_filters' => true, 'nopaging' => true, 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_hidden_status_id(), 'fields' => 'ids'));
// Bail if queries returned errors
if (is_wp_error($private_forums) || is_wp_error($hidden_forums)) {
return array(2, sprintf($statement, $result));
}
update_option('_bbp_private_forums', $private_forums->posts);
// Private forums
update_option('_bbp_hidden_forums', $hidden_forums->posts);
// Hidden forums
// Complete results
$result = __('Complete!', 'bbpress');
return array(0, sprintf($statement, $result));
}
开发者ID:hscale,项目名称:webento,代码行数:33,代码来源:bbp-tools.php
示例12: test_bbp_is_forum_private
/**
* @covers ::bbp_is_forum_private
*/
public function test_bbp_is_forum_private()
{
$f = $this->factory->forum->create(array('post_status' => 'private'));
$forum = bbp_get_forum_visibility($f);
$this->assertSame('private', $forum);
$forum_status_id = bbp_get_private_status_id($f);
$this->assertSame('private', $forum_status_id);
$this->assertTrue(bbp_is_forum_private($f));
}
开发者ID:joeyblake,项目名称:bbpress,代码行数:12,代码来源:status.php
示例13: row_actions
/**
* Forum Row actions
*
* Remove the quick-edit action link and display the description under
* the forum title and add the open/close links
*
* @since 2.0.0 bbPress (r2577)
*
* @param array $actions Actions
* @param array $forum Forum object
* @uses bbp_get_public_status_id() To get the published forum id's
* @uses bbp_get_private_status_id() To get the private forum id's
* @uses bbp_get_hidden_status_id() To get the hidden forum id's
* @uses bbp_get_closed_status_id() To get the closed forum id's
* @uses wp_nonce_url() To nonce the url
* @uses bbp_is_forum_open() To check if a forum is open
* @uses bbp_forum_content() To output forum description
* @return array $actions Actions
*/
public function row_actions($actions, $forum)
{
if ($this->bail()) {
return $actions;
}
unset($actions['inline hide-if-no-js']);
// Only show the actions if the user is capable of viewing them :)
if (current_user_can('keep_gate', $forum->ID)) {
// Show the 'close' and 'open' link on published, private, hidden and closed posts only
if (in_array($forum->post_status, array(bbp_get_public_status_id(), bbp_get_private_status_id(), bbp_get_hidden_status_id(), bbp_get_closed_status_id()))) {
$close_uri = wp_nonce_url(add_query_arg(array('forum_id' => $forum->ID, 'action' => 'bbp_toggle_forum_close'), remove_query_arg(array('bbp_forum_toggle_notice', 'forum_id', 'failed', 'super'))), 'close-forum_' . $forum->ID);
if (bbp_is_forum_open($forum->ID)) {
$actions['closed'] = '<a href="' . esc_url($close_uri) . '" title="' . esc_attr__('Close this forum', 'bbpress') . '">' . _x('Close', 'Close a Forum', 'bbpress') . '</a>';
} else {
$actions['closed'] = '<a href="' . esc_url($close_uri) . '" title="' . esc_attr__('Open this forum', 'bbpress') . '">' . _x('Open', 'Open a Forum', 'bbpress') . '</a>';
}
}
}
// simple hack to show the forum description under the title
bbp_forum_content($forum->ID);
return $actions;
}
开发者ID:joeyblake,项目名称:bbpress,代码行数:41,代码来源:forums.php
示例14: bbp_list_private_groups_subforums
function bbp_list_private_groups_subforums($args)
{
// Use passed integer as post_parent
if (is_numeric($args)) {
$args = array('post_parent' => $args);
}
// Setup possible post__not_in array
$post_stati[] = bbp_get_public_status_id();
// Super admin get whitelisted post statuses
if (bbp_is_user_keymaster()) {
$post_stati = array(bbp_get_public_status_id(), bbp_get_private_status_id(), bbp_get_hidden_status_id());
// Not a keymaster, so check caps
} else {
// Check if user can read private forums
if (current_user_can('read_private_forums')) {
$post_stati[] = bbp_get_private_status_id();
}
// Check if user can read hidden forums
if (current_user_can('read_hidden_forums')) {
$post_stati[] = bbp_get_hidden_status_id();
}
}
$args['post_status'] = implode(',', $post_stati);
return $args;
}
开发者ID:USSLomaPrieta,项目名称:usslomaprieta.org,代码行数:25,代码来源:forum-filters.php
示例15: include_private_forums
public static function include_private_forums($posts_query)
{
// Bail if $posts_query is not an object or of incorrect class
if (!is_object($posts_query) || !is_a($posts_query, 'WP_Query')) {
return;
}
// Get query post types array .
$post_types = (array) $posts_query->get('post_type');
// Forums
if (bbp_get_forum_post_type() === implode('', $post_types)) {
// Prevent accidental wp-admin post_row override
if (is_admin() && isset($_REQUEST['post_status'])) {
return;
}
/** Default ***********************************************************/
// Get any existing post status
$post_stati = (array) $posts_query->get('post_status');
if (!in_array(bbp_get_private_status_id(), $post_stati)) {
$post_stati[] = bbp_get_private_status_id();
// Add the statuses
$posts_query->set('post_status', array_unique(array_filter($post_stati)));
}
}
}
开发者ID:082net,项目名称:bbpresskr,代码行数:24,代码来源:permissions.php
示例16: test_bbp_is_reply_private
/**
* @covers ::bbp_is_reply_private
*/
public function test_bbp_is_reply_private()
{
$forum_id = $this->factory->forum->create();
$topic_id = $this->factory->topic->create(array('post_parent' => $forum_id, 'topic_meta' => array('forum_id' => $forum_id)));
$reply_id = $this->factory->reply->create(array('post_parent' => $topic_id, 'reply_meta' => array('forum_id' => $forum_id, 'topic_id' => $topic_id)));
$reply_private = bbp_is_reply_private($reply_id);
$this->assertFalse($reply_private);
$r = $this->factory->reply->create(array('post_parent' => $topic_id, 'post_status' => bbp_get_private_status_id(), 'reply_meta' => array('forum_id' => $forum_id, 'topic_id' => $topic_id)));
$reply_private = bbp_is_reply_private($r);
$this->assertTrue($reply_private);
}
开发者ID:joeyblake,项目名称:bbpress,代码行数:14,代码来源:status.php
示例17: bbp_is_forum_private
/**
* Is the forum private?
*
* @since bbPress (r2746)
*
* @param int $forum_id Optional. Forum id
* @param bool $check_ancestors Check if the ancestors are private (only if
* they're a category)
* @uses get_post_meta() To get the forum private meta
* @uses bbp_get_forum_ancestors() To get the forum ancestors
* @uses bbp_is_forum_category() To check if the forum is a category
* @uses bbp_is_forum_closed() To check if the forum is closed
* @return bool True if closed, false if not
*/
function bbp_is_forum_private($forum_id = 0, $check_ancestors = true)
{
$forum_id = bbp_get_forum_id($forum_id);
$visibility = bbp_get_forum_visibility($forum_id);
// If post status is private, return true
$retval = bbp_get_private_status_id() === $visibility;
// Check ancestors and inherit their privacy setting for display
if (!empty($check_ancestors)) {
$ancestors = bbp_get_forum_ancestors($forum_id);
foreach ((array) $ancestors as $ancestor) {
if (bbp_is_forum($ancestor) && bbp_is_forum_private($ancestor, false)) {
$retval = true;
}
}
}
return (bool) apply_filters('bbp_is_forum_private', (bool) $retval, $forum_id, $check_ancestors);
}
开发者ID:ReLiFeD,项目名称:irreversible.eu,代码行数:31,代码来源:template.php
示例18: bp_group_organizer_admin_page
function bp_group_organizer_admin_page()
{
global $wpdb;
// Permissions Check
if (!current_user_can('manage_options')) {
wp_die(__('Cheatin’ uh?'));
}
// Load all the nav menu interface functions
require_once 'includes/group-meta-boxes.php';
require_once 'includes/group-organizer-template.php';
require_once 'includes/group-organizer.php';
// Container for any messages displayed to the user
$messages = array();
// Container that stores the name of the active menu
$nav_menu_selected_title = '';
// Allowed actions: add, update, delete
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'edit';
$errored = false;
switch ($action) {
case 'add-group':
check_admin_referer('add-group', 'group-settings-column-nonce');
$group['name'] = stripslashes($_POST['group_name']);
$group['description'] = stripslashes($_POST['group_desc']);
$group['slug'] = groups_check_slug($_POST['group_slug']);
$group['status'] = $_POST['group_status'];
$group['enable_forum'] = isset($_POST['group_forum']) ? true : false;
$group['date_created'] = date('Y-m-d H:i:s');
if ($group['slug'] != $_POST['group_slug']) {
$messages[] = '<div class="updated warning"><p>' . sprintf(__('The group slug you specified was unavailable or invalid. This group was created with the slug: <code>%s</code>.', 'bp-group-organizer'), $group['slug']) . '</p></div>';
}
if (empty($group['name'])) {
$messages[] = '<div class="error"><p>' . __('Group could not be created because one or more required fields were not filled in', 'bp-group-organizer') . '</p></div>';
$errored = true;
}
if (!$errored) {
$group_id = groups_create_group($group);
if (!$group_id) {
$wpdb->show_errors();
$wpdb->print_error();
$messages[] = '<div class="error"><p>' . __('Group was not successfully created.', 'bp-group-organizer') . '</p></div>';
} else {
$messages[] = '<div class="updated"><p>' . __('Group was created successfully.', 'bp-group-organizer') . '</p></div>';
}
}
if (!empty($group_id)) {
groups_update_groupmeta($group_id, 'total_member_count', 1);
if (bpgo_is_hierarchy_available()) {
$obj_group = new BP_Groups_Hierarchy($group_id);
$obj_group->parent_id = (int) $_POST['group_parent'];
$obj_group->save();
}
// Create the forum if enable_forum is checked
if ($group['enable_forum']) {
// Ensure group forums are activated, and group does not already have a forum
if (bp_is_active('forums')) {
// Check for BuddyPress group forums
if (!groups_get_groupmeta($group_id, 'forum_id')) {
groups_new_group_forum($group_id, $group['name'], $group['description']);
}
} else {
if (function_exists('bbp_is_group_forums_active') && bbp_is_group_forums_active()) {
// Check for bbPress group forums
if (count(bbp_get_group_forum_ids($group_id)) == 0) {
// Create the group forum - implementation from BBP_Forums_Group_Extension:create_screen_save
// Set the default forum status
switch ($group['status']) {
case 'hidden':
$status = bbp_get_hidden_status_id();
break;
case 'private':
$status = bbp_get_private_status_id();
break;
case 'public':
default:
$status = bbp_get_public_status_id();
break;
}
// Create the initial forum
$forum_id = bbp_insert_forum(array('post_parent' => bbp_get_group_forums_root_id(), 'post_title' => $group['name'], 'post_content' => $group['description'], 'post_status' => $status));
bbp_add_forum_id_to_group($group_id, $forum_id);
bbp_add_group_id_to_forum($forum_id, $group_id);
}
}
}
}
do_action('bp_group_organizer_save_new_group_options', $group_id);
}
break;
case 'delete-group':
$group_id = (int) $_REQUEST['group_id'];
check_admin_referer('delete-group_' . $group_id);
break;
case 'update':
check_admin_referer('update-groups', 'update-groups-nonce');
$groups_order = $_POST['group'];
$parent_ids = $_POST['menu-item-parent-id'];
$db_ids = $_POST['menu-item-db-id'];
foreach ($groups_order as $id => $group) {
$group_reference = new BP_Groups_Group($id);
if (defined('BP_GROUP_HIERARCHY_IS_INSTALLED') && method_exists('BP_Groups_Hierarchy', 'get_tree')) {
//.........这里部分代码省略.........
开发者ID:adisonc,项目名称:MaineLearning,代码行数:101,代码来源:index.php
示例19: bbp_get_all_child_ids
/**
* Query the DB and get a the child id's of all children
*
* @since 2.0.0 bbPress (r3325)
*
* @param int $parent_id Parent id
* @param string $post_type Post type. Defaults to 'post'
* @uses wp_cache_get() To check if there is a cache of the children
* @uses bbp_get_public_status_id() To get the public status id
* @uses bbp_get_private_status_id() To get the private status id
* @uses bbp_get_hidden_status_id() To get the hidden status id
* @uses bbp_get_pending_status_id() To get the pending status id
* @uses bbp_get_closed_status_id() To get the closed status id
* @uses bbp_get_trash_status_id() To get the trash status id
* @uses bbp_get_spam_status_id() To get the spam status id
* @uses bbp_get_forum_post_type() To get the forum post type
* @uses bbp_get_topic_post_type() To get the topic post type
* @uses bbp_get_reply_post_type() To get the reply post type
* @uses wpdb::prepare() To prepare the query
* @uses wpdb::get_col() To get the result of the query in an array
* @uses wp_cache_set() To set the cache for future use
* @uses apply_filters() Calls 'bbp_get_all_child_ids' with the child ids,
* parent id and post type
* @return array The array of children
*/
function bbp_get_all_child_ids($parent_id = 0, $post_type = 'post')
{
// Bail if nothing passed
if (empty($parent_id)) {
return false;
}
// The ID of the cached query
$cache_id = 'bbp_parent_all_' . $parent_id . '_type_' . $post_type . '_child_ids';
// Check for cache and set if needed
$child_ids = wp_cache_get($cache_id, 'bbpress_posts');
if (false === $child_ids) {
$post_status = array(bbp_get_public_status_id());
// Extra post statuses based on post type
|
请发表评论