Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kadencewp committed Feb 16, 2024
2 parents 72500e4 + f9a54b9 commit 6da3833
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/early-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ export function blockMetadataAttribute( settings ) {
if ( context === 'list-view' && get( metadata, 'name', '' ) !== '' ) {
return metadata.name;
} else if ( undefined !== contentLabel && get( attributes, contentLabel ) !== '' ) {
// Accordion pane block is stored as an array, doing this instead of deprecation on parent accordion.
if( get( settings, 'name' ) === 'kadence/pane' && get( attributes, contentLabel ) instanceof Array ) {
return convertArrayTitleToString( get( attributes, contentLabel ) );
}

return get( attributes, contentLabel );
}
};
Expand All @@ -47,4 +52,18 @@ export function blockMetadataAttribute( settings ) {
return settings;
}

function convertArrayTitleToString(arr) {
let result = '';

arr.forEach(item => {
if (typeof item === 'string') {
result += item;
} else if (item.props && item.props.children) {
result += convertArrayTitleToString(item.props.children);
}
});

return result;
}

addFilter( 'blocks.registerBlockType', 'kadence/block-label', blockMetadataAttribute );

0 comments on commit 6da3833

Please sign in to comment.