Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 65051

<script> tag removed from Custom HTML block

$
0
0

Replies: 0

On a WordPress Page, I can’t get to output a <script> tag to the resulting HTML. It is stripped.

I used WordPress 5.1.1 and upgraded to 5.2, with the new editor.
I have a multisite install.

On a new Page I created three blocks :

<!-- wp:paragraph -->
<p>before</p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<script>document.write('<div>hello world</div>');</script>
<!-- /wp:html -->

<!-- wp:paragraph -->
<p>after</p>
<!-- /wp:paragraph -->

But when I publish, this is always what gets outputted :

	<div class="entry-content">
		
<p>before</p>

document.write(&lsquo;<div>hello world</div>&lsquo;);

<p>after</p>
			</div><!-- .entry-content -->

When I open the Page afterwards to edit it, the <script> tags have been stripped in the page content itself.

The documentation for the Custom HTML block says that it should be used to “include custom <script> tags” (https://gogutenberg.com/blocks/custom-html/).

Things I have tried, which failed :
– Upgrading to 5.2
– Deactivating all plug-ins
– Installing and using the Classic Editor plug-in to type the Page content
– Adding this to functions.php : https://www.denisbouquet.com/stop-wordpress-removing-tags-without-plugins/

Thanks in advance for your help.


Viewing all articles
Browse latest Browse all 65051

Trending Articles