Skip Navigation

[Resolved] Post form disable shortcode

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 3 replies, has 2 voices.

Last updated by marcoG-5 7 months, 1 week ago.

Assisted by: Nigel.

Author
Posts
#2691730

I am trying to disable execution of shortcodes when submitting the form. Shortcodes are being executed when I submit either post creation or post modification form. I need this be disabed so that I can put shortcodes into the content as plain text.

I tried removing the `do_shortcode` from `the_content` filter but it didn't work. It seems the form is executing the shortcode before it save.

Tried containing the shortcode with `<pre>` and `[php]` but it still executes the shortcode. Using `[[]]` is not an option this time as it really not solving the issue I am dealing with.

Do you have filter that I can use to disable execution of shortcodes on save?

#2691747

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

There is no such filter available, I'm afraid, not documented at least, I don't think this is an anticipated use case.

I can take a look at the source code when I have some free time later to see if I can spot a possible solution, but that might take me a while.

In the meantime the only thing I can suggest is that you try using HTML entities in place of the square brackets, so they will still look like square brackets when rendered, e.g.

&lsqb;shortcode]
#2692055

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Actually, now that I test this, I don't find that a shortcode added to the content of a post being created with a form is parsed.

I registered a very simple shortcode for testing:

add_shortcode( 'test-shortcode', function(){

  	error_log("shortcode being parsed...");
  
	return "shortcode parsed";
});

Then I went to a page with a form that creates a post, and in the content section I added that shortcode.

I submitted the form, all the while monitoring the debug.log for any message to indicate the shortcode had been parsed.

There was no such message.

I *do* get a message indicating the shortcode has been parsed if my form is set to display the published post after the form has been submitted. Obviously, showing the post will render the shortcode.

So I can't actually reproduce what you are describing.

#2692908

Nigel,

Thank you for trying. I used a custom field instead. This somehow not run the shortcodes inside the custom field when displaying it using `get_post_meta`.