query_vars['colibri_data'] = new Tree( $data );
if ( file_exists( $path ) ) {
load_template( $path );
} else {
$file_path = "{$path}.php";
if ( locate_template( $file_path, false ) ) {
get_template_part( $path );
} else {
$resolved = false;
if ( $try_to_locate_in_base ) {
$base_path = Theme::resolveThemeBaseTemplateRelativePath( $path );
$base_file_php = "{$base_path}.php";
$base_file_abs_path = locate_template( $base_file_php, false );
if ( $base_file_abs_path ) {
$resolved = true;
get_template_part( $base_path );
}
}
if ( ! $resolved ) {
get_template_part( $path );
}
}
}
$wp_query->query_vars['colibri_data'] = null;
}
public static function getData( $path, $default = null ) {
global $wp_query;
$colibri_data = $wp_query->query_vars['colibri_data'];
if ( $colibri_data ) {
/** @var Tree $colibri_data */
return $colibri_data->findAt( $path, $default );
}
return $default;
}
public static function isFrontPage() {
return is_front_page();
}
public static function printMenu( $attrs, $walker = '' ) {
$attrs = array_merge(
array(
'id' => null,
'classes' => '',
),
$attrs
);
$theme_location = $attrs['id'];
$customClasses = $attrs['classes'];
$drop_down_menu_classes = array( 'colibri-menu' );
$drop_down_menu_classes = array_merge( $drop_down_menu_classes, array( $customClasses ) );
if ( static::emptyMenu( $theme_location ) ) {
echo 'No menu items';
return;
}
wp_nav_menu(
array(
'theme_location' => $theme_location,
'menu_class' => esc_attr( implode( ' ', $drop_down_menu_classes ) ),
'container_class' => 'colibri-menu-container',
'fallback_cb' => function () use ( $attrs ) {
static::menuFallback( $attrs );
},
'walker' => $walker,
)
);
}
private static function emptyMenu( $theme_location ) {
$theme_locations = get_nav_menu_locations();
$menu_id = 0;
if ( array_key_exists( $theme_location, $theme_locations ) ) {
$menu_id = $theme_locations[ $theme_location ];
}
$menu_items = wp_get_nav_menu_items( $menu_id );
if ( $menu_items && count( $menu_items ) === 0 ) {
return true;
}
}
public static function menuFallback( $attrs, $walker = '' ) {
$customClasses = $attrs['classes'];
$drop_down_menu_classes = array( 'colibri-menu' );
$drop_down_menu_classes = array_merge( $drop_down_menu_classes, array( $customClasses ) );
return wp_page_menu(
array(
'menu_class' => 'colibri-menu-container',
'before' => '
',
'walker' => $walker,
)
);
}
public static function printContentWrapperAttrs( $classes = array() ) {
$classes = is_array( $classes ) ? $classes : array( $classes );
$classes = array_merge( array( 'gridContainer', 'content' ), $classes );
$classes = Hooks::prefixed_apply_filters( 'content_wrapper_class', $classes );
$classes = array_unique( $classes );
printf( ' class="%s" ', esc_attr( implode( ' ', $classes ) ) );
}
public static function printEntryThumb( $classes = '' ) {
$placeholder_color = '#333';
?>
$classes,
)
);
} else {
?>
array(),
'outer_class' => array(),
),
$args
);
$outer_classes = array_merge(
array(
'h-row-container',
),
$args['outer_class']
);
$inner_classes = array_merge(
array(
'h-row',
),
$args['inner_class']
);
static::printTwoLevelsDivStart( $outer_classes, $inner_classes );
}
private static function printTwoLevelsDivStart( $outer_classes = array(), $inner_classes = array() ) {
$outer_classes = implode( ' ', $outer_classes );
$inner_classes = implode( ' ', $inner_classes );
static::printElementStart( 'div', array( 'class' => $outer_classes ) );
static::printElementStart( 'div', array( 'class' => $inner_classes ) );
}
public static function printElementStart( $tag, $attrs = array() ) {
$key_value_attrs = array();
foreach ( $attrs as $key => $value ) {
if ( is_array( $value ) ) {
$value = implode( ' ', array_unique( $value ) );
}
$value = esc_attr( $value );
$key = sanitize_key( $key );
$key_value_attrs[] = "{$key}='{$value}'";
}
$attrs_string = implode( ' ', $key_value_attrs );
echo "<{$tag} {$attrs_string}>";
}
public static function printRowEnd() {
static::printTwoLevelsDivEnd();
}
private static function printTwoLevelsDivEnd() {
self::printElementEnd( 'div' );
self::printElementEnd( 'div' );
}
public static function printElementEnd( $tag ) {
echo "{$tag}>";
}
public static function printSectionStart( $args = array() ) {
$args = array_merge(
array(
'inner_class' => array(),
'outer_class' => array(),
),
$args
);
$outer_classes = array_merge(
array(
'd-flex',
'h-section',
'h-section-global-spacing',
'position-relative',
),
(array) $args['outer_class']
);
$inner_classes = array_merge(
array(
'h-section-grid-container',
),
(array) $args['inner_class']
);
static::printTwoLevelsDivStart( $outer_classes, $inner_classes );
}
public static function printSectionEnd() {
static::printTwoLevelsDivEnd();
}
public static function printContentStart( $args = array() ) {
$class = Utils::pathGet( $args, 'class', array() );
$class = array_merge( array( 'content', ' position-relative' ), $class );
$args['class'] = $class;
$args['id'] = Utils::pathGet( $args, 'id', 'content' );
self::printElementStart( 'div', $args );
}
public static function printContentEnd() {
static::printElementEnd( 'div' );
}
public static function printColumnStart( $args = array() ) {
$class = Utils::pathGet( $args, 'class', array() );
$class = array_merge( array( 'h-col' ), $class );
$args['class'] = $class;
self::printElementStart( 'div', $args );
}
public static function printColumnEnd() {
static::printElementEnd( 'div' );
}
/**
* @param string $wrapper
* @param callable $to_print
* @param array $args
*/
public static function printIn( $wrapper, $to_print, $args = array() ) {
$wrapper = ucfirst( strtolower( $wrapper ) );
$wrapper_fn_start = "print{$wrapper}Start";
$wrapper_fn_end = "print{$wrapper}End";
if ( method_exists( self::class, "{$wrapper_fn_start}" ) ) {
if ( method_exists( self::class, "{$wrapper_fn_end}" ) ) {
echo "\n";
call_user_func( array( self::class, $wrapper_fn_start ), $args );
call_user_func( $to_print );
call_user_func( array( self::class, $wrapper_fn_end ), $args );
echo "\n";
}
}
}
public static function printSkipToContent() {
?>