1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Jetpack Search Overlay Customization |
4
|
|
|
* |
5
|
|
|
* @package jetpack |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
// Exit if file is accessed directly. |
9
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
10
|
|
|
exit; |
11
|
|
|
} |
12
|
|
|
|
13
|
|
|
require_once dirname( __FILE__ ) . '/class.jetpack-search-options.php'; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Class to customize search on the site. |
17
|
|
|
* |
18
|
|
|
* @since 8.3.0 |
19
|
|
|
*/ |
20
|
|
|
class Jetpack_Search_Customize { |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Class initialization. |
24
|
|
|
* |
25
|
|
|
* @since 8.3.0 |
26
|
|
|
*/ |
27
|
|
|
public function __construct() { |
28
|
|
|
add_action( 'customize_register', array( $this, 'customize_register' ) ); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Initialize Customizer controls. |
33
|
|
|
* |
34
|
|
|
* @since 8.3.0 |
35
|
|
|
* |
36
|
|
|
* @param WP_Customize_Manager $wp_customize Customizer instance. |
37
|
|
|
*/ |
38
|
|
|
public function customize_register( $wp_customize ) { |
39
|
|
|
$section_id = 'jetpack_search'; |
40
|
|
|
$setting_prefix = Jetpack_Search_Options::OPTION_PREFIX; |
41
|
|
|
|
42
|
|
|
$wp_customize->add_section( |
43
|
|
|
$section_id, |
44
|
|
|
array( |
45
|
|
|
'title' => esc_html__( 'Jetpack Search', 'jetpack' ), |
46
|
|
|
'description' => __( 'Use these settings to customize the search overlay.', 'jetpack' ), |
47
|
|
|
'capability' => 'edit_theme_options', |
48
|
|
|
'priority' => 200, |
49
|
|
|
) |
50
|
|
|
); |
51
|
|
|
|
52
|
|
|
$id = $setting_prefix . 'color_theme'; |
53
|
|
|
$wp_customize->add_setting( |
54
|
|
|
$id, |
55
|
|
|
array( |
56
|
|
|
'default' => 'light', |
57
|
|
|
'type' => 'option', |
58
|
|
|
) |
59
|
|
|
); |
60
|
|
|
$wp_customize->add_control( |
61
|
|
|
$id, |
62
|
|
|
array( |
63
|
|
|
'label' => __( 'Theme', 'jetpack' ), |
64
|
|
|
'description' => __( 'A light or dark theme for your search overlay.', 'jetpack' ), |
65
|
|
|
'section' => $section_id, |
66
|
|
|
'type' => 'radio', |
67
|
|
|
'choices' => array( |
68
|
|
|
'light' => 'Light', |
69
|
|
|
'dark' => 'Dark', |
70
|
|
|
), |
71
|
|
|
) |
72
|
|
|
); |
73
|
|
|
|
74
|
|
|
$id = $setting_prefix . 'opacity'; |
75
|
|
|
$wp_customize->add_setting( |
76
|
|
|
$id, |
77
|
|
|
array( |
78
|
|
|
'default' => 97, |
79
|
|
|
'type' => 'option', |
80
|
|
|
) |
81
|
|
|
); |
82
|
|
|
$wp_customize->add_control( |
83
|
|
|
$id, |
84
|
|
|
array( |
85
|
|
|
'type' => 'range', |
86
|
|
|
'section' => $section_id, |
87
|
|
|
'label' => __( 'Background Opacity', 'jetpack' ), |
88
|
|
|
'description' => __( 'Select and opacity for the search overlay.', 'jetpack' ), |
89
|
|
|
'input_attrs' => array( |
90
|
|
|
'min' => 0, |
91
|
|
|
'max' => 100, |
92
|
|
|
'step' => 1, |
93
|
|
|
), |
94
|
|
|
) |
95
|
|
|
); |
96
|
|
|
|
97
|
|
|
$id = $setting_prefix . 'close_color'; |
98
|
|
|
$wp_customize->add_setting( |
99
|
|
|
$id, |
100
|
|
|
array( |
101
|
|
|
'default' => '#BD3854', |
102
|
|
|
'type' => 'option', |
103
|
|
|
) |
104
|
|
|
); |
105
|
|
|
$wp_customize->add_control( |
106
|
|
|
new WP_Customize_Color_Control( |
107
|
|
|
$wp_customize, |
108
|
|
|
$id, |
109
|
|
|
array( |
110
|
|
|
'label' => __( 'Close Button', 'jetpack' ), |
111
|
|
|
'description' => __( 'Select a color and position for the close button.', 'jetpack' ), |
112
|
|
|
'section' => $section_id, |
113
|
|
|
) |
114
|
|
|
) |
115
|
|
|
); |
116
|
|
|
|
117
|
|
|
$id = $setting_prefix . 'highlight_color'; |
118
|
|
|
$wp_customize->add_setting( |
119
|
|
|
$id, |
120
|
|
|
array( |
121
|
|
|
'default' => '#FFC', |
122
|
|
|
'type' => 'option', |
123
|
|
|
) |
124
|
|
|
); |
125
|
|
|
$wp_customize->add_control( |
126
|
|
|
new WP_Customize_Color_Control( |
127
|
|
|
$wp_customize, |
128
|
|
|
$id, |
129
|
|
|
array( |
130
|
|
|
'label' => __( 'Highlight Search Terms', 'jetpack' ), |
131
|
|
|
'description' => __( 'Choose a color to highlight matching search terms.', 'jetpack' ), |
132
|
|
|
'section' => $section_id, |
133
|
|
|
) |
134
|
|
|
) |
135
|
|
|
); |
136
|
|
|
|
137
|
|
|
$id = $setting_prefix . 'inf_scroll'; |
138
|
|
|
$wp_customize->add_setting( |
139
|
|
|
$id, |
140
|
|
|
array( |
141
|
|
|
'default' => true, |
142
|
|
|
'type' => 'option', |
143
|
|
|
) |
144
|
|
|
); |
145
|
|
|
$wp_customize->add_control( |
146
|
|
|
$id, |
147
|
|
|
array( |
148
|
|
|
'type' => 'checkbox', |
149
|
|
|
'section' => $section_id, |
150
|
|
|
'label' => __( 'Infinite Scroll Results', 'jetpack' ), |
151
|
|
|
) |
152
|
|
|
); |
153
|
|
|
|
154
|
|
|
$id = $setting_prefix . 'show_logo'; |
155
|
|
|
$wp_customize->add_setting( |
156
|
|
|
$id, |
157
|
|
|
array( |
158
|
|
|
'default' => true, |
159
|
|
|
'type' => 'option', |
160
|
|
|
) |
161
|
|
|
); |
162
|
|
|
|
163
|
|
|
$wp_customize->add_control( |
164
|
|
|
$id, |
165
|
|
|
array( |
166
|
|
|
'type' => 'checkbox', |
167
|
|
|
'section' => $section_id, |
168
|
|
|
'label' => __( 'Display Magnifying Glass Logo', 'jetpack' ), |
169
|
|
|
) |
170
|
|
|
); |
171
|
|
|
|
172
|
|
|
$id = $setting_prefix . 'show_powered_by'; |
173
|
|
|
$wp_customize->add_setting( |
174
|
|
|
$id, |
175
|
|
|
array( |
176
|
|
|
'default' => true, |
177
|
|
|
'type' => 'option', |
178
|
|
|
) |
179
|
|
|
); |
180
|
|
|
$wp_customize->add_control( |
181
|
|
|
$id, |
182
|
|
|
array( |
183
|
|
|
'type' => 'checkbox', |
184
|
|
|
'section' => $section_id, |
185
|
|
|
'label' => __( 'Display "Powered by Jetpack"', 'jetpack' ), |
186
|
|
|
) |
187
|
|
|
); |
188
|
|
|
|
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
|