PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.6.2
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.6.2
4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 All 340 releases
profile-builder / admin / manage-fields.php

manage-fields.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.6.2, at admin/manage-fields.php

1,749 lines 93.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3 // Define the default values.
4 define( 'WPPB_DEFAULTS_MAP_LAT', 48 );
5 define( 'WPPB_DEFAULTS_MAP_LNG', 12 );
6 define( 'WPPB_DEFAULTS_MAP_ZOOM', 4 );
7
8 /**
9 * Function that creates the Manage Fields submenu and populates it with a repeater field form
10 *
11 * @since v.2.0
12 *
13 * @return void
14 */
15 function wppb_manage_fields_submenu(){
16 // create a new sub_menu page which holds the data for the default + extra fields
17 $args = array(
18 'menu_title' => __('Form Fields', 'profile-builder'),
19 'page_title' => __('Manage Form Fields', 'profile-builder'),
20 'menu_slug' => 'manage-fields',
21 'page_type' => 'submenu_page',
22 'capability' => 'manage_options',
23 'priority' => 5,
24 'parent_slug' => 'profile-builder'
25 );
26 $manage_fields_page = new WCK_Page_Creator_PB($args);
27 }
28 add_action( 'admin_menu', 'wppb_manage_fields_submenu', 1 );
29
30 function wppb_populate_manage_fields(){
31
32 $manage_field_types = array(
33 'optgroups' => array(
34 'default' =>
35 array(
36 'label' => __('Default', 'profile-builder'),
37 'options' => array(
38 'Default - Name (Heading)',
39 'Default - Contact Info (Heading)',
40 'Default - About Yourself (Heading)',
41 'Default - Username',
42 'Default - First Name',
43 'Default - Last Name',
44 'Default - Nickname',
45 'Default - E-mail',
46 'Default - Website',
47 'Default - Password',
48 'Default - Repeat Password',
49 'Default - Biographical Info',
50 'Default - Display name publicly as',
51 ),
52 ),
53 'standard' =>
54 array(
55 'label' => __('Standard', 'profile-builder'),
56 'options' => array(),
57 ),
58 'advanced' =>
59 array(
60 'label' => __('Advanced', 'profile-builder'),
61 'options' => array(),
62 ),
63 'other' =>
64 array(
65 'label' => __('Other', 'profile-builder'),
66 'options' => array(
67 'GDPR Checkbox', // since 2.8.2
68 'GDPR Delete Button', // since 3.0.1
69 ),
70 ),
71 ),
72 );
73
74 // Default contact methods were removed in WP 3.6. A filter dictates contact methods.
75 if ( apply_filters( 'wppb_remove_default_contact_methods', get_site_option( 'initial_db_version' ) < 23588 ) ){
76 $manage_field_types['optgroups']['default']['options'][] = 'Default - AIM';
77 $manage_field_types['optgroups']['default']['options'][] = 'Default - Yahoo IM';
78 $manage_field_types['optgroups']['default']['options'][] = 'Default - Jabber / Google Talk';
79 }
80
81 if ( wppb_can_users_signup_blog() ) {
82 $manage_field_types['optgroups']['advanced']['options'][] = 'Default - Blog Details';
83 }
84
85 if( PROFILE_BUILDER != 'Profile Builder Free' ) {
86 $manage_field_types['optgroups']['standard']['options'][] = 'Heading';
87 $manage_field_types['optgroups']['standard']['options'][] = 'Input';
88 $manage_field_types['optgroups']['standard']['options'][] = 'Number';
89 $manage_field_types['optgroups']['standard']['options'][] = 'Input (Hidden)';
90 $manage_field_types['optgroups']['standard']['options'][] = 'Language';
91 $manage_field_types['optgroups']['standard']['options'][] = 'Textarea';
92 $manage_field_types['optgroups']['standard']['options'][] = 'WYSIWYG';
93 $manage_field_types['optgroups']['standard']['options'][] = 'Select';
94 $manage_field_types['optgroups']['standard']['options'][] = 'Select (Multiple)';
95 $manage_field_types['optgroups']['standard']['options'][] = 'Checkbox';
96 $manage_field_types['optgroups']['standard']['options'][] = 'Radio';
97 $manage_field_types['optgroups']['standard']['options'][] = 'HTML';
98 $manage_field_types['optgroups']['standard']['options'][] = 'Upload';
99 $manage_field_types['optgroups']['standard']['options'][] = 'Avatar';
100
101 $manage_field_types['optgroups']['advanced']['options'][] = 'Phone';
102 $manage_field_types['optgroups']['advanced']['options'][] = 'Select (Country)';
103 $manage_field_types['optgroups']['advanced']['options'][] = 'Select (Timezone)';
104 $manage_field_types['optgroups']['advanced']['options'][] = 'Select (Currency)';
105 $manage_field_types['optgroups']['advanced']['options'][] = 'Select (CPT)';
106 $manage_field_types['optgroups']['advanced']['options'][] = 'Checkbox (Terms and Conditions)';
107 $manage_field_types['optgroups']['advanced']['options'][] = 'Datepicker';
108 $manage_field_types['optgroups']['advanced']['options'][] = 'Timepicker';
109 $manage_field_types['optgroups']['advanced']['options'][] = 'Colorpicker';
110 $manage_field_types['optgroups']['advanced']['options'][] = 'Validation';
111 $manage_field_types['optgroups']['advanced']['options'][] = 'Map';
112
113 $manage_field_types['optgroups']['other']['options'][] = 'Email';
114 $manage_field_types['optgroups']['other']['options'][] = 'URL';
115
116 $manage_field_types['optgroups']['other']['options'][] = 'Select2';
117 $manage_field_types['optgroups']['other']['options'][] = 'Select2 (Multiple)';
118
119 $manage_field_types['optgroups']['other']['options'][] = 'Honeypot';
120 }
121
122 $manage_field_types['optgroups']['other']['options'][] = 'Email Confirmation';
123
124 /* added recaptcha and user role field since version 2.6.2 */
125 $manage_field_types['optgroups']['advanced']['options'][] = 'reCAPTCHA';
126 $manage_field_types['optgroups']['advanced']['options'][] = 'Select (User Role)';
127
128
129 $manage_field_types['optgroups']['other']['options'] = apply_filters( 'wppb_manage_fields_types', $manage_field_types['optgroups']['other']['options'] );
130
131 $manage_field_types = apply_filters( 'wppb_all_manage_fields_types', $manage_field_types );
132
133 //Free to Pro call to action on Manage Fields page
134 $field_description = __('Choose one of the supported field types','profile-builder');
135 if( PROFILE_BUILDER == 'Profile Builder Free' ) {
136 $field_description .= sprintf( __('. Extra Field Types are available in <a href="%s">Hobbyist or PRO versions</a>.' , 'profile-builder'), esc_url( 'https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=wpbackend&utm_medium=clientsite&utm_content=manage-fields-link&utm_campaign=PBFree' ) );
137 }
138
139 //user roles
140 global $wp_roles;
141
142 // @TODO - The block below could use refactoring, see new function wppb_prepare_key_value_options.
143 $user_roles = array();
144 foreach( $wp_roles->roles as $user_role_slug => $user_role )
145 if( $user_role_slug !== 'administrator' )
146 array_push( $user_roles, '%' . wppb_prepare_wck_labels( $user_role['name'] ) . '%' . $user_role_slug );
147
148
149 // @TODO - The block below could use refactoring, see new function wppb_prepare_key_value_options.
150 // country select
151 $default_country_array = wppb_country_select_options( 'back_end' );
152 foreach( $default_country_array as $iso_country_code => $country_name ) {
153 $default_country_options[] = '%'. wppb_prepare_wck_labels( $country_name ) .'%'.$iso_country_code;
154 }
155
156 // @TODO - The block below could use refactoring, see new function wppb_prepare_key_value_options.
157 // currency select
158 $default_currency_array = wppb_get_currencies( 'back_end' );
159 array_unshift( $default_currency_array, '' );
160 foreach( $default_currency_array as $iso_currency_code => $currency_name ) {
161 $default_currency_options[] = '%'. wppb_prepare_wck_labels( $currency_name ) .'%'.$iso_currency_code;
162 }
163
164 //cpt select
165 $post_types = get_post_types( array( 'public' => true ), 'names' );
166
167
168 if( apply_filters( 'wppb_update_field_meta_key_in_db', false ) ) {
169 $meta_key_description = __( 'Use this in conjunction with WordPress functions to display the value in the page of your choosing<br/>Auto-completed but in some cases editable (in which case it must be unique)<br/>Changing this might take long in case of a very big user-count', 'profile-builder' );
170 }
171 else{
172 $meta_key_description = __( 'Use this in conjunction with WordPress functions to display the value in the page of your choosing<br/>Auto-completed but in some cases editable (in which case it must be unique)<br/>Changing this will only affect subsequent entries', 'profile-builder' );
173 }
174
175 // Initiate the list of available tags for the pin bubble.
176 if( function_exists( 'wppb_generate_userlisting_merge_tags' ) ) {
177 $bubble_meta_tags = wppb_generate_userlisting_merge_tags('meta');
178 $bubble_meta_tags = wp_list_pluck($bubble_meta_tags, 'label', 'name');
179 }
180 else
181 $bubble_meta_tags = array();
182
183 // set up the fields array
184 $fields = apply_filters( 'wppb_manage_fields', array(
185
186 array( 'type' => 'text', 'slug' => 'field-title', 'title' => __( 'Field Title', 'profile-builder' ), 'description' => __( 'Title of the field', 'profile-builder' ) ),
187 array( 'type' => 'select', 'slug' => 'field', 'title' => __( 'Field', 'profile-builder' ), 'options' => apply_filters( 'wppb_manage_fields_types_options', $manage_field_types ), 'default-option' => true, 'description' => $field_description ),
188 array( 'type' => 'text', 'slug' => 'meta-name', 'title' => __( 'Meta-name', 'profile-builder' ), 'default' => wppb_get_meta_name(), 'description' => $meta_key_description ),
189 array( 'type' => 'text', 'slug' => 'id', 'title' => __( 'ID', 'profile-builder' ), 'default' => wppb_get_unique_id(), 'description' => __( "A unique, auto-generated ID for this particular field<br/>You can use this in conjuction with filters to target this element if needed<br/>Can't be edited", 'profile-builder' ), 'readonly' => true ),
190 array( 'type' => 'textarea', 'slug' => 'description', 'title' => __( 'Description', 'profile-builder' ), 'description' => __( 'Enter a (detailed) description of the option for end users to read<br/>Optional', 'profile-builder') ),
191 array( 'type' => 'text', 'slug' => 'row-count', 'title' => __( 'Row Count', 'profile-builder' ), 'default' => 5, 'description' => __( "Specify the number of rows for a 'Textarea' field<br/>If not specified, defaults to 5", 'profile-builder' ) ),
192 array( 'type' => 'text', 'slug' => 'allowed-image-extensions', 'title' => __( 'Allowed Image Extensions', 'profile-builder' ), 'default' => '.*', 'description' => __( 'Specify the extension(s) you want to limit to upload<br/>Example: .ext1,.ext2,.ext3<br/>If not specified, defaults to: .jpg,.jpeg,.gif,.png (.*)', 'profile-builder' ) ),
193 array( 'type' => 'checkbox', 'slug' => 'simple-upload', 'title' => __( 'Use Simple Upload', 'profile-builder' ), 'options' => array( '%'.__('Yes','profile-builder').'%'.'yes' ), 'description' => __( 'Use a simple upload field instead of the WordPress upload', 'profile-builder' ) ),
194 array( 'type' => 'text', 'slug' => 'allowed-upload-extensions', 'title' => __( 'Allowed Upload Extensions', 'profile-builder' ), 'default' => '.*', 'description' => __( 'Specify the extension(s) you want to limit to upload<br/>Example: .ext1,.ext2,.ext3<br/>If not specified, defaults to all WordPress allowed file extensions (.*)', 'profile-builder' ) ),
195 array( 'type' => 'text', 'slug' => 'avatar-size', 'title' => __( 'Avatar Size', 'profile-builder' ), 'default' => 100, 'description' => __( "Enter a value (between 20 and 200) for the size of the 'Avatar'<br/>If not specified, defaults to 100", 'profile-builder' ) ),
196 array( 'type' => 'text', 'slug' => 'date-format', 'title' => __( 'Date-format', 'profile-builder' ), 'default' => 'mm/dd/yy', 'description' => __( 'Specify the format of the date when using Datepicker<br/>Valid options: mm/dd/yy, mm/yy/dd, dd/yy/mm, dd/mm/yy, yy/dd/mm, yy/mm/dd, mm-dd-yy, yy-mm-dd, D, dd M yy, D, d M y, DD, dd-M-y, D, d M yy, mm/yy, mm/dd, dd/mm, @<br/>If not specified, defaults to mm/dd/yy<br/>ATTENTION: if you plan to use this field for sorting, please make sure to use year first, then month, and day last.', 'profile-builder' ) ),
197 array( 'type' => 'textarea', 'slug' => 'terms-of-agreement', 'title' => __( 'Terms of Agreement', 'profile-builder' ), 'description' => __( 'Enter a detailed description of the terms of agreement for the user to read.<br/>Links can be inserted by using standard HTML syntax: &lt;a href="custom_url"&gt;custom_text&lt;/a&gt;', 'profile-builder' ) ),
198 array( 'type' => 'text', 'slug' => 'options', 'title' => __( 'Options', 'profile-builder' ), 'description' => __( "Enter a comma separated list of values<br/>This can be anything, as it is hidden from the user, but should not contain special characters or apostrophes", 'profile-builder' ) ),
199 array( 'type' => 'text', 'slug' => 'labels', 'title' => __( 'Labels', 'profile-builder' ), 'description' => __( "Enter a comma separated list of labels<br/>Visible for the user", 'profile-builder' ) ),
200 array( 'type' => 'select', 'slug' => 'recaptcha-type', 'title' => __( 'reCAPTCHA Type', 'profile-builder' ), 'options' => array('%reCAPTCHA V2%v2', '%Invisible reCAPTCHA%invisible'), 'default' => 'v2', 'description' => __( 'Choose the <a href="https://developers.google.com/recaptcha/docs/versions" target="_blank">type of reCAPTCHA</a> you wish to add to this site.<br/>Please note that the Invisible reCAPTCHA is a type of reCAPTCHA v2.', 'profile-builder' ) ),
201 array( 'type' => 'text', 'slug' => 'public-key', 'title' => __( 'Site Key', 'profile-builder' ), 'description' => __( 'The site key from Google, <a href="https://www.google.com/recaptcha/admin/create" target="_blank">https://www.google.com/recaptcha/admin/create</a>', 'profile-builder' ) ),
202 array( 'type' => 'text', 'slug' => 'private-key', 'title' => __( 'Secret Key', 'profile-builder' ), 'description' => __( 'The secret key from Google, <a href="https://www.google.com/recaptcha/admin/create" target="_blank">https://www.google.com/recaptcha/admin/create</a>', 'profile-builder' ) ),
203 array( 'type' => 'checkbox', 'slug' => 'captcha-pb-forms', 'title' => __( 'Display on PB forms', 'profile-builder' ), 'options' => array( '%'.__('PB Login','profile-builder').'%'.'pb_login', '%'.__('PB Register','profile-builder').'%'.'pb_register', '%'.__('PB Recover Password','profile-builder').'%'.'pb_recover_password' ), 'default' => 'pb_register', 'description' => __( "Select on which Profile Builder forms to display reCAPTCHA", 'profile-builder' ) ),
204 array( 'type' => 'checkbox', 'slug' => 'captcha-wp-forms', 'title' => __( 'Display on default WP forms', 'profile-builder' ), 'options' => array( '%'.__('Default WP Login', 'profile-builder').'%'.'default_wp_login', '%'.__('Default WP Register', 'profile-builder').'%'.'default_wp_register', '%'.__('Default WP Recover Password', 'profile-builder').'%'.'default_wp_recover_password'), 'default' => 'default_wp_register', 'description' => __( "Select on which default WP forms to display reCAPTCHA", 'profile-builder' ) ),
205 array( 'type' => 'checkbox', 'slug' => 'user-roles', 'title' => __( 'User Roles', 'profile-builder' ), 'options' => $user_roles, 'description' => __( "Select which user roles to show to the user ( drag and drop to re-order )", 'profile-builder' ) ),
206 array( 'type' => 'checkbox', 'slug' => 'user-roles-on-edit-profile', 'title' => __( 'Display on Edit Profile', 'profile-builder' ), 'options' => array('%Yes%yes'), 'description' => __( "Check if you want the select user role field to appear on Edit Profile forms", 'profile-builder' ) ),
207 array( 'type' => 'text', 'slug' => 'user-roles-sort-order', 'title' => __( 'User Roles Order', 'profile-builder' ), 'description' => __( "Save the user role order from the user roles checkboxes", 'profile-builder' ) ),
208 array( 'type' => 'text', 'slug' => 'default-value', 'title' => __( 'Default Value', 'profile-builder' ), 'description' => __( "Default value of the field", 'profile-builder' ) ),
209 array( 'type' => 'text', 'slug' => 'default-option', 'title' => __( 'Default Option', 'profile-builder' ), 'description' => __( "Specify the option which should be selected by default", 'profile-builder' ) ),
210 array( 'type' => 'text', 'slug' => 'default-options', 'title' => __( 'Default Option(s)', 'profile-builder' ), 'description' => __( "Specify the option which should be checked by default<br/>If there are multiple values, separate them with a ',' (comma)", 'profile-builder' ) ),
211 array( 'type' => 'select', 'slug' => 'default-option-country', 'title' => __( 'Default Option', 'profile-builder' ), 'options' => ( isset( $default_country_options ) ) ? $default_country_options : '', 'description' => __( "Default option of the field", 'profile-builder' ) ),
212 array( 'type' => 'select', 'slug' => 'default-option-timezone', 'title' => __( 'Default Option', 'profile-builder' ), 'options' => wppb_timezone_select_options( 'back_end' ), 'description' => __( "Default option of the field", 'profile-builder' ) ),
213 array( 'type' => 'select', 'slug' => 'default-option-currency', 'title' => __( 'Default Option', 'profile-builder' ), 'options' => ( isset( $default_currency_options ) ) ? $default_currency_options : '', 'description' => __( "Default option of the field", 'profile-builder' ) ),
214 array( 'type' => 'select', 'slug' => 'show-currency-symbol', 'title' => __( 'Show Currency Symbol', 'profile-builder' ), 'options' => array( 'No', 'Yes' ), 'default' => 'No', 'description' => __( 'Whether the currency symbol should be displayed after the currency name in the select option.', 'profile-builder' ) ),
215 array( 'type' => 'select', 'slug' => 'cpt', 'title' => __( 'Show Post Type', 'profile-builder' ), 'options' => $post_types, 'default' => 'post', 'description' => __( 'Posts from what post type will be displayed in the select.', 'profile-builder' ) ),
216 array( 'type' => 'text', 'slug' => 'validation-possible-values', 'title' => __( 'Allowable Values', 'profile-builder' ), 'description' => __( "Enter a comma separated list of possible values. Upon registration if the value provided by the user does not match one of these values, the user will not be registered.", 'profile-builder' ) ),
217 array( 'type' => 'text', 'slug' => 'custom-error-message', 'title' => __( 'Error Message', 'profile-builder' ), 'description' => __( "Set a custom error message that will be displayed to the user.", 'profile-builder' ) ),
218 array( 'type' => 'select', 'slug' => 'time-format', 'title' => __( 'Time Format', 'profile-builder' ), 'options' => array( '%12 Hours%12', '%24 Hours%24' ), 'description' => __( 'Specify the time format.', 'profile-builder' ) ),
219 array( 'type' => 'text', 'slug' => 'map-api-key', 'title' => __( 'Google Maps API Key', 'profile-builder' ), 'description' => __( 'Enter your Google Maps API key ( <a href="https://console.developers.google.com/flows/enableapi?apiid=maps_backend" target="_blank">Get your API key</a> ). If more than one map fields are added to a form the API key from the first map displayed will be used.', 'profile-builder' ) ),
220
221 array(
222 'type' => 'text',
223 'slug' => 'map-default-lat',
224 'title' => __( 'Default Latitude', 'profile-builder' ),
225 'description' => __( 'The latitude at which the map should be displayed when no pins are attached.', 'profile-builder' ),
226 'default' => WPPB_DEFAULTS_MAP_LAT,
227 ),
228 array(
229 'type' => 'text',
230 'slug' => 'map-default-lng',
231 'title' => __( 'Default Longitude', 'profile-builder' ),
232 'description' => __( 'The longitude at which the map should be displayed when no pins are attached.', 'profile-builder' ),
233 'default' => WPPB_DEFAULTS_MAP_LNG,
234 ),
235 array(
236 'type' => 'text',
237 'slug' => 'map-default-zoom',
238 'title' => __( 'Default Zoom Level', 'profile-builder' ),
239 'description' => __( 'Add a number from 0 to 19. The higher the number the higher the zoom.', 'profile-builder' ),
240 'default' => WPPB_DEFAULTS_MAP_ZOOM,
241 ),
242
243 array( 'type' => 'text', 'slug' => 'map-height', 'title' => __( 'Map Height', 'profile-builder' ), 'description' => __( "The height of the map.", 'profile-builder' ), 'default' => 400 ),
244 array( 'type' => 'textarea', 'slug' => 'default-content', 'title' => __( 'Default Content', 'profile-builder' ), 'description' => __( "Default value of the textarea", 'profile-builder' ) ),
245 array( 'type' => 'textarea', 'slug' => 'html-content', 'title' => __( 'HTML Content', 'profile-builder' ), 'description' => __( "Add your HTML (or text) content", 'profile-builder' ) ),
246 array( 'type' => 'text', 'slug' => 'phone-format', 'title' => __( 'Phone Format', 'profile-builder' ), 'default' => '(###) ###-####', 'description' => __( "You can use: # for numbers, parentheses ( ), - sign, + sign, dot . and spaces.", 'profile-builder' ) .'<br>'. __( "Eg. (###) ###-####", 'profile-builder' ) .'<br>'. __( "Empty field won't check for correct phone number.", 'profile-builder' ) ),
247 array( 'type' => 'select', 'slug' => 'heading-tag', 'title' => __( 'Heading Tag', 'profile-builder' ), 'options' => array( '%h1 - biggest size%h1', 'h2', 'h3', 'h4', 'h5', '%h6 - smallest size%h6' ), 'default' => 'h4', 'description' => __( 'Change heading field size on front-end forms', 'profile-builder' ) ),
248 array( 'type' => 'text', 'slug' => 'min-number-value', 'title' => __( 'Min Number Value', 'profile-builder' ), 'description' => __( "Min allowed number value (0 to allow only positive numbers)", 'profile-builder' ) .'<br>'. __( "Leave it empty for no min value", 'profile-builder' ) ),
249 array( 'type' => 'text', 'slug' => 'max-number-value', 'title' => __( 'Max Number Value', 'profile-builder' ), 'description' => __( "Max allowed number value (0 to allow only negative numbers)", 'profile-builder' ) .'<br>'. __( "Leave it empty for no max value", 'profile-builder' ) ),
250 array( 'type' => 'text', 'slug' => 'number-step-value', 'title' => __( 'Number Step Value', 'profile-builder' ), 'description' => __( "Step value 1 to allow only integers, 0.1 to allow integers and numbers with 1 decimal", 'profile-builder' ) .'<br>'. __( "To allow multiple decimals use for eg. 0.01 (for 2 deciamls) and so on", 'profile-builder' ) .'<br>'. __( "You can also use step value to specify the legal number intervals (eg. step value 2 will allow only -4, -2, 0, 2 and so on)", 'profile-builder' ) .'<br>'. __( "Leave it empty for no restriction", 'profile-builder' ) ),
251 array( 'type' => 'select', 'slug' => 'required', 'title' => __( 'Required', 'profile-builder' ), 'options' => array( 'No', 'Yes' ), 'default' => 'No', 'description' => __( 'Whether the field is required or not', 'profile-builder' ) ),
252 array( 'type' => 'select', 'slug' => 'overwrite-existing', 'title' => __( 'Overwrite Existing', 'profile-builder' ), 'options' => array( 'No', 'Yes' ), 'default' => 'No', 'description' => __( "Selecting 'Yes' will add the field to the list, but will overwrite any other field in the database that has the same meta-name<br/>Use this at your own risk", 'profile-builder' ) ),
253
254 // Added the new option for the map field type, that allows to customize the POIs load type.
255 array(
256 'type' => 'select',
257 'slug' => 'map-pins-load-type',
258 'title' => __( 'POIs Load Type', 'profile-builder' ),
259 'options' => array(
260 '%' . __( 'POIs of the listed users (as filtered & paginated)', 'profile-builder' ) . '%',
261 '%' . __( 'POIs of all the users for the filter* (no pagination)', 'profile-builder' ) . '%all',
262 ),
263 'default' => '',
264 'description' => __( 'This option allows you to load on a single map the POIs for all users, or just these for the listed ones (this will take into account the filters and the faceted menus). *Please use this feature wisely, it will impact the performance.', 'profile-builder' ),
265 ),
266
267 // Added the new option for the map field type, that allows to customize the POI bubble content.
268 array(
269 'type' => 'checkbox',
270 'slug' => 'map-bubble-fields',
271 'title' => __( 'POI Bubble Info', 'profile-builder' ),
272 'options' => wppb_prepare_key_value_options( apply_filters( 'wppb_map_bubble_fields', $bubble_meta_tags ) ),
273 'default' => 'avatar_or_gravatar, meta_display_name',
274 'description' => __( 'Select the attributes to be listed inside the POI bubble.', 'profile-builder' ),
275 'extra_attributes' => array(
276 'dropdown_options' => true,
277 'sortable_options' => true,
278 ),
279 ),
280
281 // Added the new option for the map field type, that allows to customize the number of users per iteration.
282 array(
283 'type' => 'text',
284 'slug' => 'map-pagination-number',
285 'title' => __( 'Number of Users per Map Iteration', 'profile-builder' ),
286 'description' => __( 'When loading the map of all users with no pagination, the map script will iterate multiple times and will expose gradually POIs on the map, until all the POIs for the users that match the criteria will be added on the map (think of this as of pagination for the map POIs). The smaller the number of users per iteration, the fastest the iteration response will be, but for a large number of users, the map script will iterate multiple times. Setting a higher limit will decrease the performance, but might produce a smaller number of iterations. <br><br><b>Please adjust this value to your hosting capabilities, and make sure that the value you set is the best for performance.</b> We recommend a <b>maximum</b> value of 300.', 'profile-builder' ),
287 'default' => 50,
288 ),
289
290 //add Select 2 attributes
291 array( 'type' => 'text', 'slug' => 'select2-multiple-limit', 'title' => __( 'Maximum Selections', 'profile-builder' ), 'description' => __( "Select2 multi-value select boxes can set restrictions regarding the maximum number of options selected.", 'profile-builder' ) ),
292 array( 'type' => 'checkbox', 'slug' => 'select2-multiple-tags', 'title' => __( 'User Inputted Options', 'profile-builder' ), 'options' => array( '%Enable user inputted options%yes' ), 'description' => __( "Check this to allow users to create their own options beside the pre-existing ones.", 'profile-builder' ) ),
293
294 ) );
295
296 // create the new submenu with the above options
297 $args = array(
298 'metabox_id' => 'manage-fields',
299 'metabox_title' => __( 'Form Field Properties', 'profile-builder' ),
300 'post_type' => 'manage-fields',
301 'meta_name' => 'wppb_manage_fields',
302 'meta_array' => $fields,
303 'context' => 'option'
304 );
305 new Wordpress_Creation_Kit_PB( $args );
306
307 /* this is redundant but it should have a very low impact and for comfort we leave it here as well */
308 wppb_prepopulate_fields();
309
310 // create the info side meta-box
311 $args = array(
312 'metabox_id' => 'manage-fields-info',
313 'metabox_title' => __( 'Registration & Edit Profile Forms', 'profile-builder' ),
314 'post_type' => 'manage-fields',
315 'meta_name' => 'wppb_manage_fields_info',
316 'meta_array' => '',
317 'context' => 'option',
318 'mb_context' => 'side'
319 );
320 new Wordpress_Creation_Kit_PB( $args );
321 }
322 add_action( 'admin_init', 'wppb_populate_manage_fields', 1 );
323
324 /**
325 * Function that prepopulates the manage fields list with the default fields of WP
326 *
327 * @since v.2.0
328 *
329 * @return void
330 */
331 function wppb_prepopulate_fields(){
332 $prepopulated_fields[] = array( 'field' => 'Default - Name (Heading)', 'field-title' => __( 'Name', 'profile-builder' ), 'meta-name' => '', 'overwrite-existing' => 'No', 'id' => '1', 'description' => '', 'row-count' => '5', 'allowed-image-extensions' => '.*', 'allowed-upload-extensions' => '.*', 'avatar-size' => '100', 'date-format' => 'mm/dd/yy', 'terms-of-agreement' => '', 'options' => '', 'labels' => '', 'public-key' => '', 'private-key' => '', 'default-value' => '', 'default-option' => '', 'default-options' => '', 'default-content' => '', 'required' => 'No' );
333 $prepopulated_fields[] = array( 'field' => 'Default - Username', 'field-title' => __( 'Username', 'profile-builder' ), 'meta-name' => '', 'overwrite-existing' => 'No', 'id' => '2', 'description' => __( 'Usernames cannot be changed.', 'profile-builder' ), 'row-count' => '5', 'allowed-image-extensions' => '.*', 'allowed-upload-extensions' => '.*', 'avatar-size' => '100', 'date-format' => 'mm/dd/yy', 'terms-of-agreement' => '', 'options' => '', 'labels' => '', 'public-key' => '', 'private-key' => '', 'default-value' => '', 'default-option' => '', 'default-options' => '', 'default-content' => '', 'required' => 'Yes' );
334 $prepopulated_fields[] = array( 'field' => 'Default - First Name', 'field-title' => __( 'First Name', 'profile-builder' ), 'meta-name' => 'first_name', 'overwrite-existing' => 'No', 'id' => '3', 'description' => '', 'row-count' => '5', 'allowed-image-extensions' => '.*', 'allowed-upload-extensions' => '.*', 'avatar-size' => '100', 'date-format' => 'mm/dd/yy', 'terms-of-agreement' => '', 'options' => '', 'labels' => '', 'public-key' => '', 'private-key' => '', 'default-value' => '', 'default-option' => '', 'default-options' => '', 'default-content' => '', 'required' => 'No' );
335 $prepopulated_fields[] = array( 'field' => 'Default - Last Name', 'field-title' => __( 'Last Name', 'profile-builder' ), 'meta-name' => 'last_name', 'overwrite-existing' => 'No', 'id' => '4', 'description' => '', 'row-count' => '5', 'allowed-image-extensions' => '.*', 'allowed-upload-extensions' => '.*', 'avatar-size' => '100', 'date-format' => 'mm/dd/yy', 'terms-of-agreement' => '', 'options' => '', 'labels' => '', 'public-key' => '', 'private-key' => '', 'default-value' => '', 'default-option' => '', 'default-options' => '', 'default-content' => '', 'required' => 'No' );
336 $prepopulated_fields[] = array( 'field' => 'Default - Nickname', 'field-title' => __( 'Nickname', 'profile-builder' ), 'meta-name' => 'nickname', 'overwrite-existing' => 'No', 'id' => '5', 'description' => '', 'row-count' => '5', 'allowed-image-extensions' => '.*', 'allowed-upload-extensions' => '.*', 'avatar-size' => '100', 'date-format' => 'mm/dd/yy', 'terms-of-agreement' => '', 'options' => '', 'labels' => '', 'public-key' => '', 'private-key' => '', 'default-value' => '', 'default-option' => '', 'default-options' => '', 'default-content' => '', 'required' => 'Yes' );
337 $prepopulated_fields[] = array( 'field' => 'Default - Display name publicly as', 'field-title' => __( 'Display name publicly as', 'profile-builder' ), 'meta-name' => '', 'overwrite-existing' => 'No', 'id' => '6', 'description' => '', 'row-count' => '5', 'allowed-image-extensions' => '.*', 'allowed-upload-extensions' => '.*', 'avatar-size' => '100', 'date-format' => 'mm/dd/yy', 'terms-of-agreement' => '', 'options' => '', 'labels' => '', 'public-key' => '', 'private-key' => '', 'default-value' => '', 'default-option' => '', 'default-options' => '', 'default-content' => '', 'required' => 'No' );
338 $prepopulated_fields[] = array( 'field' => 'Default - Contact Info (Heading)', 'field-title' => __( 'Contact Info', 'profile-builder' ), 'meta-name' => '', 'overwrite-existing' => 'No', 'id' => '7', 'description' => '', 'row-count' => '5', 'allowed-image-extensions' => '.*', 'allowed-upload-extensions' => '.*', 'avatar-size' => '100', 'date-format' => 'mm/dd/yy', 'terms-of-agreement' => '', 'options' => '', 'labels' => '', 'public-key' => '', 'private-key' => '', 'default-value' => '', 'default-option' => '', 'default-options' => '', 'default-content' => '', 'required' => 'No' );
339 $prepopulated_fields[] = array( 'field' => 'Default - E-mail', 'field-title' => __( 'E-mail', 'profile-builder' ), 'meta-name' => '', 'overwrite-existing' => 'No', 'id' => '8', 'description' => '', 'row-count' => '5', 'allowed-image-extensions' => '.*', 'allowed-upload-extensions' => '.*', 'avatar-size' => '100', 'date-format' => 'mm/dd/yy', 'terms-of-agreement' => '', 'options' => '', 'labels' => '', 'public-key' => '', 'private-key' => '', 'default-value' => '', 'default-option' => '', 'default-options' => '', 'default-content' => '', 'required' => 'Yes' );
340 $prepopulated_fields[] = array( 'field' => 'Default - Website', 'field-title' => __( 'Website', 'profile-builder' ), 'meta-name' => '', 'overwrite-existing' => 'No', 'id' => '9', 'description' => '', 'row-count' => '5', 'allowed-image-extensions' => '.*', 'allowed-upload-extensions' => '.*', 'avatar-size' => '100', 'date-format' => 'mm/dd/yy', 'terms-of-agreement' => '', 'options' => '', 'labels' => '', 'public-key' => '', 'private-key' => '', 'default-value' => '', 'default-option' => '', 'default-options' => '', 'default-content' => '', 'required' => 'No' );
341
342 // Default contact methods were removed in WP 3.6. A filter dictates contact methods.
343 if ( apply_filters( 'wppb_remove_default_contact_methods', get_site_option( 'initial_db_version' ) < 23588 ) ){
344 $prepopulated_fields[] = array( 'field' => 'Default - AIM', 'field-title' => __( 'AIM', 'profile-builder' ), 'meta-name' => 'aim', 'overwrite-existing' => 'No', 'id' => '10', 'description' => '', 'row-count' => '5', 'allowed-image-extensions' => '.*', 'allowed-upload-extensions' => '.*', 'avatar-size' => '100', 'date-format' => 'mm/dd/yy', 'terms-of-agreement' => '', 'options' => '', 'labels' => '', 'public-key' => '', 'private-key' => '', 'default-value' => '', 'default-option' => '', 'default-options' => '', 'default-content' => '', 'required' => 'No' );
345 $prepopulated_fields[] = array( 'field' => 'Default - Yahoo IM', 'field-title' => __( 'Yahoo IM', 'profile-builder' ), 'meta-name' => 'yim', 'overwrite-existing' => 'No', 'id' => '11', 'description' => '', 'row-count' => '5', 'allowed-image-extensions' => '.*', 'allowed-upload-extensions' => '.*', 'avatar-size' => '100', 'date-format' => 'mm/dd/yy', 'terms-of-agreement' => '', 'options' => '', 'labels' => '', 'public-key' => '', 'private-key' => '', 'default-value' => '', 'default-option' => '', 'default-options' => '', 'default-content' => '', 'required' => 'No' );
346 $prepopulated_fields[] = array( 'field' => 'Default - Jabber / Google Talk', 'field-title' => __( 'Jabber / Google Talk', 'profile-builder' ), 'meta-name' => 'jabber', 'overwrite-existing' => 'No', 'id' => '12', 'description' => '', 'row-count' => '5', 'allowed-image-extensions' => '.*', 'allowed-upload-extensions' => '.*', 'avatar-size' => '100', 'date-format' => 'mm/dd/yy', 'terms-of-agreement' => '', 'options' => '', 'labels' => '', 'public-key' => '', 'private-key' => '', 'default-value' => '', 'default-option' => '', 'default-options' => '', 'default-content' => '', 'required' => 'No' );
347 }
348
349 $prepopulated_fields[] = array( 'field' => 'Default - About Yourself (Heading)', 'field-title' => __( 'About Yourself', 'profile-builder' ), 'meta-name' => '', 'overwrite-existing' => 'No', 'id' => '13', 'description' => '', 'row-count' => '5', 'allowed-image-extensions' => '.*', 'allowed-upload-extensions' => '.*', 'avatar-size' => '100', 'date-format' => 'mm/dd/yy', 'terms-of-agreement' => '', 'options' => '', 'labels' => '', 'public-key' => '', 'private-key' => '', 'default-value' => '', 'default-option' => '', 'default-options' => '', 'default-content' => '', 'required' => 'No' );
350 $prepopulated_fields[] = array( 'field' => 'Default - Biographical Info', 'field-title' => __( 'Biographical Info', 'profile-builder' ), 'meta-name' => 'description', 'overwrite-existing' => 'No', 'id' => '14', 'description' => __( 'Share a little biographical information to fill out your profile. This may be shown publicly.', 'profile-builder' ), 'row-count' => '5', 'allowed-image-extensions' => '.*', 'allowed-upload-extensions' => '.*', 'avatar-size' => '100', 'date-format' => 'mm/dd/yy', 'terms-of-agreement' => '', 'options' => '', 'labels' => '', 'public-key' => '', 'private-key' => '', 'default-value' => '', 'default-option' => '', 'default-options' => '', 'required' => 'No' );
351 $prepopulated_fields[] = array( 'field' => 'Default - Password', 'field-title' => __( 'Password', 'profile-builder' ), 'meta-name' => '', 'overwrite-existing' => 'No', 'id' => '15', 'description' => __( 'Type your password.', 'profile-builder' ), 'row-count' => '5', 'allowed-image-extensions' => '.*', 'allowed-upload-extensions' => '.*', 'avatar-size' => '100', 'date-format' => 'mm/dd/yy', 'terms-of-agreement' => '', 'options' => '', 'labels' => '', 'public-key' => '', 'private-key' => '', 'default-value' => '', 'default-option' => '', 'default-options' => '', 'default-content' => '', 'required' => 'Yes' );
352 $prepopulated_fields[] = array( 'field' => 'Default - Repeat Password', 'field-title' => __( 'Repeat Password', 'profile-builder' ), 'meta-name' => '', 'overwrite-existing' => 'No', 'id' => '16', 'description' => __( 'Type your password again. ', 'profile-builder' ), 'row-count' => '5', 'allowed-image-extensions' => '.*', 'allowed-upload-extensions' => '.*', 'avatar-size' => '100', 'date-format' => 'mm/dd/yy', 'terms-of-agreement' => '', 'options' => '', 'labels' => '', 'public-key' => '', 'private-key' => '', 'default-value' => '', 'default-option' => '', 'default-options' => '', 'default-content' => '', 'required' => 'Yes' );
353 if ( wppb_can_users_signup_blog() ){
354 $prepopulated_fields[] = array( 'field' => 'Default - Blog Details', 'field-title' => __( 'Blog Details', 'profile-builder' ), 'meta-name' => '', 'overwrite-existing' => 'No', 'id' => '17', 'description' => '', 'row-count' => '5', 'allowed-image-extensions' => '.*', 'allowed-upload-extensions' => '.*', 'avatar-size' => '100', 'date-format' => 'mm/dd/yy', 'terms-of-agreement' => '', 'options' => '', 'labels' => '', 'public-key' => '', 'private-key' => '', 'default-value' => '', 'default-option' => '', 'default-options' => '', 'default-content' => '', 'required' => 'No' );
355 }
356
357 add_option ( 'wppb_manage_fields', apply_filters ( 'wppb_prepopulated_fields', $prepopulated_fields ) );
358 }
359
360 /**
361 * Function that returns a unique meta-name
362 *
363 * @since v.2.0
364 *
365 * @return string
366 */
367 function wppb_get_meta_name( $option = 'wppb_manage_fields', $prefix = 'custom_field_' ){
368 $id = 1;
369
370 $wppb_manage_fields = get_option( $option, 'not_found' );
371
372 if ( ( $wppb_manage_fields === 'not_found' ) || ( empty( $wppb_manage_fields ) ) ){
373 return $prefix . $id;
374 }
375 else{
376 $meta_names = array();
377 foreach( $wppb_manage_fields as $value ){
378 if ( strpos( $value['meta-name'], $prefix ) === 0 ){
379 $meta_names[] = $value['meta-name'];
380 }
381 }
382
383 if( !empty( $meta_names ) ){
384 $meta_numbers = array();
385 foreach( $meta_names as $meta_name ){
386 $number = str_replace( $prefix, '', $meta_name );
387 /* we should have an underscore present in custom_field_# so remove it */
388 $number = str_replace( '_', '', $number );
389
390 $meta_numbers[] = $number;
391 }
392 if( !empty( $meta_numbers ) ){
393 rsort( $meta_numbers );
394 $id = (int)$meta_numbers[0] + 1;
395 }
396 }
397
398 return $prefix . $id;
399 }
400 }
401
402
403 /**
404 * Function that returns an array with countries
405 *
406 * @since v.2.0
407 *
408 * @return array
409 */
410 function wppb_country_select_options( $form_location ) {
411 $country_array = apply_filters( 'wppb_'.$form_location.'_country_select_array',
412 array(
413 '' => __( 'Select a Country', 'profile-builder' ),
414 'AF' => __( 'Afghanistan', 'profile-builder' ),
415 'AX' => __( 'Aland Islands', 'profile-builder' ),
416 'AL' => __( 'Albania', 'profile-builder' ),
417 'DZ' => __( 'Algeria', 'profile-builder' ),
418 'AS' => __( 'American Samoa', 'profile-builder' ),
419 'AD' => __( 'Andorra', 'profile-builder' ),
420 'AO' => __( 'Angola', 'profile-builder' ),
421 'AI' => __( 'Anguilla', 'profile-builder' ),
422 'AQ' => __( 'Antarctica', 'profile-builder' ),
423 'AG' => __( 'Antigua and Barbuda', 'profile-builder' ),
424 'AR' => __( 'Argentina', 'profile-builder' ),
425 'AM' => __( 'Armenia', 'profile-builder' ),
426 'AW' => __( 'Aruba', 'profile-builder' ),
427 'AU' => __( 'Australia', 'profile-builder' ),
428 'AT' => __( 'Austria', 'profile-builder' ),
429 'AZ' => __( 'Azerbaijan', 'profile-builder' ),
430 'BS' => __( 'Bahamas', 'profile-builder' ),
431 'BH' => __( 'Bahrain', 'profile-builder' ),
432 'BD' => __( 'Bangladesh', 'profile-builder' ),
433 'BB' => __( 'Barbados', 'profile-builder' ),
434 'BY' => __( 'Belarus', 'profile-builder' ),
435 'BE' => __( 'Belgium', 'profile-builder' ),
436 'BZ' => __( 'Belize', 'profile-builder' ),
437 'BJ' => __( 'Benin', 'profile-builder' ),
438 'BM' => __( 'Bermuda', 'profile-builder' ),
439 'BT' => __( 'Bhutan', 'profile-builder' ),
440 'BO' => __( 'Bolivia', 'profile-builder' ),
441 'BQ' => __( 'Bonaire, Saint Eustatius and Saba', 'profile-builder' ),
442 'BA' => __( 'Bosnia and Herzegovina', 'profile-builder' ),
443 'BW' => __( 'Botswana', 'profile-builder' ),
444 'BV' => __( 'Bouvet Island', 'profile-builder' ),
445 'BR' => __( 'Brazil', 'profile-builder' ),
446 'IO' => __( 'British Indian Ocean Territory', 'profile-builder' ),
447 'VG' => __( 'British Virgin Islands', 'profile-builder' ),
448 'BN' => __( 'Brunei', 'profile-builder' ),
449 'BG' => __( 'Bulgaria', 'profile-builder' ),
450 'BF' => __( 'Burkina Faso', 'profile-builder' ),
451 'BI' => __( 'Burundi', 'profile-builder' ),
452 'KH' => __( 'Cambodia', 'profile-builder' ),
453 'CM' => __( 'Cameroon', 'profile-builder' ),
454 'CA' => __( 'Canada', 'profile-builder' ),
455 'CV' => __( 'Cape Verde', 'profile-builder' ),
456 'KY' => __( 'Cayman Islands', 'profile-builder' ),
457 'CF' => __( 'Central African Republic', 'profile-builder' ),
458 'TD' => __( 'Chad', 'profile-builder' ),
459 'CL' => __( 'Chile', 'profile-builder' ),
460 'CN' => __( 'China', 'profile-builder' ),
461 'CX' => __( 'Christmas Island', 'profile-builder' ),
462 'CC' => __( 'Cocos Islands', 'profile-builder' ),
463 'CO' => __( 'Colombia', 'profile-builder' ),
464 'KM' => __( 'Comoros', 'profile-builder' ),
465 'CK' => __( 'Cook Islands', 'profile-builder' ),
466 'CR' => __( 'Costa Rica', 'profile-builder' ),
467 'HR' => __( 'Croatia', 'profile-builder' ),
468 'CU' => __( 'Cuba', 'profile-builder' ),
469 'CW' => __( 'Curacao', 'profile-builder' ),
470 'CY' => __( 'Cyprus', 'profile-builder' ),
471 'CZ' => __( 'Czech Republic', 'profile-builder' ),
472 'CD' => __( 'Democratic Republic of the Congo', 'profile-builder' ),
473 'DK' => __( 'Denmark', 'profile-builder' ),
474 'DJ' => __( 'Djibouti', 'profile-builder' ),
475 'DM' => __( 'Dominica', 'profile-builder' ),
476 'DO' => __( 'Dominican Republic', 'profile-builder' ),
477 'TL' => __( 'East Timor', 'profile-builder' ),
478 'EC' => __( 'Ecuador', 'profile-builder' ),
479 'EG' => __( 'Egypt', 'profile-builder' ),
480 'SV' => __( 'El Salvador', 'profile-builder' ),
481 'GQ' => __( 'Equatorial Guinea', 'profile-builder' ),
482 'ER' => __( 'Eritrea', 'profile-builder' ),
483 'EE' => __( 'Estonia', 'profile-builder' ),
484 'ET' => __( 'Ethiopia', 'profile-builder' ),
485 'FK' => __( 'Falkland Islands', 'profile-builder' ),
486 'FO' => __( 'Faroe Islands', 'profile-builder' ),
487 'FJ' => __( 'Fiji', 'profile-builder' ),
488 'FI' => __( 'Finland', 'profile-builder' ),
489 'FR' => __( 'France', 'profile-builder' ),
490 'GF' => __( 'French Guiana', 'profile-builder' ),
491 'PF' => __( 'French Polynesia', 'profile-builder' ),
492 'TF' => __( 'French Southern Territories', 'profile-builder' ),
493 'GA' => __( 'Gabon', 'profile-builder' ),
494 'GM' => __( 'Gambia', 'profile-builder' ),
495 'GE' => __( 'Georgia', 'profile-builder' ),
496 'DE' => __( 'Germany', 'profile-builder' ),
497 'GH' => __( 'Ghana', 'profile-builder' ),
498 'GI' => __( 'Gibraltar', 'profile-builder' ),
499 'GR' => __( 'Greece', 'profile-builder' ),
500 'GL' => __( 'Greenland', 'profile-builder' ),
501 'GD' => __( 'Grenada', 'profile-builder' ),
502 'GP' => __( 'Guadeloupe', 'profile-builder' ),
503 'GU' => __( 'Guam', 'profile-builder' ),
504 'GT' => __( 'Guatemala', 'profile-builder' ),
505 'GG' => __( 'Guernsey', 'profile-builder' ),
506 'GN' => __( 'Guinea', 'profile-builder' ),
507 'GW' => __( 'Guinea-Bissau', 'profile-builder' ),
508 'GY' => __( 'Guyana', 'profile-builder' ),
509 'HT' => __( 'Haiti', 'profile-builder' ),
510 'HM' => __( 'Heard Island and McDonald Islands', 'profile-builder' ),
511 'HN' => __( 'Honduras', 'profile-builder' ),
512 'HK' => __( 'Hong Kong', 'profile-builder' ),
513 'HU' => __( 'Hungary', 'profile-builder' ),
514 'IS' => __( 'Iceland', 'profile-builder' ),
515 'IN' => __( 'India', 'profile-builder' ),
516 'ID' => __( 'Indonesia', 'profile-builder' ),
517 'IR' => __( 'Iran', 'profile-builder' ),
518 'IQ' => __( 'Iraq', 'profile-builder' ),
519 'IE' => __( 'Ireland', 'profile-builder' ),
520 'IM' => __( 'Isle of Man', 'profile-builder' ),
521 'IL' => __( 'Israel', 'profile-builder' ),
522 'IT' => __( 'Italy', 'profile-builder' ),
523 'CI' => __( 'Ivory Coast', 'profile-builder' ),
524 'JM' => __( 'Jamaica', 'profile-builder' ),
525 'JP' => __( 'Japan', 'profile-builder' ),
526 'JE' => __( 'Jersey', 'profile-builder' ),
527 'JO' => __( 'Jordan', 'profile-builder' ),
528 'KZ' => __( 'Kazakhstan', 'profile-builder' ),
529 'KE' => __( 'Kenya', 'profile-builder' ),
530 'KI' => __( 'Kiribati', 'profile-builder' ),
531 'XK' => __( 'Kosovo', 'profile-builder' ),
532 'KW' => __( 'Kuwait', 'profile-builder' ),
533 'KG' => __( 'Kyrgyzstan', 'profile-builder' ),
534 'LA' => __( 'Laos', 'profile-builder' ),
535 'LV' => __( 'Latvia', 'profile-builder' ),
536 'LB' => __( 'Lebanon', 'profile-builder' ),
537 'LS' => __( 'Lesotho', 'profile-builder' ),
538 'LR' => __( 'Liberia', 'profile-builder' ),
539 'LY' => __( 'Libya', 'profile-builder' ),
540 'LI' => __( 'Liechtenstein', 'profile-builder' ),
541 'LT' => __( 'Lithuania', 'profile-builder' ),
542 'LU' => __( 'Luxembourg', 'profile-builder' ),
543 'MO' => __( 'Macao', 'profile-builder' ),
544 'MK' => __( 'Macedonia', 'profile-builder' ),
545 'MG' => __( 'Madagascar', 'profile-builder' ),
546 'MW' => __( 'Malawi', 'profile-builder' ),
547 'MY' => __( 'Malaysia', 'profile-builder' ),
548 'MV' => __( 'Maldives', 'profile-builder' ),
549 'ML' => __( 'Mali', 'profile-builder' ),
550 'MT' => __( 'Malta', 'profile-builder' ),
551 'MH' => __( 'Marshall Islands', 'profile-builder' ),
552 'MQ' => __( 'Martinique', 'profile-builder' ),
553 'MR' => __( 'Mauritania', 'profile-builder' ),
554 'MU' => __( 'Mauritius', 'profile-builder' ),
555 'YT' => __( 'Mayotte', 'profile-builder' ),
556 'MX' => __( 'Mexico', 'profile-builder' ),
557 'FM' => __( 'Micronesia', 'profile-builder' ),
558 'MD' => __( 'Moldova', 'profile-builder' ),
559 'MC' => __( 'Monaco', 'profile-builder' ),
560 'MN' => __( 'Mongolia', 'profile-builder' ),
561 'ME' => __( 'Montenegro', 'profile-builder' ),
562 'MS' => __( 'Montserrat', 'profile-builder' ),
563 'MA' => __( 'Morocco', 'profile-builder' ),
564 'MZ' => __( 'Mozambique', 'profile-builder' ),
565 'MM' => __( 'Myanmar', 'profile-builder' ),
566 'NA' => __( 'Namibia', 'profile-builder' ),
567 'NR' => __( 'Nauru', 'profile-builder' ),
568 'NP' => __( 'Nepal', 'profile-builder' ),
569 'NL' => __( 'Netherlands', 'profile-builder' ),
570 'NC' => __( 'New Caledonia', 'profile-builder' ),
571 'NZ' => __( 'New Zealand', 'profile-builder' ),
572 'NI' => __( 'Nicaragua', 'profile-builder' ),
573 'NE' => __( 'Niger', 'profile-builder' ),
574 'NG' => __( 'Nigeria', 'profile-builder' ),
575 'NU' => __( 'Niue', 'profile-builder' ),
576 'NF' => __( 'Norfolk Island', 'profile-builder' ),
577 'KP' => __( 'North Korea', 'profile-builder' ),
578 'MP' => __( 'Northern Mariana Islands', 'profile-builder' ),
579 'NO' => __( 'Norway', 'profile-builder' ),
580 'OM' => __( 'Oman', 'profile-builder' ),
581 'PK' => __( 'Pakistan', 'profile-builder' ),
582 'PW' => __( 'Palau', 'profile-builder' ),
583 'PS' => __( 'Palestinian Territory', 'profile-builder' ),
584 'PA' => __( 'Panama', 'profile-builder' ),
585 'PG' => __( 'Papua New Guinea', 'profile-builder' ),
586 'PY' => __( 'Paraguay', 'profile-builder' ),
587 'PE' => __( 'Peru', 'profile-builder' ),
588 'PH' => __( 'Philippines', 'profile-builder' ),
589 'PN' => __( 'Pitcairn', 'profile-builder' ),
590 'PL' => __( 'Poland', 'profile-builder' ),
591 'PT' => __( 'Portugal', 'profile-builder' ),
592 'PR' => __( 'Puerto Rico', 'profile-builder' ),
593 'QA' => __( 'Qatar', 'profile-builder' ),
594 'CG' => __( 'Republic of the Congo', 'profile-builder' ),
595 'RE' => __( 'Reunion', 'profile-builder' ),
596 'RO' => __( 'Romania', 'profile-builder' ),
597 'RU' => __( 'Russia', 'profile-builder' ),
598 'RW' => __( 'Rwanda', 'profile-builder' ),
599 'BL' => __( 'Saint Barthelemy', 'profile-builder' ),
600 'SH' => __( 'Saint Helena', 'profile-builder' ),
601 'KN' => __( 'Saint Kitts and Nevis', 'profile-builder' ),
602 'LC' => __( 'Saint Lucia', 'profile-builder' ),
603 'MF' => __( 'Saint Martin', 'profile-builder' ),
604 'PM' => __( 'Saint Pierre and Miquelon', 'profile-builder' ),
605 'VC' => __( 'Saint Vincent and the Grenadines', 'profile-builder' ),
606 'WS' => __( 'Samoa', 'profile-builder' ),
607 'SM' => __( 'San Marino', 'profile-builder' ),
608 'ST' => __( 'Sao Tome and Principe', 'profile-builder' ),
609 'SA' => __( 'Saudi Arabia', 'profile-builder' ),
610 'SN' => __( 'Senegal', 'profile-builder' ),
611 'RS' => __( 'Serbia', 'profile-builder' ),
612 'SC' => __( 'Seychelles', 'profile-builder' ),
613 'SL' => __( 'Sierra Leone', 'profile-builder' ),
614 'SG' => __( 'Singapore', 'profile-builder' ),
615 'SX' => __( 'Sint Maarten', 'profile-builder' ),
616 'SK' => __( 'Slovakia', 'profile-builder' ),
617 'SI' => __( 'Slovenia', 'profile-builder' ),
618 'SB' => __( 'Solomon Islands', 'profile-builder' ),
619 'SO' => __( 'Somalia', 'profile-builder' ),
620 'ZA' => __( 'South Africa', 'profile-builder' ),
621 'GS' => __( 'South Georgia and the South Sandwich Islands', 'profile-builder' ),
622 'KR' => __( 'South Korea', 'profile-builder' ),
623 'SS' => __( 'South Sudan', 'profile-builder' ),
624 'ES' => __( 'Spain', 'profile-builder' ),
625 'LK' => __( 'Sri Lanka', 'profile-builder' ),
626 'SD' => __( 'Sudan', 'profile-builder' ),
627 'SR' => __( 'Suriname', 'profile-builder' ),
628 'SJ' => __( 'Svalbard and Jan Mayen', 'profile-builder' ),
629 'SZ' => __( 'Swaziland', 'profile-builder' ),
630 'SE' => __( 'Sweden', 'profile-builder' ),
631 'CH' => __( 'Switzerland', 'profile-builder' ),
632 'SY' => __( 'Syria', 'profile-builder' ),
633 'TW' => __( 'Taiwan', 'profile-builder' ),
634 'TJ' => __( 'Tajikistan', 'profile-builder' ),
635 'TZ' => __( 'Tanzania', 'profile-builder' ),
636 'TH' => __( 'Thailand', 'profile-builder' ),
637 'TG' => __( 'Togo', 'profile-builder' ),
638 'TK' => __( 'Tokelau', 'profile-builder' ),
639 'TO' => __( 'Tonga', 'profile-builder' ),
640 'TT' => __( 'Trinidad and Tobago', 'profile-builder' ),
641 'TN' => __( 'Tunisia', 'profile-builder' ),
642 'TR' => __( 'Turkey', 'profile-builder' ),
643 'TM' => __( 'Turkmenistan', 'profile-builder' ),
644 'TC' => __( 'Turks and Caicos Islands', 'profile-builder' ),
645 'TV' => __( 'Tuvalu', 'profile-builder' ),
646 'VI' => __( 'U.S. Virgin Islands', 'profile-builder' ),
647 'UG' => __( 'Uganda', 'profile-builder' ),
648 'UA' => __( 'Ukraine', 'profile-builder' ),
649 'AE' => __( 'United Arab Emirates', 'profile-builder' ),
650 'GB' => __( 'United Kingdom', 'profile-builder' ),
651 'US' => __( 'United States', 'profile-builder' ),
652 'UM' => __( 'United States Minor Outlying Islands', 'profile-builder' ),
653 'UY' => __( 'Uruguay', 'profile-builder' ),
654 'UZ' => __( 'Uzbekistan', 'profile-builder' ),
655 'VU' => __( 'Vanuatu', 'profile-builder' ),
656 'VA' => __( 'Vatican', 'profile-builder' ),
657 'VE' => __( 'Venezuela', 'profile-builder' ),
658 'VN' => __( 'Vietnam', 'profile-builder' ),
659 'WF' => __( 'Wallis and Futuna', 'profile-builder' ),
660 'EH' => __( 'Western Sahara', 'profile-builder' ),
661 'YE' => __( 'Yemen', 'profile-builder' ),
662 'ZM' => __( 'Zambia', 'profile-builder' ),
663 'ZW' => __( 'Zimbabwe', 'profile-builder' ),
664 )
665 );
666
667 return $country_array;
668 }
669
670
671 /**
672 * Function that returns an array with timezone options
673 *
674 * @since v.2.0
675 *
676 * @return array
677 */
678 function wppb_timezone_select_options( $form_location ) {
679 $timezone_array = apply_filters( 'wppb_'.$form_location.'_timezone_select_array', array ( '(GMT -12:00) Eniwetok, Kwajalein', '(GMT -11:00) Midway Island, Samoa', '(GMT -10:00) Hawaii', '(GMT -9:00) Alaska', '(GMT -8:00) Pacific Time (US & Canada)', '(GMT -7:00) Mountain Time (US & Canada)', '(GMT -6:00) Central Time (US & Canada), Mexico City', '(GMT -5:00) Eastern Time (US & Canada), Bogota, Lima', '(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz', '(GMT -3:30) Newfoundland', '(GMT -3:00) Brazil, Buenos Aires, Georgetown', '(GMT -2:00) Mid-Atlantic', '(GMT -1:00) Azores, Cape Verde Islands', '(GMT) Western Europe Time, London, Lisbon, Casablanca', '(GMT +1:00) Brussels, Copenhagen, Madrid, Paris', '(GMT +2:00) Kaliningrad, South Africa', '(GMT +3:00) Baghdad, Riyadh, Moscow, St. Petersburg', '(GMT +3:30) Tehran', '(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi', '(GMT +4:30) Kabul', '(GMT +5:00) Ekaterinburg, Islamabad, Karachi, Tashkent', '(GMT +5:30) Bombay, Calcutta, Madras, New Delhi', '(GMT +5:45) Kathmandu', '(GMT +6:00) Almaty, Dhaka, Colombo', '(GMT +7:00) Bangkok, Hanoi, Jakarta', '(GMT +8:00) Beijing, Perth, Singapore, Hong Kong', '(GMT +9:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk', '(GMT +9:30) Adelaide, Darwin', '(GMT +10:00) Eastern Australia, Guam, Vladivostok', '(GMT +11:00) Magadan, Solomon Islands, New Caledonia', '(GMT +12:00) Auckland, Wellington, Fiji, Kamchatka' ) );
680
681 return $timezone_array;
682 }
683
684
685 /*
686 * Array with the currency ISO code and associated currency name
687 *
688 * @param string $form_location
689 *
690 * @return array
691 *
692 */
693 function wppb_get_currencies( $form_location = '' ) {
694
695 $currencies = array(
696 'ALL' => __( 'Albania Lek', 'profile-builder' ),
697 'AFN' => __( 'Afghanistan Afghani', 'profile-builder' ),
698 'ARS' => __( 'Argentina Peso', 'profile-builder' ),
699 'AWG' => __( 'Aruba Guilder', 'profile-builder' ),
700 'AUD' => __( 'Australia Dollar', 'profile-builder' ),
701 'AZN' => __( 'Azerbaijan New Manat', 'profile-builder' ),
702 'BSD' => __( 'Bahamas Dollar', 'profile-builder' ),
703 'BBD' => __( 'Barbados Dollar','profile-builder' ),
704 'BDT' => __( 'Bangladeshi taka','profile-builder' ),
705 'BYR' => __( 'Belarus Ruble','profile-builder' ),
706 'BZD' => __( 'Belize Dollar','profile-builder' ),
707 'BMD' => __( 'Bermuda Dollar','profile-builder' ),
708 'BOB' => __( 'Bolivia Boliviano','profile-builder' ),
709 'BAM' => __( 'Bosnia and Herzegovina Convertible Marka','profile-builder' ),
710 'BWP' => __( 'Botswana Pula','profile-builder' ),
711 'BGN' => __( 'Bulgaria Lev','profile-builder' ),
712 'BRL' => __( 'Brazil Real','profile-builder' ),
713 'BND' => __( 'Brunei Darussalam Dollar','profile-builder' ),
714 'KHR' => __( 'Cambodia Riel','profile-builder' ),
715 'CAD' => __( 'Canada Dollar','profile-builder' ),
716 'KYD' => __( 'Cayman Islands Dollar','profile-builder' ),
717 'CLP' => __( 'Chile Peso','profile-builder' ),
718 'CNY' => __( 'China Yuan Renminbi','profile-builder' ),
719 'COP' => __( 'Colombia Peso','profile-builder' ),
720 'CRC' => __( 'Costa Rica Colon','profile-builder' ),
721 'HRK' => __( 'Croatia Kuna','profile-builder' ),
722 'CUP' => __( 'Cuba Peso','profile-builder' ),
723 'CZK' => __( 'Czech Republic Koruna','profile-builder' ),
724 'DKK' => __( 'Denmark Krone','profile-builder' ),
725 'DOP' => __( 'Dominican Republic Peso','profile-builder' ),
726 'XCD' => __( 'East Caribbean Dollar','profile-builder' ),
727 'EGP' => __( 'Egypt Pound','profile-builder' ),
728 'SVC' => __( 'El Salvador Colon','profile-builder' ),
729 'EEK' => __( 'Estonia Kroon','profile-builder' ),
730 'EUR' => __( 'Euro','profile-builder' ),
731 'FKP' => __( 'Falkland Islands (Malvinas) Pound','profile-builder' ),
732 'FJD' => __( 'Fiji Dollar','profile-builder' ),
733 'GHC' => __( 'Ghana Cedis','profile-builder' ),
734 'GIP' => __( 'Gibraltar Pound','profile-builder' ),
735 'GTQ' => __( 'Guatemala Quetzal','profile-builder' ),
736 'GGP' => __( 'Guernsey Pound','profile-builder' ),
737 'GYD' => __( 'Guyana Dollar','profile-builder' ),
738 'HNL' => __( 'Honduras Lempira','profile-builder' ),
739 'HKD' => __( 'Hong Kong Dollar','profile-builder' ),
740 'HUF' => __( 'Hungary Forint','profile-builder' ),
741 'ISK' => __( 'Iceland Krona','profile-builder' ),
742 'INR' => __( 'India Rupee','profile-builder' ),
743 'IDR' => __( 'Indonesia Rupiah','profile-builder' ),
744 'IRR' => __( 'Iran Rial','profile-builder' ),
745 'IMP' => __( 'Isle of Man Pound','profile-builder' ),
746 'ILS' => __( 'Israel Shekel','profile-builder' ),
747 'JMD' => __( 'Jamaica Dollar','profile-builder' ),
748 'JPY' => __( 'Japan Yen','profile-builder' ),
749 'JEP' => __( 'Jersey Pound','profile-builder' ),
750 'KZT' => __( 'Kazakhstan Tenge','profile-builder' ),
751 'KPW' => __( 'Korea (North) Won','profile-builder' ),
752 'KRW' => __( 'Korea (South) Won','profile-builder' ),
753 'KGS' => __( 'Kyrgyzstan Som','profile-builder' ),
754 'LAK' => __( 'Laos Kip','profile-builder' ),
755 'LVL' => __( 'Latvia Lat','profile-builder' ),
756 'LBP' => __( 'Lebanon Pound','profile-builder' ),
757 'LRD' => __( 'Liberia Dollar','profile-builder' ),
758 'LTL' => __( 'Lithuania Litas','profile-builder' ),
759 'MKD' => __( 'Macedonia Denar','profile-builder' ),
760 'MYR' => __( 'Malaysia Ringgit','profile-builder' ),
761 'MUR' => __( 'Mauritius Rupee','profile-builder' ),
762 'MXN' => __( 'Mexico Peso','profile-builder' ),
763 'MNT' => __( 'Mongolia Tughrik','profile-builder' ),
764 'MZN' => __( 'Mozambique Metical','profile-builder' ),
765 'NAD' => __( 'Namibia Dollar','profile-builder' ),
766 'NPR' => __( 'Nepal Rupee','profile-builder' ),
767 'ANG' => __( 'Netherlands Antilles Guilder','profile-builder' ),
768 'NZD' => __( 'New Zealand Dollar','profile-builder' ),
769 'NIO' => __( 'Nicaragua Cordoba','profile-builder' ),
770 'NGN' => __( 'Nigeria Naira','profile-builder' ),
771 'NOK' => __( 'Norway Krone','profile-builder' ),
772 'OMR' => __( 'Oman Rial', 'profile-builder' ),
773 'PKR' => __( 'Pakistan Rupee', 'profile-builder' ),
774 'PAB' => __( 'Panama Balboa', 'profile-builder' ),
775 'PYG' => __( 'Paraguay Guarani', 'profile-builder' ),
776 'PEN' => __( 'Peru Nuevo Sol', 'profile-builder' ),
777 'PHP' => __( 'Philippines Peso', 'profile-builder' ),
778 'PLN' => __( 'Poland Zloty', 'profile-builder' ),
779 'QAR' => __( 'Qatar Riyal', 'profile-builder' ),
780 'RON' => __( 'Romania New Leu', 'profile-builder' ),
781 'RUB' => __( 'Russia Ruble', 'profile-builder' ),
782 'SHP' => __( 'Saint Helena Pound', 'profile-builder' ),
783 'SAR' => __( 'Saudi Arabia Riyal', 'profile-builder' ),
784 'RSD' => __( 'Serbia Dinar', 'profile-builder' ),
785 'SCR' => __( 'Seychelles Rupee', 'profile-builder' ),
786 'SGD' => __( 'Singapore Dollar', 'profile-builder' ),
787 'SBD' => __( 'Solomon Islands Dollar', 'profile-builder' ),
788 'SOS' => __( 'Somalia Shilling', 'profile-builder' ),
789 'ZAR' => __( 'South Africa Rand', 'profile-builder' ),
790 'LKR' => __( 'Sri Lanka Rupee', 'profile-builder' ),
791 'SEK' => __( 'Sweden Krona', 'profile-builder' ),
792 'CHF' => __( 'Switzerland Franc', 'profile-builder' ),
793 'SRD' => __( 'Suriname Dollar', 'profile-builder' ),
794 'SYP' => __( 'Syria Pound', 'profile-builder' ),
795 'TWD' => __( 'Taiwan New Dollar', 'profile-builder' ),
796 'THB' => __( 'Thailand Baht', 'profile-builder' ),
797 'TTD' => __( 'Trinidad and Tobago Dollar', 'profile-builder' ),
798 'TRY' => __( 'Turkey Lira', 'profile-builder' ),
799 'TRL' => __( 'Turkey Lira', 'profile-builder' ),
800 'TVD' => __( 'Tuvalu Dollar', 'profile-builder' ),
801 'UAH' => __( 'Ukraine Hryvna', 'profile-builder' ),
802 'GBP' => __( 'United Kingdom Pound', 'profile-builder' ),
803 'UGX' => __( 'Uganda Shilling', 'profile-builder' ),
804 'USD' => __( 'US Dollar', 'profile-builder' ),
805 'UYU' => __( 'Uruguay Peso', 'profile-builder' ),
806 'UZS' => __( 'Uzbekistan Som', 'profile-builder' ),
807 'VEF' => __( 'Venezuela Bolivar', 'profile-builder' ),
808 'VND' => __( 'Viet Nam Dong', 'profile-builder' ),
809 'YER' => __( 'Yemen Rial', 'profile-builder' ),
810 'ZWD' => __( 'Zimbabwe Dollar', 'profile-builder' )
811 );
812
813 $filter_name = ( empty( $form_location ) ? 'wppb_get_currencies' : 'wppb_get_currencies_' . $form_location );
814
815 return apply_filters( $filter_name, $currencies );
816
817 }
818
819
820 /*
821 * Returns the currency symbol for a given currency code
822 *
823 * @param string $currency_code
824 *
825 * @return string
826 *
827 */
828 function wppb_get_currency_symbol( $currency_code ) {
829
830 $currency_symbols = array(
831 'AED' => '&#1583;.&#1573;', // ?
832 'AFN' => '&#65;&#102;',
833 'ALL' => '&#76;&#101;&#107;',
834 'AMD' => '',
835 'ANG' => '&#402;',
836 'AOA' => '&#75;&#122;', // ?
837 'ARS' => '&#36;',
838 'AUD' => '&#36;',
839 'AWG' => '&#402;',
840 'AZN' => '&#1084;&#1072;&#1085;',
841 'BAM' => '&#75;&#77;',
842 'BBD' => '&#36;',
843 'BDT' => '&#2547;', // ?
844 'BGN' => '&#1083;&#1074;',
845 'BHD' => '.&#1583;.&#1576;', // ?
846 'BIF' => '&#70;&#66;&#117;', // ?
847 'BMD' => '&#36;',
848 'BND' => '&#36;',
849 'BOB' => '&#36;&#98;',
850 'BRL' => '&#82;&#36;',
851 'BSD' => '&#36;',
852 'BTN' => '&#78;&#117;&#46;', // ?
853 'BWP' => '&#80;',
854 'BYR' => '&#112;&#46;',
855 'BZD' => '&#66;&#90;&#36;',
856 'CAD' => '&#36;',
857 'CDF' => '&#70;&#67;',
858 'CHF' => '&#67;&#72;&#70;',
859 'CLF' => '', // ?
860 'CLP' => '&#36;',
861 'CNY' => '&#165;',
862 'COP' => '&#36;',
863 'CRC' => '&#8353;',
864 'CUP' => '&#8396;',
865 'CVE' => '&#36;', // ?
866 'CZK' => '&#75;&#269;',
867 'DJF' => '&#70;&#100;&#106;', // ?
868 'DKK' => '&#107;&#114;',
869 'DOP' => '&#82;&#68;&#36;',
870 'DZD' => '&#1583;&#1580;', // ?
871 'EGP' => '&#163;',
872 'ETB' => '&#66;&#114;',
873 'EUR' => '&#8364;',
874 'FJD' => '&#36;',
875 'FKP' => '&#163;',
876 'GBP' => '&#163;',
877 'GEL' => '&#4314;', // ?
878 'GHS' => '&#162;',
879 'GIP' => '&#163;',
880 'GMD' => '&#68;', // ?
881 'GNF' => '&#70;&#71;', // ?
882 'GTQ' => '&#81;',
883 'GYD' => '&#36;',
884 'HKD' => '&#36;',
885 'HNL' => '&#76;',
886 'HRK' => '&#107;&#110;',
887 'HTG' => '&#71;', // ?
888 'HUF' => '&#70;&#116;',
889 'IDR' => '&#82;&#112;',
890 'ILS' => '&#8362;',
891 'INR' => '&#8377;',
892 'IQD' => '&#1593;.&#1583;', // ?
893 'IRR' => '&#65020;',
894 'ISK' => '&#107;&#114;',
895 'JEP' => '&#163;',
896 'JMD' => '&#74;&#36;',
897 'JOD' => '&#74;&#68;', // ?
898 'JPY' => '&#165;',
899 'KES' => '&#75;&#83;&#104;', // ?
900 'KGS' => '&#1083;&#1074;',
901 'KHR' => '&#6107;',
902 'KMF' => '&#67;&#70;', // ?
903 'KPW' => '&#8361;',
904 'KRW' => '&#8361;',
905 'KWD' => '&#1583;.&#1603;', // ?
906 'KYD' => '&#36;',
907 'KZT' => '&#1083;&#1074;',
908 'LAK' => '&#8365;',
909 'LBP' => '&#163;',
910 'LKR' => '&#8360;',
911 'LRD' => '&#36;',
912 'LSL' => '&#76;', // ?
913 'LTL' => '&#76;&#116;',
914 'LVL' => '&#76;&#115;',
915 'LYD' => '&#1604;.&#1583;', // ?
916 'MAD' => '&#1583;.&#1605;.', //?
917 'MDL' => '&#76;',
918 'MGA' => '&#65;&#114;', // ?
919 'MKD' => '&#1076;&#1077;&#1085;',
920 'MMK' => '&#75;',
921 'MNT' => '&#8366;',
922 'MOP' => '&#77;&#79;&#80;&#36;', // ?
923 'MRO' => '&#85;&#77;', // ?
924 'MUR' => '&#8360;', // ?
925 'MVR' => '.&#1923;', // ?
926 'MWK' => '&#77;&#75;',
927 'MXN' => '&#36;',
928 'MYR' => '&#82;&#77;',
929 'MZN' => '&#77;&#84;',
930 'NAD' => '&#36;',
931 'NGN' => '&#8358;',
932 'NIO' => '&#67;&#36;',
933 'NOK' => '&#107;&#114;',
934 'NPR' => '&#8360;',
935 'NZD' => '&#36;',
936 'OMR' => '&#65020;',
937 'PAB' => '&#66;&#47;&#46;',
938 'PEN' => '&#83;&#47;&#46;',
939 'PGK' => '&#75;', // ?
940 'PHP' => '&#8369;',
941 'PKR' => '&#8360;',
942 'PLN' => '&#122;&#322;',
943 'PYG' => '&#71;&#115;',
944 'QAR' => '&#65020;',
945 'RON' => '&#108;&#101;&#105;',
946 'RSD' => '&#1044;&#1080;&#1085;&#46;',
947 'RUB' => '&#1088;&#1091;&#1073;',
948 'RWF' => '&#1585;.&#1587;',
949 'SAR' => '&#65020;',
950 'SBD' => '&#36;',
951 'SCR' => '&#8360;',
952 'SDG' => '&#163;', // ?
953 'SEK' => '&#107;&#114;',
954 'SGD' => '&#36;',
955 'SHP' => '&#163;',
956 'SLL' => '&#76;&#101;', // ?
957 'SOS' => '&#83;',
958 'SRD' => '&#36;',
959 'STD' => '&#68;&#98;', // ?
960 'SVC' => '&#36;',
961 'SYP' => '&#163;',
962 'SZL' => '&#76;', // ?
963 'THB' => '&#3647;',
964 'TJS' => '&#84;&#74;&#83;', // ? TJS (guess)
965 'TMT' => '&#109;',
966 'TND' => '&#1583;.&#1578;',
967 'TOP' => '&#84;&#36;',
968 'TRY' => '&#8356;', // New Turkey Lira (old symbol used)
969 'TTD' => '&#36;',
970 'TWD' => '&#78;&#84;&#36;',
971 'TZS' => '',
972 'UAH' => '&#8372;',
973 'UGX' => '&#85;&#83;&#104;',
974 'USD' => '&#36;',
975 'UYU' => '&#36;&#85;',
976 'UZS' => '&#1083;&#1074;',
977 'VEF' => '&#66;&#115;',
978 'VND' => '&#8363;',
979 'VUV' => '&#86;&#84;',
980 'WST' => '&#87;&#83;&#36;',
981 'XAF' => '&#70;&#67;&#70;&#65;',
982 'XCD' => '&#36;',
983 'XDR' => '',
984 'XOF' => '',
985 'XPF' => '&#70;',
986 'YER' => '&#65020;',
987 'ZAR' => '&#82;',
988 'ZMK' => '&#90;&#75;', // ?
989 'ZWL' => '&#90;&#36;',
990 );
991
992 if( !empty( $currency_symbols[$currency_code] ) )
993 return $currency_symbols[$currency_code];
994 else
995 return '';
996
997 }
998
999
1000 /**
1001 * Function that returns a unique, incremented ID
1002 *
1003 * @since v.2.0
1004 *
1005 * @return integer id
1006 */
1007 function wppb_get_unique_id(){
1008 $id = 1;
1009 $wppb_manage_fields = get_option( 'wppb_manage_fields', 'not_found' );
1010 if ( ( $wppb_manage_fields === 'not_found' ) || ( empty( $wppb_manage_fields ) ) ){
1011 return $id;
1012 }
1013 else{
1014 $ids_array = array();
1015 foreach( $wppb_manage_fields as $value ){
1016 $ids_array[] = $value['id'];
1017 }
1018 if( !empty( $ids_array ) ){
1019 rsort( $ids_array );
1020 $id = $ids_array[0] + 1;
1021 }
1022 }
1023 return apply_filters( 'wppb_field_unique_id', $id, $ids_array, $wppb_manage_fields );
1024 }
1025
1026 /**
1027 * Function that checks to see if the id is unique when saving the new field
1028 *
1029 * @param array $values
1030 *
1031 * @return array
1032 */
1033 function wppb_check_unique_id_on_saving( $values ) {
1034 $wppb_manage_fields = get_option( 'wppb_manage_fields', 'not_found' );
1035
1036 if( $wppb_manage_fields != 'not_found' ) {
1037
1038 $ids_array = array();
1039 foreach( $wppb_manage_fields as $field ){
1040 $ids_array[] = $field['id'];
1041 }
1042
1043 if( in_array( $values['id'], $ids_array ) ) {
1044 rsort( $ids_array );
1045 $values['id'] = $ids_array[0] + 1;
1046 }
1047
1048 }
1049 return $values;
1050 }
1051 add_filter( 'wck_add_meta_filter_values_wppb_manage_fields', 'wppb_check_unique_id_on_saving' );
1052
1053
1054 function wppb_return_unique_field_list( $only_default_fields = false ){
1055
1056 $unique_field_list[] = 'Default - Name (Heading)';
1057 $unique_field_list[] = 'Default - Contact Info (Heading)';
1058 $unique_field_list[] = 'Default - About Yourself (Heading)';
1059 $unique_field_list[] = 'Default - Username';
1060 $unique_field_list[] = 'Default - First Name';
1061 $unique_field_list[] = 'Default - Last Name';
1062 $unique_field_list[] = 'Default - Nickname';
1063 $unique_field_list[] = 'Default - E-mail';
1064 $unique_field_list[] = 'Default - Website';
1065
1066 // Default contact methods were removed in WP 3.6. A filter dictates contact methods.
1067 if ( apply_filters( 'wppb_remove_default_contact_methods', get_site_option( 'initial_db_version' ) < 23588 ) ){
1068 $unique_field_list[] = 'Default - AIM';
1069 $unique_field_list[] = 'Default - Yahoo IM';
1070 $unique_field_list[] = 'Default - Jabber / Google Talk';
1071 }
1072
1073 $unique_field_list[] = 'Default - Password';
1074 $unique_field_list[] = 'Default - Repeat Password';
1075 $unique_field_list[] = 'Default - Biographical Info';
1076 $unique_field_list[] = 'Default - Display name publicly as';
1077
1078 $unique_field_list[] = 'GDPR Checkbox';
1079
1080 $unique_field_list[] = 'Email Confirmation';
1081
1082 if ( wppb_can_users_signup_blog() ) {
1083 $unique_field_list[] = 'Default - Blog Details';
1084 }
1085
1086 if( !$only_default_fields ){
1087 $unique_field_list[] = 'Avatar';
1088 $unique_field_list[] = 'reCAPTCHA';
1089 $unique_field_list[] = 'Select (User Role)';
1090 $unique_field_list[] = 'Map';
1091 }
1092
1093 return apply_filters ( 'wppb_unique_field_list', $unique_field_list );
1094 }
1095
1096
1097 /**
1098 * Function that checks several things when adding/editing the fields
1099 *
1100 * @since v.2.0
1101 *
1102 * @param string $message - the message to be displayed
1103 * @param array $fields - the added fields
1104 * @param array $required_fields
1105 * @param string $meta - the meta-name of the option
1106 * @param string $values - The values entered for each option
1107 * @param integer $post_id
1108 * @return boolean
1109 */
1110 function wppb_check_field_on_edit_add( $message, $fields, $required_fields, $meta_name, $posted_values, $post_id ){
1111 global $wpdb;
1112
1113 if ( $meta_name == 'wppb_manage_fields' ){
1114
1115 // check for a valid field-type (fallback)
1116 if ( $posted_values['field'] == '' )
1117 $message .= __( "You must select a field\n", 'profile-builder' );
1118 // END check for a valid field-type (fallback)
1119
1120 $unique_field_list = wppb_return_unique_field_list();
1121 $all_fields = apply_filters( 'wppb_manage_fields_check_field_on_edit_add', get_option ( $meta_name, 'not_set' ), $posted_values );
1122
1123 // check if the unique fields are only added once
1124 if( $all_fields != 'not_set' ){
1125 foreach( $all_fields as $field ){
1126 if ( ( in_array ( $posted_values['field'], $unique_field_list ) ) && ( $posted_values['field'] == $field['field'] ) && ( $posted_values['id'] != $field['id'] ) ){
1127 $message .= __( "Please choose a different field type as this one already exists in your form (must be unique)\n", 'profile-builder' );
1128 break;
1129 }
1130 }
1131 }
1132 // END check if the unique fields are only added once
1133
1134 // check for avatar size
1135 if ( $posted_values['field'] == 'Avatar' ){
1136 if ( is_numeric( $posted_values['avatar-size'] ) ){
1137 if ( ( $posted_values['avatar-size'] < 20 ) || ( $posted_values['avatar-size'] > 200 ) )
1138 $message .= __( "The entered avatar size is not between 20 and 200\n", 'profile-builder' );
1139
1140 }else
1141 $message .= __( "The entered avatar size is not numerical\n", 'profile-builder' );
1142
1143 }
1144 // END check for avatar size
1145
1146 // check for correct row value
1147 if ( ( $posted_values['field'] == 'Default - Biographical Info' ) || ( $posted_values['field'] == 'Textarea' ) ){
1148 if ( !is_numeric( $posted_values['row-count'] ) )
1149 $message .= __( "The entered row number is not numerical\n", 'profile-builder' );
1150
1151 elseif ( trim( $posted_values['row-count'] ) == '' )
1152 $message .= __( "You must enter a value for the row number\n", 'profile-builder' );
1153 }
1154 // END check for correct row value
1155
1156
1157 // check for the public and private keys
1158 if ( $posted_values['field'] == 'reCAPTCHA'){
1159 if ( trim( $posted_values['public-key'] ) == '' )
1160 $message .= __( "You must enter the site key\n", 'profile-builder' );
1161 if ( trim( $posted_values['private-key'] ) == '' )
1162 $message .= __( "You must enter the secret key\n", 'profile-builder' );
1163 }
1164 // END check for the public and private keys
1165
1166 // check for the correct the date-format
1167 if ( $posted_values['field'] == 'Datepicker' ){
1168 $date_format = trim( $posted_values['date-format'] );
1169 if( empty( $date_format ) )
1170 $message .= __( "You must enter a value for the date-format\n", 'profile-builder' );
1171 else {
1172 $date_format = preg_split("/(, | |\/|-|\.|,)/", $date_format );
1173 $valid_pieces = array('d', 'dd', 'D', 'DD', 'o', 'oo', 'm', 'mm', 'M', 'MM', 'y', 'yy', '@');
1174 if ($date_format) {
1175 $invalid_format = false;
1176 foreach ($date_format as $piece) {
1177 if (!in_array($piece, $valid_pieces)) {
1178 $invalid_format = true;
1179 break;
1180 }
1181 }
1182
1183 if ($invalid_format)
1184 $message .= __("The entered value for the Datepicker is not a valid date-format\n", 'profile-builder');
1185 }
1186 }
1187
1188 }
1189 // END check for the correct the date-format
1190
1191 //check for empty meta-name and duplicate meta-name
1192 if ( $posted_values['overwrite-existing'] == 'No' ){
1193 $skip_check_for_fields = wppb_return_unique_field_list(true);
1194 $skip_check_for_fields = apply_filters ( 'wppb_skip_check_for_fields', $skip_check_for_fields );
1195
1196 if ( !in_array( trim( $posted_values['field'] ), $skip_check_for_fields ) ){
1197 $reserved_meta_name_list = wppb_get_reserved_meta_name_list( $all_fields, $posted_values );
1198
1199 //check to see if meta-name is empty
1200 $skip_empty_check_for_fields = array( 'Heading', 'Select (User Role)', 'reCAPTCHA', 'HTML', 'GDPR Delete Button' );
1201
1202 if( !in_array( $posted_values['field'], $skip_empty_check_for_fields ) && empty( $posted_values['meta-name'] ) ) {
1203 $message .= __( "The meta-name cannot be empty\n", 'profile-builder' );
1204 }
1205
1206 //check if the meta-name starts or ends with a space
1207 if ( strpos( $posted_values['meta-name'], " " ) === 0 ) {
1208 $message .= __( "The meta-name cannot begin with a space\n", 'profile-builder' );
1209 }
1210 if ( strpos( $posted_values['meta-name'], " " ) === strlen( $posted_values['meta-name'] ) - 1 ) {
1211 $message .= __( "The meta-name cannot end with a space\n", 'profile-builder' );
1212 }
1213
1214 // meta names that are reserved and cannot be used as part of other meta names
1215 $reserved_meta_name_list_strict = apply_filters( 'wppb_unique_meta_name_list_strict', array( 'map' ) );
1216 // skip meta name check for these fields
1217 $skip_unique_meta_name_list_check = apply_filters( 'wppb_skip_unique_meta_name_list_check', array( 'Map', 'Honeypot' ) );
1218
1219 // if the desired meta name is in the restricted list or if one of the meta names in the strictly
1220 // restricted list is part of it display an error message
1221 $is_reserved_meta_name = false;
1222 $trimmed_meta_name = trim( $posted_values['meta-name'] );
1223 if ( !in_array( $posted_values['field'], $skip_unique_meta_name_list_check ) ) {
1224 foreach ($reserved_meta_name_list as $reserved_meta_name) {
1225 if (in_array($trimmed_meta_name, $reserved_meta_name_list) ||
1226 (strpos($trimmed_meta_name, $reserved_meta_name) !== false && in_array($reserved_meta_name, $reserved_meta_name_list_strict))) {
1227 $is_reserved_meta_name = true;
1228 break;
1229 }
1230 }
1231 }
1232 if ( $is_reserved_meta_name )
1233 $message .= __( "That meta-name can't be used, please choose another\n", 'profile-builder' );
1234
1235 else{
1236 $found_in_custom_fields = false;
1237
1238 if( $all_fields != 'not_set' )
1239 foreach( $all_fields as $field ){
1240 if ( $posted_values['meta-name'] != '' && ( $field['meta-name'] == $posted_values['meta-name'] ) && ( $field['id'] != $posted_values['id'] ) ){
1241 $message .= __( "That meta-name is already in use\n", 'profile-builder' );
1242 $found_in_custom_fields = true;
1243
1244 }elseif ( ( $field['meta-name'] == $posted_values['meta-name'] ) && ( $field['id'] == $posted_values['id'] ) )
1245 $found_in_custom_fields = true;
1246 }
1247
1248 if ( $found_in_custom_fields === false ){
1249 if( $posted_values['meta-name'] != '' ) {
1250 $found_meta_name = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE meta_key = %s", $posted_values['meta-name']));
1251 if ($found_meta_name != null)
1252 $message .= __("That meta-name is already in use\n", 'profile-builder');
1253 }
1254 }
1255 }
1256 }
1257 }
1258 //END check duplicate meta-name
1259
1260 // check for correct meta name on upload field
1261 if( $posted_values['field'] == 'Upload' ) {
1262 if( ! empty( $posted_values['meta-name'] ) && preg_match( '/([^a-z\d_-])/', $posted_values['meta-name'] ) ) {
1263 $message .= __( "The meta-name can only contain lowercase letters, numbers, _ , - and no spaces.\n", 'profile-builder' );
1264 }
1265 }
1266 // END check for correct meta name on upload field
1267
1268 // check for valid default option (checkbox, select, radio)
1269 if ( ( $posted_values['field'] == 'Checkbox' ) || ( $posted_values['field'] == 'Select (Multiple)' ) ) {
1270 $options = array_map( 'trim', explode( ',', $posted_values['options'] ) );
1271 $default_options = ( ( trim( $posted_values['default-options'] ) == '' ) ? array() : array_map( 'trim', explode( ',', $posted_values['default-options'] ) ) );
1272
1273 /* echo "<script>console.log( Posted options: " . print_r($options, true) . "' );</script>";
1274 echo "<script>console.log( Default options: " . print_r($default_options, true) . "' );</script>"; */
1275
1276 $not_found = '';
1277 foreach ( $default_options as $key => $value ){
1278 if ( !in_array( $value, $options ) )
1279 $not_found .= $value . ', ';
1280 }
1281
1282 if ( $not_found != '' )
1283 $message .= sprintf( __( "The following option(s) did not coincide with the ones in the options list: %s\n", 'profile-builder' ), trim( $not_found, ', ' ) );
1284
1285 }elseif ( ( $posted_values['field'] == 'Radio' ) || ( $posted_values['field'] == 'Select' ) ){
1286 if ( ( trim( $posted_values['default-option'] ) != '' ) && ( !in_array( $posted_values['default-option'], array_map( 'trim', explode( ',', $posted_values['options'] ) ) ) ) )
1287 $message .= sprintf( __( "The following option did not coincide with the ones in the options list: %s\n", 'profile-builder' ), $posted_values['default-option'] );
1288 }
1289 // END check for valid default option (checkbox, select, radio)
1290
1291 // check to see if any user role is selected (user-role field)
1292 if( $posted_values['field'] == 'Select (User Role)' ) {
1293 if( empty( $posted_values['user-roles'] ) ) {
1294 $message .= __( "Please select at least one user role\n", 'profile-builder' );
1295 }
1296 }
1297 // END check to see if Administrator user role has been selected (user-role field)
1298
1299 $message = apply_filters( 'wppb_check_extra_manage_fields', $message, $posted_values );
1300
1301 }elseif ( ( $meta_name == 'wppb_rf_fields' ) || ( $meta_name == 'wppb_epf_fields' ) ){
1302 if ( $posted_values['field'] == '' ){
1303 $message .= __( "You must select a field\n", 'profile-builder' );
1304
1305 }else{
1306 $fields_so_far = get_post_meta ( $post_id, $meta_name, true );
1307 if ( !empty($fields_so_far) ){
1308 foreach ( $fields_so_far as $key => $value ){
1309 if ( $value['id'] == $posted_values['id'] )
1310 $message .= __( "That field is already added in this form\n", 'profile-builder' );
1311 }
1312 }
1313 }
1314 }
1315 return $message;
1316 }
1317 add_filter( 'wck_extra_message', 'wppb_check_field_on_edit_add', 10, 6 );
1318
1319
1320 /**
1321 * Function that calls the wppb_hide_properties_for_already_added_fields and wppb_enable_select2 after a field-update
1322 *
1323 * @since v.2.0
1324 *
1325 * @param void
1326 *
1327 * @return string
1328 */
1329 function wppb_manage_fields_after_refresh_list( $id ){
1330 echo "<script type=\"text/javascript\">wppb_hide_properties_for_already_added_fields( '#container_wppb_manage_fields' );</script>";
1331 echo "<script type=\"text/javascript\">wppb_enable_select2( '#wppb_manage_fields' );</script>";
1332
1333 }
1334 add_action( "wck_refresh_list_wppb_manage_fields", "wppb_manage_fields_after_refresh_list" );
1335 add_action( "wck_refresh_entry_wppb_manage_fields", "wppb_manage_fields_after_refresh_list" );
1336
1337 /**
1338 * Function that calls the wppb_hide_all and wppb_enable_select2
1339 *
1340 * @since v.2.0
1341 *
1342 * @param void
1343 *
1344 * @return string
1345 */
1346 function wppb_manage_fields_after_ajax_add_field( $id ){
1347 echo "<script type=\"text/javascript\">wppb_hide_all( '#wppb_manage_fields' );</script>";
1348 echo "<script type=\"text/javascript\">wppb_enable_select2( '#wppb_manage_fields' );</script>";
1349 }
1350 add_action("wck_ajax_add_form_wppb_manage_fields", "wppb_manage_fields_after_ajax_add_field" );
1351
1352 /**
1353 * Function that modifies the table header in Manage Fields to add Field Name, Field Type, Meta Key, Required
1354 *
1355 * @since v.2.0
1356 *
1357 * @param $list, $id
1358 *
1359 * @return string
1360 */
1361 function wppb_manage_fields_header( $list_header ){
1362 return '<thead><tr><th class="wck-number">#</th><th class="wck-content">'. __( '<pre>Title</pre><pre>Type</pre><pre>Meta Name</pre><pre class="wppb-mb-head-required">Required</pre>', 'profile-builder' ) .'</th><th class="wck-edit">'. __( 'Edit', 'profile-builder' ) .'</th><th class="wck-delete">'. __( 'Delete', 'profile-builder' ) .'</th></tr></thead>';
1363 }
1364 add_action( 'wck_metabox_content_header_wppb_manage_fields', 'wppb_manage_fields_header' );
1365
1366 /**
1367 * Add contextual help to the side of manage fields for the shortcodes
1368 *
1369 * @since v.2.0
1370 *
1371 * @param $hook
1372 *
1373 * @return string
1374 */
1375 function wppb_add_content_before_manage_fields(){
1376 ?>
1377 <p><?php esc_html_e('Use these shortcodes on the pages you want the forms to be displayed:', 'profile-builder'); ?></p>
1378 <ul>
1379 <li><strong class="nowrap">[wppb-register]</strong></li>
1380 <li><strong class="nowrap">[wppb-edit-profile]</strong></li>
1381 <li><strong class="nowrap">[wppb-register role="author"]</strong></li>
1382 </ul>
1383 <p>
1384 <?php
1385 if( PROFILE_BUILDER == 'Profile Builder Pro' )
1386 esc_html_e("If you're interested in displaying different fields in the registration and edit profile forms, please use the Multiple Registration & Edit Profile Forms Add-ons.", 'profile-builder');
1387 else
1388 esc_html_e( "With Profile Builder Pro you can display different fields in the registration and edit profile forms, using the Multiple Registration & Edit Profile Forms add-on.", "profile-builder" )
1389 ?>
1390 </p>
1391 <?php
1392 }
1393 add_action('wck_metabox_content_wppb_manage_fields_info', 'wppb_add_content_before_manage_fields');
1394
1395
1396 /**
1397 * Function that calls the wppb_edit_form_properties
1398 *
1399 * @since v.2.0
1400 *
1401 * @param void
1402 *
1403 * @return string
1404 */
1405 function wppb_remove_properties_from_added_form( $meta_name, $id, $element_id ){
1406 if ( ( $meta_name == 'wppb_epf_fields' ) || ( $meta_name == 'wppb_rf_fields' ) )
1407 echo "<script type=\"text/javascript\">wppb_disable_delete_on_default_mandatory_fields();</script>";
1408
1409 if ( $meta_name == 'wppb_manage_fields' ) {
1410 echo "<script type=\"text/javascript\">wppb_edit_form_properties( '#container_wppb_manage_fields', 'update_container_wppb_manage_fields_" . esc_attr( $element_id ) . "' );</script>";
1411 echo "<script type=\"text/javascript\">wppb_enable_select2( '#container_wppb_manage_fields' );</script>";
1412 }
1413 }
1414 add_action("wck_after_adding_form", "wppb_remove_properties_from_added_form", 10, 3);
1415
1416 /*
1417 * WPML Support for dynamic strings in Profile Builder. Tags: WPML, fields, translate
1418 */
1419 add_filter( 'update_option_wppb_manage_fields', 'wppb_wpml_compat_with_fields', 10, 2 );
1420 function wppb_wpml_compat_with_fields( $oldvalue, $_newvalue ){
1421 $default_fields = array(
1422 'Default - Name (Heading)',
1423 'Default - Contact Info (Heading)',
1424 'Default - About Yourself (Heading)',
1425 'Default - Username',
1426 'Default - First Name',
1427 'Default - Last Name',
1428 'Default - Nickname',
1429 'Default - E-mail',
1430 'Default - Website',
1431 'Default - AIM',
1432 'Default - Yahoo IM',
1433 'Default - Jabber / Google Talk',
1434 'Default - Password',
1435 'Default - Repeat Password',
1436 'Default - Biographical Info',
1437 'Default - Blog Details',
1438 'Default - Display name publicly as'
1439 );
1440
1441 if ( is_array( $_newvalue ) ){
1442 foreach ( $_newvalue as $field ){
1443 if ( in_array($field['field'], $default_fields) ){
1444 $prefix = 'default_field_';
1445 } else {
1446 $prefix = 'custom_field_';
1447 }
1448 if (function_exists('icl_register_string')){
1449 if( !empty( $field['field-title'] ) )
1450 icl_register_string('plugin profile-builder-pro', $prefix . $field['id'].'_title_translation' , $field['field-title'] );
1451 if( !empty( $field['description'] ) )
1452 icl_register_string('plugin profile-builder-pro', $prefix . $field['id'].'_description_translation', $field['description'] );
1453 if( !empty( $field['labels'] ) )
1454 icl_register_string('plugin profile-builder-pro', $prefix . $field['id'].'_labels_translation', $field['labels'] );
1455 if( !empty( $field['default-value'] ) )
1456 icl_register_string('plugin profile-builder-pro', $prefix . $field['id'].'_default_value_translation', $field['default-value'] );
1457 if( !empty( $field['default-content'] ) )
1458 icl_register_string('plugin profile-builder-pro', $prefix . $field['id'].'_default_content_translation', $field['default-content'] );
1459 if( !empty( $field['html-content'] ) )
1460 icl_register_string('plugin profile-builder-pro', $prefix . $field['id'].'_html_content_translation', $field['html-content'] );
1461 }
1462 }
1463 }
1464 }
1465
1466
1467 /*
1468 * Returns the HTML for a map given the field
1469 *
1470 */
1471 function wppb_get_map_output( $field, $args ) {
1472
1473 $defaults = array(
1474 'markers' => array(),
1475 'editable' => true,
1476 'show_search' => true,
1477 'extra_attr' => ''
1478 );
1479
1480 $args = wp_parse_args( $args, $defaults );
1481
1482 $return = '';
1483
1484 // Search box
1485 // The style:left=-99999px is set to hide the input from the viewport. It will be rewritten when the map gets initialised
1486 if ( $args['show_search'] ) {
1487 $return .= '<input style="left: -99999px" type="text" id="' . $field['meta-name'] . '-search-box" class="wppb-map-search-box" placeholder="' . __( 'Search Location', 'profile-builder' ) . '" />';
1488 }
1489
1490 $lng = ( ! empty( $field['map-default-lng'] ) ) ? (float) $field['map-default-lng'] : WPPB_DEFAULTS_MAP_LNG;
1491 $lat = ( ! empty( $field['map-default-lat'] ) ) ? (float) $field['map-default-lat'] : WPPB_DEFAULTS_MAP_LAT;
1492 $zoom = ( ! empty( $field['map-default-zoom'] ) ) ? (int) $field['map-default-zoom'] : WPPB_DEFAULTS_MAP_ZOOM;
1493
1494 // Get one time the settings.
1495 $settings = wppb_options_get_map_settings();
1496 $pin_info = ( ! empty( $args['user_id'] ) ) ? wppb_compute_simple_pin_content_for_user( $args['user_id'], $settings ) : '';
1497
1498 // Map container.
1499 $return .= '<div id="' . $field['meta-name'] . '" class="wppb-map-container" style="height: ' . $field['map-height'] . 'px;" data-editable="' . ( $args['editable'] ? 1 : 0 ) . '" data-default-zoom="' . $zoom . '" data-default-lat="' . $lat . '" data-default-lng="' . $lng . '" ' . $args['extra_attr'] . '></div>';
1500
1501 if ( ! empty( $args['markers'] ) ) {
1502 foreach ( $args['markers'] as $marker ) {
1503 if ( ! empty( $args['user_id'] ) ) {
1504 // Also compute the marker bubble content.
1505 $bubble = wppb_get_user_pin_bubble(
1506 $args['user_id'],
1507 strstr( $marker, ',', true ),
1508 ltrim( strstr( $marker, ',' ), ',' ),
1509 $pin_info,
1510 ''
1511 );
1512 $return .= $bubble;
1513 }
1514
1515 $return .= '<input name="' . $field['meta-name'] . '[]" type="hidden" class="wppb-map-marker" value="' . $marker . '" />';
1516 }
1517 }
1518
1519 return $return;
1520 }
1521
1522
1523 /*
1524 * Returns all the saved markers for a map field for a particular user
1525 *
1526 */
1527 function wppb_get_user_map_markers( $user_id, $meta_name ) {
1528
1529 global $wpdb;
1530
1531 $meta_name_underlined = $meta_name . '_';
1532
1533 $results = $wpdb->get_results( "SELECT meta_value, meta_key FROM {$wpdb->usermeta} WHERE user_id={$user_id} AND meta_key LIKE '%{$meta_name_underlined}%'", ARRAY_N );
1534
1535 $markers = array();
1536 $i = 0;
1537
1538 foreach( $results as $key => $result ) {
1539 $pattern = '/^' . $meta_name . '_[0-9]+(_[0-9]+)*$/';
1540 preg_match( $pattern, $result[1], $matches );
1541 if ( count ($matches) > 0 ) {
1542 $markers[$i] = $result[0];
1543 $i++;
1544 }
1545
1546 }
1547 return $markers;
1548
1549 }
1550
1551 /*
1552 * Deletes from the database all saved markers
1553 *
1554 */
1555 function wppb_delete_user_map_markers( $user_id, $meta_name ) {
1556
1557 global $wpdb;
1558
1559 $delete = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->usermeta} WHERE user_id=%d AND meta_key REGEXP %s", $user_id, $meta_name . '_[0-9]' ) );
1560
1561 wp_cache_delete( $user_id, 'user_meta' );
1562
1563 }
1564
1565
1566 if ( ! function_exists( 'wppb_options_get_map_settings' ) ) {
1567 /**
1568 * Get all the map related attributes.
1569 *
1570 * @return string
1571 */
1572 function wppb_options_get_map_settings() {
1573 $manage_fields = apply_filters(
1574 'wppb_form_fields',
1575 get_option( 'wppb_manage_fields', 'not_set' ),
1576 array( 'context' => 'map_api_key' )
1577 );
1578 foreach ( $manage_fields as $field ) {
1579 if ( ! empty( $field['map-api-key'] ) ) {
1580 // Fail-fast. This is what we need.
1581 return $field;
1582 }
1583 }
1584
1585 // Fallback.
1586 return null;
1587 }
1588 }
1589
1590 if ( ! function_exists( 'wppb_get_user_pin_bubble' ) ) {
1591 /**
1592 * Returns the map usable marker info.
1593 *
1594 * @param integer $id The user ID.
1595 * @param float $lat The latitude.
1596 * @param float $lng The longitude.
1597 * @param string $info The bubble inner info.
1598 * @param string $icon The pin custom icon.
1599 * @return string
1600 */
1601 function wppb_get_user_pin_bubble( $id, $lat, $lng, $info, $icon = '' ) {
1602 return '<div class="marker marker-for-user-' . (int) $id . ' marker-content-info" data-lat="' . esc_attr( $lat ) . '" data-lng="' . esc_attr( $lng ) . '" data-icon="' . esc_attr( $icon ) . '"><div class="marker-content">' . wp_kses_post( $info ) . '</div></div>';
1603 }
1604 }
1605
1606 if ( ! function_exists( 'wppb_compute_simple_pin_content_for_user' ) ) {
1607 /**
1608 * Compute simple pin content for user.
1609 *
1610 * @param integer $id_user User ID.
1611 * @param array $settings Settings array.
1612 * @return string
1613 */
1614 function wppb_compute_simple_pin_content_for_user( $id_user, $settings = array() ) {
1615
1616 if ( empty( $id_user ) ) {
1617 // Fail-fast.
1618 return '';
1619 }
1620 if ( empty( $settings ) ) {
1621 // Get one time the settings.
1622 $settings = wppb_options_get_map_settings();
1623 }
1624
1625 $args = ( ! empty( $settings['map-bubble-fields'] ) ) ? explode( ', ', $settings['map-bubble-fields'] ) : array();
1626 $result = '';
1627 if ( ! empty( $args ) ) {
1628 foreach ( $args as $tag ) {
1629 // Go to souce.
1630 if ( 'avatar_or_gravatar' == $tag ) {
1631 $val = apply_filters( 'mustache_variable_avatar_or_gravatar', '', $tag, array(), array(
1632 'user_id' => $id_user,
1633 ) );
1634 } else {
1635 $val = apply_filters( 'mustache_variable_default_user_field', '', $tag, array(), array(
1636 'user_id' => $id_user,
1637 ) );
1638 }
1639 if ( ! empty( $val ) ) {
1640 $result .= '<p class="marker-info-' . esc_attr( $tag ) . '">' . wp_kses_post( $val ) . '</p>';
1641 }
1642 }
1643 }
1644
1645 return $result;
1646 }
1647 }
1648
1649
1650 /**
1651 * Disable the add button again after we added a field
1652 */
1653 add_action( 'wck_ajax_add_form_wppb_manage_fields', 'wppb_redisable_the_add_button' );
1654 function wppb_redisable_the_add_button(){
1655 ?>
1656 <script>wppb_disable_add_entry_button ( '#wppb_manage_fields' );</script>
1657 <?php
1658 }
1659
1660
1661 /**
1662 * Function that updates the meta_key of a field in the usertmeta table when it was changed for a field. It is turned off by default
1663 */
1664 add_action( 'wck_before_update_meta', 'wppb_change_field_meta_key', 10, 4 );
1665 function wppb_change_field_meta_key( $meta, $id, $values, $element_id ){
1666 if( apply_filters( 'wppb_update_field_meta_key_in_db', false ) ) {
1667 if ($meta == 'wppb_manage_fields') {
1668 global $wpdb;
1669 $wppb_manage_fields = get_option('wppb_manage_fields');
1670 if (!empty($wppb_manage_fields)) {
1671
1672 /*
1673 * We need to be sure this is not a repeater.
1674 * The way we're doing this is by checking if the $values['meta-name'] is found inside $wppb_manage_fields
1675 * If it's not, it's probably inside a repeater.
1676 *
1677 * The reason we're doing this is because when we're updating a repeater field the $meta is still 'wppb_manage_fields' for some reason, while $element_id comes from the position of the repeater.
1678 *
1679 * This means we're updating last_name (if it's the 9'th position in wppb_manage_fields) instead of 'something_repeater' that's also in the 9'th position but inside the repeater group.
1680 *
1681 * Also, this code didn't account for 'something_repeater_1' etc, meaning it would have changed just 1 field, causing data loss anyway.
1682 *
1683 */
1684 $is_not_repeater = false;
1685 foreach ($wppb_manage_fields as $field){
1686 if ( $field['meta-name'] == $values['meta-name'] ){
1687 $is_not_repeater = true;
1688 }
1689 }
1690
1691 if (!empty($values['meta-name']) && $wppb_manage_fields[$element_id]['meta-name'] != $values['meta-name'] && $is_not_repeater ) {
1692 $wpdb->update(
1693 $wpdb->usermeta,
1694 array('meta_key' => sanitize_text_field($values['meta-name'])),
1695 array('meta_key' => sanitize_text_field($wppb_manage_fields[$element_id]['meta-name']))
1696 );
1697 } else {
1698 return;
1699 }
1700 }
1701 }
1702 }
1703 }
1704
1705
1706 if ( ! function_exists( 'wppb_prepare_key_value_options' ) ) {
1707 /**
1708 * Convert an array with keys and values into a usable option for the defined fields types.
1709 *
1710 * @param arrays $array List of options.
1711 * @return array Usable options.
1712 */
1713 function wppb_prepare_key_value_options( $array = array() ) {
1714 $result = array();
1715 if ( ! empty( $array ) ) {
1716 foreach ( $array as $name => $label ) {
1717 $result[] = '%' . wppb_prepare_wck_labels( $label ) . '%' . $name;
1718 }
1719 }
1720 return $result;
1721 }
1722 }
1723
1724 if ( ! function_exists( 'wppb_filter_map_bubble_fields' ) ) {
1725 /**
1726 * Filter the map POI's bubble content.
1727 *
1728 * @param arrays $tags List of available tags.
1729 * @return array Filtered and sorted tags.
1730 */
1731 function wppb_filter_map_bubble_fields( $tags ) {
1732 // Attempt to preseve one tag example.
1733 $maybe_avatar = ( ! empty( $tags['avatar_or_gravatar'] ) ) ? $tags['avatar_or_gravatar'] : false;
1734
1735 // Remove some of the tags.
1736 unset( $tags['meta_user_name'] );
1737 unset( $tags['more_info_url'] );
1738 unset( $tags['avatar_or_gravatar'] );
1739
1740 if ( ! empty( $maybe_avatar ) ) {
1741 // Perhaps preprend this to the list.
1742 $tags = array_merge( array( 'avatar_or_gravatar' => $maybe_avatar ), $tags );
1743 }
1744
1745 return $tags;
1746 }
1747 }
1748 add_filter( 'wppb_map_bubble_fields', 'wppb_filter_map_bubble_fields' );
1749