Files
branddefense.pl/wp-content/plugins/brizy/content/shortcode-to-placeholder-processor.php
Roman Pyrih c2e100a763 first commit
2023-07-24 08:30:51 +02:00

26 lines
795 B
PHP

<?php
class Brizy_Content_ShortcodeToPlaceholderProcessor implements Brizy_Editor_Content_ProcessorInterface {
/**
* @param string $content
* @param Brizy_Content_Context $context
*
* @return mixed|string
*/
public function process( $content, Brizy_Content_Context $context ) {
// Transform [brizy_shortcode_name attr="val"] to {{editor_shortcode_name attr='val'}}
$regex = '@(\[)(brizy_)(.*?)(\])@';
$content = preg_replace_callback( $regex, function ( $matches ) {
$shortcode = $matches[0];
$shortcode = str_replace( [ '[brizy', ']' ], [ '{{editor', '}}' ], $shortcode );
$shortcode = str_replace( '"', "'", $shortcode );
return $shortcode;
}, $content );
return $content;
}
}