new zaglushka
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
//ini_set('display_errors', 0);
|
//ini_set('display_errors', 1);
|
||||||
//error_reporting(E_ALL);
|
//error_reporting(E_ERROR);
|
||||||
|
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
|
|
||||||
@@ -12,10 +12,9 @@ require "inc/cache-cleaner-home.php";
|
|||||||
require 'inc/article-rss-feed.php'; //rss ленты статей по датам
|
require 'inc/article-rss-feed.php'; //rss ленты статей по датам
|
||||||
require "inc/meta_keywords.php";
|
require "inc/meta_keywords.php";
|
||||||
require "inc/journal_issue.php"; //номера журналов
|
require "inc/journal_issue.php"; //номера журналов
|
||||||
require "inc/rank-description.php";
|
require "inc/rank-description.php"; //подменяем дескрипшт от соцсетей
|
||||||
|
|
||||||
//utils
|
require "inc/replace_old_copyright.php"; //подменяем фото для старых картинок с "плохим" копирайтом
|
||||||
require "utils/acf-category.php";
|
|
||||||
|
|
||||||
//scheduler
|
//scheduler
|
||||||
require "inc/schedule_async_post_processing.php";
|
require "inc/schedule_async_post_processing.php";
|
||||||
@@ -26,7 +25,6 @@ if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
include "inc/get_cached_alm.php";
|
include "inc/get_cached_alm.php";
|
||||||
include "inc/graphql.php";
|
|
||||||
|
|
||||||
if (is_admin()) {
|
if (is_admin()) {
|
||||||
require "inc/add_adv_checked.php"; // рекламная статья
|
require "inc/add_adv_checked.php"; // рекламная статья
|
||||||
@@ -2351,7 +2349,7 @@ add_action('wp_head', function() {
|
|||||||
if (!is_singular()) return;
|
if (!is_singular()) return;
|
||||||
|
|
||||||
$post_id = get_the_ID();
|
$post_id = get_the_ID();
|
||||||
$default_image = 'https://cdn.profile.ru/wp-content/uploads/2023/07/profile_lazyload_hq.jpg'; // Заглушка в папке темы
|
$default_image = 'https://cdn.profile.ru/wp-content/uploads/2026/01/zaglushka.jpg'; // Заглушка в папке темы
|
||||||
|
|
||||||
$og_image = esc_url($default_image);
|
$og_image = esc_url($default_image);
|
||||||
|
|
||||||
@@ -6111,6 +6109,13 @@ add_filter( 'http_request_args',
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
74
inc/replace_old_copyright.php
Normal file
74
inc/replace_old_copyright.php
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Фильтр для удаления заглавных изображений с влиянием на OpenGraph
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Глобальный массив для хранения ID постов где удалили изображение
|
||||||
|
$GLOBALS['removed_featured_images'] = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Основной фильтр - удаление изображения
|
||||||
|
*/
|
||||||
|
add_filter('post_thumbnail_id', 'filter_featured_image_if_old_and_copyright', 999, 2);
|
||||||
|
function filter_featured_image_if_old_and_copyright($thumb_id, $post) {
|
||||||
|
// Быстрый выход если нет ID
|
||||||
|
if (!$thumb_id) {
|
||||||
|
return $thumb_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Определяем ID поста
|
||||||
|
$post_id = is_object($post) ? $post->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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user