PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 7.6.2
Jetpack – WP Security, Backup, Speed, & Growth v7.6.2
16.3-a.3 16.3-a.1 16.2 16.2-beta 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 All 504 releases
jetpack / modules / theme-tools / content-options / featured-images.php

featured-images.php in Jetpack – WP Security, Backup, Speed, & Growth 7.6.2, at modules/theme-tools/content-options/featured-images.php

85 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 // Automatically return metadata if it's a PayPal product - we don't want to hide the Featured Image.
9 if ( 'jp_pay_product' === get_post_type( $object_id ) ) {
10 return $metadata;
11 }
12
13 // Return false if the archive option or singular option is unticked.
14 if (
15 ( true === $opts['archive']
16 && ( is_home() || is_archive() || is_search() )
17 && ! jetpack_is_shop_page()
18 && ! $opts['archive-option']
19 && ( isset( $meta_key )
20 && '_thumbnail_id' === $meta_key )
21 && in_the_loop()
22 )
23 || ( true === $opts['post']
24 && is_single()
25 && ! jetpack_is_product()
26 && ! $opts['post-option']
27 && ( isset( $meta_key )
28 && '_thumbnail_id' === $meta_key )
29 && in_the_loop()
30 )
31 || ( true === $opts['page']
32 && is_singular()
33 && is_page()
34 && ! $opts['page-option']
35 && ( isset( $meta_key )
36 && '_thumbnail_id' === $meta_key )
37 && in_the_loop()
38 )
39 || ( true === $opts['portfolio']
40 && post_type_exists( 'jetpack-portfolio' )
41 && is_singular( 'jetpack-portfolio' )
42 && ! $opts['portfolio-option']
43 && ( isset( $meta_key )
44 && '_thumbnail_id' === $meta_key )
45 && in_the_loop()
46 )
47 ) {
48 return false;
49 } else {
50 return $metadata;
51 }
52 }
53 add_filter( 'get_post_metadata', 'jetpack_featured_images_remove_post_thumbnail', true, 4 );
54
55 /**
56 * Check if we are in a WooCommerce Product in order to exclude it from the is_single check.
57 */
58 function jetpack_is_product() {
59 return ( function_exists( 'is_product' ) ) ? is_product() : false;
60 }
61
62 /**
63 * Check if we are in a WooCommerce Shop in order to exclude it from the is_archive check.
64 */
65 function jetpack_is_shop_page() {
66 // Check if WooCommerce is active first.
67 if ( ! class_exists( 'WooCommerce' ) ) {
68 return false;
69 }
70
71 global $wp_query;
72
73 $front_page_id = get_option( 'page_on_front' );
74 $current_page_id = $wp_query->get( 'page_id' );
75 $is_static_front_page = 'page' === get_option( 'show_on_front' );
76
77 if ( $is_static_front_page && $front_page_id === $current_page_id ) {
78 $is_shop_page = ( $current_page_id === wc_get_page_id( 'shop' ) ) ? true : false;
79 } else {
80 $is_shop_page = is_shop();
81 }
82
83 return $is_shop_page;
84 }
85