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