post-smtp
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/develop.tangible.one/htdocs/wp-includes/functions.php on line 6121We can use JSON to generate sections and fields in a block.
Tabs are optional, if none are added sections will be added in the default panel ("General" for beaver-builder, "Content" for elementor).
In Gutenberg, tabs will be showned only if there is more than one tab.
{
"tabs": [
{
"title": "default", // If the title is default, tabs name will be different according to the builder
"sections": [
{
"title": "Section 1",
"controls": [
// Controls
]
},{
"title": "Section 2",
"controls": [
// Controls
]
}
]
},
{
"title": "Custom tab",
"sections": [
{
"title": "Section 3",
"controls": [
// Controls
]
}
]
}
]
}
[
{
"title": "Section 1",
"controls": [
// Controls
]
},
{
"title": "Section 2",
"controls": [
// Controls
]
}
]
Here is the different type of controls implemented:
{
"type": "ajax_select",
"name": "ajax_select_control_name",
"label": "Ajax select",
"ajax_action_name": "ajax_action_name" // See https://docs.tangible.one/modules/plugin-framework/ajax/
}
{
"type": "align",
"name": "align_control_name",
"label": "Align control",
"default": "right" // Optional - Accepted value: right, center, left
}
{
"type": "color",
"name": "color_control_name",
"label": "Color control",
"default": "#FFFFFF", // Optional
"alpha": false // Optional - Default true
}
{
"type": "date",
"name": "date_control_name",
"label": "Date",
"format": "d/m/Y g:i a" // Optional
}
{
"type": "dimension",
"name": "dimension_control_name",
"label": "Dimensions",
"units": "px,vh,vw", // Optional - Default px
"default": "0,0,0,0", // Optional - Default 0,0,0,0
"default_unit": "vw", // Optional - Default px
"multiple_values": true // Optional - Default true
}
{
"type": "editor",
"name": "editor_control_name",
"label": "Editor",
"default": "Some <strong>text</strong>" // Optional
}
{
"type": "gallery",
"name": "gallery_control_name",
"label": "Gallery",
"default": "1,2", // Optional - Attachment IDs
"size": "full" // Optional - Default full
}
{
"type": "gradient",
"name": "gradient_control_name",
"label": "Gradient"
}
{
"type": "image",
"name": "image_control_name",
"label": "Image",
"default": "1" // Optional - Attachment ID or URL
}
{
"type": "number",
"name": "number_control_name",
"label": "Number",
"default": "10", // Optional
"min": "0", // Optional
"max": "100" // Optional
}
{
"type": "post_query",
"name": "post_query_control_name",
"label": "Post query",
"include_fields": "taxonomy, type, order, orderby", // Optional - Default type, order, orderby
}
{
"type": "post_select",
"name": "post_select_control_name",
"label": "Post select",
"default": "1", // Optional - Post ID
"multiple": true, // Optional - Default false
"result_length": 10, // Optional - Default 10
"post_type": "post,page", // Optional - Default post
"result_order": "ASC" // Optional - default ASC
}
{
"type": "post_types",
"name": "post_types_control_name",
"label": "Post types",
"multiple": true, // Optional - Default false
"default": "post" // Optional
}
{
"type": "select",
"name": "select_control_name",
"label": "Select",
"options": {
"one": "Option one",
"two": "Option two",
"three": "Option three"
},
"multiple": true, // Optional - Default false
"default": "one" // Optional
}
{
"type": "select2",
"name": "select2_control_name",
"label": "Select2",
"options": {
"one": "Option one",
"two": "Option two",
"three": "Option three"
},
"multiple": true, // Optional - Default false
"default": "one" // Optional
}
{
"type": "switch",
"name": "switch_control_name",
"label": "Switch",
"default": "on", // Optional - Default on
"label_on": "On", // Optional - Default On
"label_off": "Off", // Optional - Default Off
"value_on": "on", // Optional - Default on
"value_off": "off" // Optional - Default off
}
{
"type": "text",
"name": "text_control_name",
"label": "Text",
"default": "default text" // Optional
}
{
"type": "user_select",
"name": "user_select_control_name",
"label": "User select",
"default": "1", // Optional - User ID
"multiple": true, // Optional - Default false
"result_length": 10, // Optional - Default 1
"role": "editor" // Optional - Default all
}
We can use a control value in templates, scripts and styles by adding {{ control-name }}.
<div id="template">
<img src="{{ image-name }}" />
<p id="text">{{ before-click-text }}</p>
</div>
#template {
background: {{ background-color }};
}
var container = document.getElementById('template')
container.addEventListener('click', function() {
document.getElementById('text').textContent = "{{ after-click-text }}"
})
[
{
"title": "Section style",
"controls": [
{
"type": "image",
"name": "image-name",
"label": "Image",
"default": "https://ps.w.org/tangible-loops-and-logic/assets/banner-1544x500.jpg"
},
{
"type": "color",
"name": "background-color",
"label": "Background color",
"default": "#FF0000"
}
]
},
{
"title": "Section text",
"controls": [
{
"type": "text",
"name": "before-click-text",
"label": "Before click text",
"default": "Visible before the click"
},
{
"type": "text",
"name": "after-click-text",
"label": "After click text",
"default": "Visible after the click"
}
]
}
]