Support » Plugin: Shortcode Table of Contents » Filter shortcode presets

  • Great simple plugin! There are no filters available to set shortcode defaults. My clients dont know the right class names to set the parameter ‘content’. So if you want to set the default class for ‘content’ or set the default set of headers, use filter ‘shortcode_atts_{shortcode}’. This way you the shortcode get much cleaner like ‘[toc]’. If the parameters in the shortcode are set, the default are over ruled. Filter like:

    
        add_action('shortcode_atts_toc','nen_shortcode_atts_toc');
        function nen_shortcode_atts_toc( $out )
        {
                if( isset( $out['content'] ) && empty( $out['content'] ) ) $out['content'] = '.entry-content';
                if( isset( $out['headers'] ) && $out['headers'] == 'h1, h2, h3, h4, h5, h6' ) $out['headers'] = 'h2, h3, h4';
            
                return $out;
        }
    

    Hopefully James Kemp can apply a filter to add custom content before and/or after the div ‘shortcode-toc’. This way we can add a custom toc-header or something.

    Thanx!

    • This topic was modified 2 years, 1 month ago by nenontwerp.
  • The topic ‘Filter shortcode presets’ is closed to new replies.