GCBGutenberg
Control Blocks
Buy

Reference

PHP functions

Reference, generated from the plugin source

Every global gcblite_* function the plugin defines, with its signature as written in the code and the first paragraph of its docblock. They are kept outside the plugin's namespace so a theme can call them from functions.php or a render.php.

Each one is wrapped in if (!function_exists(...)), so a site can load them without GCB (the render helpers are what a block's render.php calls).

Field types

gcblite_register_control_type()

PHP
gcblite_register_control_type($type, array $args)
  • @param string $type 'my-field' — lowercase letters, digits and dashes; not a built-in name.
  • @param array $args shape (required: string|number|integer|boolean|object|array), doc (absolute path to a schemas/controls-style.md file), script (handle of an editor script that calls gcbLiteControls.register()).
  • @return bool Whether it was registered.

Source: includes/Fields/helpers.php:35

Options pages

gcblite_register_options_fields()

PHP
gcblite_register_options_fields($slug, array $config)

Source: includes/Options/helpers.php:21

gcblite_get_options()

PHP
gcblite_get_options($slug)

Source: includes/Options/helpers.php:27

Post fields

gcblite_register_post_fields()

PHP
gcblite_register_post_fields($post_type, array $config)

Source: includes/PostFields/helpers.php:16

gcblite_render_post_fields()

PHP
gcblite_render_post_fields($post_id = null)

Render the registered post-fields for a post as an ACF-style label/value stack. Defaults to the current post in The Loop.

  • @param int|null $post_id Specific post ID, or null for current.

Source: includes/PostFields/helpers.php:30

Render helpers (for render.php)

gcblite_post_card()

PHP
gcblite_post_card($post, array $args = []): string
  • @param \WP_Post|int|null $post The post; null for a blank card (a place kept while editing).
  • @param array $args 'taxonomy' => whose first term is the line under the title (default: category); 'level' => the title's tag, h2 to h6 (default h3); 'title' => a blank card's words.

Source: includes/Render/card.php:32

gcblite_embed_hosts()

PHP
gcblite_embed_hosts(): array

The hosts a widget's script may load from. Exact host names, lowercase. Add a provider with add_filter('gcblite_embed_hosts', fn ($h) => array_merge($h, ['widget.example.com']));.

  • @return string[]

Source: includes/Render/embed.php:34

gcblite_embed_script_src()

PHP
gcblite_embed_script_src(string $src): string

A script address as it will load — //host/x.js and http:// made https — when its host is on the allow-list; '' otherwise.

Source: includes/Render/embed.php:66

gcblite_embed_load()

PHP
gcblite_embed_load(string $src, string $strategy = ''): string

Load one allowed widget script, once per address per request. Returns '' when it was enqueued (or already loaded); the <script> tag to print when wp_footer has already run and an enqueue would never print.

  • @param string $strategy 'async', 'defer' or ''.

Source: includes/Render/embed.php:88

gcblite_embed_allowed_html()

PHP
gcblite_embed_allowed_html(): array

The wp_kses allow-list a widget's markup passes through.

Source: includes/Render/embed.php:113

gcblite_embed()

PHP
gcblite_embed($value, string $fallback = ''): string

A widget, ready to print: the stored snippet, else the drawn one ($fallback). Its allowed scripts are loaded (enqueued, or printed inline after wp_footer); every other script, every comment and anything the allow-list does not name is gone.

  • @param mixed $value the field's stored snippet
  • @param string $fallback the snippet the block was built with

Source: includes/Render/embed.php:136

PHP
gcblite_gallery_pictures($value, array $fallback = array()): array

A gallery field's value as pictures: [[url, alt], …] — a stored id read through the media library, a url kept.

  • @param mixed $value the stored value
  • @param array $fallback the design's own pictures, used when nothing is stored

Source: includes/Render/gallery.php:36

PHP
gcblite_gallery_slots($value, string $html, array $fallback = array()): string

The drawn places filled with the field's pictures.

  • @param mixed $value the stored value
  • @param string $html what the design drew inside the field's box
  • @param array $fallback the design's own pictures

Source: includes/Render/gallery.php:65

gcblite_value()

PHP
gcblite_value($v)

A stored value as PHP arrays all the way down: the editor hands arrays, the REST API hands objects.

Source: includes/Render/helpers.php:24

gcblite_sub()

PHP
gcblite_sub($v, $key)

One key of a stored value, or null — a hotspots field's image, say.

Source: includes/Render/helpers.php:41

gcblite_in_editor()

PHP
gcblite_in_editor()

Is this render for the editor or the REST API rather than a visitor?

Source: includes/Render/helpers.php:49

gcblite_fallback_url()

PHP
gcblite_fallback_url($fb)

A design-time address kept portable. The build writes uploads:/2026/10/x.jpg for a file in this site's uploads and content:/themes/x/y.jpg for one under wp-content, so a block moved to another host — a staging copy, a client's site — still finds its picture. Any other address is returned as it is.

Source: includes/Render/helpers.php:60

gcblite_image_url()

PHP
gcblite_image_url($v, $size = 'large')

A picture's address: the attachment at the stored id (older data stored a bare id), else the url the value carries (an external picture, a seeded one), else ''.

Source: includes/Render/helpers.php:78

gcblite_resolve_portable_urls()

PHP
gcblite_resolve_portable_urls($html)

Every portable address in a run of HTML put back on this site: uploads:/… and content:/… as the build writes them into a Repeater's template (the seeded items' pictures), resolved before the editor reads the template and seeds them into a post. Nothing else in markup starts with those words.

