beans_register_widget_area

Register a widget area.

Since a Beans widget area is using the WordPress sidebar, this function registers a WordPress sidebar using register_sidebar(), with additional arguments.

Note that the ‘class’, before_widget’, ‘after_widget’, ‘before_title’ and ‘after_title’ arguments are not supported. Beans widgets are built using the Beans HTML API which allows full control over HTML markup and attributes.

When allowing for automatic generation of the name and ID parameters, keep in mind that the incrementor for your widget area can change over time depending on what other plugins and themes are installed.

beans_register_widget_area( array $args = array(), $widget_control = array() )

Return: (string) The widget area ID is added to the $wp_registered_sidebars globals when the widget area is setup.

Parameters

NameTypeRequiredDefaultDescription
$argsView Arrayarraytruearray()Optional. Arguments used by the widget area.

Using $args parameter array:

Array Key Type Default Description
'id'string-Optional. The unique identifier by which the widget area will be called.
'name'string-Optional. The name or title of the widget area displayed in the admin dashboard.
'description'string-Optional. The widget area description.
'beans_type'stringstack.Optional. The widget area type. Accepts 'stack', 'grid' or 'offcanvas'.
'beans_show_widget_title'booltrue.Optional. Whether to show the widget title or not.
'beans_show_widget_badge'boolfalse.Optional. Whether to show the widget badge or not.
'beans_widget_badge_content'bool'Hello'Optional. The badge content. This may contain widget shortcodes beans_widget_shortcodes().

Source

function beans_register_widget_area( $args = array(), $widget_control = array() ) {

	// Stop here if the id isn't set.
	if ( ! $id = beans_get( 'id', $args ) ) {
		return;
	}

	/**
	 * Filter the default arguments used by the widget area.
	 *
	 * @since 1.0.0
	 */
	$defaults = apply_filters( 'beans_widgets_area_default_args', array(
		'beans_type'                 => 'stack',
		'beans_show_widget_title'    => true,
		'beans_show_widget_badge'    => false,
		'beans_widget_badge_content' => __( 'Hello', 'tm-beans' ),
	) );

	/**
	 * Filter the arguments used by the widget area.
	 *
	 * The dynamic portion of the hook name, $id, refers to the widget area id.
	 *
	 * @since 1.0.0
	 */
	$args = beans_apply_filters( "beans_widgets_area_args[_{$id}]", array_merge( $defaults, $args ) );

	return register_sidebar( $args );

}