| @@ -55,9 +55,9 @@ | ||
| 55 | 55 | public function maybe_configure_cache_plugins() { |
| 56 | 56 | |
| 57 | 57 | // If no Pages, Posts or CPTs are configured to use Restrict Content, don't |
| 58 | 58 | // configure any caching plugins. |
| 59 | - if ( ! WP_ConvertKit()->get_class( 'admin_restrict_content' )->restrict_content_enabled() ) { | |
| 59 | + if ( ! $this->restrict_content_enabled() ) { | |
| 60 | 60 | return; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | $this->litespeed_cache(); |
| @@ -65,8 +65,43 @@ | ||
| 65 | 65 | $this->wp_fastest_cache(); |
| 66 | 66 | $this->wp_optimize(); |
| 67 | 67 | $this->wp_rocket(); |
| 68 | 68 | $this->wp_super_cache(); |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * Check if any Pages, Posts or CPTs are configured to use Restrict Content. | |
| 74 | + * | |
| 75 | + * @since 2.7.6 | |
| 76 | + * | |
| 77 | + * @return bool | |
| 78 | + */ | |
| 79 | + private function restrict_content_enabled() { | |
| 80 | + | |
| 81 | + // Check if any Pages, Posts or CPTs are configured to use Restrict Content. | |
| 82 | + $query = new WP_Query( | |
| 83 | + array( | |
| 84 | + 'post_type' => convertkit_get_supported_post_types(), | |
| 85 | + 'post_status' => 'publish', | |
| 86 | + 'meta_query' => array( | |
| 87 | + array( | |
| 88 | + 'key' => '_wp_convertkit_post_meta', | |
| 89 | + 'value' => '"restrict_content";', | |
| 90 | + 'compare' => 'LIKE', | |
| 91 | + ), | |
| 92 | + array( | |
| 93 | + 'key' => '_wp_convertkit_post_meta', | |
| 94 | + 'value' => '"restrict_content";s:1:"0"', | |
| 95 | + 'compare' => 'NOT LIKE', | |
| 96 | + ), | |
| 97 | + ), | |
| 98 | + 'posts_per_page' => 1, | |
| 99 | + 'fields' => 'ids', | |
| 100 | + ) | |
| 101 | + ); | |
| 102 | + | |
| 103 | + return $query->have_posts(); | |
| 69 | 104 | |
| 70 | 105 | } |
| 71 | 106 | |
| 72 | 107 | /** |