ID : (is_numeric($post) ? $post : 0); if (!$post_id) return $thumb_id; // Проверяем тип записи $post_type = get_post_type($post_id); if (!in_array($post_type, array('profile_article', 'anew', 'yellow'))) { return $thumb_id; } // Получаем дату загрузки изображения $attachment = get_post($thumb_id); if (!$attachment) return $thumb_id; // Проверяем дату (изображения до 2024 года) if (strtotime($attachment->post_date) >= strtotime('2024-01-01')) { return $thumb_id; } // Проверяем на наличие копирайтов $text = strtolower($attachment->post_excerpt . ' ' . $attachment->post_content . ' ' . $attachment->post_title); if (stripos($text, 'shutterstock') !== false || stripos($text, 'fotodom') !== false) { // Запоминаем что для этого поста удалили изображение $GLOBALS['removed_featured_images'][$post_id] = true; // Возвращаем false - изображение удалено return false; } return $thumb_id; } /** * 4. Фильтр для Rank Math OpenGraph */ add_filter('rank_math/opengraph/facebook/image', 'filter_rankmath_opengraph', 10, 1); add_filter('rank_math/opengraph/twitter/image', 'filter_rankmath_opengraph', 10, 1); function filter_rankmath_opengraph($image_url) { global $post; if (!is_object($post) || !isset($post->ID)) { return $image_url; } if (isset($GLOBALS['removed_featured_images'][$post->ID])) { return ''; // Удаляем изображение } return $image_url; }