Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 42 |
|
0.00% |
0 / 2 |
CRAP | n/a |
0 / 0 |
|
| twentynineteen__jetpack_setup | |
0.00% |
0 / 20 |
|
0.00% |
0 / 1 |
2 | |||
| twentynineteen_override_post_thumbnail | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
182 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Jetpack Compatibility File |
| 4 | * See: https://jetpack.com/ |
| 5 | * |
| 6 | * @package automattic/jetpack-classic-theme-helper |
| 7 | */ |
| 8 | |
| 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | exit( 0 ); |
| 11 | } |
| 12 | |
| 13 | /** |
| 14 | * Add Jetpack theme supports for Twenty Nineteen. |
| 15 | */ |
| 16 | function twentynineteen__jetpack_setup() { |
| 17 | |
| 18 | /** |
| 19 | * Add theme support for Responsive Videos. |
| 20 | */ |
| 21 | add_theme_support( 'jetpack-responsive-videos' ); |
| 22 | |
| 23 | /** |
| 24 | * Add theme support for Content Options. |
| 25 | */ |
| 26 | add_theme_support( |
| 27 | 'jetpack-content-options', |
| 28 | array( |
| 29 | 'blog-display' => array( 'content', 'excerpt' ), |
| 30 | 'post-details' => array( |
| 31 | 'stylesheet' => 'twentynineteen-style', |
| 32 | 'date' => '.posted-on', |
| 33 | 'categories' => '.cat-links', |
| 34 | 'tags' => '.tags-links', |
| 35 | 'author' => '.byline', |
| 36 | 'comment' => '.comments-link', |
| 37 | ), |
| 38 | 'featured-images' => array( |
| 39 | 'archive' => true, |
| 40 | 'post' => true, |
| 41 | 'page' => true, |
| 42 | ), |
| 43 | ) |
| 44 | ); |
| 45 | } |
| 46 | add_action( 'after_setup_theme', 'twentynineteen__jetpack_setup' ); |
| 47 | |
| 48 | if ( ! function_exists( 'twentynineteen_override_post_thumbnail' ) ) { |
| 49 | /** |
| 50 | * Alter featured-image default visibility for content-options. |
| 51 | */ |
| 52 | function twentynineteen_override_post_thumbnail() { |
| 53 | $options = get_theme_support( 'jetpack-content-options' ); |
| 54 | $featured_images = ( ! empty( $options[0]['featured-images'] ) ) ? $options[0]['featured-images'] : null; |
| 55 | |
| 56 | $settings = array( |
| 57 | 'post-default' => ( isset( $featured_images['post-default'] ) && false === $featured_images['post-default'] ) ? '' : 1, |
| 58 | 'page-default' => ( isset( $featured_images['page-default'] ) && false === $featured_images['page-default'] ) ? '' : 1, |
| 59 | ); |
| 60 | |
| 61 | $settings = array_merge( |
| 62 | $settings, |
| 63 | array( |
| 64 | 'post-option' => get_option( 'jetpack_content_featured_images_post', $settings['post-default'] ), |
| 65 | 'page-option' => get_option( 'jetpack_content_featured_images_page', $settings['page-default'] ), |
| 66 | ) |
| 67 | ); |
| 68 | |
| 69 | if ( ( ! $settings['post-option'] && is_single() ) |
| 70 | || ( ! $settings['page-option'] && is_singular() && is_page() ) ) { |
| 71 | return false; |
| 72 | } else { |
| 73 | return ! post_password_required() && ! is_attachment() && has_post_thumbnail(); |
| 74 | } |
| 75 | } |
| 76 | add_filter( 'twentynineteen_can_show_post_thumbnail', 'twentynineteen_override_post_thumbnail', 10, 2 ); |
| 77 | } |