Skip to:
Content

BuddyPress.org

Ticket #8065: 8065.patch

File 8065.patch, 6.3 KB (added by imath, 7 years ago)
  • src/bp-templates/bp-nouveau/buddypress/common/js-templates/activity/form.php

    diff --git src/bp-templates/bp-nouveau/buddypress/common/js-templates/activity/form.php src/bp-templates/bp-nouveau/buddypress/common/js-templates/activity/form.php
    index ef5cfbbfd..285245993 100644
     
    22/**
    33 * Activity Post form JS Templates
    44 *
    5  * @version 3.1.0
     5 * @since 3.0.0
     6 * @version 5.0.0
    67 */
    78?>
    89
     10<script type="text/html" id="tmpl-activity-before-post-form-inputs">
     11        <?php bp_nouveau_activity_hook( 'before', 'post_form' ); ?>
     12</script>
     13
    914<script type="text/html" id="tmpl-activity-post-form-feedback">
    1015        <span class="bp-icon" aria-hidden="true"></span><p>{{{data.message}}}</p>
    1116</script>
  • src/bp-templates/bp-nouveau/includes/activity/functions.php

    diff --git src/bp-templates/bp-nouveau/includes/activity/functions.php src/bp-templates/bp-nouveau/includes/activity/functions.php
    index 385dd1634..975bc5e86 100644
     
    33 * Activity functions
    44 *
    55 * @since 3.0.0
    6  * @version 3.1.0
     6 * @version 5.0.0
    77 */
    88
    99// Exit if accessed directly.
    function bp_nouveau_activity_localize_scripts( $params = array() ) {  
    6767        $activity_params = array(
    6868                'user_id'     => bp_loggedin_user_id(),
    6969                'object'      => 'user',
    70                 'backcompat'  => (bool) has_action( 'bp_activity_post_form_options' ),
     70                'backcompat'  => array(
     71                        'before_post_form'  => (bool) has_action( 'bp_before_activity_post_form' ),
     72                        'post_form_options' => (bool) has_action( 'bp_activity_post_form_options' ),
     73                ),
    7174                'post_nonce'  => wp_create_nonce( 'post_update', '_wpnonce_post_update' ),
    7275        );
    7376
  • src/bp-templates/bp-nouveau/includes/activity/template-tags.php

    diff --git src/bp-templates/bp-nouveau/includes/activity/template-tags.php src/bp-templates/bp-nouveau/includes/activity/template-tags.php
    index 2d73c2ed8..29e4d7273 100644
     
    33 * Activity Template tags
    44 *
    55 * @since 3.0.0
    6  * @version 3.1.0
     6 * @version 5.0.0
    77 */
    88
    99// Exit if accessed directly.
    function bp_nouveau_after_activity_directory_content() {  
    6767 * Enqueue needed scripts for the Activity Post Form
    6868 *
    6969 * @since 3.0.0
     70 * @since 5.0.0 Move the `bp_before_activity_post_form` hook inside the Activity post form.
    7071 */
    7172function bp_nouveau_before_activity_post_form() {
    7273        if ( bp_nouveau_current_user_can( 'publish_activity' ) ) {
    7374                wp_enqueue_script( 'bp-nouveau-activity-post-form' );
    7475        }
    75 
    76         /**
    77          * Fires before the activity post form.
    78          *
    79          * @since 1.2.0
    80          */
    81         do_action( 'bp_before_activity_post_form' );
    8276}
    8377
    8478/**
  • src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.js

    diff --git src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.js src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.js
    index 1e17af71d..3e3c83b78 100644
     
    11/* global bp, BP_Nouveau, _, Backbone */
    2 /* @version 3.1.0 */
     2/* @since 3.0.0 */
     3/* @version 5.0.0 */
    34window.wp = window.wp || {};
    45window.bp = window.bp || {};
    56
    window.bp = window.bp || {};  
    375376                template : bp.template( 'activity-post-form-options' )
    376377        } );
    377378
     379        bp.Views.BeforeFormInputs = bp.View.extend( {
     380                tagName  : 'div',
     381                template : bp.template( 'activity-before-post-form-inputs' )
     382        } );
     383
    378384        bp.Views.FormTarget = bp.View.extend( {
    379385                tagName   : 'div',
    380386                id        : 'whats-new-post-in-box',
    window.bp = window.bp || {};  
    586592                                BP_Nouveau.activity.params,
    587593                                ['user_id', 'item_id', 'object' ]
    588594                        ) );
     595                        this.options.backcompat = BP_Nouveau.activity.params.backcompat;
     596                        var staticViews = [
     597                                new bp.Views.FormAvatar(),
     598                                new bp.Views.FormContent( { activity: this.model } )
     599                        ];
     600
     601                        // Backcompat to take the `bp_before_activity_post_form` action in account.
     602                        if ( true === this.options.backcompat.before_post_form ) {
     603                                staticViews.unshift( new bp.Views.BeforeFormInputs() );
     604                        }
    589605
    590606                        // Clone the model to set the resetted one
    591607                        this.resetModel = this.model.clone();
    592608
    593                         this.views.set( [
    594                                 new bp.Views.FormAvatar(),
    595                                 new bp.Views.FormContent( { activity: this.model } )
    596                         ] );
     609                        this.views.set( staticViews );
    597610
    598611                        this.model.on( 'change:errors', this.displayFeedback, this );
    599612                },
    600613
    601614                displayFull: function( event ) {
     615                        var numStaticViews = true === this.options.backcompat.before_post_form ? 3 : 2;
    602616
    603617                        // Remove feedback.
    604618                        this.cleanFeedback();
    605619
    606                         if ( 2 !== this.views._views[''].length ) {
     620                        if ( numStaticViews !== this.views._views[''].length ) {
    607621                                return;
    608622                        }
    609623
    window.bp = window.bp || {};  
    612626                                height : 'auto'
    613627                        } );
    614628
    615                         // Backcompat custom fields
    616                         if ( true === BP_Nouveau.activity.params.backcompat ) {
     629                        // Add the container view for buttons or custom fields.
     630                        if ( true === this.options.backcompat.post_form_options ) {
    617631                                this.views.add( new bp.Views.FormOptions( { model: this.model } ) );
     632                        } else {
     633                                this.views.add( new bp.View( { id: 'whats-new-options' } ) );
    618634                        }
    619635
    620636                        // Attach buttons
    621637                        if ( ! _.isUndefined( BP_Nouveau.activity.params.buttons ) ) {
    622638                                // Global
    623639                                bp.Nouveau.Activity.postForm.buttons.set( BP_Nouveau.activity.params.buttons );
    624                                 this.views.add( new bp.Views.FormButtons( { collection: bp.Nouveau.Activity.postForm.buttons, model: this.model } ) );
     640                                this.views.add( '#whats-new-options', new bp.Views.FormButtons( { collection: bp.Nouveau.Activity.postForm.buttons, model: this.model } ) );
    625641                        }
    626642
    627643                        // Select box for the object
    628644                        if ( ! _.isUndefined( BP_Nouveau.activity.params.objects ) && 1 < _.keys( BP_Nouveau.activity.params.objects ).length ) {
    629                                 this.views.add( new bp.Views.FormTarget( { model: this.model } ) );
     645                                this.views.add( '#whats-new-options', new bp.Views.FormTarget( { model: this.model } ) );
    630646                        }
    631647
    632                         this.views.add( new bp.Views.FormSubmit( { model: this.model } ) );
     648                        this.views.add( '#whats-new-options', new bp.Views.FormSubmit( { model: this.model } ) );
    633649                },
    634650
    635651                resetForm: function() {
     652                        var self = this, indexStaticViews = self.options.backcompat.before_post_form ? 2 : 1;
     653
    636654                        _.each( this.views._views[''], function( view, index ) {
    637                                 if ( index > 1 ) {
     655                                if ( index > indexStaticViews ) {
    638656                                        view.remove();
    639657                                }
    640658                        } );