File tree Expand file tree Collapse file tree 3 files changed +23
-8
lines changed
mu-plugins/blocks/link-wrapper Expand file tree Collapse file tree 3 files changed +23
-8
lines changed Original file line number Diff line number Diff line change 2020 * @see https://developer.wordpress.org/reference/functions/register_block_type/
2121 */
2222function init () {
23- register_block_type ( __DIR__ . '/build ' );
23+ register_block_type (
24+ __DIR__ . '/build ' ,
25+ array (
26+ 'render_callback ' => __NAMESPACE__ . '\render ' ,
27+ )
28+ );
29+ }
30+
31+ function render ( $ attributes , $ content ) {
32+ $ wrapper_attributes = get_block_wrapper_attributes ();
33+ $ link = isset ( $ attributes ['url ' ] ) ? ' ' . $ attributes ['url ' ] : get_permalink ();
34+
35+ return sprintf (
36+ '<a href="%1$s" %2$s">%3$s</a> ' ,
37+ esc_url ( $ link ),
38+ $ wrapper_attributes ,
39+ do_blocks ( $ content )
40+ );
2441}
Original file line number Diff line number Diff line change 3030 "padding" : true
3131 }
3232 },
33+ "dimensions" : {
34+ "minHeight" : true
35+ },
3336 "typography" : {
3437 "fontSize" : true ,
3538 "lineHeight" : true
Original file line number Diff line number Diff line change @@ -55,12 +55,7 @@ function Edit( { attributes, setAttributes } ) {
5555
5656registerBlockType ( metadata . name , {
5757 edit : Edit ,
58- save : ( { attributes } ) => {
59- const blockProps = useBlockProps . save ( ) ;
60- return (
61- < a { ...blockProps } href = { attributes . url } >
62- < InnerBlocks . Content />
63- </ a >
64- ) ;
58+ save : ( ) => {
59+ return < InnerBlocks . Content />
6560 } ,
6661} ) ;
You can’t perform that action at this time.
0 commit comments