wufoo_shortcode

Plugin Name: Wufoo Shortcode Plugin Description: Enables shortcode to embed Wufoo forms.

Description

wufoo_shortcode( $atts ); 

Usage: [wufoo username="chriscoyier" formhash="x7w3w3" autoresize="true" height="458" header="show" ssl="true"] Author: Chris Coyier / Wufoo, evansolomon

Based on http://wordpress.org/extend/plugins/wufoo-shortcode/ http://wufoo.com/docs/code-manager/wordpress-shortcode-plugin/

Parameters (1)

0. $atts
The atts.

Usage

  1. if ( !function_exists( 'wufoo_shortcode' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/modules/shortcodes/wufoo.php'; 
  3.  
  4. // The atts. 
  5. $atts = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wufoo_shortcode($atts); 
  9.  

Defined (1)

The function is defined in the following location(s).

/modules/shortcodes/wufoo.php  
  1. function wufoo_shortcode( $atts ) { 
  2. extract( shortcode_atts( array( 
  3. 'username' => '',  
  4. 'formhash' => '',  
  5. 'autoresize' => true,  
  6. 'height' => '500',  
  7. 'header' => 'show',  
  8. 'ssl' => '' 
  9. ), $atts ) ); 
  10.  
  11. //Check username and formhash to ensure they only have alphanumeric characters or underscores, and aren't empty 
  12. if ( !preg_match( "/^[a-zA-Z0-9_]+$/", $username) || !preg_match( "/^[a-zA-Z0-9_]+$/", $formhash ) ) { 
  13.  
  14. /** 
  15. * Return anerrorto the users with instructions if one of these params is invalid 
  16. * They don't have default values because they are user/form-specific 
  17. */ 
  18. $return_error = sprintf( __( 'Something is wrong with your Wufoo shortcode. If you copy and paste it from the %sWufoo Code Manager%s, you should be golden.', jetpack ), "<a href='http://wufoo.com/docs/code-manager/'>", "</a>" ); 
  19.  
  20. return " 
  21. <div style='border: 20px solid red; border-radius: 40px; padding: 40px; margin: 50px 0 70px;'> 
  22. <h3>Uh oh!</h3> 
  23. <p style='margin: 0;'>$return_error</p> 
  24. </div>"; 
  25.  
  26. /** 
  27. * Required parameters are present 
  28. * Anerrorwill be returned inside the form if they are invalid 
  29. */ 
  30.  
  31. $js_embed = '<script type="text/javascript">var host = (("https:" == document.location.protocol) ? "https://secure." : "http://");document.write(unescape("%3Cscript src=\'" + host + "wufoo.com/scripts/embed/form.js\' type=\'text/javascript\'%3E%3C/script%3E"));</script>'; 
  32. $js_embed .= "<script type='text/javascript'>"; 
  33. $js_embed .= "var wufoo_$formhash = new WufooForm();"; 
  34. $js_embed .= "wufoo_$formhash.initialize({"; 
  35. $js_embed .= "'userName':'$username', "; 
  36. $js_embed .= "'formHash':'$formhash', "; 
  37. $js_embed .= "'autoResize':".(bool)( $autoresize ).", "; 
  38. $js_embed .= "'height':'". (int) $height ."', "; 
  39. $js_embed .= "'header':'".esc_attr( $header )."' "; 
  40.  
  41. /** 
  42. * Only output SSL value if passes as param 
  43. * Lower tier plans don't show this param (don't offer SSL) 
  44. */ 
  45. $js_embed .= ( $ssl ) ? ", 'ssl':".(bool) $ssl : ""; 
  46. $js_embed .= "});"; 
  47. $js_embed .= "wufoo_$formhash.display();"; 
  48. $js_embed .= "</script>"; 
  49.  
  50. /** 
  51. * iframe embed, loaded inside <noscript> tags 
  52. */ 
  53. $iframe_embed = '<iframe '; 
  54. $iframe_embed .= 'height="'. (int) $height .'" '; 
  55. $iframe_embed .= 'allowTransparency="true" frameborder="0" scrolling="no" style="width:100%;border:none;"'; 
  56. $iframe_embed .= 'src="https://'. $username .'.wufoo.com/embed/'. $formhash .'/">'; 
  57. $iframe_embed .= '<a href="https://'. $username .'.wufoo.com/forms/'. $formhash .'/" '; 
  58. $iframe_embed .= 'rel="nofollow">Fill out my Wufoo form!</a></iframe>'; 
  59.  
  60. /** This action is already documented in modules/widgets/gravatar-profile.php */ 
  61. do_action( 'jetpack_stats_extra', 'embeds', 'wufoo' ); 
  62.  
  63. /** 
  64. * Return embed in JS and iframe 
  65. */ 
  66. return "$js_embed <noscript> $iframe_embed </noscript>";