bp_nouveau_wrapper( array $args = array() )

Output HTML content into a wrapper.


Parameters Parameters

$args

(array) (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()


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 based on the component ID to add.
	 * We need to to this because bp_current_component() is using the component slugs which can differ
	 * from the component ID.
	 */
	$current_component_id = bp_core_get_active_components( array( 'slug' => bp_current_component() ) );
	if ( $current_component_id && 1 === count( $current_component_id ) ) {
		$current_component_id = reset( $current_component_id );
	} else {
		$current_component_id = bp_current_component();
	}

	$current_component_class = $current_component_id . '-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.