Shortcodes Generator

Overview

Use this tool to create custom code for Shortcodes with add_shortcode() function.

Usage

  • Fill in the user-friendly form.
  • Click the “Update Code” button.
  • Copy the code to your project.
  • Or save it as a snippet and share with the community.
Shortcode tag in the content.
e.g. [tag]
The function used in the code.
Self-closing shortcode: [tag]
Enclosing shortcode: [tag]content[/tag]
Enable attributes such as
[tag foo="123" bar="456"].
Use "shortcode_atts_{$shortcode}" filter, to allow shortcode attributes filtering.
Set custom filter name.
Attribute name. Lowercase.
Default value.
e.g. [tag attr_name="default_value"]
Attribute name. Lowercase.
Default value.
Attribute name. Lowercase.
Default value.
Custom code to generate the output.
Should only "return" the text, never produce the output directly.
  Save Snippet
// Add Shortcode
function news_sign_form( $atts ) {

	// Attributes
	$atts = shortcode_atts(
		array(
			'class' => 'md-color',
		),
	);

		$url_base = get_site_url().'/';
		$theme_opts = get_option( 'news_sign_tab' );
		$url_host = $theme_opts['news_host'];
		$news_ok = $url_base.$theme_opts['news_ok'];
		$news_er = $url_base.$theme_opts['news_er'];
		$news_act = $url_base.$theme_opts['news_act'];
	
	
	$news_form = '<form class="news-form '.$class.'" enctype="application/x-www-form-urlencoded" action="http://'.$url_host.'/ccm/subscribe/index/form/" method="post">
		
		<input type="hidden" name="confirmationUrl" value="'.$news_act.'" />
		<input type="hidden" name="successUrl" value="'.$news_ok.'" />
		<input type="hidden" name="errorUrl" value="'.$news_er.'" />
		
		<div class="form-group col-sm-4">
			<label class="sr-only" for="name" class="required">Nome</label>
			<input class="form-control input-lg" tabindex="1" type="text" autocomplete="off" name="name" id="name" placeholder="'.__('Your Name', 'odin').'" required />
		</div>
		<div class="form-group col-sm-5">
			<label class="sr-only" for="email" class="required">Email</label>
			<input class="form-control input-lg" tabindex="2" type="email" autocomplete="off" name="email" id="email" placeholder="'.__('Your Email', 'odin').'"  required />
		</div>
		<div class="form-group col-sm-3">
			<input type="hidden" name="groups[]" value="1" />
			<button class="btn btn-default btn-lg btn-block" tabindex="3" type="submit" name="submit" id="submit">Cadastre-se <span></span></button>
		</div>
	</form>';
	return $news_form;

}
add_shortcode( 'news_sign', 'news_sign_form' );