Jump to Navigation Jump to Main Content Jump to Footer
Home » Docs » Features » Custom action and filter hooks

Custom action and filter hooks

Chisel exposes a set of filters (and relies on some WP/WC core filters) to customize assets, blocks rendering, CPT/Taxonomy registration, AJAX, and more. Locations are given for reference.

Assets: registration and enqueueing (inc/WP/Assets.php)

  • chisel_frontend_styles, chisel_frontend_scripts, chisel_frontend_footer_styles
    Purpose: Modify arrays of assets before registration/enqueue on frontend.
    Args: (array $scripts).
    Example:
add_filter('chisel_frontend_scripts', function ( array $scripts ) {
  $scripts['my-custom-script'] = array();
  
  return $scripts;
});
PHP
  • chisel_admin_styles, chisel_admin_scripts, chisel_editor_styles, chisel_editor_scripts, chisel_login_styles, chisel_login_scripts
    Purpose: Modify asset maps for admin/editor/login contexts.
    Args: (array $scripts).
  • chisel_pre_enqueue_frontend_styles, chisel_pre_enqueue_frontend_scripts
    Purpose: Final chance to adjust assets right before enqueue.
    Args: (array $scripts).
  • chisel_enqueue_frontend_style, chisel_enqueue_frontend_script
    Purpose: Per-handle decision to enqueue.
    Args: (bool $enqueue, string $handle, array $args).
    Example:
add_filter('chisel_enqueue_frontend_script', function ( bool $enqueue, string $handle, array $args ) {
  if ( $handle === 'app' && is_page_template( 'templates/landing.php' ) ) { 
	  return false;
	}
	
  return $enqueue;
}, 10, 2);
PHP
  • Also available for other contexts:
    Pre-enqueue: chisel_pre_enqueue_frontend_footer_styles, chisel_pre_enqueue_admin_styles, chisel_pre_enqueue_admin_scripts, chisel_pre_enqueue_editor_styles, chisel_pre_enqueue_editor_scripts, chisel_pre_enqueue_login_styles, chisel_pre_enqueue_login_scripts
    Per-handle: chisel_enqueue_frontend_footer_style, chisel_enqueue_admin_style, chisel_enqueue_admin_script, chisel_enqueue_editor_style, chisel_enqueue_editor_script, chisel_enqueue_login_style, chisel_enqueue_login_script

Blocks: ACF render context and registration

  • chisel_timber_acf_blocks_data (inc/Helper/BlocksHelpers.php)
    Purpose: Modify the Twig context for ACF blocks (global).
    Args: (array $context).
    Example:
add_filter('chisel_timber_acf_blocks_data', function ( array $context ) {
  $context ['env'] = wp_get_environment_type();
  return $context ;
});
PHP
  • chisel_timber_acf_blocks_data_{block_slug}, chisel_timber_acf_blocks_data_{block_id} (inc/Helper/BlocksHelpers.php) Purpose: Block‑specific or instance‑specific context modifications. Args: (array $context).
  • chisel_blocks_register_scripts (inc/Factory/RegisterBlocks.php) Purpose: Enable/disable auto block script registration. Args: (bool $register, string $blocks_type).
  • chisel_block_register_script_args (inc/Factory/RegisterBlocks.php) Purpose: Tweak per-block script registration args (e.g., strategy/deps). Args: (array $args).

Theme structure: supports, menus, sidebars

  • chisel_post_thumbnails_post_types (inc/WP/Theme.php)
    Purpose: Which post types support thumbnails.
    Args: (array $post_types).
  • chisel_nav_menus (inc/WP/Theme.php)
    Purpose: Register additional nav menus or tweak names.
    Args: (array $menus).
    Example:
add_filter('chisel_nav_menus', function ($menus) {
  $menus['footer_secondary'] = __('Footer Secondary', 'chisel');
  return $menus;
});
PHP
  • chisel_sidebars (inc/WP/Sidebars.php)
    Purpose: Register sidebars/widgets.
    Args: (array $sidebars).

CPTs and taxonomies

  • chisel_default_post_type_supports, chisel_default_post_type_rewrite_args (inc/WP/CustomPostTypes.php)
    Purpose: Global defaults for CPT supports/rewrite.
    Args: (array).
  • chisel_custom_post_types (inc/WP/CustomPostTypes.php)
    Purpose: Provide CPT registrations programmatically.
    Args: (array $post_types).
  • chisel_default_taxonomy_capabilities, chisel_default_taxonomy_rewrite_args (inc/WP/CustomTaxonomies.php)
    Purpose: Global defaults for taxonomy capabilities/rewrite.
    Args: (array).
  • chisel_custom_taxonomies (inc/WP/CustomTaxonomies.php)
    Purpose: Provide taxonomy registrations programmatically.
    Args: (array $taxonomies).
  • Per‑type refinement in factories: chisel_default_post_type_supports{post_type}__, chisel_default_post_type_rewrite_args{post_type} (inc/Factory/RegisterCustomPostType.php) chisel_default_taxonomy_capabilities{taxonomy}__, chisel_default_taxonomy_rewrite_args{taxonomy} (inc/Factory/RegisterCustomTaxonomy.php)

ACF options pages

  • chisel_acf_options_pages, chisel_acf_options_sub_pages (inc/WP/Acf.php)
    Purpose: Define ACF options pages/subpages.
    Args: (array).

Blocks (global behavior)

  • chisel_styles_inline_size_limit (inc/WP/Blocks.php)
    Purpose: Max CSS size to inline for blocks.
    Args: (int $limit).
  • chisel_load_separate_core_block_assets (inc/WP/Blocks.php)
    Purpose: Whether to load separate core block assets.
    Args: (bool $load).

Caching

  • chisel_cache_expiry, chisel_cache_everything, chisel_environment_cache (inc/WP/Cache.php)
    Purpose: Control Timber/Twig caching behavior.
    Args: (int|string $expiry), (bool $all), (bool $env_cache).

AJAX (REST)

  • chisel_ajax_routes (inc/Controllers/AjaxController.php)
    Purpose: Register custom REST endpoints under chisel/v2/ajax.
    Args: (array $routes).
    Example:
add_filter('chisel_ajax_routes', function ($routes) {
  $routes['my-custom-action'] = array( 'methods' => 'POST' );

  return $routes;
});
PHP
  • chisel_ajax_permissions_check (inc/Controllers/AjaxController.php)
    Purpose: Override per‑request permission (nonce + custom logic).
    Args: (bool $permission, string $callback_name, WP_REST_Request $request).

WooCommerce integration

  • chisel_woocommerce_upsell_display, chisel_woocommerce_output_related_products (woocommerce.php)
    Purpose: Toggle upsells/related products for single product context.
    Args: (bool).
  • WC core filters used by wrappers: single_product_archive_thumbnail_size, subcategory_archive_thumbnail_size ( inc/WP/ChiselProduct*.php).

Theme helpers

  • chisel{type}colors_palette (inc/Helper/ThemeHelpers.php)
    Purpose: Modify color palettes derived from theme.json.
    Args: (array $palette), type is dynamic (e.g., ‘acf’, ‘tinymce’).

Notes and tips

  • Scoping: Many filters accept full config arrays; prefer small, well‑scoped adjustments via per‑handle enqueue filters when possible.
  • Order: Use default priority (10) unless chaining with other plugins; increase/decrease as needed.
  • Performance: Avoid heavy logic inside filters that run on every request (e.g., enqueue decisions).

Do you like Chisel?

Give it a star on GitHub!