-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
33 lines (28 loc) · 932 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* Extend acf related articles block settings
*
* @see https://developer.wordpress.org/block-editor/developers/filters/block-filters/#blocks-registerblocktype
*/
const registerBlockTypeHook = {
hookName: 'blocks.registerBlockType',
namespace: 'ups/extend/related-articles-settings',
callback(settings, name) {
if (name !== 'acf/relatedarticles') {
return settings;
}
const updatedSettings = Object.assign({}, settings, {
attributes: Object.assign({}, settings.attributes, {
align: Object.assign({}, settings.attributes.align, {
default: 'center',
}),
}),
supports: Object.assign({}, settings.supports, {
// Only allow center, left, and right alignment options
align: ['center', 'left', 'right'],
}),
});
return updatedSettings;
},
};
export const hooks = [registerBlockTypeHook];
export const name = 'related-articles';