Skip to:
Content

BuddyPress.org

Changeset 3685


Ignore:
Timestamp:
01/09/2011 05:40:12 PM (15 years ago)
Author:
djpaul
Message:

Adds additional arguments to the BP_Button class to allow for greater customisation in themes. Fixes #2711, props johnjamesjacoby.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-templatetags.php

    r3670 r3685  
    10511051            'link_href'         => bp_get_send_public_message_link(),
    10521052            'link_title'        => __( 'Mention this user in a new public message, this will send the user a notification to get their attention.', 'buddypress' ),
    1053             'link_text'         => __( 'Mention this User', 'buddypress' )
     1053            'link_text'         => __( 'Mention this User', 'buddypress' ),
     1054            'link_class'        => 'activity-button mention'
    10541055        );
    10551056
  • trunk/bp-blogs/bp-blogs-templatetags.php

    r3666 r3685  
    540540            'wrapper_class'     => 'blog-button visit',
    541541            'link_href'         => bp_get_blog_permalink(),
    542             'link_class'        => 'visit',
     542            'link_class'        => 'blog-button visit',
    543543            'link_text'         => __( 'Visit Blog', 'buddypress' ),
    544544            'link_title'        => __( 'Visit Blog', 'buddypress' ),
  • trunk/bp-core/bp-core-classes.php

    r3592 r3685  
    547547    var $block_self;
    548548
    549     // Wrapper div
     549    // Wrapper
     550    var $wrapper;
    550551    var $wrapper_class;
    551552    var $wrapper_id;
     
    570571     * must_be_logged_in: Button only appears for logged in users
    571572     * block_self: Button will not appear when viewing your own profile.
     573     * wrapper: div|span|p|li|false for no wrapper
    572574     * wrapper_id: The DOM ID of the button wrapper
    573575     * wrapper_class: The DOM class of the button wrapper
     
    584586    function bp_button( $args = '' ) {
    585587
     588        // Default arguments
    586589        $defaults = array(
    587590            'id'                => '',
     
    590593            'block_self'        => true,
    591594
     595            'wrapper'           => 'div',
    592596            'wrapper_id'        => '',
    593597            'wrapper_class'     => '',
     
    609613        $this->must_be_logged_in = (bool)$must_be_logged_in;
    610614        $this->block_self        = (bool)$block_self;
     615        $this->wrapper           = $wrapper;
    611616
    612617        // $id and $component are required
     
    627632
    628633        // Wrapper properties
    629         if ( !empty( $wrapper_id ) )
    630             $this->wrapper_id    = ' id="' . $wrapper_id . '"';
    631 
    632         if ( !empty( $wrapper_class ) )
    633             $this->wrapper_class = ' class="generic-button ' . $wrapper_class . '"';
    634         else
    635             $this->wrapper_class = ' class="generic-button"';
     634        if ( false !== $this->wrapper ) {
     635
     636            // Wrapper ID
     637            if ( !empty( $wrapper_id ) )
     638                $this->wrapper_id    = ' id="' . $wrapper_id . '"';
     639
     640            // Wrapper class
     641            if ( !empty( $wrapper_class ) )
     642                $this->wrapper_class = ' class="generic-button ' . $wrapper_class . '"';
     643            else
     644                $this->wrapper_class = ' class="generic-button"';
     645
     646            // Set before and after
     647            $before = '<' . $wrapper . $this->wrapper_class . $this->wrapper_id . '>';
     648            $after  = '</' . $wrapper . '>';
     649
     650        // No wrapper
     651        } else {
     652            $before = $after = '';
     653        }
    636654
    637655        // Link properties
    638656        if ( !empty( $link_id ) )
    639             $this->link_id       = ' id="' . $link_id . '"';
     657            $this->link_id    = ' id="' . $link_id . '"';
    640658
    641659        if ( !empty( $link_href ) )
    642             $this->link_href     = ' href="' . $link_href . '"';
     660            $this->link_href  = ' href="' . $link_href . '"';
    643661
    644662        if ( !empty( $link_title ) )
    645             $this->link_title    = ' title="' . $link_title . '"';
     663            $this->link_title = ' title="' . $link_title . '"';
    646664
    647665        if ( !empty( $link_rel ) )
    648             $this->link_rel      = ' rel="' . $link_rel . '"';
     666            $this->link_rel   = ' rel="' . $link_rel . '"';
    649667
    650668        if ( !empty( $link_class ) )
    651             $this->link_class    = ' class="' . $link_class . '"';
     669            $this->link_class = ' class="' . $link_class . '"';
    652670
    653671        if ( !empty( $link_text ) )
    654             $this->link_text     = $link_text;
     672            $this->link_text  = $link_text;
    655673
    656674        // Build the button
    657         $this->contents  = '<div' . $this->wrapper_class . $this->wrapper_id . '>';
    658         $this->contents .= '<a'. $this->link_href . $this->link_title . $this->link_id . $this->link_rel . $this->link_class . '>' . $this->link_text . '</a>';
    659         $this->contents .= '</div>';
     675        $this->contents = $before . '<a'. $this->link_href . $this->link_title . $this->link_id . $this->link_rel . $this->link_class . '>' . $this->link_text . '</a>' . $after;
    660676
    661677        // Allow button to be manipulated externally
    662         $this->contents = apply_filters( 'bp_button_' . $component . '_' . $id, $this->contents, $this );
     678        $this->contents = apply_filters( 'bp_button_' . $component . '_' . $id, $this->contents, $this, $before, $after );
    663679    }
    664680
  • trunk/bp-core/bp-core-templatetags.php

    r3666 r3685  
    11161116
    11171117/**
    1118  * bp_button( $button )
    1119  *
    11201118 * Creates and outputs a button.
    1121  * Args: div_id | div_class | a_href | a_title | a_id | a_class | a_rel | a_text
    1122  *
    1123  * @param array $button
     1119 *
     1120 * @param array $args See bp_get_button() for the list of arguments.
     1121 * @see bp_get_button()
    11241122 */
    1125 function bp_button( $button = '' ) {
    1126     echo bp_get_button( $button );
     1123function bp_button( $args = '' ) {
     1124    echo bp_get_button( $args );
    11271125}
    11281126    /**
    1129      * bp_get_button( $button )
     1127     * Creates and returns a button.
    11301128     *
    1131      * Creates and returns a button.
    1132      * Args: div_id | div_class | a_href | a_title | a_id | a_class | a_rel | a_text
     1129     * Args:
     1130     * component: Which component this button is for
     1131     * must_be_logged_in: Button only appears for logged in users
     1132     * block_self: Button will not appear when viewing your own profile.
     1133     * wrapper: div|span|p|li|
     1134     * wrapper_id: The DOM ID of the button wrapper
     1135     * wrapper_class: The DOM class of the button wrapper
     1136     * link_href: The destination link of the button
     1137     * link_title: Title of the button
     1138     * link_id: The DOM ID of the button
     1139     * link_class: The DOM class of the button
     1140     * link_rel: The DOM rel of the button
     1141     * link_text: The contents of the button
    11331142     *
    11341143     * @param array $button
    11351144     * @return string
     1145     * @see bp_add_friend_button()
     1146     * @see bp_send_public_message_button()
     1147     * @see bp_send_private_message_button()
    11361148     */
    1137     function bp_get_button( $button = '' ) {
    1138         $btn = new BP_Button( $button );
    1139         return apply_filters( 'bp_get_button', $btn->contents, $button );
     1149    function bp_get_button( $args = '' ) {
     1150        $button = new BP_Button( $args );
     1151        return apply_filters( 'bp_get_button', $button->contents, $args, $button );
    11401152    }
    11411153
  • trunk/bp-friends/bp-friends-templatetags.php

    r3523 r3685  
    220220                    'wrapper_class'     => 'friendship-button pending',
    221221                    'wrapper_id'        => 'friendship-button-' . $potential_friend_id,
    222                     'link_class'        => 'requested',
    223222                    'link_href'         => trailingslashit( $bp->loggedin_user->domain . $bp->friends->slug . '/requests' ),
    224223                    'link_text'         => __( 'Friendship Requested', 'buddypress' ),
    225                     'link_title'        => __( 'Friendship Requested', 'buddypress' )
     224                    'link_title'        => __( 'Friendship Requested', 'buddypress' ),
     225                    'link_class'        => 'friendship-button pending requested'
    226226                );
    227227                break;
     
    235235                    'wrapper_class'     => 'friendship-button is_friend',
    236236                    'wrapper_id'        => 'friendship-button-' . $potential_friend_id,
    237                     'link_class'        => '',
    238237                    'link_href'         => wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/remove-friend/' . $potential_friend_id . '/', 'friends_remove_friend' ),
    239238                    'link_text'         => __( 'Cancel Friendship', 'buddypress' ),
     
    241240                    'link_id'           => 'friend-' . $potential_friend_id,
    242241                    'link_rel'          => 'remove',
    243                     'link_class'        => 'remove'
     242                    'link_class'        => 'friendship-button is_friend remove'
    244243                );
    245244                break;
     
    253252                    'wrapper_class'     => 'friendship-button not_friends',
    254253                    'wrapper_id'        => 'friendship-button-' . $potential_friend_id,
    255                     'link_class'        => '',
    256254                    'link_href'         => wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/add-friend/' . $potential_friend_id . '/', 'friends_add_friend' ),
    257255                    'link_text'         => __( 'Add Friend', 'buddypress' ),
     
    259257                    'link_id'           => 'friend-' . $potential_friend_id,
    260258                    'link_rel'          => 'add',
    261                     'link_class'        => 'add'
     259                    'link_class'        => 'friendship-button not_friends add'
    262260                );
    263261                break;
  • trunk/bp-groups/bp-groups-templatetags.php

    r3648 r3685  
    11511151            'wrapper_class'     => 'group-button',
    11521152            'link_href'         => '#post-new',
    1153             'link_class'        => '',
     1153            'link_class'        => 'group-button',
    11541154            'link_id'           => 'new-topic-button',
    11551155            'link_text'         => __( 'New Topic', 'buddypress' ),
     
    11921192                'wrapper_class'     => 'group-button ' . $group->status,
    11931193                'wrapper_id'        => 'groupbutton-' . $group->id,
    1194                 'link_class'        => 'leave-group',
    11951194                'link_href'         => wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ),
    11961195                'link_text'         => __( 'Leave Group', 'buddypress' ),
    1197                 'link_title'        => __( 'Leave Group', 'buddypress' )
     1196                'link_title'        => __( 'Leave Group', 'buddypress' ),
     1197                'link_class'        => 'group-button leave-group',
    11981198            );
    11991199
     
    12151215                        'wrapper_class'     => 'group-button ' . $group->status,
    12161216                        'wrapper_id'        => 'groupbutton-' . $group->id,
    1217                         'link_class'        => 'join-group',
    12181217                        'link_href'         => wp_nonce_url( bp_get_group_permalink( $group ) . 'join', 'groups_join_group' ),
    12191218                        'link_text'         => __( 'Join Group', 'buddypress' ),
    1220                         'link_title'        => __( 'Join Group', 'buddypress' )
     1219                        'link_title'        => __( 'Join Group', 'buddypress' ),
     1220                        'link_class'        => 'group-button join-group',
    12211221                    );
    12221222                    break;
     
    12331233                            'wrapper_class'     => 'group-button ' . $group->status,
    12341234                            'wrapper_id'        => 'groupbutton-' . $group->id,
    1235                             'link_class'        => 'request-membership',
    12361235                            'link_href'         => wp_nonce_url( bp_get_group_permalink( $group ) . 'request-membership', 'groups_request_membership' ),
    12371236                            'link_text'         => __( 'Request Membership', 'buddypress' ),
    12381237                            'link_title'        => __( 'Request Membership', 'buddypress' ),
     1238                            'link_class'        => 'group-button request-membership',
    12391239                        );
    12401240
     
    12481248                            'wrapper_class'     => 'group-button pending ' . $group->status,
    12491249                            'wrapper_id'        => 'groupbutton-' . $group->id,
    1250                             'link_class'        => 'membership-requested',
    12511250                            'link_href'         => bp_get_group_permalink( $group ),
    12521251                            'link_text'         => __( 'Request Sent', 'buddypress' ),
    12531252                            'link_title'        => __( 'Request Sent', 'buddypress' ),
     1253                            'link_class'        => 'group-button pending membership-requested',
    12541254                        );
    12551255                    }
  • trunk/bp-messages/bp-messages-templatetags.php

    r3616 r3685  
    548548                'wrapper_id'        => 'send-private-message',
    549549                'link_href'         => bp_get_send_private_message_link(),
     550                'link_title'        => __( 'Send a private message to this user.', 'buddypress' ),
     551                'link_text'         => __( 'Send Private Message', 'buddypress' ),
    550552                'link_class'        => 'send-message',
    551                 'link_title'        => __( 'Send a private message to this user.', 'buddypress' ),
    552                 'link_text'         => __( 'Send Private Message', 'buddypress' )
    553553            ) )
    554554        );
Note: See TracChangeset for help on using the changeset viewer.