Skip to:
Content

BuddyPress.org

Changeset 12148


Ignore:
Timestamp:
05/30/2018 04:55:10 PM (8 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

See #7839 (Trunk)

Location:
trunk/src/bp-templates/bp-nouveau
Files:
4 edited

Legend:

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

    r12104 r12148  
    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>
  • trunk/src/bp-templates/bp-nouveau/includes/activity/template-tags.php

    r12107 r12148  
    700700function bp_nouveau_activity_comment_form() {
    701701    bp_get_template_part( 'activity/comment-form' );
    702 
    703     /**
    704      * Fires after the activity entry comment form.
    705      *
    706      * @since 1.5.0
    707      */
    708     do_action( 'bp_activity_entry_comments' );
    709702}
    710703
  • trunk/src/bp-templates/bp-nouveau/includes/functions.php

    r12108 r12148  
    13341334            ),
    13351335        ),
     1336        'activity-new-comment' => array(
     1337            'after'     => 'bp_activity_entry_comments',
     1338            'nonce'     => 'new_activity_comment',
     1339            'nonce_key' => '_wpnonce_new_activity_comment',
     1340            'wrapper'   => false,
     1341            'attributes' => array(
     1342                'name'  => 'ac_form_submit',
     1343                'value' => _x( 'Post', 'button', 'buddypress' ),
     1344            ),
     1345        ),
    13361346    ) );
    13371347
  • trunk/src/bp-templates/bp-nouveau/includes/template-tags.php

    r12146 r12148  
    24242424    }
    24252425
    2426     // Output the submit button.
    2427     printf(
    2428         '<div class="submit">
    2429             <input type="submit" %s/>
    2430         </div>',
     2426    $submit_input = sprintf( '<input type="submit" %s/>',
    24312427        bp_get_form_field_attributes( 'submit', $submit_data['attributes'] )  // Safe.
    24322428    );
    24332429
    2434     wp_nonce_field( $submit_data['nonce'] );
     2430    // Output the submit button.
     2431    if ( isset( $submit_data['wrapper'] ) && false === $submit_data['wrapper'] ) {
     2432        echo $submit_input;
     2433
     2434    // Output the submit button into a wrapper.
     2435    } else {
     2436        printf( '<div class="submit">%s</div>', $submit_input );
     2437    }
     2438
     2439    if ( empty( $submit_data['nonce_key'] ) ) {
     2440        wp_nonce_field( $submit_data['nonce'] );
     2441    } else {
     2442        wp_nonce_field( $submit_data['nonce'], $submit_data['nonce_key'] );
     2443    }
    24352444
    24362445    if ( ! empty( $submit_data['after'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.