PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 2.7.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v2.7.3
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 2.7.3, at admin/manage-fields.php

1,413 lines 79.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Function that creates the Manage Fields submenu and populates it with a repeater field form
4 *
5 * @since v.2.0
6 *
7 * @return void
8 */
9 function wppb_manage_fields_submenu(){
10 // create a new sub_menu page which holds the data for the default + extra fields
11 $args = array(
12 'menu_title' => __( 'Manage Fields', 'profile-builder' ),
13 'page_title' => __( 'Manage Default and Extra Fields', 'profile-builder' ),
14 'menu_slug' => 'manage-fields',
15 'page_type' => 'submenu_page',
16 'capability' => 'manage_options',
17 'priority' => 5,
18 'parent_slug' => 'profile-builder'
19 );
20 $all_fields = new WCK_Page_Creator_PB( $args );
21
22
23 // populate this page
24 $manage_field_types[] = 'Default - Name (Heading)';
25 $manage_field_types[] = 'Default - Contact Info (Heading)';
26 $manage_field_types[] = 'Default - About Yourself (Heading)';
27 $manage_field_types[] = 'Default - Username';
28 $manage_field_types[] = 'Default - First Name';
29 $manage_field_types[] = 'Default - Last Name';
30 $manage_field_types[] = 'Default - Nickname';
31 $manage_field_types[] = 'Default - E-mail';
32 $manage_field_types[] = 'Default - Website';
33
34 // Default contact methods were removed in WP 3.6. A filter dictates contact methods.
35 if ( apply_filters( 'wppb_remove_default_contact_methods', get_site_option( 'initial_db_version' ) < 23588 ) ){
36 $manage_field_types[] = 'Default - AIM';
37 $manage_field_types[] = 'Default - Yahoo IM';
38 $manage_field_types[] = 'Default - Jabber / Google Talk';
39 }
40
41 $manage_field_types[] = 'Default - Password';
42 $manage_field_types[] = 'Default - Repeat Password';
43 $manage_field_types[] = 'Default - Biographical Info';
44 $manage_field_types[] = 'Default - Display name publicly as';
45 if ( wppb_can_users_signup_blog() ) {
46 $manage_field_types[] = 'Default - Blog Details';
47 }
48
49 /* added recaptcha and user role field since version 2.6.2 */
50 $manage_field_types[] = 'reCAPTCHA';
51 $manage_field_types[] = 'Select (User Role)';
52
53 if( PROFILE_BUILDER != 'Profile Builder Free' ) {
54 $manage_field_types[] = 'Heading';
55 $manage_field_types[] = 'Input';
56 $manage_field_types[] = 'Number';
57 $manage_field_types[] = 'Input (Hidden)';
58 $manage_field_types[] = 'Textarea';
59 $manage_field_types[] = 'WYSIWYG';
60 $manage_field_types[] = 'Phone';
61 $manage_field_types[] = 'Select';
62 $manage_field_types[] = 'Select (Multiple)';
63 $manage_field_types[] = 'Select (Country)';
64 $manage_field_types[] = 'Select (Timezone)';
65 $manage_field_types[] = 'Select (Currency)';
66 $manage_field_types[] = 'Select (CPT)';
67 $manage_field_types[] = 'Checkbox';
68 $manage_field_types[] = 'Checkbox (Terms and Conditions)';
69 $manage_field_types[] = 'Radio';
70 $manage_field_types[] = 'Upload';
71 $manage_field_types[] = 'Avatar';
72 $manage_field_types[] = 'Datepicker';
73 $manage_field_types[] = 'Timepicker';
74 $manage_field_types[] = 'Colorpicker';
75 $manage_field_types[] = 'Validation';
76 $manage_field_types[] = 'Map';
77 $manage_field_types[] = 'HTML';
78 }
79
80
81 //Free to Pro call to action on Manage Fields page
82 $field_description = __('Choose one of the supported field types','profile-builder');
83 if( PROFILE_BUILDER == 'Profile Builder Free' ) {
84 $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' ) );
85 }
86
87
88 //user roles
89 global $wp_roles;
90
91 $user_roles = array();
92 foreach( $wp_roles->roles as $user_role_slug => $user_role )
93 if( $user_role_slug !== 'administrator' )
94 array_push( $user_roles, '%' . $user_role['name'] . '%' . $user_role_slug );
95
96
97 // country select
98 $default_country_array = wppb_country_select_options( 'back_end' );
99 foreach( $default_country_array as $iso_country_code => $country_name ) {
100 $default_country_values[] = $iso_country_code;
101 $default_country_options[] = $country_name;
102 }
103
104 // currency select
105 $default_currency_array = wppb_get_currencies( 'back_end' );
106 array_unshift( $default_currency_array, '' );
107 foreach( $default_currency_array as $iso_currency_code => $currency_name ) {
108 $default_currency_values[] = $iso_currency_code;
109 $default_currency_options[] = $currency_name;
110 }
111
112 //cpt select
113 $post_types = get_post_types( array( 'public' => true ), 'names' );
114
115
116 if( apply_filters( 'wppb_update_field_meta_key_in_db', false ) ) {
117 $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' );
118 }
119 else{
120 $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' );
121 }
122
123 // set up the fields array
124 $fields = apply_filters( 'wppb_manage_fields', array(
125
126 array( 'type' => 'text', 'slug' => 'field-title', 'title' => __( 'Field Title', 'profile-builder' ), 'description' => __( 'Title of the field', 'profile-builder' ) ),
127 array( 'type' => 'select', 'slug' => 'field', 'title' => __( 'Field', 'profile-builder' ), 'options' => apply_filters( 'wppb_manage_fields_types', $manage_field_types ), 'default-option' => true, 'description' => $field_description ),
128 array( 'type' => 'text', 'slug' => 'meta-name', 'title' => __( 'Meta-name', 'profile-builder' ), 'default' => wppb_get_meta_name(), 'description' => $meta_key_description ),
129 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 ),
130 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') ),
131 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' ) ),
132 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' ) ),
133 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' ) ),
134 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' ) ),
135 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, @<br/>If not specified, defaults to mm/dd/yy', 'profile-builder' ) ),
136 array( 'type' => 'textarea', 'slug' => 'terms-of-agreement', 'title' => __( 'Terms of Agreement', 'profile-builder' ), 'description' => __( 'Enter a detailed description of the temrs 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' ) ),
137 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' ) ),
138 array( 'type' => 'text', 'slug' => 'labels', 'title' => __( 'Labels', 'profile-builder' ), 'description' => __( "Enter a comma separated list of labels<br/>Visible for the user", 'profile-builder' ) ),
139 array( 'type' => 'text', 'slug' => 'public-key', 'title' => __( 'Site Key', 'profile-builder' ), 'description' => __( 'The site key from Google, <a href="http://www.google.com/recaptcha" target="_blank">www.google.com/recaptcha</a>', 'profile-builder' ) ),
140 array( 'type' => 'text', 'slug' => 'private-key', 'title' => __( 'Secret Key', 'profile-builder' ), 'description' => __( 'The secret key from Google, <a href="http://www.google.com/recaptcha" target="_blank">www.google.com/recaptcha</a>', 'profile-builder' ) ),
141 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' ) ),
142 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' ) ),
143 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' ) ),
144 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' ) ),
145 array( 'type' => 'text', 'slug' => 'default-value', 'title' => __( 'Default Value', 'profile-builder' ), 'description' => __( "Default value of the field", 'profile-builder' ) ),
146 array( 'type' => 'text', 'slug' => 'default-option', 'title' => __( 'Default Option', 'profile-builder' ), 'description' => __( "Specify the option which should be selected by default", 'profile-builder' ) ),
147 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' ) ),
148 array( 'type' => 'select', 'slug' => 'default-option-country', 'title' => __( 'Default Option', 'profile-builder' ), 'values' => ( isset( $default_country_values ) ) ? $default_country_values : '', 'options' => ( isset( $default_country_options ) ) ? $default_country_options : '', 'description' => __( "Default option of the field", 'profile-builder' ) ),
149 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' ) ),
150 array( 'type' => 'select', 'slug' => 'default-option-currency', 'title' => __( 'Default Option', 'profile-builder' ), 'values' => ( isset( $default_currency_values ) ) ? $default_currency_values : '', 'options' => ( isset( $default_currency_options ) ) ? $default_currency_options : '', 'description' => __( "Default option of the field", 'profile-builder' ) ),
151 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' ) ),
152 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' ) ),
153 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' ) ),
154 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' ) ),
155 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' ) ),
156 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' ) ),
157 array( 'type' => 'text', 'slug' => 'map-default-lat', 'title' => __( 'Default Latitude', 'profile-builder' ), 'description' => __( "The latitude at which the map should be displayed when no pins are attached.", 'profile-builder' ) ),
158 array( 'type' => 'text', 'slug' => 'map-default-lng', 'title' => __( 'Default Longitude', 'profile-builder' ), 'description' => __( "The longitude at which the map should be displayed when no pins are attached.", 'profile-builder' ) ),
159 array( 'type' => 'text', 'slug' => 'map-default-zoom', 'title' => __( 'Default Zoom Level', 'profile-builder' ), 'description' => __( "Add a number from 0 to 19. The higher the number the higher the zoom.", 'profile-builder' ), 'default' => 16 ),
160 array( 'type' => 'text', 'slug' => 'map-height', 'title' => __( 'Map Height', 'profile-builder' ), 'description' => __( "The height of the map.", 'profile-builder' ), 'default' => 400 ),
161 array( 'type' => 'textarea', 'slug' => 'default-content', 'title' => __( 'Default Content', 'profile-builder' ), 'description' => __( "Default value of the textarea", 'profile-builder' ) ),
162 array( 'type' => 'textarea', 'slug' => 'html-content', 'title' => __( 'HTML Content', 'profile-builder' ), 'description' => __( "Add your HTML (or text) content", 'profile-builder' ) ),
163 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' ) ),
164 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' ) ),
165 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' ) ),
166 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' ) ),
167 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' ) ),
168 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' ) ),
169 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' ) ),
170 ) );
171
172 // create the new submenu with the above options
173 $args = array(
174 'metabox_id' => 'manage-fields',
175 'metabox_title' => __( 'Field Properties', 'profile-builder' ),
176 'post_type' => 'manage-fields',
177 'meta_name' => 'wppb_manage_fields',
178 'meta_array' => $fields,
179 'context' => 'option'
180 );
181 new Wordpress_Creation_Kit_PB( $args );
182
183 /* this is redundant but it should have a very low impact and for comfort we leave it here as well */
184 wppb_prepopulate_fields();
185
186 // create the info side meta-box
187 $args = array(
188 'metabox_id' => 'manage-fields-info',
189 'metabox_title' => __( 'Registration & Edit Profile', 'profile-builder' ),
190 'post_type' => 'manage-fields',
191 'meta_name' => 'wppb_manage_fields_info',
192 'meta_array' => '',
193 'context' => 'option',
194 'mb_context' => 'side'
195 );
196 new Wordpress_Creation_Kit_PB( $args );
197 }
198 add_action( 'init', 'wppb_manage_fields_submenu', 11 );
199
200 /**
201 * Function that prepopulates the manage fields list with the default fields of WP
202 *
203 * @since v.2.0
204 *
205 * @return void
206 */
207 function wppb_prepopulate_fields(){
208 $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' );
209 $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' );
210 $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' );
211 $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' );
212 $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' );
213 $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' );
214 $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' );
215 $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' );
216 $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' );
217
218 // Default contact methods were removed in WP 3.6. A filter dictates contact methods.
219 if ( apply_filters( 'wppb_remove_default_contact_methods', get_site_option( 'initial_db_version' ) < 23588 ) ){
220 $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' );
221 $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' );
222 $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' );
223 }
224
225 $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' );
226 $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' );
227 $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' );
228 $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' );
229 if ( wppb_can_users_signup_blog() ){
230 $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' );
231 }
232
233 add_option ( 'wppb_manage_fields', apply_filters ( 'wppb_prepopulated_fields', $prepopulated_fields ) );
234 }
235
236 /**
237 * Function that returns a unique meta-name
238 *
239 * @since v.2.0
240 *
241 * @return string
242 */
243 function wppb_get_meta_name( $option = 'wppb_manage_fields', $prefix = 'custom_field_' ){
244 $id = 1;
245
246 $wppb_manage_fields = get_option( $option, 'not_found' );
247
248 if ( ( $wppb_manage_fields === 'not_found' ) || ( empty( $wppb_manage_fields ) ) ){
249 return $prefix . $id;
250 }
251 else{
252 $meta_names = array();
253 foreach( $wppb_manage_fields as $value ){
254 if ( strpos( $value['meta-name'], $prefix ) === 0 ){
255 $meta_names[] = $value['meta-name'];
256 }
257 }
258
259 if( !empty( $meta_names ) ){
260 $meta_numbers = array();
261 foreach( $meta_names as $meta_name ){
262 $number = str_replace( $prefix, '', $meta_name );
263 /* we should have an underscore present in custom_field_# so remove it */
264 $number = str_replace( '_', '', $number );
265
266 $meta_numbers[] = $number;
267 }
268 if( !empty( $meta_numbers ) ){
269 rsort( $meta_numbers );
270 $id = $meta_numbers[0]++;
271 }
272 }
273
274 return $prefix . $id;
275 }
276 }
277
278
279 /**
280 * Function that returns an array with countries
281 *
282 * @since v.2.0
283 *
284 * @return array
285 */
286 function wppb_country_select_options( $form_location ) {
287 $country_array = apply_filters( 'wppb_'.$form_location.'_country_select_array',
288 array(
289 '' => '',
290 'AF' => __( 'Afghanistan', 'profile-builder' ),
291 'AX' => __( 'Aland Islands', 'profile-builder' ),
292 'AL' => __( 'Albania', 'profile-builder' ),
293 'DZ' => __( 'Algeria', 'profile-builder' ),
294 'AS' => __( 'American Samoa', 'profile-builder' ),
295 'AD' => __( 'Andorra', 'profile-builder' ),
296 'AO' => __( 'Angola', 'profile-builder' ),
297 'AI' => __( 'Anguilla', 'profile-builder' ),
298 'AQ' => __( 'Antarctica', 'profile-builder' ),
299 'AG' => __( 'Antigua and Barbuda', 'profile-builder' ),
300 'AR' => __( 'Argentina', 'profile-builder' ),
301 'AM' => __( 'Armenia', 'profile-builder' ),
302 'AW' => __( 'Aruba', 'profile-builder' ),
303 'AU' => __( 'Australia', 'profile-builder' ),
304 'AT' => __( 'Austria', 'profile-builder' ),
305 'AZ' => __( 'Azerbaijan', 'profile-builder' ),
306 'BS' => __( 'Bahamas', 'profile-builder' ),
307 'BH' => __( 'Bahrain', 'profile-builder' ),
308 'BD' => __( 'Bangladesh', 'profile-builder' ),
309 'BB' => __( 'Barbados', 'profile-builder' ),
310 'BY' => __( 'Belarus', 'profile-builder' ),
311 'BE' => __( 'Belgium', 'profile-builder' ),
312 'BZ' => __( 'Belize', 'profile-builder' ),
313 'BJ' => __( 'Benin', 'profile-builder' ),
314 'BM' => __( 'Bermuda', 'profile-builder' ),
315 'BT' => __( 'Bhutan', 'profile-builder' ),
316 'BO' => __( 'Bolivia', 'profile-builder' ),
317 'BQ' => __( 'Bonaire, Saint Eustatius and Saba', 'profile-builder' ),
318 'BA' => __( 'Bosnia and Herzegovina', 'profile-builder' ),
319 'BW' => __( 'Botswana', 'profile-builder' ),
320 'BV' => __( 'Bouvet Island', 'profile-builder' ),
321 'BR' => __( 'Brazil', 'profile-builder' ),
322 'IO' => __( 'British Indian Ocean Territory', 'profile-builder' ),
323 'VG' => __( 'British Virgin Islands', 'profile-builder' ),
324 'BN' => __( 'Brunei', 'profile-builder' ),
325 'BG' => __( 'Bulgaria', 'profile-builder' ),
326 'BF' => __( 'Burkina Faso', 'profile-builder' ),
327 'BI' => __( 'Burundi', 'profile-builder' ),
328 'KH' => __( 'Cambodia', 'profile-builder' ),
329 'CM' => __( 'Cameroon', 'profile-builder' ),
330 'CA' => __( 'Canada', 'profile-builder' ),
331 'CV' => __( 'Cape Verde', 'profile-builder' ),
332 'KY' => __( 'Cayman Islands', 'profile-builder' ),
333 'CF' => __( 'Central African Republic', 'profile-builder' ),
334 'TD' => __( 'Chad', 'profile-builder' ),
335 'CL' => __( 'Chile', 'profile-builder' ),
336 'CN' => __( 'China', 'profile-builder' ),
337 'CX' => __( 'Christmas Island', 'profile-builder' ),
338 'CC' => __( 'Cocos Islands', 'profile-builder' ),
339 'CO' => __( 'Colombia', 'profile-builder' ),
340 'KM' => __( 'Comoros', 'profile-builder' ),
341 'CK' => __( 'Cook Islands', 'profile-builder' ),
342 'CR' => __( 'Costa Rica', 'profile-builder' ),
343 'HR' => __( 'Croatia', 'profile-builder' ),
344 'CU' => __( 'Cuba', 'profile-builder' ),
345 'CW' => __( 'Curacao', 'profile-builder' ),
346 'CY' => __( 'Cyprus', 'profile-builder' ),
347 'CZ' => __( 'Czech Republic', 'profile-builder' ),
348 'CD' => __( 'Democratic Republic of the Congo', 'profile-builder' ),
349 'DK' => __( 'Denmark', 'profile-builder' ),
350 'DJ' => __( 'Djibouti', 'profile-builder' ),
351 'DM' => __( 'Dominica', 'profile-builder' ),
352 'DO' => __( 'Dominican Republic', 'profile-builder' ),
353 'TL' => __( 'East Timor', 'profile-builder' ),
354 'EC' => __( 'Ecuador', 'profile-builder' ),
355 'EG' => __( 'Egypt', 'profile-builder' ),
356 'SV' => __( 'El Salvador', 'profile-builder' ),
357 'GQ' => __( 'Equatorial Guinea', 'profile-builder' ),
358 'ER' => __( 'Eritrea', 'profile-builder' ),
359 'EE' => __( 'Estonia', 'profile-builder' ),
360 'ET' => __( 'Ethiopia', 'profile-builder' ),
361 'FK' => __( 'Falkland Islands', 'profile-builder' ),
362 'FO' => __( 'Faroe Islands', 'profile-builder' ),
363 'FJ' => __( 'Fiji', 'profile-builder' ),
364 'FI' => __( 'Finland', 'profile-builder' ),
365 'FR' => __( 'France', 'profile-builder' ),
366 'GF' => __( 'French Guiana', 'profile-builder' ),
367 'PF' => __( 'French Polynesia', 'profile-builder' ),
368 'TF' => __( 'French Southern Territories', 'profile-builder' ),
369 'GA' => __( 'Gabon', 'profile-builder' ),
370 'GM' => __( 'Gambia', 'profile-builder' ),
371 'GE' => __( 'Georgia', 'profile-builder' ),
372 'DE' => __( 'Germany', 'profile-builder' ),
373 'GH' => __( 'Ghana', 'profile-builder' ),
374 'GI' => __( 'Gibraltar', 'profile-builder' ),
375 'GR' => __( 'Greece', 'profile-builder' ),
376 'GL' => __( 'Greenland', 'profile-builder' ),
377 'GD' => __( 'Grenada', 'profile-builder' ),
378 'GP' => __( 'Guadeloupe', 'profile-builder' ),
379 'GU' => __( 'Guam', 'profile-builder' ),
380 'GT' => __( 'Guatemala', 'profile-builder' ),
381 'GG' => __( 'Guernsey', 'profile-builder' ),
382 'GN' => __( 'Guinea', 'profile-builder' ),
383 'GW' => __( 'Guinea-Bissau', 'profile-builder' ),
384 'GY' => __( 'Guyana', 'profile-builder' ),
385 'HT' => __( 'Haiti', 'profile-builder' ),
386 'HM' => __( 'Heard Island and McDonald Islands', 'profile-builder' ),
387 'HN' => __( 'Honduras', 'profile-builder' ),
388 'HK' => __( 'Hong Kong', 'profile-builder' ),
389 'HU' => __( 'Hungary', 'profile-builder' ),
390 'IS' => __( 'Iceland', 'profile-builder' ),
391 'IN' => __( 'India', 'profile-builder' ),
392 'ID' => __( 'Indonesia', 'profile-builder' ),
393 'IR' => __( 'Iran', 'profile-builder' ),
394 'IQ' => __( 'Iraq', 'profile-builder' ),
395 'IE' => __( 'Ireland', 'profile-builder' ),
396 'IM' => __( 'Isle of Man', 'profile-builder' ),
397 'IL' => __( 'Israel', 'profile-builder' ),
398 'IT' => __( 'Italy', 'profile-builder' ),
399 'CI' => __( 'Ivory Coast', 'profile-builder' ),
400 'JM' => __( 'Jamaica', 'profile-builder' ),
401 'JP' => __( 'Japan', 'profile-builder' ),
402 'JE' => __( 'Jersey', 'profile-builder' ),
403 'JO' => __( 'Jordan', 'profile-builder' ),
404 'KZ' => __( 'Kazakhstan', 'profile-builder' ),
405 'KE' => __( 'Kenya', 'profile-builder' ),
406 'KI' => __( 'Kiribati', 'profile-builder' ),
407 'XK' => __( 'Kosovo', 'profile-builder' ),
408 'KW' => __( 'Kuwait', 'profile-builder' ),
409 'KG' => __( 'Kyrgyzstan', 'profile-builder' ),
410 'LA' => __( 'Laos', 'profile-builder' ),
411 'LV' => __( 'Latvia', 'profile-builder' ),
412 'LB' => __( 'Lebanon', 'profile-builder' ),
413 'LS' => __( 'Lesotho', 'profile-builder' ),
414 'LR' => __( 'Liberia', 'profile-builder' ),
415 'LY' => __( 'Libya', 'profile-builder' ),
416 'LI' => __( 'Liechtenstein', 'profile-builder' ),
417 'LT' => __( 'Lithuania', 'profile-builder' ),
418 'LU' => __( 'Luxembourg', 'profile-builder' ),
419 'MO' => __( 'Macao', 'profile-builder' ),
420 'MK' => __( 'Macedonia', 'profile-builder' ),
421 'MG' => __( 'Madagascar', 'profile-builder' ),
422 'MW' => __( 'Malawi', 'profile-builder' ),
423 'MY' => __( 'Malaysia', 'profile-builder' ),
424 'MV' => __( 'Maldives', 'profile-builder' ),
425 'ML' => __( 'Mali', 'profile-builder' ),
426 'MT' => __( 'Malta', 'profile-builder' ),
427 'MH' => __( 'Marshall Islands', 'profile-builder' ),
428 'MQ' => __( 'Martinique', 'profile-builder' ),
429 'MR' => __( 'Mauritania', 'profile-builder' ),
430 'MU' => __( 'Mauritius', 'profile-builder' ),
431 'YT' => __( 'Mayotte', 'profile-builder' ),
432 'MX' => __( 'Mexico', 'profile-builder' ),
433 'FM' => __( 'Micronesia', 'profile-builder' ),
434 'MD' => __( 'Moldova', 'profile-builder' ),
435 'MC' => __( 'Monaco', 'profile-builder' ),
436 'MN' => __( 'Mongolia', 'profile-builder' ),
437 'ME' => __( 'Montenegro', 'profile-builder' ),
438 'MS' => __( 'Montserrat', 'profile-builder' ),
439 'MA' => __( 'Morocco', 'profile-builder' ),
440 'MZ' => __( 'Mozambique', 'profile-builder' ),
441 'MM' => __( 'Myanmar', 'profile-builder' ),
442 'NA' => __( 'Namibia', 'profile-builder' ),
443 'NR' => __( 'Nauru', 'profile-builder' ),
444 'NP' => __( 'Nepal', 'profile-builder' ),
445 'NL' => __( 'Netherlands', 'profile-builder' ),
446 'NC' => __( 'New Caledonia', 'profile-builder' ),
447 'NZ' => __( 'New Zealand', 'profile-builder' ),
448 'NI' => __( 'Nicaragua', 'profile-builder' ),
449 'NE' => __( 'Niger', 'profile-builder' ),
450 'NG' => __( 'Nigeria', 'profile-builder' ),
451 'NU' => __( 'Niue', 'profile-builder' ),
452 'NF' => __( 'Norfolk Island', 'profile-builder' ),
453 'KP' => __( 'North Korea', 'profile-builder' ),
454 'MP' => __( 'Northern Mariana Islands', 'profile-builder' ),
455 'NO' => __( 'Norway', 'profile-builder' ),
456 'OM' => __( 'Oman', 'profile-builder' ),
457 'PK' => __( 'Pakistan', 'profile-builder' ),
458 'PW' => __( 'Palau', 'profile-builder' ),
459 'PS' => __( 'Palestinian Territory', 'profile-builder' ),
460 'PA' => __( 'Panama', 'profile-builder' ),
461 'PG' => __( 'Papua New Guinea', 'profile-builder' ),
462 'PY' => __( 'Paraguay', 'profile-builder' ),
463 'PE' => __( 'Peru', 'profile-builder' ),
464 'PH' => __( 'Philippines', 'profile-builder' ),
465 'PN' => __( 'Pitcairn', 'profile-builder' ),
466 'PL' => __( 'Poland', 'profile-builder' ),
467 'PT' => __( 'Portugal', 'profile-builder' ),
468 'PR' => __( 'Puerto Rico', 'profile-builder' ),
469 'QA' => __( 'Qatar', 'profile-builder' ),
470 'CG' => __( 'Republic of the Congo', 'profile-builder' ),
471 'RE' => __( 'Reunion', 'profile-builder' ),
472 'RO' => __( 'Romania', 'profile-builder' ),
473 'RU' => __( 'Russia', 'profile-builder' ),
474 'RW' => __( 'Rwanda', 'profile-builder' ),
475 'BL' => __( 'Saint Barthelemy', 'profile-builder' ),
476 'SH' => __( 'Saint Helena', 'profile-builder' ),
477 'KN' => __( 'Saint Kitts and Nevis', 'profile-builder' ),
478 'LC' => __( 'Saint Lucia', 'profile-builder' ),
479 'MF' => __( 'Saint Martin', 'profile-builder' ),
480 'PM' => __( 'Saint Pierre and Miquelon', 'profile-builder' ),
481 'VC' => __( 'Saint Vincent and the Grenadines', 'profile-builder' ),
482 'WS' => __( 'Samoa', 'profile-builder' ),
483 'SM' => __( 'San Marino', 'profile-builder' ),
484 'ST' => __( 'Sao Tome and Principe', 'profile-builder' ),
485 'SA' => __( 'Saudi Arabia', 'profile-builder' ),
486 'SN' => __( 'Senegal', 'profile-builder' ),
487 'RS' => __( 'Serbia', 'profile-builder' ),
488 'SC' => __( 'Seychelles', 'profile-builder' ),
489 'SL' => __( 'Sierra Leone', 'profile-builder' ),
490 'SG' => __( 'Singapore', 'profile-builder' ),
491 'SX' => __( 'Sint Maarten', 'profile-builder' ),
492 'SK' => __( 'Slovakia', 'profile-builder' ),
493 'SI' => __( 'Slovenia', 'profile-builder' ),
494 'SB' => __( 'Solomon Islands', 'profile-builder' ),
495 'SO' => __( 'Somalia', 'profile-builder' ),
496 'ZA' => __( 'South Africa', 'profile-builder' ),
497 'GS' => __( 'South Georgia and the South Sandwich Islands', 'profile-builder' ),
498 'KR' => __( 'South Korea', 'profile-builder' ),
499 'SS' => __( 'South Sudan', 'profile-builder' ),
500 'ES' => __( 'Spain', 'profile-builder' ),
501 'LK' => __( 'Sri Lanka', 'profile-builder' ),
502 'SD' => __( 'Sudan', 'profile-builder' ),
503 'SR' => __( 'Suriname', 'profile-builder' ),
504 'SJ' => __( 'Svalbard and Jan Mayen', 'profile-builder' ),
505 'SZ' => __( 'Swaziland', 'profile-builder' ),
506 'SE' => __( 'Sweden', 'profile-builder' ),
507 'CH' => __( 'Switzerland', 'profile-builder' ),
508 'SY' => __( 'Syria', 'profile-builder' ),
509 'TW' => __( 'Taiwan', 'profile-builder' ),
510 'TJ' => __( 'Tajikistan', 'profile-builder' ),
511 'TZ' => __( 'Tanzania', 'profile-builder' ),
512 'TH' => __( 'Thailand', 'profile-builder' ),
513 'TG' => __( 'Togo', 'profile-builder' ),
514 'TK' => __( 'Tokelau', 'profile-builder' ),
515 'TO' => __( 'Tonga', 'profile-builder' ),
516 'TT' => __( 'Trinidad and Tobago', 'profile-builder' ),
517 'TN' => __( 'Tunisia', 'profile-builder' ),
518 'TR' => __( 'Turkey', 'profile-builder' ),
519 'TM' => __( 'Turkmenistan', 'profile-builder' ),
520 'TC' => __( 'Turks and Caicos Islands', 'profile-builder' ),
521 'TV' => __( 'Tuvalu', 'profile-builder' ),
522 'VI' => __( 'U.S. Virgin Islands', 'profile-builder' ),
523 'UG' => __( 'Uganda', 'profile-builder' ),
524 'UA' => __( 'Ukraine', 'profile-builder' ),
525 'AE' => __( 'United Arab Emirates', 'profile-builder' ),
526 'GB' => __( 'United Kingdom', 'profile-builder' ),
527 'US' => __( 'United States', 'profile-builder' ),
528 'UM' => __( 'United States Minor Outlying Islands', 'profile-builder' ),
529 'UY' => __( 'Uruguay', 'profile-builder' ),
530 'UZ' => __( 'Uzbekistan', 'profile-builder' ),
531 'VU' => __( 'Vanuatu', 'profile-builder' ),
532 'VA' => __( 'Vatican', 'profile-builder' ),
533 'VE' => __( 'Venezuela', 'profile-builder' ),
534 'VN' => __( 'Vietnam', 'profile-builder' ),
535 'WF' => __( 'Wallis and Futuna', 'profile-builder' ),
536 'EH' => __( 'Western Sahara', 'profile-builder' ),
537 'YE' => __( 'Yemen', 'profile-builder' ),
538 'ZM' => __( 'Zambia', 'profile-builder' ),
539 'ZW' => __( 'Zimbabwe', 'profile-builder' ),
540 )
541 );
542
543 return $country_array;
544 }
545
546
547 /**
548 * Function that returns an array with timezone options
549 *
550 * @since v.2.0
551 *
552 * @return array
553 */
554 function wppb_timezone_select_options( $form_location ) {
555 $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' ) );
556
557 return $timezone_array;
558 }
559
560
561 /*
562 * Array with the currency ISO code and associated currency name
563 *
564 * @param string $form_location
565 *
566 * @return array
567 *
568 */
569 function wppb_get_currencies( $form_location = '' ) {
570
571 $currencies = array(
572 'ALL' => __( 'Albania Lek', 'profile-builder' ),
573 'AFN' => __( 'Afghanistan Afghani', 'profile-builder' ),
574 'ARS' => __( 'Argentina Peso', 'profile-builder' ),
575 'AWG' => __( 'Aruba Guilder', 'wkc' ),
576 'AUD' => __( 'Australia Dollar', 'profile-builder' ),
577 'AZN' => __( 'Azerbaijan New Manat', 'profile-builder' ),
578 'BSD' => __( 'Bahamas Dollar', 'profile-builder' ),
579 'BBD' => __( 'Barbados Dollar','profile-builder' ),
580 'BDT' => __( 'Bangladeshi taka','profile-builder' ),
581 'BYR' => __( 'Belarus Ruble','profile-builder' ),
582 'BZD' => __( 'Belize Dollar','profile-builder' ),
583 'BMD' => __( 'Bermuda Dollar','profile-builder' ),
584 'BOB' => __( 'Bolivia Boliviano','profile-builder' ),
585 'BAM' => __( 'Bosnia and Herzegovina Convertible Marka','profile-builder' ),
586 'BWP' => __( 'Botswana Pula','profile-builder' ),
587 'BGN' => __( 'Bulgaria Lev','profile-builder' ),
588 'BRL' => __( 'Brazil Real','profile-builder' ),
589 'BND' => __( 'Brunei Darussalam Dollar','profile-builder' ),
590 'KHR' => __( 'Cambodia Riel','profile-builder' ),
591 'CAD' => __( 'Canada Dollar','profile-builder' ),
592 'KYD' => __( 'Cayman Islands Dollar','profile-builder' ),
593 'CLP' => __( 'Chile Peso','profile-builder' ),
594 'CNY' => __( 'China Yuan Renminbi','profile-builder' ),
595 'COP' => __( 'Colombia Peso','profile-builder' ),
596 'CRC' => __( 'Costa Rica Colon','profile-builder' ),
597 'HRK' => __( 'Croatia Kuna','profile-builder' ),
598 'CUP' => __( 'Cuba Peso','profile-builder' ),
599 'CZK' => __( 'Czech Republic Koruna','profile-builder' ),
600 'DKK' => __( 'Denmark Krone','profile-builder' ),
601 'DOP' => __( 'Dominican Republic Peso','profile-builder' ),
602 'XCD' => __( 'East Caribbean Dollar','profile-builder' ),
603 'EGP' => __( 'Egypt Pound','profile-builder' ),
604 'SVC' => __( 'El Salvador Colon','profile-builder' ),
605 'EEK' => __( 'Estonia Kroon','profile-builder' ),
606 'EUR' => __( 'Euro','profile-builder' ),
607 'FKP' => __( 'Falkland Islands (Malvinas) Pound','profile-builder' ),
608 'FJD' => __( 'Fiji Dollar','profile-builder' ),
609 'GHC' => __( 'Ghana Cedis','profile-builder' ),
610 'GIP' => __( 'Gibraltar Pound','profile-builder' ),
611 'GTQ' => __( 'Guatemala Quetzal','profile-builder' ),
612 'GGP' => __( 'Guernsey Pound','profile-builder' ),
613 'GYD' => __( 'Guyana Dollar','profile-builder' ),
614 'HNL' => __( 'Honduras Lempira','profile-builder' ),
615 'HKD' => __( 'Hong Kong Dollar','profile-builder' ),
616 'HUF' => __( 'Hungary Forint','profile-builder' ),
617 'ISK' => __( 'Iceland Krona','profile-builder' ),
618 'INR' => __( 'India Rupee','profile-builder' ),
619 'IDR' => __( 'Indonesia Rupiah','profile-builder' ),
620 'IRR' => __( 'Iran Rial','profile-builder' ),
621 'IMP' => __( 'Isle of Man Pound','profile-builder' ),
622 'ILS' => __( 'Israel Shekel','profile-builder' ),
623 'JMD' => __( 'Jamaica Dollar','profile-builder' ),
624 'JPY' => __( 'Japan Yen','profile-builder' ),
625 'JEP' => __( 'Jersey Pound','profile-builder' ),
626 'KZT' => __( 'Kazakhstan Tenge','profile-builder' ),
627 'KPW' => __( 'Korea (North) Won','profile-builder' ),
628 'KRW' => __( 'Korea (South) Won','profile-builder' ),
629 'KGS' => __( 'Kyrgyzstan Som','profile-builder' ),
630 'LAK' => __( 'Laos Kip','profile-builder' ),
631 'LVL' => __( 'Latvia Lat','profile-builder' ),
632 'LBP' => __( 'Lebanon Pound','profile-builder' ),
633 'LRD' => __( 'Liberia Dollar','profile-builder' ),
634 'LTL' => __( 'Lithuania Litas','profile-builder' ),
635 'MKD' => __( 'Macedonia Denar','profile-builder' ),
636 'MYR' => __( 'Malaysia Ringgit','profile-builder' ),
637 'MUR' => __( 'Mauritius Rupee','profile-builder' ),
638 'MXN' => __( 'Mexico Peso','profile-builder' ),
639 'MNT' => __( 'Mongolia Tughrik','profile-builder' ),
640 'MZN' => __( 'Mozambique Metical','profile-builder' ),
641 'NAD' => __( 'Namibia Dollar','profile-builder' ),
642 'NPR' => __( 'Nepal Rupee','profile-builder' ),
643 'ANG' => __( 'Netherlands Antilles Guilder','profile-builder' ),
644 'NZD' => __( 'New Zealand Dollar','profile-builder' ),
645 'NIO' => __( 'Nicaragua Cordoba','profile-builder' ),
646 'NGN' => __( 'Nigeria Naira','profile-builder' ),
647 'NOK' => __( 'Norway Krone','profile-builder' ),
648 'OMR' => __( 'Oman Rial', 'profile-builder' ),
649 'PKR' => __( 'Pakistan Rupee', 'profile-builder' ),
650 'PAB' => __( 'Panama Balboa', 'profile-builder' ),
651 'PYG' => __( 'Paraguay Guarani', 'profile-builder' ),
652 'PEN' => __( 'Peru Nuevo Sol', 'profile-builder' ),
653 'PHP' => __( 'Philippines Peso', 'profile-builder' ),
654 'PLN' => __( 'Poland Zloty', 'profile-builder' ),
655 'QAR' => __( 'Qatar Riyal', 'profile-builder' ),
656 'RON' => __( 'Romania New Leu', 'profile-builder' ),
657 'RUB' => __( 'Russia Ruble', 'profile-builder' ),
658 'SHP' => __( 'Saint Helena Pound', 'profile-builder' ),
659 'SAR' => __( 'Saudi Arabia Riyal', 'profile-builder' ),
660 'RSD' => __( 'Serbia Dinar', 'profile-builder' ),
661 'SCR' => __( 'Seychelles Rupee', 'profile-builder' ),
662 'SGD' => __( 'Singapore Dollar', 'profile-builder' ),
663 'SBD' => __( 'Solomon Islands Dollar', 'profile-builder' ),
664 'SOS' => __( 'Somalia Shilling', 'profile-builder' ),
665 'ZAR' => __( 'South Africa Rand', 'profile-builder' ),
666 'LKR' => __( 'Sri Lanka Rupee', 'profile-builder' ),
667 'SEK' => __( 'Sweden Krona', 'profile-builder' ),
668 'CHF' => __( 'Switzerland Franc', 'profile-builder' ),
669 'SRD' => __( 'Suriname Dollar', 'profile-builder' ),
670 'SYP' => __( 'Syria Pound', 'profile-builder' ),
671 'TWD' => __( 'Taiwan New Dollar', 'profile-builder' ),
672 'THB' => __( 'Thailand Baht', 'profile-builder' ),
673 'TTD' => __( 'Trinidad and Tobago Dollar', 'profile-builder' ),
674 'TRY' => __( 'Turkey Lira', 'profile-builder' ),
675 'TRL' => __( 'Turkey Lira', 'profile-builder' ),
676 'TVD' => __( 'Tuvalu Dollar', 'profile-builder' ),
677 'UAH' => __( 'Ukraine Hryvna', 'profile-builder' ),
678 'GBP' => __( 'United Kingdom Pound', 'profile-builder' ),
679 'UGX' => __( 'Uganda Shilling', 'profile-builder' ),
680 'USD' => __( 'US Dollar', 'profile-builder' ),
681 'UYU' => __( 'Uruguay Peso', 'profile-builder' ),
682 'UZS' => __( 'Uzbekistan Som', 'profile-builder' ),
683 'VEF' => __( 'Venezuela Bolivar', 'profile-builder' ),
684 'VND' => __( 'Viet Nam Dong', 'profile-builder' ),
685 'YER' => __( 'Yemen Rial', 'profile-builder' ),
686 'ZWD' => __( 'Zimbabwe Dollar', 'profile-builder' )
687 );
688
689 $filter_name = ( empty( $form_location ) ? 'wppb_get_currencies' : 'wppb_get_currencies_' . $form_location );
690
691 return apply_filters( $filter_name, $currencies );
692
693 }
694
695
696 /*
697 * Returns the currency symbol for a given currency code
698 *
699 * @param string $currency_code
700 *
701 * @return string
702 *
703 */
704 function wppb_get_currency_symbol( $currency_code ) {
705
706 $currency_symbols = array(
707 'AED' => '&#1583;.&#1573;', // ?
708 'AFN' => '&#65;&#102;',
709 'ALL' => '&#76;&#101;&#107;',
710 'AMD' => '',
711 'ANG' => '&#402;',
712 'AOA' => '&#75;&#122;', // ?
713 'ARS' => '&#36;',
714 'AUD' => '&#36;',
715 'AWG' => '&#402;',
716 'AZN' => '&#1084;&#1072;&#1085;',
717 'BAM' => '&#75;&#77;',
718 'BBD' => '&#36;',
719 'BDT' => '&#2547;', // ?
720 'BGN' => '&#1083;&#1074;',
721 'BHD' => '.&#1583;.&#1576;', // ?
722 'BIF' => '&#70;&#66;&#117;', // ?
723 'BMD' => '&#36;',
724 'BND' => '&#36;',
725 'BOB' => '&#36;&#98;',
726 'BRL' => '&#82;&#36;',
727 'BSD' => '&#36;',
728 'BTN' => '&#78;&#117;&#46;', // ?
729 'BWP' => '&#80;',
730 'BYR' => '&#112;&#46;',
731 'BZD' => '&#66;&#90;&#36;',
732 'CAD' => '&#36;',
733 'CDF' => '&#70;&#67;',
734 'CHF' => '&#67;&#72;&#70;',
735 'CLF' => '', // ?
736 'CLP' => '&#36;',
737 'CNY' => '&#165;',
738 'COP' => '&#36;',
739 'CRC' => '&#8353;',
740 'CUP' => '&#8396;',
741 'CVE' => '&#36;', // ?
742 'CZK' => '&#75;&#269;',
743 'DJF' => '&#70;&#100;&#106;', // ?
744 'DKK' => '&#107;&#114;',
745 'DOP' => '&#82;&#68;&#36;',
746 'DZD' => '&#1583;&#1580;', // ?
747 'EGP' => '&#163;',
748 'ETB' => '&#66;&#114;',
749 'EUR' => '&#8364;',
750 'FJD' => '&#36;',
751 'FKP' => '&#163;',
752 'GBP' => '&#163;',
753 'GEL' => '&#4314;', // ?
754 'GHS' => '&#162;',
755 'GIP' => '&#163;',
756 'GMD' => '&#68;', // ?
757 'GNF' => '&#70;&#71;', // ?
758 'GTQ' => '&#81;',
759 'GYD' => '&#36;',
760 'HKD' => '&#36;',
761 'HNL' => '&#76;',
762 'HRK' => '&#107;&#110;',
763 'HTG' => '&#71;', // ?
764 'HUF' => '&#70;&#116;',
765 'IDR' => '&#82;&#112;',
766 'ILS' => '&#8362;',
767 'INR' => '&#8377;',
768 'IQD' => '&#1593;.&#1583;', // ?
769 'IRR' => '&#65020;',
770 'ISK' => '&#107;&#114;',
771 'JEP' => '&#163;',
772 'JMD' => '&#74;&#36;',
773 'JOD' => '&#74;&#68;', // ?
774 'JPY' => '&#165;',
775 'KES' => '&#75;&#83;&#104;', // ?
776 'KGS' => '&#1083;&#1074;',
777 'KHR' => '&#6107;',
778 'KMF' => '&#67;&#70;', // ?
779 'KPW' => '&#8361;',
780 'KRW' => '&#8361;',
781 'KWD' => '&#1583;.&#1603;', // ?
782 'KYD' => '&#36;',
783 'KZT' => '&#1083;&#1074;',
784 'LAK' => '&#8365;',
785 'LBP' => '&#163;',
786 'LKR' => '&#8360;',
787 'LRD' => '&#36;',
788 'LSL' => '&#76;', // ?
789 'LTL' => '&#76;&#116;',
790 'LVL' => '&#76;&#115;',
791 'LYD' => '&#1604;.&#1583;', // ?
792 'MAD' => '&#1583;.&#1605;.', //?
793 'MDL' => '&#76;',
794 'MGA' => '&#65;&#114;', // ?
795 'MKD' => '&#1076;&#1077;&#1085;',
796 'MMK' => '&#75;',
797 'MNT' => '&#8366;',
798 'MOP' => '&#77;&#79;&#80;&#36;', // ?
799 'MRO' => '&#85;&#77;', // ?
800 'MUR' => '&#8360;', // ?
801 'MVR' => '.&#1923;', // ?
802 'MWK' => '&#77;&#75;',
803 'MXN' => '&#36;',
804 'MYR' => '&#82;&#77;',
805 'MZN' => '&#77;&#84;',
806 'NAD' => '&#36;',
807 'NGN' => '&#8358;',
808 'NIO' => '&#67;&#36;',
809 'NOK' => '&#107;&#114;',
810 'NPR' => '&#8360;',
811 'NZD' => '&#36;',
812 'OMR' => '&#65020;',
813 'PAB' => '&#66;&#47;&#46;',
814 'PEN' => '&#83;&#47;&#46;',
815 'PGK' => '&#75;', // ?
816 'PHP' => '&#8369;',
817 'PKR' => '&#8360;',
818 'PLN' => '&#122;&#322;',
819 'PYG' => '&#71;&#115;',
820 'QAR' => '&#65020;',
821 'RON' => '&#108;&#101;&#105;',
822 'RSD' => '&#1044;&#1080;&#1085;&#46;',
823 'RUB' => '&#1088;&#1091;&#1073;',
824 'RWF' => '&#1585;.&#1587;',
825 'SAR' => '&#65020;',
826 'SBD' => '&#36;',
827 'SCR' => '&#8360;',
828 'SDG' => '&#163;', // ?
829 'SEK' => '&#107;&#114;',
830 'SGD' => '&#36;',
831 'SHP' => '&#163;',
832 'SLL' => '&#76;&#101;', // ?
833 'SOS' => '&#83;',
834 'SRD' => '&#36;',
835 'STD' => '&#68;&#98;', // ?
836 'SVC' => '&#36;',
837 'SYP' => '&#163;',
838 'SZL' => '&#76;', // ?
839 'THB' => '&#3647;',
840 'TJS' => '&#84;&#74;&#83;', // ? TJS (guess)
841 'TMT' => '&#109;',
842 'TND' => '&#1583;.&#1578;',
843 'TOP' => '&#84;&#36;',
844 'TRY' => '&#8356;', // New Turkey Lira (old symbol used)
845 'TTD' => '&#36;',
846 'TWD' => '&#78;&#84;&#36;',
847 'TZS' => '',
848 'UAH' => '&#8372;',
849 'UGX' => '&#85;&#83;&#104;',
850 'USD' => '&#36;',
851 'UYU' => '&#36;&#85;',
852 'UZS' => '&#1083;&#1074;',
853 'VEF' => '&#66;&#115;',
854 'VND' => '&#8363;',
855 'VUV' => '&#86;&#84;',
856 'WST' => '&#87;&#83;&#36;',
857 'XAF' => '&#70;&#67;&#70;&#65;',
858 'XCD' => '&#36;',
859 'XDR' => '',
860 'XOF' => '',
861 'XPF' => '&#70;',
862 'YER' => '&#65020;',
863 'ZAR' => '&#82;',
864 'ZMK' => '&#90;&#75;', // ?
865 'ZWL' => '&#90;&#36;',
866 );
867
868 if( !empty( $currency_symbols[$currency_code] ) )
869 return $currency_symbols[$currency_code];
870 else
871 return '';
872
873 }
874
875
876 /**
877 * Function that returns a unique, incremented ID
878 *
879 * @since v.2.0
880 *
881 * @return integer id
882 */
883 function wppb_get_unique_id(){
884 $id = 1;
885 $wppb_manage_fields = get_option( 'wppb_manage_fields', 'not_found' );
886 if ( ( $wppb_manage_fields === 'not_found' ) || ( empty( $wppb_manage_fields ) ) ){
887 return $id;
888 }
889 else{
890 $ids_array = array();
891 foreach( $wppb_manage_fields as $value ){
892 $ids_array[] = $value['id'];
893 }
894 if( !empty( $ids_array ) ){
895 rsort( $ids_array );
896 $id = $ids_array[0] + 1;
897 }
898 }
899 return apply_filters( 'wppb_field_unique_id', $id, $ids_array, $wppb_manage_fields );
900 }
901
902 /**
903 * Function that checks to see if the id is unique when saving the new field
904 *
905 * @param array $values
906 *
907 * @return array
908 */
909 function wppb_check_unique_id_on_saving( $values ) {
910 $wppb_manage_fields = get_option( 'wppb_manage_fields', 'not_found' );
911
912 if( $wppb_manage_fields != 'not_found' ) {
913
914 $ids_array = array();
915 foreach( $wppb_manage_fields as $field ){
916 $ids_array[] = $field['id'];
917 }
918
919 if( in_array( $values['id'], $ids_array ) ) {
920 rsort( $ids_array );
921 $values['id'] = $ids_array[0] + 1;
922 }
923
924 }
925 return $values;
926 }
927 add_filter( 'wck_add_meta_filter_values_wppb_manage_fields', 'wppb_check_unique_id_on_saving' );
928
929
930 function wppb_return_unique_field_list( $only_default_fields = false ){
931
932 $unique_field_list[] = 'Default - Name (Heading)';
933 $unique_field_list[] = 'Default - Contact Info (Heading)';
934 $unique_field_list[] = 'Default - About Yourself (Heading)';
935 $unique_field_list[] = 'Default - Username';
936 $unique_field_list[] = 'Default - First Name';
937 $unique_field_list[] = 'Default - Last Name';
938 $unique_field_list[] = 'Default - Nickname';
939 $unique_field_list[] = 'Default - E-mail';
940 $unique_field_list[] = 'Default - Website';
941
942 // Default contact methods were removed in WP 3.6. A filter dictates contact methods.
943 if ( apply_filters( 'wppb_remove_default_contact_methods', get_site_option( 'initial_db_version' ) < 23588 ) ){
944 $unique_field_list[] = 'Default - AIM';
945 $unique_field_list[] = 'Default - Yahoo IM';
946 $unique_field_list[] = 'Default - Jabber / Google Talk';
947 }
948
949 $unique_field_list[] = 'Default - Password';
950 $unique_field_list[] = 'Default - Repeat Password';
951 $unique_field_list[] = 'Default - Biographical Info';
952 $unique_field_list[] = 'Default - Display name publicly as';
953
954 if ( wppb_can_users_signup_blog() ) {
955 $unique_field_list[] = 'Default - Blog Details';
956 }
957
958 if( !$only_default_fields ){
959 $unique_field_list[] = 'Avatar';
960 $unique_field_list[] = 'reCAPTCHA';
961 $unique_field_list[] = 'Select (User Role)';
962 }
963
964 return apply_filters ( 'wppb_unique_field_list', $unique_field_list );
965 }
966
967
968 /**
969 * Function that checks several things when adding/editing the fields
970 *
971 * @since v.2.0
972 *
973 * @param string $message - the message to be displayed
974 * @param array $fields - the added fields
975 * @param array $required_fields
976 * @param string $meta - the meta-name of the option
977 * @param string $values - The values entered for each option
978 * @param integer $post_id
979 * @return boolean
980 */
981 function wppb_check_field_on_edit_add( $message, $fields, $required_fields, $meta_name, $posted_values, $post_id ){
982 global $wpdb;
983
984 if ( $meta_name == 'wppb_manage_fields' ){
985
986 // check for a valid field-type (fallback)
987 if ( $posted_values['field'] == '' )
988 $message .= __( "You must select a field\n", 'profile-builder' );
989 // END check for a valid field-type (fallback)
990
991 $unique_field_list = wppb_return_unique_field_list();
992 $all_fields = apply_filters( 'wppb_manage_fields_check_field_on_edit_add', get_option ( $meta_name, 'not_set' ), $posted_values );
993
994 // check if the unique fields are only added once
995 if( $all_fields != 'not_set' ){
996 foreach( $all_fields as $field ){
997 if ( ( in_array ( $posted_values['field'], $unique_field_list ) ) && ( $posted_values['field'] == $field['field'] ) && ( $posted_values['id'] != $field['id'] ) ){
998 $message .= __( "Please choose a different field type as this one already exists in your form (must be unique)\n", 'profile-builder' );
999 break;
1000 }
1001 }
1002 }
1003 // END check if the unique fields are only added once
1004
1005 // check for avatar size
1006 if ( $posted_values['field'] == 'Avatar' ){
1007 if ( is_numeric( $posted_values['avatar-size'] ) ){
1008 if ( ( $posted_values['avatar-size'] < 20 ) || ( $posted_values['avatar-size'] > 200 ) )
1009 $message .= __( "The entered avatar size is not between 20 and 200\n", 'profile-builder' );
1010
1011 }else
1012 $message .= __( "The entered avatar size is not numerical\n", 'profile-builder' );
1013
1014 }
1015 // END check for avatar size
1016
1017 // check for correct row value
1018 if ( ( $posted_values['field'] == 'Default - Biographical Info' ) || ( $posted_values['field'] == 'Textarea' ) ){
1019 if ( !is_numeric( $posted_values['row-count'] ) )
1020 $message .= __( "The entered row number is not numerical\n", 'profile-builder' );
1021
1022 elseif ( trim( $posted_values['row-count'] ) == '' )
1023 $message .= __( "You must enter a value for the row number\n", 'profile-builder' );
1024 }
1025 // END check for correct row value
1026
1027
1028 // check for the public and private keys
1029 if ( $posted_values['field'] == 'reCAPTCHA'){
1030 if ( trim( $posted_values['public-key'] ) == '' )
1031 $message .= __( "You must enter the site key\n", 'profile-builder' );
1032 if ( trim( $posted_values['private-key'] ) == '' )
1033 $message .= __( "You must enter the secret key\n", 'profile-builder' );
1034 }
1035 // END check for the public and private keys
1036
1037 // check for the correct the date-format
1038 if ( $posted_values['field'] == 'Datepicker' ){
1039 $date_format = strtolower( $posted_values['date-format'] );
1040 if ( trim( $date_format ) != 'mm/dd/yy' && trim( $date_format ) != 'mm/yy/dd' && trim( $date_format ) != 'dd/yy/mm' &&
1041 trim( $date_format ) != 'dd/mm/yy' && trim( $date_format ) != 'yy/dd/mm' && trim( $date_format ) != 'yy/mm/dd' &&
1042 trim( $date_format ) != 'yy-mm-dd' && trim( $date_format ) != 'DD, dd-M-y' && trim( $date_format ) != 'D, dd M yy' &&
1043 trim( $date_format ) != 'D, d M y' && trim( $date_format ) != 'D, d M yy' && trim( $date_format ) != 'mm-dd-yy' && trim( $date_format ) != '@' )
1044 $message .= __( "The entered value for the Datepicker is not a valid date-format\n", 'profile-builder' );
1045
1046 elseif ( trim( $date_format ) == '' )
1047 $message .= __( "You must enter a value for the date-format\n", 'profile-builder' );
1048 }
1049 // END check for the correct the date-format
1050
1051 //check for empty meta-name and duplicate meta-name
1052 if ( $posted_values['overwrite-existing'] == 'No' ){
1053 $skip_check_for_fields = wppb_return_unique_field_list(true);
1054 $skip_check_for_fields = apply_filters ( 'wppb_skip_check_for_fields', $skip_check_for_fields );
1055
1056 if ( !in_array( trim( $posted_values['field'] ), $skip_check_for_fields ) ){
1057 $unique_meta_name_list = array( 'first_name', 'last_name', 'nickname', 'description' );
1058
1059 //check to see if meta-name is empty
1060 $skip_empty_check_for_fields = array( 'Heading', 'Select (User Role)', 'reCAPTCHA', 'HTML' );
1061
1062 if( !in_array( $posted_values['field'], $skip_empty_check_for_fields ) && empty( $posted_values['meta-name'] ) ) {
1063 $message .= __( "The meta-name cannot be empty\n", 'profile-builder' );
1064 }
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_meta_name_list[] = 'aim';
1069 $unique_meta_name_list[] = 'yim';
1070 $unique_meta_name_list[] = 'jabber';
1071 }
1072
1073 // if the desired meta-name is one of the following, automatically give an error
1074 if ( in_array( trim( $posted_values['meta-name'] ), apply_filters ( 'wppb_unique_meta_name_list', $unique_meta_name_list ) ) )
1075 $message .= __( "That meta-name is already in use\n", 'profile-builder' );
1076
1077 else{
1078 $found_in_custom_fields = false;
1079
1080 if( $all_fields != 'not_set' )
1081 foreach( $all_fields as $field ){
1082 if ( $posted_values['meta-name'] != '' && ( $field['meta-name'] == $posted_values['meta-name'] ) && ( $field['id'] != $posted_values['id'] ) ){
1083 $message .= __( "That meta-name is already in use\n", 'profile-builder' );
1084 $found_in_custom_fields = true;
1085
1086 }elseif ( ( $field['meta-name'] == $posted_values['meta-name'] ) && ( $field['id'] == $posted_values['id'] ) )
1087 $found_in_custom_fields = true;
1088 }
1089
1090 if ( $found_in_custom_fields === false ){
1091 if( $posted_values['meta-name'] != '' ) {
1092 $found_meta_name = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE meta_key = %s", $posted_values['meta-name']));
1093 if ($found_meta_name != null)
1094 $message .= __("That meta-name is already in use\n", 'profile-builder');
1095 }
1096 }
1097 }
1098 }
1099 }
1100 //END check duplicate meta-name
1101
1102 // check for correct meta name on upload field
1103 if( $posted_values['field'] == 'Upload' ) {
1104 if( ! empty( $posted_values['meta-name'] ) && preg_match( '/([^a-z\d_-])/', $posted_values['meta-name'] ) ) {
1105 $message .= __( "The meta-name can only contain lowercase letters, numbers, _ , - and no spaces.\n", 'profile-builder' );
1106 }
1107 }
1108 // END check for correct meta name on upload field
1109
1110 // check for valid default option (checkbox, select, radio)
1111 if ( ( $posted_values['field'] == 'Checkbox' ) || ( $posted_values['field'] == 'Select (Multiple)' ) ) {
1112 $options = array_map( 'trim', explode( ',', $posted_values['options'] ) );
1113 $default_options = ( ( trim( $posted_values['default-options'] ) == '' ) ? array() : array_map( 'trim', explode( ',', $posted_values['default-options'] ) ) );
1114
1115 /* echo "<script>console.log( Posted options: " . print_r($options, true) . "' );</script>";
1116 echo "<script>console.log( Default options: " . print_r($default_options, true) . "' );</script>"; */
1117
1118 $not_found = '';
1119 foreach ( $default_options as $key => $value ){
1120 if ( !in_array( $value, $options ) )
1121 $not_found .= $value . ', ';
1122 }
1123
1124 if ( $not_found != '' )
1125 $message .= sprintf( __( "The following option(s) did not coincide with the ones in the options list: %s\n", 'profile-builder' ), trim( $not_found, ', ' ) );
1126
1127 }elseif ( ( $posted_values['field'] == 'Radio' ) || ( $posted_values['field'] == 'Select' ) ){
1128 if ( ( trim( $posted_values['default-option'] ) != '' ) && ( !in_array( $posted_values['default-option'], array_map( 'trim', explode( ',', $posted_values['options'] ) ) ) ) )
1129 $message .= sprintf( __( "The following option did not coincide with the ones in the options list: %s\n", 'profile-builder' ), $posted_values['default-option'] );
1130 }
1131 // END check for valid default option (checkbox, select, radio)
1132
1133 // check to see if any user role is selected (user-role field)
1134 if( $posted_values['field'] == 'Select (User Role)' ) {
1135 if( empty( $posted_values['user-roles'] ) ) {
1136 $message .= __( "Please select at least one user role\n", 'profile-builder' );
1137 }
1138 }
1139 // END check to see if Administrator user role has been selected (user-role field)
1140
1141 $message = apply_filters( 'wppb_check_extra_manage_fields', $message, $posted_values );
1142
1143 }elseif ( ( $meta_name == 'wppb_rf_fields' ) || ( $meta_name == 'wppb_epf_fields' ) ){
1144 if ( $posted_values['field'] == '' ){
1145 $message .= __( "You must select a field\n", 'profile-builder' );
1146
1147 }else{
1148 $fields_so_far = get_post_meta ( $post_id, $meta_name, true );
1149
1150 foreach ( $fields_so_far as $key => $value ){
1151 if ( $value['id'] == $posted_values['id'] )
1152 $message .= __( "That field is already added in this form\n", 'profile-builder' );
1153 }
1154 }
1155 }
1156 return $message;
1157 }
1158 add_filter( 'wck_extra_message', 'wppb_check_field_on_edit_add', 10, 6 );
1159
1160
1161 /**
1162 * Function that calls the wppb_hide_properties_for_already_added_fields after a field-update
1163 *
1164 * @since v.2.0
1165 *
1166 * @param void
1167 *
1168 * @return string
1169 */
1170 function wppb_manage_fields_after_refresh_list( $id ){
1171 echo "<script type=\"text/javascript\">wppb_hide_properties_for_already_added_fields( '#container_wppb_manage_fields' );</script>";
1172 }
1173 add_action( "wck_refresh_list_wppb_manage_fields", "wppb_manage_fields_after_refresh_list" );
1174 add_action( "wck_refresh_entry_wppb_manage_fields", "wppb_manage_fields_after_refresh_list" );
1175
1176
1177 /**
1178 * Function that calls the wppb_hide_all
1179 *
1180 * @since v.2.0
1181 *
1182 * @param void
1183 *
1184 * @return string
1185 */
1186 function wppb_hide_all_after_add( $id ){
1187 echo "<script type=\"text/javascript\">wppb_hide_all( '#wppb_manage_fields' );</script>";
1188 }
1189 add_action("wck_ajax_add_form_wppb_manage_fields", "wppb_hide_all_after_add" );
1190
1191 /**
1192 * Function that modifies the table header in Manage Fields to add Field Name, Field Type, Meta Key, Required
1193 *
1194 * @since v.2.0
1195 *
1196 * @param $list, $id
1197 *
1198 * @return string
1199 */
1200 function wppb_manage_fields_header( $list_header ){
1201 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>';
1202 }
1203 add_action( 'wck_metabox_content_header_wppb_manage_fields', 'wppb_manage_fields_header' );
1204
1205 /**
1206 * Add contextual help to the side of manage fields for the shortcodes
1207 *
1208 * @since v.2.0
1209 *
1210 * @param $hook
1211 *
1212 * @return string
1213 */
1214 function wppb_add_content_before_manage_fields(){
1215 ?>
1216 <p><?php _e('Use these shortcodes on the pages you want the forms to be displayed:', 'profile-builder'); ?></p>
1217 <ul>
1218 <li><strong class="nowrap">[wppb-register]</strong></li>
1219 <li><strong class="nowrap">[wppb-edit-profile]</strong></li>
1220 <li><strong class="nowrap">[wppb-register role="author"]</strong></li>
1221 </ul>
1222 <p>
1223 <?php
1224 if( PROFILE_BUILDER == 'Profile Builder Pro' )
1225 _e("If you're interested in displaying different fields in the registration and edit profile forms, please use the Multiple Registration & Edit Profile Forms Modules.", 'profile-builder');
1226 else
1227 _e( "With Profile Builder Pro v2 you can display different fields in the registration and edit profile forms, using the Multiple Registration & Edit Profile Forms module.", "profile-builder" )
1228 ?>
1229 </p>
1230 <?php
1231 }
1232 add_action('wck_metabox_content_wppb_manage_fields_info', 'wppb_add_content_before_manage_fields');
1233
1234
1235 /**
1236 * Function that calls the wppb_edit_form_properties
1237 *
1238 * @since v.2.0
1239 *
1240 * @param void
1241 *
1242 * @return string
1243 */
1244 function wppb_remove_properties_from_added_form( $meta_name, $id, $element_id ){
1245 if ( ( $meta_name == 'wppb_epf_fields' ) || ( $meta_name == 'wppb_rf_fields' ) )
1246 echo "<script type=\"text/javascript\">wppb_disable_delete_on_default_mandatory_fields();</script>";
1247
1248 if ( $meta_name == 'wppb_manage_fields' )
1249 echo "<script type=\"text/javascript\">wppb_edit_form_properties( '#container_wppb_manage_fields', 'update_container_wppb_manage_fields_".$element_id."' );</script>";
1250 }
1251 add_action("wck_after_adding_form", "wppb_remove_properties_from_added_form", 10, 3);
1252
1253 /*
1254 * WPML Support for dynamic strings in Profile Builder. Tags: WPML, fields, translate
1255 */
1256 add_filter( 'update_option_wppb_manage_fields', 'wppb_wpml_compat_with_fields', 10, 2 );
1257 function wppb_wpml_compat_with_fields( $oldvalue, $_newvalue ){
1258 $default_fields = array(
1259 'Default - Name (Heading)',
1260 'Default - Contact Info (Heading)',
1261 'Default - About Yourself (Heading)',
1262 'Default - Username',
1263 'Default - First Name',
1264 'Default - Last Name',
1265 'Default - Nickname',
1266 'Default - E-mail',
1267 'Default - Website',
1268 'Default - AIM',
1269 'Default - Yahoo IM',
1270 'Default - Jabber / Google Talk',
1271 'Default - Password',
1272 'Default - Repeat Password',
1273 'Default - Biographical Info',
1274 'Default - Blog Details',
1275 'Default - Display name publicly as'
1276 );
1277
1278 if ( is_array( $_newvalue ) ){
1279 foreach ( $_newvalue as $field ){
1280 if ( in_array($field['field'], $default_fields) ){
1281 $prefix = 'default_field_';
1282 } else {
1283 $prefix = 'custom_field_';
1284 }
1285 if (function_exists('icl_register_string')){
1286 if( !empty( $field['field-title'] ) )
1287 icl_register_string('plugin profile-builder-pro', $prefix . $field['id'].'_title_translation' , $field['field-title'] );
1288 if( !empty( $field['description'] ) )
1289 icl_register_string('plugin profile-builder-pro', $prefix . $field['id'].'_description_translation', $field['description'] );
1290 if( !empty( $field['labels'] ) )
1291 icl_register_string('plugin profile-builder-pro', $prefix . $field['id'].'_labels_translation', $field['labels'] );
1292 if( !empty( $field['default-value'] ) )
1293 icl_register_string('plugin profile-builder-pro', $prefix . $field['id'].'_default_value_translation', $field['default-value'] );
1294 if( !empty( $field['default-content'] ) )
1295 icl_register_string('plugin profile-builder-pro', $prefix . $field['id'].'_default_content_translation', $field['default-content'] );
1296 }
1297 }
1298 }
1299 }
1300
1301
1302 /*
1303 * Returns the HTML for a map given the field
1304 *
1305 */
1306 function wppb_get_map_output( $field, $args ) {
1307
1308 $defaults = array(
1309 'markers' => array(),
1310 'editable' => true,
1311 'show_search' => true,
1312 'extra_attr' => ''
1313 );
1314
1315 $args = wp_parse_args( $args, $defaults );
1316
1317 $return = '';
1318
1319 // Search box
1320 // The style:left=-99999px is set to hide the input from the viewport. It will be rewritten when the map gets initialised
1321 if( $args['show_search'] )
1322 $return .= '<input style="left: -99999px" type="text" id="' . $field['meta-name'] . '-search-box" class="wppb-map-search-box" placeholder="' . __( 'Search Location', 'profile-builder' ) . '" />';
1323
1324 // Map container
1325 $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="' . ( !empty( $field['map-default-zoom'] ) ? (int)$field['map-default-zoom'] : 16 ) . '" data-default-lat="' . $field['map-default-lat'] . '" data-default-lng="' . $field['map-default-lng'] . '" ' . $args['extra_attr'] . '></div>';
1326
1327 if( !empty( $args['markers'] ) ) {
1328 foreach( $args['markers'] as $marker )
1329 $return .= '<input name="' . $field['meta-name'] . '[]" type="hidden" class="wppb-map-marker" value="' . $marker . '" />';
1330 }
1331
1332 return $return;
1333
1334 }
1335
1336
1337 /*
1338 * Returns all the saved markers for a map field for a particular user
1339 *
1340 */
1341 function wppb_get_user_map_markers( $user_id, $meta_name ) {
1342
1343 global $wpdb;
1344
1345 $meta_name_underlined = $meta_name . '_';
1346
1347 $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 );
1348
1349 $markers = array();
1350 $i = 0;
1351
1352 foreach( $results as $key => $result ) {
1353 $pattern = '/^' . $meta_name . '_[0-9]+$/';
1354 preg_match( $pattern, $result[1], $matches );
1355 if ( count ($matches) > 0 ) {
1356 $markers[$i] = $result[0];
1357 $i++;
1358 }
1359
1360 }
1361 return $markers;
1362
1363 }
1364
1365 /*
1366 * Deletes from the database all saved markers
1367 *
1368 */
1369 function wppb_delete_user_map_markers( $user_id, $meta_name ) {
1370
1371 global $wpdb;
1372
1373 $meta_name .= '_';
1374
1375 $delete = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->usermeta} WHERE user_id=%d AND meta_key LIKE %s", $user_id, '%' . $meta_name . '%' ) );
1376
1377 wp_cache_delete( $user_id, 'user_meta' );
1378
1379 }
1380
1381 /**
1382 * Disable the add button again after we added a field
1383 */
1384 add_action( 'wck_ajax_add_form_wppb_manage_fields', 'wppb_redisable_the_add_button' );
1385 function wppb_redisable_the_add_button(){
1386 ?>
1387 <script>wppb_disable_add_entry_button ( '#wppb_manage_fields' );</script>
1388 <?php
1389 }
1390
1391
1392 /**
1393 * 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
1394 */
1395 add_action( 'wck_before_update_meta', 'wppb_change_field_meta_key', 10, 4 );
1396 function wppb_change_field_meta_key( $meta, $id, $values, $element_id ){
1397 if( apply_filters( 'wppb_update_field_meta_key_in_db', false ) ) {
1398 if ($meta == 'wppb_manage_fields') {
1399 global $wpdb;
1400 $wppb_manage_fields = get_option('wppb_manage_fields');
1401 if (!empty($wppb_manage_fields)) {
1402 if (!empty($values['meta-name']) && $wppb_manage_fields[$element_id]['meta-name'] != $values['meta-name']) {
1403 $wpdb->update(
1404 $wpdb->usermeta,
1405 array('meta_key' => sanitize_text_field($values['meta-name'])),
1406 array('meta_key' => sanitize_text_field($wppb_manage_fields[$element_id]['meta-name']))
1407 );
1408 }
1409 }
1410 }
1411 }
1412 }
1413