├── .gitattributes ├── .gitignore ├── README.md ├── bb-extra-fields.php ├── geocode-field ├── README.md ├── bb-geocode-field.php ├── bb-geocode.css └── bb-geocode.js ├── responsive-field └── bb-responsive-field.php ├── slider-field ├── slider.css └── slider_field.php └── toggle-field ├── toggle.css ├── toggle_field.js └── toggle_field.php /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/sublimetext 3 | 4 | ### SublimeText ### 5 | # cache files for sublime text 6 | *.tmlanguage.cache 7 | *.tmPreferences.cache 8 | *.stTheme.cache 9 | 10 | # workspace files are user-specific 11 | *.sublime-workspace 12 | 13 | # project files should be checked into the repository, unless a significant 14 | # proportion of contributors will probably not be using SublimeText 15 | # *.sublime-project 16 | 17 | # sftp configuration file 18 | sftp-config.json 19 | 20 | #pdf-field 21 | pdf-field 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | README 2 | ====== 3 | 4 | *What is this repository for?* 5 | 6 | Beaver Builder Extra Fields allows for the use of custom fields in your custom modules. There are currently the following extra fields: 7 | 8 | - toggle field A multi-option button like field that could substitute for yes/no selectboxes or one/two/three options. It has no set constraints on number of options though but make sure it fits on screen. 9 | 10 | - slider-field using the jquery-ui allows for easy creation of sliders with full-range, min-and-up and up-to-max ranges. Can use step-size. see https://jqueryui.com/slider/ for available options. 11 | 12 | - sliderrange-field using the jquery-ui allows for easy creation of sliders with both min and max range. Can use stepsize. see https://jqueryui.com/slider/ for available options. 13 | 14 | 15 | Version 1.1 16 | ------------------- 17 | 18 | *How do I get set up?* 19 | 20 | download the zip-file 21 | go to /plugins/new plugins 22 | install zip-file 23 | activate 24 | or 25 | 26 | upload zip-file contents to wp-contents/plugins/ using a FTP-client 27 | activate the plugin in the admin-panel 28 | using the fields 29 | 30 | In custom modules register a module and add the field type as you would any other field, for instance: 31 | 32 | Toggle 33 | ------ 34 | 35 | 'my_favorite_animal' => array( 36 | 'type' => 'toggle', 37 | 'label' => __( 'Favorite Animal', 'textdomain' ), 38 | 'default' => 'kitten', 39 | 'options' => array( 40 | 'cat' => __( 'Cat', 'textdomain' ), 41 | 'unicorn' => __( 'Unicorn', 'textdomain' ), 42 | 'hamster' => __( 'Hamster', 'textdomain'), 43 | ), 44 | 'toggle' => array ( 45 | 'cat' => array ( 46 | 'fields' => array ( 'name', 'size' ), 47 | ), 48 | 'unicorn' => array (), 49 | 'hamster' => array (), 50 | ), 51 | 'hide' => array(), 52 | 'trigger' => array(), 53 | 'oncolor' => '#333333', 54 | 'offcolor' => '#d1d1d1', 55 | ), 56 | 57 | Slider 58 | ------ 59 | 60 | 'number_of_unicorns' => array( 61 | 'type' => 'slider', 62 | 'label' => __( 'Unicorns' , 'textdomain' ), 63 | 'settings' => array ( 64 | 'min' => 0, // min value for slider 65 | 'max' => 60, // max value for slider 66 | 'value' => 30, // default value to use when not set 67 | 'range' => 'min', // optional: min|max , do not set if no min- or max-range needed 68 | 'step' => 5, // optional: step size, default to one 69 | 'color' => '#666666', 70 | ), 71 | ), 72 | 73 | Slider Range 74 | ------------ 75 | 76 | 'number_of_kittens' => array( 77 | 'type' => 'sliderrange', 78 | 'label' => __( 'Kittens' , 'textdomain' ), 79 | 'settings' => array ( 80 | 'min' => 0, // min value for slider 81 | 'max' => 10, // max value for slider 82 | 'defmin' => 0, // default min value 83 | 'defmax' => 10, // default max value 84 | 'value' => 2, // default value to use when not set 85 | 'step' => 2, // step size 86 | 'color' => '#666666', 87 | ), 88 | ), 89 | 90 | Using the returned values 91 | ------------------------- 92 | **Toggle & Slider field** 93 | Both Toggle and Slider field return the set value. From the code examples above, you should be able to get the field-value by using the 94 | 95 | echo 'Your favorite animal is a(n) ' . $settings->my_favorite_animal; 96 | 97 | and 98 | 99 | echo 'You have a total of ' . $settings->number_of_unicorns . 'unicorns!'; 100 | 101 | **Sliderrange field** 102 | The sliderrange will have 2 values, that you will need to explode in order to get two seperate values. 103 | 104 | $values = explode( '|' , $settings->number_of_kittens ); 105 | echo 'having ' . $values[1] . ' kittens is more than having ' . $values[0]; 106 | 107 | 108 | Dependencies 109 | ------------ 110 | 111 | Since your custom modules will need to be sure to have the custom field available, make sure to test for the existence of the bbExtraFields class at the top of your modules code (somewhere right after the opening php tag. If not, don't register the module and return. it won't show in Beaver Builder until you reactivate the bb-extra-fields plugin. 112 | 113 | if ( ! class_exists ( bbExtraFields ) ) { return; } 114 | 115 | version history 116 | 1.1 removed the geotag field. Updated toggle-field code, sliderrange-field. Fields have fallback default settings. 117 | 1.0 - 118 | -------------------------------------------------------------------------------- /bb-extra-fields.php: -------------------------------------------------------------------------------- 1 | array( 12 | 'type' =>"geocode", 13 | 'label' => __( 'Geocode' , 'textdomain' ), 14 | 'settings' => array ( 15 | 'default' => '', 16 | 'placeholder' => 'enter location', 17 | 'foundcolor' => '#060', 18 | 'notfoundcolor' => '#900', 19 | ), 20 | ), 21 | 22 | Button text is handled by the textdomain translation files 23 | 24 | USING THE SET FIELD-VALUE WITHIN YOUR CODE 25 | 26 | The Field-value is a uriencoded json value. This means the set data has to be urldecoded first and then json decoded: 27 | 28 | geocode ) ) ); 33 | 34 | $address = $geocode->address; 35 | $lat = $geocode->marker->lat; 36 | $lng = $geocode->marker->lng; 37 | ?> 38 | 39 | or Using Javascript / jQuery 40 | 41 | var myValueArray = JSON.parse( decodeURIComponent( 'geocode; ?>'' ) ); 42 | 43 | then access them using 44 | 45 | var address = myValueArray.address; 46 | var lat = myValueArray.marker.lat; 47 | var lng = myValueArray.marker.lng; 48 | -------------------------------------------------------------------------------- /geocode-field/bb-geocode-field.php: -------------------------------------------------------------------------------- 1 | 26 |
27 |
28 |
33 |
34 | 46 | 47 | 63 | 64 | 20 |
21 |
22 |
28 |
29 | array( 29 | 'min' => 0 , 30 | 'max' => 10 , 31 | 'defmin' => 0 , 32 | 'defmax' => 10 , 33 | 'value' => '0|10' , 34 | 'step' => 1 , 35 | 'color' => '#666666' 36 | ) 37 | ) , $field ); 38 | 39 | if ( sizeof( $value = explode( '|' , $value ) ) !== 2 ) { 40 | $value = array ( $field[ 'settings' ][ 'defmin' ], $field[ 'settings' ]['defmax' ] ); 41 | } 42 | ?> 43 | 66 |
67 |
68 |
69 |
70 |
71 | "> 72 |
73 | array( 82 | 'min' => 0 , 83 | 'max' => 10 , 84 | 'range' => 'min', 85 | 'value' => 10 , 86 | 'step' => 1 , 87 | 'color' => '#666666' 88 | ) 89 | ) , $field ); 90 | 91 | if ( $value==null ) $value = $field[ 'settings' ][ 'value' ]; 92 | 93 | ?> 94 | 114 |
115 |
116 |
117 | 118 |
119 |
120 |
121 |
122 |
123 | 124 |
125 | array( 30 | * 'type' => 'toggle', 31 | * 'label' => __( 'Graph Type', 'textdomain' ), 32 | * 'default' => 'Line', 33 | * 'options' => array( 34 | * 'Line' => __( 'Line', 'textdomain' ), 35 | * 'Bar' => __( 'Bar', 'textdomain' ), 36 | * 'Radar' => __( 'Radar', 'textdomain'), 37 | * ), 38 | * 'toggle' => array ( 39 | * 'Line' => array ( 40 | * 'fields' => array ( 'usebeziers', 'beziercurvetension' ), 41 | * ), 42 | * 'Bar' => array (), 43 | * 'Radar' => array (), 44 | * ), 45 | * 'hide' => array(), 46 | * 'trigger' => array(), 47 | * 'oncolor' => '#333333', 48 | * 'offcolor' => '#d1d1d1', 49 | * 50 | */ 51 | function fl_toggle_field_true( $name , $value , $field ) { 52 | 53 | // merge settings with default settings 54 | $field = array_merge( 55 | array( 'settings' => array( 56 | 'oncolor' => '#e4e4e4' , 57 | 'offcolor' => '#a5dc86' , 58 | ) 59 | ) , $field ); 60 | 61 | $buttoncount = count($field['options']); 62 | 63 | ?> 64 |
65 | 73 | $option ) { 78 | 79 | $checked = ''; 80 | if ( isset( $value ) && $key == $value ) { 81 | $checked = 'checked'; 82 | } elseif ( !isset( $value ) && $key == $field[ 'default' ] ) { 83 | $checked = 'checked'; 84 | } 85 | 86 | $toggle = isset( $field[ 'toggle' ][ $key ]) ? 'data-toggle=\''. json_encode( $field[ 'toggle' ] ) . '\'' : ''; 87 | $hide = isset( $field[ 'hide' ][ $key ]) ? 'data-hide="'. json_encode( $field[ 'hide' ] ) . '"' : ''; 88 | $trigger = isset( $field[ 'trigger' ][ $key ] )? 'data-trigger="'. json_encode( $field[ 'trigger' ] ) . '"' : ''; 89 | 90 | $html = sprintf( '' , $toggle , $hide , $trigger ); 92 | $html .= sprintf( '' , $name , $name . '_' . $key , $option ); 93 | 94 | echo $html; 95 | } 96 | ?> 97 |
98 |