| 1 |
<?php |
| 2 |
if ( ! function_exists( 'spiceb_spicepress_service_customize_register' ) ) : |
| 3 |
function spiceb_spicepress_service_customize_register($wp_customize){ |
| 4 |
$selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh'; |
| 5 |
|
| 6 |
/* Services section */ |
| 7 |
$wp_customize->add_section( 'services_section' , array( |
| 8 |
'title' => __('Service settings', 'spicepress'), |
| 9 |
'panel' => 'section_settings', |
| 10 |
'priority' => 1, |
| 11 |
) ); |
| 12 |
|
| 13 |
|
| 14 |
// Enable service more btn |
| 15 |
$wp_customize->add_setting( 'home_service_section_enabled' , array( 'default' => 'on') ); |
| 16 |
$wp_customize->add_control( 'home_service_section_enabled' , array( |
| 17 |
'label' => __( 'Enable Services on homepage', 'spicepress' ), |
| 18 |
'section' => 'services_section', |
| 19 |
'type' => 'radio', |
| 20 |
'choices' => array( |
| 21 |
'on'=>__('ON', 'spicepress'), |
| 22 |
'off'=>__('OFF', 'spicepress') |
| 23 |
) |
| 24 |
)); |
| 25 |
|
| 26 |
|
| 27 |
// Service section title |
| 28 |
$wp_customize->add_setting( 'home_service_section_title',array( |
| 29 |
'capability' => 'edit_theme_options', |
| 30 |
'default' => __('What we Offer?','spicepress'), |
| 31 |
'sanitize_callback' => 'spiceb_spicepress_home_page_sanitize_text', |
| 32 |
'transport' => $selective_refresh, |
| 33 |
)); |
| 34 |
$wp_customize->add_control( 'home_service_section_title',array( |
| 35 |
'label' => __('Title','spicepress'), |
| 36 |
'section' => 'services_section', |
| 37 |
'type' => 'text', |
| 38 |
)); |
| 39 |
|
| 40 |
//room section discription |
| 41 |
$wp_customize->add_setting( 'home_service_section_discription',array( |
| 42 |
'capability' => 'edit_theme_options', |
| 43 |
'default' => 'Sea summo mazim ex, ea errem eleifend definitionem vim. Ut nec hinc dolor possim mei ludus efficiendi ei sea summo mazim ex.', |
| 44 |
'sanitize_callback' => 'spiceb_spicepress_home_page_sanitize_text', |
| 45 |
'transport' => $selective_refresh, |
| 46 |
)); |
| 47 |
$wp_customize->add_control( 'home_service_section_discription',array( |
| 48 |
'label' => __('Description','spicepress'), |
| 49 |
'section' => 'services_section', |
| 50 |
'type' => 'textarea', |
| 51 |
)); |
| 52 |
|
| 53 |
if ( class_exists( 'Spicepress_Repeater' ) ) { |
| 54 |
$wp_customize->add_setting( 'spicepress_service_content', array( |
| 55 |
) ); |
| 56 |
|
| 57 |
$wp_customize->add_control( new Spicepress_Repeater( $wp_customize, 'spicepress_service_content', array( |
| 58 |
'label' => esc_html__( 'Service content', 'spicepress' ), |
| 59 |
'section' => 'services_section', |
| 60 |
'priority' => 10, |
| 61 |
'add_field_label' => esc_html__( 'Add new Service', 'spicepress' ), |
| 62 |
'item_name' => esc_html__( 'Service', 'spicepress' ), |
| 63 |
'customizer_repeater_icon_control' => true, |
| 64 |
'customizer_repeater_title_control' => true, |
| 65 |
'customizer_repeater_text_control' => true, |
| 66 |
'customizer_repeater_link_control' => true, |
| 67 |
'customizer_repeater_checkbox_control' => true, |
| 68 |
'customizer_repeater_image_control' => true, |
| 69 |
) ) ); |
| 70 |
} |
| 71 |
|
| 72 |
} |
| 73 |
|
| 74 |
add_action( 'customize_register', 'spiceb_spicepress_service_customize_register' ); |
| 75 |
endif; |
| 76 |
|
| 77 |
|
| 78 |
/** |
| 79 |
* Add selective refresh for Front page section section controls. |
| 80 |
*/ |
| 81 |
function spiceb_spicepress_register_home_service_section_partials( $wp_customize ){ |
| 82 |
|
| 83 |
//Slider section |
| 84 |
$wp_customize->selective_refresh->add_partial( 'spicepress_service_content', array( |
| 85 |
'selector' => '.service-section #service_content_section', |
| 86 |
'settings' => 'spicepress_service_content', |
| 87 |
|
| 88 |
) ); |
| 89 |
|
| 90 |
|
| 91 |
//Slider section |
| 92 |
$wp_customize->selective_refresh->add_partial( 'home_service_section_title', array( |
| 93 |
'selector' => '.service-section .section-header .widget-title', |
| 94 |
'settings' => 'home_service_section_title', |
| 95 |
'render_callback' => 'spiceb_spicepress_service_section_title_render_callback', |
| 96 |
|
| 97 |
) ); |
| 98 |
|
| 99 |
$wp_customize->selective_refresh->add_partial( 'home_service_section_discription', array( |
| 100 |
'selector' => '.service-section .section-header p', |
| 101 |
'settings' => 'home_service_section_discription', |
| 102 |
'render_callback' => 'spiceb_spicepress_service_section_discription_render_callback', |
| 103 |
|
| 104 |
) ); |
| 105 |
|
| 106 |
} |
| 107 |
|
| 108 |
add_action( 'customize_register', 'spiceb_spicepress_register_home_service_section_partials' ); |
| 109 |
|
| 110 |
|
| 111 |
function spiceb_spicepress_service_section_title_render_callback() { |
| 112 |
return get_theme_mod( 'home_service_section_title' ); |
| 113 |
} |
| 114 |
|
| 115 |
function spiceb_spicepress_service_section_discription_render_callback() { |
| 116 |
return get_theme_mod( 'home_service_section_discription' ); |
| 117 |
} |
| 118 |
?> |