Skip to content
This repository has been archived by the owner on Nov 2, 2024. It is now read-only.

Commit

Permalink
Remove pre-WP 5.6 from save fn
Browse files Browse the repository at this point in the history
  • Loading branch information
mkaz committed Dec 13, 2021
1 parent 6ae6c5b commit 78eab9a
Showing 1 changed file with 11 additions and 23 deletions.
34 changes: 11 additions & 23 deletions src/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,18 @@ const save = ( { attributes } ) => {
cls = attributes.language ? 'language-' + attributes.language : '';
cls = attributes.lineNumbers ? cls + ' line-numbers' : cls;

// WP 5.6 / GB 9.2
if ( useBlockProps ) {
const blockProps = useBlockProps.save( { title: attributes.title } );
return (
<>
<pre { ...blockProps }>
<RichText.Content
tagName="code"
value={ attributes.content }
lang={ attributes.language }
className={ cls }
/>
</pre>
</>
);
}

// Backward compatibility < WP 5.6
const blockProps = useBlockProps.save( { title: attributes.title } );
return (
<pre className="wp-block-code" title={ attributes.title }>
<code lang={ attributes.language } className={ cls }>
{ attributes.content }
</code>
</pre>
<>
<pre { ...blockProps }>
<RichText.Content
tagName="code"
value={ attributes.content }
lang={ attributes.language }
className={ cls }
/>
</pre>
</>
);
};

Expand Down

0 comments on commit 78eab9a

Please sign in to comment.