Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/31/2014 01:57:38 PM (10 years ago)
Author:
imath
Message:

Move the Blogs and Groups create links into their directory main navs

Since r9157, we have removed the create links of these two components from the title of their WordPress post object.
For version 2.2, we've decided to move them into their directory main navs. As a result, each component navigation will now display 3 links for the logged in user :

  • All Groups / My Groups / Create a Group
  • All Sites / My Sites / Create a Site

We are aware, this might not be the best positioning for every users, so we are also introducing two new filters to help these users to neutralize it and choose their prefered positioning.

  • 'bp_get_group_create_nav_item'
  • 'bp_get_blog_create_nav_item'

Neutralizing the positioning can be achieve by simply returning false to these filters, here's an example for the Groups component create link.
add_filter( 'bp_get_group_create_nav_item', '__return_false' );

See #6008 / #4638

Props hnla, johnjamesjacoby, DJPaul, boonebgorges, modemlooper, imath

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-blogs/bp-blogs-template.php

    r9260 r9291  
    14691469            'link_text'  => __( 'Create a Site', 'buddypress' ),
    14701470            'link_title' => __( 'Create a Site', 'buddypress' ),
    1471             'link_class' => 'button blog-create bp-title-button',
     1471            'link_class' => 'blog-create no-ajax',
    14721472            'link_href'  => trailingslashit( bp_get_root_domain() ) . trailingslashit( bp_get_blogs_root_slug() ) . trailingslashit( 'create' ),
    14731473            'wrapper'    => false,
     
    14831483        return bp_get_button( apply_filters( 'bp_get_blog_create_button', $button_args ) );
    14841484    }
     1485
     1486/**
     1487 * Output the Create a Site nav item.
     1488 *
     1489 * @since BuddyPress (2.2.0)
     1490 */
     1491function bp_blog_create_nav_item() {
     1492    echo bp_get_blog_create_nav_item();
     1493}
     1494
     1495    /**
     1496     * Get the Create a Site nav item.
     1497     *
     1498     * @since BuddyPress (2.2.0)
     1499     *
     1500     * @return string
     1501     */
     1502    function bp_get_blog_create_nav_item() {
     1503        // Get the create a site button
     1504        $create_blog_button = bp_get_blog_create_button();
     1505
     1506        // Make sure the button is available
     1507        if ( empty( $create_blog_button ) ) {
     1508            return;
     1509        }
     1510
     1511        $output = '<li id="blog-create-nav">' . $create_blog_button . '</li>';
     1512
     1513        return apply_filters( 'bp_get_blog_create_nav_item', $output );
     1514    }
     1515
     1516/**
     1517 * Checks if a specific theme is still filtering the Blogs directory title
     1518 * if so, transform the title button into a Blogs directory nav item.
     1519 *
     1520 * @since BuddyPress (2.2.0)
     1521 *
     1522 * @uses   bp_blog_create_nav_item() to output the Create a Site nav item
     1523 * @return string HTML Output
     1524 */
     1525function bp_blog_backcompat_create_nav_item() {
     1526    // Bail if Blogs nav item is already used by bp-legacy
     1527    if ( has_action( 'bp_blogs_directory_blog_types', 'bp_legacy_theme_blog_create_nav', 999 ) ) {
     1528        return;
     1529    }
     1530
     1531    // Bail if the theme is not filtering the Blogs directory title
     1532    if ( ! has_filter( 'bp_blogs_directory_header' ) ) {
     1533        return;
     1534    }
     1535
     1536    bp_blog_create_nav_item();
     1537}
     1538add_action( 'bp_blogs_directory_blog_types', 'bp_blog_backcompat_create_nav_item', 1000 );
    14851539
    14861540/**
Note: See TracChangeset for help on using the changeset viewer.