Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/20/2014 09:02:33 PM (11 years ago)
Author:
boonebgorges
Message:

Introduce blog- and group-create button functions, and use to build directory headers in bp-legacy

The new functions bp_get_blog_create_button() and bp_get_group_create_button()
standardize the treatment of these buttons by using bp_get_button(). They also
make life easier for themers, who will not need to build the buttons from
scratch.

In this changeset we modify the way that bp-legacy loads these buttons into the
titles of the directory pages. Previously, it was done directly in BP's theme
compat layer, with the result that all template packs had to follow the
questionable practice of embedding a button inside of a header element. Now,
the directory title is a string, but is filtered; bp-legacy then chooses to
add a button by using the new create-button functions + the new filters.

Fixes #5144

Props hnla, r-a-y

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-template.php

    r7931 r7942  
    18551855
    18561856/**
     1857 * Output the Create a Group button.
     1858 *
     1859 * @since BuddyPress (2.0.0)
     1860 */
     1861function bp_group_create_button() {
     1862    echo bp_get_group_create_button();
     1863}
     1864    /**
     1865     * Get the Create a Group button.
     1866     *
     1867     * @since BuddyPress (2.0.0)
     1868     *
     1869     * @return string
     1870     */
     1871    function bp_get_group_create_button() {
     1872        if ( ! is_user_logged_in() ) {
     1873            return false;
     1874        }
     1875
     1876        if ( ! bp_user_can_create_groups() ) {
     1877            return false;
     1878        }
     1879
     1880        $button_args = array(
     1881            'id'         => 'create_group',
     1882            'component'  => 'groups',
     1883            'link_text'  => __( 'Create a Group', 'buddypress' ),
     1884            'link_title' => __( 'Create a Group', 'buddypress' ),
     1885            'link_class' => 'button group-create bp-title-button',
     1886            'link_href'  => trailingslashit( bp_get_root_domain() ) . trailingslashit( bp_get_groups_root_slug() ) . trailingslashit( 'create' ),
     1887            'wrapper'    => false,
     1888        );
     1889
     1890        return bp_get_button( $button_args );
     1891    }
     1892
     1893/**
    18571894 * Prints a message if the group is not visible to the current user (it is a
    18581895 * hidden or private group, and the user does not have access).
Note: See TracChangeset for help on using the changeset viewer.