Title: Nahnu Code &amp; API Block
Author: Jaime Alnassim
Published: <strong>16 верасня, 2026</strong>
Last modified: 16 верасня, 2026

---

Пошук плагінаў

![](https://ps.w.org/nahnu-code-block/assets/banner-772x250.png?rev=3698225)

![](https://ps.w.org/nahnu-code-block/assets/icon-256x256.png?rev=3698225)

# Nahnu Code & API Block

 Аўтар: [Jaime Alnassim](https://profiles.wordpress.org/ja1me4/)

[Спампаваць](https://downloads.wordpress.org/plugin/nahnu-code-block.1.0.0.zip)

 * [Падрабязнасці](https://bel.wordpress.org/plugins/nahnu-code-block/#description)
 * [Водгукі](https://bel.wordpress.org/plugins/nahnu-code-block/#reviews)
 *  [Ўсталёўка](https://bel.wordpress.org/plugins/nahnu-code-block/#installation)
 * [Распрацоўка](https://bel.wordpress.org/plugins/nahnu-code-block/#developers)

 [Падтрымка](https://wordpress.org/support/plugin/nahnu-code-block/)

## Апісанне

Nahnu Code & API Block gives the block editor everything a developer-facing site
needs to document code and APIs: a polished syntax-highlighted code block, and a
matching family of blocks purpose-built for API reference pages — endpoints, parameter
tables, tabbed request/response examples, status code tables, authentication headers,
and a live try-it console.

**The code block**

 * Syntax highlighting for 20+ languages, powered by Prism.js and bundled with the
   plugin (no external CDN requests).
 * Automatic light/dark mode: follows the visitor’s OS preference, and can also 
   follow a dark-mode class or attribute your theme or another plugin already sets
   on `<html>` or `<body>` (filterable).
 * An optional per-block toggle button so visitors can flip a single code block 
   between light and dark themes manually.
 * Long snippets collapse to a configurable preview height with a “View all code”
   button that opens the complete snippet in a modal.
 * One-click Copy button, optional line numbers.

**The API-documentation blocks**

 * **Endpoint** — HTTP method badge, path, summary, version badge, and an optional
   deprecation notice.
 * **Parameters** — a name / type / required-optional / description table.
 * **Request / Response** — tabbed code examples per language (cURL, JavaScript,
   Python, PHP, and more), each with Request and Response sub-tabs. Language selection
   is synced and remembered across every Request/Response block on the same page.
 * **Status Codes** — a table of the HTTP status codes your API returns, color-coded
   by class (2xx/3xx/4xx/5xx), with an optional collapsible example response body.
 * **Authentication** — shows the exact header a client needs to send (Bearer token,
   API key, Basic auth, or OAuth 2.0), with a copy button.
 * **Try It Console** — a live request form visitors can edit (URL, headers, body)
   and send directly from their own browser to see a real response. This performs
   a genuine client-side request; it never proxies or issues the call from your 
   WordPress server.

All blocks share the same visual language and the same light/dark theming, so a 
full API reference page looks consistent throughout.

#### External services and data

Nahnu Code & API Block does not connect to any external service, API, or CDN at 
runtime, and does not collect, transmit, or store any personal data. The Prism.js
syntax-highlighting library is bundled with the plugin files (MIT licensed) rather
than loaded from a third-party server. The Try It Console block is the one exception
worth being explicit about: when a site visitor clicks “Send request” on that block,
their own browser makes a direct HTTP request to whatever URL is shown in that block(
which the page author configured, and the visitor can edit). That request comes 
from the visitor’s browser, not from your WordPress server, and nothing about it
is seen by this plugin’s author or by Nahnu.

## Скрыншоты

[⌊An Endpoint block and a code block together on a documentation page.⌉⌊An Endpoint
block and a code block together on a documentation page.⌉[

An Endpoint block and a code block together on a documentation page.

[⌊The "View all code" modal, opened from a collapsed code block.⌉⌊The "View all 
code" modal, opened from a collapsed code block.⌉[

The “View all code” modal, opened from a collapsed code block.

[⌊The Try It Console alongside Authentication, Endpoint, and Parameters blocks.⌉⌊
The Try It Console alongside Authentication, Endpoint, and Parameters blocks.⌉[

The Try It Console alongside Authentication, Endpoint, and Parameters blocks.

[⌊Editing an Endpoint block's settings in the block editor.⌉⌊Editing an Endpoint
block's settings in the block editor.⌉[

Editing an Endpoint block’s settings in the block editor.

## Блокі

Гэты плагін прадастаўляе 7 блокаў.

 *   API Request / Response Tabbed request and response code examples per language,
   synced across every request/response block on the page.
 *   API Endpoint Show an API endpoint's HTTP method, path, and summary — with an
   optional deprecation notice.
 *   API Try It Console A live request console visitors can use to call your API
   directly from their browser and see the real response.
 *   API Parameters A parameters table for API documentation: name, type, required/
   optional, and description.
 *   API Status Codes A table of HTTP status codes your API returns, with meaning,
   description, and an optional example body.
 *   Nahnu Code Block A professional, syntax-highlighted code snippet block with
   light/dark mode, a collapsible preview, a copy button, and a full-code modal.
 *   API Authentication Show how to authenticate against an API: bearer token, API
   key, basic auth, or OAuth 2.0.

## Ўсталёўка

 1. Upload the `nahnu-code-block` folder to `/wp-content/plugins/`, or install the 
    plugin through the **Plugins  Add New** screen in your WordPress admin.
 2. Activate the plugin through the **Plugins** screen.
 3. Edit any post or page, add a new block, and search for “Nahnu” to see the full 
    set of code and API blocks.
 4. Configure each block from its sidebar settings.

## Часта задаваныя пытанні

### Does this send my code anywhere?

No. Everything is rendered on your own server and in the visitor’s browser. The 
plugin makes no external network requests, with the one exception noted above for
the Try It Console, which is a request the visitor themselves chooses to send.

### Will this conflict with my theme’s or another plugin’s dark mode switcher?

It’s designed to cooperate rather than compete. By default it follows the visitor’s
OS-level light/dark preference. You can also use the `nahnu_code_block_dark_mode_selectors`
filter to tell it which CSS selector your existing dark-mode plugin toggles (for
example `body.dark-mode`), so the code block switches along with the rest of your
site.

### Can I integrate my own dark-mode toggle with this plugin?

Yes. If your theme or plugin already sets a class or attribute for dark mode (like`
body.dark-mode`), add it via the `nahnu_code_block_dark_mode_selectors` PHP filter
and it works automatically, with no JavaScript required. If your toggle is JavaScript-
driven, call `window.NahnuCodeBlock.setTheme('dark' | 'light' | 'auto')` from your
own click handler. Full details, including how to rebrand the actual colors, are
in `HOOKS.md` in the plugin folder.

### Can I change the syntax highlighting or table colors?

Yes. All colors are exposed as CSS custom properties scoped to `.nahnu-code-block`(
for example `--nahnu-code-block-token-string`), so they can be overridden from your
theme’s stylesheet without touching plugin files.

### Is the Try It Console safe to use?

It only ever performs a request from the visitor’s own browser to a URL you configure(
and the visitor can see and edit before sending). It does not run on, or route through,
your WordPress server, so it can’t be used to make your server call arbitrary internal
or external URLs.

### Does it work with the Classic Editor?

No. These are blocks for the block editor (Gutenberg).

## Водгукі

На гэты плагін няма водгукаў.

## Удзельнікі і распрацоўшчыкі

“Nahnu Code & API Block” з’яўляецца праграмным забеспячэннем з адкрытым зыходным
кодам. Наступныя людзі ўнеслі свой уклад у гэты плагін.

Удзельнікі

 *   [ Jaime Alnassim ](https://profiles.wordpress.org/ja1me4/)

[Перакласці “Nahnu Code & API Block” на вашу мову.](https://translate.wordpress.org/projects/wp-plugins/nahnu-code-block)

### Зацікаўлены ў распрацоўцы?

[Праглядзіце код](https://plugins.trac.wordpress.org/browser/nahnu-code-block/),
праверце [SVN рэпазітарый](https://plugins.svn.wordpress.org/nahnu-code-block/),
або падпішыцеся на [журнал распрацоўкі](https://plugins.trac.wordpress.org/log/nahnu-code-block/)
па [RSS](https://plugins.trac.wordpress.org/log/nahnu-code-block/?limit=100&mode=stop_on_copy&format=rss).

## Журнал змяненняў

#### 1.0.0

 * First public WP.org version.

## Мета

 *  Версія **1.0.0**
 *  Апошняе абнаўленне **1 дзень таму**
 *  Актыўных установак **Менш за 10**
 *  Версія WordPress ** 6.3 або вышэй **
 *  Правераны да версіі **7.1**
 *  Версія PHP ** 7.4 або вышэй **
 *  Мова
 * [English (US)](https://wordpress.org/plugins/nahnu-code-block/)
 * Тэгі
 * [code block](https://bel.wordpress.org/plugins/tags/code-block/)[gutenberg](https://bel.wordpress.org/plugins/tags/gutenberg/)
   [rest-api](https://bel.wordpress.org/plugins/tags/rest-api/)[syntax highlighting](https://bel.wordpress.org/plugins/tags/syntax-highlighting/)
 *  [Пашыраны прагляд](https://bel.wordpress.org/plugins/nahnu-code-block/advanced/)

## Ацэнкі

Пакуль яшчэ няма водгукаў.

[Ваш водгук](https://wordpress.org/support/plugin/nahnu-code-block/reviews/#new-post)

[Паглядзець усе водгукі](https://wordpress.org/support/plugin/nahnu-code-block/reviews/)

## Удзельнікі

 *   [ Jaime Alnassim ](https://profiles.wordpress.org/ja1me4/)

## Падтрымка

Ёсць што сказаць? Патрэбна дапамога?

 [Перайсці да форуму падтрымкі](https://wordpress.org/support/plugin/nahnu-code-block/)