bp_nouveau_wrapper( array $args = array() )

Output HTML content into a wrapper.


Description Description


Parameters Parameters

$args

(Optional) Optional arguments.

  • 'container'
    (string) String HTML container type that should wrap the items as a group: 'div', 'ul', or 'p'. Required.
  • 'container_id'
    (string) The group wrapping container element ID
  • 'container_classes'
    (string) The group wrapping container elements class
  • 'output'
    (string) The HTML to output. Required.

Default value: array()


Top ↑

Source Source

File: bp-templates/bp-nouveau/includes/functions.php

function bp_nouveau_wrapper( $args = array() ) {
 /**
	* Classes need to be determined & set by component to a certain degree
	*
	* Check the component to find a default container_class to add
	*/
	$current_component_class = bp_current_component() . '-meta';

	if ( bp_is_group_activity() ) {
		$generic_class = ' activity-meta ';
	} else {
		$generic_class = '';
	}

	$r = bp_parse_args(
		$args,
		array(
			'container'         => 'div',
			'container_id'      => '',
			'container_classes' => array( $generic_class, $current_component_class   ),
			'output'            => '',
		),
		'nouveau_wrapper'
	);

	$valid_containers = array(
		'div'  => true,
		'ul'   => true,
		'ol'   => true,
		'span' => true,
		'p'    => true,
	);

	// Actually merge some classes defaults and $args
	// @todo This is temp, we need certain classes but maybe improve this approach.
	$default_classes        = array( 'action' );
	$r['container_classes'] = array_merge( $r['container_classes'], $default_classes );

	if ( empty( $r['container'] ) || ! isset( $valid_containers[ $r['container'] ] ) || empty( $r['output'] ) ) {
		return;
	}

	$container         = $r['container'];
	$container_id      = '';
	$container_classes = '';
	$output            = $r['output'];

	if ( ! empty( $r['container_id'] ) ) {
		$container_id = ' id="' . esc_attr( $r['container_id'] ) . '"';
	}

	if ( ! empty( $r['container_classes'] ) && is_array( $r['container_classes'] ) ) {
		$container_classes = ' class="' . join( ' ', array_map( 'sanitize_html_class', $r['container_classes'] ) ) . '"';
	}

	// Print the wrapper and its content.
	printf( '<%1$s%2$s%3$s>%4$s</%1$s>', $container, $container_id, $container_classes, $output );
}

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.