wpcf7_version

The Contact Form 7 wpcf7 version function.

Description

wpcf7_version( (string) $args = '' ); 

Parameters (1)

0. $args — Optional. (string) => ''
The args.

Usage

  1. if ( !function_exists( 'wpcf7_version' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'contact-form-7/includes/functions.php'; 
  3.  
  4. // The args. 
  5. $args = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wpcf7_version($args); 
  9.  

Defined (1)

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

/includes/functions.php  
  1. function wpcf7_version( $args = '' ) { 
  2. $defaults = array( 
  3. 'limit' => -1,  
  4. 'only_major' => false ); 
  5.  
  6. $args = wp_parse_args( $args, $defaults ); 
  7.  
  8. if ( $args['only_major'] ) { 
  9. $args['limit'] = 2; 
  10.  
  11. $args['limit'] = (int) $args['limit']; 
  12.  
  13. $ver = WPCF7_VERSION
  14. $ver = strtr( $ver, '_-+', '...' ); 
  15. $ver = preg_replace( '/[^0-9.]+/', ".$0.", $ver ); 
  16. $ver = preg_replace( '/[.]+/', ".", $ver ); 
  17. $ver = trim( $ver, '.' ); 
  18. $ver = explode( '.', $ver ); 
  19.  
  20. if ( -1 < $args['limit'] ) { 
  21. $ver = array_slice( $ver, 0, $args['limit'] ); 
  22.  
  23. $ver = implode( '.', $ver ); 
  24.  
  25. return $ver;