author-bio.php
1 year ago
blog-display.php
1 year ago
customizer.js
1 year ago
customizer.php
1 year ago
featured-images-fallback.php
1 year ago
featured-images.php
1 year ago
post-details.php
1 year ago
customizer.php
536 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 | * @deprecated 13.9 Moved to Classic Theme Helper package. |
| 14 | * |
| 15 | * @param WP_Customize_Manager $wp_customize Theme Customizer object. |
| 16 | */ |
| 17 | function jetpack_content_options_customize_register( $wp_customize ) { |
| 18 | _deprecated_function( __FUNCTION__, 'jetpack-13.9' ); |
| 19 | $options = get_theme_support( 'jetpack-content-options' ); |
| 20 | $blog_display = ( ! empty( $options[0]['blog-display'] ) ) ? $options[0]['blog-display'] : null; |
| 21 | $blog_display = preg_grep( '/^(content|excerpt)$/', (array) $blog_display ); |
| 22 | sort( $blog_display ); |
| 23 | $blog_display = implode( ', ', $blog_display ); |
| 24 | $blog_display = ( 'content, excerpt' === $blog_display ) ? 'mixed' : $blog_display; |
| 25 | $author_bio = ( ! empty( $options[0]['author-bio'] ) ) ? $options[0]['author-bio'] : null; |
| 26 | $author_bio_default = ( isset( $options[0]['author-bio-default'] ) && false === $options[0]['author-bio-default'] ) ? '' : 1; |
| 27 | $post_details = ( ! empty( $options[0]['post-details'] ) ) ? $options[0]['post-details'] : null; |
| 28 | $date = ( ! empty( $post_details['date'] ) ) ? $post_details['date'] : null; |
| 29 | $categories = ( ! empty( $post_details['categories'] ) ) ? $post_details['categories'] : null; |
| 30 | $tags = ( ! empty( $post_details['tags'] ) ) ? $post_details['tags'] : null; |
| 31 | $author = ( ! empty( $post_details['author'] ) ) ? $post_details['author'] : null; |
| 32 | $comment = ( ! empty( $post_details['comment'] ) ) ? $post_details['comment'] : null; |
| 33 | $featured_images = ( ! empty( $options[0]['featured-images'] ) ) ? $options[0]['featured-images'] : null; |
| 34 | $fi_archive = ( ! empty( $featured_images['archive'] ) ) ? $featured_images['archive'] : null; |
| 35 | $fi_post = ( ! empty( $featured_images['post'] ) ) ? $featured_images['post'] : null; |
| 36 | $fi_page = ( ! empty( $featured_images['page'] ) ) ? $featured_images['page'] : null; |
| 37 | $fi_portfolio = ( ! empty( $featured_images['portfolio'] ) ) ? $featured_images['portfolio'] : null; |
| 38 | $fi_fallback = ( ! empty( $featured_images['fallback'] ) ) ? $featured_images['fallback'] : null; |
| 39 | $fi_archive_default = ( isset( $featured_images['archive-default'] ) && false === $featured_images['archive-default'] ) ? '' : 1; |
| 40 | $fi_post_default = ( isset( $featured_images['post-default'] ) && false === $featured_images['post-default'] ) ? '' : 1; |
| 41 | $fi_page_default = ( isset( $featured_images['page-default'] ) && false === $featured_images['page-default'] ) ? '' : 1; |
| 42 | $fi_portfolio_default = ( isset( $featured_images['portfolio-default'] ) && false === $featured_images['portfolio-default'] ) ? '' : 1; |
| 43 | $fi_fallback_default = ( isset( $featured_images['fallback-default'] ) && false === $featured_images['fallback-default'] ) ? '' : 1; |
| 44 | |
| 45 | // 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. |
| 46 | if ( ( ! in_array( $blog_display, array( 'content', 'excerpt', 'mixed' ), true ) ) |
| 47 | && ( true !== $author_bio ) |
| 48 | && ( ( empty( $post_details['stylesheet'] ) ) |
| 49 | && ( empty( $date ) |
| 50 | || empty( $categories ) |
| 51 | || empty( $tags ) |
| 52 | || empty( $author ) |
| 53 | || empty( $comment ) ) ) |
| 54 | && ( true !== $fi_archive && true !== $fi_post && true !== $fi_page && true !== $fi_portfolio && true !== $fi_fallback ) ) { |
| 55 | return; |
| 56 | } |
| 57 | |
| 58 | if ( ! class_exists( 'Jetpack_Customize_Control_Title' ) ) { |
| 59 | |
| 60 | /** |
| 61 | * New Customizer control type: Title. |
| 62 | */ |
| 63 | class Jetpack_Customize_Control_Title extends WP_Customize_Control { |
| 64 | /** |
| 65 | * Customizer control type. |
| 66 | * |
| 67 | * @var string |
| 68 | */ |
| 69 | public $type = 'title'; |
| 70 | |
| 71 | /** |
| 72 | * Render the control's content. |
| 73 | */ |
| 74 | public function render_content() { // phpcs:ignore MediaWiki.Usage.NestedFunctions.NestedFunction |
| 75 | ?> |
| 76 | <span class="customize-control-title"><?php echo wp_kses_post( $this->label ); ?></span> |
| 77 | <?php |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | } |
| 82 | |
| 83 | // Add Content section. |
| 84 | $wp_customize->add_section( |
| 85 | 'jetpack_content_options', |
| 86 | array( |
| 87 | 'title' => esc_html__( 'Content Options', 'jetpack' ), |
| 88 | 'theme_supports' => 'jetpack-content-options', |
| 89 | 'priority' => 100, |
| 90 | ) |
| 91 | ); |
| 92 | |
| 93 | // Add Blog Display option. |
| 94 | if ( in_array( $blog_display, array( 'content', 'excerpt', 'mixed' ), true ) ) { |
| 95 | if ( 'mixed' === $blog_display ) { |
| 96 | $blog_display_choices = array( |
| 97 | 'content' => esc_html__( 'Full post', 'jetpack' ), |
| 98 | 'excerpt' => esc_html__( 'Post excerpt', 'jetpack' ), |
| 99 | 'mixed' => esc_html__( 'Default', 'jetpack' ), |
| 100 | ); |
| 101 | |
| 102 | $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' ); |
| 103 | } else { |
| 104 | $blog_display_choices = array( |
| 105 | 'content' => esc_html__( 'Full post', 'jetpack' ), |
| 106 | 'excerpt' => esc_html__( 'Post excerpt', 'jetpack' ), |
| 107 | ); |
| 108 | |
| 109 | $blog_display_description = esc_html__( 'Choose between a full post or an excerpt for the blog and archive pages.', 'jetpack' ); |
| 110 | |
| 111 | if ( 'mixed' === get_option( 'jetpack_content_blog_display' ) ) { |
| 112 | update_option( 'jetpack_content_blog_display', $blog_display ); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | $wp_customize->add_setting( |
| 117 | 'jetpack_content_blog_display', |
| 118 | array( |
| 119 | 'default' => $blog_display, |
| 120 | 'type' => 'option', |
| 121 | 'transport' => 'postMessage', |
| 122 | 'sanitize_callback' => 'jetpack_content_options_sanitize_blog_display', |
| 123 | ) |
| 124 | ); |
| 125 | |
| 126 | $wp_customize->add_control( |
| 127 | 'jetpack_content_blog_display', |
| 128 | array( |
| 129 | 'section' => 'jetpack_content_options', |
| 130 | 'label' => esc_html__( 'Blog Display', 'jetpack' ), |
| 131 | 'description' => $blog_display_description, |
| 132 | 'type' => 'radio', |
| 133 | 'choices' => $blog_display_choices, |
| 134 | ) |
| 135 | ); |
| 136 | } |
| 137 | |
| 138 | // Add Author Bio option. |
| 139 | if ( true === $author_bio ) { |
| 140 | $wp_customize->add_setting( 'jetpack_content_author_bio_title' ); |
| 141 | |
| 142 | $wp_customize->add_control( |
| 143 | new Jetpack_Customize_Control_Title( |
| 144 | $wp_customize, |
| 145 | 'jetpack_content_author_bio_title', |
| 146 | array( |
| 147 | 'section' => 'jetpack_content_options', |
| 148 | 'label' => esc_html__( 'Author Bio', 'jetpack' ), |
| 149 | 'type' => 'title', |
| 150 | ) |
| 151 | ) |
| 152 | ); |
| 153 | |
| 154 | $wp_customize->add_setting( |
| 155 | 'jetpack_content_author_bio', |
| 156 | array( |
| 157 | 'default' => $author_bio_default, |
| 158 | 'type' => 'option', |
| 159 | 'sanitize_callback' => 'jetpack_content_options_sanitize_checkbox', |
| 160 | ) |
| 161 | ); |
| 162 | |
| 163 | $wp_customize->add_control( |
| 164 | 'jetpack_content_author_bio', |
| 165 | array( |
| 166 | 'section' => 'jetpack_content_options', |
| 167 | 'label' => esc_html__( 'Display on single posts', 'jetpack' ), |
| 168 | 'type' => 'checkbox', |
| 169 | ) |
| 170 | ); |
| 171 | } |
| 172 | |
| 173 | // Add Post Details options. |
| 174 | if ( ( ! empty( $post_details ) ) |
| 175 | && ( ! empty( $post_details['stylesheet'] ) ) |
| 176 | && ( ! empty( $date ) |
| 177 | || ! empty( $categories ) |
| 178 | || ! empty( $tags ) |
| 179 | || ! empty( $author ) |
| 180 | || ! empty( $comment ) ) ) { |
| 181 | $wp_customize->add_setting( 'jetpack_content_post_details_title' ); |
| 182 | |
| 183 | $wp_customize->add_control( |
| 184 | new Jetpack_Customize_Control_Title( |
| 185 | $wp_customize, |
| 186 | 'jetpack_content_post_details_title', |
| 187 | array( |
| 188 | 'section' => 'jetpack_content_options', |
| 189 | 'label' => esc_html__( 'Post Details', 'jetpack' ), |
| 190 | 'type' => 'title', |
| 191 | ) |
| 192 | ) |
| 193 | ); |
| 194 | |
| 195 | // Post Details: Date. |
| 196 | if ( ! empty( $date ) ) { |
| 197 | $wp_customize->add_setting( |
| 198 | 'jetpack_content_post_details_date', |
| 199 | array( |
| 200 | 'default' => 1, |
| 201 | 'type' => 'option', |
| 202 | 'transport' => 'postMessage', |
| 203 | 'sanitize_callback' => 'jetpack_content_options_sanitize_checkbox', |
| 204 | ) |
| 205 | ); |
| 206 | |
| 207 | $wp_customize->add_control( |
| 208 | 'jetpack_content_post_details_date', |
| 209 | array( |
| 210 | 'section' => 'jetpack_content_options', |
| 211 | 'label' => esc_html__( 'Display date', 'jetpack' ), |
| 212 | 'type' => 'checkbox', |
| 213 | ) |
| 214 | ); |
| 215 | } |
| 216 | |
| 217 | // Post Details: Categories. |
| 218 | if ( ! empty( $categories ) ) { |
| 219 | $wp_customize->add_setting( |
| 220 | 'jetpack_content_post_details_categories', |
| 221 | array( |
| 222 | 'default' => 1, |
| 223 | 'type' => 'option', |
| 224 | 'transport' => 'postMessage', |
| 225 | 'sanitize_callback' => 'jetpack_content_options_sanitize_checkbox', |
| 226 | ) |
| 227 | ); |
| 228 | |
| 229 | $wp_customize->add_control( |
| 230 | 'jetpack_content_post_details_categories', |
| 231 | array( |
| 232 | 'section' => 'jetpack_content_options', |
| 233 | 'label' => esc_html__( 'Display categories', 'jetpack' ), |
| 234 | 'type' => 'checkbox', |
| 235 | ) |
| 236 | ); |
| 237 | } |
| 238 | |
| 239 | // Post Details: Tags. |
| 240 | if ( ! empty( $tags ) ) { |
| 241 | $wp_customize->add_setting( |
| 242 | 'jetpack_content_post_details_tags', |
| 243 | array( |
| 244 | 'default' => 1, |
| 245 | 'type' => 'option', |
| 246 | 'transport' => 'postMessage', |
| 247 | 'sanitize_callback' => 'jetpack_content_options_sanitize_checkbox', |
| 248 | ) |
| 249 | ); |
| 250 | |
| 251 | $wp_customize->add_control( |
| 252 | 'jetpack_content_post_details_tags', |
| 253 | array( |
| 254 | 'section' => 'jetpack_content_options', |
| 255 | 'label' => esc_html__( 'Display tags', 'jetpack' ), |
| 256 | 'type' => 'checkbox', |
| 257 | ) |
| 258 | ); |
| 259 | } |
| 260 | |
| 261 | // Post Details: Author. |
| 262 | if ( ! empty( $author ) ) { |
| 263 | $wp_customize->add_setting( |
| 264 | 'jetpack_content_post_details_author', |
| 265 | array( |
| 266 | 'default' => 1, |
| 267 | 'type' => 'option', |
| 268 | 'transport' => 'postMessage', |
| 269 | 'sanitize_callback' => 'jetpack_content_options_sanitize_checkbox', |
| 270 | ) |
| 271 | ); |
| 272 | |
| 273 | $wp_customize->add_control( |
| 274 | 'jetpack_content_post_details_author', |
| 275 | array( |
| 276 | 'section' => 'jetpack_content_options', |
| 277 | 'label' => esc_html__( 'Display author', 'jetpack' ), |
| 278 | 'type' => 'checkbox', |
| 279 | ) |
| 280 | ); |
| 281 | } |
| 282 | |
| 283 | // Post Details: Comment link. |
| 284 | if ( ! empty( $comment ) ) { |
| 285 | $wp_customize->add_setting( |
| 286 | 'jetpack_content_post_details_comment', |
| 287 | array( |
| 288 | 'default' => 1, |
| 289 | 'type' => 'option', |
| 290 | 'transport' => 'postMessage', |
| 291 | 'sanitize_callback' => 'jetpack_content_options_sanitize_checkbox', |
| 292 | ) |
| 293 | ); |
| 294 | |
| 295 | $wp_customize->add_control( |
| 296 | 'jetpack_content_post_details_comment', |
| 297 | array( |
| 298 | 'section' => 'jetpack_content_options', |
| 299 | 'label' => esc_html__( 'Display comment link', 'jetpack' ), |
| 300 | 'type' => 'checkbox', |
| 301 | ) |
| 302 | ); |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | // Add Featured Images options. |
| 307 | if ( true === $fi_archive || true === $fi_post || true === $fi_page || true === $fi_portfolio || true === $fi_fallback ) { |
| 308 | $wp_customize->add_setting( 'jetpack_content_featured_images_title' ); |
| 309 | |
| 310 | $wp_customize->add_control( |
| 311 | new Jetpack_Customize_Control_Title( |
| 312 | $wp_customize, |
| 313 | 'jetpack_content_featured_images_title', |
| 314 | array( |
| 315 | 'section' => 'jetpack_content_options', |
| 316 | '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' ) ), |
| 317 | 'type' => 'title', |
| 318 | 'active_callback' => 'jetpack_post_thumbnail_supports', |
| 319 | ) |
| 320 | ) |
| 321 | ); |
| 322 | |
| 323 | // Featured Images: Archive. |
| 324 | if ( true === $fi_archive ) { |
| 325 | $wp_customize->add_setting( |
| 326 | 'jetpack_content_featured_images_archive', |
| 327 | array( |
| 328 | 'default' => $fi_archive_default, |
| 329 | 'type' => 'option', |
| 330 | 'sanitize_callback' => 'jetpack_content_options_sanitize_checkbox', |
| 331 | ) |
| 332 | ); |
| 333 | |
| 334 | $wp_customize->add_control( |
| 335 | 'jetpack_content_featured_images_archive', |
| 336 | array( |
| 337 | 'section' => 'jetpack_content_options', |
| 338 | 'label' => esc_html__( 'Display on blog and archives', 'jetpack' ), |
| 339 | 'type' => 'checkbox', |
| 340 | 'active_callback' => 'jetpack_post_thumbnail_supports', |
| 341 | ) |
| 342 | ); |
| 343 | } |
| 344 | |
| 345 | // Featured Images: Post. |
| 346 | if ( true === $fi_post ) { |
| 347 | $wp_customize->add_setting( |
| 348 | 'jetpack_content_featured_images_post', |
| 349 | array( |
| 350 | 'default' => $fi_post_default, |
| 351 | 'type' => 'option', |
| 352 | 'sanitize_callback' => 'jetpack_content_options_sanitize_checkbox', |
| 353 | ) |
| 354 | ); |
| 355 | |
| 356 | $wp_customize->add_control( |
| 357 | 'jetpack_content_featured_images_post', |
| 358 | array( |
| 359 | 'section' => 'jetpack_content_options', |
| 360 | 'label' => esc_html__( 'Display on single posts', 'jetpack' ), |
| 361 | 'type' => 'checkbox', |
| 362 | 'active_callback' => 'jetpack_post_thumbnail_supports', |
| 363 | ) |
| 364 | ); |
| 365 | } |
| 366 | |
| 367 | // Featured Images: Page. |
| 368 | if ( true === $fi_page ) { |
| 369 | $wp_customize->add_setting( |
| 370 | 'jetpack_content_featured_images_page', |
| 371 | array( |
| 372 | 'default' => $fi_page_default, |
| 373 | 'type' => 'option', |
| 374 | 'sanitize_callback' => 'jetpack_content_options_sanitize_checkbox', |
| 375 | ) |
| 376 | ); |
| 377 | |
| 378 | $wp_customize->add_control( |
| 379 | 'jetpack_content_featured_images_page', |
| 380 | array( |
| 381 | 'section' => 'jetpack_content_options', |
| 382 | 'label' => esc_html__( 'Display on pages', 'jetpack' ), |
| 383 | 'type' => 'checkbox', |
| 384 | 'active_callback' => 'jetpack_post_thumbnail_supports', |
| 385 | ) |
| 386 | ); |
| 387 | } |
| 388 | |
| 389 | // Featured Images: Portfolio. |
| 390 | if ( true === $fi_portfolio && post_type_exists( 'jetpack-portfolio' ) ) { |
| 391 | $wp_customize->add_setting( |
| 392 | 'jetpack_content_featured_images_portfolio', |
| 393 | array( |
| 394 | 'default' => $fi_portfolio_default, |
| 395 | 'type' => 'option', |
| 396 | 'sanitize_callback' => 'jetpack_content_options_sanitize_checkbox', |
| 397 | ) |
| 398 | ); |
| 399 | |
| 400 | $wp_customize->add_control( |
| 401 | 'jetpack_content_featured_images_portfolio', |
| 402 | array( |
| 403 | 'section' => 'jetpack_content_options', |
| 404 | 'label' => esc_html__( 'Display on single projects', 'jetpack' ), |
| 405 | 'type' => 'checkbox', |
| 406 | 'active_callback' => 'jetpack_post_thumbnail_supports', |
| 407 | ) |
| 408 | ); |
| 409 | } |
| 410 | |
| 411 | // Featured Images: Fallback. |
| 412 | if ( true === $fi_fallback ) { |
| 413 | $wp_customize->add_setting( |
| 414 | 'jetpack_content_featured_images_fallback', |
| 415 | array( |
| 416 | 'default' => $fi_fallback_default, |
| 417 | 'type' => 'option', |
| 418 | 'sanitize_callback' => 'jetpack_content_options_sanitize_checkbox', |
| 419 | ) |
| 420 | ); |
| 421 | |
| 422 | $wp_customize->add_control( |
| 423 | 'jetpack_content_featured_images_fallback', |
| 424 | array( |
| 425 | 'section' => 'jetpack_content_options', |
| 426 | 'label' => esc_html__( 'Automatically use first image in post', 'jetpack' ), |
| 427 | 'type' => 'checkbox', |
| 428 | 'active_callback' => 'jetpack_post_thumbnail_supports', |
| 429 | ) |
| 430 | ); |
| 431 | } |
| 432 | } |
| 433 | } |
| 434 | add_action( 'customize_register', 'jetpack_content_options_customize_register' ); |
| 435 | |
| 436 | } |
| 437 | |
| 438 | if ( ! function_exists( 'jetpack_post_thumbnail_supports' ) ) { |
| 439 | |
| 440 | /** |
| 441 | * Return whether the theme supports Post Thumbnails. |
| 442 | * |
| 443 | * @deprecated 13.9 Moved to Classic Theme Helper package. |
| 444 | */ |
| 445 | function jetpack_post_thumbnail_supports() { |
| 446 | _deprecated_function( __FUNCTION__, 'jetpack-13.9' ); |
| 447 | return ( current_theme_supports( 'post-thumbnails' ) ); |
| 448 | } |
| 449 | |
| 450 | } |
| 451 | |
| 452 | if ( ! function_exists( 'jetpack_content_options_sanitize_checkbox' ) ) { |
| 453 | |
| 454 | /** |
| 455 | * Sanitize the checkbox. |
| 456 | * |
| 457 | * @deprecated 13.9 Moved to Classic Theme Helper package. |
| 458 | * @param int $input The unsanitized value from the setting. |
| 459 | * @return boolean|string |
| 460 | */ |
| 461 | function jetpack_content_options_sanitize_checkbox( $input ) { |
| 462 | _deprecated_function( __FUNCTION__, 'jetpack-13.9' ); |
| 463 | return ( 1 === (int) $input ) ? 1 : ''; |
| 464 | } |
| 465 | |
| 466 | } |
| 467 | |
| 468 | if ( ! function_exists( 'jetpack_content_options_sanitize_blog_display' ) ) { |
| 469 | |
| 470 | /** |
| 471 | * Sanitize the Display value. |
| 472 | * |
| 473 | * @deprecated 13.9 Moved to Classic Theme Helper package. |
| 474 | * @param string $display The unsanitized value from the setting. |
| 475 | * @return string |
| 476 | */ |
| 477 | function jetpack_content_options_sanitize_blog_display( $display ) { |
| 478 | _deprecated_function( __FUNCTION__, 'jetpack-13.9' ); |
| 479 | if ( ! in_array( $display, array( 'content', 'excerpt', 'mixed' ), true ) ) { |
| 480 | $display = 'content'; |
| 481 | } |
| 482 | return $display; |
| 483 | } |
| 484 | |
| 485 | } |
| 486 | |
| 487 | if ( ! function_exists( 'jetpack_content_options_customize_preview_js' ) ) { |
| 488 | |
| 489 | /** |
| 490 | * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. |
| 491 | * |
| 492 | * @deprecated 13.9 Moved to Classic Theme Helper package. |
| 493 | */ |
| 494 | function jetpack_content_options_customize_preview_js() { |
| 495 | _deprecated_function( __FUNCTION__, 'jetpack-13.9' ); |
| 496 | $options = get_theme_support( 'jetpack-content-options' ); |
| 497 | $blog_display = ( ! empty( $options[0]['blog-display'] ) ) ? $options[0]['blog-display'] : null; |
| 498 | $blog_display = preg_grep( '/^(content|excerpt)$/', (array) $blog_display ); |
| 499 | sort( $blog_display ); |
| 500 | $blog_display = implode( ', ', $blog_display ); |
| 501 | $blog_display = ( 'content, excerpt' === $blog_display ) ? 'mixed' : $blog_display; |
| 502 | $masonry = ( ! empty( $options[0]['masonry'] ) ) ? $options[0]['masonry'] : null; |
| 503 | $post_details = ( ! empty( $options[0]['post-details'] ) ) ? $options[0]['post-details'] : null; |
| 504 | $date = ( ! empty( $post_details['date'] ) ) ? $post_details['date'] : null; |
| 505 | $categories = ( ! empty( $post_details['categories'] ) ) ? $post_details['categories'] : null; |
| 506 | $tags = ( ! empty( $post_details['tags'] ) ) ? $post_details['tags'] : null; |
| 507 | $author = ( ! empty( $post_details['author'] ) ) ? $post_details['author'] : null; |
| 508 | $comment = ( ! empty( $post_details['comment'] ) ) ? $post_details['comment'] : null; |
| 509 | |
| 510 | wp_enqueue_script( 'jetpack-content-options-customizer', plugins_url( 'customizer.js', __FILE__ ), array( 'jquery', 'customize-preview' ), '1.0', true ); |
| 511 | |
| 512 | wp_localize_script( |
| 513 | 'jetpack-content-options-customizer', |
| 514 | 'blogDisplay', |
| 515 | array( |
| 516 | 'display' => get_option( 'jetpack_content_blog_display', $blog_display ), |
| 517 | 'masonry' => $masonry, |
| 518 | ) |
| 519 | ); |
| 520 | |
| 521 | wp_localize_script( |
| 522 | 'jetpack-content-options-customizer', |
| 523 | 'postDetails', |
| 524 | array( |
| 525 | 'date' => $date, |
| 526 | 'categories' => $categories, |
| 527 | 'tags' => $tags, |
| 528 | 'author' => $author, |
| 529 | 'comment' => $comment, |
| 530 | ) |
| 531 | ); |
| 532 | } |
| 533 | add_action( 'customize_preview_init', 'jetpack_content_options_customize_preview_js' ); |
| 534 | |
| 535 | } |
| 536 |