bh_current_section( $p = null,  $depth,  $current = true )


Description


Source

File: functions/common/resources.php

	function bh_current_section( &$p = null, $depth = 0, $current = true ) {
		if ( is_object( $p ) && ! empty( $p->_current_section ) ) {
			return $p->_current_section;
		}
		$path = bh_get_page_path( $p, $current );
		if ( defined( 'DEBUG_PATHS' ) && DEBUG_PATHS ) {
			do_action( 'log', 'current_section: Current path', $path );
		}
		$parts = explode( '/', $path );
		$parts = array_values( array_filter( $parts ) );

		if ( defined( 'DEBUG_PATHS' ) && DEBUG_PATHS ) {
			do_action( 'log', 'current_section: path parts', $parts );
		}

		if ( count( $parts ) <= $depth ) {
			$depth = count( $parts );
		}
		if ( defined( 'DEBUG_PATHS' ) && DEBUG_PATHS ) {
			do_action( 'log', 'current_section: depth', $depth );
		}
		if ( -1 >= $depth || ! isset( $parts[ $depth ] ) ) {
			$section = 'home';
		} else {
			$section = $parts[ $depth ];
		}

		$section2 = apply_filters( 'bh_post_section', $section, $p );
		if ( defined( 'DEBUG_PATHS' ) && DEBUG_PATHS ) {
			do_action( 'log', 'current_section: Page section', $path, $section, $section2 );
		}
		if ( is_object( $p ) ) {
			$p->_current_section = $section2;
		}
		return $section2;
	}


User Contributed Notes

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