diff --git a/block-cache-manager.php b/block-cache-manager.php new file mode 100644 index 0000000..fef11eb --- /dev/null +++ b/block-cache-manager.php @@ -0,0 +1,112 @@ +post_type == 'profile_article') { + clear_template_cache('template-parts/home/list-items'); + clear_template_cache('template-parts/home/main-item'); + clear_template_cache('template-parts/home/colon-item'); + + } elseif ($post->post_type == 'anew' || $post->post_type == 'yellow') { + clear_template_cache('template-parts/home/news'); + } + + // Сброс главной + $main_item = get_post_meta($post_id, 'main_item', true); + if ($main_item === 'true' || $main_item === '1') { + clear_template_cache('template-parts/home/main-item'); + } + + // Сброс колонки + $colon_item = get_post_meta($post_id, 'colon_item', true); + if ($colon_item === 'true' || $colon_item === '1') { + clear_template_cache('template-parts/home/colon-item'); + } + +} + +// Хук для обычного сохранения +add_action('save_post', function($post_id, $post, $update) { + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return; + if (wp_is_post_revision($post_id)) return; + if (!current_user_can('edit_post', $post_id)) return; + if ($post->post_status !== 'publish') return; + + clear_post_cache_based_on_conditions($post_id, $post); // Передаем только $post +}, 10, 3); + +// Хук для запланированных публикаций +add_action('transition_post_status', function($new_status, $old_status, $post) { + if ($new_status !== 'publish') return; + if (!current_user_can('edit_post', $post->ID)) return; // Используем $post->ID + + clear_post_cache_based_on_conditions($post->ID, $post); // Передаем только $post +}, 10, 3); + +?> + + + diff --git a/clear-functions.php b/clear-functions.php index 2bd2776..90635ea 100644 --- a/clear-functions.php +++ b/clear-functions.php @@ -414,13 +414,23 @@ function show_post_thumbnail(WP_Post|int $post = null) : bool { + $post_id = get_the_ID(); + + + $days = get_post_meta(get_the_ID(),'_hide_thumbnail_countdown', true); + + if ($days == 0){ // если ноль - показывать всегда + return true; + } + + if( hide_thumbnail_by_countdown() ) { return false; } - if ( is_single() || is_feed() ) { + //if ( is_single() || is_feed() ) { if ( in_array( get_post_type(), ['anew', 'yellow'] ) && get_the_date("U") < 1719187200 ) { @@ -501,7 +511,7 @@ return true; - } + //} return true; @@ -1279,7 +1289,8 @@ /** * Сжатие html */ - require_once __DIR__ . "/inc/compress-html.php"; + require_once 'inc/compress-html.php'; + //require_once __DIR__ . "/inc/compress-html.php"; diff --git a/functions.php b/functions.php index 27d5af3..055fa6e 100644 --- a/functions.php +++ b/functions.php @@ -1,12 +1,13 @@ ' . _e($field['label']); break; @@ -2263,6 +2308,30 @@ remove_action( 'wp_head', 'feed_links', 2 ); remove_action( 'wp_head', 'rsd_link' ); +//делаем opengraph для постов без фото +add_action('wp_head', function() { + + if (!is_singular()) return; + + $post_id = get_the_ID(); + $default_image = 'https://cdn.profile.ru/wp-content/uploads/2023/07/profile_lazyload_hq.jpg'; // Заглушка в папке темы + + $og_image = esc_url($default_image); + + if (!has_post_thumbnail($post_id) or !show_thumbnail($post_id)) { + + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo ''; + + //} else { + // $og_image = get_the_post_thumbnail_url($post_id, 'large'); + } + + + +}); //Добавили к ссылкам nofollow @@ -2962,11 +3031,21 @@ function send_telegram($post) { $bot_id = "1108783670:AAGm7_vdXQAte25OGUa5gWJNXhy5-v6d_hU"; $post_id = (is_object($post_id)) ? $post_id->ID : $post_id; + // Получаем и проверяем ссылку + $curr_url = get_permalink($post_id); + if (empty($curr_url)) { + error_log('Telegram bot: Empty permalink for post ID ' . $post_id); + return; + } + + $curr_url = fix_broken_url($curr_url, 'profile.ru'); //корректируем ссылку с ошиюбками + if(has_tag(103565, $post_id)){ $chat_id = "-1001241573514";//идентификатор канала profile_lifestyle - $text = '' . get_the_title($post_id) . ''; + + $text = '' . get_the_title($post_id) . ''; $text = str_replace('admin.', '', $text); $request = "https://api.telegram.org/bot" . $bot_id . "/sendMessage?chat_id=" . $chat_id . "&parse_mode=HTML&text=" . urlencode($text); @@ -2976,6 +3055,8 @@ function send_telegram($post) { curl_setopt($ch, CURLOPT_URL, $request); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); + + }else{ if( (((bool)filter_input(INPUT_POST,'_send_telegram')) @@ -2985,7 +3066,7 @@ function send_telegram($post) { $chat_id = "-1001365682276";//идентификатор канала profile_news - $text = ''.get_the_title($post_id).''; + $text = ''.get_the_title($post_id).''; $text = str_replace('admin.', '', $text); $request = "https://api.telegram.org/bot".$bot_id."/sendMessage?chat_id=".$chat_id."&parse_mode=HTML&text=".urlencode($text); @@ -6129,8 +6210,17 @@ add_filter( 'ep_post_sync_kill', 'my_ep_stop_sync', 10, 3 );*/ + + add_action('wp_insert_post', 'news_telegram_log', 10, 1 ); +//хук для запланированных +add_action('transition_post_status', function($new_status, $old_status, $post) { + if ($new_status == 'publish' && $old_status == 'future') { + news_telegram_log($post); + } +}, 10, 3); + function news_telegram_log($post){ $post = get_post($post); @@ -6147,15 +6237,20 @@ function news_telegram_log($post){ return; } - - if(wp_get_post_categories($post_id)[0] == 104862){ return; } + // Получаем и проверяем ссылку + $curr_link = get_permalink($post_id); + if (empty($curr_link)) { + error_log('Telegram bot: Empty permalink for post ID ' . $post_id); + return; + } + $curr_link = fix_broken_url($curr_link, 'profile.ru'); //корректируем ссылку с ошиюбками - $content = ''.get_the_title($post_id).''; + $content = ''.get_the_title($post_id).''; $content = str_replace('admin.', '', $content); $request = "https://api.telegram.org/bot1184440628:AAE5N10dnzClx3Qce4v1mBD9ax1BsHo98Rs/sendMessage?chat_id=-1001588455134&parse_mode=HTML&text=".urlencode($content); @@ -6207,6 +6302,13 @@ function show_thumbnail($id = false) : bool $id = get_the_ID(); } + // НОВОЕ УСЛОВИЕ: Амнистия для постов, опубликованных после 1 августа 2025 года + $amnestyDate = strtotime('2025-08-01'); + + if (get_the_date("U", $id) > $amnestyDate) { + return true; + } + $days = ((get_post_meta($id,'_hide_thumbnail_countdown'))[0]); if ( $days == NULL ){ diff --git a/template-parts/archive/cell-image.php b/template-parts/archive/cell-image.php index f8334bc..8f36d7d 100644 --- a/template-parts/archive/cell-image.php +++ b/template-parts/archive/cell-image.php @@ -7,7 +7,7 @@ alt="" /> - + " diff --git a/template-parts/archive/list.php b/template-parts/archive/list.php index 8c994e2..8be59d2 100644 --- a/template-parts/archive/list.php +++ b/template-parts/archive/list.php @@ -1,6 +1,8 @@ - +request; +echo $sql_query; // Выведет SQL-запрос?> diff --git a/template-parts/header/header-top-line.php b/template-parts/header/header-top-line.php index 6e46ba9..161b5fc 100644 --- a/template-parts/header/header-top-line.php +++ b/template-parts/header/header-top-line.php @@ -4,7 +4,7 @@
- +
diff --git a/template-parts/header/header.php b/template-parts/header/header.php index b847d71..923e20b 100644 --- a/template-parts/header/header.php +++ b/template-parts/header/header.php @@ -1,65 +1,67 @@ - - - -> - - - - - " - > - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
- -
- - - - - - - - - - -
- 14, "show_on_mobile" => false ]); ?> -
- - -
- - -
- + + + +> + + + + + " + > + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ +
+ + + + + + + + + + + +
+ 12, "show_on_mobile" => false ]); ?> +
+ + + +
+ + +
+ \ No newline at end of file diff --git a/template-parts/home/colon-item.php b/template-parts/home/colon-item.php index c4e8995..44509cf 100644 --- a/template-parts/home/colon-item.php +++ b/template-parts/home/colon-item.php @@ -36,14 +36,7 @@ $colon_query = new WP_Query(
-
- itemtype="https://schema.org/Article" - - itemtype="https://schema.org/NewsArticle" - - > +
@@ -73,13 +66,13 @@ $colon_query = new WP_Query( - +
- +
diff --git a/template-parts/home/index.php b/template-parts/home/index.php index ac931a7..a1b855f 100644 --- a/template-parts/home/index.php +++ b/template-parts/home/index.php @@ -1,13 +1,18 @@ - +
- + - +
@@ -22,7 +27,8 @@
- + + diff --git a/template-parts/nav/header-nav.php b/template-parts/nav/header-nav.php index a3d2f0c..114bd4e 100644 --- a/template-parts/nav/header-nav.php +++ b/template-parts/nav/header-nav.php @@ -77,6 +77,7 @@
+
@@ -102,6 +103,8 @@ +
+ diff --git a/template-parts/post/cell-author.php b/template-parts/post/cell-author.php index e5d9c32..b6a5139 100644 --- a/template-parts/post/cell-author.php +++ b/template-parts/post/cell-author.php @@ -10,12 +10,10 @@ - diff --git a/template-parts/single/post-most-popular-item.php b/template-parts/single/post-most-popular-item.php index b3e2ee6..471afcb 100644 --- a/template-parts/single/post-most-popular-item.php +++ b/template-parts/single/post-most-popular-item.php @@ -1,8 +1,10 @@ -