Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/31/2014 01:57:38 PM (11 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-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/**
Note: See TracChangeset for help on using the changeset viewer.