NicheWP
Table of Contents
Constants
- TRANSIENT_PREFIX : string = 'xs_theme_meta_'
- Dynamic transient key prefix used for caching site-wide lightness metadata.
Functions
- register_block_bindings() : void
- Registers custom WordPress block binding source for Featured Image bound to the standard Image block. This is so we or users can add lightbox functionality to it. This is used in various Template Parts.
- featured_image_binding() : string|null
- Callback handler for the 'lumina/featured-image' dynamic block binding.
- register_additional_pattern_categories() : void
- Registers additional block pattern categories for NicheWP products.
- remove_core_block_patterns() : void
- Removes core WordPress block patterns so they do not clutter the editor design tab.
- get_transient_key() : string
- Returns a transient key dynamically scoped to the current theme/child-theme slug.
- hsl_to_rgb() : array{0: int, 1: int, 2: int}
- Converts HSL/HSLA color channels down to baseline RGB values (0–255 range).
- hue_to_rgb() : float|int
- Helper function for HSL conversion steps.
- add_body_classes() : array<string|int, mixed>
- Appends dynamic canvas luminance, theme mode, and color scheme variant classes to the body class array.
- clear_lightness_transient() : void
- Clears the lightness transient metadata cache for the active theme.
- purge_empty_comments_template_part() : string
- Removes the Comments template part from rendered output if it contains no functional HTML tags.
- register_theme_svg_icons() : void
- Registers custom SVG icons using the WP 7.1 Icon API across sub-folder sets.
- get_featured_image_fallback_data() : array{url: string, alt: string}
- 1A. THE FEATURED IMAGE ENGINE CORE Dynamically scans Lumina's asset directory for fallback featured images.
- get_default_site_logo_url() : string
- 1B. THE SITE LOGO ENGINE CORE Resolves default site logo from theme settings with fallback to DEFAULT_SITE_LOGO.
- get_default_site_logo_dimensions() : array{width: int, height: int}
- 1C. LOGO DIMENSIONS RESOLVER Resolves intrinsic or configured pixel dimensions for the fallback site logo.
- filter_cover_block_fallback() : string
- 2A. THE COVER TOGGLE INTERCEPT Intercepts Core Cover block rendering to inject fallback featured images.
- filter_media_text_block_fallback() : string
- 2B. THE MEDIA & TEXT TOGGLE INTERCEPT Intercepts Core Media & Text block rendering to inject fallback featured images.
- filter_site_logo_block_fallback() : string
- 2C. THE SITE LOGO BLOCK INTERCEPT Intercepts Core Site Logo block rendering to supply fallback logo markup.
- filter_get_custom_logo_fallback() : string
- 2D. THE LEGACY CUSTOM LOGO INTERCEPT Intercepts legacy get_custom_logo HTML output to supply fallback site logo.
- get_registered_image_size_dimensions() : array{width: int, height: int}
- Helper function to resolve pixel dimensions for standard or custom image sizes.
- filter_legacy_post_thumbnail_html() : string
- 3. THE POST THUMBNAIL / FEATURED IMAGE INTERCEPT Intercepts post_thumbnail_html to output fallback featured images for posts missing thumbnails.
- has_post_thumbnail_fallback() : bool
- 4. FORCE TRUE FOR WRAPPERS CONSISTENCY Forces has_post_thumbnail to return true so theme wrappers always render fallback markup.
Constants
TRANSIENT_PREFIX
Dynamic transient key prefix used for caching site-wide lightness metadata.
public
string
TRANSIENT_PREFIX
= 'xs_theme_meta_'
Functions
register_block_bindings()
Registers custom WordPress block binding source for Featured Image bound to the standard Image block. This is so we or users can add lightbox functionality to it. This is used in various Template Parts.
register_block_bindings() : void
featured_image_binding()
Callback handler for the 'lumina/featured-image' dynamic block binding.
featured_image_binding(array<string, mixed> $source_args, WP_Block $block_instance[, string $attribute_name = 'url' ]) : string|null
Performs a four-tier Post ID lookup to guarantee context inside template parts, falling back to default theme assets if no post thumbnail is set.
Parameters
- $source_args : array<string, mixed>
-
Arguments passed from the block binding definition.
- $block_instance : WP_Block
-
The instance of the block being rendered.
- $attribute_name : string = 'url'
-
Target attribute being requested ('url' or 'alt').
Return values
string|null —Resolved image URL, alt text string, or null if unresolvable.
register_additional_pattern_categories()
Registers additional block pattern categories for NicheWP products.
register_additional_pattern_categories() : void
remove_core_block_patterns()
Removes core WordPress block patterns so they do not clutter the editor design tab.
remove_core_block_patterns() : void
get_transient_key()
Returns a transient key dynamically scoped to the current theme/child-theme slug.
get_transient_key() : string
Return values
string —WordPress Transient Database Key (Prefix + Theme Slug)
hsl_to_rgb()
Converts HSL/HSLA color channels down to baseline RGB values (0–255 range).
hsl_to_rgb(float|int $h, float|int $s, float|int $l) : array{0: int, 1: int, 2: int}
Parameters
- $h : float|int
-
Hue value (0 to 360).
- $s : float|int
-
Saturation value (0 to 100).
- $l : float|int
-
Lightness value (0 to 100).
Return values
array{0: int, 1: int, 2: int} —Array containing red, green, and blue integer channels.
hue_to_rgb()
Helper function for HSL conversion steps.
hue_to_rgb(float|int $p, float|int $q, float|int $t) : float|int
Parameters
- $p : float|int
-
First color helper value.
- $q : float|int
-
Second color helper value.
- $t : float|int
-
Channel tint/hue component value.
Return values
float|int —Calculated RGB color component.
add_body_classes()
Appends dynamic canvas luminance, theme mode, and color scheme variant classes to the body class array.
add_body_classes(array<string|int, mixed> $classes) : array<string|int, mixed>
Parameters
- $classes : array<string|int, mixed>
-
Array of existing body class names.
Return values
array<string|int, mixed> —Array of modified body class names.
clear_lightness_transient()
Clears the lightness transient metadata cache for the active theme.
clear_lightness_transient() : void
purge_empty_comments_template_part()
Removes the Comments template part from rendered output if it contains no functional HTML tags.
purge_empty_comments_template_part(string $block_content, array<string, mixed> $block) : string
Parameters
- $block_content : string
-
The block's rendered HTML.
- $block : array<string, mixed>
-
The block instance data.
Return values
string —Filtered block markup or empty string when no comment content exists.
register_theme_svg_icons()
Registers custom SVG icons using the WP 7.1 Icon API across sub-folder sets.
register_theme_svg_icons() : void
get_featured_image_fallback_data()
1A. THE FEATURED IMAGE ENGINE CORE Dynamically scans Lumina's asset directory for fallback featured images.
get_featured_image_fallback_data([int|null $post_id = null ]) : array{url: string, alt: string}
Parameters
- $post_id : int|null = null
-
Optional post ID to calculate hashed image selections.
Return values
array{url: string, alt: string} —Fallback image URL and alt text array.
get_default_site_logo_url()
1B. THE SITE LOGO ENGINE CORE Resolves default site logo from theme settings with fallback to DEFAULT_SITE_LOGO.
get_default_site_logo_url() : string
Return values
string —Filtered logo image URL.
get_default_site_logo_dimensions()
1C. LOGO DIMENSIONS RESOLVER Resolves intrinsic or configured pixel dimensions for the fallback site logo.
get_default_site_logo_dimensions([int $target_width = 0 ]) : array{width: int, height: int}
Parameters
- $target_width : int = 0
-
Requested target pixel width.
Return values
array{width: int, height: int} —Dimension array containing width and height.
filter_cover_block_fallback()
2A. THE COVER TOGGLE INTERCEPT Intercepts Core Cover block rendering to inject fallback featured images.
filter_cover_block_fallback(string $block_content, array<string, mixed> $block) : string
Parameters
- $block_content : string
-
Rendered HTML output of the Cover block.
- $block : array<string, mixed>
-
Block configuration and attributes array.
Return values
string —Filtered Cover block HTML output.
filter_media_text_block_fallback()
2B. THE MEDIA & TEXT TOGGLE INTERCEPT Intercepts Core Media & Text block rendering to inject fallback featured images.
filter_media_text_block_fallback(string $block_content, array<string, mixed> $block) : string
Parameters
- $block_content : string
-
Rendered HTML output of the Media & Text block.
- $block : array<string, mixed>
-
Block configuration and attributes array.
Return values
string —Filtered Media & Text block HTML output.
filter_site_logo_block_fallback()
2C. THE SITE LOGO BLOCK INTERCEPT Intercepts Core Site Logo block rendering to supply fallback logo markup.
filter_site_logo_block_fallback(string $block_content, array<string, mixed> $block) : string
Parameters
- $block_content : string
-
Rendered HTML output of the Site Logo block.
- $block : array<string, mixed>
-
Block configuration and attributes array.
Return values
string —Filtered Site Logo block HTML output.
filter_get_custom_logo_fallback()
2D. THE LEGACY CUSTOM LOGO INTERCEPT Intercepts legacy get_custom_logo HTML output to supply fallback site logo.
filter_get_custom_logo_fallback(string $html[, int|null $blog_id = null ]) : string
Parameters
- $html : string
-
Existing custom logo HTML string.
- $blog_id : int|null = null
-
Optional blog ID context.
Return values
string —Filtered logo HTML string.
get_registered_image_size_dimensions()
Helper function to resolve pixel dimensions for standard or custom image sizes.
get_registered_image_size_dimensions(string|array<string|int, int> $size) : array{width: int, height: int}
Parameters
- $size : string|array<string|int, int>
-
Registered image size slug string or array of dimensions.
Return values
array{width: int, height: int} —Resolved width and height dimension array.
filter_legacy_post_thumbnail_html()
3. THE POST THUMBNAIL / FEATURED IMAGE INTERCEPT Intercepts post_thumbnail_html to output fallback featured images for posts missing thumbnails.
filter_legacy_post_thumbnail_html(string $html, int $pid, int $post_thumbnail_id, string|array<string|int, int> $size, array<string, mixed> $attr) : string
Parameters
- $html : string
-
Existing post thumbnail HTML output.
- $pid : int
-
Post ID context.
- $post_thumbnail_id : int
-
Attachment ID of the thumbnail.
- $size : string|array<string|int, int>
-
Requested image size slug or array.
- $attr : array<string, mixed>
-
Attributes array for the img tag.
Return values
string —Filtered post thumbnail HTML markup.
has_post_thumbnail_fallback()
4. FORCE TRUE FOR WRAPPERS CONSISTENCY Forces has_post_thumbnail to return true so theme wrappers always render fallback markup.
has_post_thumbnail_fallback(bool $has_thumbnail, WP_Post $post, int $thumbnail_id) : bool
Parameters
- $has_thumbnail : bool
-
Existing has_thumbnail check result.
- $post : WP_Post
-
Post object being evaluated.
- $thumbnail_id : int
-
Thumbnail attachment ID.
Return values
bool —Always true to enable fallback rendering.