Created
February 8, 2018 16:57
-
-
Save jaredatch/d368c1a243c14a3f10cbb5c2f9754d56 to your computer and use it in GitHub Desktop.
WPForms manually run the 1.4.3 entries database upgrade routine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Manually run the v1.4.3 entries upgrade routine. | |
* | |
*/ | |
function wpf_v143_upgrade_manual() { | |
// Fetch all entries. | |
$entries = wpforms()->entry->get_entries( | |
array( | |
'number' => -1, | |
'order' => 'ASC', | |
) | |
); | |
// Loop through the entries and add each field value to the new entry | |
// fields database table. | |
if ( ! empty( $entries ) ) { | |
foreach ( $entries as $entry ) { | |
$fields = wpforms_decode( $entry->fields ); | |
if ( ! empty( $fields ) ) { | |
foreach ( $fields as $field ) { | |
if ( isset( $field['id'] ) && isset( $field['value'] ) && '' !== $field['value'] ) { | |
wpforms()->entry_fields->add( | |
array( | |
'entry_id' => absint( $entry->entry_id ), | |
'form_id' => absint( $entry->form_id ), | |
'field_id' => absint( $field['id'] ), | |
'value' => $field['value'], | |
'date' => $entry->date, | |
) | |
); | |
} | |
} | |
} | |
} | |
} | |
delete_option( 'wpforms_fields_update' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment