offscreen.php (2118B)
1 <?php 2 3 add_action("materialis_customize_register_options", 'materialis_offscreen_menu_settings', 1); 4 5 function materialis_offscreen_menu_settings() 6 { 7 $prefix = "header_offscreen_nav"; 8 $section = "navigation_offscreen"; 9 $priority = 1; 10 11 materialis_add_kirki_field(array( 12 'type' => 'sectionseparator', 13 'label' => esc_html__('Offscreen Menu Settings', 'materialis'), 14 'settings' => "{$prefix}_settings_separator", 15 'section' => $section, 16 'priority' => $priority, 17 )); 18 19 materialis_add_kirki_field(array( 20 'type' => 'checkbox', 21 'settings' => "{$prefix}_on_tablet", 22 'label' => esc_html__('Show offscreen navigation on tablet', 'materialis'), 23 'section' => $section, 24 'default' => false, 25 'priority' => $priority, 26 27 )); 28 29 materialis_add_kirki_field(array( 30 'type' => 'checkbox', 31 'settings' => "{$prefix}_on_desktop", 32 'label' => esc_html__('Show offscreen navigation on desktop', 'materialis'), 33 'section' => $section, 34 'default' => false, 35 'priority' => $priority, 36 37 )); 38 39 40 materialis_add_kirki_field(array( 41 'type' => 'ope-info-pro', 42 'label' => esc_html__('More colors and typography options available in PRO. @BTN@', 'materialis'), 43 'section' => $section, 44 'priority' => $priority, 45 'settings' => "{$prefix}_offscreen_pro_info", 46 'default' => true, 47 'transport' => 'postMessage', 48 )); 49 50 } 51 52 53 // APPLY OFFSCREEN FILTERS 54 55 function materialis_header_offscreen_nav_filter($classes) 56 { 57 $prefix = "header_offscreen_nav"; 58 59 $offscreen_on_tablet = materialis_get_theme_mod("{$prefix}_on_tablet", false); 60 $offscreen_on_desktop = materialis_get_theme_mod("{$prefix}_on_desktop", false); 61 62 if (intval($offscreen_on_desktop)) { 63 $classes[] = "offcanvas_menu-desktop"; 64 } 65 if (intval($offscreen_on_tablet)) { 66 $classes[] = "offcanvas_menu-tablet"; 67 } 68 69 return $classes; 70 } 71 72 add_filter('body_class', 'materialis_header_offscreen_nav_filter');