• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Jetpack a2z

Jetpack a2z

Jetpack a2z

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / wufoo_shortcode() – Display the Wufoo shortcode.

You appear to be a bot. Output may be restricted

Description

Display the Wufoo shortcode.

Usage

wufoo_shortcode( $atts );

Parameters

$atts
( array ) required – Shortcode attributes.

Returns

void

Source

File name: jetpack/modules/shortcodes/wufoo.php


Lines:

1 to 100 of 109
function wufoo_shortcode( $atts ) {
  $attr = shortcode_atts(
    array(
      'username'   => '',
      'formhash'   => '',
      'autoresize' => true,
      'height'     => '500',
      'header'     => 'show',
    ),
    $atts
  );

  // Check username and formhash to ensure they only have alphanumeric characters or underscores, and aren't empty.
  if (
    ! preg_match( '/^[a-zA-Z0-9_]+$/', $attr['username'] )
    || ! preg_match( '/^[a-zA-Z0-9_]+$/', $attr['formhash'] )
  ) {
    /*
		 * Return an error to the users with instructions if one of these params is invalid
		 * They don't have default values because they are user/form-specific
		 */
    if ( current_user_can( 'edit_posts' ) ) {
      return sprintf(
        wp_kses(
          /* translators: URL to Wufoo support page. */
          __( 'Something is wrong with your Wufoo shortcode. Try following the instructions <a href="%s" target="_blank" rel="noopener noreferrer">here</a> to embed a form on your site.', 'jetpack' ),
          array(
            'a' => array(
              'href'   => array(),
              'target' => array(),
              'rel'    => array(),
            ),
          )
        ),
        'https://help.wufoo.com/articles/en_US/kb/Embed'
      );
    }
  }

  
/**
 * Placeholder which will tell Wufoo where to render the form.
 */
  $js_embed_placeholder = sprintf(
    '<div id="wufoo-%s"></div>',
    esc_attr( $attr['formhash'] )
  );

  
/**
 * Required parameters are present.
 * An error will be returned inside the form if they are invalid.
 */
  $js_embed = sprintf(
    '(function(){try{var wufoo_%1$s = new WufooForm();wufoo_%1$s.initialize({"userName":"%2$s","formHash":"%1$s","autoResize":"%3$s","height":"%4$d","header":"%5$s","ssl":true,"async":true});wufoo_%1$s.display();}catch(e){}})();',
    esc_attr( $attr['formhash'] ),
    esc_attr( $attr['username'] ),
    esc_attr( $attr['autoresize'] ),
    absint( $attr['height'] ),
    esc_js( $attr['header'] )
  );

  // Embed URL.
  $embed_url = sprintf(
    'https://%1$s.wufoo.com/embed/%2$s/',
    $attr['username'],
    $attr['formhash']
  );

  // Form URL.
  $form_url = sprintf(
    'https://%1$s.wufoo.com/forms/%2$s/',
    $attr['username'],
    $attr['formhash']
  );

  /*
	 * iframe embed, loaded inside <noscript> tags.
	 */
  $iframe_embed = sprintf(
    '<iframe height="%1$d" src="%2$s" allowTransparency="true" frameborder="0" scrolling="no" style="width:100%;border:none;">
			<a href="%3$s" target="_blank" rel="noopener noreferrer">%4$s</a>
		</iframe>',
    absint( $attr['height'] ),
    esc_url( $embed_url ),
    esc_url( $form_url ),
    esc_html__( 'Fill out my Wufoo form!', 'jetpack' )
  );

  wp_enqueue_script(
    'wufoo-form',
    'https://www.wufoo.com/scripts/embed/form.js',
    array(),
    JETPACK__VERSION,
    true
  );
  wp_add_inline_script( 'wufoo-form', $js_embed );

  
/** This action is already documented in modules/widgets/gravatar-profile.php */
[1] [2] Next »

 View on GitHub View on Trac

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Pinterest (Opens in new window)

Related

Published: 27 November 2019 | Last updated: 27 November 2019

Primary Sidebar

Information

Function name: wufoo_shortcode
Plugin ref: Jetpack
Version: 7.9.1
Sourcefile: modules/shortcodes/wufoo.php
File ref: modules/shortcodes/wufoo.php
Deprecated?: No
API Letters: S,W

Footer

Jetpack a2z Jetpack a2z
Jetpack a2z
WordPress 5.3
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  jetpack.wp-a2z.org
© Copyright Jetpack a2z 2014-2019. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites