bp_core_admin_help_sub_menu( $directories,  $times,  $docs_path,  $level_hide = 1,  $show_as_heading = false,  $hide_parent = false )

Display Sub menu of Main Menu

Description

Parameters

$directories

(Required)

$times

(Required)

$docs_path

(Required)

Source

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

function bp_core_admin_help_sub_menu( $directories, $times, $docs_path, $level_hide = 1, $show_as_heading = false, $hide_parent = false ) {
	$article      = bp_core_admin_help_get_article_value();
	$article_path = $docs_path . $article;

	if ( empty( $show_as_heading ) ) {
		$ul_classed = $times > $level_hide ? 'hidden' : '';
		$ul_classed .= ' loop-' . $times;
		?>
        <ul class="<?php echo $ul_classed; ?> ">
		<?php
	}


	do_action( 'bp_core_admin_help_sub_menu_before', $directories, $times, $docs_path, $level_hide, $show_as_heading, $hide_parent );

	// For showing the menu title
	foreach ( $directories as $directory ) {
		$dir_pos = false !== strpos( $article_path, $directory ) ? true : false;

		// use in breadcrumb
		if ( empty( $dir_pos ) && ! empty( $show_as_heading ) ) {
			continue;
		}

		// add class to menu and sub menu level
		$slug = bp_core_get_post_slug_by_index( $directory );

		$dir_index_file = $directory;
		$is_dir         = is_dir( $directory );
		if ( $is_dir ) {
			// the the main file from the directory
			$dir_index_file = glob( $directory . "/0-*.md" );
			$loop_dir       = array_diff( glob( $directory . '/*' ), $dir_index_file );

			$dir_index_file = current( $dir_index_file );
			$url            = add_query_arg( 'article', str_replace( $docs_path, "", $dir_index_file ) );
		}

		// check condition on file deleted
		$file_delete = false !== strpos( $dir_index_file, 'delete-' ) ? true : false;
		if ( ! empty( $file_delete ) ) {
			continue;
		}

		$selected = $dir_index_file == $article_path ? 'selected main' : 'main';
		$selected .= ' level-' . $times . ' ' . $slug;
		?>
    <li class="<?php echo $selected; ?>">
		<?php
		// check if it's has directory
		if ( $is_dir ) {
			if ( ! empty( $loop_dir ) ) {

				/**
				 * Count variable is getting updated via JS
				 */
				$count_html = sprintf( '<span class="sub-menu-count">(%s)</span>', 0 );

				$action = '<span class="actions"><span class="open">+</span></span>';

				if ( ( $article && 1 == $times ) || ! empty( $show_as_heading ) ) {
					$action     = '';
					$count_html = '';
				}

				if ( empty( $hide_parent ) && ! empty( $dir_index_file ) ) {
					printf( '<a href="%s" class="dir">%s %s</a>%s', $url, bp_core_admin_help_get_file_title( $dir_index_file ), $count_html, $action );
				}
				if ( ! empty( $show_as_heading ) ) {
					?>
                    </li>
					<?php
				}
				bp_core_admin_help_sub_menu( $loop_dir, $times + 1, $docs_path, $level_hide, $show_as_heading );
			} else if ( empty( $hide_parent ) ) {
				printf( '<a href="%s" class="dir">%s</a>', $url, bp_core_admin_help_get_file_title( $dir_index_file ) );
			}
		} elseif ( empty( $hide_parent ) ) {
			$url = add_query_arg( 'article', str_replace( $docs_path, "", $directory ) );
			// print the title if it's a .md file
			printf( '<a href="%s" class="file">%s</a>', $url, bp_core_admin_help_get_file_title( $directory ) );
		}
		?>
        </li>
		<?php
	}

	do_action( 'bp_core_admin_help_sub_menu_after', $directories, $times, $docs_path, $level_hide, $show_as_heading, $hide_parent );

	if ( empty( $show_as_heading ) ) {
		?>
        </ul>
		<?php
	}
}

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.