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
|
|
|
'transport' => 'postMessage', |
58
|
|
|
'type' => 'option', |
59
|
|
|
) |
60
|
|
|
); |
61
|
|
|
$wp_customize->add_control( |
62
|
|
|
$id, |
63
|
|
|
array( |
64
|
|
|
'label' => __( 'Theme', 'jetpack' ), |
65
|
|
|
'description' => __( 'A light or dark theme for your search overlay.', 'jetpack' ), |
66
|
|
|
'section' => $section_id, |
67
|
|
|
'type' => 'radio', |
68
|
|
|
'choices' => array( |
69
|
|
|
'light' => __( 'Light', 'jetpack' ), |
70
|
|
|
'dark' => __( 'Dark', 'jetpack' ), |
71
|
|
|
), |
72
|
|
|
) |
73
|
|
|
); |
74
|
|
|
|
75
|
|
|
$id = $setting_prefix . 'opacity'; |
76
|
|
|
$wp_customize->add_setting( |
77
|
|
|
$id, |
78
|
|
|
array( |
79
|
|
|
'default' => 97, |
80
|
|
|
'transport' => 'postMessage', |
81
|
|
|
'type' => 'option', |
82
|
|
|
) |
83
|
|
|
); |
84
|
|
|
$wp_customize->add_control( |
85
|
|
|
$id, |
86
|
|
|
array( |
87
|
|
|
'type' => 'range', |
88
|
|
|
'section' => $section_id, |
89
|
|
|
'label' => __( 'Background Opacity', 'jetpack' ), |
90
|
|
|
'description' => __( 'Select and opacity for the search overlay.', 'jetpack' ), |
91
|
|
|
'input_attrs' => array( |
92
|
|
|
'min' => 85, |
93
|
|
|
'max' => 100, |
94
|
|
|
'step' => 0.5, |
95
|
|
|
), |
96
|
|
|
) |
97
|
|
|
); |
98
|
|
|
|
99
|
|
|
$id = $setting_prefix . 'highlight_color'; |
100
|
|
|
$wp_customize->add_setting( |
101
|
|
|
$id, |
102
|
|
|
array( |
103
|
|
|
'default' => '#FFC', |
104
|
|
|
'transport' => 'postMessage', |
105
|
|
|
'type' => 'option', |
106
|
|
|
) |
107
|
|
|
); |
108
|
|
|
$wp_customize->add_control( |
109
|
|
|
new WP_Customize_Color_Control( |
110
|
|
|
$wp_customize, |
111
|
|
|
$id, |
112
|
|
|
array( |
113
|
|
|
'label' => __( 'Highlight Search Terms', 'jetpack' ), |
114
|
|
|
'description' => __( 'Choose a color to highlight matching search terms.', 'jetpack' ), |
115
|
|
|
'section' => $section_id, |
116
|
|
|
) |
117
|
|
|
) |
118
|
|
|
); |
119
|
|
|
|
120
|
|
|
$id = $setting_prefix . 'inf_scroll'; |
121
|
|
|
$wp_customize->add_setting( |
122
|
|
|
$id, |
123
|
|
|
array( |
124
|
|
|
'default' => true, |
125
|
|
|
'transport' => 'postMessage', |
126
|
|
|
'type' => 'option', |
127
|
|
|
) |
128
|
|
|
); |
129
|
|
|
$wp_customize->add_control( |
130
|
|
|
$id, |
131
|
|
|
array( |
132
|
|
|
'type' => 'checkbox', |
133
|
|
|
'section' => $section_id, |
134
|
|
|
'label' => __( 'Infinite Scroll Results', 'jetpack' ), |
135
|
|
|
) |
136
|
|
|
); |
137
|
|
|
|
138
|
|
|
$id = $setting_prefix . 'show_powered_by'; |
139
|
|
|
$wp_customize->add_setting( |
140
|
|
|
$id, |
141
|
|
|
array( |
142
|
|
|
'default' => true, |
143
|
|
|
'transport' => 'postMessage', |
144
|
|
|
'type' => 'option', |
145
|
|
|
) |
146
|
|
|
); |
147
|
|
|
$wp_customize->add_control( |
148
|
|
|
$id, |
149
|
|
|
array( |
150
|
|
|
'type' => 'checkbox', |
151
|
|
|
'section' => $section_id, |
152
|
|
|
'label' => __( 'Display "Powered by Jetpack"', 'jetpack' ), |
153
|
|
|
) |
154
|
|
|
); |
155
|
|
|
|
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
|