1(function(){ 2 /** 3 * Create a new MediaLibraryTaxonomyFilter we later will instantiate 4 */ 5 var MediaLibraryTaxonomyFilter = wp.media.view.AttachmentFilters.extend({ 6 id: 'media-attachment-taxonomy-filter2', 7 8 createFilters: function() { 9 var filters = {}; 10 11 // Formats the 'terms' we've included via wp_localize_script() 12 _.each( MediaLibraryTaxonomyFilterData.terms || {}, function( value, index ) { 13 //console.log(value.name+"$$$"+value.term_id +"$$$"+index); 14 filters[ value.name ] = { 15 text: value.name, 16 props: { 17 // Change this: key needs to be the WP_Query var for the taxonomy 18 mediafilter: value.term_id 19 } 20 }; 21 }); 22 filters.all = { 23 // Change this: use whatever default label you'd like 24 text: 'All media cats', 25 props: { 26 // Change this: key needs to be the WP_Query var for the taxonomy 27 mediafilter: '' 28 }, 29 priority: 1 30 }; 31 this.filters = filters; 32 } 33 }); 34 /** 35 * Extend and override wp.media.view.AttachmentsBrowser to include our new filter 36 */ 37 var AttachmentsBrowser = wp.media.view.AttachmentsBrowser; 38 wp.media.view.AttachmentsBrowser = wp.media.view.AttachmentsBrowser.extend({ 39 createToolbar: function() { 40 // Make sure to load the original toolbar 41 AttachmentsBrowser.prototype.createToolbar.call( this ); 42 this.toolbar.set( 'MediaLibraryTaxonomyFilter', new MediaLibraryTaxonomyFilter({ 43 controller: this.controller, 44 model: this.collection.props, 45 priority: -10 46 }).render() ); 47 } 48 }); 49 //------------------------------------------------------------------- 50 51 var MediaLibraryTaxonomyFilter1 = wp.media.view.AttachmentFilters.extend({ 52 id: 'media-attachment-taxonomy-filter1', 53 54 createFilters: function() { 55 var filters1 = {}; 56 57 // Formats the 'terms' we've included via wp_localize_script() 58 _.each( MediaLibraryTaxonomyFilterData.terms1 || {}, function( value, index ) { 59 //console.log(value.name+"$$$"+value.term_id +"$$$"+index); 60 filters1[ value.name ] = { 61 text: value.name, 62 props: { 63 // Change this: key needs to be the WP_Query var for the taxonomy 64 mediaclasses: value.term_id 65 } 66 }; 67 }); 68 filters1.all = { 69 // Change this: use whatever default label you'd like 70 text: 'All media Classes', 71 props: { 72 // Change this: key needs to be the WP_Query var for the taxonomy 73 mediaclasses: '' 74 }, 75 priority: 5 76 }; 77 this.filters = filters1; 78 } 79 }); 80 /** 81 * Extend and override wp.media.view.AttachmentsBrowser to include our new filter 82 */ 83 var AttachmentsBrowser1 = wp.media.view.AttachmentsBrowser; 84 wp.media.view.AttachmentsBrowser = wp.media.view.AttachmentsBrowser.extend({ 85 createToolbar: function() { 86 // Make sure to load the original toolbar 87 AttachmentsBrowser1.prototype.createToolbar.call( this ); 88 this.toolbar.set( 'MediaLibraryTaxonomyFilter1', new MediaLibraryTaxonomyFilter1({ 89 controller: this.controller, 90 model: this.collection.props, 91 priority: -15 92 }).render() ); 93 } 94 }); 95})() 96
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.