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


PHP bbp_get_hidden_status_id函数代码示例

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


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

示例1: 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

示例2: 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
        switch ($post_type) {
            // Forum
            case bbp_get_forum_post_type():
                $post_status[] = bbp_get_private_status_id();
                $post_status[] = bbp_get_hidden_status_id();
                break;
                // Topic
            // Topic
            case bbp_get_topic_post_type():
                $post_status[] = bbp_get_pending_status_id();
                $post_status[] = bbp_get_closed_status_id();
                $post_status[] = bbp_get_trash_status_id();
                $post_status[] = bbp_get_spam_status_id();
                break;
                // Reply
            // Reply
            case bbp_get_reply_post_type():
                $post_status[] = bbp_get_pending_status_id();
                $post_status[] = bbp_get_trash_status_id();
                $post_status[] = bbp_get_spam_status_id();
                break;
        }
        // Join post statuses together
        $post_status = "'" . implode("', '", $post_status) . "'";
        $bbp_db = bbp_db();
        $query = $bbp_db->prepare("SELECT ID FROM {$bbp_db->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s' ORDER BY ID DESC;", $parent_id, $post_type);
        $child_ids = (array) $bbp_db->get_col($query);
        wp_cache_set($cache_id, $child_ids, 'bbpress_posts');
    } else {
        $child_ids = (array) $child_ids;
    }
    // Filter and return
    return (array) apply_filters('bbp_get_all_child_ids', $child_ids, $parent_id, $post_type);
}
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:72,代码来源:functions.php

示例3: 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

示例4: bbp_is_forum_hidden

/**
 * Is the forum hidden?
 *
 * @since bbPress (r2997)
 *
 * @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_hidden($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_hidden_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_hidden($ancestor, false)) {
                $retval = true;
            }
        }
    }
    return (bool) apply_filters('bbp_is_forum_hidden', (bool) $retval, $forum_id, $check_ancestors);
}
开发者ID:ReLiFeD,项目名称:irreversible.eu,代码行数:31,代码来源:template.php

示例5: bbp_is_forum_hidden

/**
 * Is the forum hidden?
 *
 * @since 2.0.0 bbPress (r2997)
 *
 * @param int $forum_id Optional. Forum id
 * @param bool $check_ancestors Check if the ancestors are private (only if
 *                               they're a category)
 * @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 hidden, false if not
 */
function bbp_is_forum_hidden($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 hidden
    $retval = bbp_is_forum_visibility($forum_id, bbp_get_hidden_status_id(), $check_ancestors, 'OR');
    return (bool) apply_filters('bbp_is_forum_hidden', (bool) $retval, $forum_id, $check_ancestors);
}
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:20,代码来源:template.php

示例6: register_post_statuses

 /**
  * Register the post statuses used by bbPress
  *
  * We do some manipulation of the 'trash' status so trashed topics and
  * replies can be viewed from within the theme.
  *
  * @since bbPress (r2727)
  * @uses register_post_status() To register post statuses
  * @uses $wp_post_statuses To modify trash and private statuses
  * @uses current_user_can() To check if the current user is capable &
  *                           modify $wp_post_statuses accordingly
  */
 public static function register_post_statuses()
 {
     // Closed
     register_post_status(bbp_get_closed_status_id(), apply_filters('bbp_register_closed_post_status', array('label' => _x('Closed', 'post', 'bbpress'), 'label_count' => _nx_noop('Closed <span class="count">(%s)</span>', 'Closed <span class="count">(%s)</span>', 'post', 'bbpress'), 'public' => true, 'show_in_admin_all' => true)));
     // Spam
     register_post_status(bbp_get_spam_status_id(), apply_filters('bbp_register_spam_post_status', array('label' => _x('Spam', 'post', 'bbpress'), 'label_count' => _nx_noop('Spam <span class="count">(%s)</span>', 'Spam <span class="count">(%s)</span>', 'post', 'bbpress'), 'protected' => true, 'exclude_from_search' => true, 'show_in_admin_status_list' => true, 'show_in_admin_all_list' => false)));
     // Orphan
     register_post_status(bbp_get_orphan_status_id(), apply_filters('bbp_register_orphan_post_status', array('label' => _x('Orphan', 'post', 'bbpress'), 'label_count' => _nx_noop('Orphan <span class="count">(%s)</span>', 'Orphans <span class="count">(%s)</span>', 'post', 'bbpress'), 'protected' => true, 'exclude_from_search' => true, 'show_in_admin_status_list' => true, 'show_in_admin_all_list' => false)));
     // Hidden
     register_post_status(bbp_get_hidden_status_id(), apply_filters('bbp_register_hidden_post_status', array('label' => _x('Hidden', 'post', 'bbpress'), 'label_count' => _nx_noop('Hidden <span class="count">(%s)</span>', 'Hidden <span class="count">(%s)</span>', 'post', 'bbpress'), 'private' => true, 'exclude_from_search' => true, 'show_in_admin_status_list' => true, 'show_in_admin_all_list' => true)));
     /**
      * Trash fix
      *
      * We need to remove the internal arg and change that to
      * protected so that the users with 'view_trash' cap can view
      * single trashed topics/replies in the front-end as wp_query
      * doesn't allow any hack for the trashed topics to be viewed.
      */
     global $wp_post_statuses;
     if (!empty($wp_post_statuses['trash'])) {
         // User can view trash so set internal to false
         if (current_user_can('view_trash')) {
             $wp_post_statuses['trash']->internal = false;
             $wp_post_statuses['trash']->protected = true;
             // User cannot view trash so set internal to true
         } else {
             $wp_post_statuses['trash']->internal = true;
         }
     }
 }
