Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#47816 new defect (bug)

Shortcodes being run in editor when gutenberg is active

Reported by: karlazz Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Editor Keywords:
Focuses: Cc:



We have a shortcode that makes an API call to a remote site. We noticed that it was making calls when we were editing pages on our website, even if the shortcode was not loaded on that page. This does not happen when gutenberg is disabled.

I made up a test shortcode that appends to a file in the uploads directory.
I added it to a test page. It ran when I opened the editor view of the page. It ran when I saved the page. It ran when I viewed the page, which is the only time it should run. I can see when it runs because it writes to my file.

Even more surprising is that the shortcode ran when I edited a different page, a page without the shortcode. We have good reason to believe that the pages API is running the shortcode when it runs to create the parent page drop down selector.

Why do we believe that is the issue? Because in the first incident, the one where we were sending out unexpected API calls to a remote system, the shortcode was just echoing text without doing a proper return. The echoed text interrupted the Parent page drop down selector build and so that drop down did not appear. We saw the shortcode's misplaced response text in our browser console as part of the page API response. Once we properly wrapped the echo statement, that issue went away, but the API calls were still occurring, and so I did the simple test for you.

In summary, the shortcode is run when I edit any page. We believe that the page API call that is used to create the parent page dropdown is running the shortcode.

Is this on purpose behaviour?


Change History (1)

#1 @audrasjb
2 years ago

  • Component changed from General to Editor
  • Version 5.2.2 deleted

Hi @karlazz, thanks for the ticket and welcome to WordPress Trac,

Could you please provide some code example to help us to reproduce the behavior you described?


Note: See TracTickets for help on using tickets.