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

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