From 61b86cdca5364dfb897bf90c39972cdc8c4f87e4 Mon Sep 17 00:00:00 2001 From: Profile Profile Date: Fri, 30 Jan 2026 12:55:59 +0300 Subject: [PATCH] new zaglushka --- functions.php | 19 +++++---- inc/replace_old_copyright.php | 74 +++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 7 deletions(-) create mode 100644 inc/replace_old_copyright.php diff --git a/functions.php b/functions.php index a317b10..51c5675 100644 --- a/functions.php +++ b/functions.php @@ -1,6 +1,6 @@ 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; +}