pods_view

Include a file that's child/parent theme-aware, and can be cached into object cache or transients.

Description

(string|bool) pods_view( (string) $view, (constant) $data = null, (constant) $expires = false, (string) $cache_mode = 'cache', (bool) $return = false ); 

Returns (string|bool)

The view output

Parameters (5)

0. $view (string)
Path of the file to be included, this is relative to the current theme
1. $data — Optional. (constant) => null
Data to pass on to the template, using variable => value format
2. $expires — Optional. (constant) => false
Time in seconds for the cache to expire, if false caching is disabled.
3. $cache_mode — Optional. (string) => 'cache'
Specify the caching method to use for the view, available options include cache, transient, or site-transient
4. $return — Optional. (bool) => false
Whether to return the view or not, defaults to false and will echo it

Usage

  1. if ( !function_exists( 'pods_view' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'pods-custom-content-types-and-fields/includes/classes.php'; 
  3.  
  4. // Path of the file to be included, this is relative to the current theme 
  5. $view = ''; 
  6.  
  7. // (optional) Data to pass on to the template, using variable => value format 
  8. $data = null; 
  9.  
  10. // (optional) Time in seconds for the cache to expire, if false caching is disabled. 
  11. $expires = false; 
  12.  
  13. // (optional) Specify the caching method to use for the view, available options include cache, transient, or site-transient 
  14. $cache_mode = 'cache'; 
  15.  
  16. // (optional) Whether to return the view or not, defaults to false and will echo it 
  17. $return = false; 
  18.  
  19. // NOTICE! Understand what this does before running. 
  20. $result = pods_view($view, $data, $expires, $cache_mode, $return); 
  21.  

Defined (1)

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

/includes/classes.php  
  1. function pods_view ( $view, $data = null, $expires = false, $cache_mode = 'cache', $return = false ) { 
  2. require_once( PODS_DIR . 'classes/PodsView.php' ); 
  3.  
  4. $view = PodsView::view( $view, $data, $expires, $cache_mode ); 
  5.  
  6. if ( $return ) 
  7. return $view; 
  8.  
  9. echo $view;