Completed
Push — master ( 7bd6e6...3a446e )
by
unknown
41s
created

featured-images.php ➔ jetpack_is_product()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * The function to prevent for Featured Images to be displayed in a theme.
4
 */
5
function jetpack_featured_images_remove_post_thumbnail( $metadata, $object_id, $meta_key, $single ) {
6
	$opts = jetpack_featured_images_get_settings();
7
8
	// Returns false if the archive option or singular option is unticked.
9
	if ( ( true === $opts['archive'] && ( is_home() || is_archive() || is_search() ) && ! $opts['archive-option'] && ( isset( $meta_key ) && '_thumbnail_id' === $meta_key ) && in_the_loop() )
10
		|| ( true === $opts['post'] && is_single() && ! jetpack_is_product() && ! $opts['post-option'] && ( isset( $meta_key ) && '_thumbnail_id' === $meta_key ) && in_the_loop() )
11
		|| ( true === $opts['page'] && is_singular() && is_page() && ! $opts['page-option'] && ( isset( $meta_key ) && '_thumbnail_id' === $meta_key ) && in_the_loop() ) ) {
12
		return false;
13
	} else {
14
		return $metadata;
15
	}
16
}
17
add_filter( 'get_post_metadata', 'jetpack_featured_images_remove_post_thumbnail', true, 4 );
18
19
/**
20
 * Check if we are in a WooCommerce Product in order to exclude it from the is_single check.
21
 */
22
function jetpack_is_product() {
23
	return ( function_exists( 'is_product' ) ) ? is_product() : false;
24
}
25