Title: Shortcode Empty Paragraph Fix
Author: Johann Heyne
Published: <strong>2011 年 7 月 10 日</strong>
Last modified: 2016 年 1 月 22 日

---

搜索插件

**该插件尚未通过WordPress的最新3个主要版本进行测试**。 当与较新版本的WordPress一起
使用时，可能不再受到维护或支持，并且可能会存在兼容性问题。

![](https://s.w.org/plugins/geopattern-icon/shortcode-empty-paragraph-fix.svg)

# Shortcode Empty Paragraph Fix

 作者：[Johann Heyne](https://profiles.wordpress.org/jonua/)

[下载](https://downloads.wordpress.org/plugin/shortcode-empty-paragraph-fix.zip)

 * [详情](https://cn.wordpress.org/plugins/shortcode-empty-paragraph-fix/#description)
 * [评价](https://cn.wordpress.org/plugins/shortcode-empty-paragraph-fix/#reviews)
 *  [安装](https://cn.wordpress.org/plugins/shortcode-empty-paragraph-fix/#installation)
 * [开发进展](https://cn.wordpress.org/plugins/shortcode-empty-paragraph-fix/#developers)

 [支持](https://wordpress.org/support/plugin/shortcode-empty-paragraph-fix/)

## 描述

Fix [known issues](https://core.trac.wordpress.org/ticket/12061) when shortcodes
are embedded in a block of content that is filtered by wpautop.

#### for Theme Developers

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.

    ```
    function shortcode_empty_paragraph_fix( $content ) {

        // define your shortcodes to filter, '' filters all shortcodes
        $shortcodes = array( 'your_shortcode_1', 'your_shortcode_2' );

        foreach ( $shortcodes as $shortcode ) {

            $array = array (
                '<p>[' . $shortcode => '[' .$shortcode,
                '<p>[/' . $shortcode => '[/' .$shortcode,
                $shortcode . ']</p>' => $shortcode . ']',
                $shortcode . ']<br />' => $shortcode . ']'
            );

            $content = strtr( $content, $array );
        }

        return $content;
    }

    add_filter( 'the_content', 'shortcode_empty_paragraph_fix' );
    ```

Another solution that is acceptet at the envato (themeforest) marketplace comes 
from [bitfade](https://gist.github.com/bitfade/4555047).

## 安装

 1. Upload folder `shortcode-empty-paragraph-fix` to the `/wp-content/plugins/` directory
 2. 通过WordPress的的“Plugins”菜单激活插件

或者

If you dont want to use a whole plugin to solve that bug, you can copy the code 
of the plugin file shortcode-empty-paragraph-fix.php into your theme function.php

## 常见问题

  Installation Instructions

 1. Upload folder `shortcode-empty-paragraph-fix` to the `/wp-content/plugins/` directory
 2. 通过WordPress的的“Plugins”菜单激活插件

或者

If you dont want to use a whole plugin to solve that bug, you can copy the code 
of the plugin file shortcode-empty-paragraph-fix.php into your theme function.php

## 评价

![](https://secure.gravatar.com/avatar/0fdcb3c1f606e84db3d801ef61e200a3a38bc6da0d78fbb8393f9a1957610280?
s=60&d=retro&r=g)

### 󠀁[Just what I needed.](https://wordpress.org/support/topic/just-what-i-needed-646/)󠁿

 [](https://profiles.wordpress.org/truetone/) 2017 年 10 月 5 日

Thanks for this fix. Worked great for me!

![](https://secure.gravatar.com/avatar/d952305e451542b406e068990c629ea7eafcbde0641f4c2a438501f1ba5b79bc?
s=60&d=retro&r=g)

### 󠀁[Thanks! It solves my issue](https://wordpress.org/support/topic/thanks-it-solves-my-issue/)󠁿

 [Elisabeth Pointal](https://profiles.wordpress.org/epointal/) 2017 年 7 月 14 日

This simply plugin resolve the issue in mine. I added the function and filter to
my own plugin if it did not already exist.

![](https://secure.gravatar.com/avatar/8df1cc227b62b6dfb9bf9a3785b19ed671d50c4ff028f36e70df22302787777b?
s=60&d=retro&r=g)

### 󠀁[It’s work](https://wordpress.org/support/topic/its-work-11/)󠁿

 [studio-jt](https://profiles.wordpress.org/studiojt/) 2017 年 2 月 2 日

The standalone function work great , thank you

 [ 阅读所有21条评价 ](https://wordpress.org/support/plugin/shortcode-empty-paragraph-fix/reviews/)

## 贡献者及开发者

「Shortcode Empty Paragraph Fix」是开源软件。 以下人员对此插件做出了贡献。

贡献者

 *   [ Johann Heyne ](https://profiles.wordpress.org/jonua/)

[帮助将「Shortcode Empty Paragraph Fix」翻译成简体中文。](https://translate.wordpress.org/projects/wp-plugins/shortcode-empty-paragraph-fix)

### 对开发感兴趣吗?

您可以[浏览代码](https://plugins.trac.wordpress.org/browser/shortcode-empty-paragraph-fix/)，
查看[SVN仓库](https://plugins.svn.wordpress.org/shortcode-empty-paragraph-fix/)，
或通过[RSS](https://plugins.trac.wordpress.org/log/shortcode-empty-paragraph-fix/?limit=100&mode=stop_on_copy&format=rss)
订阅[开发日志](https://plugins.trac.wordpress.org/log/shortcode-empty-paragraph-fix/)。

## 更新日志

#### 0.1

 * Initial Release

#### 0.2

 * nicer code writing style

## 额外信息

 *  版本 **0.2**
 *  最后更新：**10 年前**
 *  活跃安装数量 **900+**
 *  WordPress 版本 ** 2.5 或更高版本 **
 *  已测试的最高版本为 **4.8.28**
 *  语言
 * [English (US)](https://wordpress.org/plugins/shortcode-empty-paragraph-fix/)
 * 标签
 * [fix](https://cn.wordpress.org/plugins/tags/fix/)[shortcode](https://cn.wordpress.org/plugins/tags/shortcode/)
 *  [高级视图](https://cn.wordpress.org/plugins/shortcode-empty-paragraph-fix/advanced/)

## 评级

 4.8 星（最高 5 星）。

 *  [  19 条 5 星评价     ](https://wordpress.org/support/plugin/shortcode-empty-paragraph-fix/reviews/?filter=5)
 *  [  0 条 4 星评价     ](https://wordpress.org/support/plugin/shortcode-empty-paragraph-fix/reviews/?filter=4)
 *  [  0 条 3 星评价     ](https://wordpress.org/support/plugin/shortcode-empty-paragraph-fix/reviews/?filter=3)
 *  [  0 条 2 星评价     ](https://wordpress.org/support/plugin/shortcode-empty-paragraph-fix/reviews/?filter=2)
 *  [  1 条 1 星评价     ](https://wordpress.org/support/plugin/shortcode-empty-paragraph-fix/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/shortcode-empty-paragraph-fix/reviews/#new-post)

[查看全部评论](https://wordpress.org/support/plugin/shortcode-empty-paragraph-fix/reviews/)

## 贡献者

 *   [ Johann Heyne ](https://profiles.wordpress.org/jonua/)

## 支持

有话要说吗？是否需要帮助？

 [查看支持论坛](https://wordpress.org/support/plugin/shortcode-empty-paragraph-fix/)