PluginProbe ʕ •ᴥ•ʔ
Jetpack – WP Security, Backup, Speed, & Growth / 13.8.3
Jetpack – WP Security, Backup, Speed, & Growth v13.8.3
12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 14.4.2 14.5.1 14.6.1 14.7.1 14.8.1 14.9.2 15.0.3 15.1.2 15.2.1 15.3.2 15.4.1 15.5.1 15.6.1 15.7.2 15.8.1 15.9.2 16.0.2 16.1.3 16.2-a.5 16.2-a.3 16.1.2 16.2-a.1 16.1.1 16.1 16.1-beta 16.1-beta.2 16.1-beta.3 16.1-a.5 16.1-a.3 16.0.1 16.1-a.1 16.0 16.0-beta 16.0-a.7 16.0-a.5 15.9.1 16.0-a.3 16.0-a.1 15.9 15.9-beta 15.9-a.7 15.9-a.5 15.9-a.3 15.9-a.1 15.8 15.8-beta 15.8-a.7 15.8-a.5 5.2.5 5.3.4 5.4.4 5.5.5 5.6.5 5.7.5 5.8.4 5.9.4 6.0.4 6.1 6.1.1 6.1.2 6.1.3 6.1.4 6.1.5 6.2 6.2.1 6.2.2 6.2.3 6.2.4 6.2.5 6.3 6.3.1 6.3.2 6.3.3 6.3.4 6.3.5 6.3.6 6.3.7 6.4 6.4.1 6.4.2 6.4.3 6.4.4 6.4.5 6.4.6 6.5 6.5.1 6.5.2 6.5.3 6.5.4 6.6 6.6.1 6.6.2 6.6.3 6.6.4 6.6.5 6.7 6.7.1 6.7.2 6.7.3 6.7.4 6.8 6.8.1 6.8.2 6.8.3 6.8.4 6.8.5 6.9 6.9.1 6.9.2 6.9.3 6.9.4 7.0 7.0.1 7.0.2 7.0.3 7.0.4 7.0.5 7.1 7.1.1 7.1.2 7.1.3 7.1.4 7.1.5 7.2 7.2.1 7.2.1.1 7.2.2 7.2.3 7.2.4 7.2.5 7.3 7.3.0.1 7.3.1 7.3.1.1 7.3.2 7.3.3 7.3.4 7.3.5 7.4 7.4.1 7.4.2 7.4.3 7.4.4 7.4.5 7.5 7.5.0.1 7.5.1 7.5.2 7.5.3 7.5.4 7.5.5 7.5.6 7.5.7 7.6 7.6.1 7.6.2 7.6.3 7.6.4 7.7 7.7.1 7.7.2 7.7.3 7.7.4 7.7.5 7.7.6 7.8 7.8.1 7.8.2 7.8.3 7.8.4 7.9 7.9.1 7.9.2 7.9.3 7.9.4 8.0 8.0.1 8.0.2 8.0.3 8.1 8.1.1 8.1.2 8.1.3 8.1.4 8.2 8.2.0.1 8.2.1 8.2.2 8.2.3 8.2.4 8.2.5 8.2.6 8.3 8.3.1 8.3.2 8.3.3 8.4 8.4.1 8.4.2 8.4.3 8.4.4 8.4.5 8.5 8.5.1 8.5.2 8.5.3 8.6 8.6.1 8.6.2 8.6.3 8.6.4 8.7 8.7.0.1 8.7.1 8.7.2 8.7.3 8.7.4 8.8 8.8.1 8.8.2 8.8.3 8.8.4 8.8.5 8.9 8.9.1 8.9.2 8.9.3 8.9.4 9.0 9.0.1 9.0.2 9.0.3 9.0.4 9.0.5 9.1 9.1.1 9.1.2 9.1.3 9.2 9.2.1 9.2.2 9.2.3 9.2.4 9.3 9.3.1 9.3.2 9.3.3 9.3.4 9.3.5 9.4 9.4.1 9.4.2 9.4.3 9.4.4 9.5 9.5.1 9.5.2 9.5.3 9.5.4 9.5.5 9.6 9.6.1 9.6.2 9.6.3 9.6.4 9.7 9.7.1 9.7.2 15.7-beta.2 9.7.3 15.7.1 9.8 15.8-a.1 9.8.1 15.8-a.3 9.8.2 2.0.9 9.8.3 2.1.7 9.9 2.2.10 9.9.1 2.3.10 9.9.2 2.4.7 9.9.3 2.5.5 2.6.6 2.7.5 2.8.5 2.9.6 3.0.6 3.1.5 3.2.5 3.3.6 3.4.6 3.5.6 3.6.4 3.7.5 3.8.5 3.9.10 4.0.7 4.1.4 4.2.5 4.3.5 4.4.5 4.5.3 4.6.3 4.7.4 4.8.5 4.9.3 5.0.3 5.1.4 trunk 10.0 10.0.1 10.0.2 10.1 10.1.1 10.1.2 10.2 10.2.1 10.2.2 10.2.3 10.3 10.3.1 10.3.2 10.4 10.4.1 10.4.2 10.5 10.5.1 10.5.2 10.5.3 10.6 10.6.1 10.6.2 10.7 10.7.1 10.7.2 10.8 10.8.1 10.8.2 10.9 10.9.1 10.9.2 10.9.3 11.0 11.0.1 11.0.2 11.1 11.1.1 11.1.2 11.1.3 11.1.4 11.2 11.2.1 11.2.2 11.3 11.3.1 11.3.2 11.3.3 11.3.4 11.4 11.4.1 11.4.2 11.5 11.5.1 11.5.2 11.5.3 11.6 11.6.1 11.6.2 11.7 11.7.1 11.7.2 11.7.3 11.8 11.8.3 11.8.4 11.8.5 11.8.6 11.9 11.9.1 11.9.2 11.9.3 12.0 12.0.1 12.0.2 12.1 12.1.1 12.1.2 12.2 12.2.1 12.2.2 12.3 12.3.1 12.4 12.4.1 12.5 12.5.1 12.6 12.6.1 12.6.2 12.6.3 12.7 12.7.1 12.7.2 12.8 12.8.1 12.8.2 12.9 12.9.1 12.9.2 12.9.3 12.9.4 13.0 13.0.1 13.1 13.1.1 13.1.2 13.1.3 13.1.4 13.2 13.2.1 13.2.2 13.2.3 13.3 13.3.1 13.3.2 13.4 13.4.1 13.4.2 13.4.3 13.4.4 13.5 13.5.1 13.6 13.6.1 13.7 13.7.1 13.8 13.8.1 13.8.2 13.9 13.9.1 14.0 14.1 14.2 14.2.1 14.3 14.4 14.4.1 14.5 14.6 14.7 14.8 14.9 14.9.1 15.0 15.0.1 15.0.2 15.1 15.1.1 15.2 15.3 15.3.1 15.4 15.5 15.6 15.7 15.7-a.1 15.7-a.3 15.7-a.5 15.7-a.7 15.7-beta
jetpack / modules / theme-tools / content-options / customizer.php
jetpack / modules / theme-tools / content-options Last commit date
author-bio.php 2 years ago blog-display.php 2 years ago customizer.js 6 years ago customizer.php 2 years ago featured-images-fallback.php 2 years ago featured-images.php 2 years ago post-details.php 2 years ago
customizer.php
523 lines
1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 /**
3 * Theme Tools: functions for Customizer enhancements.
4 *
5 * @package automattic/jetpack
6 */
7
8 if ( ! function_exists( 'jetpack_content_options_customize_register' ) ) {
9
10 /**
11 * Add Content section to the Theme Customizer.
12 *
13 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
14 */
15 function jetpack_content_options_customize_register( $wp_customize ) {
16 $options = get_theme_support( 'jetpack-content-options' );
17 $blog_display = ( ! empty( $options[0]['blog-display'] ) ) ? $options[0]['blog-display'] : null;
18 $blog_display = preg_grep( '/^(content|excerpt)$/', (array) $blog_display );
19 sort( $blog_display );
20 $blog_display = implode( ', ', $blog_display );
21 $blog_display = ( 'content, excerpt' === $blog_display ) ? 'mixed' : $blog_display;
22 $author_bio = ( ! empty( $options[0]['author-bio'] ) ) ? $options[0]['author-bio'] : null;
23 $author_bio_default = ( isset( $options[0]['author-bio-default'] ) && false === $options[0]['author-bio-default'] ) ? '' : 1;
24 $post_details = ( ! empty( $options[0]['post-details'] ) ) ? $options[0]['post-details'] : null;
25 $date = ( ! empty( $post_details['date'] ) ) ? $post_details['date'] : null;
26 $categories = ( ! empty( $post_details['categories'] ) ) ? $post_details['categories'] : null;
27 $tags = ( ! empty( $post_details['tags'] ) ) ? $post_details['tags'] : null;
28 $author = ( ! empty( $post_details['author'] ) ) ? $post_details['author'] : null;
29 $comment = ( ! empty( $post_details['comment'] ) ) ? $post_details['comment'] : null;
30 $featured_images = ( ! empty( $options[0]['featured-images'] ) ) ? $options[0]['featured-images'] : null;
31 $fi_archive = ( ! empty( $featured_images['archive'] ) ) ? $featured_images['archive'] : null;
32 $fi_post = ( ! empty( $featured_images['post'] ) ) ? $featured_images['post'] : null;
33 $fi_page = ( ! empty( $featured_images['page'] ) ) ? $featured_images['page'] : null;
34 $fi_portfolio = ( ! empty( $featured_images['portfolio'] ) ) ? $featured_images['portfolio'] : null;
35 $fi_fallback = ( ! empty( $featured_images['fallback'] ) ) ? $featured_images['fallback'] : null;
36 $fi_archive_default = ( isset( $featured_images['archive-default'] ) && false === $featured_images['archive-default'] ) ? '' : 1;
37 $fi_post_default = ( isset( $featured_images['post-default'] ) && false === $featured_images['post-default'] ) ? '' : 1;
38 $fi_page_default = ( isset( $featured_images['page-default'] ) && false === $featured_images['page-default'] ) ? '' : 1;
39 $fi_portfolio_default = ( isset( $featured_images['portfolio-default'] ) && false === $featured_images['portfolio-default'] ) ? '' : 1;
40 $fi_fallback_default = ( isset( $featured_images['fallback-default'] ) && false === $featured_images['fallback-default'] ) ? '' : 1;
41
42 // If the theme doesn't support 'jetpack-content-options[ 'blog-display' ]', 'jetpack-content-options[ 'author-bio' ]', 'jetpack-content-options[ 'post-details' ]' and 'jetpack-content-options[ 'featured-images' ]', don't continue.
43 if ( ( ! in_array( $blog_display, array( 'content', 'excerpt', 'mixed' ), true ) )
44 && ( true !== $author_bio )
45 && ( ( empty( $post_details['stylesheet'] ) )
46 && ( empty( $date )
47 || empty( $categories )
48 || empty( $tags )
49 || empty( $author )
50 || empty( $comment ) ) )
51 && ( true !== $fi_archive && true !== $fi_post && true !== $fi_page && true !== $fi_portfolio && true !== $fi_fallback ) ) {
52 return;
53 }
54
55 if ( ! class_exists( 'Jetpack_Customize_Control_Title' ) ) {
56
57 /**
58 * New Customizer control type: Title.
59 */
60 class Jetpack_Customize_Control_Title extends WP_Customize_Control {
61 /**
62 * Customizer control type.
63 *
64 * @var string
65 */
66 public $type = 'title';
67
68 /**
69 * Render the control's content.
70 */
71 public function render_content() { // phpcs:ignore MediaWiki.Usage.NestedFunctions.NestedFunction
72 ?>
73 <span class="customize-control-title"><?php echo wp_kses_post( $this->label ); ?></span>
74 <?php
75 }
76 }
77
78 }
79
80 // Add Content section.
81 $wp_customize->add_section(
82 'jetpack_content_options',
83 array(
84 'title' => esc_html__( 'Content Options', 'jetpack' ),
85 'theme_supports' => 'jetpack-content-options',
86 'priority' => 100,
87 )
88 );
89
90 // Add Blog Display option.
91 if ( in_array( $blog_display, array( 'content', 'excerpt', 'mixed' ), true ) ) {
92 if ( 'mixed' === $blog_display ) {
93 $blog_display_choices = array(
94 'content' => esc_html__( 'Full post', 'jetpack' ),
95 'excerpt' => esc_html__( 'Post excerpt', 'jetpack' ),
96 'mixed' => esc_html__( 'Default', 'jetpack' ),
97 );
98
99 $blog_display_description = esc_html__( 'Choose between a full post or an excerpt for the blog and archive pages, or opt for the theme\'s default combination of excerpt and full post.', 'jetpack' );
100 } else {
101 $blog_display_choices = array(
102 'content' => esc_html__( 'Full post', 'jetpack' ),
103 'excerpt' => esc_html__( 'Post excerpt', 'jetpack' ),
104 );
105
106 $blog_display_description = esc_html__( 'Choose between a full post or an excerpt for the blog and archive pages.', 'jetpack' );
107
108 if ( 'mixed' === get_option( 'jetpack_content_blog_display' ) ) {
109 update_option( 'jetpack_content_blog_display', $blog_display );
110 }
111 }
112
113 $wp_customize->add_setting(
114 'jetpack_content_blog_display',
115 array(
116 'default' => $blog_display,
117 'type' => 'option',
118 'transport' => 'postMessage',
119 'sanitize_callback' => 'jetpack_content_options_sanitize_blog_display',
120 )
121 );
122
123 $wp_customize->add_control(
124 'jetpack_content_blog_display',
125 array(
126 'section' => 'jetpack_content_options',
127 'label' => esc_html__( 'Blog Display', 'jetpack' ),
128 'description' => $blog_display_description,
129 'type' => 'radio',
130 'choices' => $blog_display_choices,
131 )
132 );
133 }
134
135 // Add Author Bio option.
136 if ( true === $author_bio ) {
137 $wp_customize->add_setting( 'jetpack_content_author_bio_title' );
138
139 $wp_customize->add_control(
140 new Jetpack_Customize_Control_Title(
141 $wp_customize,
142 'jetpack_content_author_bio_title',
143 array(
144 'section' => 'jetpack_content_options',
145 'label' => esc_html__( 'Author Bio', 'jetpack' ),
146 'type' => 'title',
147 )
148 )
149 );
150
151 $wp_customize->add_setting(
152 'jetpack_content_author_bio',
153 array(
154 'default' => $author_bio_default,
155 'type' => 'option',
156 'sanitize_callback' => 'jetpack_content_options_sanitize_checkbox',
157 )
158 );
159
160 $wp_customize->add_control(
161 'jetpack_content_author_bio',
162 array(
163 'section' => 'jetpack_content_options',
164 'label' => esc_html__( 'Display on single posts', 'jetpack' ),
165 'type' => 'checkbox',
166 )
167 );
168 }
169
170 // Add Post Details options.
171 if ( ( ! empty( $post_details ) )
172 && ( ! empty( $post_details['stylesheet'] ) )
173 && ( ! empty( $date )
174 || ! empty( $categories )
175 || ! empty( $tags )
176 || ! empty( $author )
177 || ! empty( $comment ) ) ) {
178 $wp_customize->add_setting( 'jetpack_content_post_details_title' );
179
180 $wp_customize->add_control(
181 new Jetpack_Customize_Control_Title(
182 $wp_customize,
183 'jetpack_content_post_details_title',
184 array(
185 'section' => 'jetpack_content_options',
186 'label' => esc_html__( 'Post Details', 'jetpack' ),
187 'type' => 'title',
188 )
189 )
190 );
191
192 // Post Details: Date.
193 if ( ! empty( $date ) ) {
194 $wp_customize->add_setting(
195 'jetpack_content_post_details_date',
196 array(
197 'default' => 1,
198 'type' => 'option',
199 'transport' => 'postMessage',
200 'sanitize_callback' => 'jetpack_content_options_sanitize_checkbox',
201 )
202 );
203
204 $wp_customize->add_control(
205 'jetpack_content_post_details_date',
206 array(
207 'section' => 'jetpack_content_options',
208 'label' => esc_html__( 'Display date', 'jetpack' ),
209 'type' => 'checkbox',
210 )
211 );
212 }
213
214 // Post Details: Categories.
215 if ( ! empty( $categories ) ) {
216 $wp_customize->add_setting(
217 'jetpack_content_post_details_categories',
218 array(
219 'default' => 1,
220 'type' => 'option',
221 'transport' => 'postMessage',
222 'sanitize_callback' => 'jetpack_content_options_sanitize_checkbox',
223 )
224 );
225
226 $wp_customize->add_control(
227 'jetpack_content_post_details_categories',
228 array(
229 'section' => 'jetpack_content_options',
230 'label' => esc_html__( 'Display categories', 'jetpack' ),
231 'type' => 'checkbox',
232 )
233 );
234 }
235
236 // Post Details: Tags.
237 if ( ! empty( $tags ) ) {
238 $wp_customize->add_setting(
239 'jetpack_content_post_details_tags',
240 array(
241 'default' => 1,
242 'type' => 'option',
243 'transport' => 'postMessage',
244 'sanitize_callback' => 'jetpack_content_options_sanitize_checkbox',
245 )
246 );
247
248 $wp_customize->add_control(
249 'jetpack_content_post_details_tags',
250 array(
251 'section' => 'jetpack_content_options',
252 'label' => esc_html__( 'Display tags', 'jetpack' ),
253 'type' => 'checkbox',
254 )
255 );
256 }
257
258 // Post Details: Author.
259 if ( ! empty( $author ) ) {
260 $wp_customize->add_setting(
261 'jetpack_content_post_details_author',
262 array(
263 'default' => 1,
264 'type' => 'option',
265 'transport' => 'postMessage',
266 'sanitize_callback' => 'jetpack_content_options_sanitize_checkbox',
267 )
268 );
269
270 $wp_customize->add_control(
271 'jetpack_content_post_details_author',
272 array(
273 'section' => 'jetpack_content_options',
274 'label' => esc_html__( 'Display author', 'jetpack' ),
275 'type' => 'checkbox',
276 )
277 );
278 }
279
280 // Post Details: Comment link.
281 if ( ! empty( $comment ) ) {
282 $wp_customize->add_setting(
283 'jetpack_content_post_details_comment',
284 array(
285 'default' => 1,
286 'type' => 'option',
287 'transport' => 'postMessage',
288 'sanitize_callback' => 'jetpack_content_options_sanitize_checkbox',
289 )
290 );
291
292 $wp_customize->add_control(
293 'jetpack_content_post_details_comment',
294 array(
295 'section' => 'jetpack_content_options',
296 'label' => esc_html__( 'Display comment link', 'jetpack' ),
297 'type' => 'checkbox',
298 )
299 );
300 }
301 }
302
303 // Add Featured Images options.
304 if ( true === $fi_archive || true === $fi_post || true === $fi_page || true === $fi_portfolio || true === $fi_fallback ) {
305 $wp_customize->add_setting( 'jetpack_content_featured_images_title' );
306
307 $wp_customize->add_control(
308 new Jetpack_Customize_Control_Title(
309 $wp_customize,
310 'jetpack_content_featured_images_title',
311 array(
312 'section' => 'jetpack_content_options',
313 'label' => esc_html__( 'Featured Images', 'jetpack' ) . sprintf( '<a href="https://en.support.wordpress.com/featured-images/" class="customize-help-toggle dashicons dashicons-editor-help" title="%1$s" rel="noopener noreferrer" target="_blank"><span class="screen-reader-text">%1$s</span></a>', esc_html__( 'Learn more about Featured Images', 'jetpack' ) ),
314 'type' => 'title',
315 'active_callback' => 'jetpack_post_thumbnail_supports',
316 )
317 )
318 );
319
320 // Featured Images: Archive.
321 if ( true === $fi_archive ) {
322 $wp_customize->add_setting(
323 'jetpack_content_featured_images_archive',
324 array(
325 'default' => $fi_archive_default,
326 'type' => 'option',
327 'sanitize_callback' => 'jetpack_content_options_sanitize_checkbox',
328 )
329 );
330
331 $wp_customize->add_control(
332 'jetpack_content_featured_images_archive',
333 array(
334 'section' => 'jetpack_content_options',
335 'label' => esc_html__( 'Display on blog and archives', 'jetpack' ),
336 'type' => 'checkbox',
337 'active_callback' => 'jetpack_post_thumbnail_supports',
338 )
339 );
340 }
341
342 // Featured Images: Post.
343 if ( true === $fi_post ) {
344 $wp_customize->add_setting(
345 'jetpack_content_featured_images_post',
346 array(
347 'default' => $fi_post_default,
348 'type' => 'option',
349 'sanitize_callback' => 'jetpack_content_options_sanitize_checkbox',
350 )
351 );
352
353 $wp_customize->add_control(
354 'jetpack_content_featured_images_post',
355 array(
356 'section' => 'jetpack_content_options',
357 'label' => esc_html__( 'Display on single posts', 'jetpack' ),
358 'type' => 'checkbox',
359 'active_callback' => 'jetpack_post_thumbnail_supports',
360 )
361 );
362 }
363
364 // Featured Images: Page.
365 if ( true === $fi_page ) {
366 $wp_customize->add_setting(
367 'jetpack_content_featured_images_page',
368 array(
369 'default' => $fi_page_default,
370 'type' => 'option',
371 'sanitize_callback' => 'jetpack_content_options_sanitize_checkbox',
372 )
373 );
374
375 $wp_customize->add_control(
376 'jetpack_content_featured_images_page',
377 array(
378 'section' => 'jetpack_content_options',
379 'label' => esc_html__( 'Display on pages', 'jetpack' ),
380 'type' => 'checkbox',
381 'active_callback' => 'jetpack_post_thumbnail_supports',
382 )
383 );
384 }
385
386 // Featured Images: Portfolio.
387 if ( true === $fi_portfolio && post_type_exists( 'jetpack-portfolio' ) ) {
388 $wp_customize->add_setting(
389 'jetpack_content_featured_images_portfolio',
390 array(
391 'default' => $fi_portfolio_default,
392 'type' => 'option',
393 'sanitize_callback' => 'jetpack_content_options_sanitize_checkbox',
394 )
395 );
396
397 $wp_customize->add_control(
398 'jetpack_content_featured_images_portfolio',
399 array(
400 'section' => 'jetpack_content_options',
401 'label' => esc_html__( 'Display on single projects', 'jetpack' ),
402 'type' => 'checkbox',
403 'active_callback' => 'jetpack_post_thumbnail_supports',
404 )
405 );
406 }
407
408 // Featured Images: Fallback.
409 if ( true === $fi_fallback ) {
410 $wp_customize->add_setting(
411 'jetpack_content_featured_images_fallback',
412 array(
413 'default' => $fi_fallback_default,
414 'type' => 'option',
415 'sanitize_callback' => 'jetpack_content_options_sanitize_checkbox',
416 )
417 );
418
419 $wp_customize->add_control(
420 'jetpack_content_featured_images_fallback',
421 array(
422 'section' => 'jetpack_content_options',
423 'label' => esc_html__( 'Automatically use first image in post', 'jetpack' ),
424 'type' => 'checkbox',
425 'active_callback' => 'jetpack_post_thumbnail_supports',
426 )
427 );
428 }
429 }
430 }
431 add_action( 'customize_register', 'jetpack_content_options_customize_register' );
432
433 }
434
435 if ( ! function_exists( 'jetpack_post_thumbnail_supports' ) ) {
436
437 /**
438 * Return whether the theme supports Post Thumbnails.
439 */
440 function jetpack_post_thumbnail_supports() {
441 return ( current_theme_supports( 'post-thumbnails' ) );
442 }
443
444 }
445
446 if ( ! function_exists( 'jetpack_content_options_sanitize_checkbox' ) ) {
447
448 /**
449 * Sanitize the checkbox.
450 *
451 * @param int $input The unsanitized value from the setting.
452 * @return boolean|string
453 */
454 function jetpack_content_options_sanitize_checkbox( $input ) {
455 return ( 1 === (int) $input ) ? 1 : '';
456 }
457
458 }
459
460 if ( ! function_exists( 'jetpack_content_options_sanitize_blog_display' ) ) {
461
462 /**
463 * Sanitize the Display value.
464 *
465 * @param string $display The unsanitized value from the setting.
466 * @return string
467 */
468 function jetpack_content_options_sanitize_blog_display( $display ) {
469 if ( ! in_array( $display, array( 'content', 'excerpt', 'mixed' ), true ) ) {
470 $display = 'content';
471 }
472 return $display;
473 }
474
475 }
476
477 if ( ! function_exists( 'jetpack_content_options_customize_preview_js' ) ) {
478
479 /**
480 * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
481 */
482 function jetpack_content_options_customize_preview_js() {
483 $options = get_theme_support( 'jetpack-content-options' );
484 $blog_display = ( ! empty( $options[0]['blog-display'] ) ) ? $options[0]['blog-display'] : null;
485 $blog_display = preg_grep( '/^(content|excerpt)$/', (array) $blog_display );
486 sort( $blog_display );
487 $blog_display = implode( ', ', $blog_display );
488 $blog_display = ( 'content, excerpt' === $blog_display ) ? 'mixed' : $blog_display;
489 $masonry = ( ! empty( $options[0]['masonry'] ) ) ? $options[0]['masonry'] : null;
490 $post_details = ( ! empty( $options[0]['post-details'] ) ) ? $options[0]['post-details'] : null;
491 $date = ( ! empty( $post_details['date'] ) ) ? $post_details['date'] : null;
492 $categories = ( ! empty( $post_details['categories'] ) ) ? $post_details['categories'] : null;
493 $tags = ( ! empty( $post_details['tags'] ) ) ? $post_details['tags'] : null;
494 $author = ( ! empty( $post_details['author'] ) ) ? $post_details['author'] : null;
495 $comment = ( ! empty( $post_details['comment'] ) ) ? $post_details['comment'] : null;
496
497 wp_enqueue_script( 'jetpack-content-options-customizer', plugins_url( 'customizer.js', __FILE__ ), array( 'jquery', 'customize-preview' ), '1.0', true );
498
499 wp_localize_script(
500 'jetpack-content-options-customizer',
501 'blogDisplay',
502 array(
503 'display' => get_option( 'jetpack_content_blog_display', $blog_display ),
504 'masonry' => $masonry,
505 )
506 );
507
508 wp_localize_script(
509 'jetpack-content-options-customizer',
510 'postDetails',
511 array(
512 'date' => $date,
513 'categories' => $categories,
514 'tags' => $tags,
515 'author' => $author,
516 'comment' => $comment,
517 )
518 );
519 }
520 add_action( 'customize_preview_init', 'jetpack_content_options_customize_preview_js' );
521
522 }
523