title.php (11502B)
1 <?php 2 3 4 function materialis_front_page_header_title_options($section, $prefix, $priority) 5 { 6 $companion = apply_filters('materialis_is_companion_installed', false); 7 8 materialis_add_kirki_field(array( 9 'type' => 'checkbox', 10 'settings' => 'header_content_show_title', 11 'label' => esc_html__('Show title', 'materialis'), 12 'section' => $section, 13 'default' => true, 14 'priority' => $priority, 15 )); 16 17 materialis_add_kirki_field(array( 18 'type' => 'sidebar-button-group', 19 'settings' => 'header_content_title_group', 20 'label' => esc_html__('Options', 'materialis'), 21 'section' => $section, 22 'priority' => $priority, 23 'choices' => array( 24 'header_title', 25 'header_title_color', 26 "header_content_title_background_options_separator", 27 "header_content_title_background_enabled", 28 "header_content_title_background_color", 29 "header_content_title_background_spacing", 30 "header_content_title_background_border_radius", 31 "header_content_title_background_border_color", 32 "header_content_title_background_border_thickness", 33 "header_content_title_background_shadow", 34 ), 35 'active_callback' => array( 36 array( 37 'setting' => 'header_content_show_title', 38 'operator' => '==', 39 'value' => true, 40 ), 41 ), 42 'in_row_with' => array('header_content_show_title'), 43 )); 44 45 if ( ! $companion) { 46 materialis_add_kirki_field(array( 47 'type' => 'textarea', 48 'settings' => 'header_title', 49 'label' => esc_html__('Title', 'materialis'), 50 'section' => $section, 51 'default' => '', 52 'sanitize_callback' => 'materialis_wp_kses_post', 53 'priority' => $priority, 54 'partial_refresh' => array( 55 'header_title' => array( 56 'selector' => ".header-homepage .hero-title", 57 'render_callback' => function () { 58 return get_theme_mod('header_title'); 59 }, 60 ), 61 ), 62 )); 63 } 64 65 if (apply_filters('materialis_show_header_title_color', true)) { 66 67 materialis_add_kirki_field(array( 68 'type' => 'select', 69 'settings' => 'header_title_color', 70 'label' => esc_html__('Title color', 'materialis'), 71 'section' => $section, 72 'default' => '#ffffff', 73 'choices' => apply_filters('materialis_woocommerce_shop_header_type_choices', array( 74 "#ffffff" => esc_html__("White text", "materialis"), 75 "#000000" => esc_html__("Dark Text", "materialis"), 76 )), 77 'priority' => $priority, 78 'transport' => 'postMessage', 79 'output' => array( 80 array( 81 'element' => '.header-homepage .hero-title', 82 'property' => 'color', 83 'function' => 'css', 84 ), 85 ), 86 'js_vars' => array( 87 array( 88 'element' => '.header-homepage .hero-title', 89 'property' => 'color', 90 'function' => 'css', 91 ), 92 ), 93 )); 94 } 95 96 97 materialis_add_kirki_field(array( 98 'type' => 'sectionseparator', 99 'label' => esc_html__('Background Options', 'materialis'), 100 'section' => $section, 101 'settings' => "header_content_title_background_options_separator", 102 'priority' => $priority, 103 )); 104 105 materialis_add_kirki_field(array( 106 'type' => 'checkbox', 107 'label' => esc_html__('Enable Background', 'materialis'), 108 'section' => $section, 109 'settings' => 'header_content_title_background_enabled', 110 'priority' => $priority, 111 'default' => materialis_mod_default("header_element_background_enabled"), 112 )); 113 114 materialis_add_kirki_field(array( 115 'type' => 'color', 116 'label' => esc_html__('Background Color', 'materialis'), 117 'section' => $section, 118 'settings' => 'header_content_title_background_color', 119 'default' => materialis_mod_default("header_element_background_color"), 120 'transport' => 'postMessage', 121 'priority' => $priority, 122 'choices' => array( 123 'alpha' => true, 124 ), 125 'active_callback' => array( 126 array( 127 'setting' => 'header_content_title_background_enabled', 128 'operator' => '==', 129 'value' => true, 130 ), 131 ), 132 "output" => array( 133 array( 134 'element' => '.header-homepage .hero-title', 135 'property' => 'background', 136 ), 137 ), 138 'js_vars' => array( 139 array( 140 'element' => ".header-homepage .hero-title", 141 'function' => 'css', 142 'property' => 'background', 143 ), 144 ), 145 )); 146 147 materialis_add_kirki_field(array( 148 'type' => 'spacing', 149 'settings' => 'header_content_title_background_spacing', 150 'label' => esc_html__('Background Spacing', 'materialis'), 151 'section' => $section, 152 'priority' => $priority, 153 'default' => materialis_mod_default("header_element_background_spacing"), 154 'transport' => 'postMessage', 155 'active_callback' => array( 156 array( 157 'setting' => 'header_content_title_background_enabled', 158 'operator' => '==', 159 'value' => true, 160 ), 161 ), 162 'output' => array( 163 array( 164 'element' => '.header-homepage .hero-title', 165 'property' => 'padding', 166 ), 167 ), 168 'js_vars' => array( 169 array( 170 'element' => ".header-homepage .hero-title", 171 'function' => 'style', 172 'property' => 'padding', 173 ), 174 ), 175 )); 176 177 materialis_add_kirki_field(array( 178 'type' => 'dimension', 179 'settings' => 'header_content_title_background_border_radius', 180 'label' => esc_html__('Border Radius', 'materialis'), 181 'section' => $section, 182 'priority' => $priority, 183 'default' => materialis_mod_default("header_element_background_radius"), 184 'transport' => 'postMessage', 185 'active_callback' => array( 186 array( 187 'setting' => 'header_content_title_background_enabled', 188 'operator' => '==', 189 'value' => true, 190 ), 191 ), 192 'output' => array( 193 array( 194 'element' => '.header-homepage .hero-title', 195 'property' => 'border-radius', 196 ), 197 ), 198 'js_vars' => array( 199 array( 200 'element' => ".header-homepage .hero-title", 201 'function' => 'style', 202 'property' => 'border-radius', 203 ), 204 ), 205 )); 206 207 materialis_add_kirki_field(array( 208 'type' => 'color', 209 'settings' => 'header_content_title_background_border_color', 210 'label' => esc_html__('Border Color', 'materialis'), 211 'section' => $section, 212 'default' => materialis_mod_default('header_element_background_border_color'), 213 'transport' => 'postMessage', 214 'priority' => $priority, 215 'choices' => array( 216 'alpha' => true, 217 ), 218 'active_callback' => array( 219 array( 220 'setting' => 'header_content_title_background_enabled', 221 'operator' => '==', 222 'value' => true, 223 ), 224 ), 225 'output' => array( 226 array( 227 'element' => ".header-homepage .hero-title", 228 'property' => 'border-color', 229 ), 230 ), 231 'js_vars' => array( 232 array( 233 'element' => ".header-homepage .hero-title", 234 'function' => 'css', 235 'property' => 'border-color', 236 ), 237 ), 238 )); 239 240 materialis_add_kirki_field(array( 241 'type' => 'spacing', 242 'settings' => 'header_content_title_background_border_thickness', 243 'label' => esc_html__('Background Border Thickness', 'materialis'), 244 'section' => $section, 245 'priority' => $priority, 246 'default' => materialis_mod_default('header_element_background_border_thickness'), 247 'transport' => 'postMessage', 248 'active_callback' => array( 249 array( 250 'setting' => 'header_content_title_background_enabled', 251 'operator' => '==', 252 'value' => true, 253 ), 254 ), 255 )); 256 257 materialis_add_kirki_field(array( 258 'type' => 'slider', 259 'settings' => 'header_content_title_background_shadow', 260 'label' => esc_html__('Shadow Elevation', 'materialis'), 261 'section' => $section, 262 'priority' => $priority, 263 'default' => materialis_mod_default("header_element_background_shadow"), 264 'choices' => array( 265 'min' => '0', 266 'max' => '12', 267 'step' => '1', 268 ), 269 'transport' => 'postMessage', 270 'active_callback' => array( 271 array( 272 'setting' => 'header_content_title_background_enabled', 273 'operator' => '==', 274 'value' => true, 275 ), 276 ), 277 )); 278 } 279 280 281 function materialis_print_header_content_title_hook() 282 { 283 materialis_print_header_title(); 284 } 285 286 add_action("materialis_print_header_content", 'materialis_print_header_content_title_hook', 1); 287 288 function materialis_print_header_title() 289 { 290 $title = materialis_get_theme_mod('header_title', ""); 291 $show = materialis_get_theme_mod('header_content_show_title', true); 292 $shadow_class = ''; 293 294 if (materialis_can_show_demo_content()) { 295 if ($title == "") { 296 $title = strtoupper(esc_html__('Set the title in customizer', 'materialis')); 297 } 298 } else { 299 if ($title == "") { 300 $title = get_bloginfo('site_title'); 301 } 302 } 303 304 $title = materialis_wp_kses_post($title); 305 $title = apply_filters("materialis_header_title", $title); 306 307 if ($show) { 308 $background_enabled = materialis_get_theme_mod('header_content_title_background_enabled', false); 309 $shadow_value = materialis_get_theme_mod('header_content_title_background_shadow', 0); 310 if ($background_enabled && $shadow_value) { 311 $shadow_class = 'mdc-elevation--z' . $shadow_value; 312 } 313 314 if ($title) { 315 printf('<h1 class="hero-title ' . esc_attr($shadow_class) . '">%1$s</h1>', $title); 316 } 317 } 318 }