bp_nouveau_customize_register( WP_Customize_Manager $wp_customize )

Add a specific panel for the BP Nouveau Template Pack.

Description

Parameters

$wp_customize

(Required) WordPress customizer.

Source

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

function bp_nouveau_customize_register( WP_Customize_Manager $wp_customize ) {
	if ( ! bp_is_root_blog() ) {
		return;
	}

	require_once( trailingslashit( bp_nouveau()->includes_dir ) . 'customizer-controls.php' );
	$wp_customize->register_control_type( 'BP_Nouveau_Nav_Customize_Control' );
	$bp_nouveau_options = bp_nouveau_get_appearance_settings();
	//@todo is the BuddyBoss Platform really translatable?
	$wp_customize->add_panel( 'bp_nouveau_panel', array(
		'description' => __( 'Customize the appearance of the BuddyBoss Platform.', 'buddyboss' ),
		'title'       => __( 'BuddyBoss Platform', 'buddyboss' ),
		'priority'    => 200,
	) );

	/**
	 * Filters the BuddyPress Nouveau customizer sections and their arguments.
	 *
	 * @since BuddyPress 3.0.0
	 *
	 * @param array $value Array of Customizer sections.
	 */
	$sections = apply_filters( 'bp_nouveau_customizer_sections', array(
		'bp_nouveau_user_primary_nav' => array(
			'title'       => __( 'Profile Navigation', 'buddyboss' ),
			'panel'       => 'bp_nouveau_panel',
			'priority'    => 50,
			'description' => __( 'Customize the navigation menu for member profiles. In the preview window, navigate to a user to preview your changes.', 'buddyboss' ),
		),
		'bp_nouveau_mail' => array(
			'title'       => __( 'BuddyBoss Emails', 'buddyboss' ),
			'panel'       => 'bp_nouveau_panel',
			'priority'    => 80,
			'description' => __( 'Customize the appearance of emails sent by BuddyBoss.', 'buddyboss' ),
		),
	) );

	// Add the sections to the customizer
	foreach ( $sections as $id_section => $section_args ) {
		$wp_customize->add_section( $id_section, $section_args );
	}

	/**
	 * Filters the BuddyPress Nouveau customizer settings and their arguments.
	 *
	 * @since BuddyPress 3.0.0
	 *
	 * @param array $value Array of Customizer settings.
	 */
	$settings = apply_filters( 'bp_nouveau_customizer_settings', array(
		'bp_nouveau_appearance[user_nav_display]' => array(
			'index'             => 'user_nav_display',
			'capability'        => 'bp_moderate',
			'sanitize_callback' => 'absint',
			'transport'         => 'refresh',
			'type'              => 'option',
		),
		'bp_nouveau_appearance[user_default_tab]' => array(
			'index'             => 'user_default_tab',
			'capability'        => 'bp_moderate',
			'transport'         => 'refresh',
			'type'              => 'option',
		),
		'bp_nouveau_appearance[user_nav_order]' => array(
			'index'             => 'user_nav_order',
			'capability'        => 'bp_moderate',
			'sanitize_callback' => 'bp_nouveau_sanitize_nav_order',
			'transport'         => 'refresh',
			'type'              => 'option',
		),
		'bp_nouveau_appearance[activity_dir_layout]' => array(
			'index'             => 'activity_dir_layout',
			'capability'        => 'bp_moderate',
			'sanitize_callback' => 'absint',
			'transport'         => 'refresh',
			'type'              => 'option',
		),
		'bp_nouveau_appearance[activity_dir_tabs]' => array(
			'index'             => 'activity_dir_tabs',
			'capability'        => 'bp_moderate',
			'sanitize_callback' => 'absint',
			'transport'         => 'refresh',
			'type'              => 'option',
		),
		'bp_nouveau_appearance[members_dir_layout]' => array(
			'index'             => 'members_dir_layout',
			'capability'        => 'bp_moderate',
			'sanitize_callback' => 'absint',
			'transport'         => 'refresh',
			'type'              => 'option',
		),
		'bp_nouveau_appearance[members_dir_tabs]' => array(
			'index'             => 'members_dir_tabs',
			'capability'        => 'bp_moderate',
			'sanitize_callback' => 'absint',
			'transport'         => 'refresh',
			'type'              => 'option',
		),
		'bp_nouveau_appearance[groups_dir_layout]' => array(
			'index'             => 'groups_dir_layout',
			'capability'        => 'bp_moderate',
			'sanitize_callback' => 'absint',
			'transport'         => 'refresh',
			'type'              => 'option',
		),
		'bp_nouveau_appearance[sites_dir_layout]' => array(
			'index'             => 'sites_dir_layout',
			'capability'        => 'bp_moderate',
			'sanitize_callback' => 'absint',
			'transport'         => 'refresh',
			'type'              => 'option',
		),
		'bp_nouveau_appearance[sites_dir_tabs]' => array(
			'index'             => 'sites_dir_tabs',
			'capability'        => 'bp_moderate',
			'sanitize_callback' => 'absint',
			'transport'         => 'refresh',
			'type'              => 'option',
		),
		'bp_nouveau_appearance[bp_emails]' => array(
			'index'             => 'bp_emails',
			'capability'        => 'bp_moderate',
			'sanitize_callback' => 'absint',
			'transport'         => 'refresh',
			'type'              => 'option',
		),
	) );

	// Add the settings
	foreach ( $settings as $id_setting => $setting_args ) {
		$args = array();

		if ( empty( $setting_args['index'] ) || ! isset( $bp_nouveau_options[ $setting_args['index'] ] ) ) {
			continue;
		}

		$args = array_merge( $setting_args, array( 'default' => $bp_nouveau_options[ $setting_args['index'] ] ) );

		$wp_customize->add_setting( $id_setting, $args );
	}

	// Default options for the users default tab.

	$options = array();
	if ( bp_is_active( 'xprofile' ) ) {
		$options['profile'] = __( 'Profile', 'buddyboss' );
	}
	if ( bp_is_active( 'activity' ) ) {
		$options['activity'] = __( 'Timeline', 'buddyboss' );
	}
	if ( bp_is_active( 'friends' ) ) {
		$options['friends'] = __( 'Connections', 'buddyboss' );
	}
	if ( bp_is_active( 'groups' ) ) {
		$options['groups'] = __( 'Groups', 'buddyboss' );
	}
	if ( bp_is_active( 'forums' ) ) {
		$options['forums'] = __( 'Forums', 'buddyboss' );
	}
	if ( bp_is_active( 'media' ) ) {
		$options['media'] = __( 'Photos', 'buddyboss' );
	}

	$controls = array(
		'user_nav_display' => array(
			'label'    => __( 'Display the profile navigation vertically.', 'buddyboss' ),
			'section'  => 'bp_nouveau_user_primary_nav',
			'settings' => 'bp_nouveau_appearance[user_nav_display]',
			'type'     => 'checkbox',
		),
		'user_default_tab' => array(
			'label'       => __( 'Profile navigation order', 'buddyboss' ),
			'description' => __( 'Set the default navigation tab when viewing a member profile. The dropdown only shows tabs that are available to all members.', 'buddyboss' ),
			'section'     => 'bp_nouveau_user_primary_nav',
			'settings'    => 'bp_nouveau_appearance[user_default_tab]',
			'type'        => 'select',
			'choices'     => apply_filters( 'user_default_tab_options_list', $options ),
		),
		'user_nav_order'   => array(
			'class'    => 'BP_Nouveau_Nav_Customize_Control',
			'label'    => __( 'Reorder the primary navigation for a member.', 'buddyboss' ),
			'section'  => 'bp_nouveau_user_primary_nav',
			'settings' => 'bp_nouveau_appearance[user_nav_order]',
			'type'     => 'user',
		),
		'mail_layout'      => array(
			'section'  => 'bp_nouveau_mail',
			'settings' => 'bp_nouveau_appearance[bp_emails]',
		),
	);

	/**
	 * Filters the BuddyPress Nouveau customizer controls and their arguments.
	 *
	 * @since BuddyPress 3.0.0
	 *
	 * @param array $value Array of Customizer controls.
	 */
	$controls = apply_filters( 'bp_nouveau_customizer_controls', $controls );

	// Add the controls to the customizer's section
	foreach ( $controls as $id_control => $control_args ) {
		if ( empty( $control_args['class'] ) ) {
			$wp_customize->add_control( $id_control, $control_args );
		} else {
			$wp_customize->add_control( new $control_args['class']( $wp_customize, $id_control, $control_args ) );
		}
	}
}

Changelog

Changelog
Version Description
BuddyPress 3.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.