PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.3
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
← All changes | admin/advanced-settings/includes/forms/placeholder-labels.php +79 -13 3.9.9 → 4.0.3 View file →
@@ -1,5 +1,8 @@
1 1 <?php
2 +// Exit if accessed directly
3 +if ( ! defined( 'ABSPATH' ) ) exit;
4 +
2 5 /*
3 6 * Function that enqueues the necessary scripts in the front-end area
4 7 *
5 8 * @since v.1.0
@@ -27,9 +30,9 @@
27 30 */
28 31 function wppb_pbpl_field_css_class( $field ) {
29 32 $field = esc_attr( $field );
30 33
31 - if( strpos( $field, 'wppb-subscription-plans' ) == false ) {
34 + if( strpos( $field, 'wppb-subscription-plans' ) == false && strpos( $field, 'wppb-default-blog-details' ) == false ) {
32 35 $field = $field . ' pbpl-class';
33 36 }
34 37
35 38 return $field;
@@ -64,8 +67,9 @@
64 67 'Datepicker',
65 68 'Number',
66 69 'Validation',
67 70 'Email',
71 + 'Input (Hidden)',
68 72 );
69 73
70 74 if( ! empty ( $field ) && in_array( $field['field'], $extra_attr_only_for ) ) {
71 75 $extra_attribute .= 'placeholder = "' . esc_attr( wppb_icl_t( 'plugin profile-builder-pro', 'custom_field_'.$field['id'].'_title_translation', $field['field-title'], true ) ) . ( ( $field['required'] == 'Yes' ) ? '*' : '' ) . '"';
@@ -102,13 +106,13 @@
102 106
103 107 if( $pbpl_pb_moduleSettings != 'not_found' ) {
104 108
105 109 if( $pbpl_pb_moduleSettings['wppb_multipleRegistrationForms'] == 'show' ) {
106 - add_meta_box( 'pbpl-rf-side', __( 'Placeholder Labels', 'profile-builder' ), 'wppb_pbpl_meta_box_content', 'wppb-rf-cpt', 'normal', 'low' );
110 + add_meta_box( 'pbpl-rf-side', __( 'Placeholder Labels', 'profile-builder' ), 'wppb_pbpl_meta_box_content', 'wppb-rf-cpt', 'side', 'low' );
107 111 }
108 112
109 113 if( $pbpl_pb_moduleSettings['wppb_multipleEditProfileForms'] == 'show' ) {
110 - add_meta_box( 'pbpl-epf-side', __( 'Placeholder Labels', 'profile-builder' ), 'wppb_pbpl_meta_box_content', 'wppb-epf-cpt', 'normal', 'low' );
114 + add_meta_box( 'pbpl-epf-side', __( 'Placeholder Labels', 'profile-builder' ), 'wppb_pbpl_meta_box_content', 'wppb-epf-cpt', 'side', 'low' );
111 115 }
112 116
113 117 }
114 118 }
@@ -135,12 +139,14 @@
135 139 <label class="cozmoslabs-toggle-track" for="pbpl-active"></label>
136 140 </div>
137 141
138 142 <div class="cozmoslabs-toggle-description">
139 - <p class="cozmoslabs-description"><?php esc_html_e( 'Replace labels with placeholders', 'profile-builder' ) ?></p>
143 + <label for="pbpl-active" class="cozmoslabs-description"><?php esc_html_e( 'Replace labels with placeholders', 'profile-builder' ) ?></label>
140 144 </div>
141 145 </div>
142 146 <?php
147 +
148 + wp_nonce_field( 'wppb-pbpl-post-'. $post->ID .'-options-verify', 'wppb_pbpl_save_post_options', false );
143 149 }
144 150
145 151
146 152 /*
@@ -148,17 +154,25 @@
148 154 *
149 155 * @since v.2.0
150 156 *
151 157 */
152 -function wppb_pbpl_save_meta_box_option() {
153 - global $post;
158 +function wppb_pbpl_save_meta_box_option( $post_id ) {
154 159
155 - if( isset( $_POST['pbpl-active'] ) ) {
156 - $pbpl_select_value = sanitize_text_field( $_POST['pbpl-active'] );
160 + if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
161 + return;
157 162
158 - update_post_meta( $post->ID, 'pbpl-active', $pbpl_select_value );
159 - }
160 - elseif ( !empty( $post->ID ) ) update_post_meta( $post->ID, 'pbpl-active', 'no' );
163 + /* Verify our metabox nonce before current_user_can — save_post runs for every
164 + * post type and map_meta_cap warns if the CPT is unregistered. */
165 + if( ! isset( $_POST['wppb_pbpl_save_post_options'] ) || ! wp_verify_nonce( sanitize_text_field( $_POST['wppb_pbpl_save_post_options'] ), 'wppb-pbpl-post-'. $post_id .'-options-verify' ) )
166 + return;
167 +
168 + if( ! current_user_can( 'edit_post', $post_id ) )
169 + return;
170 +
171 + if( isset( $_POST['pbpl-active'] ) && $_POST['pbpl-active'] == 'yes' )
172 + update_post_meta( $post_id, 'pbpl-active', 'yes' );
173 + else delete_post_meta( $post_id, 'pbpl-active' );
174 +
161 175 }
162 176 add_action( 'save_post', 'wppb_pbpl_save_meta_box_option' );
163 177
164 178
@@ -172,12 +186,12 @@
172 186 function wppb_pbpl_activate( $form ) {
173 187 $pbpl_pb_moduleSettings = get_option( 'wppb_module_settings', 'not_found' );
174 188
175 189 if( ( $pbpl_pb_moduleSettings != 'not_found' && isset( $pbpl_pb_moduleSettings['wppb_multipleRegistrationForms'] ) && $pbpl_pb_moduleSettings['wppb_multipleRegistrationForms'] == 'show' ) || ( $pbpl_pb_moduleSettings != 'not_found' && isset( $pbpl_pb_moduleSettings['wppb_multipleEditProfileForms'] ) && $pbpl_pb_moduleSettings['wppb_multipleEditProfileForms'] == 'show' ) ) {
176 - if( ! empty( $form['ID'] ) ) {
190 + if( wppb_pbpl_form_uses_per_form_option( $form ) ) {
177 191 $pbpl_saved_value = get_post_meta( $form['ID'], 'pbpl-active', true );
178 192
179 - if( $pbpl_saved_value == 'no' ) {
193 + if( $pbpl_saved_value != 'yes' ) {
180 194 return;
181 195 } else {
182 196 wppb_pbpl_add_filters();
183 197 }
@@ -191,8 +205,38 @@
191 205 add_action( 'wppb_form_args_before_output', 'wppb_pbpl_activate' );
192 206
193 207
194 208 /*
209 + * Function that decides whether a form is governed by the per-form "Enable Placeholders" option
210 + *
211 + * - a bare shortcode resolves to the default form, which nobody ever opted in on
212 + * - the modern form builder hides the meta box, so the option cannot be set there
213 + * - when it does not apply, the global Placeholder Labels setting decides
214 + *
215 + * @param array $form Contain the form args
216 + *
217 + * @return bool
218 + */
219 +function wppb_pbpl_form_uses_per_form_option( $form ) {
220 + if( empty( $form['ID'] ) )
221 + return false;
222 +
223 + if( empty( $form['form_name'] ) || $form['form_name'] === 'unspecified' )
224 + return false;
225 +
226 + if( ! function_exists( 'wppb_fb_is_active_for' ) )
227 + return true;
228 +
229 + $post_type = get_post_type( $form['ID'] );
230 +
231 + if( ! in_array( $post_type, array( 'wppb-rf-cpt', 'wppb-epf-cpt' ), true ) )
232 + return false;
233 +
234 + return ! wppb_fb_is_active_for( $post_type );
235 +}
236 +
237 +
238 +/*
195 239 * Function that adds the necessary filters
196 240 *
197 241 * @since v.2.0
198 242 *
@@ -198,8 +242,9 @@
198 242 *
199 243 */
200 244 function wppb_pbpl_add_filters() {
201 245 add_filter( 'wppb_field_css_class', 'wppb_pbpl_field_css_class', 10, 1 );
246 + add_filter( 'wppb_blog_details_field_css_class', 'wppb_pbpl_field_css_class', 10, 1 );
202 247 add_filter( 'wppb_extra_attribute', 'wppb_pbpl_extra_attribute', 10, 3 );
203 248 add_filter( 'wppb_woo_extra_attribute', 'wppb_pbpl_woo_extra_attribute', 10, 2 );
204 249 add_filter( 'wppb_extra_select_option', 'wppb_pbpl_extra_select_option', 10, 3 );
205 250 add_filter( 'wppb_select2_multiple_arguments', 'wppb_pbpl_select2_multiple_placeholder', 10, 3 );
@@ -301,8 +346,27 @@
301 346 return $extra_attr;
302 347 }
303 348 add_filter( 'wppb_resend_activation_extra_attr', 'wppb_pbpl_resend_activation', 10, 3 );
304 349
350 +
351 +/**
352 + * Add Placeholder to Blog Details Fields
353 + *
354 + */
355 +function wppb_pbpl_blog_details( $placeholder, $field_slug, $label ){
356 +
357 + if( $field_slug !== 'default_field_blog_url' && $field_slug !== 'default_field_blog_title' )
358 + return $placeholder;
359 +
360 + return ' placeholder="'. esc_attr( $label ) . '" ';
361 +}
362 +add_filter( 'wppb_blog_details_field_placeholder', 'wppb_pbpl_blog_details', 10, 3 );
363 +
364 +
365 +/**
366 + * Add Placeholder Labels classes
367 + *
368 + */
305 369 function wppb_pbpl_add_resend_activation_classes( $classes, $field ) {
306 370 $forms_settings = get_option( 'wppb_toolbox_forms_settings' );
307 371
308 372 if ( $forms_settings['placeholder-labels'] == 'yes' )
@@ -310,5 +374,7 @@
310 374
311 375 return $classes;
312 376 }
313 377 add_filter( 'wppb_resend_activation_extra_css_class', 'wppb_pbpl_add_resend_activation_classes', 20, 2);
378 +add_filter( 'wppb_login_field_extra_css_class', 'wppb_pbpl_add_resend_activation_classes', 20, 2);
379 +add_filter( 'wppb_recover_field_extra_css_class', 'wppb_pbpl_add_resend_activation_classes', 20, 2);
314 380