nf_parse_fields_shortcode

Parse our [ninja_forms_field] shortcode, just incase the shortcode parser screwed up.

Description

nf_parse_fields_shortcode( $content ); 

Parameters (1)

0. $content
The content.

Usage

  1. if ( !function_exists( 'nf_parse_fields_shortcode' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/shortcode.php'; 
  3.  
  4. // The content. 
  5. $content = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = nf_parse_fields_shortcode($content); 
  9.  

Defined (1)

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

/deprecated/includes/shortcode.php  
  1. function nf_parse_fields_shortcode( $content ) { 
  2. global $ninja_forms_processing; 
  3.  
  4. if ( ! isset ( $ninja_forms_processing ) ) 
  5. return $content; 
  6.  
  7. if ( is_array ( $content ) ) 
  8. return $content; 
  9.  
  10. $matches = array(); 
  11. $pattern = '\[(\[?)(ninja_forms_field|ninja_forms_all_fields)(?![\w-])([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)'; 
  12.  
  13. preg_match_all('/'.$pattern.'/s', $content, $matches); 
  14.  
  15. if ( is_array( $matches ) && ! empty( $matches[2] ) ) { 
  16. foreach ( $matches[2] as $key => $shortcode ) { 
  17.  
  18. if ( 'ninja_forms_field' == $shortcode ) { 
  19. if ( isset ( $matches[3][ $key ] ) ) { 
  20. $atts = shortcode_parse_atts( $matches[3][ $key ] ); 
  21. $id = $atts['id']; 
  22. $value = $ninja_forms_processing->get_field_value( $id ); 
  23. if( is_array( $value ) ) { 
  24. $value = implode( ', ', $value ); 
  25. $content = str_replace( $matches[0][ $key ], $value, $content ); 
  26. } else if ( 'ninja_forms_all_fields' == $shortcode ) { 
  27. if ( isset ( $matches[3][ $key ] ) ) { 
  28. $atts = shortcode_parse_atts( $matches[3][ $key ] ); 
  29. $content = str_replace( $matches[0][ $key ], nf_all_fields_shortcode( $atts, $content ), $content ); 
  30. return $content;