Skip to content

Commit

Permalink
Merge pull request #320 from 10up/fix/block-recovery
Browse files Browse the repository at this point in the history
Ensure Podcast block updates are backward compatible.
  • Loading branch information
dkotter authored Sep 20, 2024
2 parents 48bf448 + 22c89c4 commit c765d1d
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
2 changes: 2 additions & 0 deletions assets/js/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { registerBlockType, registerBlockVariation } from '@wordpress/blocks';
// Split the Edit component out.
import Edit from './edit';
import transforms from './transforms';
import deprecated from './deprecated';
import '../css/podcasting-editor-screen.css';

/**
Expand Down Expand Up @@ -139,6 +140,7 @@ export default registerBlockType(
</figure>
);
},
deprecated,
},
);

Expand Down
89 changes: 89 additions & 0 deletions assets/js/deprecated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
export default [
{
attributes: {
id: {
type: 'number',
},
src: {
type: 'string',
source: 'attribute',
selector: 'audio',
attribute: 'src',
},
url: {
type: 'string',
source: 'meta',
meta: 'podcast_url',
},
filesize: {
type: 'number',
source: 'meta',
meta: 'podcast_filesize',
},
duration: {
type: 'string',
source: 'meta',
meta: 'podcast_duration',
},
mime: {
type: 'string',
source: 'meta',
meta: 'podcast_mime',
},
caption: {
type: 'array',
source: 'children',
selector: 'figcaption',
},
captioned: {
type: 'boolean',
source: 'meta',
meta: 'podcast_captioned',
default: false,
},
explicit: {
type: 'string',
source: 'meta',
meta: 'podcast_explicit',
default: 'no',
},
enclosure: {
type: 'string',
source: 'meta',
meta: 'enclosure',
},
seasonNumber: {
type: 'string',
source: 'meta',
meta: 'podcast_season_number',
},
episodeNumber: {
type: 'string',
source: 'meta',
meta: 'podcast_episode_number',
},
episodeType: {
type: 'string',
source: 'meta',
meta: 'podcast_episode_type',
}
},
supports: {
multiple: false,
},
save: props => {
const {
id,
src,
caption
} = props.attributes;

return (
<figure className={ id ? `podcast-${ id }` : null }>
<audio controls="controls" src={ src } />
{ caption && caption.length > 0 && <figcaption>{ caption }</figcaption> }
</figure>
);
},
},
];

0 comments on commit c765d1d

Please sign in to comment.