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