-
Notifications
You must be signed in to change notification settings - Fork 163
Expand file tree
/
Copy pathupdater.php
More file actions
executable file
·118 lines (93 loc) · 2.74 KB
/
updater.php
File metadata and controls
executable file
·118 lines (93 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
/**
* Updaters for DB structure/etc.
*
* @package Caldera_Froms
* @author Josh Pollock <Josh@JoshPress.net>
* @license GPL-2.0+
* @link
* @copyright 2016 CalderaWP LLC
*/
/**
* Update Caldera Forms DB system to v2
*
* @since 1.3.4
*/
function caldera_forms_db_v2_update(){
//Before 1.3.4 forms were tracked in options -- each one was autoloaded
//Also which forms exist tracked in a "registry" option _caldera_forms that was also autoload
//Old registry had the "details" fields of forms -- duplicate data oh my.
$forms = get_option( '_caldera_forms', array() );
if( ! empty( $forms ) ){
//set options storage to be not autoloaded
$where = '`option_name` = "' . implode( '" OR `option_name` = "', array_keys( $forms ) ) . '"';
global $wpdb;
$sql = sprintf( "UPDATE `%s` SET `autoload`='no' WHERE %s", $wpdb->options, $where );
$wpdb->get_results( $sql );
//Create new registry that is just ID and not autoloaded
$new_registry = array();
if( ! empty( $forms ) ){
foreach( $forms as $id => $form ){
$new_registry[ $id ] = $id;
}
}
add_option( '_caldera_forms_forms', $new_registry, false );
caldera_forms_write_db_flag( 2 );
}
//BTW old registry option didn't get deleted because maybe some one reverts...
}
/** BTW v3-5 did not require updater functions */
/**
* Updated Caldera Forms DB system to v6
*
* Moves form configuration to custom table
*
* @see https://github.com/CalderaWP/Caldera-Forms/pull/1741
*
* @since 1.5.3
*/
function caldera_forms_db_v6_update(){
if( ! class_exists( 'Caldera_Forms_Forms' ) ){
return;
}
//This will make sure DB table is there if not already
Caldera_Forms::check_tables();
$forms = Caldera_Forms_Forms::get_forms( false, true );
if( ! empty( $forms ) ){
foreach ( $forms as $form ){
//Migration happens automatically when getting form config
//BTW means this isn't totally needed, but good to get it done in one go.
Caldera_Forms_Forms::get_form( $form );
}
}
//NOTE: Leaving options in place for now, especially beacuse of rollback.
}
function caldera_forms_db_v7_update(){
$registry_forms = get_option('_caldera_forms_forms' );
if( ! empty( $registry_forms ) ){
foreach ( $registry_forms as $id ){
delete_option( $id );
}
}
delete_option( '_caldera_forms_forms' );
}
/**
* Write DB version flag to options
*
* @since 1.3.4
*
* @param int $version Optional. The version number to write. Default is value of CF_DB
*/
function caldera_forms_write_db_flag( $version = CF_DB ){
update_option( 'CF_DB', $version );
}
/**
* Gets the last update version
*
* @since 1.5.0.9
*
* @return string
*/
function caldera_forms_get_last_update_version(){
return get_option( '_calderaforms_lastupdate' );
}