Skip to:
Content

BuddyPress.org

Changeset 9291


Ignore:
Timestamp:
12/31/2014 01:57:38 PM (7 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

Location:
trunk/src
Files:
4 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/**
  • trunk/src/bp-groups/bp-groups-template.php

    r9283 r9291  
    28552855            'link_text'  => __( 'Create a Group', 'buddypress' ),
    28562856            'link_title' => __( 'Create a Group', 'buddypress' ),
    2857             'link_class' => 'button group-create bp-title-button',
     2857            'link_class' => 'group-create no-ajax',
    28582858            'link_href'  => trailingslashit( bp_get_root_domain() ) . trailingslashit( bp_get_groups_root_slug() ) . trailingslashit( 'create' ),
    28592859            'wrapper'    => false,
     
    28622862        return bp_get_button( apply_filters( 'bp_get_group_create_button', $button_args ) );
    28632863    }
     2864
     2865/**
     2866 * Output the Create a Group nav item.
     2867 *
     2868 * @since BuddyPress (2.2.0)
     2869 */
     2870function bp_group_create_nav_item() {
     2871    echo bp_get_group_create_nav_item();
     2872}
     2873
     2874    /**
     2875     * Get the Create a Group nav item.
     2876     *
     2877     * @since BuddyPress (2.2.0)
     2878     *
     2879     * @return string
     2880     */
     2881    function bp_get_group_create_nav_item() {
     2882        // Get the create a group button
     2883        $create_group_button = bp_get_group_create_button();
     2884
     2885        // Make sure the button is available
     2886        if ( empty( $create_group_button ) ) {
     2887            return;
     2888        }
     2889
     2890        $output = '<li id="group-create-nav">' . $create_group_button . '</li>';
     2891
     2892        return apply_filters( 'bp_get_group_create_nav_item', $output );
     2893    }
     2894
     2895/**
     2896 * Checks if a specific theme is still filtering the Groups directory title
     2897 * if so, transform the title button into a Groups directory nav item.
     2898 *
     2899 * @since BuddyPress (2.2.0)
     2900 *
     2901 * @uses   bp_group_create_nav_item() to output the create a Group nav item
     2902 * @return string HTML Output
     2903 */
     2904function bp_group_backcompat_create_nav_item() {
     2905    // Bail if the Groups nav item is already used by bp-legacy
     2906    if ( has_action( 'bp_groups_directory_group_filter', 'bp_legacy_theme_group_create_nav', 999 ) ) {
     2907        return;
     2908    }
     2909
     2910    // Bail if the theme is not filtering the Groups directory title
     2911    if ( ! has_filter( 'bp_groups_directory_header' ) ) {
     2912        return;
     2913    }
     2914
     2915    bp_group_create_nav_item();
     2916}
     2917add_action( 'bp_groups_directory_group_filter', 'bp_group_backcompat_create_nav_item', 1000 );
    28642918
    28652919/**
  • trunk/src/bp-templates/bp-legacy/buddypress-functions.php

    r9190 r9291  
    109109            // Group buttons
    110110            if ( bp_is_active( 'groups' ) ) {
    111                 add_action( 'bp_group_header_actions',     'bp_group_join_button',           5 );
    112                 add_action( 'bp_group_header_actions',     'bp_group_new_topic_button',      20 );
    113                 add_action( 'bp_directory_groups_actions', 'bp_group_join_button' );
    114                 add_filter( 'bp_groups_directory_header',  'bp_legacy_theme_group_create_button' );
    115                 add_filter( 'bp_blogs_directory_header',   'bp_legacy_theme_blog_create_button' );
     111                add_action( 'bp_group_header_actions',          'bp_group_join_button',               5 );
     112                add_action( 'bp_group_header_actions',          'bp_group_new_topic_button',         20 );
     113                add_action( 'bp_directory_groups_actions',      'bp_group_join_button'                  );
     114                add_action( 'bp_groups_directory_group_filter', 'bp_legacy_theme_group_create_nav', 999 );
    116115            }
    117116
    118117            // Blog button
    119             if ( bp_is_active( 'blogs' ) )
    120                 add_action( 'bp_directory_blogs_actions',  'bp_blogs_visit_blog_button' );
     118            if ( bp_is_active( 'blogs' ) ) {
     119                add_action( 'bp_directory_blogs_actions',    'bp_blogs_visit_blog_button'           );
     120                add_action( 'bp_blogs_directory_blog_types', 'bp_legacy_theme_blog_create_nav', 999 );
     121            }
     122
    121123
    122124        }
     
    450452 *
    451453 * @since BuddyPress (2.0.0)
     454 * @todo Deprecate
    452455 *
    453456 * @param string $title Groups directory title.
     
    459462
    460463/**
     464 * Add the Create a Group nav to the Groups directory navigation.
     465 *
     466 * bp-legacy puts the Create a Group nav at the last position of
     467 * the Groups directory navigation.
     468 *
     469 * @since BuddyPress (2.2.0)
     470 *
     471 * @uses   bp_group_create_nav_item() to output the create a Group nav item
     472 * @return string
     473 */
     474function bp_legacy_theme_group_create_nav() {
     475    bp_group_create_nav_item();
     476}
     477
     478/**
    461479 * Add the Create a Site button to the Sites directory title.
    462480 *
     
    465483 *
    466484 * @since BuddyPress (2.0.0)
     485 * @todo Deprecate
    467486 *
    468487 * @param string $title Sites directory title.
     
    472491    return $title . ' ' . bp_get_blog_create_button();
    473492}
     493
     494/**
     495 * Add the Create a Site nav to the Sites directory navigation.
     496 *
     497 * bp-legacy puts the Create a Site nav at the last position of
     498 * the Sites directory navigation.
     499 *
     500 * @since BuddyPress (2.2.0)
     501 *
     502 * @uses   bp_blog_create_nav_item() to output the Create a Site nav item
     503 * @return string
     504 */
     505function bp_legacy_theme_blog_create_nav() {
     506    bp_blog_create_nav_item();
     507}
     508
    474509/**
    475510 * This function looks scarier than it actually is. :)
  • trunk/src/bp-templates/bp-legacy/js/buddypress.js

    r9277 r9291  
    836836    /* When a navigation tab is clicked - e.g. | All Groups | My Groups | */
    837837    jq('div.item-list-tabs').on( 'click', function(event) {
    838         if ( jq(this).hasClass('no-ajax') )  {
     838        if ( jq(this).hasClass('no-ajax')  || jq( event.target ).hasClass('no-ajax') )  {
    839839            return;
    840840        }
Note: See TracChangeset for help on using the changeset viewer.