Skip to content

Commit

Permalink
Merge pull request #1134 from publishpress/ppb-1125
Browse files Browse the repository at this point in the history
Ppb 1125
  • Loading branch information
htmgarcia authored Dec 21, 2022
2 parents a790d19 + eaed58a commit f371237
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/assets/blocks/blocks.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/assets/blocks/blocks.min.js.map

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions src/assets/blocks/summary/block.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,46 @@ import latinize from "latinize";
return storeData;
}

/**
* Function to get headings from accordions blocks
*
* @since 3.1.2
*
* @param block array Columns block to get data
* @param storeData array Data array to store heading blocks
*
* @returns array array Headings from block given
*/
static getHeadingsfromAccordion( block, storeData )
{
block.innerBlocks.map( (item) => {
if( item.name === 'advgb/accordion-item' ) {
const content = item.attributes.header || null;
const level = item.attributes.headerTag
? parseInt( item.attributes.headerTag.substring( 1 ) )
: 3;

if( content ) {

// Create a valid heading block
let block_ = wp.blocks.createBlock('core/heading', {
content: content,
level: level
});

// Add anchor attribute
if( item.attributes.anchor ) {
block_.attributes = Object.assign( block_.attributes, {
anchor: item.attributes.anchor
} );
}

storeData.push( block_ );
}
}
});
}

latinise(str) {
let lettersArr = str.split('');
let result = [];
Expand All @@ -155,10 +195,15 @@ import latinize from "latinize";
const filteredBlocks = allBlocks.filter( ( block ) => (
block.name === 'core/heading' || block.name === 'core/columns'
|| block.name === 'core/cover' || block.name === 'core/group'
|| block.name === 'advgb/accordions'
) );
filteredBlocks.map(function ( block ) {
if (block.name === 'core/columns' || block.name === 'core/cover' || block.name === 'core/group') {
SummaryBlock.getHeadingBlocksFromColumns( block, headingBlocks );
} else if( block.name === 'advgb/accordions'
&& advgbBlocks.advgb_pro === '1' // Only in Pro
) {
SummaryBlock.getHeadingsfromAccordion( block, headingBlocks );
} else {
headingBlocks.push( block );
}
Expand Down
3 changes: 2 additions & 1 deletion src/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,13 @@ Yes, we use the phrase "publishpress-advg-install" to share install links. You w

== Changelog ==

= 3.1.2 - 20 Dec 2022 =
= 3.1.2 - 21 Dec 2022 =
* Add: Days of the week and time range settings to Schedule control
* Add: Term archives and pages control
* Add: Bring back map files
* Add: Display timezone below dates
* Add: Minify compiled JSX files
* Add: Support for Accordion items in Table of Contents block for Pro version
* Fix: For User role control, when no role is selected, the block is hidden to everyone
* Fix: Hide widgets HTML wrapper when its block is not visible
* Fix: Set autoload to 'no' for bigger size options
Expand Down

0 comments on commit f371237

Please sign in to comment.