WordPress.org

Make WordPress Core

Opened 11 years ago

Closed 9 years ago

Last modified 9 years ago

#13288 closed defect (bug) (wontfix)

Shortcodes getting wrapped with a "p" tag by rich editor

Reported by: aizatto Owned by: azaozz
Milestone: Priority: normal
Severity: normal Version:
Component: Shortcodes Keywords:
Focuses: Cc:

Description

This bug appeared when trying to hunt down a bug with the TinyMCE Advanced ( http://wordpress.org/extend/plugins/tinymce-advanced/ ) plugin where extra spaces were being added ( http://wordpress.org/support/topic/350867 ), and was related to the WordPress code.

It appears that shortcodes are wrapped with a "p" tag, before being sent to the rich editor.

This patch removes the "p" tag, by calling shortcode_unautop.

Attachments (1)

wp_richhtml_pre_shortcode_unautop.diff (446 bytes) - added by aizatto 11 years ago.
Adds a call to shortcode_unautop in wp_richedit_pre

Download all attachments as: .zip

Change History (8)

@aizatto
11 years ago

Adds a call to shortcode_unautop in wp_richedit_pre

#1 @nacin
11 years ago

  • Component changed from General to Shortcodes
  • Owner set to azaozz
  • Status changed from new to assigned

#2 @scribu
11 years ago

  • Keywords has-patch added

#3 @nacin
11 years ago

  • Milestone changed from Awaiting Review to 3.1

#4 @nacin
11 years ago

  • Milestone changed from 3.1 to Future Release

#5 follow-up: @azaozz
9 years ago

  • Keywords has-patch removed
  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from assigned to closed

Even if we remove the <p> around a shortcode, TinyMCE will wrap it in another <p> as it forces base blocks on cleanup. Seems the proper thing to do is to always run the content through shortcode_unautop() on display even if wpautop is not used.

#6 in reply to: ↑ 5 @nacin
9 years ago

Replying to azaozz:

Even if we remove the <p> around a shortcode, TinyMCE will wrap it in another <p> as it forces base blocks on cleanup. Seems the proper thing to do is to always run the content through shortcode_unautop() on display even if wpautop is not used.

There is really no way to prevent TinyMCE from munging this?

#7 @azaozz
9 years ago

For TinyMCE a shortcode is just a text string like any other text entered by the user. It's actually better to have it wrapped in a <p> as it's displayed correctly, either as a separate block or inline with other text.

If a TinyMCE plugin wants to do something with that shortcode in the editor, like image captions or [gallery], it can replace the whole DOM node or insert content in it.

When saving all <p> are replaced with two line breaks. The saved content is exactly like in the HTML (Text) editor, so there is no need for separate shortcode processing.

The only time this is a problem is when wpautop() is not used. Then the <p> aren't replaced on save (the content is saved in the db with all html tags intact). But this is strictly a plugin material for now. These plugins can either run shortcode_unautop() on saving the content or leave it running on display (the default).

A way to make this easier would be to pass whether wpautop was used to PHP on saving. This can include a flag whether the content was taken from TinyMCE or directly from the textarea.

Note: See TracTickets for help on using tickets.