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

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