| 1 |
<?php |
| 2 |
if ( ! function_exists( 'spiceb_spicepress_testimonial_customize_register' ) ) : |
| 3 |
function spiceb_spicepress_testimonial_customize_register($wp_customize){ |
| 4 |
$selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh'; |
| 5 |
|
| 6 |
/* Testimonial Section */ |
| 7 |
$wp_customize->add_section( 'testimonial_section' , array( |
| 8 |
'title' => __('Testimonial settings', 'spicepress'), |
| 9 |
'panel' => 'section_settings', |
| 10 |
'priority' => 7, |
| 11 |
) ); |
| 12 |
|
| 13 |
// Enable testimonial section |
| 14 |
$wp_customize->add_setting( 'testimonial_section_enable' , array( 'default' => 'on') ); |
| 15 |
$wp_customize->add_control( 'testimonial_section_enable' , array( |
| 16 |
'label' => __( 'Enable Home Testimonial section', 'spicepress' ), |
| 17 |
'section' => 'testimonial_section', |
| 18 |
'type' => 'radio', |
| 19 |
'choices' => array( |
| 20 |
'on'=>__('ON', 'spicepress'), |
| 21 |
'off'=>__('OFF', 'spicepress') |
| 22 |
) |
| 23 |
)); |
| 24 |
|
| 25 |
//Testimonial Background Image |
| 26 |
$wp_customize->add_setting( 'testimonial_callout_background',array('default' => SPICEB_PLUGIN_URL .'inc/spicepress/images/testimonial/testimonial-bg.jpg', |
| 27 |
'sanitize_callback' => 'esc_url_raw', 'transport' => $selective_refresh,)); |
| 28 |
|
| 29 |
|
| 30 |
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'testimonial_callout_background', array( |
| 31 |
'label' => __( 'Background Image', 'spicepress' ), |
| 32 |
'section' => 'testimonial_section', |
| 33 |
'settings' => 'testimonial_callout_background', |
| 34 |
) ) ); |
| 35 |
|
| 36 |
// Image overlay |
| 37 |
$wp_customize->add_setting( 'testimonial_image_overlay', array( |
| 38 |
'default' => true, |
| 39 |
'sanitize_callback' => 'sanitize_text_field', |
| 40 |
) ); |
| 41 |
|
| 42 |
$wp_customize->add_control('testimonial_image_overlay', array( |
| 43 |
'label' => __('Enable testimonial image overlay', 'spicepress' ), |
| 44 |
'section' => 'testimonial_section', |
| 45 |
'type' => 'checkbox', |
| 46 |
) ); |
| 47 |
|
| 48 |
|
| 49 |
//Testimonial Background Overlay Color |
| 50 |
$wp_customize->add_setting( 'testimonial_overlay_section_color', array( |
| 51 |
'sanitize_callback' => 'sanitize_text_field', |
| 52 |
'default' => 'rgba(0,0,0,0.6)', |
| 53 |
) ); |
| 54 |
|
| 55 |
$wp_customize->add_control(new SpicePress_Customize_Alpha_Color_Control( $wp_customize,'testimonial_overlay_section_color', array( |
| 56 |
'label' => __('Testimonial image overlay color','spicepress' ), |
| 57 |
'palette' => true, |
| 58 |
'section' => 'testimonial_section') |
| 59 |
) ); |
| 60 |
|
| 61 |
|
| 62 |
// testimonial section title |
| 63 |
$wp_customize->add_setting( 'home_testimonial_section_title',array( |
| 64 |
'capability' => 'edit_theme_options', |
| 65 |
'default' => __('What People Say','spicepress'), |
| 66 |
'sanitize_callback' => 'spiceb_spicepress_home_page_sanitize_text', |
| 67 |
'transport' => $selective_refresh, |
| 68 |
)); |
| 69 |
$wp_customize->add_control( 'home_testimonial_section_title',array( |
| 70 |
'label' => __('Title','spicepress'), |
| 71 |
'section' => 'testimonial_section', |
| 72 |
'type' => 'text', |
| 73 |
)); |
| 74 |
|
| 75 |
//testimonial section discription |
| 76 |
$wp_customize->add_setting( 'home_testimonial_section_discription',array( |
| 77 |
'capability' => 'edit_theme_options', |
| 78 |
'default'=> 'Sea summo mazim ex, ea errem eleifend definitionem vim. Ut nec hinc dolor possim mei ludus efficiendi ei sea summo mazim ex.', |
| 79 |
'sanitize_callback' => 'spiceb_spicepress_home_page_sanitize_text', |
| 80 |
'transport' => $selective_refresh, |
| 81 |
)); |
| 82 |
$wp_customize->add_control( 'home_testimonial_section_discription',array( |
| 83 |
'label' => __('Description','spicepress'), |
| 84 |
'section' => 'testimonial_section', |
| 85 |
'type' => 'textarea', |
| 86 |
)); |
| 87 |
|
| 88 |
//testimonial one image |
| 89 |
$wp_customize->add_setting( 'home_testimonial_thumb',array('default' => SPICEB_PLUGIN_URL .'inc/spicepress/images/testimonial/testi1.jpg', |
| 90 |
'sanitize_callback' => 'esc_url_raw', 'transport' => $selective_refresh,)); |
| 91 |
|
| 92 |
$wp_customize->add_control( |
| 93 |
new WP_Customize_Image_Control( |
| 94 |
$wp_customize, |
| 95 |
'home_testimonial_thumb', |
| 96 |
array( |
| 97 |
'label' => __('Image','spicebox'), |
| 98 |
'section' => 'example_section_one', |
| 99 |
'settings' =>'home_testimonial_thumb', |
| 100 |
'section' => 'testimonial_section', |
| 101 |
'type' => 'upload', |
| 102 |
) |
| 103 |
) |
| 104 |
); |
| 105 |
|
| 106 |
//testimonial description |
| 107 |
$wp_customize->add_setting( 'home_testimonial_desc',array( |
| 108 |
'capability' => 'edit_theme_options', |
| 109 |
'default' => 'Sed ut Perspiciatis Unde Omnis Iste Sed ut perspiciatis unde omnis iste natu error sit voluptatem accu tium neque fermentum veposu miten a tempor nise. Duis autem vel eum iriure dolor in hendrerit in vulputate velit consequat reprehender in voluptate velit esse cillum duis dolor fugiat nulla pariatur.', |
| 110 |
'sanitize_callback' => 'spiceb_spicepress_home_page_sanitize_text', |
| 111 |
'transport' => $selective_refresh, |
| 112 |
)); |
| 113 |
$wp_customize->add_control( 'home_testimonial_desc',array( |
| 114 |
'label' => __('Description','spicepress'), |
| 115 |
'section' => 'testimonial_section', |
| 116 |
'type' => 'text', |
| 117 |
)); |
| 118 |
|
| 119 |
|
| 120 |
// testimonial section title |
| 121 |
$wp_customize->add_setting( 'home_testimonial_title',array( |
| 122 |
'capability' => 'edit_theme_options', |
| 123 |
'default' => __('Alice Culan','spicepress'), |
| 124 |
'sanitize_callback' => 'spiceb_spicepress_home_page_sanitize_text', |
| 125 |
'transport' => $selective_refresh, |
| 126 |
)); |
| 127 |
$wp_customize->add_control( 'home_testimonial_title',array( |
| 128 |
'label' => __('Title','spicepress'), |
| 129 |
'section' => 'testimonial_section', |
| 130 |
'type' => 'text', |
| 131 |
)); |
| 132 |
|
| 133 |
|
| 134 |
$wp_customize->add_setting( 'home_testimonial_designation',array( |
| 135 |
'capability' => 'edit_theme_options', |
| 136 |
'default' => __('UI Developer','spicepress'), |
| 137 |
'sanitize_callback' => 'spiceb_spicepress_home_page_sanitize_text', |
| 138 |
'transport' => $selective_refresh, |
| 139 |
)); |
| 140 |
$wp_customize->add_control( 'home_testimonial_designation',array( |
| 141 |
'label' => __('Designation','spicepress'), |
| 142 |
'section' => 'testimonial_section', |
| 143 |
'type' => 'text', |
| 144 |
)); |
| 145 |
|
| 146 |
|
| 147 |
} |
| 148 |
|
| 149 |
add_action( 'customize_register', 'spiceb_spicepress_testimonial_customize_register' ); |
| 150 |
endif; |
| 151 |
|
| 152 |
|
| 153 |
/** |
| 154 |
* Add selective refresh for Front page section section controls. |
| 155 |
*/ |
| 156 |
function spiceb_spicepress_register_home_testimonial_section_partials( $wp_customize ){ |
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
//Testimonial |
| 161 |
$wp_customize->selective_refresh->add_partial( 'home_testimonial_section_title', array( |
| 162 |
'selector' => '.testimonial-section .section-header h1', |
| 163 |
'settings' => 'home_testimonial_section_title', |
| 164 |
'render_callback' => 'spiceb_spicepress_testimonial_section_title_render_callback', |
| 165 |
|
| 166 |
) ); |
| 167 |
|
| 168 |
$wp_customize->selective_refresh->add_partial( 'home_testimonial_section_discription', array( |
| 169 |
'selector' => '.testimonial-section .section-header p', |
| 170 |
'settings' => 'home_testimonial_section_discription', |
| 171 |
'render_callback' => 'spiceb_spicepress_testimonial_section_discription_render_callback', |
| 172 |
|
| 173 |
) ); |
| 174 |
|
| 175 |
$wp_customize->selective_refresh->add_partial( 'home_testimonial_desc', array( |
| 176 |
'selector' => '.author-description p', |
| 177 |
'settings' => 'home_testimonial_desc', |
| 178 |
'render_callback' => 'spiceb_spicepress_testimonial_desc_render_callback', |
| 179 |
|
| 180 |
) ); |
| 181 |
|
| 182 |
|
| 183 |
$wp_customize->selective_refresh->add_partial( 'home_testimonial_title', array( |
| 184 |
'selector' => '.testmonial-area h4', |
| 185 |
'settings' => 'home_testimonial_title', |
| 186 |
'render_callback' => 'spiceb_spicepress_testimonial_title_render_callback', |
| 187 |
|
| 188 |
) ); |
| 189 |
|
| 190 |
$wp_customize->selective_refresh->add_partial( 'home_testimonial_designation', array( |
| 191 |
'selector' => '.testmonial-area span.designation', |
| 192 |
'settings' => 'home_testimonial_designation', |
| 193 |
'render_callback' => 'spiceb_spicepress_testimonial_designation_render_callback', |
| 194 |
|
| 195 |
) ); |
| 196 |
|
| 197 |
$wp_customize->selective_refresh->add_partial( 'testimonial_callout_background', array( |
| 198 |
'selector' => 'section.testimonial-section', |
| 199 |
'settings' => 'testimonial_callout_background', |
| 200 |
|
| 201 |
) ); |
| 202 |
|
| 203 |
$wp_customize->selective_refresh->add_partial( 'home_testimonial_thumb', array( |
| 204 |
'selector' => '.testmonial-area .author-box', |
| 205 |
'settings' => 'home_testimonial_thumb', |
| 206 |
|
| 207 |
) ); |
| 208 |
|
| 209 |
|
| 210 |
} |
| 211 |
|
| 212 |
add_action( 'customize_register', 'spiceb_spicepress_register_home_testimonial_section_partials' ); |
| 213 |
|
| 214 |
|
| 215 |
function spiceb_spicepress_testimonial_section_title_render_callback() { |
| 216 |
return get_theme_mod( 'home_testimonial_section_title' ); |
| 217 |
} |
| 218 |
|
| 219 |
function spiceb_spicepress_testimonial_section_discription_render_callback() { |
| 220 |
return get_theme_mod( 'home_testimonial_section_discription' ); |
| 221 |
} |
| 222 |
|
| 223 |
function spiceb_spicepress_testimonial_desc_render_callback() { |
| 224 |
return get_theme_mod( 'home_testimonial_desc' ); |
| 225 |
} |
| 226 |
|
| 227 |
function spiceb_spicepress_testimonial_title_render_callback() { |
| 228 |
return get_theme_mod( 'home_testimonial_title' ); |
| 229 |
} |
| 230 |
|
| 231 |
function spiceb_spicepress_testimonial_designation_render_callback() { |
| 232 |
return get_theme_mod( 'home_testimonial_designation' ); |
| 233 |
} |
| 234 |
?> |