pods_evaluate_tags

Evaluate tags like magic tags but through pods_var.

Description

(string) pods_evaluate_tags( (string|array|object) $tags, (bool) $sanitize = false ); 

Returns (string)

Parameters (2)

0. $tags (string|array|object)
String to be evaluated
1. $sanitize — Optional. (bool) => false
Whether to sanitize tags

Usage

  1. if ( !function_exists( 'pods_evaluate_tags' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'pods-custom-content-types-and-fields/includes/data.php'; 
  3.  
  4. // String to be evaluated 
  5. $tags = null; 
  6.  
  7. // Whether to sanitize tags 
  8. $sanitize = false; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = pods_evaluate_tags($tags, $sanitize); 
  12.  

Defined (1)

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

/includes/data.php  
  1. function pods_evaluate_tags ( $tags, $sanitize = false ) { 
  2.  
  3. if ( is_array( $tags ) ) { 
  4. foreach ( $tags as $k => $tag ) { 
  5. $tags[ $k ] = pods_evaluate_tags( $tag, $sanitize ); 
  6.  
  7. return $tags; 
  8. elseif ( is_object( $tags ) ) { 
  9. $tags = get_object_vars( $tags ); 
  10.  
  11. foreach ( $tags as $k => $tag ) { 
  12. $tags[ $k ] = pods_evaluate_tags( $tag, $sanitize ); 
  13.  
  14. $tags = (object) $tags; 
  15.  
  16. return $tags; 
  17.  
  18. $callback = 'pods_evaluate_tag'; 
  19.  
  20. if ( true === $sanitize ) { 
  21. $callback = 'pods_evaluate_tag_sanitized'; 
  22.  
  23. return preg_replace_callback( '/({@(.*?)})/m', $callback, (string) $tags ); 
  24.