add_map() method enables you to add a new shortcode to KingComposer, then you can use it as an element of KingComposer builder.
Instruction:
array(
'name' => '__String__',
'description' => '__String__',
'category' => '__String__',
'icon' => '__string__'
'title' => '__String__',
'admin_view' => '__String__'
'views' => '__Array__'
'is_container' => true|fasle, // shortcode container such as [name]...[/name]
'system_only' => true|false, // set true to not visible in list of adding elements
'filter' => '__String__', // PHP function name, data will be run through this filter before process
'nested' => true|false, // allow add elements into your element
'accept_child' => 'kc_column_text,kc_title', // use for nested element
'except_child' => '',
'accept_parent' => '',
'except_parent' => '',
// Since ver 2.6.4
// Only load assets when using this element
'assets' => array(
'scripts' => array(
'handle-js-id' => 'http://sample.com/script.js',
'jquery' => '', // Leave empty to call the registered scripts
),
'styles' => array(
'handle-css-id' => 'http://sample.com/style.css',
'jquery-ui' => '', // Leave empty to call the registered styles
)
),
'params' => array(
array(
'name' => '__slug__',
'label' => '__String__',
'type' => '__Param Types__',
'description' => '__String__',
),
array(
'name' => '__slug__',
'label' => '__String__',
'type' => '__Param Types__',
'description' => '__String__',
),
)
// OR build params under groups
'params' => array(
'group 1' => array(
array(
'name' => '__slug__',
'label' => '__String__',
'type' => '__Param Types__',
'description' => '__String__',
),
array(
'name' => '__slug__',
'label' => '__String__',
'type' => '__Param Types__',
'description' => '__String__',
)
),
'group 2' => array(
array(
'name' => '__slug__',
'label' => '__String__',
'type' => '__Param Types__',
'description' => '__String__',
),
array(
'name' => '__slug__',
'label' => '__String__',
'type' => '__Param Types__',
'description' => '__String__',
)
),
)
)
)
);
}
?>
Example:
array(
'name' => 'Icon',
'description' => __('Display single icon', 'KingComposer'),
'icon' => 'sl-paper-plane',
'category' => 'Content',
'params' => array(
array(
'name' => 'icon',
'label' => 'Select Icon',
'type' => 'icon_picker',
'admin_label' => true,
),
array(
'name' => 'icon_size',
'label' => 'Icon Size',
'type' => 'text',
'admin_label' => true,
'description' => __('Enter font-size for icon such as: 15px, 1em ..etc..', 'KingComposer')
),
array(
'name' => 'icon_color',
'label' => 'Icon Color',
'type' => 'color_picker',
'admin_label' => true,
'description' => __('Set color for icon', 'KingComposer')
)
)
), // End of elemnt kc_icon
)
); // End add map
} // End if
}
?>
Parameters:
- Name [string]: Displays the shortcode name in the list of items.
- Description [string]: ]: Displays additional statement.
- Category [string]: Groups elements into a tab.
- Title [string]: Element title which will be displayed on popup editor.
- Icon [string]: Class name to display as element icon.
- Admin_view [string]: Removes this option if you don't need it. Read about admin_view.
- Views [array]: Removes this option if you don't need it. Read about Views.
- Is_container [boolean]: The default value is false. The container shortcode should be inserted into [name]shortcode[/name] and the single shortcode should be inserted into [name param="shortcode"]
- Css_box [boolean]: The default value is false. It allows you to add CSS via editting popup.
- System_only [boolean]:The default value is false. The elements are used in the system only, they aren't shown on the list of elements. For example shortcode [tab].
- Nested [boolean]: Allows add another elements inside your element.
- Assets [array]: Only load scripts and styles when using this element.
- accept_child|accept_parent|except_child|except_parent [string]: Restrictive element inside nested elements.
- Filter [string]: PHP Function. You can use this method to filter any shortcodes before executing. Read more about Shorcode Filter
- Params [array]: Registers parameters for shortcode.
- params > name [slug]: Uses it as an ID of parameter (slug string)
- params > label [string]: Label on editing.
- params > type [string]: Please check all of Available Param Types.
- params > value [string]: Default value for this parameter, Remove this if you do not need default value.
- params > options [array]: List of options for some parameter types such as select, radio, checkbox..etc..
- params > relation [array]: Creates the relationship between parameters. For example if the parameter A is set yes, parameter B will be displayed.
Screenshot:
Useful Links: