-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2819 from 10up/feature/2792
Support transforming legacy widgets to blocks and hide widgets when the blocks are available
- Loading branch information
Showing
15 changed files
with
557 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* WordPress dependencies. | ||
*/ | ||
import { createBlock } from '@wordpress/blocks'; | ||
|
||
/** | ||
* Facet widget block transforms. | ||
*/ | ||
export default { | ||
from: [ | ||
{ | ||
type: 'block', | ||
blocks: ['core/legacy-widget'], | ||
isMatch: ({ idBase }) => idBase === 'ep-facet', | ||
transform: ({ instance }) => { | ||
const { title = null, ...attributes } = instance.raw; | ||
|
||
if (!title) { | ||
return createBlock('elasticpress/facet', attributes); | ||
} | ||
|
||
return [ | ||
createBlock('core/heading', { content: title }), | ||
createBlock('elasticpress/facet', attributes), | ||
]; | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* WordPress dependencies. | ||
*/ | ||
import { createBlock } from '@wordpress/blocks'; | ||
|
||
/** | ||
* Facet widget block transforms. | ||
*/ | ||
export default { | ||
from: [ | ||
{ | ||
type: 'block', | ||
blocks: ['core/legacy-widget'], | ||
isMatch: ({ idBase }) => idBase === 'ep-related-posts', | ||
transform: ({ instance }) => { | ||
const { title = null, num_posts: number } = instance.raw; | ||
|
||
if (!title) { | ||
return createBlock('elasticpress/related-posts', { number }); | ||
} | ||
|
||
return [ | ||
createBlock('core/heading', { content: title }), | ||
createBlock('elasticpress/related-posts', { number }), | ||
]; | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.