{"id":18,"date":"2025-09-26T08:50:45","date_gmt":"2025-09-26T08:50:45","guid":{"rendered":"https:\/\/ska-blocks.com\/docs\/2025\/09\/26\/code-block\/"},"modified":"2025-09-27T09:58:23","modified_gmt":"2025-09-27T09:58:23","slug":"code-block","status":"publish","type":"post","link":"https:\/\/ska-blocks.com\/docs\/code-block\/","title":{"rendered":"Code block"},"content":{"rendered":"\n<p class=\"lead\">The code block is an alternative for the WordPress code block with the addition of syntax highlighting, indenting and copy function.<\/p>\n\n\n\n<p>The Code block uses the &#8220;Code block&#8221; <a href=\"https:\/\/ska-blocks.com\/docs\/presets\/\" data-type=\"post\" data-id=\"46\">preset<\/a> for its&#8217; appearance by default.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Basic code block<\/h2>\n\n\n\n<div class=\"wp-block-ska-code not-prose ska-preset--ska-theme--code\"><div class=\"content\"><pre class=\"code html language-html\"><code class=\"language-html\">&lt;p class=\"lead\">The code block is an alternative for the WordPress code block with the addition of syntax highlighting, indenting and copy function.&lt;\/p><\/code><\/pre><\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Code block with a header<\/h2>\n\n\n\n<p>Code block can have a header that can contain a short description of the given code.<\/p>\n\n\n\n<div class=\"wp-block-ska-code not-prose ska-preset--ska-theme--code\"><header><span class=\"title\">Basic WordPress theme.json<\/span><span class=\"label language-json\">JSON<\/span><\/header><div class=\"content\"><pre class=\"code json language-json\"><code class=\"language-json\">{\n\t\"$schema\": \"https:\/\/schemas.wp.org\/trunk\/theme.json\",\n\t\"version\": 3\n}<\/code><\/pre><\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Copy button<\/h2>\n\n\n\n<p>Code block can include a button for copying its&#8217; contents. The button requires <a href=\"https:\/\/ska-blocks.com\/docs\/ska-theme\/alpine-js\/\">Alpine.js<\/a> so if you&#8217;re not using ska-theme you&#8217;ll need to provide your own.<\/p>\n\n\n\n<div class=\"wp-block-ska-code not-prose ska-preset--ska-theme--code\"><div class=\"content\"><pre class=\"code php language-php\"><code class=\"language-php\">\/**\n * Disable auto-update email notifications.\n *\/\nadd_filter('auto_core_update_send_email', '__return_false');\nadd_filter('auto_plugin_update_send_email', '__return_false');\nadd_filter('auto_theme_update_send_email', '__return_false');<\/code><\/pre><button :class=\"{error: state === &apos;error&apos;, success: state === &apos;success&apos;}\" x-data=\"{state:&apos;&apos;}\" x-on:click=\"navigator.clipboard ? (navigator.clipboard.writeText($el.previousElementSibling.innerText), $el.innerText = `Copied!`, state = &apos;success&apos;) : ($el.innerText = `Can&amp;#039;t copy`, state = &apos;error&apos;)\" class=\"copy\" type=\"button\">Copy<\/button><span class=\"label language-php\">PHP<\/span><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The code block is an alternative for the WordPress code block with the addition of syntax highlighting, indenting and copy function. The Code block uses the &#8220;Code block&#8221; preset for its&#8217; appearance by default. Basic code block Code block with a header Code block can have a header that can contain a short description of&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[4],"class_list":["post-18","post","type-post","status-publish","format-standard","hentry","category-ska-theme","tag-blocks"],"_links":{"self":[{"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/posts\/18","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/comments?post=18"}],"version-history":[{"count":2,"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/posts\/18\/revisions"}],"predecessor-version":[{"id":355,"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/posts\/18\/revisions\/355"}],"wp:attachment":[{"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/media?parent=18"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/categories?post=18"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/tags?post=18"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}