开发者ID:jenia-buianov,项目名称:all_my_sites,代码行数:42,代码来源:bbpress.php

示例7: bbp_pre_get_posts_exclude_forums

/**
 * Adjusts 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.
 *
 * @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_exclude_forums($posts_query)
{
    // Bail if all forums are explicitly allowed
    if (true === apply_filters('bbp_include_all_forums', $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;
    }
    // Bail if filters are suppressed on this query
    if (true == $posts_query->get('suppress_filters')) {
        return;
    }
    // Only exclude forums on bbPress queries
    switch ($posts_query->get('post_type')) {
        // Forums
        case bbp_get_forum_post_type():
            // Prevent accidental wp-admin post_row override
            if (is_admin() && isset($_REQUEST['post_status'])) {
                break;
            }
            // Define local variable
            $status = array();
            // All users can see published forums
            $status[] = bbp_get_public_status_id();
            // Add bbp_get_private_status_id() if user is capable
            if (current_user_can('read_private_forums')) {
                $status[] = bbp_get_private_status_id();
            }
            // Add bbp_get_hidden_status_id() if user is capable
            if (current_user_can('read_hidden_forums')) {
                $status[] = bbp_get_hidden_status_id();
            }
            // Implode and add the statuses
            $posts_query->set('post_status', implode(',', $status));
            break;
            // Topics
        // Topics
        case bbp_get_topic_post_type():
            // Replies
        // Replies
        case bbp_get_reply_post_type():
            // Get forums to exclude
            $forum_ids = bbp_exclude_forum_ids('meta_query');
            // Bail if no forums to exclude
            if (empty($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);
            break;
    }
}
开发者ID:vsalx,项目名称:rattieinfo,代码行数:73,代码来源:bbp-forum-functions.php

示例8: 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

示例9: bp_group_organizer_import_group

function bp_group_organizer_import_group($group, $args = array())
{
    if (empty($group['name'])) {
        return false;
    }
    if (isset($group['path'])) {
        if (bpgo_is_hierarchy_available()) {
            // Try to place the group in the requested spot, but if the spot doesn't exist (e.g. because of slug conflicts)
            // then place it as far down the tree as possible
            $parent_path = $group['path'];
            do {
                $parent_path = dirname($parent_path);
                $parent_id = BP_Groups_Hierarchy::get_id_from_slug($parent_path);
            } while ($parent_path != '.' && $parent_id == 0);
            $group['parent_id'] = $parent_id ? $parent_id : 0;
        }
        $group['slug'] = basename($group['path']);
        unset($group['path']);
    }
    $group['slug'] = groups_check_slug($group['slug']);
    $group_id = groups_create_group($group);
    if (!$group_id) {
        return false;
    }
    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) $group['parent_id'];
        $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_import_group', $group_id);
    return $group_id;
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:67,代码来源:group-organizer-import.php

示例10: bp_group_organizer_admin_page

function bp_group_organizer_admin_page()
{
    global $wpdb;
    // Permissions Check
    if (!current_user_can('manage_options')) {
        wp_die(__('Cheatin&#8217; 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

示例11: 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

示例12: 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 &hellip; %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

示例13: test_bbp_is_forum_hidden

 /**
  * @covers ::bbp_is_forum_hidden
  */
 public function test_bbp_is_forum_hidden()
 {
     $f = $this->factory->forum->create(array('post_status' => 'hidden'));
     $forum = bbp_get_forum_visibility($f);
     $this->assertSame('hidden', $forum);
     $forum_status_id = bbp_get_hidden_status_id($f);
     $this->assertSame('hidden', $forum_status_id);
     $this->assertTrue(bbp_is_forum_hidden($f));
 }
开发者ID:joeyblake,项目名称:bbpress,代码行数:12,代码来源:status.php

示例14: 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

