add_param_type() is used to add new parameter type such as Input, Checkbox, Text, etc.
Instruction:
add_param_type( $name , $func ); ?>
Example:
add_param_type( 'new_param', 'your_new_function' );
}
function your_new_function(){
echo ' ';
}
?>
Parameters:
Name [string]: Name of the newly added parameter type.
Func [string]: Name of the callback function. Please check the Additional Notes below for more details.
class="kc-param" : Set class name of the input which will return value.
Additional Notes:
Callback Function uses JS Templates; it passes values through "Data" variable .
Templates will pass a data
variable which can then be called upon output values.
Escaped output goes in two curly braces {{data.escaped}}
.
Unescaped data goes in three curly braces {{{data.unescaped}}}
.
Arbitrary logic (JavaScript code) goes in carrot hash template tags <# //logic #>
.
None of the three token markers above will be returned as it is.
Callback Function Parameters:
Value [string]: Value of the parameter.
Options [array]: List of options registered via mapping. These are used in some parameter types such as select, checkbox, radio, etc.
Name [string]: Name of the parameter that is registered via mapping.
Type [string]: Parameter type.
Callback [function]: Call after the parameter is rendered.
Example:
add_param_type( 'new_param', 'your_new_function' );
}
function your_new_function(){
?>
<# alert( data.value ); #>
<# console.log( data.name ); #>
<# console.log( data ); #>
data.callback:
This method allows you do more actions after the parameter has been rendered.
add_param_type( 'new_param', 'your_new_function' );
}
function your_new_function(){
?>
<#
data.callback = function( wrp, $ ){
wrp.find('input.your-class').on('click', function(){ alert('success'); });
}
#>