{"id":155344,"date":"2011-07-10T08:00:00","date_gmt":"2011-07-10T08:00:00","guid":{"rendered":"https:\/\/www.weixiaoduo.com\/plugins\/2024\/02\/22\/shortcode-empty-paragraph-fix\/"},"modified":"2016-01-23T03:08:00","modified_gmt":"2016-01-23T03:08:00","slug":"shortcode-empty-paragraph-fix","status":"publish","type":"post","link":"https:\/\/www.weixiaoduo.com\/plugins\/shortcode-empty-paragraph-fix\/","title":{"rendered":"Shortcode Empty Paragraph Fix"},"content":{"rendered":"<p>Fix <a href=\"https:\/\/core.trac.wordpress.org\/ticket\/12061\" rel=\"nofollow ugc\">known issues<\/a> when shortcodes are embedded in a block of content that is filtered by wpautop.<\/p>\n<h4>for Theme Developers<\/h4>\n<p>If you are developing a theme to provide this on a marketplace, you better embed the following code in your functions.php. This code filters only the shortcodes you defined. Otherwise you risk a failed review because the code in the plugin filters content in general which may is not acceptet.<\/p>\n<pre><code>function shortcode_empty_paragraph_fix( $content ) {\n\n    \/\/ define your shortcodes to filter, '' filters all shortcodes\n    $shortcodes = array( 'your_shortcode_1', 'your_shortcode_2' );\n\n    foreach ( $shortcodes as $shortcode ) {\n\n        $array = array (\n            '<p>[' . $shortcode => '[' .$shortcode,\n            '<p>[\/' . $shortcode => '[\/' .$shortcode,\n            $shortcode . ']<\/p>' => $shortcode . ']',\n            $shortcode . ']<br \/>' => $shortcode . ']'\n        );\n\n        $content = strtr( $content, $array );\n    }\n\n    return $content;\n}\n\nadd_filter( 'the_content', 'shortcode_empty_paragraph_fix' );\n<\/code><\/pre>\n<p>Another solution that is acceptet at the envato (themeforest) marketplace comes from <a href=\"https:\/\/gist.github.com\/bitfade\/4555047\" title=\"a Gist on Github\" rel=\"nofollow ugc\">bitfade<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Fix known issues when shortcodes are embedded in a block of content that is filtered by wpautop.<\/p>\n","protected":false},"author":65,"featured_media":239817,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"Shortcode Empty Paragraph Fix - \u8587\u6653\u6735\u63d2\u4ef6\u76ee\u5f55","description":"Fix known issues when shortcodes are embedded in a block of content that is filtered by wpautop."},"footnotes":""},"categories":[1],"tags":[2518,345],"class_list":["post-155344","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-fix","tag-shortcode"],"_links":{"self":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/155344","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/comments?post=155344"}],"version-history":[{"count":0,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/155344\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/media\/239817"}],"wp:attachment":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/media?parent=155344"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/categories?post=155344"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/tags?post=155344"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}