{"id":33896,"date":"2019-03-01T16:36:24","date_gmt":"2019-03-01T16:36:24","guid":{"rendered":"http:\/\/getshortcodes.com\/?post_type=docs&#038;p=33896"},"modified":"2020-04-15T17:25:00","modified_gmt":"2020-04-15T17:25:00","slug":"disabling-built-in-shortcodes","status":"publish","type":"docs","link":"https:\/\/getshortcodes.com\/docs\/disabling-built-in-shortcodes\/","title":{"rendered":"Disabling built-in shortcodes"},"content":{"rendered":"\n<p>You can use the plugin API in order to remove default shortcodes. Use filter&nbsp;<em>su\/data\/shortcodes<\/em> to do that.<\/p>\n\n\n<p class=\"h2\">Table of contents<\/p>\n\n<ol><li><a href=\"#disabling-all-shortcodes\">Disabling all shortcodes<\/a><\/li><li><a href=\"#disabling-specific-shortcodes\">Disabling specific shortcodes<\/a><\/li><li><a href=\"#disabling-all-shortcodes-except-custom-ones\">Disabling all shortcodes except custom ones<\/a><\/li><\/ol><\/li><\/ol>\n\n\n<h2 class=\"wp-block-heading\" id=\"disabling-all-shortcodes\">Disabling all shortcodes<\/h2>\n\n\n\n<p>To remove all shortcodes, you should simply remove all elements from shortcode array.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">add_filter( 'su\/data\/shortcodes', 'remove_su_shortcodes' );<br><br>\/**<br> * Filter to modify original shortcodes data<br> *<br> * @param array   $shortcodes Default shortcodes<br> * @return array Modified array<br> *\/<br>function remove_su_shortcodes( $shortcodes ) {<br><br>  \/\/ Remove all shortcodes<br>  $shortcodes = array();<br><br>  \/\/ Return modified data<br>  return $shortcodes;<br><br>}<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"disabling-specific-shortcodes\">Disabling specific shortcodes<\/h2>\n\n\n\n<p>Use the same filter as in the previous example in order to remove specific shortcodes. However, not all elements of the array, but only some elements will be removed. For example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">add_filter( 'su\/data\/shortcodes', 'remove_su_shortcodes' );<br><br>\/**<br> * Filter to modify original shortcodes data<br> *<br> * @param array   $shortcodes Default shortcodes<br> * @return array Modified array<br> *\/<br>function remove_su_shortcodes( $shortcodes ) {<br><br>  \/\/ Remove button shortcode<br>  unset( $shortcodes['button'] );<br><br>  \/\/ Return modified data<br>  return $shortcodes;<br><br>}<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"disabling-all-shortcodes-except-custom-ones\">Disabling all shortcodes except custom ones<\/h2>\n\n\n\n<p>The following code will disable all shortcodes except those made with the <a href=\"\/add-ons\/shortcode-creator\/\">Shortcode Creator add-on<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_filter(\n\t'su\/data\/shortcodes',\n\tfunction( $shortcodes ) {\n\n\t\treturn array_filter(\n\t\t\t$shortcodes,\n\t\t\tfunction( $shortcode ) {\n\t\t\t\treturn isset( $shortcode&#91;'group'] ) &amp;&amp; 'shortcode-creator' === $shortcode&#91;'group'];\n\t\t\t}\n\t\t);\n\n\t},\n\t99,\n\t1\n);<\/code><\/pre>\n\n\n\n<p>The following snippet will also remove all shortcode groups.<\/p>\n\n\n\n<p class=\"has-text-color has-background has-black-color has-yellow-background-color\">The code below requires PHP version 5.5 or higher.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_filter(\n\t'su\/data\/groups',\n\tfunction( $groups ) {\n\n\t\treturn array_filter(\n\t\t\t$groups,\n\t\t\tfunction( $group ) {\n\t\t\t\treturn in_array( $group, array( 'all' ) );\n\t\t\t},\n\t\t\tARRAY_FILTER_USE_KEY\n\t\t);\n\n\t}\n);<\/code><\/pre>\n","protected":false},"featured_media":0,"template":"","docs_category":[24],"class_list":["post-33896","docs","type-docs","status-publish","hentry","docs_category-api"],"_links":{"self":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/docs\/33896","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/types\/docs"}],"wp:attachment":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/media?parent=33896"}],"wp:term":[{"taxonomy":"docs_category","embeddable":true,"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/docs_category?post=33896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}