Created
February 15, 2024 19:19
-
-
Save koen12344/a06d82227b0abb51161327242cd899fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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