Remove post_markdown2html
-
I just want the markdown output. How should I disable the post_markdown2html
-
@karkidennis I guess you can’t. At the moment of writing you can access “staticly” the PHP instance’s properties & methods through the global “mmd” function but not the instance itself so you won’t be able to remove the filter. Time for a new feature ? 🙂
Anyway I setup the filter to “the_content” function so if you want the raw source code, you can still use “get_the_content”.
For example if your theme’s template instead of writing :the_content();If you write :
echo get_the_content();The markdown version should popup 😉 Tell me if that helps
Actually, I want the raw content in API Like this https://prnt.sc/craHr8qCrUbx I have this after I commented the filter https://prnt.sc/9uiSQBfVbl-a
Any Suggestions for doing this without modifying the Plugin?
Or as you mentionedget_the_content()will output the raw then I can add the custom field in API.-
This reply was modified 3 years, 2 months ago by
Dennish Karki.
@karkidennis yeah I have to add a new setting / constant so developer can freely switch off the filter regards to their needs.
I’m busy right now but will definitively take a look this week-end.
If you only target the API, you should be able to use the appropriate filters without modifying the plugin. For exemple :function raw_markdown_code( $data, $post, $request ) { # Replace the html formated content via original markdown saved in database $data->data[ 'content' ] = $post->post_content; return $data; } add_filter( 'rest_prepare_post', 'raw_markdown_code', 10, 3 );You still need to modify the snippet for your needs 😉
@peter202202 Thanks man. It is what I need.
@karkidennis Glad it’s working mate 🙂
I’ve just released v1.8.1 with the WP_MMD_RAW_DATA constant so you can disable the filter through a specific “loading”* hook of your choice.
- For example you can add the following snippet inside you wp-config.php to disable globally the html output :
define( 'WP_MMD_RAW_DATA', 1 ); - Or inside a hook from your child’s theme functions.php file :
add_action('init', function() { if ( ... ) { define( 'WP_MMD_RAW_DATA', 1 ); } });
The side effect with the REST API is that the related hooks or constants like REST_REQUEST created by WordPress are setup at the beginning of the “processing”* stage, just after the “loading”* stage has finished, which is too late.
To make it short it will remain a specific case with the current plugin’s structure and to avoid “delicate” modifications or unwanted side effects, the best way to target the REST API – with other plugins as well to my mind – is still the use of the snippet provided last week or a variant like the following one :
add_action( 'rest_api_init', function() { remove_all_filters( 'the_content' ); remove_all_filters( 'the_excerpt' ); });*By loading and processing I’m referring to this chart :
https://blog.lancecleveland.com/2017/10/11/wordpress-hooks-and-filters-order-of-precedence/I hope the explanations / reference is gonna inspire you, and if you don’t mind I’m gonna mark the issue as resolved 👍
-
This reply was modified 3 years, 2 months ago by
The topic ‘Remove post_markdown2html’ is closed to new replies.