| 1 |
<?php |
| 2 |
/** |
| 3 |
* Function that adds backwards compatibility starting from v1.3.15 for the email customizer |
| 4 |
* |
| 5 |
* @since v.1.3.15 |
| 6 |
* |
| 7 |
* @return void |
| 8 |
*/ |
| 9 |
function wppb_pro_v1_3_15(){ |
| 10 |
$email_customizer_array = get_option( 'emailCustomizer', 'not_found' ); |
| 11 |
|
| 12 |
if ( $email_customizer_array != 'not_found' ){ |
| 13 |
$new_email_customizer_array = array(); |
| 14 |
|
| 15 |
$new_email_customizer_array = wppb_copy_old_content( $email_customizer_array, $new_email_customizer_array, 'from', 'reply_to' ); |
| 16 |
$new_email_customizer_array = wppb_copy_old_content( $email_customizer_array, $new_email_customizer_array, 'settingsGroup1Option2', 'default_registration_email_subject' ); |
| 17 |
$new_email_customizer_array = wppb_copy_old_content( $email_customizer_array, $new_email_customizer_array, 'settingsGroup1Option3', 'default_registration_email_content' ); |
| 18 |
$new_email_customizer_array = wppb_copy_old_content( $email_customizer_array, $new_email_customizer_array, 'settingsGroup3Option2', 'registration_w_admin_approval_email_subject' ); |
| 19 |
$new_email_customizer_array = wppb_copy_old_content( $email_customizer_array, $new_email_customizer_array, 'settingsGroup3Option3', 'registration_w_admin_approval_email_content' ); |
| 20 |
$new_email_customizer_array = wppb_copy_old_content( $email_customizer_array, $new_email_customizer_array, 'settingsGroup4Option2', 'admin_approval_aproved_status_email_subject' ); |
| 21 |
$new_email_customizer_array = wppb_copy_old_content( $email_customizer_array, $new_email_customizer_array, 'settingsGroup4Option3', 'admin_approval_aproved_status_email_content' ); |
| 22 |
$new_email_customizer_array = wppb_copy_old_content( $email_customizer_array, $new_email_customizer_array, 'settingsGroup2Option2', 'registration_w_email_confirmation_email_subject' ); |
| 23 |
$new_email_customizer_array = wppb_copy_old_content( $email_customizer_array, $new_email_customizer_array, 'settingsGroup2Option3', 'registration_w_email_confirmation_email_content' ); |
| 24 |
$new_email_customizer_array = wppb_copy_old_content( $email_customizer_array, $new_email_customizer_array, 'settingsGroup4Option6', 'admin_approval_unaproved_status_email_subject' ); |
| 25 |
$new_email_customizer_array = wppb_copy_old_content( $email_customizer_array, $new_email_customizer_array, 'settingsGroup4Option7', 'admin_approval_unaproved_status_email_content' ); |
| 26 |
$new_email_customizer_array = wppb_copy_old_content( $email_customizer_array, $new_email_customizer_array, 'admin_settingsGroup1Option2', 'admin_default_registration_email_subject' ); |
| 27 |
$new_email_customizer_array = wppb_copy_old_content( $email_customizer_array, $new_email_customizer_array, 'admin_settingsGroup1Option3', 'admin_default_registration_email_content' ); |
| 28 |
$new_email_customizer_array = wppb_copy_old_content( $email_customizer_array, $new_email_customizer_array, 'admin_settingsGroup3Option2', 'admin_registration_w_admin_approval_email_subject' ); |
| 29 |
$new_email_customizer_array = wppb_copy_old_content( $email_customizer_array, $new_email_customizer_array, 'admin_settingsGroup3Option3', 'admin_registration_w_admin_approval_email_content' ); |
| 30 |
|
| 31 |
update_option( 'emailCustomizer', $new_email_customizer_array + $email_customizer_array ); |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
function wppb_copy_old_content ( $email_customizer_array, $new_email_customizer_array, $old_index, $new_index ){ |
| 36 |
if ( isset( $email_customizer_array[$old_index] ) ){ |
| 37 |
$new_email_customizer_array[$new_index] = $email_customizer_array[$old_index]; |
| 38 |
unset( $email_customizer_array[$old_index] ); |
| 39 |
} |
| 40 |
|
| 41 |
return $new_email_customizer_array; |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Function that adds backwards compatibility version 1.3.13 to version 1.3.14: we need to copy all data from item_options_values, and create the item_option_labels index for the checkbox, radio and select extra-fields, to reflect the front-end changes |
| 46 |
* |
| 47 |
* @since v.1.3.13 |
| 48 |
* |
| 49 |
* @return void |
| 50 |
*/ |
| 51 |
function wppb_pro_hobbyist_v1_3_13(){ |
| 52 |
$custom_fields = get_option( 'wppb_custom_fields','not_found' ); |
| 53 |
|
| 54 |
if ( $custom_fields != 'not_found' ){ |
| 55 |
foreach ( $custom_fields as $key => $value ){ |
| 56 |
if ( ( $value['item_type'] == 'checkbox' ) || ( $value['item_type'] == 'radio' ) || ( $value['item_type'] == 'select' ) ){ |
| 57 |
if ( isset( $custom_fields[$key]['item_option_values'] ) ){ |
| 58 |
$custom_fields[$key]['item_option_labels'] = $custom_fields[$key]['item_option_values']; |
| 59 |
unset( $custom_fields[$key]['item_option_values'] ); |
| 60 |
} |
| 61 |
|
| 62 |
}else |
| 63 |
unset( $custom_fields[$key]['item_option_values'] ); |
| 64 |
} |
| 65 |
|
| 66 |
update_option( 'wppb_custom_fields', $custom_fields ); |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
/** |
| 72 |
* Function that checks if there is at least one EP and/or R form. In the execution timeline this function runs faster than the wppb_prepopulate_fields function |
| 73 |
* |
| 74 |
* @since v.2.0 |
| 75 |
* |
| 76 |
* @return void |
| 77 |
*/ |
| 78 |
function wppb_pro_hobbyist_free_v2_0(){ |
| 79 |
$wppb_manage_fields = get_option( 'wppb_manage_fields', 'not_found' ); |
| 80 |
$backed_up_manage_fields = array(); |
| 81 |
|
| 82 |
// part that handles the manage fields |
| 83 |
if ( $wppb_manage_fields == 'not_found' ){ |
| 84 |
|
| 85 |
$old_default_fields = get_option( 'wppb_default_settings', 'not_found' ); |
| 86 |
|
| 87 |
if ( $old_default_fields != 'not_found' ){ |
| 88 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Name (Heading)', '', 'No' ); |
| 89 |
|
| 90 |
if ( $old_default_fields['username'] == 'show' ) |
| 91 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Username', '', ucfirst( trim( $old_default_fields['usernameRequired'] ) ), __( 'The usernames cannot be changed.', 'profilebuilder' ) ); |
| 92 |
|
| 93 |
if ( $old_default_fields['firstname'] == 'show' ) |
| 94 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - First Name', 'first_name', ucfirst( trim( $old_default_fields['firstnameRequired'] ) ) ); |
| 95 |
|
| 96 |
if ( $old_default_fields['lastname'] == 'show' ) |
| 97 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Last Name', 'last_name', ucfirst( trim( $old_default_fields['lastnameRequired'] ) ) ); |
| 98 |
|
| 99 |
if ( $old_default_fields['nickname'] == 'show' ) |
| 100 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Nickname', 'nickname', ucfirst( trim( $old_default_fields['nicknameRequired'] ) ) ); |
| 101 |
|
| 102 |
if ( $old_default_fields['dispname'] == 'show' ) |
| 103 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Display name publicly as', '', ucfirst( trim( $old_default_fields['dispnameRequired'] ) ) ); |
| 104 |
|
| 105 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Contact Info (Heading)', '', 'No' ); |
| 106 |
|
| 107 |
if ( $old_default_fields['email'] == 'show' ) |
| 108 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - E-mail', '', ucfirst( trim( $old_default_fields['emailRequired'] ) ), '(required)' ); |
| 109 |
|
| 110 |
if ( $old_default_fields['website'] == 'show' ) |
| 111 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Website', '', ucfirst( trim( $old_default_fields['websiteRequired'] ) ) ); |
| 112 |
|
| 113 |
if ( $old_default_fields['aim'] == 'show' ) |
| 114 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - AIM', 'aim', ucfirst( trim( $old_default_fields['aimRequired'] ) ) ); |
| 115 |
|
| 116 |
if ( $old_default_fields['yahoo'] == 'show' ) |
| 117 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Yahoo IM', 'yim', ucfirst( trim( $old_default_fields['yahooRequired'] ) ) ); |
| 118 |
|
| 119 |
if ( $old_default_fields['jabber'] == 'show' ) |
| 120 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Jabber / Google Talk', 'jabber', ucfirst( trim( $old_default_fields['jabberRequired'] ) ) ); |
| 121 |
|
| 122 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - About Yourself (Heading)', '', 'No' ); |
| 123 |
|
| 124 |
if ( $old_default_fields['bio'] == 'show' ) |
| 125 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Biographical Info', 'description', ucfirst( trim( $old_default_fields['bioRequired'] ) ) ); |
| 126 |
|
| 127 |
if ( $old_default_fields['password'] == 'show' ){ |
| 128 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Password', '', ucfirst( trim( $old_default_fields['passwordRequired'] ) ) ); |
| 129 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Repeat Password', '', ucfirst( trim( $old_default_fields['passwordRequired'] ) ) ); |
| 130 |
} |
| 131 |
|
| 132 |
}else{ |
| 133 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Name (Heading)', '', 'No' ); |
| 134 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Username', '', 'Yes', __( 'The usernames cannot be changed.', 'profilebuilder' ) ); |
| 135 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - First Name', 'first_name', 'No' ); |
| 136 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Last Name', 'last_name', 'No' ); |
| 137 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Nickname', 'nickname', 'No' ); |
| 138 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Display name publicly as', '', 'No' ); |
| 139 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Contact Info (Heading)', '', 'No' ); |
| 140 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - E-mail', '', 'Yes', '(required)' ); |
| 141 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Website', '', 'No' ); |
| 142 |
|
| 143 |
// Default contact methods were removed in WP 3.6. A filter dictates contact methods. |
| 144 |
if ( apply_filters( 'wppb_remove_default_contact_methods', get_site_option( 'initial_db_version' ) < 23588 ) ){ |
| 145 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - AIM', 'aim', 'No' ); |
| 146 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Yahoo IM', 'yim', 'No' ); |
| 147 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Jabber / Google Talk', 'jabber', 'No' ); |
| 148 |
} |
| 149 |
|
| 150 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - About Yourself (Heading)', '', 'No' ); |
| 151 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Biographical Info', 'description', 'No' ); |
| 152 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Password', '', 'Yes' ); |
| 153 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'Default - Repeat Password', '', 'Yes' ); |
| 154 |
} |
| 155 |
|
| 156 |
$old_custom_fields = get_option( 'wppb_custom_fields', 'not_found' ); |
| 157 |
if( $old_custom_fields != 'not_found' && count( $old_custom_fields ) != 0 ){ |
| 158 |
foreach ( $old_custom_fields as $key => $value ) { |
| 159 |
$local_array = array(); |
| 160 |
|
| 161 |
$local_array['id'] = ( isset( $value['id'] ) ? trim( $value['id'] ) : '' ); |
| 162 |
$local_array['meta-name'] = ( isset( $value['item_metaName'] ) ? trim( $value['item_metaName'] ) : '' ); |
| 163 |
$local_array['field-title'] = ( isset( $value['item_title'] ) ? trim( $value['item_title'] ) : '' ); |
| 164 |
$local_array['description'] = ( isset( $value['item_desc'] ) ? $value['item_desc'] : '' ); |
| 165 |
$local_array['required'] = 'No'; |
| 166 |
$local_array['overwrite-existing'] = 'No'; |
| 167 |
$local_array['row-count'] = '5'; |
| 168 |
$local_array['allowed-image-extensions'] = '.*'; |
| 169 |
$local_array['allowed-upload-extensions'] = '.*'; |
| 170 |
$local_array['avatar-size'] = '100'; |
| 171 |
$local_array['date-format'] = 'mm/dd/yy'; |
| 172 |
$local_array['terms-of-agreement'] = ''; |
| 173 |
$local_array['options'] = ''; |
| 174 |
$local_array['labels'] = ''; |
| 175 |
$local_array['public-key'] = ''; |
| 176 |
$local_array['private-key'] = ''; |
| 177 |
$local_array['default-value'] = ''; |
| 178 |
$local_array['default-option'] = ''; |
| 179 |
$local_array['default-options'] = ''; |
| 180 |
$local_array['default-content'] = ''; |
| 181 |
|
| 182 |
switch ( $value['item_type' ] ){ |
| 183 |
case "heading":{ |
| 184 |
$local_array['field'] = 'Heading'; |
| 185 |
$local_array['meta-name'] = ''; |
| 186 |
break; |
| 187 |
} |
| 188 |
case "input":{ |
| 189 |
$local_array['field'] = 'Input'; |
| 190 |
$local_array['required'] = ucfirst( trim( $value['item_required'] ) ); |
| 191 |
break; |
| 192 |
} |
| 193 |
case "hiddenInput":{ |
| 194 |
$local_array['field'] = 'Input (Hidden)'; |
| 195 |
$local_array['default-value'] = ( isset( $value['item_options'] ) ? trim( $value['item_options'] ) : '' ); |
| 196 |
break; |
| 197 |
} |
| 198 |
case "checkbox":{ |
| 199 |
$local_array['field'] = 'Checkbox'; |
| 200 |
$local_array['options'] = ( isset( $value['item_options'] ) ? trim( $value['item_options'] ) : '' ); |
| 201 |
$local_array['labels'] = ( isset( $value['item_option_labels'] ) ? trim( $value['item_option_labels'] ) : '' ); |
| 202 |
$local_array['required'] = ucfirst( trim( $value['item_required'] ) ); |
| 203 |
break; |
| 204 |
} |
| 205 |
case "agreeToTerms":{ |
| 206 |
$local_array['field'] = 'Checkbox (Terms and Conditions)'; |
| 207 |
$local_array['required'] = ucfirst( trim( "Yes" ) ); |
| 208 |
break; |
| 209 |
} |
| 210 |
case "radio":{ |
| 211 |
$local_array['field'] = 'Radio'; |
| 212 |
$local_array['options'] = ( isset( $value['item_options'] ) ? trim( $value['item_options'] ) : '' ); |
| 213 |
$local_array['labels'] = ( isset( $value['item_option_labels'] ) ? trim( $value['item_option_labels'] ) : '' ); |
| 214 |
$local_array['required'] = ucfirst( trim( $value['item_required'] ) ); |
| 215 |
break; |
| 216 |
} |
| 217 |
case "select":{ |
| 218 |
$local_array['field'] = 'Select'; |
| 219 |
$local_array['options'] = ( isset( $value['item_options'] ) ? trim( $value['item_options'] ) : '' ); |
| 220 |
$local_array['labels'] = ( isset( $value['item_option_labels'] ) ? trim( $value['item_option_labels'] ) : '' ); |
| 221 |
$local_array['required'] = ucfirst( trim( $value['item_required'] ) ); |
| 222 |
break; |
| 223 |
} |
| 224 |
case "countrySelect":{ |
| 225 |
$local_array['field'] = 'Select (Country)'; |
| 226 |
$local_array['required'] = ucfirst( trim( $value['item_required'] ) ); |
| 227 |
break; |
| 228 |
} |
| 229 |
case "timeZone":{ |
| 230 |
$local_array['field'] = 'Select (Timezone)'; |
| 231 |
$local_array['required'] = ucfirst( trim( $value['item_required'] ) ); |
| 232 |
break; |
| 233 |
} |
| 234 |
case "datepicker":{ |
| 235 |
$local_array['field'] = 'Datepicker'; |
| 236 |
$local_array['required'] = ucfirst( trim( $value['item_required'] ) ); |
| 237 |
break; |
| 238 |
} |
| 239 |
case "textarea":{ |
| 240 |
$local_array['field'] = 'Textarea'; |
| 241 |
$local_array['row-count'] = ( isset( $value['item_options'] ) ? trim( $value['item_options'] ) : '' ); |
| 242 |
$local_array['required'] = ucfirst( trim( $value['item_required'] ) ); |
| 243 |
break; |
| 244 |
} |
| 245 |
case "upload":{ |
| 246 |
$local_array['field'] = 'Upload'; |
| 247 |
$local_array['allowed-upload-extensions'] = ( isset( $value['item_options'] ) ? trim( $value['item_options'] ) : $local_array['allowed-upload-extensions'] ); |
| 248 |
$local_array['required'] = ucfirst( trim( $value['item_required'] ) ); |
| 249 |
break; |
| 250 |
} |
| 251 |
case "avatar":{ |
| 252 |
$local_array['field'] = 'Avatar'; |
| 253 |
$local_array['avatar-size'] = ( isset( $value['item_options'] ) ? trim( $value['item_options'] ) : $local_array['avatar-size'] ); |
| 254 |
$local_array['required'] = ucfirst( trim( $value['item_required'] ) ); |
| 255 |
break; |
| 256 |
} |
| 257 |
} |
| 258 |
|
| 259 |
array_push( $backed_up_manage_fields, $local_array ); |
| 260 |
} |
| 261 |
} |
| 262 |
} |
| 263 |
|
| 264 |
|
| 265 |
// part which handles the removal of the reCAPTCHA from the addon list |
| 266 |
$wppb_module_settings = get_option( 'wppb_addon_settings', 'not_found' ); |
| 267 |
if ( $wppb_module_settings != 'not_found' ){ |
| 268 |
if ( isset( $wppb_module_settings['wppb_reCaptcha'] ) && ( $wppb_module_settings['wppb_reCaptcha'] == 'show' ) ){ |
| 269 |
$recaptcha_settings = get_option( 'reCaptchaSettings' ); |
| 270 |
|
| 271 |
if ( ( $recaptcha_settings != 'no_found' ) || ( count( $recaptcha_settings ) != 0 ) ){ |
| 272 |
$backed_up_manage_fields = wppb_add_existing_default_fields( $backed_up_manage_fields, 'reCAPTCHA', '', 'Yes', '', trim( $recaptcha_settings['publicKey'] ), trim( $recaptcha_settings['privateKey'] ) ); |
| 273 |
} |
| 274 |
} |
| 275 |
|
| 276 |
unset( $wppb_module_settings['wppb_reCaptcha'] ); |
| 277 |
$wppb_module_settings['wppb_multipleEditProfileForms'] = 'hide'; |
| 278 |
$wppb_module_settings['wppb_multipleRegistrationForms'] = 'hide'; |
| 279 |
|
| 280 |
update_option( 'wppb_module_settings', $wppb_module_settings ); |
| 281 |
} |
| 282 |
|
| 283 |
add_option( 'wppb_manage_fields', $backed_up_manage_fields ); |
| 284 |
|
| 285 |
|
| 286 |
// part which handles the general settings select->checkbox backwards comp. |
| 287 |
$wppb_generalSettings = get_option( 'wppb_general_settings', 'not_found' ); |
| 288 |
if ( ( $wppb_generalSettings != 'not_found' ) && ( count( $wppb_generalSettings ) > 1 ) ){ |
| 289 |
if ( isset( $wppb_generalSettings['extraFieldsLayout'] ) && ( $wppb_generalSettings['extraFieldsLayout'] == 'no' ) ) |
| 290 |
unset( $wppb_generalSettings['extraFieldsLayout'] ); |
| 291 |
|
| 292 |
else |
| 293 |
$wppb_generalSettings['extraFieldsLayout'] = 'default'; |
| 294 |
|
| 295 |
update_option( 'wppb_general_settings', $wppb_generalSettings ); |
| 296 |
} |
| 297 |
} |
| 298 |
|
| 299 |
|
| 300 |
/** |
| 301 |
* Function that adds backwards compatibility for the userlisting |
| 302 |
* |
| 303 |
* @since v.2.0 |
| 304 |
* |
| 305 |
*/ |
| 306 |
function wppb_pro_userlisting_compatibility_upgrade(){ |
| 307 |
if ( wppb_default_form_already_present( 'Userlisting', 'wppb-ul-cpt' ) ) |
| 308 |
return ''; |
| 309 |
|
| 310 |
$old_userlisting_settings = get_option( 'customUserListingSettings', 'not_found' ); |
| 311 |
if ( $old_userlisting_settings == 'not_found' ) |
| 312 |
$old_userlisting_settings = get_option( 'userListingSettings' ); |
| 313 |
|
| 314 |
if ( $old_userlisting_settings == 'not_found' ) |
| 315 |
return; |
| 316 |
|
| 317 |
$all_userlisting = ( isset( $old_userlisting_settings['allUserlisting'] ) ? wppb_replace_merge_tags( $old_userlisting_settings['allUserlisting'], true ) : '' ); |
| 318 |
$single_userlisting = ( isset( $old_userlisting_settings['singleUserlisting'] ) ? wppb_replace_merge_tags( $old_userlisting_settings['singleUserlisting'] ) : '' ); |
| 319 |
|
| 320 |
if( !empty( $old_userlisting_settings['sortingNumber'] ) ) |
| 321 |
$number_os_users_per_page = $old_userlisting_settings['sortingNumber']; |
| 322 |
else |
| 323 |
$number_os_users_per_page = '5'; |
| 324 |
|
| 325 |
if( !empty( $old_userlisting_settings['sortingCriteria'] ) ) |
| 326 |
$default_sorting_criteria = $old_userlisting_settings['sortingCriteria']; |
| 327 |
else |
| 328 |
$default_sorting_criteria = 'login'; |
| 329 |
|
| 330 |
if( !empty( $old_userlisting_settings['sortingOrder'] ) ) |
| 331 |
$default_sorting_order = $old_userlisting_settings['sortingOrder']; |
| 332 |
else |
| 333 |
$default_sorting_order = 'asc'; |
| 334 |
|
| 335 |
if( !empty( $old_userlisting_settings['avatarSize'] ) ) |
| 336 |
$avatar_size_all = $old_userlisting_settings['avatarSize']; |
| 337 |
else |
| 338 |
$avatar_size_all = '40'; |
| 339 |
|
| 340 |
if( !empty( $old_userlisting_settings['avatarSize'] ) ) |
| 341 |
$avatar_size_single = $old_userlisting_settings['avatarSize']; |
| 342 |
else |
| 343 |
$avatar_size_single = '60'; |
| 344 |
|
| 345 |
$userlisting_settings = array( array( 'roles-to-display' => '*', 'number-of-userspage' => $number_os_users_per_page, 'default-sorting-criteria' => $default_sorting_criteria, 'default-sorting-order' => $default_sorting_order, 'avatar-size-all-userlisting' => $avatar_size_all, 'avatar-size-single-userlisting' => $avatar_size_single ) ); |
| 346 |
|
| 347 |
$ul_post_id = wp_insert_post( array( 'post_title' => 'Userlisting', 'post_status' => 'publish', 'post_author' => get_current_user_id(), 'post_type' => 'wppb-ul-cpt', 'post_content' => 'Default Userlisting form placeholder' ), true ); |
| 348 |
|
| 349 |
add_post_meta( $ul_post_id, 'wppb-ul-templates', $all_userlisting ); |
| 350 |
add_post_meta( $ul_post_id, 'wppb-single-ul-templates', $single_userlisting ); |
| 351 |
add_post_meta( $ul_post_id, 'wppb_ul_page_settings', $userlisting_settings ); |
| 352 |
} |
| 353 |
|
| 354 |
|
| 355 |
/** |
| 356 |
* Function that replaces the individual merge-tags in the userlisting |
| 357 |
* |
| 358 |
* @since v.2.0 |
| 359 |
* |
| 360 |
* @param string $content |
| 361 |
* @param boolean $all_userlisting_form |
| 362 |
* |
| 363 |
* @return string |
| 364 |
* |
| 365 |
*/ |
| 366 |
function wppb_replace_merge_tags( $content, $all_userlisting_form = false ){ |
| 367 |
$content = trim( $content ); |
| 368 |
|
| 369 |
$content = wppb_old_backwards_compatibility( $content ); |
| 370 |
|
| 371 |
$content = str_replace( '%%meta_number_of_posts%%', '{{{meta_number_of_posts}}}', $content ); |
| 372 |
$content = str_replace( '%%extra_search_all_fields%%', '{{{extra_search_all_fields}}}', $content ); |
| 373 |
$content = str_replace( '%%extra_more_info_link%%', '{{{more_info}}}', $content ); |
| 374 |
$content = str_replace( '%%extra_while_users%%', '{{#users}}', $content ); |
| 375 |
$content = str_replace( '%%extra_end_while_users%%', '{{/users}}', $content ); |
| 376 |
$content = str_replace( '%%extra_avatar_or_gravatar%%', '{{{avatar_or_gravatar}}}', $content ); |
| 377 |
$content = str_replace( '%%extra_go_back_link%%', '{{{extra_go_back_link}}}', $content ); |
| 378 |
$content = str_replace( '%%meta_first_last_name%%', '{{meta_first_name}}{{meta_last_name}}', $content ); |
| 379 |
$content = str_replace( '%%sort_first_last_name%%', '{{{sort_first_name}}}', $content ); |
| 380 |
|
| 381 |
preg_match_all( '/%%([a-z0-9\_]+)%%/', $content, $matches, PREG_PATTERN_ORDER ); |
| 382 |
foreach ( $matches[0] as $key => $value ) |
| 383 |
$content = ( ( strpos( $value, 'sort_' ) !== false ) ? str_replace( $value, '{{{'.$matches[1][$key].'}}}', $content ) : str_replace( $value, '{{'.$matches[1][$key].'}}', $content ) ); |
| 384 |
|
| 385 |
if ( $all_userlisting_form ) |
| 386 |
$content .= '{{{pagination}}}'; |
| 387 |
|
| 388 |
return $content; |
| 389 |
} |
| 390 |
|
| 391 |
|
| 392 |
/** |
| 393 |
* Function that replaces the individual merge-tags which existed the very first time. These consisted of %%item_title%% instead of the (then) newer %%item_meta_name%% |
| 394 |
* |
| 395 |
* @since v.2.0 |
| 396 |
* |
| 397 |
* @param string $content |
| 398 |
* |
| 399 |
* @return string |
| 400 |
* |
| 401 |
*/ |
| 402 |
function wppb_old_backwards_compatibility( $content ){ |
| 403 |
$wppb_custom_fields = get_option( 'wppb_custom_fields', 'not_found' ); |
| 404 |
|
| 405 |
if ( ( $wppb_custom_fields == 'not_found' ) || ( count( $wppb_custom_fields ) < 1 ) ) |
| 406 |
return $content; |
| 407 |
|
| 408 |
foreach( $wppb_custom_fields as $key => $value ){ |
| 409 |
if ( ( isset( $value['item_type'] ) ) && ( trim( $value['item_type'] != '' ) ) ) |
| 410 |
if ( ( isset( $value['item_metaName'] ) ) && ( trim( $value['item_metaName'] != '' ) ) ){ |
| 411 |
/* TODO don't know what's supposed to be here and don't have time before launch */ |
| 412 |
$string = str_replace( '%%meta_'.$value['item_title'].'%%', '%%meta_'.$value['item_metaName'].'%%', $string ); |
| 413 |
$string = str_replace( '%%meta_description_'.$value['item_title'].'%%', '%%meta_description_'.$value['item_metaName'].'%%', $string ); |
| 414 |
$string = str_replace( '%%sort_'.$value['item_title'].'%%', '%%sort_'.$value['item_metaName'].'%%', $string ); |
| 415 |
} |
| 416 |
} |
| 417 |
|
| 418 |
return $content; |
| 419 |
} |
| 420 |
|
| 421 |
|
| 422 |
/** |
| 423 |
* Function that checks if a default userlisting-form is already present |
| 424 |
* |
| 425 |
* @since v.2.0 |
| 426 |
* |
| 427 |
* @param string $post_title |
| 428 |
* @param string $post_type |
| 429 |
* |
| 430 |
* @return boolean |
| 431 |
* |
| 432 |
*/ |
| 433 |
function wppb_default_form_already_present( $post_title, $post_type ){ |
| 434 |
$defaults = get_posts( array( 'posts_per_page' => -1, 'post_status' => array( 'publish' ), 'post_type' => $post_type, 'orderby' => 'post_date', 'order' => 'ASC' ) ); |
| 435 |
foreach ( $defaults as $default ){ |
| 436 |
if ( $default->post_content == 'Default '.$post_title.' form placeholder' ) |
| 437 |
return true; |
| 438 |
} |
| 439 |
|
| 440 |
return false; |
| 441 |
} |
| 442 |
|
| 443 |
|
| 444 |
/** |
| 445 |
* Function that assures backwards compatibility for the email customizer |
| 446 |
* |
| 447 |
* @since v.2.0 |
| 448 |
* |
| 449 |
*/ |
| 450 |
function wppb_pro_email_customizer_compatibility_upgrade(){ |
| 451 |
$email_customizer_array = get_option( 'emailCustomizer', 'not_found' ); |
| 452 |
|
| 453 |
if ( $email_customizer_array != 'not_found' ){ |
| 454 |
wppb_replace_and_save( $email_customizer_array['from_name'], 'wppb_emailc_common_settings_from_name' ); |
| 455 |
wppb_replace_and_save( $email_customizer_array['reply_to'], 'wppb_emailc_common_settings_from_reply_to_email' ); |
| 456 |
wppb_replace_and_save( $email_customizer_array['default_registration_email_subject'], 'wppb_user_emailc_default_registration_email_subject' ); |
| 457 |
wppb_replace_and_save( $email_customizer_array['default_registration_email_content'], 'wppb_user_emailc_default_registration_email_content' ); |
| 458 |
wppb_replace_and_save( $email_customizer_array['registration_w_admin_approval_email_subject'], 'wppb_user_emailc_registration_with_admin_approval_email_subject' ); |
| 459 |
wppb_replace_and_save( $email_customizer_array['registration_w_admin_approval_email_content'], 'wppb_user_emailc_registration_with_admin_approval_email_content' ); |
| 460 |
wppb_replace_and_save( $email_customizer_array['admin_approval_aproved_status_email_subject'], 'wppb_user_emailc_admin_approval_notif_approved_email_subject' ); |
| 461 |
wppb_replace_and_save( $email_customizer_array['admin_approval_aproved_status_email_content'], 'wppb_user_emailc_admin_approval_notif_approved_email_content' ); |
| 462 |
wppb_replace_and_save( $email_customizer_array['admin_approval_unaproved_status_email_subject'], 'wppb_user_emailc_admin_approval_notif_unapproved_email_subject' ); |
| 463 |
wppb_replace_and_save( $email_customizer_array['admin_approval_unaproved_status_email_content'], 'wppb_user_emailc_admin_approval_notif_unapproved_email_content' ); |
| 464 |
wppb_replace_and_save( $email_customizer_array['registration_w_email_confirmation_email_subject'], 'wppb_user_emailc_registr_w_email_confirm_email_subject' ); |
| 465 |
wppb_replace_and_save( $email_customizer_array['registration_w_email_confirmation_email_content'], 'wppb_user_emailc_registr_w_email_confirm_email_content' ); |
| 466 |
wppb_replace_and_save( $email_customizer_array['admin_default_registration_email_subject'], 'wppb_admin_emailc_default_registration_email_subject' ); |
| 467 |
wppb_replace_and_save( $email_customizer_array['admin_default_registration_email_content'], 'wppb_admin_emailc_default_registration_email_content' ); |
| 468 |
wppb_replace_and_save( $email_customizer_array['admin_registration_w_admin_approval_email_subject'], 'wppb_admin_emailc_registration_with_admin_approval_email_subject' ); |
| 469 |
wppb_replace_and_save( $email_customizer_array['admin_registration_w_admin_approval_email_content'], 'wppb_admin_emailc_registration_with_admin_approval_email_content' ); |
| 470 |
} |
| 471 |
} |
| 472 |
|
| 473 |
|
| 474 |
/** |
| 475 |
* Function that checks if a default userlisting-form is already present |
| 476 |
* |
| 477 |
* @since v.2.0 |
| 478 |
* |
| 479 |
* @param string $old_content |
| 480 |
* @param string $option_name |
| 481 |
* |
| 482 |
*/ |
| 483 |
function wppb_replace_and_save( $content, $option_name ){ |
| 484 |
preg_match_all( '/%%([a-z0-9\_]+)%%/', $content, $matches, PREG_PATTERN_ORDER ); |
| 485 |
|
| 486 |
foreach ( $matches[0] as $key => $value ) |
| 487 |
$content = str_replace( $value, '{{'.$matches[1][$key].'}}', $content ); |
| 488 |
|
| 489 |
update_option( $option_name, $content ); |
| 490 |
} |
| 491 |
|
| 492 |
|
| 493 |
/** |
| 494 |
* Function that adds backwards compatibility for the default fields only |
| 495 |
* |
| 496 |
* @since v.2.0 |
| 497 |
* |
| 498 |
* @param array $backed_up_manage_fields |
| 499 |
* @param string $field |
| 500 |
* @param string $meta_name |
| 501 |
* @param string $required |
| 502 |
* @param string $description |
| 503 |
* @param string $recaptcha_public_key |
| 504 |
* @param string $recaptcha_private_key |
| 505 |
* |
| 506 |
* @return array |
| 507 |
*/ |
| 508 |
function wppb_add_existing_default_fields ( $backed_up_manage_fields = array(), $field, $meta_name, $required, $description = '', $recaptcha_public_key = '', $recaptcha_private_key = '' ){ |
| 509 |
$local_array = array(); |
| 510 |
|
| 511 |
$id = 0; |
| 512 |
foreach ( $backed_up_manage_fields as $key => $value ){ |
| 513 |
if ( (int)$id < (int)$value['id'] ); |
| 514 |
$id = $value['id']; |
| 515 |
} |
| 516 |
$id++; |
| 517 |
|
| 518 |
$local_array['id'] = $id; |
| 519 |
$local_array['field'] = $field; |
| 520 |
$local_array['meta-name'] = $meta_name; |
| 521 |
$local_array['field-title'] = str_replace( array( 'Default - ', ' (Heading)' ), '', $field ); |
| 522 |
$local_array['description'] = ''; |
| 523 |
$local_array['required'] = $required; |
| 524 |
$local_array['overwrite-existing'] = 'No'; |
| 525 |
$local_array['row-count'] = '5'; |
| 526 |
$local_array['allowed-image-extensions'] = '.*'; |
| 527 |
$local_array['allowed-upload-extensions'] = '.*'; |
| 528 |
$local_array['avatar-size'] = '100'; |
| 529 |
$local_array['date-format'] = 'mm/dd/yy'; |
| 530 |
$local_array['terms-of-agreement'] = ''; |
| 531 |
$local_array['options'] = ''; |
| 532 |
$local_array['labels'] = ''; |
| 533 |
$local_array['public-key'] = $recaptcha_public_key; |
| 534 |
$local_array['private-key'] = $recaptcha_private_key; |
| 535 |
$local_array['default-value'] = ''; |
| 536 |
$local_array['default-option'] = ''; |
| 537 |
$local_array['default-options'] = ''; |
| 538 |
$local_array['default-content'] = ''; |
| 539 |
|
| 540 |
array_push( $backed_up_manage_fields, $local_array ); |
| 541 |
|
| 542 |
return $backed_up_manage_fields; |
| 543 |
} |