Skip to content

Hooks & Internationalization

Extension points (filters and actions) you can use to customise Styble Pro, plus how the plugin handles translation.

This page lists the developer-facing hooks Styble Pro exposes and explains its internationalization setup. Hook names below are verified against the source; signatures follow the standard WordPress add_filter / add_action patterns.

Internationalization

Styble Pro uses the text domain styble-pro throughout, on both the PHP and JavaScript sides.

Text domain loading

Block_Init::load_text_domain() (blocks/Block_Init.php) loads translations from the languages/ directory on the init hook:

php
public function load_text_domain() {
	load_plugin_textdomain(
		'styble-pro',
		false,
		dirname( plugin_basename( SP_STYBLE_FILE ) ) . '/languages/'
	);
}

Writing translatable strings

  • PHP: wrap user-facing strings in __(), _e(), esc_html__(), etc., always with the styble-pro domain:

    php
    esc_html__( 'Session expired. Please reload the page.', 'styble-pro' );
  • JavaScript / JSX: import from @wordpress/i18n and pass the same domain:

    js
    import { __ } from '@wordpress/i18n';
    title: __( 'My Custom Block', 'styble-pro' ),

Lint enforcement

ESLint (WordPress preset) enforces the text domain via the @wordpress/i18n-text-domain rule, so a missing or wrong domain in JS is caught by npm run lint. See Build & Assets.

Translation files live in blocks/languages/ (the path passed to load_plugin_textdomain).

Block rendering hooks

Dynamic blocks are rendered through AbstractBlock::render_block_callback() (blocks/Includes/AbstractBlock.php), which wraps each block's render_block() with filters and actions.

styble_pro_attributes (filter)

Filters a block's attributes at render time, just before the block is rendered.

php
add_filter( 'styble_pro_attributes', function ( $attributes, $block_name ) {
	// Adjust $attributes for $block_name at render time.
	return $attributes;
}, 10, 2 );

styble_pro_before_render / styble_pro_after_render (actions)

Fire immediately before and after a Styble block's frontend render.

php
// Before render: $block_name, $attributes, $content, $block
add_action( 'styble_pro_before_render', function ( $block_name, $attributes, $content, $block ) {
	// …
}, 10, 4 );

// After render: $block_name, $attributes, $output, $block
add_action( 'styble_pro_after_render', function ( $block_name, $attributes, $output, $block ) {
	// …
}, 10, 4 );

Attribute hooks

styble_block_attributes (filter)

Filters the merged attribute definitions during registration in AbstractBlock::load_attributes(). Use it to add or modify a block's attributes. Full example in the Attributes guide.

php
add_filter( 'styble_block_attributes', function ( $attributes, $block_name ) {
	return $attributes;
}, 10, 2 );

Query hooks

styble_pro_query_args (filter)

Filters the final WP_Query arguments built by PostQueryHandler::query() before the query runs.

php
add_filter( 'styble_pro_query_args', function ( $args, $block_name, $query_data ) {
	// Adjust $args, e.g. restrict post status or add a meta_query.
	return $args;
}, 10, 3 );

See Query & AJAX for the surrounding flow.

Selected feature filters

Beyond the core block hooks above, several subsystems expose their own filters. A non-exhaustive list:

FilterArea
styble_advanced_settings_defaults, styble_advanced_tab_optionsAdvanced settings / Advanced tab.
styble_performance_tab_optionsPerformance settings.
styble_dynamic_content_data_sources, styble_dynamic_content_post_fields, styble_dynamic_content_link_fields, styble_dynamic_content_featured_image_fields, styble_dynamic_content_resolved_textDynamic Content tokens & resolution.
styble_lightbox_fancybox_optionsLightbox (Fancybox) configuration.
styble_no_thumb_placeholderFallback thumbnail.
styble_google_fonts_cdn_urlGoogle Fonts source URL.
styble_dashboard_modules_list, styble_dashboard_settings_for_js, styble_dashboard_social_links (and other styble_dashboard_*)Admin dashboard.
styble_design_library_enabledPrebuilt design library.

These follow the standard add_filter( 'name', $callback, $priority, $args ) pattern.

Released under the GPL-2.0-or-later License.