PluginProbe
SpiceBox / 0.3.3
SpiceBox v0.3.3
trunk 0.2.2 0.2.3 0.2.4 0.2.5 0.2.6 0.2.7 0.2.8 0.2.9 0.3 0.3.1 0.3.2 0.3.3 0.3.4 0.3.5 0.3.6 0.3.7 0.3.8 0.3.9.1 0.3.9.2 0.4 0.5 0.6 0.7 1.0 All 76 releases
spicebox / inc / spicepress / features / feature-slider-section.php

feature-slider-section.php in SpiceBox 0.3.3, at inc/spicepress/features/feature-slider-section.php

188 lines 6.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! function_exists( 'spiceb_spicepress_slider_customize_register' ) ) :
2 function spiceb_spicepress_slider_customize_register($wp_customize){
3 $selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh';
4
5 /* Slider Section */
6 $wp_customize->add_section( 'slider_section' , array(
7 'title' => __('Slider settings', 'spicepress'),
8 'panel' => 'section_settings',
9 'priority' => 1,
10 ) );
11
12 // Enable slider
13 $wp_customize->add_setting( 'home_page_slider_enabled' , array( 'default' => 'on') );
14 $wp_customize->add_control( 'home_page_slider_enabled' , array(
15 'label' => __( 'Enable slider', 'spicepress' ),
16 'section' => 'slider_section',
17 'type' => 'radio',
18 'choices' => array(
19 'on'=>__('ON', 'spicepress'),
20 'off'=>__('OFF', 'spicepress')
21 )
22 ));
23
24
25 //Slider Image
26 $wp_customize->add_setting( 'home_slider_image',array('default' => SPICEB_PLUGIN_URL .'inc/spicepress/images/slider/slider.jpg',
27 'sanitize_callback' => 'esc_url_raw', 'transport' => $selective_refresh,));
28
29 $wp_customize->add_control(
30 new WP_Customize_Image_Control(
31 $wp_customize,
32 'home_slider_image',
33 array(
34 'type' => 'upload',
35 'label' => __('Image','spicepress'),
36 'settings' =>'home_slider_image',
37 'section' => 'slider_section',
38
39 )
40 )
41 );
42
43 // Image overlay
44 $wp_customize->add_setting( 'slider_image_overlay', array(
45 'default' => true,
46 'sanitize_callback' => 'sanitize_text_field',
47 ) );
48
49 $wp_customize->add_control('slider_image_overlay', array(
50 'label' => __('Enable slider image overlay', 'spicepress' ),
51 'section' => 'slider_section',
52 'type' => 'checkbox',
53 ) );
54
55
56 //Slider Background Overlay Color
57 $wp_customize->add_setting( 'slider_overlay_section_color', array(
58 'sanitize_callback' => 'sanitize_text_field',
59 'default' => 'rgba(0,0,0,0.30)',
60 ) );
61
62 $wp_customize->add_control(new SpicePress_Customize_Alpha_Color_Control( $wp_customize,'slider_overlay_section_color', array(
63 'label' => __('Slider image overlay color','spicepress' ),
64 'palette' => true,
65 'section' => 'slider_section')
66 ) );
67
68
69 // Slider title
70 $wp_customize->add_setting( 'home_slider_title',array(
71 'default' => __('Welcome to SpicePress Theme','spicepress'),
72 'sanitize_callback' => 'spiceb_spicepress_home_page_sanitize_text',
73 'transport' => $selective_refresh,
74 ));
75 $wp_customize->add_control( 'home_slider_title',array(
76 'label' => __('Title','spicepress'),
77 'section' => 'slider_section',
78 'type' => 'text',
79 ));
80
81 //Slider discription
82 $wp_customize->add_setting( 'home_slider_discription',array(
83 'default' => 'Sea summo mazim ex, ea errem eleifend definitionem vim. Ut nec hinc dolor possim mei ludus efficiendi ei sea summo mazim ex.',
84 'sanitize_callback' => 'spiceb_spicepress_home_page_sanitize_text',
85 'transport' => $selective_refresh,
86 ));
87 $wp_customize->add_control( 'home_slider_discription',array(
88 'label' => __('Description','spicepress'),
89 'section' => 'slider_section',
90 'type' => 'textarea',
91 ));
92
93
94 // Slider button text
95 $wp_customize->add_setting( 'home_slider_btn_txt',array(
96 'default' => __('Read more','spicepress'),
97 'sanitize_callback' => 'spiceb_spicepress_home_page_sanitize_text',
98 'transport' => $selective_refresh,
99 ));
100 $wp_customize->add_control( 'home_slider_btn_txt',array(
101 'label' => __('Button Text','spicepress'),
102 'section' => 'slider_section',
103 'type' => 'text',
104 ));
105
106 // Slider button link
107 $wp_customize->add_setting( 'home_slider_btn_link',array(
108 'default' => __('#','spicepress'),
109 'sanitize_callback' => 'spiceb_spicepress_home_page_sanitize_text',
110 'transport' => $selective_refresh,
111 ));
112 $wp_customize->add_control( 'home_slider_btn_link',array(
113 'label' => __('Button Link','spicepress'),
114 'section' => 'slider_section',
115 'type' => 'text',
116 ));
117
118 // Slider button target
119 $wp_customize->add_setting(
120 'home_slider_btn_target',
121 array(
122 'default' => false,
123 'sanitize_callback' => 'spiceb_spicepress_home_page_sanitize_text',
124 ));
125 $wp_customize->add_control('home_slider_btn_target', array(
126 'label' => __('Open link in new tab', 'spicepress'),
127 'section' => 'slider_section',
128 'type' => 'checkbox',
129 ));
130
131
132
133 }
134
135 add_action( 'customize_register', 'spiceb_spicepress_slider_customize_register' );
136 endif;
137
138
139 /**
140 * Add selective refresh for Front page section section controls.
141 */
142 function spiceb_spicepress_register_home_slider_section_partials( $wp_customize ){
143
144
145
146 $wp_customize->selective_refresh->add_partial( 'home_slider_image', array(
147 'selector' => '.slider .item',
148 'settings' => 'home_slider_image',
149
150 ) );
151
152 //Slider section
153 $wp_customize->selective_refresh->add_partial( 'home_slider_title', array(
154 'selector' => '.format-standard .slide-text-bg1 h1',
155 'settings' => 'home_slider_title',
156 'render_callback' => 'spiceb_spicepress_slider_section_title_render_callback',
157
158 ) );
159
160 $wp_customize->selective_refresh->add_partial( 'home_slider_discription', array(
161 'selector' => '.format-standard .slide-text-bg1 p',
162 'settings' => 'home_slider_discription',
163 'render_callback' => 'spiceb_spicepress_slider_section_discription_render_callback',
164
165 ) );
166
167 $wp_customize->selective_refresh->add_partial( 'home_slider_btn_txt', array(
168 'selector' => '.slide-btn-sm',
169 'settings' => 'home_slider_btn_txt',
170 'render_callback' => 'spiceb_spicepress_slider_btn_render_callback',
171
172 ) );
173 }
174
175 add_action( 'customize_register', 'spiceb_spicepress_register_home_slider_section_partials' );
176
177
178 function spiceb_spicepress_slider_section_title_render_callback() {
179 return get_theme_mod( 'home_slider_title' );
180 }
181
182 function spiceb_spicepress_slider_section_discription_render_callback() {
183 return get_theme_mod( 'home_slider_discription' );
184 }
185
186 function spiceb_spicepress_slider_btn_render_callback() {
187 return get_theme_mod( 'home_slider_btn_txt' );
188 }