grunion_ajax_shortcode

The Jetpack by WordPress.com grunion ajax shortcode function.

Description

grunion_ajax_shortcode(); 

Usage

  1. if ( !function_exists( 'grunion_ajax_shortcode' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/modules/contact-form/admin.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = grunion_ajax_shortcode(); 
  7.  

Defined (1)

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

/modules/contact-form/admin.php  
  1. function grunion_ajax_shortcode() { 
  2. check_ajax_referer( 'grunion_shortcode' ); 
  3.  
  4. $attributes = array(); 
  5.  
  6. foreach ( array( 'subject', 'to' ) as $attribute ) { 
  7. if ( isset( $_POST[$attribute] ) && strlen( $_POST[$attribute] ) ) { 
  8. $attributes[$attribute] = stripslashes( $_POST[$attribute] ); 
  9.  
  10. if ( is_array( $_POST['fields'] ) ) { 
  11. $fields = stripslashes_deep( $_POST['fields'] ); 
  12. usort( $fields, 'grunion_sort_objects' ); 
  13.  
  14. $field_shortcodes = array(); 
  15.  
  16. foreach ( $fields as $field ) { 
  17. $field_attributes = array(); 
  18.  
  19. if ( isset( $field['required'] ) && 'true' === $field['required'] ) { 
  20. $field_attributes['required'] = 'true'; 
  21.  
  22. foreach ( array( 'options', 'label', 'type' ) as $attribute ) { 
  23. if ( isset( $field[$attribute] ) ) { 
  24. $field_attributes[$attribute] = $field[$attribute]; 
  25.  
  26. $field_shortcodes[] = new Grunion_Contact_Form_Field( $field_attributes ); 
  27.  
  28. $grunion = new Grunion_Contact_Form( $attributes, $field_shortcodes ); 
  29.  
  30. die( "\n$grunion\n" );