bp_admin_setting_callback_page_directory_dropdown( $args )

Pages drop downs callback

Description

Parameters

$args

(Required)

Source

File: bp-core/admin/bp-core-admin-pages.php

function bp_admin_setting_callback_page_directory_dropdown( $args ) {
	extract( $args );

	if ( ! bp_is_root_blog() ) {
		switch_to_blog( bp_get_root_blog_id() );
	}

	// For the button
	if ( 'button' === $name ) {

	    printf( '<p><a href="%s" class="button">%s</a> </p>', $args['label']['link'], $args['label']['label'] );
		// For the forums will set the page selected from the custom option `_bbp_root_slug_custom_slug`
	} elseif ( 'new_forums_page' === $name ) {

		// Get the page id from the options.
		$id = (int) bp_get_option( '_bbp_root_slug_custom_slug' );

		// Check the status of current set value.
		$status = get_post_status( $id );

		// Set the page id if page exists and in publish otherwise set blank.
		$id = ( '' !== $status && 'publish' === $status ) ? $id : '';

		echo wp_dropdown_pages( array(
			'name'             => 'bp_pages[' . esc_attr( $name ) . ']',
			'echo'             => false,
			'show_option_none' => __( '- Select a page -', 'buddyboss' ),
			'selected'         => ! empty( $id ) ? $id : false
		) );

		if ( ! empty( $id ) ) {
			printf( '<a href="%s" class="button-secondary" target="_bp">%s</a>',
				get_permalink( $id ),
				__( 'View', 'buddyboss' ) );
		} else {
			printf( '<a href="%s" class="button-secondary create-background-page" data-name="%s" target="_bp">%s</a>',
				'javascript:void(0);', esc_attr( $name ),
				__( 'Create Page', 'buddyboss' ) );
		}

		if ( '' !== $description ) {
			printf(
				'<p class="description">%s</p>',
				$description
			);
		}

		// For the normal directory pages.
	} else {

		echo wp_dropdown_pages( array(
			'name'             => 'bp_pages[' . esc_attr( $name ) . ']',
			'echo'             => false,
			'show_option_none' => __( '- Select a page -', 'buddyboss' ),
			'selected'         => ! empty( $existing_pages[ $name ] ) ? $existing_pages[ $name ] : false
		) );

		if ( ! empty( $existing_pages[ $name ] ) ) {
			printf( '<a href="%s" class="button-secondary" target="_bp">%s</a>',
				get_permalink( $existing_pages[ $name ] ),
				__( 'View', 'buddyboss' ) );
		} else {
			printf( '<a href="%s" class="button-secondary create-background-page" data-name="%s" target="_bp">%s</a>',
				'javascript:void(0);', esc_attr( $name ),
				__( 'Create Page', 'buddyboss' ) );
		}

		if ( '' !== $description ) {
			printf( '<p class="description">%s</p>', $description );
		}

	}

	if ( ! bp_is_root_blog() ) {
		restore_current_blog();
	}
}

Changelog

Changelog
Version Description
BuddyBoss 1.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.