Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Parser: Enable filterable attribute source
  • Loading branch information
aduth committed Mar 3, 2018
commit c2ad6f81563e9b38c7aeb8b0f3e97db078d6dd8d
11 changes: 10 additions & 1 deletion blocks/api/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { mapValues, omit } from 'lodash';
* WordPress dependencies
*/
import { autop } from '@wordpress/autop';
import { applyFilters } from '@wordpress/hooks';

/**
* Internal dependencies
Expand Down Expand Up @@ -118,7 +119,15 @@ export function getBlockAttribute( attributeKey, attributeSchema, innerHTML, com
break;
}

return value === undefined ? attributeSchema.default : asType( value, attributeSchema.type );
value = applyFilters( 'blocks.getBlockAttribute.source', value, attributeSchema, innerHTML, commentAttributes );

if ( value === undefined ) {
value = attributeSchema.default;
} else {
value = asType( value, attributeSchema.type );
}

return applyFilters( 'blocks.getBlockAttribute', value, attributeSchema, innerHTML, commentAttributes );
}

/**
Expand Down