Shortcode Filter Join KC discussion

Every shortcode runs via KingComposer is filtered before wp_header hook. You can add your filter to every shortcode to change the attributes or contents. And the most important mission is loading CSS, JS

Instruction:

add_filter( 'shortcode_{{YOUR-SHORTCODE-NAME}}', 'Your_PHP_Function_Filter' );

// add_filter is a wordpress core method
// you can add your filter anywhere in your theme or your plugin

// THIS FILTER RUNS ONLY WHEN THIS SHORTCODE WAS USED IN PAGE

Example: We have a shortcode [kc_row id="my-id" style="1"] row content [/kc_row]
add_filter( 'shortcode_kc_row', 'my_row_filter' );

// This filter will run before wp_header

function my_row_filter( $atts ){
    
    if( $atts[ 'style' ] === 1 )
        wp_enqueue_style('row-style-1', '/css/style1.css', false, '1.0' );

    if( $atts[ 'id' ] == 'my-id' )
        $atts[ 'id' ] = 'passed-filter';

    // All attributes go here via an array $atts
    // The name of shortcode goes via $atts[ '__name' ]
    // The content goes via $atts[ '__content' ]

    return $atts;

}