示例15: bbp_get_dropdown

/**
 * Output a select box allowing to pick which forum/topic a new
 * topic/reply belongs in.
 *
 * @since bbPress (r2746)
 *
 * @param mixed $args The function supports these args:
 *  - post_type: Post type, defaults to bbp_get_forum_post_type() (bbp_forum)
 *  - selected: Selected ID, to not have any value as selected, pass
 *               anything smaller than 0 (due to the nature of select
 *               box, the first value would of course be selected -
 *               though you can have that as none (pass 'show_none' arg))
 *  - sort_column: Sort by? Defaults to 'menu_order, post_title'
 *  - child_of: Child of. Defaults to 0
 *  - post_status: Which all post_statuses to find in? Can be an array
 *                  or CSV of publish, category, closed, private, spam,
 *                  trash (based on post type) - if not set, these are
 *                  automatically determined based on the post_type
 *  - posts_per_page: Retrieve all forums/topics. Defaults to -1 to get
 *                     all posts
 *  - walker: Which walker to use? Defaults to
 *             {@link BBP_Walker_Dropdown}
 *  - select_id: ID of the select box. Defaults to 'bbp_forum_id'
 *  - tab: Tabindex value. False or integer
 *  - options_only: Show only <options>? No <select>?
 *  - show_none: False or something like __( '(No Forum)', 'bbpress' ),
 *                will have value=""
 *  - none_found: False or something like
 *                 __( 'No forums to post to!', 'bbpress' )
 *  - disable_categories: Disable forum categories and closed forums?
 *                         Defaults to true. Only for forums and when
 *                         the category option is displayed.
 * @uses BBP_Walker_Dropdown() As the default walker to generate the
 *                              dropdown
 * @uses current_user_can() To check if the current user can read
 *                           private forums
 * @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 walk_page_dropdown_tree() To generate the dropdown using the
 *                                  walker
 * @uses apply_filters() Calls 'bbp_get_dropdown' with the dropdown
 *                        and args
 * @return string The dropdown
 */
function bbp_get_dropdown($args = '')
{
    /** Arguments *********************************************************/
    $defaults = array('post_type' => bbp_get_forum_post_type(), 'selected' => 0, 'sort_column' => 'menu_order', 'child_of' => '0', 'numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', 'walker' => '', 'select_id' => 'bbp_forum_id', 'tab' => bbp_get_tab_index(), 'options_only' => false, 'show_none' => false, 'none_found' => false, 'disable_categories' => true);
    $r = bbp_parse_args($args, $defaults, 'get_dropdown');
    if (empty($r['walker'])) {
        $r['walker'] = new BBP_Walker_Dropdown();
        $r['walker']->tree_type = $r['post_type'];
    }
    // Force 0
    if (is_numeric($r['selected']) && $r['selected'] < 0) {
        $r['selected'] = 0;
    }
    extract($r);
    // Unset the args not needed for WP_Query to avoid any possible conflicts.
    // Note: walker and disable_categories are not unset
    unset($r['select_id'], $r['tab'], $r['options_only'], $r['show_none'], $r['none_found']);
    /** Post Status *******************************************************/
    // Define local variable(s)
    $post_stati = array();
    // Public
    $post_stati[] = bbp_get_public_status_id();
    // Forums
    if (bbp_get_forum_post_type() == $post_type) {
        // Private forums
        if (current_user_can('read_private_forums')) {
            $post_stati[] = bbp_get_private_status_id();
        }
        // Hidden forums
        if (current_user_can('read_hidden_forums')) {
            $post_stati[] = bbp_get_hidden_status_id();
        }
    }
    // Setup the post statuses
    $r['post_status'] = implode(',', $post_stati);
    /** Setup variables ***************************************************/
    $name = esc_attr($select_id);
    $select_id = $name;
    $tab = (int) $tab;
    $retval = '';
    $posts = get_posts($r);
    /** Drop Down *********************************************************/
    // Items found
    if (!empty($posts)) {
        if (empty($options_only)) {
            $tab = !empty($tab) ? ' tabindex="' . $tab . '"' : '';
            $retval .= '<select name="' . $name . '" id="' . $select_id . '"' . $tab . '>' . "\n";
        }
        $retval .= !empty($show_none) ? "\t<option value=\"\" class=\"level-0\">" . $show_none . '</option>' : '';
        $retval .= walk_page_dropdown_tree($posts, 0, $r);
        if (empty($options_only)) {
            $retval .= '</select>';
        }
        // No items found - Display feedback if no custom message was passed
    } elseif (empty($none_found)) {
        // Switch the response based on post type
//.........这里部分代码省略.........
开发者ID:rmccue,项目名称:bbPress,代码行数:101,代码来源:bbp-common-template.php


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