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


PHP bbp_get_root_slug函数代码示例

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


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

示例1: bbp_replace_the_content

/**
 * Replaces the_content() if the post_type being displayed is one that would
 * normally be handled by bbPress, but proper single page templates do not
 * exist in the currently active theme.
 *
 * Note that we do *not* currently use is_main_query() here. This is because so
 * many existing themes either use query_posts() or fail to use wp_reset_query()
 * when running queries before the main loop, causing theme compat to fail.
 *
 * @since bbPress (r3034)
 * @param string $content
 * @return type
 */
function bbp_replace_the_content($content = '')
{
    // Bail if not inside the query loop
    if (!in_the_loop()) {
        return $content;
    }
    $bbp = bbpress();
    // Define local variable(s)
    $new_content = '';
    // Bail if shortcodes are unset somehow
    if (!is_a($bbp->shortcodes, 'BBP_Shortcodes')) {
        return $content;
    }
    // Use shortcode API to display forums/topics/replies because they are
    // already output buffered and ready to fit inside the_content
    /** Users *************************************************************/
    // Profile View
    if (bbp_is_single_user_edit() || bbp_is_single_user()) {
        ob_start();
        bbp_get_template_part('content', 'single-user');
        $new_content = ob_get_contents();
        ob_end_clean();
        /** Forums ************************************************************/
        // Forum archive
    } elseif (bbp_is_forum_archive()) {
        // Page exists where this archive should be
        $page = bbp_get_page_by_path(bbp_get_root_slug());
        if (!empty($page)) {
            // Restore previously unset filters
            bbp_restore_all_filters('the_content');
            // Remove 'bbp_replace_the_content' filter to prevent infinite loops
            remove_filter('the_content', 'bbp_replace_the_content');
            // Start output buffer
            ob_start();
            // Grab the content of this page
            $new_content = apply_filters('the_content', $page->post_content);
            // Clean up the buffer
            ob_end_clean();
            // Add 'bbp_replace_the_content' filter back (@see $this::start())
            add_filter('the_content', 'bbp_replace_the_content');
            // No page so show the archive
        } else {
            $new_content = $bbp->shortcodes->display_forum_index();
        }
        // Forum Edit
    } elseif (bbp_is_forum_edit()) {
        $new_content = $bbp->shortcodes->display_forum_form();
        // Single Forum
    } elseif (bbp_is_single_forum()) {
        $new_content = $bbp->shortcodes->display_forum(array('id' => get_the_ID()));
        /** Topics ************************************************************/
        // Topic archive
    } elseif (bbp_is_topic_archive()) {
        // Page exists where this archive should be
        $page = bbp_get_page_by_path(bbp_get_topic_archive_slug());
        if (!empty($page)) {
            // Restore previously unset filters
            bbp_restore_all_filters('the_content');
            // Remove 'bbp_replace_the_content' filter to prevent infinite loops
            remove_filter('the_content', 'bbp_replace_the_content');
            // Start output buffer
            ob_start();
            // Grab the content of this page
            $new_content = apply_filters('the_content', $page->post_content);
            // Clean up the buffer
            ob_end_clean();
            // Add 'bbp_replace_the_content' filter back (@see $this::start())
            add_filter('the_content', 'bbp_replace_the_content');
            // No page so show the archive
        } else {
            $new_content = $bbp->shortcodes->display_topic_index();
        }
        // Topic Edit
    } elseif (bbp_is_topic_edit()) {
        // Split
        if (bbp_is_topic_split()) {
            ob_start();
            bbp_get_template_part('form', 'topic-split');
            $new_content = ob_get_contents();
            ob_end_clean();
            // Merge
        } elseif (bbp_is_topic_merge()) {
            ob_start();
            bbp_get_template_part('form', 'topic-merge');
            $new_content = ob_get_contents();
            ob_end_clean();
            // Edit
//.........这里部分代码省略.........
开发者ID:hscale,项目名称:webento,代码行数:101,代码来源:theme-compat.php

示例2: bbp_get_breadcrumb

/**
 * Return a breadcrumb ( forum -> topic -> reply )
 *
 * @since bbPress (r2589)
 *
 * @param string $sep Separator. Defaults to '←'
 * @param bool $current_page Include the current item
 * @param bool $root Include the root page if one exists
 *
 * @uses get_post() To get the post
 * @uses bbp_get_forum_permalink() To get the forum link
 * @uses bbp_get_topic_permalink() To get the topic link
 * @uses bbp_get_reply_permalink() To get the reply link
 * @uses get_permalink() To get the permalink
 * @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 bbp_get_forum_title() To get the forum title
 * @uses bbp_get_topic_title() To get the topic title
 * @uses bbp_get_reply_title() To get the reply title
 * @uses get_the_title() To get the title
 * @uses apply_filters() Calls 'bbp_get_breadcrumb' with the crumbs
 * @return string Breadcrumbs
 */
function bbp_get_breadcrumb($args = array())
{
    // Turn off breadcrumbs
    if (apply_filters('bbp_no_breadcrumb', is_front_page())) {
        return;
    }
    // Define variables
    $front_id = $root_id = 0;
    $ancestors = $crumbs = $tag_data = array();
    $pre_root_text = $pre_front_text = $pre_current_text = '';
    $pre_include_root = $pre_include_home = $pre_include_current = true;
    /** Home Text *********************************************************/
    // No custom home text
    if (empty($args['home_text'])) {
        // Set home text to page title
        $front_id = get_option('page_on_front');
        if (!empty($front_id)) {
            $pre_front_text = get_the_title($front_id);
            // Default to 'Home'
        } else {
            $pre_front_text = __('Home', 'bbpress');
        }
    }
    /** Root Text *********************************************************/
    // No custom root text
    if (empty($args['root_text'])) {
        $page = bbp_get_page_by_path(bbp_get_root_slug());
        if (!empty($page)) {
            $root_id = $page->ID;
        }
        $pre_root_text = bbp_get_forum_archive_title();
    }
    /** Includes **********************************************************/
    // Root slug is also the front page
    if (!empty($front_id) && $front_id == $root_id) {
        $pre_include_root = false;
    }
    // Don't show root if viewing forum archive
    if (bbp_is_forum_archive()) {
        $pre_include_root = false;
    }
    // Don't show root if viewing page in place of forum archive
    if (!empty($root_id) && ((is_single() || is_page()) && $root_id == get_the_ID())) {
        $pre_include_root = false;
    }
    /** Current Text ******************************************************/
    // Forum archive
    if (bbp_is_forum_archive()) {
        $pre_current_text = bbp_get_forum_archive_title();
        // Topic archive
    } elseif (bbp_is_topic_archive()) {
        $pre_current_text = bbp_get_topic_archive_title();
        // View
    } elseif (bbp_is_single_view()) {
        $pre_current_text = bbp_get_view_title();
        // Single Forum
    } elseif (bbp_is_single_forum()) {
        $pre_current_text = bbp_get_forum_title();
        // Single Topic
    } elseif (bbp_is_single_topic()) {
        $pre_current_text = bbp_get_topic_title();
        // Single Topic
    } elseif (bbp_is_single_reply()) {
        $pre_current_text = bbp_get_reply_title();
        // Topic Tag (or theme compat topic tag)
    } elseif (bbp_is_topic_tag() || get_query_var('bbp_topic_tag') && !bbp_is_topic_tag_edit()) {
        // Always include the tag name
        $tag_data[] = bbp_get_topic_tag_name();
        // If capable, include a link to edit the tag
        if (current_user_can('manage_topic_tags')) {
            $tag_data[] = '<a href="' . bbp_get_topic_tag_edit_link() . '" class="bbp-edit-topic-tag-link">' . __('(Edit)', 'bbpress') . '</a>';
        }
        // Implode the results of the tag data
        $pre_current_text = sprintf(__('Topic Tag: %s', 'bbpress'), implode(' ', $tag_data));
        // Edit Topic Tag
    } elseif (bbp_is_topic_tag_edit()) {
//.........这里部分代码省略.........
开发者ID:rmccue,项目名称:bbPress,代码行数:101,代码来源:bbp-common-template.php

示例3: us_breadcrumbs

/**
 * Based on breadcrumbs function by Dimox
 * http://dimox.net/wordpress-breadcrumbs-without-a-plugin/
 */
function us_breadcrumbs()
{
    /* === OPTIONS === */
    $text['home'] = __('Home', 'us');
    // text for the 'Home' link
    $text['category'] = __('Archive by Category "%s"', 'us');
    // text for a category page
    $text['search'] = __('Search Results for "%s" Query', 'us');
    // text for a search results page
    $text['tag'] = __('Posts Tagged "%s"', 'us');
    // text for a tag page
    $text['author'] = __('Articles Posted by %s', 'us');
    // text for an author page
    $text['404'] = __('Error 404', 'us');
    // text for the 404 page
    $text['forums'] = __('Forums', 'us');
    // text for the 404 page
    $showCurrent = 1;
    // 1 - show current post/page title in breadcrumbs, 0 - don't show
    $showOnHome = 0;
    // 1 - show breadcrumbs on the homepage, 0 - don't show
    $delimiter = ' <span class="g-breadcrumbs-separator"><i class="mdfi_navigation_chevron_right"></i></span> ';
    // delimiter between crumbs
    $before = '<span class="g-breadcrumbs-item">';
    // tag before the current crumb
    $after = '</span>';
    // tag after the current crumb
    /* === END OF OPTIONS === */
    global $post;
    $homeLink = home_url() . '/';
    $linkBefore = '<span typeof="v:Breadcrumb">';
    $linkAfter = '</span>';
    $linkAttr = ' rel="v:url" property="v:title"';
    $link = $linkBefore . '<a class="g-breadcrumbs-item"' . $linkAttr . ' href="%1$s">%2$s</a>' . $linkAfter;
    if (is_home() || is_front_page()) {
        if ($showOnHome == 1) {
            echo '<div id="crumbs"><a href="' . esc_url($homeLink) . '">' . $text['home'] . '</a></div>';
        }
    } else {
        echo '<div class="g-breadcrumbs" xmlns:v="http://rdf.data-vocabulary.org/#">' . sprintf($link, $homeLink, $text['home']) . $delimiter;
        if (is_category()) {
            $thisCat = get_category(get_query_var('cat'), false);
            if ($thisCat->parent != 0) {
                $cats = get_category_parents($thisCat->parent, TRUE, $delimiter);
                $cats = str_replace('<a', $linkBefore . '<a' . $linkAttr, $cats);
                $cats = str_replace('</a>', '</a>' . $linkAfter, $cats);
                echo $cats;
            }
            echo $before . sprintf($text['category'], single_cat_title('', false)) . $after;
        } elseif (is_search()) {
            echo $before . sprintf($text['search'], get_search_query()) . $after;
        } elseif (is_day()) {
            echo sprintf($link, get_year_link(get_the_time('Y')), get_the_time('Y')) . $delimiter;
            echo sprintf($link, get_month_link(get_the_time('Y'), get_the_time('m')), __(get_the_time('F'), 'us')) . $delimiter;
            echo $before . get_the_time('d') . $after;
        } elseif (is_month()) {
            echo sprintf($link, get_year_link(get_the_time('Y')), get_the_time('Y')) . $delimiter;
            echo $before . __(get_the_time('F'), 'us') . $after;
        } elseif (is_year()) {
            echo $before . get_the_time('Y') . $after;
        } elseif (is_single() && !is_attachment()) {
            if (get_post_type() == 'topic' or get_post_type() == 'forum') {
                $forums_page = bbp_get_page_by_path(bbp_get_root_slug());
                if (!empty($forums_page)) {
                    $forums_page_url = get_permalink($forums_page->ID);
                    echo sprintf($link, $forums_page_url, $text['forums']);
                }
                $parent_id = $post->post_parent;
                if ($parent_id) {
                    $breadcrumbs = array();
                    while ($parent_id) {
                        $page = get_page($parent_id);
                        $breadcrumbs[] = sprintf($link, get_permalink($page->ID), get_the_title($page->ID));
                        $parent_id = $page->post_parent;
                    }
                    $breadcrumbs = array_reverse($breadcrumbs);
                    for ($i = 0; $i < count($breadcrumbs); $i++) {
                        echo $delimiter . $breadcrumbs[$i];
                        //                        if ($i != count($breadcrumbs)-1) echo $delimiter;
                    }
                    //                    if ( get_post_type() == 'forum' ) {
                    //                        echo $delimiter;
                    //                    }
                }
                //                if ( get_post_type() == 'forum' ) {
                //                    if ($showCurrent == 1) echo $before . get_the_title() . $after;
                //                }
            } elseif (get_post_type() != 'post') {
                $post_type = get_post_type_object(get_post_type());
                $slug = $post_type->rewrite;
                printf($link, $homeLink . '/' . $slug['slug'] . '/', $post_type->labels->singular_name);
                if ($showCurrent == 1) {
                    echo $delimiter . $before . get_the_title() . $after;
                }
            } else {
                $cat = get_the_category();
//.........这里部分代码省略.........
开发者ID:ConceptHaus,项目名称:atra,代码行数:101,代码来源:breadcrumbs.php

示例4: bbp_maybe_get_root_slug

/**
 * Maybe return the root slug, based on whether or not it's included in the url
 *
 * @since 2.1.0 bbPress (r3759)
 *
 * @return string
 */
function bbp_maybe_get_root_slug()
{
    $retval = '';
    if (bbp_get_root_slug() && bbp_include_root_slug()) {
        $retval = trailingslashit(bbp_get_root_slug());
    }
    return apply_filters('bbp_maybe_get_root_slug', $retval);
}
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:15,代码来源:options.php

示例5: register_post_types

 /**
  * Setup the post types for forums, topics and replies
  *
  * @since bbPress (r2597)
  * @uses register_post_type() To register the post types
  * @uses apply_filters() Calls various filters to modify the arguments
  *                        sent to register_post_type()
  */
 public static function register_post_types()
 {
     /** Forums ************************************************************/
     // Register Forum content type
     register_post_type(bbp_get_forum_post_type(), apply_filters('bbp_register_forum_post_type', array('labels' => bbp_get_forum_post_type_labels(), 'rewrite' => bbp_get_forum_post_type_rewrite(), 'supports' => bbp_get_forum_post_type_supports(), 'description' => __('bbPress Forums', 'bbpress'), 'capabilities' => bbp_get_forum_caps(), 'capability_type' => array('forum', 'forums'), 'menu_position' => 555555, 'has_archive' => bbp_get_root_slug(), 'exclude_from_search' => true, 'show_in_nav_menus' => true, 'public' => true, 'show_ui' => current_user_can('bbp_forums_admin'), 'can_export' => true, 'hierarchical' => true, 'query_var' => true, 'menu_icon' => '')));
     /** Topics ************************************************************/
     // Register Topic content type
     register_post_type(bbp_get_topic_post_type(), apply_filters('bbp_register_topic_post_type', array('labels' => bbp_get_topic_post_type_labels(), 'rewrite' => bbp_get_topic_post_type_rewrite(), 'supports' => bbp_get_topic_post_type_supports(), 'description' => __('bbPress Topics', 'bbpress'), 'capabilities' => bbp_get_topic_caps(), 'capability_type' => array('topic', 'topics'), 'menu_position' => 555555, 'has_archive' => 'forums' === bbp_show_on_root() ? bbp_get_topic_archive_slug() : false, 'exclude_from_search' => true, 'show_in_nav_menus' => false, 'public' => true, 'show_ui' => current_user_can('bbp_topics_admin'), 'can_export' => true, 'hierarchical' => false, 'query_var' => true, 'menu_icon' => '')));
     /** Replies ***********************************************************/
     // Register reply content type
     register_post_type(bbp_get_reply_post_type(), apply_filters('bbp_register_reply_post_type', array('labels' => bbp_get_reply_post_type_labels(), 'rewrite' => bbp_get_reply_post_type_rewrite(), 'supports' => bbp_get_reply_post_type_supports(), 'description' => __('bbPress Replies', 'bbpress'), 'capabilities' => bbp_get_reply_caps(), 'capability_type' => array('reply', 'replies'), 'menu_position' => 555555, 'exclude_from_search' => true, 'has_archive' => false, 'show_in_nav_menus' => false, 'public' => true, 'show_ui' => current_user_can('bbp_replies_admin'), 'can_export' => true, 'hierarchical' => false, 'query_var' => true, 'menu_icon' => '')));
 }
开发者ID:jenia-buianov,项目名称:all_my_sites,代码行数:20,代码来源:bbpress.php

示例6: bbp_get_forum_archive_title

/**
 * Return the forum archive title
 *
 * @since bbPress (r3249)
 *
 * @param string $title Default text to use as title
 *
 * @uses bbp_get_page_by_path() Check if page exists at root path
 * @uses get_the_title() Use the page title at the root path
 * @uses get_post_type_object() Load the post type object
 * @uses bbp_get_forum_post_type() Get the forum post type ID
 * @uses get_post_type_labels() Get labels for forum post type
 * @uses apply_filters() Allow output to be manipulated
 *
 * @return string The forum archive title
 */
function bbp_get_forum_archive_title($title = '')
{
    // If no title was passed
    if (empty($title)) {
        // Set root text to page title
        $page = bbp_get_page_by_path(bbp_get_root_slug());
        if (!empty($page)) {
            $title = get_the_title($page->ID);
            // Default to forum post type name label
        } else {
            $fto = get_post_type_object(bbp_get_forum_post_type());
            $title = $fto->labels->name;
        }
    }
    return apply_filters('bbp_get_forum_archive_title', $title);
}
开发者ID:hscale,项目名称:webento,代码行数:32,代码来源:bbp-forum-template.php

示例7: bbp_template_include_theme_compat

/**
 * Reset main query vars and filter 'the_content' to output a bbPress
 * template part as needed.
 *
 * @since 2.0.0 bbPress (r3032)
 *
 * @param string $template
 * @uses bbp_is_single_user() To check if page is single user
 * @uses bbp_get_single_user_template() To get user template
 * @uses bbp_is_single_user_edit() To check if page is single user edit
 * @uses bbp_get_single_user_edit_template() To get user edit template
 * @uses bbp_is_single_view() To check if page is single view
 * @uses bbp_get_single_view_template() To get view template
 * @uses bbp_is_search() To check if page is search
 * @uses bbp_get_search_template() To get search template
 * @uses bbp_is_forum_edit() To check if page is forum edit
 * @uses bbp_get_forum_edit_template() To get forum edit template
 * @uses bbp_is_topic_merge() To check if page is topic merge
 * @uses bbp_get_topic_merge_template() To get topic merge template
 * @uses bbp_is_topic_split() To check if page is topic split
 * @uses bbp_get_topic_split_template() To get topic split template
 * @uses bbp_is_topic_edit() To check if page is topic edit
 * @uses bbp_get_topic_edit_template() To get topic edit template
 * @uses bbp_is_reply_move() To check if page is reply move
 * @uses bbp_get_reply_move_template() To get reply move template
 * @uses bbp_is_reply_edit() To check if page is reply edit
 * @uses bbp_get_reply_edit_template() To get reply edit template
 * @uses bbp_set_theme_compat_template() To set the global theme compat template
 */
function bbp_template_include_theme_compat($template = '')
{
    /**
     * Bail if a root template was already found. This prevents unintended
     * recursive filtering of 'the_content'.
     *
     * @link https://bbpress.trac.wordpress.org/ticket/2429
     */
    if (bbp_is_template_included()) {
        return $template;
    }
    /**
     * If BuddyPress is activated at a network level, the action order is
     * reversed, which causes the template integration to fail. If we're looking
     * at a BuddyPress page here, bail to prevent the extra processing.
     *
     * This is a bit more brute-force than is probably necessary, but gets the
     * job done while we work towards something more elegant.
     */
    if (function_exists('is_buddypress') && is_buddypress()) {
        return $template;
    }
    // Define local variable(s)
    $bbp_shortcodes = bbpress()->shortcodes;
    // Bail if shortcodes are unset somehow
    if (!is_a($bbp_shortcodes, 'BBP_Shortcodes')) {
        return $template;
    }
    /** Users *************************************************************/
    if (bbp_is_single_user_edit() || bbp_is_single_user()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_author' => 0, 'post_date' => 0, 'post_content' => bbp_buffer_template_part('content', 'single-user', false), 'post_type' => '', 'post_title' => bbp_get_displayed_user_field('display_name'), 'post_status' => bbp_get_public_status_id(), 'is_single' => true, 'is_archive' => false, 'comment_status' => 'closed'));
        /** Forums ************************************************************/
        // Forum archive
    } elseif (bbp_is_forum_archive()) {
        // Page exists where this archive should be
        $page = bbp_get_page_by_path(bbp_get_root_slug());
        // Should we replace the content...
        if (empty($page->post_content)) {
            // Use the topics archive
            if ('topics' === bbp_show_on_root()) {
                $new_content = $bbp_shortcodes->display_topic_index();
                // No page so show the archive
            } else {
                $new_content = $bbp_shortcodes->display_forum_index();
            }
            // ...or use the existing page content?
        } else {
            $new_content = apply_filters('the_content', $page->post_content);
        }
        // Should we replace the title...
        if (empty($page->post_title)) {
            // Use the topics archive
            if ('topics' === bbp_show_on_root()) {
                $new_title = bbp_get_topic_archive_title();
                // No page so show the archive
            } else {
                $new_title = bbp_get_forum_archive_title();
            }
            // ...or use the existing page title?
        } else {
            $new_title = apply_filters('the_title', $page->post_title);
        }
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => !empty($page->ID) ? $page->ID : 0, 'post_title' => $new_title, 'post_author' => 0, 'post_date' => 0, 'post_content' => $new_content, 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_public_status_id(), 'is_archive' => true, 'comment_status' => 'closed'));
        // Single Forum
    } elseif (bbp_is_forum_edit()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => bbp_get_forum_id(), 'post_title' => bbp_get_forum_title(), 'post_author' => bbp_get_forum_author_id(), 'post_date' => 0, 'post_content' => $bbp_shortcodes->display_forum_form(), 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_forum_visibility(), 'is_single' => true, 'comment_status' => 'closed'));
    } elseif (bbp_is_single_forum()) {
        // Reset post
//.........这里部分代码省略.........
开发者ID:joeyblake,项目名称:bbpress,代码行数:101,代码来源:theme-compat.php

示例8: wp_idea_stream_root_slug_conflict_check

/**
 * Checks for rewrite conflicts, displays a warning if any
 *
 * @package WP Idea Stream
 * @subpackage admin/settings
 *
 * @since 2.0.0
 *
 * @param  string $slug the plugin's root slug
 * @uses   wp_idea_stream() to get plugin's main instance
 * @uses   get_posts() to look for a posts or a page having a post name like root slug
 * @uses   esc_url() to sanitize an url
 * @uses   get_edit_post_link() to get the edit link of the found post or page
 * @uses   bbp_get_root_slug() to get bbPress forums root slug
 * @uses   add_query_arg() to add query vars to an url
 * @uses   admin_url() to build a link inside the current blog's Administration
 * @uses   is_multisite() to check the WordPress config
 * @uses   get_id_from_blogname() to check if a blog exists having the same slug than the plugin's root slug
 * @uses   get_current_blog_id() to get the current blog ID
 * @uses   get_home_url() to get the blog's home page
 * @uses   is_super_admin() to check if the current user is a Super Administrator
 * @uses   network_admin_url() to build a link inside the network Administration
 * @uses   apply_filters() call 'wp_idea_stream_root_slug_conflict_check' to let plugins add their own warning messages
 * @return string HTML output
 */
function wp_idea_stream_root_slug_conflict_check($slug = 'ideastream')
{
    // Initialize attention
    $attention = array();
    /**
     * For pages and posts, problem can occur if the permalink setting is set to
     * '/%postname%/' In that case a post will be listed in post archive pages but the
     * single post may arrive on the IdeaStream Archive page.
     */
    if ('/%postname%/' == wp_idea_stream()->pretty_links) {
        // Check for posts having a post name == root IdeaStream slug
        $post = get_posts(array('name' => $slug, 'post_type' => array('post', 'page')));
        if (!empty($post)) {
            $post = $post[0];
            $conflict = sprintf(_x('this %s', 'ideastream settings root slug conflict', 'wp-idea-stream'), $post->post_type);
            $attention[] = '<strong><a href="' . esc_url(get_edit_post_link($post->ID)) . '">' . $conflict . '</strong>';
        }
    }
    /**
     * We need to check for bbPress forum's root prefix, if called the same way than
     * the root prefix of ideastream, then forums archive won't be reachable.
     */
    if (function_exists('bbp_get_root_slug') && $slug == bbp_get_root_slug()) {
        $conflict = _x('bbPress forum root slug', 'bbPress possible conflict', 'wp-idea-stream');
        $attention[] = '<strong><a href="' . esc_url(add_query_arg(array('page' => 'bbpress'), admin_url('options-general.php'))) . '">' . $conflict . '</strong>';
    }
    /**
     * Finally, in case of a multisite config, we need to check if a child blog is called
     * the same way than the ideastream root slug
     */
    if (is_multisite()) {
        $blog_id = (int) get_id_from_blogname($slug);
        $current_blog_id = (int) get_current_blog_id();
        $current_site = get_current_site();
        if (!empty($blog_id) && $blog_id != $current_blog_id && $current_site->blog_id == $current_blog_id) {
            $conflict = _x('child blog slug', 'Child blog possible conflict', 'wp-idea-stream');
            $blog_url = get_home_url($blog_id, '/');
            if (is_super_admin()) {
                $blog_url = add_query_arg(array('id' => $blog_id), network_admin_url('site-info.php'));
            }
            $attention[] = '<strong><a href="' . esc_url($blog_url) . '">' . $conflict . '</strong>';
        }
    }
    /**
     * Other plugins can come in there to draw attention ;)
     *
     * @param array  $attention list of slug conflicts
     * @param string $slug      the plugin's root slug
     */
    $attention = apply_filters('wp_idea_stream_root_slug_conflict_check', $attention, $slug);
    // Display warnings if needed
    if (!empty($attention)) {
        ?>

		<span class="attention"><?php 
        printf(esc_html__('Possible conflict with: %s', 'wp-idea-stream'), join(', ', $attention));
        ?>
</span>

		<?php 
    }
}
开发者ID:BoweFrankema,项目名称:wp-idea-stream,代码行数:87,代码来源:settings.php

示例9: register_post_types

 /**
  * Setup the post types for forums, topics and replies
  *
  * @since bbPress (r2597)
  * @uses register_post_type() To register the post types
  * @uses apply_filters() Calls various filters to modify the arguments
  *                        sent to register_post_type()
  */
 public static function register_post_types()
 {
     // Define local variable(s)
     $post_type = array();
     /** Forums ************************************************************/
     // Forum labels
     $post_type['labels'] = array('name' => __('Forums', 'bbpress'), 'menu_name' => __('Forums', 'bbpress'), 'singular_name' => __('Forum', 'bbpress'), 'all_items' => __('All Forums', 'bbpress'), 'add_new' => __('New Forum', 'bbpress'), 'add_new_item' => __('Create New Forum', 'bbpress'), 'edit' => __('Edit', 'bbpress'), 'edit_item' => __('Edit Forum', 'bbpress'), 'new_item' => __('New Forum', 'bbpress'), 'view' => __('View Forum', 'bbpress'), 'view_item' => __('View Forum', 'bbpress'), 'search_items' => __('Search Forums', 'bbpress'), 'not_found' => __('No forums found', 'bbpress'), 'not_found_in_trash' => __('No forums found in Trash', 'bbpress'), 'parent_item_colon' => __('Parent Forum:', 'bbpress'));
     // Forum rewrite
     $post_type['rewrite'] = array('slug' => bbp_get_forum_slug(), 'with_front' => false);
     // Forum supports
     $post_type['supports'] = array('title', 'editor', 'revisions');
     // Register Forum content type
     register_post_type(bbp_get_forum_post_type(), apply_filters('bbp_register_forum_post_type', array('labels' => $post_type['labels'], 'rewrite' => $post_type['rewrite'], 'supports' => $post_type['supports'], 'description' => __('bbPress Forums', 'bbpress'), 'capabilities' => bbp_get_forum_caps(), 'capability_type' => array('forum', 'forums'), 'menu_position' => 555555, 'has_archive' => bbp_get_root_slug(), 'exclude_from_search' => true, 'show_in_nav_menus' => true, 'public' => true, 'show_ui' => current_user_can('bbp_forums_admin'), 'can_export' => true, 'hierarchical' => true, 'query_var' => true, 'menu_icon' => '')));
     /** Topics ************************************************************/
     // Topic labels
     $post_type['labels'] = array('name' => __('Topics', 'bbpress'), 'menu_name' => __('Topics', 'bbpress'), 'singular_name' => __('Topic', 'bbpress'), 'all_items' => __('All Topics', 'bbpress'), 'add_new' => __('New Topic', 'bbpress'), 'add_new_item' => __('Create New Topic', 'bbpress'), 'edit' => __('Edit', 'bbpress'), 'edit_item' => __('Edit Topic', 'bbpress'), 'new_item' => __('New Topic', 'bbpress'), 'view' => __('View Topic', 'bbpress'), 'view_item' => __('View Topic', 'bbpress'), 'search_items' => __('Search Topics', 'bbpress'), 'not_found' => __('No topics found', 'bbpress'), 'not_found_in_trash' => __('No topics found in Trash', 'bbpress'), 'parent_item_colon' => __('Forum:', 'bbpress'));
     // Topic rewrite
     $post_type['rewrite'] = array('slug' => bbp_get_topic_slug(), 'with_front' => false);
     // Topic supports
     $post_type['supports'] = array('title', 'editor', 'revisions');
     // Register Topic content type
     register_post_type(bbp_get_topic_post_type(), apply_filters('bbp_register_topic_post_type', array('labels' => $post_type['labels'], 'rewrite' => $post_type['rewrite'], 'supports' => $post_type['supports'], 'description' => __('bbPress Topics', 'bbpress'), 'capabilities' => bbp_get_topic_caps(), 'capability_type' => array('topic', 'topics'), 'menu_position' => 555555, 'has_archive' => bbp_get_topic_archive_slug(), 'exclude_from_search' => true, 'show_in_nav_menus' => false, 'public' => true, 'show_ui' => current_user_can('bbp_topics_admin'), 'can_export' => true, 'hierarchical' => false, 'query_var' => true, 'menu_icon' => '')));
     /** Replies ***********************************************************/
     // Reply labels
     $post_type['labels'] = array('name' => __('Replies', 'bbpress'), 'menu_name' => __('Replies', 'bbpress'), 'singular_name' => __('Reply', 'bbpress'), 'all_items' => __('All Replies', 'bbpress'), 'add_new' => __('New Reply', 'bbpress'), 'add_new_item' => __('Create New Reply', 'bbpress'), 'edit' => __('Edit', 'bbpress'), 'edit_item' => __('Edit Reply', 'bbpress'), 'new_item' => __('New Reply', 'bbpress'), 'view' => __('View Reply', 'bbpress'), 'view_item' => __('View Reply', 'bbpress'), 'search_items' => __('Search Replies', 'bbpress'), 'not_found' => __('No replies found', 'bbpress'), 'not_found_in_trash' => __('No replies found in Trash', 'bbpress'), 'parent_item_colon' => __('Topic:', 'bbpress'));
     // Reply rewrite
     $post_type['rewrite'] = array('slug' => bbp_get_reply_slug(), 'with_front' => false);
     // Reply supports
     $post_type['supports'] = array('title', 'editor', 'revisions');
     // Register reply content type
     register_post_type(bbp_get_reply_post_type(), apply_filters('bbp_register_reply_post_type', array('labels' => $post_type['labels'], 'rewrite' => $post_type['rewrite'], 'supports' => $post_type['supports'], 'description' => __('bbPress Replies', 'bbpress'), 'capabilities' => bbp_get_reply_caps(), 'capability_type' => array('reply', 'replies'), 'menu_position' => 555555, 'exclude_from_search' => true, 'has_archive' => false, 'show_in_nav_menus' => false, 'public' => true, 'show_ui' => current_user_can('bbp_replies_admin'), 'can_export' => true, 'hierarchical' => false, 'query_var' => true, 'menu_icon' => '')));
 }
开发者ID:hscale,项目名称:webento,代码行数:40,代码来源:bbpress.php

示例10: bbp_replace_the_content

/**
 * Replaces the_content() if the post_type being displayed is one that would
 * normally be handled by bbPress, but proper single page templates do not
 * exist in the currently active theme.
 *
 * @since bbPress (r3034)
 * @param string $content
 * @return type
 */
function bbp_replace_the_content($content = '')
{
    $bbp = bbpress();
    // Define local variable(s)
    $new_content = '';
    // Bail if shortcodes are unset somehow
    if (!is_a($bbp->shortcodes, 'BBP_Shortcodes')) {
        return $content;
    }
    // Use shortcode API to display forums/topics/replies because they are
    // already output buffered and ready to fit inside the_content
    /** Users *************************************************************/
    // Profile View
    if (bbp_is_single_user()) {
        ob_start();
        bbp_get_template_part('content', 'single-user');
        $new_content = ob_get_contents();
        ob_end_clean();
        // Profile Edit
    } elseif (bbp_is_single_user_edit()) {
        ob_start();
        bbp_get_template_part('content', 'single-user-edit');
        $new_content = ob_get_contents();
        ob_end_clean();
        /** Forums ************************************************************/
        // Reply Edit
    } elseif (bbp_is_forum_edit()) {
        $new_content = $bbp->shortcodes->display_forum_form();
        // Forum archive
    } elseif (bbp_is_forum_archive()) {
        // Page exists where this archive should be
        $page = bbp_get_page_by_path(bbp_get_root_slug());
        if (!empty($page)) {
            // Restore previously unset filters
            bbp_restore_all_filters('the_content');
            // Remove 'bbp_replace_the_content' filter to prevent infinite loops
            remove_filter('the_content', 'bbp_replace_the_content');
            // Start output buffer
            ob_start();
            // Grab the content of this page
            $new_content = apply_filters('the_content', $page->post_content);
            // Clean up the buffer
            ob_end_clean();
            // Add 'bbp_replace_the_content' filter back (@see $this::start())
            add_filter('the_content', 'bbp_replace_the_content');
            // No page so show the archive
        } else {
            $new_content = $bbp->shortcodes->display_forum_index();
        }
        /** Topics ************************************************************/
        // Topic archive
    } elseif (bbp_is_topic_archive()) {
        // Page exists where this archive should be
        $page = bbp_get_page_by_path(bbp_get_topic_archive_slug());
        if (!empty($page)) {
            // Restore previously unset filters
            bbp_restore_all_filters('the_content');
            // Remove 'bbp_replace_the_content' filter to prevent infinite loops
            remove_filter('the_content', 'bbp_replace_the_content');
            // Start output buffer
            ob_start();
            // Grab the content of this page
            $new_content = apply_filters('the_content', $page->post_content);
            // Clean up the buffer
            ob_end_clean();
            // Add 'bbp_replace_the_content' filter back (@see $this::start())
            add_filter('the_content', 'bbp_replace_the_content');
            // No page so show the archive
        } else {
            $new_content = $bbp->shortcodes->display_topic_index();
        }
        // Single topic
    } elseif (bbp_is_topic_edit()) {
        // Split
        if (bbp_is_topic_split()) {
            ob_start();
            bbp_get_template_part('form', 'topic-split');
            $new_content = ob_get_contents();
            ob_end_clean();
            // Merge
        } elseif (bbp_is_topic_merge()) {
            ob_start();
            bbp_get_template_part('form', 'topic-merge');
            $new_content = ob_get_contents();
            ob_end_clean();
            // Edit
        } else {
            $new_content = $bbp->shortcodes->display_topic_form();
        }
        /** Replies ***********************************************************/
        // Reply archive
//.........这里部分代码省略.........
开发者ID:hscale,项目名称:webento,代码行数:101,代码来源:bbp-theme-compatibility.php

示例11: insert_lang_tag_root

 /**
  * insert lang rewrite tag in $url of post, CPT, Category and Taxonomy links
  *
  * @updated 1.1.2 - short link of post
  * @updated 2.16.6 - add filter for json link
  */
 function insert_lang_tag_root($url, $path, $orig_scheme, $blog_id)
 {
     // isset( $wp_query->query_vars['json_route'])
     if (true === apply_filters('xili_json_dont_insert_lang_tag_root', false, $url, $path, $orig_scheme, $blog_id)) {
         return $url;
     }
     // for JSON REST API 2.16.5
     if (false !== strpos($url, $this->rew_reqtag)) {
         return $url;
     }
     // to avoid twice insertion
     global $xili_language;
     $enabled_custom_posts = $enabled_custom_post_types = array();
     // fixes with only enabled 2.10.1
     foreach ($xili_language->xili_settings['multilingual_custom_post'] as $post_type => $values) {
         if ($values['multilingual'] == 'enable') {
             $enabled_custom_posts[] = '\\/' . $post_type . '\\/';
             $enabled_custom_post_types[] = $post_type;
         }
     }
     if ($enabled_custom_posts) {
         $pattern = '/(' . implode('|', $enabled_custom_posts) . ')/';
     } else {
         $pattern = '';
     }
     $tax_base = array();
     $category_base_option = get_option('category_base');
     $tax_base[] = $category_base_option ? $category_base_option : 'category';
     // à centraliser si class - ajouter "date"
     if (class_exists('xili_tidy_tags')) {
         // now gives lang of tags
         $tag_base_option = get_option('tag_base');
         $tax_base[] = $tag_base_option ? $tag_base_option : 'tag';
     }
     $authorized_custom_taxonomies = $xili_language->authorized_custom_taxonomies($enabled_custom_post_types);
     $tax_base = array_merge($tax_base, $this->always_insert, $authorized_custom_taxonomies);
     $tax_base_slash = array();
     foreach ($tax_base as $base) {
         $tax_base_slash[] = '\\/' . $base . '\\/';
     }
     $pattern_tax = '/(' . implode('|', $tax_base_slash) . ')/';
     // add / around
     if (class_exists('bbpress')) {
         if ($path == bbp_get_root_slug() . '/') {
             $replace = $xili_language->lang_slug_qv_trans($xili_language->default_slug);
             $url = str_replace($path, $replace . '/' . $path, $url);
             return $url;
         } else {
             if (false !== strpos($path, bbp_get_root_slug()) && preg_match($pattern, $path)) {
                 $url = str_replace($path, $this->rew_reqtag . '/' . $path, $url);
                 return $url;
             }
         }
     }
     if ($pattern && preg_match($pattern, $path)) {
         xili_xl_error_log(__CLASS__ . ' # ' . __LINE__ . ' ' . $path . ' ici 1 ' . $url);
         // CPT
         $path = substr($path, 0, 1) == '/' ? $path : '/' . $path;
         $url = str_replace($path, '/' . $this->rew_reqtag . $path, $url);
     } else {
         if (preg_match($pattern_tax, $path)) {
             $url = str_replace($path, '/' . $this->rew_reqtag . $path, $url);
             xili_xl_error_log(__CLASS__ . ' # ' . __LINE__ . ' ici 2 tax ' . $url);
         } else {
             if ('' != $path && '/' != substr($path, 0, 1) && false === strpos($path, $this->rew_reqtag)) {
                 $url = str_replace($path, $this->rew_reqtag . '/' . $path, $url);
                 xili_xl_error_log(__CLASS__ . ' # ' . __LINE__ . ' ici 3 ' . $url);
                 // page
             }
         }
     }
     return $url;
 }
开发者ID:ergov2015,项目名称:rideflag.dev,代码行数:79,代码来源:xili-permalinks-class.php


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