index.js
17 lines
| 1 | export default function getAllUniqueIds( allBlocks, data, currentClientId ) { |
| 2 | Object.keys( allBlocks ).forEach( ( key ) => { |
| 3 | const clientId = 'undefined' !== typeof allBlocks[ key ].clientId ? allBlocks[ key ].clientId : ''; |
| 4 | const blockName = 'undefined' !== typeof allBlocks[ key ].name ? allBlocks[ key ].name : ''; |
| 5 | |
| 6 | if ( clientId !== currentClientId && blockName.includes( 'generateblocks' ) ) { |
| 7 | data.push( allBlocks[ key ].attributes.uniqueId ); |
| 8 | } |
| 9 | |
| 10 | if ( 'undefined' !== typeof allBlocks[ key ].innerBlocks && allBlocks[ key ].innerBlocks.length > 0 ) { |
| 11 | getAllUniqueIds( allBlocks[ key ].innerBlocks, data, currentClientId ); |
| 12 | } |
| 13 | } ); |
| 14 | |
| 15 | return data; |
| 16 | } |
| 17 |