wpcf7_prepend_underscore

The Contact Form 7 wpcf7 prepend underscore function.

Description

wpcf7_prepend_underscore( $new_ver, $old_ver ); 

Parameters (2)

0. $new_ver
The new ver.
1. $old_ver
The old ver.

Usage

  1. if ( !function_exists( 'wpcf7_prepend_underscore' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'contact-form-7/includes/upgrade.php'; 
  3.  
  4. // The new ver. 
  5. $new_ver = null; 
  6.  
  7. // The old ver. 
  8. $old_ver = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wpcf7_prepend_underscore($new_ver, $old_ver); 
  12.  

Defined (1)

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

/includes/upgrade.php  
  1. function wpcf7_prepend_underscore( $new_ver, $old_ver ) { 
  2. if ( version_compare( $old_ver, '3.0-dev', '<' ) ) { 
  3. return; 
  4.  
  5. if ( ! version_compare( $old_ver, '3.3-dev', '<' ) ) { 
  6. return; 
  7.  
  8. $posts = WPCF7_ContactForm::find( array( 
  9. 'post_status' => 'any',  
  10. 'posts_per_page' => -1,  
  11. ) ); 
  12.  
  13. foreach ( $posts as $post ) { 
  14. $props = $post->get_properties(); 
  15.  
  16. foreach ( $props as $prop => $value ) { 
  17. if ( metadata_exists( 'post', $post->id(), '_' . $prop ) ) { 
  18. continue; 
  19.  
  20. update_post_meta( $post->id(), '_' . $prop, $value ); 
  21. delete_post_meta( $post->id(), $prop );