[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 /** 2 * WordPress dependencies. 3 */ 4 const { 5 blocks: { 6 createBlock, 7 }, 8 } = wp; 9 10 /** 11 * Transforms Nouveau Activity Widget to Activity Block. 12 * 13 * @type {Object} 14 */ 15 const transforms = { 16 from: [ 17 { 18 type: 'block', 19 blocks: [ 'core/legacy-widget' ], 20 isMatch: ( { idBase, instance } ) => { 21 if ( ! instance?.raw ) { 22 return false; 23 } 24 25 return idBase === 'bp_latest_activities'; 26 }, 27 transform: ( { instance } ) => { 28 const regex = /i:\d*;s:\d*:"(.*?)";/gmi; 29 let types = []; 30 let matches; 31 32 while ( ( matches = regex.exec( instance.raw.type ) ) !== null ) { 33 if ( matches.index === regex.lastIndex ) { 34 regex.lastIndex++; 35 } 36 37 matches.forEach( ( match, groupIndex ) => { 38 if ( 1 === groupIndex ) { 39 types.push( match ); 40 } 41 } ); 42 } 43 44 return createBlock( 'bp/latest-activities', { 45 title: instance.raw.title, 46 maxActivities: parseInt( instance.raw.max, 10 ), 47 type: types, 48 } ); 49 }, 50 }, 51 ], 52 }; 53 54 export default transforms;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri May 5 01:01:24 2023 | Cross-referenced by PHPXref 0.7.1 |