background.php (2644B)
1 <?php 2 3 require_once get_template_directory() . "/inc/header-options/background-options/background-type.php"; 4 require_once get_template_directory() . "/inc/header-options/background-options/overlay-type.php"; 5 require_once get_template_directory() . "/inc/header-options/background-options/header-separator.php"; 6 require_once get_template_directory() . "/inc/header-options/background-options/general.php"; 7 require_once get_template_directory() . "/inc/header-options/background-options/bottom-arrow.php"; 8 9 function materialis_header_background_settings($inner) 10 { 11 $prefix = $inner ? "inner_header" : "header"; 12 $section = $inner ? "header_image" : "header_background_chooser"; 13 14 $group = "{$prefix}_bg_options_group_button"; 15 16 $priority = 1; 17 materialis_add_kirki_field(array( 18 'type' => 'sectionseparator', 19 'label' => __('Background', 'materialis'), 20 'section' => $section, 21 'priority' => $priority, 22 'settings' => $prefix . "_header_1", 23 )); 24 25 do_action("materialis_header_background_settings", $section, $prefix, $group, $inner, $priority); 26 } 27 28 function materialis_customize_register_options_header_bg_settings() 29 { 30 materialis_header_background_settings(false); 31 materialis_header_background_settings(true); 32 } 33 34 add_action("materialis_customize_register_options", 'materialis_customize_register_options_header_bg_settings'); 35 36 37 /* 38 template functions 39 */ 40 41 function materialis_header_background_atts_full_height_header($attrs, $bg_type, $inner) 42 { 43 if ( ! $inner) { 44 $full_height_header = materialis_get_theme_mod('full_height_header', false); 45 46 if ($full_height_header) { 47 $attrs['style'] .= "; min-height:100vh"; 48 } 49 } 50 51 return $attrs; 52 } 53 54 add_filter("materialis_header_background_atts", 'materialis_header_background_atts_full_height_header', 1, 3); 55 56 57 function materialis_header_background_atts() 58 { 59 $inner = materialis_is_inner(true); 60 $attrs = array( 61 'class' => $inner ? "header " : "header-homepage ", 62 'style' => "", 63 ); 64 65 $prefix = $inner ? "inner_header" : "header"; 66 $bgType = materialis_get_theme_mod($prefix . '_background_type', $inner ? 'color' : 'image'); 67 // $bgType = apply_filters('materialis_' . $prefix . '_background_type', $bgType); 68 69 do_action("materialis_background", $bgType, $inner, $prefix); 70 71 $attrs = apply_filters('materialis_header_background_atts', $attrs, $bgType, $inner); 72 $result = ""; 73 foreach ($attrs as $key => $value) { 74 $value = trim(esc_attr($value)); 75 $result .= " {$key}='" . esc_attr($value) . "'"; 76 } 77 78 return $result; 79 }