Skip to content

Instantly share code, notes, and snippets.

@koen12344
Created February 15, 2024 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koen12344/a06d82227b0abb51161327242cd899fc to your computer and use it in GitHub Desktop.
Save koen12344/a06d82227b0abb51161327242cd899fc to your computer and use it in GitHub Desktop.
<?php
function pgmb_raw_content_variable($variables, $parent_post_id){
$post = get_post($parent_post_id);
$text = wpautop($post->post_content); //Add paragraph tags
//$text = preg_replace("~(?:\[/?)[^\]]+/?\]~s", '', $text); //Strip shortcodes
$text = do_shortcode($text);
$parse_html = new \PGMB\Vendor\Html2Text\Html2Text(
$text,
array(
'width' => 0,
'do_links' => true
)
);
$text = $parse_html->getText();
$text = trim($text);
$variables['%post_content_raw%'] = $text;
return $variables;
}
add_filter('mbp_placeholder_variables', 'pgmb_raw_content_variable', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment