Last active
January 25, 2022 04:23
-
-
Save vovafeldman/8bc0a9160728d53de627f8308b3bae10 to your computer and use it in GitHub Desktop.
Freemius - WP Markdown Editor, Exporting
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 | |
/** | |
* When exporting using WP default export tool, use the | |
* markdown version when exist. | |
* | |
* @author Vova Feldman | |
* | |
* @param string $content | |
* | |
* @return string | |
*/ | |
function freemius_export_markdown_content( $content ) { | |
if ( ! class_exists( 'WPCom_Markdown' ) ) { | |
// WP Markdown isn't installed. | |
return $content; | |
} | |
$post = get_post(); | |
if ( ! post_type_supports( $post->post_type, WPCom_Markdown::POST_TYPE_SUPPORT ) ) { | |
// Post type doesn't support markdown. | |
return $content; | |
} | |
return ! empty( $post->post_content_filtered ) ? | |
$post->post_content_filtered : | |
$content; | |
} | |
add_filter( 'the_content_export', 'freemius_export_markdown_content' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment