Skip to:
Content

BuddyPress.org

Changeset 12149


Ignore:
Timestamp:
05/30/2018 04:59:34 PM (7 years ago)
Author:
imath
Message:

BP Nouveau Activity comment form: allow inputs to be added to the form

In BP Legacy, the hook bp_activity_entry_comments is fired inside the activity comment form, letting plugin developers inject custom inputs into this form. The same hook is also available in BP Nouveau but was misplaced out of the comment form.

To adapt to one of this Nouveau principle: try to avoid adding hooks directly into templates using existing template tags or specific wrappers and preserve the same level of customization plugin developers need, we will use the bp_nouveau_submit_button() template tag to wrap and fire this hook into its output.

Props sbrajesh

Fixes #7839 (Branch 3.0)

Location:
branches/3.0/src/bp-templates/bp-nouveau
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/src/bp-templates/bp-nouveau/buddypress/activity/comment-form.php

    r12105 r12149  
    2121            <textarea id="ac-input-<?php bp_activity_id(); ?>" class="ac-input bp-suggestions" name="ac_input_<?php bp_activity_id(); ?>"></textarea>
    2222        </div>
     23        <input type="hidden" name="comment_form_id" value="<?php bp_activity_id(); ?>" />
     24
    2325        <?php
     26        bp_nouveau_submit_button( 'activity-new-comment' );
    2427        printf(
    25             '<input type="submit" name="ac_form_submit" value="%s" /> &nbsp; <button type="button" class="ac-reply-cancel">%s</button>',
    26             esc_attr( _x( 'Post', 'button', 'buddypress' ) ),
     28            '&nbsp; <button type="button" class="ac-reply-cancel">%s</button>',
    2729            esc_html( _x( 'Cancel', 'button', 'buddypress' ) )
    2830        );
    2931        ?>
    30         <input type="hidden" name="comment_form_id" value="<?php bp_activity_id(); ?>" />
    3132    </div>
    3233
    33     <?php wp_nonce_field( 'new_activity_comment', '_wpnonce_new_activity_comment' ); ?>
    34 
    3534</form>
  • branches/3.0/src/bp-templates/bp-nouveau/includes/activity/template-tags.php

    r12105 r12149  
    696696function bp_nouveau_activity_comment_form() {
    697697    bp_get_template_part( 'activity/comment-form' );
    698 
    699     /**
    700      * Fires after the activity entry comment form.
    701      *
    702      * @since 1.5.0
    703      */
    704     do_action( 'bp_activity_entry_comments' );
    705698}
    706699
  • branches/3.0/src/bp-templates/bp-nouveau/includes/functions.php

    r12109 r12149  
    13221322            ),
    13231323        ),
     1324        'activity-new-comment' => array(
     1325            'after'     => 'bp_activity_entry_comments',
     1326            'nonce'     => 'new_activity_comment',
     1327            'nonce_key' => '_wpnonce_new_activity_comment',
     1328            'wrapper'   => false,
     1329            'attributes' => array(
     1330                'name'  => 'ac_form_submit',
     1331                'value' => _x( 'Post', 'button', 'buddypress' ),
     1332            ),
     1333        ),
    13241334    ) );
    13251335
  • branches/3.0/src/bp-templates/bp-nouveau/includes/template-tags.php

    r12147 r12149  
    24202420    }
    24212421
    2422     // Output the submit button.
    2423     printf(
    2424         '<div class="submit">
    2425             <input type="submit" %s/>
    2426         </div>',
     2422    $submit_input = sprintf( '<input type="submit" %s/>',
    24272423        bp_get_form_field_attributes( 'submit', $submit_data['attributes'] )  // Safe.
    24282424    );
    24292425
    2430     wp_nonce_field( $submit_data['nonce'] );
     2426    // Output the submit button.
     2427    if ( isset( $submit_data['wrapper'] ) && false === $submit_data['wrapper'] ) {
     2428        echo $submit_input;
     2429
     2430    // Output the submit button into a wrapper.
     2431    } else {
     2432        printf( '<div class="submit">%s</div>', $submit_input );
     2433    }
     2434
     2435    if ( empty( $submit_data['nonce_key'] ) ) {
     2436        wp_nonce_field( $submit_data['nonce'] );
     2437    } else {
     2438        wp_nonce_field( $submit_data['nonce'], $submit_data['nonce_key'] );
     2439    }
    24312440
    24322441    if ( ! empty( $submit_data['after'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.