{"id":10824053,"date":"2018-10-28T16:50:01","date_gmt":"2018-10-28T16:50:01","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/filter-shortcode-presets\/"},"modified":"2018-10-28T20:21:33","modified_gmt":"2018-10-28T20:21:33","slug":"filter-shortcode-presets","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/filter-shortcode-presets\/","title":{"rendered":"Filter shortcode presets"},"content":{"rendered":"<p>Great simple plugin! There are no filters available to set shortcode defaults. My clients dont know the right class names to set the parameter &#8216;content&#8217;. So if you want to set the default class for &#8216;content&#8217; or set the default set of headers, use filter &#8216;shortcode_atts_{shortcode}&#8217;. This way you the shortcode get much cleaner like &#8216;[toc]&#8217;. If the parameters in the shortcode are set, the default are over ruled. Filter like:<\/p>\n<pre><code>\n    add_action(&#039;shortcode_atts_toc&#039;,&#039;nen_shortcode_atts_toc&#039;);\n    function nen_shortcode_atts_toc( $out )\n    {\n            if( isset( $out[&#039;content&#039;] ) &amp;&amp; empty( $out[&#039;content&#039;] ) ) $out[&#039;content&#039;] = &#039;.entry-content&#039;;\n            if( isset( $out[&#039;headers&#039;] ) &amp;&amp; $out[&#039;headers&#039;] == &#039;h1, h2, h3, h4, h5, h6&#039; ) $out[&#039;headers&#039;] = &#039;h2, h3, h4&#039;;\n        \n            return $out;\n    }\n<\/code><\/pre>\n<p>Hopefully James Kemp can apply a filter to add custom content before and\/or after the div &#8216;shortcode-toc&#8217;. This way we can add a custom toc-header or something.<\/p>\n<p>Thanx!<\/p>\n","protected":false},"template":"","class_list":["post-10824053","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/10824053","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/10824053\/revisions"}],"predecessor-version":[{"id":10824411,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/10824053\/revisions\/10824411"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=10824053"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}