2026-03-04 14:43:19 +00:00

169 lines
4.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Plugin Name: Blog Style Refresh
* Description: Adds a clean magazine-like style polish for the personal blog.
* Version: 1.0.3
*/
if (!defined('ABSPATH')) {
exit;
}
add_action('loop_start', function ($query) {
if (is_admin() || !$query->is_main_query() || is_feed()) {
return;
}
if (!(is_front_page() || is_home())) {
return;
}
static $hero_rendered = false;
if ($hero_rendered) {
return;
}
$hero_rendered = true;
$posts_page_id = (int) get_option('page_for_posts');
$blog_url = $posts_page_id ? get_permalink($posts_page_id) : home_url('/');
echo '<section class="blog-hero" aria-label="Главный блок">';
echo '<div class="blog-hero__inner">';
echo '<p class="blog-hero__kicker">Личный блог</p>';
echo '<h1 class="blog-hero__title">Пишу о жизни, технологиях и мыслях</h1>';
echo '<p class="blog-hero__subtitle">Спокойные статьи без шума: практичные идеи, наблюдения и полезные заметки на каждый день.</p>';
echo '<div class="blog-hero__actions"><a class="wp-block-button__link blog-hero__button" href="' . esc_url($blog_url) . '">Читать статьи</a></div>';
echo '</div>';
echo '</section>';
}, 9);
add_action('wp_enqueue_scripts', function () {
$css = <<<CSS
:root {
--blog-max-width: 920px;
--blog-accent: #5b47ff;
--blog-text: #1f2430;
}
.wp-site-blocks { background: linear-gradient(180deg,#f7f8ff 0%,#ffffff 320px); }
header.wp-block-template-part { backdrop-filter: blur(8px); }
.blog-hero {
max-width: var(--blog-max-width);
margin: 24px auto 30px;
padding: 0 12px;
}
.blog-hero__inner {
background: #ffffff;
border: 1px solid #eceff4;
border-radius: 18px;
padding: clamp(24px, 3.2vw, 46px);
box-shadow: 0 8px 26px rgba(20, 20, 43, .06);
}
.blog-hero__kicker {
margin: 0 0 10px;
color: #6b7280;
letter-spacing: .08em;
text-transform: uppercase;
font-size: .75rem;
font-weight: 600;
}
.blog-hero__title {
margin: 0;
color: var(--blog-text);
font-size: clamp(1.8rem, 3.5vw, 3rem);
line-height: 1.15;
}
.blog-hero__subtitle {
margin: 16px 0 0;
max-width: 62ch;
color: #4b5563;
font-size: 1.02rem;
line-height: 1.7;
}
.blog-hero__actions {
margin-top: 22px;
}
.blog-hero__button {
background: #1f2430 !important;
color: #fff !important;
border: 1px solid #1f2430;
padding: 11px 18px !important;
}
.blog-hero__button:hover {
background: #fff !important;
color: #1f2430 !important;
}
.wp-block-post,
.wp-block-post-template > li,
article.post {
border-radius: 18px;
background: #fff;
box-shadow: 0 12px 36px rgba(20,20,43,.08);
padding: clamp(18px,2vw,30px);
margin-bottom: 28px;
}
.wp-block-post-title a,
h1.wp-block-post-title,
.entry-title { color: var(--blog-text); text-decoration: none; }
.wp-block-post-title a:hover { color: var(--blog-accent); }
.wp-block-post-featured-image img,
.entry-content img {
border-radius: 14px;
box-shadow: 0 10px 26px rgba(0,0,0,.12);
max-width: 100%;
height: auto;
display: block;
}
.entry-content figure,
.entry-content .wp-block-image {
max-width: 100%;
margin-left: 0;
margin-right: 0;
}
.entry-content .alignwide,
.entry-content .alignfull {
width: 100%;
max-width: 100%;
margin-left: auto;
margin-right: auto;
}
.entry-content,
.wp-block-post-excerpt,
.wp-block-post-content,
.wp-block-group.is-layout-constrained > * {
max-width: var(--blog-max-width);
margin-left: auto;
margin-right: auto;
}
.entry-content p,
.wp-block-post-content p {
font-size: 1.08rem;
line-height: 1.8;
color: #2b3340;
}
a { text-underline-offset: 3px; }
a:hover { color: var(--blog-accent); }
.wp-block-tag-cloud a,
.wp-block-post-terms a {
display: inline-block;
border-radius: 999px;
padding: 4px 10px;
background: #f2f3ff;
margin-right: 6px;
}
.wp-block-button__link,
button,
input[type='submit'] {
border-radius: 999px !important;
}
@media (max-width: 782px) {
.blog-hero {
margin: 14px auto 22px;
padding: 0 10px;
}
}
CSS;
wp_register_style('blog-style-refresh', false, [], '1.0.3');
wp_enqueue_style('blog-style-refresh');
wp_add_inline_style('blog-style-refresh', $css);
}, 20);