Medium / medium-wordpress-plugin

The official WordPress plugin for cross-posting to Medium.
https://medium.com
Apache License 2.0
210 stars 40 forks source link

Short codes being displayed in Medium article? #38

Closed hughforsyth closed 8 years ago

hughforsyth commented 8 years ago

Hi,

I've been trying the plugin and have noticed that it seems to post short code text to Medium as I see [caption....] in the Medium article.

I'm no WordPress Codex expert but I am guessing that this part of /lib/medium-admin.php is outputting the content without rendering the short codes:

private static function _prepare_content($post) {
    // Add paragraph tags.
    $post_content = wpautop($post->post_content);

It seems like a similar issue to this issue described on stack overflow: http://stackoverflow.com/questions/22270147/wordpress-shortcode-doesnt-work-when-getting-post-content-using-function-get-p

and suggests doing do_shortcode(get_post_field('post_content', $postid));

https://developer.wordpress.org/reference/functions/do_shortcode/

or maybe this echo apply_filters( 'the_content', get_post_field('post_content', $postid) );

There's also a few suggestions in this:

http://codex.wordpress.org/Function_Reference/the_content

<?php
$content = apply_filters( 'the_content', get_the_content() );
$content = str_replace( ']]>', ']]&gt;', $content );
?>

https://wordpress.org/support/topic/post_content-with-formatting?replies=7

The easiest way to reproduce this is with a post with some embedded images with captions.

Thanks

huckphin commented 8 years ago

@hughforsyth: Thank you for reporting. Version 1.2 was released which includes a fix for this. Changelog