wpcf7_maybe_add_random_dir

The Contact Form 7 wpcf7 maybe add random dir function.

Description

wpcf7_maybe_add_random_dir( $dir ); 

Parameters (1)

0. $dir
The dir.

Usage

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

Defined (1)

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

/modules/file.php  
  1. function wpcf7_maybe_add_random_dir( $dir ) { 
  2. do { 
  3. $rand_max = mt_getrandmax(); 
  4. $rand = zeroise( mt_rand( 0, $rand_max ), strlen( $rand_max ) ); 
  5. $dir_new = path_join( $dir, $rand ); 
  6. } while ( file_exists( $dir_new ) ); 
  7.  
  8. if ( wp_mkdir_p( $dir_new ) ) { 
  9. return $dir_new; 
  10.  
  11. return $dir;