presets.php (2084B)
1 <?php 2 3 function materialis_get_header_presets() 4 { 5 global $MATERIALIS_HEADER_PRESETS; 6 7 $result = array(); 8 $presets_file = get_template_directory() . '/customizer/presets.php'; 9 if (file_exists($presets_file) && ! isset($MATERIALIS_HEADER_PRESETS)) { 10 $MATERIALIS_HEADER_PRESETS = require $presets_file; 11 } 12 13 if (isset($MATERIALIS_HEADER_PRESETS)) { 14 $result = $MATERIALIS_HEADER_PRESETS; 15 } 16 17 18 $result = apply_filters('materialis_header_presets', $result); 19 20 return $result; 21 22 } 23 24 function materialis_customize_register_header_presets($wp_customize) { 25 /** @var WP_Customize_Manager $wp_customize */ 26 $wp_customize->add_setting('header_presets', array( 27 'default' => "", 28 'sanitize_callback' => 'esc_html', 29 "transport" => "postMessage", 30 )); 31 32 $wp_customize->add_control(new Materialis\RowsListControl($wp_customize, 'header_presets', array( 33 'label' => esc_html__('Background Type', 'materialis'), 34 'section' => 'header_layout', 35 "insertText" => esc_html__("Apply Preset", "materialis"), 36 'pro_message' => false, 37 "type" => "presets_changer", 38 "dataSource" => materialis_get_header_presets(), 39 "priority" => 2, 40 ))); 41 42 43 $wp_customize->add_setting('frontpage_header_presets_pro', array( 44 'default' => "", 45 'sanitize_callback' => 'esc_html', 46 "transport" => "postMessage", 47 )); 48 49 50 if ( ! apply_filters('materialis_is_companion_installed', false)) { 51 $wp_customize->add_control(new Materialis\Info_PRO_Control($wp_customize, 'frontpage_header_presets_pro', 52 array( 53 'label' => esc_html__('18 more beautiful header designs are available in the PRO version. @BTN@', 'materialis'), 54 'section' => 'header_layout', 55 'priority' => 10, 56 'transport' => 'postMessage', 57 ))); 58 } 59 } 60 61 add_action("materialis_customize_register", 'materialis_customize_register_header_presets' );