PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.9.6
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.9.6
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
profile-builder / add-ons-free / custom-css-classes-on-fields / custom-css-classes-on-fields.php

custom-css-classes-on-fields.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.9.6, at add-ons-free/custom-css-classes-on-fields/custom-css-classes-on-fields.php

45 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Description: Extends the functionality of Profile Builder by adding the possibility to have custom css classes on fields
4 */
5
6 /*
7 * Function that enqueues the necessary scripts
8 *
9 * @since v.1.0.0
10 */
11 function wppb_ccc_scripts( $hook ) {
12 if ( $hook == 'profile-builder_page_manage-fields' ) {
13 wp_enqueue_script('wppb-custom-css-class-field', plugin_dir_url(__FILE__) . 'assets/js/main.js', array('jquery', 'wppb-manage-fields-live-change'));
14 }
15 }
16 add_action( 'admin_enqueue_scripts', 'wppb_ccc_scripts' );
17
18 /*
19 * Function that adds the numbers only checkbox on an input field.
20 *
21 * @since v.1.0.0
22 *
23 * @param array $fields - The current field properties
24 *
25 * @return array - The field properties that now include the numbers only checkbox
26 */
27 function wppb_ccc_field( $fields ) {
28 $class = array(
29 'type' => 'text',
30 'slug' => 'class-field',
31 'title' => __( 'CSS Class', 'profile-builder' ),
32 'description' => __( "Add a class to a field. Should not contain dots(.) and for multiple classes separate by space.", 'profile-builder' )
33 );
34 array_push( $fields, $class );
35 return $fields;
36 }
37 add_filter( 'wppb_manage_fields', 'wppb_ccc_field' );
38
39 function wppb_ccc_class( $class, $field, $error_var ){
40 if( !empty( $field['class-field'] ) ){
41 $class .= ' '. esc_attr( $field['class-field'] );
42 }
43 return $class;
44 }
45 add_filter( 'wppb_field_css_class', 'wppb_ccc_class', 10, 3 );