top-bar.php (3284B)
1 <?php 2 3 materialis_require("/inc/header-options/navigation-options/top-bar/content-areas.php"); 4 5 function materialis_customize_register_options_add_top_bar_options_group() 6 { 7 materialis_add_options_group(array( 8 "materialis_top_bar_options" => array( 9 // section 10 "navigation_top_bar", 11 ), 12 )); 13 } 14 15 add_action("materialis_customize_register_options", 'materialis_customize_register_options_add_top_bar_options_group'); 16 17 function materialis_top_bar_options($section) 18 { 19 materialis_add_kirki_field(array( 20 'type' => 'sectionseparator', 21 'label' => esc_html__('Top Bar Display', 'materialis'), 22 'section' => $section, 23 'settings' => "top_bar_display_separator", 24 'priority' => 0, 25 )); 26 27 materialis_add_kirki_field(array( 28 'type' => 'checkbox', 29 'label' => esc_html__('Show Top Bar', 'materialis'), 30 'section' => $section, 31 'priority' => 0, 32 'settings' => "enable_top_bar", 33 'default' => materialis_mod_default('enable_top_bar'), 34 )); 35 36 materialis_add_kirki_field(array( 37 'type' => 'ope-info-pro', 38 'label' => esc_html__('More colors and typography options available in PRO. @BTN@', 'materialis'), 39 'section' => $section, 40 'priority' => 0, 41 'settings' => "top_bar_pro_info", 42 'default' => true, 43 'transport' => 'postMessage', 44 )); 45 } 46 47 48 function materialis_print_top_bar_area($areaName, $default = "info") 49 { 50 51 $to_print = materialis_get_theme_mod("header_top_bar_{$areaName}_content", $default); 52 53 if ( ! array_key_exists($to_print, materialis_get_content_types())) { 54 $to_print = "info"; 55 } 56 57 if ( ! in_array($areaName, array('area-left', 'area-right'))) { 58 $areaName = "area-left"; 59 } 60 61 $cols = "col-xs-fit"; 62 if ($areaName == "area-left") { 63 $cols = "col-xs"; 64 } 65 ?> 66 <div class="header-top-bar-area <?php echo esc_attr($cols . " " . $areaName); ?>"> 67 <?php 68 do_action("materialis_header_top_bar_content_print", $areaName, $to_print); 69 ?> 70 </div> 71 <?php 72 } 73 74 function materialis_print_header_top_bar() 75 { 76 $inner = materialis_is_inner(true); 77 $enabled = materialis_get_theme_mod('enable_top_bar', materialis_mod_default('enable_top_bar')); 78 79 $classes = array(); 80 $prefix = $inner ? "inner_header" : "header"; 81 82 if (materialis_get_theme_mod("{$prefix}_nav_boxed", false)) { 83 $classes[] = "gridContainer"; 84 } 85 86 if ($enabled) { 87 $header_top_bar_class = ''; 88 if (in_array('gridContainer', $classes)) { 89 $header_top_bar_class = 'no-padding'; 90 } 91 $header_top_bar_class = apply_filters('materialis_header_top_bar_class', $header_top_bar_class); 92 ?> 93 <div class="header-top-bar <?php echo esc_attr($header_top_bar_class); ?>"> 94 <div class="<?php echo esc_attr(implode(' ', $classes)); ?>"> 95 <div class="header-top-bar-inner row middle-xs start-xs "> 96 <?php materialis_print_top_bar_area('area-left', 'info') ?> 97 <?php materialis_print_top_bar_area('area-right', 'social') ?> 98 </div> 99 </div> 100 </div> 101 <?php 102 } 103 104 }