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 +35 -3 3.16.4 → 4.0.3 View file →
@@ -159,12 +159,14 @@
159 159
160 160 if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
161 161 return;
162 162
163 - if( ! current_user_can( 'edit_post', $post_id ) )
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' ) )
164 166 return;
165 167
166 - 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' ) )
168 + if( ! current_user_can( 'edit_post', $post_id ) )
167 169 return;
168 170
169 171 if( isset( $_POST['pbpl-active'] ) && $_POST['pbpl-active'] == 'yes' )
170 172 update_post_meta( $post_id, 'pbpl-active', 'yes' );
@@ -184,9 +186,9 @@
184 186 function wppb_pbpl_activate( $form ) {
185 187 $pbpl_pb_moduleSettings = get_option( 'wppb_module_settings', 'not_found' );
186 188
187 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' ) ) {
188 - if( ! empty( $form['ID'] ) ) {
190 + if( wppb_pbpl_form_uses_per_form_option( $form ) ) {
189 191 $pbpl_saved_value = get_post_meta( $form['ID'], 'pbpl-active', true );
190 192
191 193 if( $pbpl_saved_value != 'yes' ) {
192 194 return;
@@ -200,8 +202,38 @@
200 202 wppb_pbpl_add_filters();
201 203 }
202 204 }
203 205 add_action( 'wppb_form_args_before_output', 'wppb_pbpl_activate' );
206 +
207 +
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 +}
204 236
205 237
206 238 /*
207 239 * Function that adds the necessary filters