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
|
|
|
|
| 2 | 2 | /** |
| 3 | 3 | * Activity Post form JS Templates |
| 4 | 4 | * |
| 5 | | * @version 3.1.0 |
| | 5 | * @since 3.0.0 |
| | 6 | * @version 5.0.0 |
| 6 | 7 | */ |
| 7 | 8 | ?> |
| 8 | 9 | |
| | 10 | <script type="text/html" id="tmpl-activity-before-post-form-inputs"> |
| | 11 | <?php bp_nouveau_activity_hook( 'before', 'post_form' ); ?> |
| | 12 | </script> |
| | 13 | |
| 9 | 14 | <script type="text/html" id="tmpl-activity-post-form-feedback"> |
| 10 | 15 | <span class="bp-icon" aria-hidden="true"></span><p>{{{data.message}}}</p> |
| 11 | 16 | </script> |
diff --git src/bp-templates/bp-nouveau/includes/activity/functions.php src/bp-templates/bp-nouveau/includes/activity/functions.php
index 385dd1634..975bc5e86 100644
|
|
|
|
| 3 | 3 | * Activity functions |
| 4 | 4 | * |
| 5 | 5 | * @since 3.0.0 |
| 6 | | * @version 3.1.0 |
| | 6 | * @version 5.0.0 |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // Exit if accessed directly. |
| … |
… |
function bp_nouveau_activity_localize_scripts( $params = array() ) {
|
| 67 | 67 | $activity_params = array( |
| 68 | 68 | 'user_id' => bp_loggedin_user_id(), |
| 69 | 69 | '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 | ), |
| 71 | 74 | 'post_nonce' => wp_create_nonce( 'post_update', '_wpnonce_post_update' ), |
| 72 | 75 | ); |
| 73 | 76 | |
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
|
|
|
|
| 3 | 3 | * Activity Template tags |
| 4 | 4 | * |
| 5 | 5 | * @since 3.0.0 |
| 6 | | * @version 3.1.0 |
| | 6 | * @version 5.0.0 |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // Exit if accessed directly. |
| … |
… |
function bp_nouveau_after_activity_directory_content() {
|
| 67 | 67 | * Enqueue needed scripts for the Activity Post Form |
| 68 | 68 | * |
| 69 | 69 | * @since 3.0.0 |
| | 70 | * @since 5.0.0 Move the `bp_before_activity_post_form` hook inside the Activity post form. |
| 70 | 71 | */ |
| 71 | 72 | function bp_nouveau_before_activity_post_form() { |
| 72 | 73 | if ( bp_nouveau_current_user_can( 'publish_activity' ) ) { |
| 73 | 74 | wp_enqueue_script( 'bp-nouveau-activity-post-form' ); |
| 74 | 75 | } |
| 75 | | |
| 76 | | /** |
| 77 | | * Fires before the activity post form. |
| 78 | | * |
| 79 | | * @since 1.2.0 |
| 80 | | */ |
| 81 | | do_action( 'bp_before_activity_post_form' ); |
| 82 | 76 | } |
| 83 | 77 | |
| 84 | 78 | /** |
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
|
|
|
|
| 1 | 1 | /* global bp, BP_Nouveau, _, Backbone */ |
| 2 | | /* @version 3.1.0 */ |
| | 2 | /* @since 3.0.0 */ |
| | 3 | /* @version 5.0.0 */ |
| 3 | 4 | window.wp = window.wp || {}; |
| 4 | 5 | window.bp = window.bp || {}; |
| 5 | 6 | |
| … |
… |
window.bp = window.bp || {};
|
| 375 | 376 | template : bp.template( 'activity-post-form-options' ) |
| 376 | 377 | } ); |
| 377 | 378 | |
| | 379 | bp.Views.BeforeFormInputs = bp.View.extend( { |
| | 380 | tagName : 'div', |
| | 381 | template : bp.template( 'activity-before-post-form-inputs' ) |
| | 382 | } ); |
| | 383 | |
| 378 | 384 | bp.Views.FormTarget = bp.View.extend( { |
| 379 | 385 | tagName : 'div', |
| 380 | 386 | id : 'whats-new-post-in-box', |
| … |
… |
window.bp = window.bp || {};
|
| 586 | 592 | BP_Nouveau.activity.params, |
| 587 | 593 | ['user_id', 'item_id', 'object' ] |
| 588 | 594 | ) ); |
| | 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 | } |
| 589 | 605 | |
| 590 | 606 | // Clone the model to set the resetted one |
| 591 | 607 | this.resetModel = this.model.clone(); |
| 592 | 608 | |
| 593 | | this.views.set( [ |
| 594 | | new bp.Views.FormAvatar(), |
| 595 | | new bp.Views.FormContent( { activity: this.model } ) |
| 596 | | ] ); |
| | 609 | this.views.set( staticViews ); |
| 597 | 610 | |
| 598 | 611 | this.model.on( 'change:errors', this.displayFeedback, this ); |
| 599 | 612 | }, |
| 600 | 613 | |
| 601 | 614 | displayFull: function( event ) { |
| | 615 | var numStaticViews = true === this.options.backcompat.before_post_form ? 3 : 2; |
| 602 | 616 | |
| 603 | 617 | // Remove feedback. |
| 604 | 618 | this.cleanFeedback(); |
| 605 | 619 | |
| 606 | | if ( 2 !== this.views._views[''].length ) { |
| | 620 | if ( numStaticViews !== this.views._views[''].length ) { |
| 607 | 621 | return; |
| 608 | 622 | } |
| 609 | 623 | |
| … |
… |
window.bp = window.bp || {};
|
| 612 | 626 | height : 'auto' |
| 613 | 627 | } ); |
| 614 | 628 | |
| 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 ) { |
| 617 | 631 | this.views.add( new bp.Views.FormOptions( { model: this.model } ) ); |
| | 632 | } else { |
| | 633 | this.views.add( new bp.View( { id: 'whats-new-options' } ) ); |
| 618 | 634 | } |
| 619 | 635 | |
| 620 | 636 | // Attach buttons |
| 621 | 637 | if ( ! _.isUndefined( BP_Nouveau.activity.params.buttons ) ) { |
| 622 | 638 | // Global |
| 623 | 639 | 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 } ) ); |
| 625 | 641 | } |
| 626 | 642 | |
| 627 | 643 | // Select box for the object |
| 628 | 644 | 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 } ) ); |
| 630 | 646 | } |
| 631 | 647 | |
| 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 } ) ); |
| 633 | 649 | }, |
| 634 | 650 | |
| 635 | 651 | resetForm: function() { |
| | 652 | var self = this, indexStaticViews = self.options.backcompat.before_post_form ? 2 : 1; |
| | 653 | |
| 636 | 654 | _.each( this.views._views[''], function( view, index ) { |
| 637 | | if ( index > 1 ) { |
| | 655 | if ( index > indexStaticViews ) { |
| 638 | 656 | view.remove(); |
| 639 | 657 | } |
| 640 | 658 | } ); |