Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Custom Hooks

Paul Taylor edited this page Nov 23, 2018 · 10 revisions

Actions

benenson_after_body_open_tag

This hook is called straight after the opening <body> within Benenson's header.php file.

Example
<?php
add_action( 'benenson_after_body_open_tag', function() {
	// ...
} );
?>

Filters

benenson_mobile_nav_attrs

Filters the HTML attributes applied to a menu item's anchor element.

Arguments
  • array $attrs Array of attributes to be added to the navigation <a> tag.
  • WP_Post $item Menu item data object.
  • stdClass $args An object of wp_nav_menu() arguments.
  • integer $depth Depth of menu item. Used for padding.
Example
<?php
add_filter( 'benenson_mobile_nav_attrs' function( $attrs, $item, $args, $depth ) {
	// ...
} );
?>

benenson_kses_allowed_html

Sets which elements and attributes are allowed by wp_kses_post.

Arguments
  • array $allowed Array of allowed html and attributes.
Example
<?php
add_filter( 'benenson_kses_allowed_html' function( $allowed ) {
	$allowed['section']['aria-label'] = true;
	$allowed['section']['role']       = true;
	
	return $allowed;
} );
?>

benenson_add_a11y_to_tables

Sets whether accessibility role attributes should be added to tables within post content.

Arguments
  • boolean $apply Whether attributes should be added.
Example
<?php add_filter( 'benenson_add_a11y_to_tables' '__return_true' ); ?>

benenson_add_async_handlers

Adds async to scripts with one of the provided script handle names as defined by their wp_enqueue/register_script handler.

Arguments
  • array $handlers List of handlers to add async to.
Example
<?php
add_filter( 'benenson_add_async_handlers', function( $handlers ) {
	$handlers[] = 'my-async-script';
	
	return $handlers;
} );
?>

benenson_option_{$name}

Allows for filtering of a Benenson theme option.

See list of available theme options

Arguments
  • mixed $option Value of the given option.
  • mixed $default Default value of the given option.
  • string $name Name of the given option.
Example
<?php
add_filter( 'benenson_option__logo', function( $option ) {
	if ( empty( $option ) ) {
		return 'my-logo.png';
	}
	
	return $option;
} );
?>

benenson_disable_emoji

Allows for disabling of emojis on the site.

Arguments
  • boolean $disable Whether to disable emojis.
Example
<?php add_filter( 'benenson_disable_emoji' '__return_true' ); ?>
Clone this wiki locally