PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.0.2
GenerateBlocks v2.0.2
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / src / extend / dynamic-content / utils / applyContext.js
generateblocks / src / extend / dynamic-content / utils Last commit date
applyContext.js 4 years ago getContent.js 3 years ago getContentTypeLabel.js 3 years ago
applyContext.js
24 lines
1 /**
2 * Applies the context to the attributes.
3 *
4 * @param {Object} context The block context.
5 * @param {Object} attributes The block attributes.
6 * @return {Object} The attributes.
7 */
8 export default function applyContext( context, attributes ) {
9 if ( attributes.dynamicSource === 'current-post' ) {
10 if ( attributes.isCaption ) {
11 // Set the static post ID for the dynamic headline.
12 context.postId = !! context[ 'generateblocks/dynamicImage' ]
13 ? context[ 'generateblocks/dynamicImage' ]
14 : context[ 'generateblocks/mediaId' ];
15
16 context.postType = 'attachment';
17 }
18
19 return Object.assign( {}, attributes, context );
20 }
21
22 return attributes;
23 }
24