liveblog icon indicating copy to clipboard operation
liveblog copied to clipboard

Shortcodes are rendered with wpautop

Open jonathanstegall opened this issue 7 years ago • 2 comments

I'm running the master branch of this plugin, and when I use a shortcode in a live post, the HTML inside the entry is full of unintended p and br tags.

[newsletter_embed] is a shortcode my theme has which echoes a form.

Here's how it renders in a standard post:

<div class="m-form m-form-in-body m-form-newsletter-shortcode m-form-newsletter-shortcode-email">
	<form action="/wp-admin/admin-post.php" method="post" class="m-form-newsletter">
		<input type="hidden" name="action" value="newsletter_shortcode">
		<input type="hidden" name="newsletter_form_nonce" value="">
		<input type="hidden" name="redirect_url" value="">
		<input type="hidden" name="first_name" value="">
		<input type="hidden" name="last_name" value="">
		<input type="hidden" name="confirm_message" value="">
		<fieldset>
			<div class="m-field-group m-form-item m-form-item-email">
				<label>Email Address: 
					<input name="user_email" value="" type="email" required="">
				</label>
				<button type="submit" name="subscribe" class="a-button a-button-next a-button-choose">Subscribe</button>
			</div>
		</fieldset>
	</form>
</div>

Here's how it renders in a live entry:

<div class="m-form m-form-in-body m-form-newsletter-shortcode m-form-newsletter-shortcode-email">
	<form action="/wp-admin/admin-post.php" method="post" class="m-form-newsletter">
		<input type="hidden" name="action" value="newsletter_shortcode"><br>
		<input type="hidden" name="newsletter_form_nonce" value=""><br>
		<input type="hidden" name="redirect_url" value=""><br>
		<input type="hidden" name="first_name" value=""><br>
		<input type="hidden" name="last_name" value=""><br>
		<input type="hidden" name="confirm_message" value=""><p></p>
		<fieldset>
			<div class="m-field-group m-form-item m-form-item-email">
				<label>Email Address:<br>
					<input name="user_email" value="" type="email" required=""><br>
				</label><br>
				<button type="submit" name="subscribe" class="a-button a-button-next a-button-choose">Subscribe</button>
			</div>
		</fieldset>
	</form>
</div>

jonathanstegall avatar Oct 31 '18 18:10 jonathanstegall

+1 this is a fairly frustrating issue that has forced us to recode our shortcodes. There should be a way to ensure shortcode content is left out of wpautop as it normally is

maxhartshorn avatar May 23 '19 13:05 maxhartshorn

+1 to this. This issue needs taking care of.

hrkhal avatar Nov 29 '19 09:11 hrkhal