File "applyContext.js"

Full path: /home/webcknlt/admissiontell.com/wp-content/plugins/generateblocks/src/extend/dynamic-content/utils/applyContext.js
File size: 666 B (666 B bytes)
MIME-type: text/plain
Charset: utf-8

Download   Open   Edit   Advanced Editor &nnbsp; Back

/**
 * Applies the context to the attributes.
 *
 * @param {Object} context    The block context.
 * @param {Object} attributes The block attributes.
 * @return {Object} The attributes.
 */
export default function applyContext( context, attributes ) {
	if ( attributes.dynamicSource === 'current-post' ) {
		if ( attributes.isCaption ) {
			// Set the static post ID for the dynamic headline.
			context.postId = !! context[ 'generateblocks/dynamicImage' ]
				? context[ 'generateblocks/dynamicImage' ]
				: context[ 'generateblocks/mediaId' ];

			context.postType = 'attachment';
		}

		return Object.assign( {}, attributes, context );
	}

	return attributes;
}