Add Param Type Join KC discussion

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:

  1. Name [string]: Name of the newly added parameter type.
  2. Func [string]: Name of the callback function. Please check the Additional Notes below for more details.
  3. 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:

  1. Value [string]: Value of the parameter.
  2. Options [array]: List of options registered via mapping. These are used in some parameter types such as select, checkbox, radio, etc.
  3. Name [string]: Name of the parameter that is registered via mapping.
  4. Type [string]: Parameter type.
  5. 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'); });
    }
#>