Ticket #8213: 8213.patch
File 8213.patch, 18.8 KB (added by , 5 years ago) |
---|
-
src/bp-loader.php
26 26 * PHP supported by WordPress. 27 27 */ 28 28 29 // Exit if accessed directly 29 // Exit if accessed directly. 30 30 defined( 'ABSPATH' ) || exit; 31 31 32 32 // Required PHP version. … … 85 85 if ( defined( 'BUDDYPRESS_LATE_LOAD' ) ) { 86 86 add_action( 'plugins_loaded', 'buddypress', (int) BUDDYPRESS_LATE_LOAD ); 87 87 88 // "And now here's something we hope you'll really like!" 88 // "And now here's something we hope you'll really like!". 89 89 } else { 90 90 $GLOBALS['bp'] = buddypress(); 91 91 } -
src/bp-templates/bp-nouveau/buddypress-functions.php
170 170 // We need to neutralize the BuddyPress core "bp_core_render_message()" once it has been added. 171 171 add_action( 'bp_actions', array( $this, 'neutralize_core_template_notices' ), 6 ); 172 172 173 // Scripts 174 add_action( 'bp_enqueue_scripts', array( $this, 'register_scripts' ), 2 ); // Register theme JS 173 // Scripts. 174 add_action( 'bp_enqueue_scripts', array( $this, 'register_scripts' ), 2 ); // Register theme JS. 175 175 remove_action( 'bp_enqueue_scripts', 'bp_core_confirmation_js' ); 176 add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); // Enqueue theme CSS 177 add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); // Enqueue theme JS 178 add_filter( 'bp_enqueue_scripts', array( $this, 'localize_scripts' ) ); // Enqueue theme script localization 176 add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); // Enqueue theme CSS. 177 add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); // Enqueue theme JS. 178 add_filter( 'bp_enqueue_scripts', array( $this, 'localize_scripts' ) ); // Enqueue theme script localization. 179 179 180 // Body no-js class 180 // Body no-js class. 181 181 add_filter( 'body_class', array( $this, 'add_nojs_body_class' ), 20, 1 ); 182 182 183 // Ajax querystring 183 // Ajax querystring. 184 184 add_filter( 'bp_ajax_querystring', 'bp_nouveau_ajax_querystring', 10, 2 ); 185 185 186 // Register directory nav items 186 // Register directory nav items. 187 187 add_action( 'bp_screens', array( $this, 'setup_directory_nav' ), 15 ); 188 188 189 // Register the Default front pages Dynamic Sidebars 189 // Register the Default front pages Dynamic Sidebars. 190 190 add_action( 'widgets_init', 'bp_nouveau_register_sidebars', 11 ); 191 191 192 // Register the Primary Object nav widget 192 // Register the Primary Object nav widget. 193 193 add_action( 'bp_widgets_init', array( 'BP_Nouveau_Object_Nav_Widget', 'register_widget' ) ); 194 194 195 // Set the BP Uri for the Ajax customizer preview 195 // Set the BP Uri for the Ajax customizer preview. 196 196 add_filter( 'bp_uri', array( $this, 'customizer_set_uri' ), 10, 1 ); 197 197 198 198 /** Override **********************************************************/ … … 317 317 ), 318 318 ) ); 319 319 320 // Bail if no scripts 320 // Bail if no scripts. 321 321 if ( empty( $scripts ) ) { 322 322 return; 323 323 } … … 430 430 'object_nav_parent' => '#buddypress', 431 431 ); 432 432 433 // If the Object/Item nav are in the sidebar 433 // If the Object/Item nav are in the sidebar. 434 434 if ( bp_nouveau_is_object_nav_in_sidebar() ) { 435 435 $params['object_nav_parent'] = '.buddypress_object_nav'; 436 436 } … … 459 459 $supported_objects = array_merge( $supported_objects, array( 'group_members', 'group_requests' ) ); 460 460 } 461 461 462 // Add components & nonces 462 // Add components & nonces. 463 463 $params['objects'] = $supported_objects; 464 464 $params['nonces'] = $object_nonces; 465 465 466 // Used to transport the settings inside the Ajax requests 466 // Used to transport the settings inside the Ajax requests. 467 467 if ( is_customize_preview() ) { 468 468 $params['customizer_settings'] = bp_nouveau_get_temporary_setting( 'any' ); 469 469 } … … 602 602 continue; 603 603 } 604 604 605 // Define the primary nav for the current component's directory 605 // Define the primary nav for the current component's directory. 606 606 $this->directory_nav->add_nav( $nav_item ); 607 607 } 608 608 } -
src/bp-templates/bp-nouveau/js/buddypress-messages.js
6 6 7 7 ( function( exports, $ ) { 8 8 9 // Bail if not set 9 // Bail if not set. 10 10 if ( typeof BP_Nouveau === 'undefined' ) { 11 11 return; 12 12 } … … 46 46 setupNav: function() { 47 47 var self = this; 48 48 49 // First adapt the compose nav 49 // First adapt the compose nav. 50 50 $( '#compose-personal-li' ).addClass( 'last' ); 51 51 52 // Then listen to nav click and load the appropriate view 52 // Then listen to nav click and load the appropriate view. 53 53 $( '#subnav a' ).on( 'click', function( event ) { 54 54 event.preventDefault(); 55 55 56 56 var view_id = $( event.target ).prop( 'id' ); 57 57 58 // Remove the editor to be sure it will be added dynamically later 58 // Remove the editor to be sure it will be added dynamically later. 59 59 self.removeTinyMCE(); 60 60 61 // The compose view is specific (toggle behavior) 61 // The compose view is specific (toggle behavior). 62 62 if ( 'compose' === view_id ) { 63 // If it exists, it means the user wants to remove it 63 // If it exists, it means the user wants to remove it. 64 64 if ( ! _.isUndefined( self.views.get( 'compose' ) ) ) { 65 65 var form = self.views.get( 'compose' ); 66 66 form.get( 'view' ).remove(); 67 67 self.views.remove( { id: 'compose', view: form } ); 68 68 69 // Back to inbox 69 // Back to inbox. 70 70 if ( 'single' === self.box ) { 71 71 self.box = 'inbox'; 72 72 } 73 73 74 // Navigate back to current box 74 // Navigate back to current box. 75 75 self.router.navigate( self.box + '/', { trigger: true } ); 76 76 77 // Otherwise load it 77 // Otherwise load it. 78 78 } else { 79 79 self.router.navigate( 'compose/', { trigger: true } ); 80 80 } … … 132 132 displayFeedback: function( message, type ) { 133 133 var feedback; 134 134 135 // Make sure to remove the feedbacks 135 // Make sure to remove the feedbacks. 136 136 this.removeFeedback(); 137 137 138 138 if ( ! message ) { … … 150 150 }, 151 151 152 152 clearViews: function() { 153 // Clear views 153 // Clear views. 154 154 if ( ! _.isUndefined( this.views.models ) ) { 155 155 _.each( this.views.models, function( model ) { 156 156 model.get( 'view' ).remove(); … … 164 164 // Remove all existing views. 165 165 this.clearViews(); 166 166 167 // Create the loop view 167 // Create the loop view. 168 168 var form = new bp.Views.messageForm( { 169 169 model: new bp.Models.Message() 170 170 } ); … … 175 175 }, 176 176 177 177 threadsView: function() { 178 // Activate the appropriate nav 178 // Activate the appropriate nav. 179 179 $( '#subnav ul li' ).each( function( l, li ) { 180 180 $( li ).removeClass( 'current selected' ); 181 181 } ); 182 182 $( '#subnav a#' + this.box ).closest( 'li' ).addClass( 'current selected' ); 183 183 184 // Create the loop view 184 // Create the loop view. 185 185 var threads_list = new bp.Views.userThreads( { collection: this.threads, box: this.box } ); 186 186 187 187 this.views.add( { id: 'threads', view: threads_list } ); … … 188 188 189 189 threads_list.inject( '.bp-messages-content' ); 190 190 191 // Attach filters 191 // Attach filters. 192 192 this.displayFilters( this.threads ); 193 193 }, 194 194 … … 195 195 displayFilters: function( collection ) { 196 196 var filters_view; 197 197 198 // Create the model 198 // Create the model. 199 199 this.filters = new Backbone.Model( { 200 200 'page' : 1, 201 201 'total_page' : 0, … … 203 203 'box' : this.box 204 204 } ); 205 205 206 // Use it in the filters viex 206 // Use it in the filters viex. 207 207 filters_view = new bp.Views.messageFilters( { model: this.filters, threads: collection } ); 208 208 209 209 this.views.add( { id: 'filters', view: filters_view } ); … … 217 217 218 218 this.box = 'single'; 219 219 220 // Create the single thread view 220 // Create the single thread view. 221 221 var single_thread = new bp.Views.userMessages( { collection: this.messages, thread: thread } ); 222 222 223 223 this.views.add( { id: 'single', view: single_thread } ); … … 310 310 options.context = this; 311 311 options.data = options.data || {}; 312 312 313 // Add generic nonce 313 // Add generic nonce. 314 314 options.data.nonce = BP_Nouveau.nonces.messages; 315 315 316 316 if ( 'read' === method ) { … … 393 393 options.context = this; 394 394 options.data = options.data || {}; 395 395 396 // Add generic nonce 396 // Add generic nonce. 397 397 options.data.nonce = BP_Nouveau.nonces.messages; 398 398 399 399 if ( 'read' === method ) { … … 447 447 } 448 448 } ); 449 449 450 // Extend wp.Backbone.View with .prepare() and .inject() 450 // Extend wp.Backbone.View with .prepare() and .inject(). 451 451 bp.Nouveau.Messages.View = bp.Backbone.View.extend( { 452 452 inject: function( selector ) { 453 453 this.render(); … … 464 464 } 465 465 } ); 466 466 467 // Feedback view 467 // Feedback view. 468 468 bp.Views.Feedback = bp.Nouveau.Messages.View.extend( { 469 469 tagName: 'div', 470 470 className: 'bp-messages bp-user-messages-feedback', … … 478 478 } 479 479 } ); 480 480 481 // Hook view 481 // Hook view. 482 482 bp.Views.Hook = bp.Nouveau.Messages.View.extend( { 483 483 tagName: 'div', 484 484 template : bp.template( 'bp-messages-hook' ), … … 522 522 }, 523 523 524 524 initialize: function() { 525 // Clone the model to set the resetted one 525 // Clone the model to set the resetted one. 526 526 this.resetModel = this.model.clone(); 527 527 528 // Add the editor view 528 // Add the editor view. 529 529 this.views.add( '#bp-message-content', new bp.Views.messageEditor() ); 530 530 531 531 this.model.on( 'change', this.resetFields, this ); 532 532 533 // Activate bp_mentions 533 // Activate bp_mentions. 534 534 this.on( 'ready', this.addMentions, this ); 535 535 }, 536 536 … … 538 538 var sendToInput = $( this.el ).find( '#send-to-input' ), 539 539 mention = bp.Nouveau.getLinkParams( null, 'r' ) || null; 540 540 541 // Add autocomplete to send_to field 541 // Add autocomplete to send_to field. 542 542 sendToInput.bp_mentions( { 543 543 data: [], 544 544 suffix: ' ' 545 545 } ); 546 546 547 // Check for mention 547 // Check for mention. 548 548 if ( ! _.isNull( mention ) ) { 549 549 sendToInput.val( '@' + _.escape( mention ) + ' ' ); 550 550 sendToInput.focus(); … … 552 552 }, 553 553 554 554 resetFields: function( model ) { 555 // Clean inputs 555 // Clean inputs. 556 556 _.each( model.previousAttributes(), function( value, input ) { 557 557 if ( 'message_content' === input ) { 558 // tinyMce 558 // tinyMce. 559 559 if ( undefined !== tinyMCE.activeEditor && null !== tinyMCE.activeEditor ) { 560 560 tinyMCE.activeEditor.setContent( '' ); 561 561 } 562 562 563 // All except meta or empty value 563 // All except meta or empty value. 564 564 } else if ( 'meta' !== input && false !== value ) { 565 565 $( 'input[name="' + input + '"]' ).val( '' ); 566 566 } … … 576 576 577 577 bp.Nouveau.Messages.removeFeedback(); 578 578 579 // Set the content and meta 579 // Set the content and meta. 580 580 _.each( this.$el.serializeArray(), function( pair ) { 581 581 pair.name = pair.name.replace( '[]', '' ); 582 582 583 // Group extra fields in meta 583 // Group extra fields in meta. 584 584 if ( -1 === _.indexOf( ['send_to', 'subject', 'message_content'], pair.name ) ) { 585 585 if ( _.isUndefined( meta[ pair.name ] ) ) { 586 586 meta[ pair.name ] = pair.value; … … 592 592 meta[ pair.name ].push( pair.value ); 593 593 } 594 594 595 // Prepare the core model 595 // Prepare the core model. 596 596 } else { 597 // Send to 597 // Send to. 598 598 if ( 'send_to' === pair.name ) { 599 599 var usernames = pair.value.match( /(^|[^@\w\-])@([a-zA-Z0-9_\-]{1,50})\b/g ); 600 600 … … 613 613 this.model.set( 'send_to', usernames, { silent: true } ); 614 614 } 615 615 616 // Subject and content 616 // Subject and content. 617 617 } else { 618 // Message content 618 // Message content. 619 619 if ( 'message_content' === pair.name && undefined !== tinyMCE.activeEditor ) { 620 620 pair.value = tinyMCE.activeEditor.getContent(); 621 621 } … … 640 640 return; 641 641 } 642 642 643 // Set meta 643 // Set meta. 644 644 this.model.set( 'meta', meta, { silent: true } ); 645 645 646 646 // Send the message. 647 647 this.model.sendMessage().done( function( response ) { 648 // Reset the model 648 // Reset the model. 649 649 self.model.set( self.resetModel ); 650 650 651 651 bp.Nouveau.Messages.displayFeedback( response.feedback, response.type ); 652 652 653 // Remove tinyMCE 653 // Remove tinyMCE. 654 654 bp.Nouveau.Messages.removeTinyMCE(); 655 655 656 // Remove the form view 656 // Remove the form view. 657 657 var form = bp.Nouveau.Messages.views.get( 'compose' ); 658 658 form.get( 'view' ).remove(); 659 659 bp.Nouveau.Messages.views.remove( { id: 'compose', view: form } ); … … 690 690 this.views.add( view ); 691 691 }, this ); 692 692 693 // Load threads for the active view 693 // Load threads for the active view. 694 694 this.requestThreads(); 695 695 696 696 this.collection.on( 'reset', this.cleanContent, this ); … … 848 848 singleSelect: function( event ) { 849 849 var isChecked = $( event.currentTarget ).prop( 'checked' ); 850 850 851 // To avoid infinite loops 851 // To avoid infinite loops. 852 852 this.model.set( 'checked', isChecked, { silent: true } ); 853 853 854 854 var hasChecked = false; … … 894 894 }, 895 895 896 896 render: function() { 897 // Only render if we have some content to render 897 // Only render if we have some content to render. 898 898 if ( _.isUndefined( this.model ) || true !== this.model.get( 'active' ) ) { 899 899 return; 900 900 } … … 944 944 945 945 mid = model.get( 'id' ); 946 946 947 // Open the full conversation 947 // Open the full conversation. 948 948 if ( 'view' === action ) { 949 949 bp.Nouveau.Messages.router.navigate( 950 950 'view/' + mid + '/', … … 973 973 bp.Nouveau.Messages.displayFeedback( response.feedback, response.type ); 974 974 975 975 if ( 'delete' === action || ( 'starred' === self.collection.options.box && 'unstar' === action ) ) { 976 // Remove from the list of messages 976 // Remove from the list of messages. 977 977 self.collection.remove( model.get( 'id' ) ); 978 978 979 // And Requery 979 // And Requery. 980 980 self.collection.fetch( { 981 981 data : _.pick( self.collection.options, ['box', 'search_terms', 'page'] ) 982 982 } ); … … 1049 1049 return model.get( 'id' ); 1050 1050 } ); 1051 1051 1052 // Default to thread ids 1052 // Default to thread ids. 1053 1053 ids = thread_ids; 1054 1054 1055 // We need to get the starred ids 1055 // We need to get the starred ids. 1056 1056 if ( 'star' === action || 'unstar' === action ) { 1057 1057 ids = _.map( threads, function( model ) { 1058 1058 return model.get( 'starred_id' ); … … 1064 1064 }; 1065 1065 } 1066 1066 1067 // Map with first message starred in the thread 1067 // Map with first message starred in the thread. 1068 1068 attr = 'starred_id'; 1069 1069 } 1070 1070 1071 // Message id to Thread id 1071 // Message id to Thread id. 1072 1072 var m_tid = _.object( _.map( threads, function (model) { 1073 1073 return [model.get( attr ), model.get( 'id' )]; 1074 1074 } ) ); … … 1084 1084 bp.Nouveau.Messages.displayFeedback( response.feedback, response.type ); 1085 1085 1086 1086 if ( 'delete' === action || ( 'starred' === self.collection.options.box && 'unstar' === action ) ) { 1087 // Remove from the list of messages 1087 // Remove from the list of messages. 1088 1088 self.collection.remove( thread_ids ); 1089 1089 1090 // And Requery 1090 // And Requery. 1091 1091 self.collection.fetch( { 1092 1092 data : _.pick( self.collection.options, ['box', 'search_terms', 'page'] ) 1093 1093 } ); 1094 1094 } else if ( response.messages ) { 1095 // Update each model attributes 1095 // Update each model attributes. 1096 1096 _.each( response.messages, function( updated, id ) { 1097 1097 var model = self.collection.get( m_tid[id] ); 1098 1098 model.set( updated ); … … 1244 1244 // Remove previous feedback. 1245 1245 bp.Nouveau.Messages.removeFeedback(); 1246 1246 1247 // Display the feedback 1247 // Display the feedback. 1248 1248 bp.Nouveau.Messages.displayFeedback( response.feedback, response.type ); 1249 1249 } ).fail( function( response ) { 1250 1250 // Remove previous feedback. … … 1281 1281 template : bp.template( 'bp-messages-single' ), 1282 1282 1283 1283 initialize: function() { 1284 // Load Messages 1284 // Load Messages. 1285 1285 this.requestMessages(); 1286 1286 1287 // Init a reply 1287 // Init a reply. 1288 1288 this.reply = new bp.Models.messageThread(); 1289 1289 1290 1290 this.collection.on( 'add', this.addMessage, this ); 1291 1291 1292 // Add the editor view 1292 // Add the editor view. 1293 1293 this.views.add( '#bp-message-content', new bp.Views.messageEditor() ); 1294 1294 }, 1295 1295 … … 1366 1366 replySent: function( response ) { 1367 1367 var reply = this.collection.parse( response ); 1368 1368 1369 // Reset the form 1369 // Reset the form. 1370 1370 tinyMCE.activeEditor.setContent( '' ); 1371 1371 this.reply.set( 'sending', false ); 1372 1372 … … 1399 1399 return; 1400 1400 } 1401 1401 1402 // Try to get the corresponding thread 1402 // Try to get the corresponding thread. 1403 1403 var thread = bp.Nouveau.Messages.threads.get( thread_id ); 1404 1404 1405 1405 if ( undefined === thread ) { … … 1426 1426 } 1427 1427 } ); 1428 1428 1429 // Launch BP Nouveau Groups 1429 // Launch BP Nouveau Groups. 1430 1430 bp.Nouveau.Messages.start(); 1431 1431 1432 1432 } )( bp, jQuery ); -
src/bp-templates/bp-nouveau/js/buddypress-notifications.js
4 4 5 5 ( function( exports, $ ) { 6 6 7 // Bail if not set 7 // Bail if not set. 8 8 if ( typeof BP_Nouveau === 'undefined' ) { 9 9 return; 10 10 } … … 24 24 start: function() { 25 25 this.setupGlobals(); 26 26 27 // Listen to events ("Add hooks!") 27 // Listen to events ("Add hooks!"). 28 28 this.addListeners(); 29 29 }, 30 30 … … 47 47 // Trigger Notifications order request. 48 48 $( '#buddypress [data-bp-list="notifications"]' ).on( 'click', '[data-bp-notifications-order]', bp.Nouveau, this.sortNotifications ); 49 49 50 // Enable the Apply Button once the bulk action is selected 50 // Enable the Apply Button once the bulk action is selected. 51 51 $( '#buddypress [data-bp-list="notifications"]' ).on( 'change', '#notification-select', this.enableBulkSubmit ); 52 52 53 // Select all displayed notifications 53 // Select all displayed notifications. 54 54 $( '#buddypress [data-bp-list="notifications"]' ).on( 'click', '#select-all-notifications', this.selectAll ); 55 55 56 // Reset The filter before unload 56 // Reset The filter before unload. 57 57 $( window ).on( 'unload', this.resetFilter ); 58 58 }, 59 59 … … 72 72 $( '[data-bp-notifications-order="DESC"]' ).hide(); 73 73 } 74 74 75 // Make sure a 'Bulk Action' is selected before submitting the form 75 // Make sure a 'Bulk Action' is selected before submitting the form. 76 76 $( '#notification-bulk-manage' ).prop( 'disabled', 'disabled' ); 77 77 }, 78 78 … … 134 134 } 135 135 }; 136 136 137 // Launch BP Nouveau Notifications 137 // Launch BP Nouveau Notifications. 138 138 bp.Nouveau.Notifications.start(); 139 139 140 140 } )( bp, jQuery );