[wp-trac] [WordPress Trac] #47816: Shortcodes being run in editor when gutenberg is active
WordPress Trac
noreply at wordpress.org
Sat Nov 12 09:25:04 UTC 2022
#47816: Shortcodes being run in editor when gutenberg is active
--------------------------+------------------------------
Reporter: karlazz | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Editor | Version: 6.1
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Changes (by vijayhardaha):
* version: => 6.1
Comment:
Hey, I have a similar issue, I was working on a custom shortcode for
WooCommerce products then I found this issue.
Steps to reproduce the issue.
1. Fresh install the WordPress
2. Create a static homepage
3. Install the WooCommerce plugin & import dummy data (it's not the
woocommerce shortcode issue, for issue testing we use WooCommerce)
4. Install Query Monitor for tracking
5. Edit the homepage and on the block, the editor adds a shortcode block
and put `[products limit=10"]`
6. Save/Update the page
7. Reload the page and open the query monitor panel
8. Click the `Queries` tab, select `woocommerce` in the component
dropdown, and select `WP_Term_Query->get_terms()` in the Caller dropdown
9. Look for the `SELECT DISTINCT t.term_id, tr.object_id` query and expend
Caller information, you'll find `WC_Shortcodes::products()` there
Shortcode code is executing on the backend page which should not happen,
If you'll install the classic editor plugin then in the classic editor
you'll not see shortcode code execution on the backend.
This current behavior slows down the backend page. for example with a
website with 10000 products if someone adds a shortcode `[products]` by
mistake without specifying the limit atts, then the backend will execute
the query and the page will either break or load after 1-2 minutes.
Another issue that I had with my custom shortcode was, I was not
initializing `add_shortcode` with the `init` action and was using the
`set_postdata` function, so when I was editing the post, the first
rendered product was set on the edit page due to this backend shortcode
execution.
However, that was my mistake, so I initiated the `add_shortcode` with the
`init` action, but I think, shortcode execution in the backend with the
block editor is an issue and should be fixed.
Thanks
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47816#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list