PluginProbe
SpiceBox / 0.2.4
SpiceBox v0.2.4
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.2.4, at inc/spicepress/features/feature-slider-section.php

169 lines 5.3 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
44 // Slider title
45 $wp_customize->add_setting( 'home_slider_title',array(
46 'default' => __('Welcome to SpicePress Theme','spicepress'),
47 'sanitize_callback' => 'spiceb_spicepress_home_page_sanitize_text',
48 'transport' => $selective_refresh,
49 ));
50 $wp_customize->add_control( 'home_slider_title',array(
51 'label' => __('Title','spicepress'),
52 'section' => 'slider_section',
53 'type' => 'text',
54 ));
55
56 //Slider discription
57 $wp_customize->add_setting( 'home_slider_discription',array(
58 'default' => 'Sea summo mazim ex, ea errem eleifend definitionem vim. Ut nec hinc dolor possim mei ludus efficiendi ei sea summo mazim ex.',
59 'sanitize_callback' => 'spiceb_spicepress_home_page_sanitize_text',
60 'transport' => $selective_refresh,
61 ));
62 $wp_customize->add_control( 'home_slider_discription',array(
63 'label' => __('Description','spicepress'),
64 'section' => 'slider_section',
65 'type' => 'textarea',
66 ));
67
68
69 // Slider button text
70 $wp_customize->add_setting( 'home_slider_btn_txt',array(
71 'default' => __('Read more','spicepress'),
72 'sanitize_callback' => 'spiceb_spicepress_home_page_sanitize_text',
73 'transport' => $selective_refresh,
74 ));
75 $wp_customize->add_control( 'home_slider_btn_txt',array(
76 'label' => __('Button Text','spicepress'),
77 'section' => 'slider_section',
78 'type' => 'text',
79 ));
80
81 // Slider button link
82 $wp_customize->add_setting( 'home_slider_btn_link',array(
83 'default' => __('#','spicepress'),
84 'sanitize_callback' => 'spiceb_spicepress_home_page_sanitize_text',
85 'transport' => $selective_refresh,
86 ));
87 $wp_customize->add_control( 'home_slider_btn_link',array(
88 'label' => __('Button Link','spicepress'),
89 'section' => 'slider_section',
90 'type' => 'text',
91 ));
92
93 // Slider button target
94 $wp_customize->add_setting(
95 'home_slider_btn_target',
96 array(
97 'default' => false,
98 'sanitize_callback' => 'spiceb_spicepress_home_page_sanitize_text',
99 ));
100 $wp_customize->add_control('home_slider_btn_target', array(
101 'label' => __('Open link in new tab', 'spicepress'),
102 'section' => 'slider_section',
103 'type' => 'checkbox',
104 ));
105
106
107
108 }
109
110 add_action( 'customize_register', 'spiceb_spicepress_slider_customize_register' );
111 endif;
112
113
114 /**
115 * Add selective refresh for Front page section section controls.
116 */
117 function spiceb_spicepress_register_home_slider_section_partials( $wp_customize ){
118
119
120
121 $wp_customize->selective_refresh->add_partial( 'home_slider_image', array(
122 'selector' => '.slider .item',
123 'settings' => 'home_slider_image',
124
125 ) );
126
127 //Slider section
128 $wp_customize->selective_refresh->add_partial( 'home_slider_title', array(
129 'selector' => '.format-standard .slide-text-bg1 h1',
130 'settings' => 'home_slider_title',
131 'render_callback' => 'spiceb_spicepress_slider_section_title_render_callback',
132
133 ) );
134
135 $wp_customize->selective_refresh->add_partial( 'home_slider_discription', array(
136 'selector' => '.format-standard .slide-text-bg1 p',
137 'settings' => 'home_slider_discription',
138 'render_callback' => 'spiceb_spicepress_slider_section_discription_render_callback',
139
140 ) );
141
142 $wp_customize->selective_refresh->add_partial( 'home_slider_btn_txt', array(
143 'selector' => '.slide-btn-sm',
144 'settings' => 'home_slider_btn_txt',
145 'render_callback' => 'spiceb_spicepress_slider_btn_render_callback',
146
147 ) );
148 }
149
150 add_action( 'customize_register', 'spiceb_spicepress_register_home_slider_section_partials' );
151
152
153 function spiceb_spicepress_slider_section_title_render_callback() {
154 return get_theme_mod( 'home_slider_title' );
155 }
156
157 function spiceb_spicepress_slider_section_discription_render_callback() {
158 return get_theme_mod( 'home_slider_discription' );
159 }
160
161 function spiceb_spicepress_slider_btn_render_callback() {
162 return get_theme_mod( 'home_slider_btn_txt' );
163 }
164
165 function spiceb_spicepress_home_page_sanitize_text( $input ) {
166
167 return wp_kses_post( force_balance_tags( $input ) );
168
169 }