PluginProbe
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 1.4.2
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v1.4.2
3.6.1 3.6.0 3.5.3 3.5.2 3.5.1 3.5.0 3.4.8 3.4.7 3.4.6 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5.1 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 All 165 releases
everest-forms / trunk / includes / evf-update-functions.php
evf-update-functions.php
203 lines 5.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * EverestForms Updates
4 *
5 * Functions for updating data, used by the background updater.
6 *
7 * @package EverestForms\Functions
8 * @since 1.0.0
9 */
10
11 defined( 'ABSPATH' ) || exit;
12
13 /**
14 * Update DB Version.
15 */
16 function evf_update_100_db_version() {
17 EVF_Install::update_db_version( '1.0.0' );
18 }
19
20 /**
21 * Update DB Version.
22 */
23 function evf_update_101_db_version() {
24 EVF_Install::update_db_version( '1.0.1' );
25 }
26
27 /**
28 * Update DB Version.
29 */
30 function evf_update_102_db_version() {
31 EVF_Install::update_db_version( '1.0.2' );
32 }
33
34 /**
35 * Update DB Version.
36 */
37 function evf_update_103_db_version() {
38 EVF_Install::update_db_version( '1.0.3' );
39 }
40
41 /**
42 * Update all forms for meta-key.
43 */
44 function evf_update_110_update_forms() {
45 $forms = evf_get_all_forms();
46
47 foreach ( $forms as $form_id => $form ) {
48 $form_obj = EVF()->form->get( $form_id );
49 $form_data = ! empty( $form_obj->post_content ) ? evf_decode( $form_obj->post_content ) : '';
50
51 if ( ! empty( $form_data['form_fields'] ) ) {
52 foreach ( $form_data['form_fields'] as &$field ) {
53 if ( ! isset( $field['meta-key'] ) ) {
54 $field['meta-key'] = evf_get_meta_key_field_option( $field );
55 }
56 }
57 }
58
59 // Update form data.
60 EVF()->form->update( $form_id, $form_data );
61 }
62 }
63
64 /**
65 * Update DB Version.
66 */
67 function evf_update_110_db_version() {
68 EVF_Install::update_db_version( '1.1.0' );
69 }
70
71 /**
72 * Delete global email related options.
73 */
74 function evf_update_116_delete_options() {
75 $delete_options = array(
76 'evf_to_email',
77 'evf_from_name',
78 'evf_from_address',
79 'evf_email_subject',
80 'evf_email_message',
81 'everest_forms_disable_form_entries',
82 'everest_forms_form_submit_button_label',
83 'everest_forms_successful_form_submission_message',
84 );
85
86 foreach ( $delete_options as $delete_option ) {
87 delete_option( $delete_option );
88 }
89 }
90
91 /**
92 * Update DB Version.
93 */
94 function evf_update_116_db_version() {
95 EVF_Install::update_db_version( '1.1.6' );
96 }
97
98 /**
99 * Update settings option to use new renamed option for 1.2.0.
100 */
101 function evf_update_120_db_rename_options() {
102 $rename_options = array(
103 'evf_email_template' => 'everest_forms_email_template',
104 'evf_recaptcha_site_key' => 'everest_forms_recaptcha_site_key',
105 'evf_recaptcha_site_secret' => 'everest_forms_recaptcha_site_secret',
106 'evf_required_validation' => 'everest_forms_required_validation',
107 'evf_url_validation' => 'everest_forms_url_validation',
108 'evf_email_validation' => 'everest_forms_email_validation',
109 'evf_number_validation' => 'everest_forms_number_validation',
110 'evf_recaptcha_validation' => 'everest_forms_recaptcha_validation',
111 'evf_default_form_page_id' => 'everest_forms_default_form_page_id',
112 );
113
114 foreach ( $rename_options as $old_option => $new_option ) {
115 $raw_old_option = get_option( $old_option );
116
117 if ( ! empty( $raw_old_option ) ) {
118 update_option( $new_option, $raw_old_option );
119 delete_option( $old_option );
120 }
121 }
122 }
123
124 /**
125 * Update email settings adding connection data.
126 */
127 function evf_update_140_db_multiple_email() {
128 $forms = EVF()->form->get( '', array( 'order' => 'DESC' ) );
129
130 // Loop through each forms.
131 foreach ( $forms as $form ) {
132 $form_id = isset( $form->ID ) ? $form->ID : '0';
133 $form_data = ! empty( $form->post_content ) ? evf_decode( $form->post_content ) : '';
134
135 if ( ! empty( $form_data['settings'] ) ) {
136 $email = (array) $form_data['settings']['email'];
137
138 // New email conn.
139 $new_email = array();
140 $new_email['connection_name'] = esc_html__( 'Admin Notification', 'everest-forms' );
141 $new_email = array_merge( $new_email, $email );
142
143 // Unset previous email data structure.
144 $email_settings = array( 'evf_send_confirmation_email', 'evf_user_to_email', 'evf_user_email_subject', 'evf_user_email_message', 'attach_pdf_to_user_email' );
145 foreach ( $email_settings as $email_setting ) {
146 unset( $email_setting );
147 }
148
149 // Maintain the multiple-email connections data structure.
150 if ( ! isset( $form_data['settings']['email']['connection_1'] ) ) {
151 $unique_connection_id = sprintf( 'connection_%s', uniqid() );
152 $form_data['settings']['email'] = array( 'connection_1' => $new_email );
153
154 if ( isset( $email['evf_send_confirmation_email'] ) && '1' === $email['evf_send_confirmation_email'] ) {
155 $form_data['settings']['email'][ $unique_connection_id ] = array(
156 'connection_name' => esc_html__( 'User Notification', 'everest-forms' ),
157 'evf_to_email' => '{field_id="' . $email['evf_user_to_email'] . '"}',
158 'evf_from_name' => $email['evf_from_name'],
159 'evf_from_email' => $email['evf_from_email'],
160 'evf_reply_to' => $email['evf_reply_to'],
161 'evf_email_subject' => $email['evf_user_email_subject'],
162 'evf_email_message' => $email['evf_user_email_message'],
163 );
164 }
165
166 if ( isset( $email['attach_pdf_to_user_email'] ) && '1' === $email['attach_pdf_to_user_email'] ){
167 $form_data['settings']['email'][ $unique_connection_id ]['attach_pdf_to_admin_email'] = '1';
168 }
169
170 if ( isset( $email['conditional_logic_status'] ) ) {
171 $form_data['settings']['email'][ $unique_connection_id ]['conditional_logic_status'] = $email['conditional_logic_status'];
172 $form_data['settings']['email'][ $unique_connection_id ]['conditional_option'] = $email['conditional_option'];
173 $form_data['settings']['email'][ $unique_connection_id ]['conditionals'] = array();
174 }
175 }
176
177 // Update form data.
178 EVF()->form->update( $form_id, $form_data );
179 }
180 }
181 }
182
183 /**
184 * Update DB Version.
185 */
186 function evf_update_120_db_version() {
187 EVF_Install::update_db_version( '1.2.0' );
188 }
189
190 /**
191 * Update DB Version.
192 */
193 function evf_update_130_db_version() {
194 EVF_Install::update_db_version( '1.3.0' );
195 }
196
197 /**
198 * Update DB Version.
199 */
200 function evf_update_140_db_version() {
201 EVF_Install::update_db_version( '1.4.0' );
202 }
203