Source: includes/Render/helpers.php:95

gcblite_resolve_portable_value()

PHP
gcblite_resolve_portable_value($value)

A field value with every portable address in it put back on this site — any string that STARTS uploads:/ or content:/, however deep in the value; text that only mentions one is left alone. For a control's default: the default went from block.fields.json into the block's registration and the editor's copy of the controls as written, and the canvas printed it as an <img> src no browser loads.

Source: includes/Render/helpers.php:119

gcblite_image_src()

PHP
gcblite_image_src($v, $size = 'large', $fallback = '')

What an <img>'s src prints: the picture, else the design's own (made portable), else — for a visitor only — a see-through pixel, so an empty slot prints no alt words over the page while the editor still shows a slot. A data: fallback goes through esc_attr: esc_url would strip it.

Source: includes/Render/helpers.php:136

gcblite_image_alt()

PHP
gcblite_image_alt($v, $fallback = '')

The alt a person wrote on the picture, else the design's.

Source: includes/Render/helpers.php:151

gcblite_image_style()

PHP
gcblite_image_style($v)

The inline style a person's picture settings add: focal point → object-position; size contain/auto → object-fit; a custom width; a zoom (capped at 3) that scales about the focal point and clips back to the picture's own box. Pure: returns the declarations, '' when nothing is set.

Source: includes/Render/helpers.php:164

gcblite_image_ratio()

PHP
gcblite_image_ratio($v)

width ÷ height of the file a picture value points at — its attachment's metadata, or an SVG's width/height or viewBox — 0.0 when it cannot be known (no attachment, no WordPress).

Source: includes/Render/helpers.php:207

gcblite_image_style_attr()

PHP
gcblite_image_style_attr($v, $own = '')

The whole style="…" attribute, the design's own declarations first; '' when there is nothing to say. With the picture's shape as --r when it is known, and a person's Scale (80–125%) as --cm-scale: contain.css reads them for a list of logos, and nothing else does.

Source: includes/Render/helpers.php:258

PHP
gcblite_link_url($v)

A link field's address as a string, whatever shape the value arrived in.

Source: includes/Render/helpers.php:275

PHP
gcblite_link_href($v)

What href= prints.

Source: includes/Render/helpers.php:283

PHP
gcblite_link_target($v)

target="_blank" rel="noopener noreferrer" when the person asked for a new tab, else ''.

Source: includes/Render/helpers.php:290

PHP
gcblite_link_text($v, $fallback = '')

The words a person gave the link, else the words the design wrote.

Source: includes/Render/helpers.php:298

gcblite_any_set()

PHP
gcblite_any_set($attributes, array $keys)

Does any of these attributes hold something? An optional part renders only then. "Something" is a non-empty scalar, or a picture, link or icon value with an id, a url or a name.

Source: includes/Render/helpers.php:310

gcblite_resolve_post_portable_urls()

PHP
gcblite_resolve_post_portable_urls($data)

Source: includes/Render/helpers.php:330

PHP
gcblite_link_parts($v, $fallback = '')

A url field in the three pieces a render prints: [href, the new-tab attributes, the words]. href is escaped, or '' when the field holds no address — so a render can leave the link out; the words are the person's, else $fallback, UNESCAPED (print them with esc_html). [$href, $new, $text] = gcblite_link_parts($attributes['link'] ?? null, 'Read more');

Source: includes/Render/helpers.php:346

gcblite_theme_image()

PHP
gcblite_theme_image($path, $alt = '')

A picture the active theme ships, as an image field value with a portable address (content:/themes/{theme}/…) — for a Repeater template's seeded items, which the editor resolves to this site's address as it seeds them. $path is relative to the theme folder: gcblite_theme_image('assets/img/logo.png', 'MG').

Source: includes/Render/helpers.php:360

gcblite_layout_count()

PHP
gcblite_layout_count($count, $default = 24)

How many items a list holds: the block's inner blocks (WordPress hands a WP_Block_List — Countable, never cast to an array: it has three properties of its own), a plain number, else $default — enough for any list a person is likely to draw.

Source: includes/Render/layout.php:27

gcblite_layout_css()

PHP
gcblite_layout_css($attributes, $key, $id, array $limits, $count = 24)

