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

Custom Hooks

Jon McPartland edited this page Jan 10, 2019 · 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' ); ?>

benenson_menu_link_attributes_ids

Provides a list of menu IDs have classes applied to within menu item links.

Arguments
  • array $menu_ids List of menu_ids that should have class applied to.
Example
<?php
add_filter( 'benenson_menu_link_attributes_ids' function( $menu_ids ) {
	return [
		'my-menu-id',
		'category-menu',
        ];
} );
?>

benenson_polyfill_js

Sets whether JavaScript polyfills should be included and applied.

Arguments
  • boolean $apply Whether polyfills should be applied.
Example
<?php add_filter( 'benenson_polyfill_js' '__return_true' ); ?>

benenson_bugsnag_development_domains

Provides a list of domains that are part of the development stage. If BugSnag is enabled when an error occurs on a matching domain, stage will be set to development.

Arguments
  • array $domains List of domains or tlds that are part of the development stage.
Example
<?php add_filter( 'benenson_bugsnag_development_domains' [ 'my-website.site' ] ); ?>

benenson_bugsnag_staging_domains

Provides a list of domains that are part of the staging stage. If BugSnag is enabled when an error occurs on a matching domain, stage will be set to staging.

Arguments
  • array $domains List of domains or tlds that are part of the staging stage.
Example
<?php add_filter( 'benenson_bugsnag_staging_domains' [ 'staging.my-site.com' ] ); ?>

benenson_disable_rest_api

Sets whether to disable the REST API for users that are not logged in.

Arguments
  • boolean $disabled Whether to disable the REST API.
Example
<?php add_filter( 'benenson_disable_rest_api' '__return_true' ); ?>

benenson_disable_rest_api_json_error

Sets whether the disabled REST API should respond with a JSON error. If set to false, a 300 redirection will occur.

Arguments
  • boolean $show_error Whether to display a JSON error.
Example
<?php add_filter( 'benenson_disable_rest_api_json_error' '__return_true' ); ?>

benenson_display_author

Enables/disables author information visibility in single.php.

Arguments
  • boolean $show_author Whether to display the author name. Default false.
Example
<?php add_filter( 'benenson_display_author', '__return_true' ); ?>