Skip to content

Handling shortcodes distribution in post content #404

Open
@avag-novembit

Description

@avag-novembit

Is your enhancement related to a problem? Please describe.
Currently, if shortcodes in distributed post content has website specific attributes (e.g. attachment id, or gravity form id), it distributed without any additional actions, exactly as it was in original post. In this case, the attachment id in the hub website (from where the post is distributed) may not be the same as in website where distributed the post.

Describe the solution you'd like
In order to handle shortcodes distribution added functionality to provide a 'hook' for each shortcode in received post content to make possible to apply all necessary changes in shortcodes.

Designs
In the file distributor/includes/post-specific-content-handler.php function save_post_specific_content(..) (see #372):

// Handle shortcode distribution
// We need just to get all shortcodes in post content regardless their type or hierarchy
$pattern = "/\[(\[?)([^\]]+)(\]?)\]/";

$content = preg_replace_callback(
	$pattern,
	function ( $matches ) {
		$shortcode = $matches[0];

		/**
		 * Filters the the shortcode tags in the post content
		 *
		 * @param string $shortcode Whole shortcode tag including wrapped content, if there is any
		 * @param array  $matches the array of matches
		 */
		$shortcode = apply_filters( 'dt_post_content_shortcode_tags', $shortcode, $matches );

		return $shortcode;
	},
	$content
);

Going to send a PR with the mentioned functionality applied.

Thanks.

Avag

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

  • Status

    In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions