content-areas.php (2762B)
1 <?php 2 3 materialis_require("/inc/header-options/navigation-options/top-bar/content-types/information.php"); 4 materialis_require("/inc/header-options/navigation-options/top-bar/content-types/social-icons.php"); 5 6 function materialis_get_content_types() { 7 $types['none'] = esc_html__("None", 'materialis'); 8 $types = apply_filters("materialis_get_content_types", $types); 9 return $types; 10 } 11 12 function materialis_get_content_types_options() { 13 $options = apply_filters("materialis_get_content_types_options", array()); 14 return $options; 15 } 16 17 18 add_action("materialis_top_bar_options_after", "materialis_add_content_areas_options"); 19 20 21 function materialis_add_content_areas_options($section) 22 { 23 24 $areas = array('area-left', 'area-right'); 25 $content_types = materialis_get_content_types(); 26 $content_types_options = materialis_get_content_types_options(); 27 28 $options = array( 29 'area-left' => array( 30 'title' => esc_html__('Top bar left area', 'materialis'), 31 'default' => 'info' 32 ), 33 34 'area-right' => array( 35 'title' => esc_html__('Top bar right area', 'materialis'), 36 'default' => 'social' 37 ), 38 ); 39 40 $priority = 0; 41 42 foreach ($areas as $area) { 43 44 $prefix = "header_top_bar_" . $area; 45 $priority += 5; 46 $default = $options[$area]['default']; 47 48 materialis_add_kirki_field(array( 49 'type' => 'sectionseparator', 50 'label' => esc_attr($options[$area]['title']), 51 'section' => $section, 52 'settings' => "{$prefix}_sep", 53 'priority' => $priority, 54 'active_callback' => array( 55 array( 56 'setting' => "enable_top_bar", 57 'operator' => '==', 58 'value' => true, 59 ), 60 ), 61 )); 62 63 materialis_add_kirki_field(array( 64 'type' => 'select', 65 'settings' => $prefix . '_content', 66 'section' => $section, 67 'label' => esc_html__('Type', 'materialis'), 68 'default' => $default, 69 'choices' => $content_types, 70 'priority' => $priority, 71 'active_callback' => array( 72 array( 73 'setting' => "enable_top_bar", 74 'operator' => '==', 75 'value' => true, 76 ), 77 ), 78 79 )); 80 81 $options_functions = array(); 82 83 foreach ($content_types_options as $type => $options_fct) { 84 $options_functions[$options_fct] = array( 85 $area, $section, $priority, $prefix 86 ); 87 } 88 89 materialis_add_options_group($options_functions); 90 91 } 92 }