The <style> that places a grid's boxes as a person arranged them in the Layout control — or '' when nothing is stored, when they kept the drawn layout, when the value does not fit the control's limits, or where gcb-lite's Contract\Fields is not loaded. The grid element carries data-gcb-layout="$id"; the rules address it by that mark (written twice, so they beat the design's own utility classes) and its boxes as its direct children.

  • @param array|object $attributes the block's attributes
  • @param string $key the layout field's attribute key: 'layout', 'layout2', …
  • @param string $id the grid's mark, from wp_unique_id('gcb-l-'); letters, digits, - and _ only
  • @param array $limits the control's limits — cols, minItemPx, containerPx, gapPx (Fields::layout_limits)
  • @param int|object $count how many boxes: a number for a grid of fixed boxes, or the $block whose inner blocks are a list's items (gcblite_layout_count)

Source: includes/Render/layout.php:52

gcblite_setting()

PHP
gcblite_setting($attributes, string $key, string $default, string $drawn = ''): string

The value a part's attribute prints: the stored word when it is safe, else the default; drawn means the drawing's own value. Attributes arrive as an array from the editor or an object from the REST API; a value that is not a string — an array, an object, a number — is not a safe word and falls to the default.

Source: includes/Render/settings.php:29

gcblite_heading_tag()

PHP
gcblite_heading_tag($attributes, $key, $drawn = 'h2')

The heading's tag: the chosen <key>_level when it is one of h1–h6, the drawn tag otherwise. Returns the bare tag name — it only ever comes from this whitelist, so it needs no escaping. The render keeps it in $__gcb_h so the close tag matches whatever the open tag printed.

Source: includes/Render/text.php:27

gcblite_rich_inline()

PHP
gcblite_rich_inline($html)

One paragraph in a line of text is its words: the sidebar's rich-text editor wraps what it holds in <p>, so a bold word typed in place came back as <p>…</p> inside the <h1>. Given html that is exactly one paragraph, returns its inside; anything else — two paragraphs, no paragraph — as it is. Takes html already run through wp_kses_post; the render shows that call so the escaping stays in view.

Source: includes/Render/text.php:40

gcblite_number()

PHP
gcblite_number($v, $group = true, $decimals = null)

A number prints as a number: grouped the way a person reads it (370,000 not 370000), at the FIELD'S precision when the control says one, else with the decimals the value was stored with.

Source: includes/Render/text.php:67

gcblite_icon_svg()

PHP
gcblite_icon_svg($value, $fallback_svg = '')

An icon's drawing. The stored value is {source, name} (or, from older data, a bare name). Then WordPress's own registry — wp_get_icon on 7.1, the registry itself on 7.0, the same two steps gcb-lite's icon-list-item takes — and last the drawing the block was built with.

Source: includes/Render/text.php:104

gcblite_field()

PHP
gcblite_field($key, $type = 'text')

The attributes that make an element inline-editable on the canvas: GCB binds RichText (or the media picker) to the element that carries them. <h2 class="x" + echo gcblite_field('heading') + > (written without an opening tag here: Eject bundles this file into one, and counts them). Escaped.

Source: includes/Render/text.php:133

gcblite_lines()

PHP
gcblite_lines($text)

A textarea's value as HTML: escaped, its line breaks kept as
.

Source: includes/Render/text.php:140

gcblite_rich()

PHP
gcblite_rich($html)

A richtext field's value as inline HTML: what wp_kses_post allows, one wrapping paragraph taken off.

Source: includes/Render/text.php:147

gcblite_rows()

PHP
gcblite_rows($text)

A textarea typed as rows, one per line: Label | value → [label, value] (a line with no bar → [line, '']); a line of three or more dashes → null, a rule between groups; blank lines are skipped. Unescaped — escape where it prints. For short lists an author types in the sidebar: menu links, select options, spec tables.

  • @return array<int, array{0: string, 1: string}|null>

Source: includes/Render/text.php:160

Taxonomy term fields

gcblite_register_taxonomy_fields()

PHP
gcblite_register_taxonomy_fields($taxonomy, array $config)

Source: includes/Taxonomy/helpers.php:21

gcblite_get_term_fields()

PHP
gcblite_get_term_fields($taxonomy, $term_id)

Convenience wrapper around get_term_meta that fills declared defaults for missing keys, matching the REST shape.

Source: includes/Taxonomy/helpers.php:31

User profile fields

gcblite_register_user_fields()

PHP
gcblite_register_user_fields(array $config)

Source: includes/User/helpers.php:27

gcblite_get_user_fields()

PHP
gcblite_get_user_fields($user_id)

Source: includes/User/helpers.php:33

gcblite_get_public_user_fields()

PHP
gcblite_get_public_user_fields($user_id)

Source: includes/User/helpers.php:45

Built from GCB Lite 0.4.0 (ce232d4). Source: includes/.

Copyright © 2026 Runchain. WordPress is a trademark of the WordPress Foundation.