The post Settings Field Visibility appeared first on Elegant Themes Documentation.
]]>Note: This tutorial series is intended for advanced users. At least a basic understanding of coding in PHP and JavaScript is required.
The visibility of a module setting can depend on the value of other settings by including one or both of the parameters described below in the setting definition.
setting_a
when:setting_b
is on
<?php | |
... | |
public function get_fields() { | |
return array( | |
'setting_a' => array( | |
'label' => esc_html__( 'Setting A', 'myex-my-extension' ), | |
'type' => 'text', | |
'option_category' => 'basic_option', | |
'description' => esc_html__( 'Input something here.', 'myex-my-extension' ), | |
'toggle_slug' => 'main_content', | |
'show_if' => array( | |
'setting_b' => 'on', | |
), | |
), | |
'setting_b' => array( | |
... | |
), | |
); | |
} | |
... |
setting_c
when:setting_b
is on
setting_a
is not some_value
<?php | |
... | |
public function get_fields() { | |
return array( | |
'setting_a' => array( | |
... | |
), | |
'setting_b' => array( | |
... | |
), | |
'setting_c' => array( | |
'label' => esc_html__( 'Setting C', 'myex-my-extension' ), | |
'type' => 'text', | |
'option_category' => 'basic_option', | |
'description' => esc_html__( 'Input something else here.', 'myex-my-extension' ), | |
'toggle_slug' => 'main_content', | |
'show_if' => array( | |
'setting_b' => 'on', | |
), | |
'show_if_not' => array( | |
'setting_a' => 'some value', | |
), | |
), | |
); | |
} | |
... |
setting_a
when:setting_b
is one of value_1
, value_3
, value_4
setting_c
is not some_value
setting_d
is not one of value_1
, value_4
<?php | |
... | |
public function get_fields() { | |
return array( | |
'setting_a' => array( | |
'label' => esc_html__( 'Setting A', 'myex-my-extension' ), | |
'type' => 'text', | |
'option_category' => 'basic_option', | |
'description' => esc_html__( 'Input something here.', 'myex-my-extension' ), | |
'toggle_slug' => 'main_content', | |
'show_if' => array( | |
'setting_b' => array( 'value_1', 'value_3', 'value_4' ), | |
), | |
'show_if_not' => array( | |
'setting_c' => 'some_value', | |
'setting_d' => array( 'value_1', 'value_4' ), | |
), | |
), | |
'setting_b' => array( | |
... | |
), | |
'setting_c' => array( | |
... | |
), | |
'setting_d' => array( | |
... | |
), | |
); | |
} | |
... |
The post Settings Field Visibility appeared first on Elegant Themes Documentation.
]]>The post Module Settings Groups appeared first on Elegant Themes Documentation.
]]>Note: This tutorial series is intended for advanced users. At least a basic understanding of coding in PHP and JavaScript is required.
When editing modules inside the Divi Builder, their settings appear in collapsable groups . You can assign a setting to a specific group using the toggle_slug
parameter in the setting definition. You can use one of the builder’s predefined settings groups or you can use a custom group.
The following groups are predefined and can be used by simply including one of their slugs as the toggle_slug
parameter in a setting definition.
Display Name | Slug |
---|---|
Admin Label | admin_label |
Alignment | alignment |
Animation | animation |
Arrows Color | arrows_color |
Attributes | attributes |
Audio | audio |
Background | background |
Bar Counter | bar |
Body Text | body |
Border | border |
Box Shadow | box_shadow |
Bullet | bullet |
Button One | button_one |
Button Two | button_two |
Button | button |
CSS ID & Classes | classes |
Caption Text | caption |
Categories | categories |
Circle | circle |
Color | color |
Conditional Logic | conditional_logic |
Content Text | content |
Controls Colors | colors |
Controls | controls |
Currency & Frequency Text | currency_frequency |
Custom CSS | custom_css |
Dividers | dividers |
Dropdown Menu | dropdown |
Elements | elements |
Email Account | provider |
Exceptions | exceptions |
Excluded Item | excluded |
Featured Image | featured_image |
Field Options | field_options |
Field Text | form_field |
Fields | fields |
Filter Criteria Text | filter |
Filters | filters |
Icon | icon |
Image & Icon | icon_settings |
Image & Video | image_video |
Images | images |
Image | image |
Input Text | input |
Label Text | label |
Layout | layout |
Links | links |
Link | link |
Map | child_filters |
Map | map |
Menu Text | menu |
Meta Text | meta |
Module Text | module |
Navigation | navigation |
Number Text | number |
Numbers Text | numbers |
Overlay | overlay |
Pagination Text | pagination |
Percentage Text | percent |
Play Icon | play_icon |
Player Pause | player_pause |
Portfolio Title Text | portfolio_header |
Price Text | price |
Redirect | redirect |
Result Message Text | result_message |
Rotation | rotation |
Sale Badge | badge |
Scroll Down Icon | scroll_down |
Search Field | field |
Sizing | width |
Spacing | margin_padding |
State | state |
Styles | styles |
Subhead Text | subhead |
Subheader Text | subheader |
Success Action | success_action |
Tab Text | tab |
Text | main_content |
Text | text |
Title Text | header |
Title Text | title |
Toggle Text | toggle |
Visibility | visibility |
Settings can be assigned to a custom group in the same way that you would assign them to predefined groups. However, you must also define all custom groups in the get_settings_modal_toggles()
method of your module’s PHP class.
Settings Group Definition
toggles
(array) — All settings group definitions for the tab
<?php | |
... | |
public function get_fields() { | |
return array( | |
'toggle_toppings_mushroom' => array( | |
'label' => esc_html__('Add Mushroom?', 'simp-simple-extension'), | |
'type' => 'yes_no_button', | |
'option_category' => 'basic_option', | |
'description' => esc_html__('Toggle whether mushroom will be added to the pizza.', 'simp-simple-extension'), | |
'toggle_slug' => 'pizza', | |
'options' => array( | |
'on' => esc_html__( 'Yes', 'simp-simple-extension'), | |
'off' => esc_html__( 'No', 'simp-simple-extension'), | |
), | |
'sub_toggle' => 'pizza_toppings_mushroom', | |
), | |
'quantity_toppings_mushroom' => array( | |
'label' => esc_html__('How Much Mushroom?', 'simp-simple-extension'), | |
'type' => 'range', | |
'option_category' => 'basic_option', | |
'description' => esc_html__('Dropdown menu with various options.', 'simp-simple-extension'), | |
'toggle_slug' => 'pizza', | |
'range_settings' => array( | |
'min' => '1', | |
'max' => '5', | |
'step' => '1', | |
), | |
'show_if' => array( | |
'toggle_toppings_mushroom' => 'on', | |
), | |
'sub_toggle' => 'pizza_toppings_mushroom', | |
), | |
'toggle_toppings_anchovy' => array( | |
'label' => esc_html__('Add Anchovies?', 'simp-simple-extension'), | |
'type' => 'yes_no_button', | |
'option_category' => 'basic_option', | |
'description' => esc_html__('Toggle whether anchovies will be added to the pizza.', 'simp-simple-extension'), | |
'toggle_slug' => 'pizza', | |
'options' => array( | |
'on' => esc_html__( 'Yes', 'simp-simple-extension'), | |
'off' => esc_html__( 'No', 'simp-simple-extension'), | |
), | |
'sub_toggle' => 'pizza_toppings_anchovy', | |
), | |
'quantity_toppings_anchovy' => array( | |
'label' => esc_html__('How Many Anchovies?', 'simp-simple-extension'), | |
'type' => 'range', | |
'option_category' => 'basic_option', | |
'description' => esc_html__('Dropdown menu with various options.', 'simp-simple-extension'), | |
'toggle_slug' => 'pizza', | |
'range_settings' => array( | |
'min' => '1', | |
'max' => '30', | |
'step' => '1', | |
), | |
'show_if' => array( | |
'toggle_toppings_anchovy' => 'on', | |
), | |
'sub_toggle' => 'pizza_toppings_anchovy', | |
), | |
'toggle_toppings_pineapple' => array( | |
'label' => esc_html__('Add Pineapple?', 'simp-simple-extension'), | |
'type' => 'yes_no_button', | |
'option_category' => 'basic_option', | |
'description' => esc_html__('Toggle whether pineapple will be added to the pizza.', 'simp-simple-extension'), | |
'toggle_slug' => 'pizza', | |
'options' => array( | |
'on' => esc_html__( 'Yes', 'simp-simple-extension'), | |
'off' => esc_html__( 'No', 'simp-simple-extension'), | |
), | |
'default' => 'on', | |
'sub_toggle' => 'pizza_toppings_pineapple', | |
), | |
'quantity_toppings_pineapple' => array( | |
'label' => esc_html__('How Much Pineapple?', 'simp-simple-extension'), | |
'type' => 'range', | |
'option_category' => 'basic_option', | |
'description' => esc_html__('Dropdown menu with various options.', 'simp-simple-extension'), | |
'toggle_slug' => 'pizza', | |
'range_settings' => array( | |
'min' => '1', | |
'max' => '9001', | |
'step' => '1', | |
), | |
'default' => '9001', | |
'show_if' => array( | |
'toggle_toppings_pineapple' => 'on', | |
), | |
'sub_toggle' => 'pizza_toppings_pineapple', | |
), | |
'toppings_other' => array( | |
'label' => esc_html__('Content', 'simp-simple-extension'), | |
'type' => 'text', | |
'option_category' => 'basic_option', | |
'description' => esc_html__('Add any special requests for toppings not in the list.', 'simp-simple-extension'), | |
'toggle_slug' => 'pizza', | |
'sub_toggle' => 'pizza_toppings_other', | |
), | |
); | |
} | |
public function get_settings_modal_toggles() { | |
return array( | |
'advanced' => array( | |
'toggles' => array( | |
'pizza' => array( | |
'priority' => 24, | |
'sub_toggles' => array( | |
'pizza_toppings_mushroom' => array( | |
'name' => 'Mushroom', | |
'icon_svg' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" enable-background="new 0 0 128 128"><g style="transform: scale(0.4) translate(-180px, -315px);"><path d="m348.71 602.06c-45.253-4.9694-60.54-23.605-52.021-63.415 1.1181-5.225 2.9033-14.45 3.9672-20.5 1.0638-6.05 2.8242-15.275 3.912-20.5 3.0758-14.774 7.9303-37.399 10.621-49.5 4.2048-18.912 4.2078-18.95 1.4114-17.961-6.1222 2.1653-32.95-0.44034-45.358-4.4053-4.9676-1.5874-12.857-4.0436-17.532-5.4582s-11.2-3.7096-14.5-5.0999-7.437-2.5386-9.1933-2.5516c-8.9383-0.0664-8.8343-18.703 0.1714-30.706 1.9879-2.6496 6.3264-8.5071 9.641-13.017 10.756-14.633 23.614-23.129 46.881-30.973 4.125-1.3907 11.721-4.1277 16.881-6.0822 9.3809-3.5536 28.656-4.1115 58.619-1.6966 45.142 3.6382 92.192 35.014 102.58 68.409 12.555 40.347 1.5058 61.959-28.422 55.593-10.792-2.2954-36.499-10.949-44.662-15.035-9.7094-4.8598-11.484-5.2888-9.9396-2.4027 0.67766 1.2662 1.1948 3.6145 1.1492 5.2183-0.0456 1.6039 1.6955 8.823 3.869 16.042 2.1736 7.2195 4.6105 18.076 5.4154 24.126 0.80487 6.05 1.9332 12.575 2.5075 14.5 5.8634 19.656 7.6253 47.835 4.0338 64.515-2.9524 13.712-5.7467 19.121-14.364 27.802-10.294 10.371-21.853 14.615-35.671 13.098zm13.996-18.913c18.645-9.4482 26.833-38.582 19.532-69.502-0.8441-3.575-2.4244-11.675-3.5119-18-3.736-21.73-5.1194-28.253-7.6076-35.868-5.9585-18.237-5.9803-24.637-0.0938-27.488 3.5546-1.7216-1.7392-4.6986-23.565-13.252-5.0878-1.9939-9.7746-3.8312-10.415-4.0829-0.81267-0.31924-1.0124 0.69859-0.66064 3.3667 0.32795 2.4876-0.55996 7.8439-2.5403 15.324-1.6745 6.325-4.3939 18.475-6.0433 27-1.6493 8.525-4.1689 20.9-5.599 27.5s-3.0358 14.025-3.5684 16.5c-0.53252 2.475-1.3869 7.466-1.8986 11.091-0.51169 3.6251-2.3015 13.3-3.9773 21.5-5.6777 27.782-4.7203 32.823 7.7397 40.757 11.443 7.2861 32.844 9.8992 42.209 5.1538zm87.766-145.75c2.2642-2.8106 2.5355-7.75 0.42578-7.75-1.2623 0-2.194 0.88854-2.5913 2.4711-0.89732 3.5752-3.8283 4.7801-9.3847 3.8581-6.09-1.0106-6.1773-1.0083-6.4052 0.17078-0.43771 2.2643 16.205 3.4229 17.955 1.25zm-127.26-23.76c3.2664-6.3166-45.948-13.36-58.825-8.4187-2.5087 0.96267-2.0343 2.3105 1.0687 3.0366 1.5125 0.35393 6.353 1.6662 10.757 2.9161 8.1836 2.3228 21.885 4.288 33.493 4.8041 3.575 0.15893 7.7259 0.37568 9.2243 0.48165 2.1162 0.14967 3.072-0.47975 4.2822-2.8198z" style="fill:#daaf6f" /><path id="path3473" d="m342.71 600.03c-19.461-3.4729-25.772-6.3378-38.984-17.695-8.8988-7.6502-10.792-21.474-5.9958-43.789 1.1114-5.171 3.5752-17.727 5.4752-27.902s4.6259-23.675 6.0574-30c2.9858-13.192 7.9759-36.78 9.5838-45.301 1.2976-6.8771 0.95743-7.4045-3.9339-6.0989-2.5571 0.68252-7.9837 0.61954-17.218-0.19984-14.154-1.2559-16.666-1.6864-23.985-4.1102-2.475-0.81973-9.7298-2.979-16.122-4.7983-6.392-1.8193-13.068-4.0559-14.836-4.9701-1.768-0.91425-6.1456-2.2755-9.728-3.0251-7.8946-1.6518-7.0526-0.62123-7.3509-8.9967-0.40075-11.249-0.23586-11.845 5.7102-20.624 17.856-26.363 30.042-35.483 60.052-44.945 6.7237-2.1198 13.699-4.6591 15.5-5.6429 5.9037-3.2243 49.271-2.3831 66.775 1.2952 40.144 8.4359 64.995 24.496 84.74 54.763 9.981 15.3 13.182 43.085 6.4781 56.226-7.7178 15.128-35.612 11.684-80.33-9.9194-21.242-10.262-27.831-13.21-39.388-17.625-5.5-2.1008-10.788-4.14-11.75-4.5315-2.3824-0.96903-2.2411 1.0111 0.25 3.5022 2.3811 2.3811 2.5002 4.9518 0.53614 11.568-1.6863 5.6808-5.8882 24.599-8.5361 38.432-1.0002 5.225-3.001 14.9-4.4463 21.5-3.3187 15.156-5.2307 24.763-6.0699 30.5-0.36203 2.475-1.9892 11.381-3.616 19.792-3.5455 18.33-4.0823 29.706-1.5818 33.522 5.92 9.0351 24.075 15.686 42.818 15.686 25.17 0 39.592-36.289 30.005-75.5-1.2103-4.95-3.0423-14.625-4.071-21.5-2.2303-14.905-4.0568-22.931-7.5013-32.963-4.0505-11.797-4.4979-20.361-1.1774-22.537 5.298-3.4714 10.803 0.90497 11.949 9.4998 0.33012 2.475 2.2266 9.8528 4.2145 16.395 1.9878 6.5423 4.2116 16.442 4.9418 22 0.73012 5.5577 2.4824 15.055 3.894 21.105 14.614 62.636-8.1583 104.77-52.359 96.886zm109.18-162.42c1.9022-2.2665 4.9544-14.524 4.3567-17.495-0.21747-1.0813-0.94317-6.1436-1.6127-11.25-0.6695-5.106-1.6067-9.5242-2.0826-9.8184-0.47593-0.29414-1.4918-2.0342-2.2575-3.8668-0.76571-1.8326-3.4589-5.8693-5.9848-8.9705-2.526-3.1012-4.5926-6.0748-4.5926-6.608 0-1.5006-13.026-13.915-16.45-15.679-1.6775-0.86375-4.4-2.576-6.05-3.8051-3.21-2.391-25.301-10.469-28.63-10.469-1.0994 0-4.1074-0.85374-6.6844-1.8972-6.0166-2.4362-19.737-5.489-21.547-4.7942-0.76645 0.29411-6.2861-0.12609-12.266-0.93379-5.9798-0.80771-12.672-1.191-14.872-0.85184-2.2 0.33919-7.0546 0.83688-10.788 1.106-3.7334 0.2691-9.8084 1.6316-13.5 3.0278s-10.987 3.7768-16.212 5.2902c-9.0292 2.6154-12.035 3.9777-25.105 11.379-10.33 5.8495-18.562 14.999-25.568 28.418-4.3795 8.388-3.5015 8.5051 18.217 2.4298 8.9841-2.5131 37.733-2.4397 45.956 0.11722 2.75 0.85515 8.2087 2.0352 12.13 2.6222 10.376 1.5532 30.003 8.6097 49.37 17.75 3.025 1.4276 9.775 4.3837 15 6.5691s13.55 5.9252 18.5 8.3107 11.925 5.0704 15.5 5.9663c3.575 0.89599 8.525 2.3215 11 3.1678 10.669 3.648 21.246 3.7724 24.174 0.28419zm-126.52-24.61c2.8597-2.9979 1.9338-3.6241-9.1582-6.1936-24.069-5.5755-58.089-5.4292-56.199 0.24175 0.90825 2.7248 33.497 9.5299 46.199 9.6473 3.85 0.0356 8.8 0.41547 11 0.84418 3.1092 0.6059 4.2227 0.43914 5-0.74884 0.55-0.84059 1.9712-2.5464 3.1582-3.7908z" style="fill:#372c35" /></g></svg>', | |
), | |
'pizza_toppings_anchovy' => array( | |
'name' => 'Anchovies', | |
'icon_svg' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" enable-background="new 0 0 128 128;"><g><path d="M127.46,74.16c-0.52-1.82-1.49-3.31-2.37-4.68c-0.56-0.85-1.18-1.83-1.53-2.78 c-0.38-1.08-0.89-2.03-1.38-2.94c-0.46-0.85-0.89-1.64-1.1-2.38c-0.39-1.31-0.16-2.94,0.1-4.66c0.08-0.51,0.15-1.01,0.21-1.51 c0.25-2.02,0.62-4.02,1.11-5.95c0.07-0.24,0.18-0.61,0.32-1.07c1.6-5.2,2.09-7.82,0.75-9.62c-0.62-0.85-1.6-1.33-2.66-1.33 c-1.52,0-2.83,1.01-3.81,1.89c-0.87,0.78-1.53,1.68-2.11,2.48l-0.46,0.64c-0.94,1.25-1.89,2.48-2.85,3.71 c-1.27,1.65-2.55,3.31-3.81,5c-0.3,0.39-0.6,0.86-0.94,1.36c-0.5,0.78-1.69,2.6-2.33,2.75c-0.38,0-1.12-0.36-1.72-0.65 l-0.45-0.21c-3.45-1.64-7.18-3.38-11.06-4.99c-0.91-1.87-2.31-3.55-3.31-5.35c-1.29-2.34-2.55-6.72-5.93-5.96 c-2.46,0.56-4.96,3.59-6.74,5.24c-0.24,0.22-0.46,0.42-0.65,0.61c-7.38-2.01-14.75-3.58-22.33-3.99 c-0.58-1.81-0.5-3.93-0.32-5.87c0.21-2.26,0.77-5.25-2.55-4.25c-2.17,0.65-4.09,2.55-5.87,3.9c-2.78,2.12-5.1,4.63-7.33,7.31 c-2.34,0.46-4.63,1.03-6.83,1.76c-7.78,2.58-14.58,6.79-20.22,12.53c-1.65,1.69-3.19,3.5-4.58,5.36 c-0.73,0.97-1.44,1.98-2.11,3.05l-0.43,0.65c-0.57,0.86-1.21,1.83-1.64,3.1c-0.86,2.54,0.72,4.24,1.47,5.06l0.44,0.4 c0.01,0.23,0,0.4-0.01,0.55c-0.04,0.92-0.02,1.86,0.9,3.28c2.85,4.37,7.84,7.08,11.49,9.06l0.74,0.41 c4.04,2.21,8.38,3.89,13.25,5.17c2.66,0.69,5.32,1.26,7.96,1.72c0.79,0.62,1.56,1.14,1.75,1.26c3.04,2.04,6.93,4.26,10.71,4.26 c2.92,0,0.62-2.93-0.19-4c-0.07-0.09-0.13-0.19-0.21-0.29c0.96,0.03,1.95,0.11,2.88,0.11c2.28,0,4.53-0.1,6.71-0.29 c6.24-0.55,12.73-2.14,19.29-4.72c0.17-0.07,0.33-0.14,0.49-0.21c0.26,0.04,0.52,0.08,0.69,0.11c2.23,0.4,4.52,1.31,6.81,1.15 c3.18-0.23,3.24-1.82,4.31-4.35c0.51-1.16,0.82-2.36,1.3-3.52c0.06-0.14,0.13-0.31,0.2-0.46c2.92-1.93,5.86-4.11,8.85-6.58 c1.01-0.82,2.1-1.55,3.26-2.32c1.17-0.79,2.39-1.6,3.76-2.6c1.12,0,3.21,1.53,4.21,2.26l1.13,0.82c1.99,1.45,4.05,2.95,6.37,4.14 c1.05,0.54,3.05,1.45,4.74,1.45c1.72,0,2.64-0.89,3.04-1.41C127.46,77.12,127.96,75.94,127.46,74.16z" style="fill:#006CA2;"/><g><defs><path id="SVGID_1_" d="M100.67,68.58c-1.23,0.81-2.48,1.65-3.7,2.65c-7.29,5.99-14.22,10.25-21.19,12.99 c-6.07,2.39-12.05,3.86-17.78,4.36c-3.73,0.34-7.67,0.36-11.72,0.08c-4.63-0.33-9.38-1.09-14.16-2.23 c0.61-1.35,1.11-2.76,1.49-4.19c0.46-1.71,0.62-3.94,0.46-5.88c0.71,0.24,1.4,0.46,2.11,0.72c2.24,0.83,4.52,1.37,6.79,1.39 c1.7,0,2.92-1.6,4.25-3.12c1.45-1.67,2.98-3.31,3.28-6.73c0.08-0.81,0.35-1.94-0.02-2.53c-0.43-0.71-1.41-0.59-1.95-0.74 c-0.72-0.18-1.42-0.26-2.12-0.35c-2.04-0.26-3.94-0.11-5.95,0.33c-2.28,0.49-4.61,1.16-6.82,2.25c-0.29,0.14-0.57,0.32-0.86,0.49 c-0.44-1.9-1.16-3.75-1.84-5.57c-0.53-1.42-0.88-2.85-2.13-3.85c-0.67-0.54-2.38-1.03-2.7,0.14c-0.13,0.49,0.17,1.2,0.53,1.87 c0.29,0.54,0.6,1.05,0.73,1.42c0.92,2.68,1.35,5.5,1.77,8.28c0.51,3.31,0.64,6.1,0.41,9.46c-0.11,1.59-0.55,3.12-1.09,4.46 c-0.15,0.36-0.32,0.71-0.51,1.05c-3.52-1.07-6.73-2.38-9.73-4.02l-0.75-0.41c-3.26-1.77-7.32-3.98-9.54-7.29 c0.02-0.26,0.03-0.57,0.01-0.96c0.71-1.05,2.51-0.66,3.48-0.32c1.25,0.44,2.44,1.28,3.76,1.16c1.27-0.11,1.74-1.39,1.05-2.41 c-0.66-1-2.27-1.47-3.3-1.98c-1.18-0.59-2.58-0.85-3.85-1.21c-0.8-0.23-1.64-0.32-2.48-0.34c0.06-0.09,0.1-0.17,0.16-0.26 c0.17-0.26,0.35-0.52,0.5-0.78c0.58-0.93,1.22-1.82,1.85-2.68c1.25-1.67,2.62-3.28,4.11-4.8c1.19-1.21,2.45-2.35,3.75-3.4 c0.86-0.64,2.97-1.83,6.13-1.24c3.35,0.63,5.33,2.24,11.23,1.31c5.91-0.93,6.6-3.7,12.36-3.7c5.76,0,7.78,4.5,14.83,4.84 c6.28,0.29,6.85-3.45,12.88-2.55c6.03,0.89,6.6,6.7,14.73,6.7c8.13,0,9.28-2.9,17.78,3.29c-0.03,0.28-0.1,0.57-0.18,0.87 c-1.08,0.13-2.08,0.53-2.92,1.21C102.85,67.12,101.79,67.83,100.67,68.58z"/></defs><use style="overflow:visible;fill:#40C0E7;" xlink:href="#SVGID_1_"/><clipPath id="SVGID_2_"><use style="overflow:visible;" xlink:href="#SVGID_1_"/></clipPath><path d="M5.32,69.55c0,0,18.87,6.14,52.2,5.44c28.2-0.59,54.3-13.13,54.3-13.13 l-0.93,5.13l-5.34,1.48c0,0-21.87,22.24-47.29,22.85c-9.07,0.21-22.21-0.8-30.33-3.35C13.26,83.33,6.11,75.71,6.11,75.71 L5.32,69.55z" style="clip-path:url(#SVGID_2_);fill:#FFFFFF;"/></g><path d="M17.3,60.96c-1.85,0.1-3.3,1.88-3.2,3.95c0.1,2.08,1.68,3.67,3.53,3.57 c1.87-0.11,3.32-1.87,3.22-3.95C20.74,62.46,19.16,60.85,17.3,60.96z" style="fill:#2F2F2F;"/></g></svg>', | |
), | |
'pizza_toppings_pineapple' => array( | |
'name' => 'Pineapple', | |
'icon_svg' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" enable-background="new 0 0 128 128;"><g style="transform: scale(2.3) matrix(1.25,0,0,-1.25,0,47.5);"><g transform="translate(19.2412,27.3672)" id="g22"><path d="M 0,0 C -0.277,3.307 2.17,4.72 2.17,4.72 -1.029,4.607 -2.724,1.895 -2.724,1.895 -3.476,3.194 -1.778,5.907 -0.555,6.614 -3.753,6.501 -4.225,4.494 -4.225,4.494 -5.728,7.095 -5.254,9.102 -5.254,9.102 -6.375,8.454 -7.021,6.989 -7.396,5.589 L -9.714,8.26 c -0.23,-1.046 0.156,-3.176 0.572,-4.962 -3.054,1.791 -5.902,0.151 -5.902,0.151 3.95,-1.187 5.45,-3.787 5.45,-3.787 0,0 -3.948,1.187 -5.645,-1.527 2.596,0.092 4.5,-0.499 5.856,-1.229 -1.163,-0.289 -3.145,0.236 -4.355,-1.371 0,0 3.198,0.113 3.851,-1.055 -2.172,-0.614 -3.574,-2.251 -3.574,-2.251 4.422,0.818 9.123,-1.668 9.123,-1.668 L 1.78,-5.907 C 0.751,-1.3 4.422,0.82 4.422,0.82 1.697,2.713 0,0 0,0" id="path24" style="fill:#5c913b;fill-opacity:1;fill-rule:nonzero;stroke:none"/></g><g transform="translate(30.5605,14.1201)" id="g26"><path d="m 0,0 c 2.488,-4.309 1.218,-9.7 -2.837,-12.041 -4.055,-2.341 -9.359,-0.746 -11.846,3.562 l -1.589,2.753 c -2.489,4.31 -1.218,9.699 2.837,12.04 4.055,2.342 9.359,0.747 11.846,-3.562 L 0,0 z" id="path28" style="fill:#ffac33;fill-opacity:1;fill-rule:nonzero;stroke:none"/></g><g transform="translate(28.7178,10.541)" id="g30"><path d="M 0,0 -1.951,0.828 -1.123,2.778 0.828,1.951 0,0 z m -1.656,-3.901 -1.95,0.827 0.828,1.952 1.95,-0.828 -0.828,-1.951 z m -1.657,-3.904 -1.951,0.828 0.828,1.952 1.952,-0.829 -0.829,-1.951 z m -4.197,6.388 0.828,1.952 1.952,-0.829 -0.829,-1.952 -1.951,0.829 z m 0.294,-4.73 -1.95,0.828 0.828,1.95 1.95,-0.829 -0.828,-1.949 z m -4.196,6.386 0.829,1.951 1.951,-0.827 -0.828,-1.952 -1.952,0.828 z m 0.295,-4.73 -1.951,0.827 0.828,1.951 1.951,-0.828 -0.828,-1.95 z m -4.196,6.386 0.828,1.952 1.951,-0.828 -0.828,-1.953 -1.951,0.829 z m 2.484,5.852 1.951,-0.828 -0.829,-1.949 -1.95,0.828 0.828,1.949 z m 3.902,-1.655 1.95,-0.828 -0.828,-1.951 -1.95,0.828 0.828,1.951 z M -7.271,9.994 -5.319,9.166 -6.148,7.214 -8.1,8.042 -7.271,9.994 z m 4.197,-6.387 -0.828,-1.95 -1.952,0.827 0.829,1.952 1.951,-0.829 z m -0.294,4.731 1.95,-0.829 -0.828,-1.95 -1.951,0.828 0.829,1.951 z M 2.845,1.095 C 2.636,1.942 2.305,2.779 1.843,3.579 L 1.656,3.902 1.656,3.901 -0.295,4.729 0.329,6.2 0.254,6.331 c -2.025,3.51 -5.92,5.217 -9.486,4.466 l -0.819,-1.926 -1.884,0.799 c -3.28,-2.122 -4.567,-6.318 -3.262,-10.128 l 1.006,-0.427 -0.401,-0.946 c 0.055,-0.106 0.102,-0.212 0.162,-0.315 l 1.59,-2.753 c 0.685,-1.188 1.59,-2.161 2.617,-2.91 l 0.229,0.538 1.951,-0.828 -0.324,-0.763 c 0.665,-0.278 1.357,-0.465 2.06,-0.573 l 0.215,0.507 1.404,-0.594 c 1.144,0.047 2.28,0.335 3.342,0.882 l -0.016,0.007 0.828,1.951 1.188,-0.504 c 0.523,0.522 0.973,1.104 1.334,1.737 l -1.693,0.72 0.828,1.951 1.667,-0.707 c 0.191,0.7 0.301,1.426 0.316,2.167 l -1.155,0.49 0.828,1.951 0.066,-0.028 z" id="path32" style="fill:#ffcc4d;fill-opacity:1;fill-rule:nonzero;stroke:none"/></g></g></svg>', | |
), | |
'pizza_toppings_other' => array( | |
'name' => 'Other', | |
'icon' => 'text-quote', | |
), | |
), | |
'tabbed_subtoggles' => true, | |
'title' => 'Special Toppings', | |
), | |
), | |
), | |
); | |
} | |
... |
The post Module Settings Groups appeared first on Elegant Themes Documentation.
]]>The post How To Create a Custom Field For a Divi Builder Module appeared first on Elegant Themes Documentation.
]]>Note: This tutorial series is intended for advanced users. At least a basic understanding of coding in PHP and JavaScript is required.
Creating a custom field for a Divi module is similar to creating a custom Divi module in the Divi Builder. Both methods require some Javascript, HTML, & CSS code. However, to create a custom field for a module, there is no need for any PHP because you don’t need to write a PHP class to render the HTML output on the frontend. The main component needed is a ReactJS component class that handles rendering the field inside of the Divi Builder. Then you can define the custom field on your module definition.
In this tutorial, you’ll learn how to create custom fields for a Divi Builder module that will be fully functional in the builder.
Keep in mind. Custom Divi Builder fields must be implemented within a theme, child-theme, or Divi Extension. In this tutorial, we’re going to create a custom field for a custom module in a Divi Extension.
Also, this tutorial is a continuation of previous tutorials that have a specific setup already in place.
If you haven’t already done so, go ahead and do the following before you start this tutorial:
Once done, you are ready to continue.
Before we can test our custom field later on in the Divi Builder we’ll need to compile the JSX code into regular JavaScript. To do that, we need to run yarn
. To do this, simply run the following command inside your plugin’s directory:
yarn start
IMPORTANT: Be sure that yarn start
is running in the root folder of your plugin. Furthermore, you should keep yarn start
running as you develop so that the files continue to compile successfully.
Custom Divi Builder Fields is a new feature and only available on divi-scripts version 1.0.2 above. So, if you want to add custom field on your existing extension, please upgrade your divi-scripts to version 1.0.2. You can do this by changing divi-scripts version on your package.json
located at at the root of your extension directory.
Then run yarn install
to update. You can also find a custom field example on this documentation here.
We’ll get to update the code in our files in a bit. But before we can do that, we need to change the default directory and file names for our new custom field.
Look inside your extension’s directory and locate the example custom field located at /includes/fields/Input/Input.jsx
.
We’ll use this as a starting point to create a custom input field.
First, rename the Input
directory to SimpleInput
.
Inside the directory (now named SimpleInput
), rename the file Input.jsx
to SimpleInput.jsx
.
The path to the file should now be includes/fields/SimpleInput/SimpleInput.jsx
Open the SimpleInput.jsx
file and edit it as follows:
For our custom field to be available and fully functional inside the Divi Builder we must create a React Component class that handles the rendering of our custom field based on its props
.
By default, the component class is named Input
. Change the name of the class Input
to SimpleInput
.
Then change the name Input
to SimpleInput
at the bottom of the file to reflect the new name of our component class in order to be exported for use.
Also make sure to update the slug, input id, and input className to reflect the name of the new field.
(NOTE: Depending on the prefix id you chose when setting up your Divi Extension, you may see different names for the static slug, input id, input class, etc. This example has the prefix simp
which was chosen when creating the Divi Extension.)
Here is an example of what the code should look like after the change has been made:
// External Dependencies import React, { Component } from 'react'; // Internal Dependencies import './style.css'; class SimpleInput extends Component { static slug = 'simp_simple_input'; /** * Handle input value change. * * @param {object} event */ _onChange = (event) => { this.props._onChange(this.props.name, event.target.value); } render() { return( <input id={`simp-simple-input-${this.props.name}`} name={this.props.name} value={this.props.value} type='text' className='simp-simple-input' onChange={this._onChange} placeholder='Your text here ...' /> ); } } export default SimpleInput;
The _onChange()
prop is a method handler to save or remove the field setting’s value. It passes 2 parameters.
The first parameter is the field setting’s name. You can use name
prop here because it’s already supplied with the correct field name based on the current active tab mode. For example: when you are editing the Title option in Tablet tab mode, the field’s name generated is title_tablet
. The second parameter is the field setting value that you want to save.
The field setting type is actually a third parameter that is automatically defined with the current field type prop. So we don’t have to include that parameter with the other 2.
Next, let’s update the import and export statements in the index.js file located at /includes/fields/index.js
. To do this, open to edit the index.js file.
Replace all instances of the name for the class and directory (which is Input
by default) to the new name SimpleInput
.
Here is an example of the final code:
import SimpleInput from './SimpleInput/SimpleInput'; export default [SimpleInput];
Styles for our custom field can be defined using the style.css file in its directory located at /includes/fields/SimpleInput/style.css
.
Our custom field is only a basic input element that comes with default builder styling. For now, let’s change the default class selector to .simp-simple-input
(rendered in SimpleInput.jsx) throughout the style.css file:
input.simp-simple-input { background: #f1f5f9; max-height: 30px; border: 0; border-radius: 3px; padding: 7px 10px; box-sizing: border-box; transition: background 200ms ease; color: #4C5866; font-family: 'Open Sans', Helvetica, Roboto, Arial, sans-serif; font-size: 13px; font-weight: 600; line-height: normal; display: block; width: 100%; } input.simp-simple-input:focus { background: #e6ecf2; } input.simp-simple-input::-webkit-input-placeholder { color: #98a7b8; } input.simp-simple-input:-moz-placeholder { color: #98a7b8; } input.simp-simple-input::-moz-placeholder { color: #98a7b8; } input.simp-simple-input:-ms-input-placeholder { color: #98a7b8; } input.simp-simple-input[readonly] { background: #ffffff !important; border: 1px solid #eaedf0 !important; cursor: not-allowed; }
To use our custom field, we need to define it on the module definition of our intended module. For this example, let’s add it to the Simple Header module we created in the previous tutorial.
Open the SimpleHeader.php file located at /includes/modules/SimpleHeader/SimpleHeader.php
.
Then add the code to define the custom field. Don’t forget to use simp_simple_input
as the field type.
The final code will look like this:
class SIMP_SimpleHeader extends ET_Builder_Module { public $slug = 'simp_simple_header'; public $vb_support = 'on'; public function init() { $this->name = esc_html__( 'Simple Header', 'simp-simple-extension' ); } public function get_fields() { return array( 'heading' => array( 'label' => esc_html__( 'Heading', 'simp-simple-extension' ), 'type' => 'text', 'option_category' => 'basic_option', 'description' => esc_html__( 'Input your desired heading here.', 'simp-simple-extension' ), 'toggle_slug' => 'main_content', ), 'content' => array( 'label' => esc_html__( 'Content', 'simp-simple-extension' ), 'type' => 'tiny_mce', 'option_category' => 'basic_option', 'description' => esc_html__( 'Content entered here will appear below the heading text.', 'simp-simple-extension' ), 'toggle_slug' => 'main_content', ), 'field' => array( 'label' => esc_html__( 'Custom Field', 'simp-simple-extension' ), 'type' => 'simp_simple_input', 'option_category' => 'basic_option', 'description' => esc_html__( 'Text entered here will appear inside the module.', 'simp-simple-extension' ), 'toggle_slug' => 'main_content', ), ); } public function render( $unprocessed_props, $content = null, $render_slug ) { return sprintf( '<h1 class="simp-simple-header-heading">%1$s</h1> <div>%2$s</div>', esc_html( $this->props['heading'] ), $this->props['content'] ); } } new SIMP_SimpleHeader;
The properties that were added to the field are only the required properties you need to define. But you can add more properties to use on the custom field if you want. For instance, you can add both responsive and hover options for your custom field as well.
Our field definition is ready. We just need to update the render()
method so that it will display the custom field value. Let’s start with the render()
method on the module PHP class.
Open the SimpleHeader.php
file and update the render()
method as follows:
The final code should look like this:
class SIMP_SimpleHeader extends ET_Builder_Module { public $slug = 'simp_simple_header'; public $vb_support = 'on'; public function init() { $this->name = esc_html__( 'Simple Header', 'simp-simple-extension' ); } public function get_fields() { return array( 'heading' => array( 'label' => esc_html__( 'Heading', 'simp-simple-extension' ), 'type' => 'text', 'option_category' => 'basic_option', 'description' => esc_html__( 'Input your desired heading here.', 'simp-simple-extension' ), 'toggle_slug' => 'main_content', ), 'content' => array( 'label' => esc_html__( 'Content', 'simp-simple-extension' ), 'type' => 'tiny_mce', 'option_category' => 'basic_option', 'description' => esc_html__( 'Content entered here will appear below the heading text.', 'simp-simple-extension' ), 'toggle_slug' => 'main_content', ), 'field' => array( 'label' => esc_html__( 'Custom Field', 'simp-simple-extension' ), 'type' => 'simp_simple_input', 'option_category' => 'basic_option', 'description' => esc_html__( 'Text entered here will appear inside the module.', 'simp-simple-extension' ), 'toggle_slug' => 'main_content', ), ); } public function render( $unprocessed_props, $content = null, $render_slug ) { return sprintf( '<h1 class="simp-simple-header-heading">%1$s</h1> <div>%2$s</div> <p>%3$s</p>', esc_html( $this->props['heading'] ), $this->props['content'], $this->props['field'] ); } } new SIMP_SimpleHeader;
Now, let’s edit the render()
method of the React component and make it produce the same output that we defined in our PHP render()
method.
Open the SimpleHeader.jsx
file and update the render()
method as follows:
The final code should look like this:
// External Dependencies import React, { Component, Fragment } from 'react'; // Internal Dependencies import './style.css'; class SimpleHeader extends Component { static slug = 'simp_simple_header'; render() { return ( <Fragment> <h1 className="simp-simple-header-heading">{this.props.heading}</h1> <div> {this.props.content()} </div> <p> {this.props.field} </p> </Fragment> ); } } export default SimpleHeader;
Here you can see how the output of the render()
method of the php file corresponds to the output of the render()
method of the php file which now includes the new field wrapped in a p
tag.
Wrapping the new field output with a p
tag makes sense here because we are interested in simple text output. This also is a good opportunity to add your own custom selectors (CSS ID, CSS Class) to the p
tag for your own needs. Just make sure you add the same selectors to the output of the render()
method of the PHP file and the JSX file.
If you already have yarn start
running as we suggested in the first step, you can now launch the Divi Builder and check out your Simple Input field!
If not, before we can test our custom field in the Divi Builder we need to compile the JSX code into regular JavaScript. To do that, simply run the following command inside your plugin’s directory:
yarn start
As a reminder, you should keep yarn start
running as you continue to edit your files so that the files continue to compile successfully.
To test out the custom field, go to your Divi site and open the settings of the custom Simple Header Module. The new Custom Field will be under the content tab.
When you are finished development, remember to stop yarn start
from running in your terminal (hitting ctrl + c within the terminal usually does the trick).
The post How To Create a Custom Field For a Divi Builder Module appeared first on Elegant Themes Documentation.
]]>The post Divi Template Hooks appeared first on Elegant Themes Documentation.
]]>Fires after the main content, before the footer is output.
Type: Action
Since: 3.1
Fires in the head, before wp_head()
is called. This action can be used to insert elements into the beginning of the head before any styles or scripts.
Type: Action
Since: 1.0
Filters the HTML output for the top header.
Type: Filter
Since: 3.1
Param | Type | Description |
---|---|---|
$top_header | string |
HTML output for the top header |
Filters the HTML output for the slide header.
Type: Filter
Since: 3.1
Param | Type | Description |
---|---|---|
$slide_header | string |
HTML output for the slide header |
Filters the HTML output for the logo container.
Type: Filter
Since: 3.1
Param | Type | Description |
---|---|---|
$logo_container | string |
HTML output for the logo container |
Fires at the end of the et-top-navigation element, just before its closing tag.
Type: Action
Since: 1.0
Filters the HTML output for the main header.
Type: Filter
Since: 3.1
Param | Type | Description |
---|---|---|
$main_header | string |
HTML output for the main header |
Fires after the header, before the main content is output.
Type: Action
Since: 3.1
Filters the width used to retrieve featured images via wp_get_attachment_image_src()
.
Type: Filter
Since: 1.0
Param | Type | Description |
---|---|---|
$width | string |
Width value as a string |
Filters the height used to retrieve featured images via wp_get_attachment_image_src()
.
Type: Filter
Since: 1.0
Param | Type | Description |
---|---|---|
$height | string |
Height value as a string |
See index.php above for definition.
See index.php above for definition.
Fires right before the_content()
is called.
Type: Action
Since: 1.0
See index.php above for definition.
See index.php above for definition.
Filters the width used to retrieve featured images via wp_get_attachment_image_src()
.
Type: Filter
Since: 1.0
Param | Type | Description |
---|---|---|
$width | string |
Width value as a string |
Filters the height used to retrieve featured images via wp_get_attachment_image_src()
.
Type: Filter
Since: 1.0
Param | Type | Description |
---|---|---|
$height | string |
Height value as a string |
The post Divi Template Hooks appeared first on Elegant Themes Documentation.
]]>The post Divi Module Hooks appeared first on Elegant Themes Documentation.
]]>Fires after contact form is submitted. This action can be used to trigger follow up actions after the contact form is submitted. Use $et_contact_error
variable to check whether there is an error on the form entry submit process or not.
Type: Action
Since: 4.13.1
Param | Type | Description |
---|---|---|
$processed_fields_values | array |
Processed fields values |
$et_contact_error | array |
Whether there is an error on the form entry submit process or not |
$contact_form_info | array |
Additional contact form info |
The post Divi Module Hooks appeared first on Elegant Themes Documentation.
]]>The post Divi Builder PHP Hooks appeared first on Elegant Themes Documentation.
]]>Filters every rendered module output for processing “Display Conditions” option group.
Type: Filter
Since: 4.13.1
Param | Type | Description |
---|---|---|
$output | string |
HTML output of the rendered module. |
$render_method | string |
The render method used to render the module. |
$this | ET_Builder_Element |
The current instance of ET_Builder_Element . |
Filters “Display Conditions” option visibility to determine whether to add its field to the Visual Builder or not. Useful for displaying/hiding the option on the Visual Builder.
Type: Filter
Since: 4.13.1
Param | Type | Description |
---|---|---|
$default_status | boolean |
True to make the option visible on VB, False to make it hidden. |
Filters “Display Conditions” functionality to determine whether to enable or disable the functionality or not. Useful for disabling/enabling “Display Condition” feature site-wide.
Type: Filter
Since: 4.13.1
Param | Type | Description |
---|---|---|
$default_status | boolean |
True to enable the functionality, False to disable it. |
The post Divi Builder PHP Hooks appeared first on Elegant Themes Documentation.
]]>The post Divi Builder Javascript Hooks appeared first on Elegant Themes Documentation.
]]>Filters module selector on the rendered layout. This filter is fired before selector processing. Third-party extensions may use this filter to modify module CSS selector such as removing builder selector prefix, append child element class, etc.
Type: Filter
Since: 4.0.0
Param | Type | Description |
---|---|---|
selector | string |
Module selector. |
type | string |
Module slug. |
Examples:
/** * Filters Hello World module selector after builder content is loaded. */ document.addEventListener('ETDOMContentLoaded', function() { // Module type: smpl_hello_world. wp.hooks.addFilter('smpl.hello.world.css.selector', 'smpl-setting-update', function(selector){ // Processing Hello World module selector here ... return selector; }); });
Filters processed module selector on the rendered layout. This filter is fired after selector processing. Third-party extensions may use this filter to modify module CSS selector such as removing builder selector prefix, append child element class, etc.
Type: Filter
Since: 4.17.6
Param | Type | Description |
---|---|---|
selector | string |
Processed module selector. |
type | string |
Module slug. |
Examples:
/** * Filters Hello World module selector after builder content is loaded. */ document.addEventListener('ETDOMContentLoaded', function() { // Module type: smpl_hello_world. wp.hooks.addFilter('smpl.hello.world.processed.css.selector', 'smpl-setting-update', function(selector){ // Processing Hello World module selector here ... return selector; }); });
The post Divi Builder Javascript Hooks appeared first on Elegant Themes Documentation.
]]>The post Divi Builder JavaScript API appeared first on Elegant Themes Documentation.
]]>Window
Global window object.
Kind: global typedef
Emits: event:et_builder_api_ready
React.Component
| object
Custom module for the Divi Builder.
Kind: global typedef
Static Properties (Required)
Name | Type | Description |
---|---|---|
slug | string |
The module’s slug as defined in it’s PHP class |
Methods (Required)
Name | Type | Description |
---|---|---|
render | function |
Divi Builder API object passed to registered callbacks of the event:et_builder_api_ready event.
Kind: global constant
string
object
string
string
string
string
boolean
array
boolean
Manage custom modules.
Kind: static property of API
Since: 3.1
Register one or more custom modules.
Kind: static method of Modules
Since: 3.1
Param | Type | Description |
---|---|---|
modules | Array.<ETBuilderModule> |
Modules to register. |
Useful functions
Kind: static property of API
Since: 3.1
string
object
string
string
string
string
boolean
array
Lodash – A modern JavaScript utility library delivering modularity, performance & extras.
Kind: static method of Utils
Link: https://github.com/lodash/lodash
License: MIT
Copyright: JS Foundation and other contributors https://js.foundation/
string
Generates className value based on the args provided. Takes any number of args which can be a string or an object. The argument foo
is short for { foo: true }
. If the value associated with a given key is falsy, the key won’t be included in the output.
Kind: static method of Utils
Link: https://github.com/JedWatson/classnames
License: MIT
Copyright: 2017 Jed Watson
Type |
---|
string | Object.<string, boolean> |
Examples:
classNames('foo', 'bar'); // => 'foo bar' classNames('foo', { bar: true }); // => 'foo bar' classNames({ 'foo-bar': true }); // => 'foo-bar' classNames({ 'foo-bar': false }); // => '' classNames({ foo: true }, { bar: true }); // => 'foo bar' classNames({ foo: true, bar: true }); // => 'foo bar'
object
Decode string value of option_list
module setting field type.
Kind: static method of Utils
Since: 3.1
Param | Type | Description |
---|---|---|
encoded_value | string |
Value to be decoded |
string
Returns CSS class for a google font.
Kind: static method of Utils
Since??:
Param | Type | Description |
---|---|---|
font_name | string |
Font name for which to return a CSS class |
string
Generate link rel HTML attribute value based on a value saved in a module’s settings.
Kind: static method of Utils
Since: 3.1
Param | Type | Description |
---|---|---|
saved_value | string |
Value saved in module settings |
Loads a Google Font if it hasn’t already been loaded.
Kind: static method of Utils
Since: 3.1
Param | Type | Description |
---|---|---|
font_name | string |
The name of the font to load |
string
Generates HTML for a saved font-based icon value.
Kind: static method of Utils
Since: 3.1
Param | Type | Description |
---|---|---|
icon | string |
The saved icon value |
is_down_icon | boolean |
Whether or not the icon is one of the down arrow icons |
string
Generates font related CSS style properties from font data saved in a module’s settings.
Kind: static method of Utils
Since: 3.1
Param | Type | Description |
---|---|---|
font_data | string |
Font data saved in module settings |
use_important | boolean |
Whether or not to use !important |
default_values | object |
Mapping of default values for the font settings |
boolean
Check whether given value can be printed or not (string). Originally a simpler way to check against empty string, but later several checks were added as well to avoid unnecessary repetition. A value considered empty if:
Kind: static method of Utils
Since: 4.14.9
Param | Type | Description |
---|---|---|
value | mixed |
Value to check. |
array
Use the `Responsive.generateResponsiveCSS` with addition to generate sticky state styles if module enable it.
Kind: static method of Utils
Since: 4.17.5
Param | Type | Description |
---|---|---|
moduleArgs | object |
Module arguments. |
Examples:
/** * Module arguments. * * @typedef moduleArgs * @type {Object} * @property {string} address: '' * @property {Object} attrs: {} * @property {string} name: '' * @property {string} defaultValue: '' * @property {string} type: '' * @property {boolean} forceReturn: false * @property {string} selector: '%%order_class%%' * @property {string} cssProperty: '' * @property {boolean} important: false * @property {boolean} hover: true * @property {boolean} sticky: true * @property {boolean} responsive: true * @property {null|boolean} isStickyModule: null * @property {string} stickyPseudoSelectorLocation: 'order_class' */ /** * Hello World module inline styling. * * @param {Object} props Module attribute names and values. * @param {Object} moduleInfo Module info. * * @return array */ static css(props, moduleInfo) { const additionalCSS = []; const { generateStyles, } = window.ET_Builder.API.Utils; /** * Box colors arguments. * * @var {moduleArgs} */ const boxColorsArgs = { attrs: props, name: 'box_color', selector: '%%order_class%% .smpl-hello-world-box-area', cssProperty: 'background-color', }; const boxColors = generateStyles(boxColorsArgs); /** * boxColors output: * * [ * { * selector: '%%order_class%% .smpl-hello-world-box-area', * declaration: 'background-color: red;', * device: 'desktop', // desktop, tablet, phone * } * ] */ additionalCSS.push(boxColors); return additionalCSS; }
boolean
Whether or not a component is registered.
Kind: static method of API
Since: 3.1
Param | Type | Description |
---|---|---|
slug | string |
The component’s slug |
Convenience wrapper for register
Kind: static method of API
Since: 3.1
Param | Type | Description |
---|---|---|
modules | Array.<ETBuilderModule> |
Modules to register. |
The post Divi Builder JavaScript API appeared first on Elegant Themes Documentation.
]]>The post Defining Module Settings appeared first on Elegant Themes Documentation.
]]>Note: This tutorial series is intended for advanced users. At least a basic understanding of coding in PHP and JavaScript is required.
Module settings are defined in the get_fields()
method of the module’s PHP class. A setting definition is simply an associative array of parameters.
The Divi Builder has a comprehensive selection of field types for module settings. Below you’ll find a list of available field types, each with a screenshot and a list of any additional parameters that must be included in the setting definition. The value to use for the type
parameter of the setting definition is in parenthesis next to each field type name.
Select Field Parameters
Checkboxes Field Parameters
Toggle Button Field Parameters
Range Slider Field Parameters
The post Defining Module Settings appeared first on Elegant Themes Documentation.
]]>The post Defining Custom CSS Fields For Modules appeared first on Elegant Themes Documentation.
]]>Note: This tutorial series is intended for advanced users. At least a basic understanding of coding in PHP and JavaScript is required.
Custom CSS fields appear in the Advanced tab of the module settings modal and allow users to set custom CSS properties for predefined target elements within the module’s HTML output. The fields are automatically generated based on the configuration defined in the module’s get_custom_css_fields_config()
method.
<?php | |
class SIMP_SimpleHeader extends ET_Builder_Module { | |
// ...Rest of implementation | |
public function get_custom_css_fields_config() { | |
return array( | |
'content' => array( | |
'label' => esc_html__( 'Content', 'simp-simple' ), | |
'selector' => '%%order_class%% p', | |
), | |
'heading' => array( | |
'label' => esc_html__( 'Heading', 'simp-simple' ), | |
'selector' => '%%order_class%% h1', | |
), | |
); | |
} | |
// Rest of implementation... | |
} |
The post Defining Custom CSS Fields For Modules appeared first on Elegant Themes Documentation.
]]>