frontier_backtrack_template

The Pods - Custom Content Types and Fields frontier backtrack template function.

Description

frontier_backtrack_template( $code, $aliases ); 

Parameters (2)

0. $code
The code.
1. $aliases
The aliases.

Usage

  1. if ( !function_exists( 'frontier_backtrack_template' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'pods-custom-content-types-and-fields/components/Templates/includes/functions-view_template.php'; 
  3.  
  4. // The code. 
  5. $code = null; 
  6.  
  7. // The aliases. 
  8. $aliases = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = frontier_backtrack_template($code, $aliases); 
  12.  

Defined (1)

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

/components/Templates/includes/functions-view_template.php  
  1. function frontier_backtrack_template( $code, $aliases ) { 
  2.  
  3. $regex = frontier_get_regex( $aliases ); 
  4. preg_match_all( '/' . $regex . '/s', $code, $used ); 
  5.  
  6. if ( !empty( $used[ 2 ] ) ) { 
  7. foreach ( $used[ 2 ] as $key => $alias ) { 
  8. $shortcodes = explode( '__', $alias ); 
  9. $content = $used[ 5 ][ $key ]; 
  10. $atts = shortcode_parse_atts( $used[ 3 ][ $key ] ); 
  11. if ( !empty( $atts ) ) { 
  12. if ( !empty( $atts[ 'field' ] ) ) { 
  13. $content = str_replace( $atts[ 'field' ] . '.', '', $content ); 
  14. preg_match_all( '/' . $regex . '/s', $content, $subused ); 
  15. if ( !empty( $subused[ 2 ] ) ) { 
  16. $content = frontier_backtrack_template( $content, $aliases ); 
  17. $codecontent = "[" . $shortcodes[ 0 ] . " " . trim( $used[ 3 ][ $key ] ) . " seq=\"" . $shortcodes[ 1 ] . "\"]" . base64_encode( $content ) . "[/" . $shortcodes[ 0 ] . "]"; 
  18. else { 
  19. $codecontent = "[" . $shortcodes[ 0 ] . " seq=\"" . $shortcodes[ 1 ] . "\"]" . base64_encode( $content ) . "[/" . $shortcodes[ 0 ] . "]"; 
  20. $code = str_replace( $used[ 0 ][ $key ], $codecontent, $code ); 
  21.  
  22. return $code;