Skip to content

Instantly share code, notes, and snippets.

@vovafeldman
Last active January 25, 2022 04:23
Show Gist options
  • Save vovafeldman/8bc0a9160728d53de627f8308b3bae10 to your computer and use it in GitHub Desktop.
Save vovafeldman/8bc0a9160728d53de627f8308b3bae10 to your computer and use it in GitHub Desktop.
Freemius - WP Markdown Editor, Exporting
<?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