add files
This commit is contained in:
60
.gitignore
vendored
Executable file
60
.gitignore
vendored
Executable file
@@ -0,0 +1,60 @@
|
|||||||
|
# Зависимости
|
||||||
|
node_modules/
|
||||||
|
vendor/
|
||||||
|
bower_components/
|
||||||
|
|
||||||
|
# Файлы сборки
|
||||||
|
dist/
|
||||||
|
build/
|
||||||
|
*.min.js
|
||||||
|
*.min.css
|
||||||
|
*.map
|
||||||
|
|
||||||
|
# Исключаем frontend (отдельный репозиторий)
|
||||||
|
frontend/
|
||||||
|
|
||||||
|
# Логи
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
|
||||||
|
# Переменные окружения
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
|
.env.*.local
|
||||||
|
|
||||||
|
# Кеш и временные файлы
|
||||||
|
.sass-cache/
|
||||||
|
.cache/
|
||||||
|
.tmp/
|
||||||
|
*.tmp
|
||||||
|
|
||||||
|
# IDE и редакторы
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
*.sublime-project
|
||||||
|
*.sublime-workspace
|
||||||
|
*.code-workspace
|
||||||
|
|
||||||
|
# Системные файлы
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
desktop.ini
|
||||||
|
|
||||||
|
# Файлы базы данных
|
||||||
|
*.sql
|
||||||
|
*.sqlite
|
||||||
|
|
||||||
|
# Файлы загрузок (если есть в теме)
|
||||||
|
uploads/
|
||||||
|
|
||||||
|
# Composer
|
||||||
|
composer.lock
|
||||||
|
composer.phar
|
||||||
|
|
||||||
|
# Package manager lock files (опционально)
|
||||||
|
package-lock.json
|
||||||
|
yarn.lock
|
||||||
|
|
||||||
|
|
||||||
51
arh/partslist.php
Normal file
51
arh/partslist.php
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<div class="sideparts">
|
||||||
|
<h4 class="sideparts-title"><a href="https://sportpressa.ru/news/">Все новости</a></h4>
|
||||||
|
<ul class="partslist">
|
||||||
|
<li><a href="https://sportpressa.ru/news/aviatsionnyy_sport">Авиационный спорт</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/avtomotosport">Автомотоспорт</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/badminton">Бадминтон</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/basketball">Баскетбол</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/biatlon">Биатлон</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/bobsley_skeleton">Бобслей/Скелетон</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/boks_mma">Бокс/MMA</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/borba">Борьба</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/vodnoe_polo">Водное поло</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/aquatics">Водные виды спорта</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/volleyball">Волейбол</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/handball">Гандбол</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/gymnastics">Гимнастика</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/dzyudo_sambo">Дзюдо/Самбо</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/edinoborstva">Единоборства</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/cybersport">Киберспорт</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/konnyy_sport">Конный спорт</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/konkobezhnyy_sport">Конькобежный спорт</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/athletics">Легкая атлетика</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/lyzhnyy_sport">Лыжный спорт</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/nastolnyy_tennis">Настольный теннис</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/news">Новости</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/parusnyy_sport">Парусный спорт</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/beachsoccer">Пляжный футбол</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/rugby">Регби</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/sannyy_sport">Санный спорт</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/snoubord">Сноуборд</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/sportivnye_smi">Спортивные СМИ</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/strelba">Стрельба</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/strelba_iz_luka">Стрельба из лука</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/dance_sport">Танцевальный спорт</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/tennis">Теннис</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/triathlon">Триатлон</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/tyazhelaya_atletika">Тяжелая атлетика</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/fekhtovanie">Фехтование</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/figurnoe_katanie">Фигурное катание</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/fitnes">Фитнес</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/fristayl">Фристайл</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/soccer">Футбол</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/hokkey">Хоккей</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/bandy">Хоккей с мячом</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/hronika">Хроника</a></li>
|
||||||
|
<li><a href="https://sportpressa.ru/news/chess">Шахматы</a></li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
<div>
|
||||||
|
|
||||||
|
</div>
|
||||||
27
category.php
Normal file
27
category.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php get_header(); ?>
|
||||||
|
|
||||||
|
<main class="main">
|
||||||
|
<div class="maintitle">
|
||||||
|
<h1><?php single_cat_title(); ?></h1>
|
||||||
|
<div class="h-telega"><a href="https://t.me/sportpressa" target="_blank">@sportpressa</a></div>
|
||||||
|
<?php if (category_description()) : ?>
|
||||||
|
<div class="category-description">
|
||||||
|
<?php echo category_description(); ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php get_template_part('template-parts/content', 'cards'); ?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// Пагинация
|
||||||
|
the_posts_pagination(array(
|
||||||
|
'mid_size' => 2,
|
||||||
|
'prev_text' => '« Предыдущая',
|
||||||
|
'next_text' => 'Следующая »',
|
||||||
|
));
|
||||||
|
?>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<?php get_sidebar(); ?>
|
||||||
|
<?php get_footer(); ?>
|
||||||
25
footer.php
Executable file
25
footer.php
Executable file
@@ -0,0 +1,25 @@
|
|||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<?php wp_footer(); ?>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
<a href="#top" class="to-top"><svg width="53" height="53" viewBox="0 0 53 53" fill="none" xmlns="http://www.w3.org/2000/svg"> <rect width="53" height="53" fill="#006842"></rect> <path d="M26.9091 24.1732L39.8181 31.6279L39.8181 24.4546L26.9091 16.9999L26.9091 24.1732Z" fill="#F18917"></path> <path d="M26.909 24.1732L14 31.6279L14 24.4546L26.909 16.9999L26.909 24.1732Z" fill="#F18917"></path> </svg></a>
|
||||||
|
<div class="footer-content">
|
||||||
|
<div class="footer-line-1">
|
||||||
|
<div class="sportpressa-logo-footer">
|
||||||
|
<a href="<?php echo home_url()?>"><span class="redword">С</span>порт</a>
|
||||||
|
<img src="<?php echo home_url()?>/sportpressa.svg" width="30">
|
||||||
|
<a href="<?php echo home_url()?>">Пресса</a>
|
||||||
|
</div>
|
||||||
|
<div class="rating">18+</div>
|
||||||
|
</div>
|
||||||
|
<div id="copyr">
|
||||||
|
© Сетевое издание Спортпресса, 2018 - <?=date('Y')?> (sportpressa.ru). Учредитель: Синьковский Петр Сергеевич. Главный редактор: Синьковский П.С. Электронный адрес: info@sportpressa.ru. Телефон редакции: +7(495)511-49-05. Свидетельство о регистрации ЭЛ № ФС 77 - 73274 от 13.07.2018 года. Выдано Федеральной службой по надзору в сфере связи, информационных технологий и массовых коммуникаций (Роскомнадзор). 2002-2024 SportPressa.ru™ Все права защищены.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
22
front-page.php
Executable file
22
front-page.php
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
get_header(); ?>
|
||||||
|
|
||||||
|
<main class="main">
|
||||||
|
<div class="maintitle">
|
||||||
|
<h1>Новости спорта</h1>
|
||||||
|
<div class="h-telega"><a href="https://t.me/sportpressa" target="_blank">@sportpressa</a></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<? // Вызываем подшаблон для кастомного запроса
|
||||||
|
get_template_part('template-parts/content', 'cards');
|
||||||
|
?>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
|
||||||
|
<?php get_template_part('sidebar');?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<?php get_footer(); ?>
|
||||||
251
functions.php
Executable file
251
functions.php
Executable file
@@ -0,0 +1,251 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (! defined( 'ABSPATH' )) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
require_once 'vite.config.php';
|
||||||
|
|
||||||
|
function theme_setup() {
|
||||||
|
|
||||||
|
add_theme_support( 'post-thumbnails' );
|
||||||
|
|
||||||
|
add_theme_support( 'menus' );
|
||||||
|
register_nav_menus( array(
|
||||||
|
'primary-menu' => __( 'Primary Menu', 'my-theme' ),
|
||||||
|
'footer-menu' => __( 'Footer Menu', 'my-theme' )
|
||||||
|
) );
|
||||||
|
|
||||||
|
}
|
||||||
|
add_action( 'after_setup_theme', 'theme_setup' );
|
||||||
|
|
||||||
|
|
||||||
|
//crops
|
||||||
|
function my_custom_image_sizes() {
|
||||||
|
add_image_size( 'small-thumbnail', 300, 200, true ); // Кроп до 300x200
|
||||||
|
add_image_size( 'medium-thumbnail', 600, 400, true ); // Кроп до 600x400
|
||||||
|
add_image_size( 'large-thumbnail', 1200, 800, true ); // Кроп до 1200x800
|
||||||
|
}
|
||||||
|
|
||||||
|
//add_action( 'after_setup_theme', 'my_custom_image_sizes' );
|
||||||
|
|
||||||
|
|
||||||
|
// Создание нового типа записи "Каталог"
|
||||||
|
function register_catalog_post_type() {
|
||||||
|
$labels = array(
|
||||||
|
'name' => 'Каталог',
|
||||||
|
'singular_name' => 'Элемент каталога',
|
||||||
|
'menu_name' => 'Каталог',
|
||||||
|
'name_admin_bar' => 'Элемент каталога',
|
||||||
|
'add_new' => 'Добавить новый',
|
||||||
|
'add_new_item' => 'Добавить новый элемент каталога',
|
||||||
|
'new_item' => 'Новый элемент каталога',
|
||||||
|
'edit_item' => 'Редактировать элемент каталога',
|
||||||
|
'view_item' => 'Просмотреть элемент каталога',
|
||||||
|
'all_items' => 'Все элементы каталога',
|
||||||
|
'search_items' => 'Искать в каталоге',
|
||||||
|
'parent_item_colon' => 'Родительский элемент:',
|
||||||
|
'not_found' => 'Элементы каталога не найдены.',
|
||||||
|
'not_found_in_trash' => 'В корзине элементы каталога не найдены.'
|
||||||
|
);
|
||||||
|
|
||||||
|
$args = array(
|
||||||
|
'labels' => $labels,
|
||||||
|
'public' => true,
|
||||||
|
'publicly_queryable' => true,
|
||||||
|
'show_ui' => true,
|
||||||
|
'show_in_menu' => true,
|
||||||
|
'query_var' => true,
|
||||||
|
'rewrite' => array('slug' => 'catalog'),
|
||||||
|
'capability_type' => 'post',
|
||||||
|
'has_archive' => true,
|
||||||
|
'hierarchical' => false,
|
||||||
|
'menu_position' => 5,
|
||||||
|
'menu_icon' => 'dashicons-products',
|
||||||
|
'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'comments', 'custom-fields'),
|
||||||
|
'taxonomies' => array('category') // Подключаем стандартные категории
|
||||||
|
);
|
||||||
|
|
||||||
|
register_post_type('catalog', $args);
|
||||||
|
}
|
||||||
|
add_action('init', 'register_catalog_post_type');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function get_first_subcategory( $post_id ) {
|
||||||
|
// Получаем все категории поста
|
||||||
|
$categories = get_the_category( $post_id );
|
||||||
|
|
||||||
|
if ( !empty( $categories ) ) {
|
||||||
|
// Проходим по каждой категории
|
||||||
|
foreach ( $categories as $category ) {
|
||||||
|
// Проверяем, является ли категория подрубрикой (если у неё есть родитель)
|
||||||
|
if ( $category->parent != 0 ) {
|
||||||
|
// Возвращаем массив с названием и ссылкой на подрубрику
|
||||||
|
return array(
|
||||||
|
'name' => esc_html( $category->name ),
|
||||||
|
'url' => get_category_link( $category->term_id ),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Если подрубрика не найдена, возвращаем null
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function custom_posts_per_page($query) {
|
||||||
|
if (!is_admin() && $query->is_main_query()) {
|
||||||
|
|
||||||
|
// Для главной страницы
|
||||||
|
if (is_home() || is_front_page()) {
|
||||||
|
$query->set('cat', 174);
|
||||||
|
$query->set('posts_per_page', 18);
|
||||||
|
$query->set('post_status', 'publish');
|
||||||
|
$query->set('ignore_sticky_posts', 1);
|
||||||
|
$query->set('meta_query', array(
|
||||||
|
array(
|
||||||
|
'key' => '_thumbnail_id',
|
||||||
|
'compare' => 'EXISTS'
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Для архивов рубрик и тегов
|
||||||
|
if (is_category() || is_tag()) {
|
||||||
|
$query->set('posts_per_page', 18);
|
||||||
|
$query->set('meta_query', array(
|
||||||
|
array(
|
||||||
|
'key' => '_thumbnail_id',
|
||||||
|
'compare' => 'EXISTS'
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
add_action('pre_get_posts', 'custom_posts_per_page');
|
||||||
|
|
||||||
|
|
||||||
|
// Добавляем slug категории в body class для архивов и постов
|
||||||
|
function add_category_slug_to_body_class($classes) {
|
||||||
|
// Для архивов рубрик
|
||||||
|
if (is_category()) {
|
||||||
|
$category = get_queried_object();
|
||||||
|
|
||||||
|
// Рубрики с обрезкой (cover) - укажите slug нужных рубрик
|
||||||
|
$cover_categories = array('news');
|
||||||
|
|
||||||
|
$is_cover = false;
|
||||||
|
|
||||||
|
if (in_array($category->slug, $cover_categories)) {
|
||||||
|
$is_cover = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$is_cover && $category->parent) {
|
||||||
|
$parent_id = $category->parent;
|
||||||
|
while ($parent_id) {
|
||||||
|
$parent = get_category($parent_id);
|
||||||
|
if (in_array($parent->slug, $cover_categories)) {
|
||||||
|
$is_cover = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$parent_id = $parent->parent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$is_cover) {
|
||||||
|
$classes[] = 'image-portrait';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Для одиночных постов
|
||||||
|
if (is_single()) {
|
||||||
|
$categories = get_the_category();
|
||||||
|
|
||||||
|
// Рубрики с обрезкой (cover)
|
||||||
|
$cover_categories = array('news');
|
||||||
|
|
||||||
|
$is_cover = false;
|
||||||
|
|
||||||
|
foreach ($categories as $category) {
|
||||||
|
if (in_array($category->slug, $cover_categories)) {
|
||||||
|
$is_cover = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Проверяем родительские категории
|
||||||
|
if (!$is_cover && $category->parent) {
|
||||||
|
$parent_id = $category->parent;
|
||||||
|
while ($parent_id) {
|
||||||
|
$parent = get_category($parent_id);
|
||||||
|
if (in_array($parent->slug, $cover_categories)) {
|
||||||
|
$is_cover = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$parent_id = $parent->parent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($is_cover) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$is_cover) {
|
||||||
|
$classes[] = 'image-portrait';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $classes;
|
||||||
|
}
|
||||||
|
add_filter('body_class', 'add_category_slug_to_body_class');
|
||||||
|
|
||||||
|
// Добавляем классы к каждому посту в цикле для архивов тегов
|
||||||
|
function add_category_class_to_posts($classes, $class, $post_id) {
|
||||||
|
// Только для архивов тегов
|
||||||
|
if (is_tag()) {
|
||||||
|
$categories = get_the_category($post_id);
|
||||||
|
|
||||||
|
// Рубрики с обрезкой (cover)
|
||||||
|
$cover_categories = array('news');
|
||||||
|
|
||||||
|
$is_cover = false;
|
||||||
|
|
||||||
|
foreach ($categories as $category) {
|
||||||
|
if (in_array($category->slug, $cover_categories)) {
|
||||||
|
$is_cover = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Проверяем родительские категории
|
||||||
|
if (!$is_cover && $category->parent) {
|
||||||
|
$parent_id = $category->parent;
|
||||||
|
while ($parent_id) {
|
||||||
|
$parent = get_category($parent_id);
|
||||||
|
if (in_array($parent->slug, $cover_categories)) {
|
||||||
|
$is_cover = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$parent_id = $parent->parent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($is_cover) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$is_cover) {
|
||||||
|
$classes[] = 'image-portrait';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $classes;
|
||||||
|
}
|
||||||
|
add_filter('post_class', 'add_category_class_to_posts', 10, 3);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
155
header.php
Executable file
155
header.php
Executable file
@@ -0,0 +1,155 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html <?php language_attributes(); ?>>
|
||||||
|
<head>
|
||||||
|
<meta charset="<?php bloginfo('charset'); ?>">
|
||||||
|
<title><?php wp_title('|', true, 'right');?><?=get_bloginfo('name')?></title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
|
||||||
|
<!-- Основные favicon -->
|
||||||
|
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
|
||||||
|
<link rel="icon" href="favicon.svg" type="image/svg+xml">
|
||||||
|
<link rel="icon" href="favicon-16x16.png" type="image/png" sizes="16x16">
|
||||||
|
<link rel="icon" href="favicon-32x32.png" type="image/png" sizes="32x32">
|
||||||
|
<link rel="icon" href="favicon-48x48.png" type="image/png" sizes="48x48">
|
||||||
|
|
||||||
|
<!-- Apple Touch Icons -->
|
||||||
|
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="57x57" href="apple-touch-icon-57x57.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="60x60" href="apple-touch-icon-60x60.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="72x72" href="apple-touch-icon-72x72.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="76x76" href="apple-touch-icon-76x76.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="114x114" href="apple-touch-icon-114x114.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="120x120" href="apple-touch-icon-120x120.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="144x144" href="apple-touch-icon-144x144.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="152x152" href="apple-touch-icon-152x152.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon-180x180.png">
|
||||||
|
|
||||||
|
<!-- Android Chrome Icons -->
|
||||||
|
<link rel="manifest" href="site.webmanifest">
|
||||||
|
<meta name="theme-color" content="#ffffff">
|
||||||
|
|
||||||
|
<!-- Microsoft Tiles -->
|
||||||
|
<meta name="msapplication-TileColor" content="#ffffff">
|
||||||
|
<meta name="msapplication-TileImage" content="mstile-144x144.png">
|
||||||
|
<meta name="msapplication-config" content="browserconfig.xml">
|
||||||
|
<?php wp_head(); ?>
|
||||||
|
|
||||||
|
<!-- Yandex.Metrika counter -->
|
||||||
|
<script type="text/javascript">
|
||||||
|
(function(m, e, t, r, i, k, a) {
|
||||||
|
m[i] = m[i] || function() {
|
||||||
|
(m[i].a = m[i].a || []).push(arguments)
|
||||||
|
};
|
||||||
|
m[i].l = 1 * new Date();
|
||||||
|
k = e.createElement(t),
|
||||||
|
a = e.getElementsByTagName(t)[0],
|
||||||
|
k.async = 1,
|
||||||
|
k.src = r,
|
||||||
|
a.parentNode.insertBefore(k, a)
|
||||||
|
})
|
||||||
|
(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
|
||||||
|
|
||||||
|
ym(52011299, "init", {
|
||||||
|
id: 52011299,
|
||||||
|
clickmap: true,
|
||||||
|
trackLinks: true,
|
||||||
|
accurateTrackBounce: true
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<noscript>
|
||||||
|
<div>
|
||||||
|
<img src="https://mc.yandex.ru/watch/52011299" style="position:absolute; left:-9999px;" alt=""/>
|
||||||
|
</div>
|
||||||
|
</noscript>
|
||||||
|
<!-- /Yandex.Metrika counter -->
|
||||||
|
<!-- Rating@Mail.ru counter -->
|
||||||
|
<script type="text/javascript">
|
||||||
|
var _tmr = window._tmr || (window._tmr = []);
|
||||||
|
_tmr.push({
|
||||||
|
id: "3078905",
|
||||||
|
type: "pageView",
|
||||||
|
start: (new Date()).getTime()
|
||||||
|
});
|
||||||
|
(function(d, w, id) {
|
||||||
|
if (d.getElementById(id))
|
||||||
|
return;
|
||||||
|
var ts = d.createElement("script");
|
||||||
|
ts.type = "text/javascript";
|
||||||
|
ts.async = true;
|
||||||
|
ts.id = id;
|
||||||
|
ts.src = "https://top-fwz1.mail.ru/js/code.js";
|
||||||
|
var f = function() {
|
||||||
|
var s = d.getElementsByTagName("script")[0];
|
||||||
|
s.parentNode.insertBefore(ts, s);
|
||||||
|
};
|
||||||
|
if (w.opera == "[object Opera]") {
|
||||||
|
d.addEventListener("DOMContentLoaded", f, false);
|
||||||
|
} else {
|
||||||
|
f();
|
||||||
|
}
|
||||||
|
})(document, window, "topmailru-code");
|
||||||
|
</script>
|
||||||
|
<noscript>
|
||||||
|
<div>
|
||||||
|
<img src="https://top-fwz1.mail.ru/counter?id=3078905;js=na" style="border:0;position:absolute;left:-9999px;" alt="Top.Mail.Ru"/>
|
||||||
|
</div>
|
||||||
|
</noscript>
|
||||||
|
<!-- //Rating@Mail.ru counter -->
|
||||||
|
<!-------------------------------------------------------------------------------- Статусная строка -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
|
||||||
|
<body <?php body_class(); ?>>
|
||||||
|
|
||||||
|
<header class="site-header" role="banner">
|
||||||
|
|
||||||
|
<?get_template_part( 'template-parts/current-datetime' );?>
|
||||||
|
|
||||||
|
<!-- Основной header -->
|
||||||
|
<div class="site-header-content">
|
||||||
|
<div class="sportpressa-logo">
|
||||||
|
<a href="<?php echo home_url()?>"><span class="redword">С</span>порт</a>
|
||||||
|
<img src="<?php echo home_url()?>/sportpressa.svg" width="40">
|
||||||
|
<a href="<?php echo home_url()?>">Пресса</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button class="hamburger" id="mobile-menu-toggle" aria-label="Открыть меню">
|
||||||
|
<span class="hamburger-icon"></span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="mobile-menu-overlay">
|
||||||
|
<button class="mobile-menu-close" id="mobile-menu-close" aria-label="Закрыть меню">
|
||||||
|
<span class="close-icon"></span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<nav class="mobile-nav">
|
||||||
|
<?php
|
||||||
|
wp_nav_menu( array(
|
||||||
|
'theme_location' => 'primary-menu',
|
||||||
|
'container' => false,
|
||||||
|
'menu_class' => 'mobile-main-menu',
|
||||||
|
'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>'
|
||||||
|
) );
|
||||||
|
?>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<nav class="desktop-nav">
|
||||||
|
<?php
|
||||||
|
wp_nav_menu( array(
|
||||||
|
'theme_location' => 'primary-menu',
|
||||||
|
'container' => false,
|
||||||
|
'menu_class' => 'main-menu',
|
||||||
|
'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>'
|
||||||
|
) );
|
||||||
|
?>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="wrapper">
|
||||||
29
sidebar.php
Normal file
29
sidebar.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<aside class="sidebar">
|
||||||
|
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// ID или слаг родительской рубрики
|
||||||
|
$parent_category_id = 174; // Укажите ID вашей рубрики
|
||||||
|
|
||||||
|
// Получаем дочерние рубрики
|
||||||
|
$child_categories = get_categories(array(
|
||||||
|
'child_of' => $parent_category_id,
|
||||||
|
'orderby' => 'name', // Сортировка по имени (алфавитно)
|
||||||
|
'order' => 'ASC', // Порядок: ASC - по возрастанию
|
||||||
|
'hide_empty' => 0, // Показывать даже пустые рубрики
|
||||||
|
'number' => 0,
|
||||||
|
));
|
||||||
|
|
||||||
|
if ($child_categories) {
|
||||||
|
echo '<div class="sideparts"><h4 class="sideparts-title"><a href="https://sportpressa.ru/news/">Все новости</a></h4><ul class="partslist">';
|
||||||
|
foreach ($child_categories as $category) {
|
||||||
|
// Выводим каждую подрубрику в <li>
|
||||||
|
echo '<li><a href="' . get_category_link($category->term_id) . '">' . $category->name . '</a></li>';
|
||||||
|
}
|
||||||
|
echo '</ul></div>';
|
||||||
|
} else {
|
||||||
|
echo 'Подрубрики не найдены.';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
</aside>
|
||||||
64
single.php
Normal file
64
single.php
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
get_header(); ?>
|
||||||
|
|
||||||
|
<main class="main">
|
||||||
|
|
||||||
|
|
||||||
|
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
|
||||||
|
|
||||||
|
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||||
|
|
||||||
|
<header class="post-header">
|
||||||
|
|
||||||
|
<?get_template_part( 'template-parts/breadcrumbs' );?>
|
||||||
|
|
||||||
|
<h1 class="post-title"><?php the_title(); ?></h1>
|
||||||
|
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<?php if ( has_post_thumbnail() ) : ?>
|
||||||
|
<figure class="single-post__thumb">
|
||||||
|
<?php the_post_thumbnail('large'); ?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$cap = get_the_post_thumbnail_caption();
|
||||||
|
if ( $cap ) : ?>
|
||||||
|
<figcaption class="single-post__thumb-caption">
|
||||||
|
<?php echo esc_html( $cap ); ?>
|
||||||
|
</figcaption>
|
||||||
|
<?php endif; ?>
|
||||||
|
</figure>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<div class="single-post__content">
|
||||||
|
<?php the_content(); ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$tags = get_the_tags();
|
||||||
|
if ($tags) : ?>
|
||||||
|
<div class="post-tags">
|
||||||
|
<?php foreach ($tags as $tag) : ?>
|
||||||
|
<a href="<?php echo get_tag_link($tag->term_id); ?>" class="tag-item">
|
||||||
|
<?php echo esc_html($tag->name); ?>
|
||||||
|
</a>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
</article>
|
||||||
|
|
||||||
|
<?php get_template_part( 'template-parts/share-buttons' ); ?>
|
||||||
|
<?php get_template_part( 'template-parts/subscripts' ); ?>
|
||||||
|
|
||||||
|
<?php endwhile; endif; ?>
|
||||||
|
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<?php get_template_part('sidebar');?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<?php get_footer(); ?>
|
||||||
27
tag.php
Normal file
27
tag.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php get_header(); ?>
|
||||||
|
|
||||||
|
<main class="main">
|
||||||
|
<div class="maintitle">
|
||||||
|
<h1>#<?php single_tag_title(); ?></h1>
|
||||||
|
<div class="h-telega"><a href="https://t.me/sportpressa" target="_blank">@sportpressa</a></div>
|
||||||
|
<?php if (tag_description()) : ?>
|
||||||
|
<div class="tag-description">
|
||||||
|
<?php echo tag_description(); ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php get_template_part('template-parts/content', 'cards'); ?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// Пагинация
|
||||||
|
the_posts_pagination(array(
|
||||||
|
'mid_size' => 2,
|
||||||
|
'prev_text' => '« Предыдущая',
|
||||||
|
'next_text' => 'Следующая »',
|
||||||
|
));
|
||||||
|
?>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<?php get_sidebar(); ?>
|
||||||
|
<?php get_footer(); ?>
|
||||||
43
template-parts/breadcrumbs.php
Normal file
43
template-parts/breadcrumbs.php
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
if ( ! is_single() ) return;
|
||||||
|
|
||||||
|
// Рекурсивная функция с Schema.org позицией
|
||||||
|
function render_full_category_breadcrumbs( $cat_id, &$position = 1, $separator = ' > ' ) {
|
||||||
|
$cat = get_category( $cat_id );
|
||||||
|
if ( ! $cat ) return;
|
||||||
|
|
||||||
|
// Рекурсивно выводим родителей
|
||||||
|
if ( $cat->parent != 0 ) {
|
||||||
|
render_full_category_breadcrumbs( $cat->parent, $position, $separator );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Выводим категорию с Schema.org структурой
|
||||||
|
echo '<li property="itemListElement" typeof="ListItem" itemprop="itemListElement">
|
||||||
|
<a property="item" typeof="WebPage" href="' . esc_url( get_category_link( $cat->term_id ) ) . '">
|
||||||
|
<span property="name" itemprop="name">' . esc_html( $cat->name ) . '</span>
|
||||||
|
</a>
|
||||||
|
<meta property="position" content="' . $position . '" />
|
||||||
|
</li>';
|
||||||
|
|
||||||
|
$position++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$categories = get_the_category();
|
||||||
|
if ( empty( $categories ) ) return;
|
||||||
|
|
||||||
|
$main_cat = $categories[0];
|
||||||
|
$breadcrumb_position = 1;
|
||||||
|
?>
|
||||||
|
|
||||||
|
<nav class="breadcrumbs" aria-label="Навигация по рубрикам" itemscope itemtype="https://schema.org/BreadcrumbList">
|
||||||
|
<ol class="breadcrumbs_list" itemprop="itemListElement">
|
||||||
|
<?php render_full_category_breadcrumbs( $main_cat->term_id, $breadcrumb_position ); ?>
|
||||||
|
<li property="itemListElement" typeof="ListItem">
|
||||||
|
<span property="item" typeof="WebPage" itemprop="name"><?php the_time('j F Y, H:i \М\С\К'); ?></span>
|
||||||
|
<meta property="position" content="<?php echo ++$breadcrumb_position; ?>" />
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
59
template-parts/content-card.php
Normal file
59
template-parts/content-card.php
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
// template-parts/content-card.php
|
||||||
|
$post_id = get_the_ID();
|
||||||
|
?>
|
||||||
|
<div class="news-item">
|
||||||
|
<?php if (has_post_thumbnail()) : ?>
|
||||||
|
<div class="post-thumbnail">
|
||||||
|
<a href="<?php the_permalink(); ?>">
|
||||||
|
<?php the_post_thumbnail('medium-thumbnail'); ?>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<h2 class="news-item-title">
|
||||||
|
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// Проверяем, является ли это страницей тега
|
||||||
|
if (is_tag()) {
|
||||||
|
// Получаем все категории поста
|
||||||
|
$categories = get_the_category();
|
||||||
|
|
||||||
|
if (!empty($categories)) {
|
||||||
|
// Находим самую первую родительскую категорию
|
||||||
|
$top_parent = $categories[0];
|
||||||
|
|
||||||
|
// Если у категории есть родитель, поднимаемся вверх по иерархии
|
||||||
|
while ($top_parent->parent != 0) {
|
||||||
|
$top_parent = get_category($top_parent->parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Выводим родительскую категорию
|
||||||
|
echo '<div class="news-item-info">';
|
||||||
|
echo '<span class="news-item-info-part">';
|
||||||
|
echo '<a href="' . esc_url(get_category_link($top_parent->term_id)) . '">';
|
||||||
|
echo esc_html($top_parent->name);
|
||||||
|
echo '</a>';
|
||||||
|
echo '</span>';
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Если это не страница тега, используем существующую логику
|
||||||
|
$subcategory = get_first_subcategory($post_id);
|
||||||
|
if ($subcategory) :
|
||||||
|
?>
|
||||||
|
<div class="news-item-info">
|
||||||
|
<span class="news-item-info-part">
|
||||||
|
<a href="<?php echo esc_url($subcategory['url']); ?>">
|
||||||
|
<?php echo esc_html($subcategory['name']); ?>
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
|
||||||
13
template-parts/content-cards.php
Normal file
13
template-parts/content-cards.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
// template-parts/content-cards.php
|
||||||
|
|
||||||
|
// Проверяем, есть ли записи в текущем запросе
|
||||||
|
if (have_posts()) : ?>
|
||||||
|
<div class="news-block">
|
||||||
|
<?php while (have_posts()) : the_post(); ?>
|
||||||
|
<?php get_template_part('template-parts/content', 'card'); ?>
|
||||||
|
<?php endwhile; ?>
|
||||||
|
</div>
|
||||||
|
<?php else : ?>
|
||||||
|
<p>Записей не найдено.</p>
|
||||||
|
<?php endif; ?>
|
||||||
28
template-parts/current-datetime.php
Normal file
28
template-parts/current-datetime.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<!-- Строка с датой и временем -->
|
||||||
|
<div class="header-top-bar">
|
||||||
|
<div class="header-top-content">
|
||||||
|
<span id="current-datetime">
|
||||||
|
<?php
|
||||||
|
// Массивы для русских названий
|
||||||
|
$months_ru = [
|
||||||
|
1 => 'января', 2 => 'февраля', 3 => 'марта', 4 => 'апреля',
|
||||||
|
5 => 'мая', 6 => 'июня', 7 => 'июля', 8 => 'августа',
|
||||||
|
9 => 'сентября', 10 => 'октября', 11 => 'ноября', 12 => 'декабря'
|
||||||
|
];
|
||||||
|
|
||||||
|
$days_ru = [
|
||||||
|
0 => 'Воскресенье', 1 => 'Понедельник', 2 => 'Вторник',
|
||||||
|
3 => 'Среда', 4 => 'Четверг', 5 => 'Пятница', 6 => 'Суббота'
|
||||||
|
];
|
||||||
|
|
||||||
|
$day = date('j');
|
||||||
|
$month = $months_ru[date('n')];
|
||||||
|
$year = date('Y');
|
||||||
|
$day_name = $days_ru[date('w')];
|
||||||
|
$time = date('H:i');
|
||||||
|
|
||||||
|
echo "$day $month $year, $day_name | Московское время: $time";
|
||||||
|
?>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
68
template-parts/share-buttons.php
Normal file
68
template-parts/share-buttons.php
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$post_url = esc_url( get_permalink() );
|
||||||
|
$post_title = esc_html( get_the_title() );
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="share-panel">
|
||||||
|
<div class="share-panel-title">
|
||||||
|
Поделитесь с друг<span class="share-panel-inoi">ими</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="share-panel-buttons">
|
||||||
|
<!-- VK -->
|
||||||
|
<div class="share-panel-element">
|
||||||
|
<a href="http://vk.com/share.php?url=<?= $post_url ?>&title=<?= $post_title ?>"
|
||||||
|
target="_blank" rel="noopener noreferrer"
|
||||||
|
aria-label="Поделиться в ВКонтакте">
|
||||||
|
<i class="social-icon social-icon-vk" aria-hidden="true"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Telegram -->
|
||||||
|
<div class="share-panel-element">
|
||||||
|
<a href="https://t.me/share/url?url=<?= $post_url ?>&text=<?= $post_title ?>"
|
||||||
|
target="_blank" rel="noopener noreferrer"
|
||||||
|
aria-label="Поделиться в Telegram">
|
||||||
|
<i class="social-icon social-icon-tg" aria-hidden="true"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Одноклассники -->
|
||||||
|
<div class="share-panel-element">
|
||||||
|
<a href="https://connect.ok.ru/dk?st.cmd=WidgetSharePreview&st.shareUrl=<?= $post_url ?>"
|
||||||
|
target="_blank" rel="noopener noreferrer"
|
||||||
|
aria-label="Поделиться в Одноклассниках">
|
||||||
|
<i class="social-icon social-icon-ok" aria-hidden="true"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$subject = get_the_title().' - Спортпресса';
|
||||||
|
$body = "Читайте на сайте Спортпресса:\n" . get_permalink();
|
||||||
|
|
||||||
|
$mailto = 'mailto:?subject=' . rawurlencode($subject) . '&body=' . rawurlencode($body);
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="share-panel-element">
|
||||||
|
<a href="<?php echo esc_attr($mailto); ?>"
|
||||||
|
target="_blank" rel="noopener noreferrer"
|
||||||
|
aria-label="Отправить на email">
|
||||||
|
<i class="social-icon social-icon-email" aria-hidden="true"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="share-panel-element">
|
||||||
|
<a class="js-copy-link" href="<?php echo esc_attr($mailto); ?>"
|
||||||
|
target="_blank" rel="noopener noreferrer"
|
||||||
|
data-copy="<?php echo esc_url( get_permalink() ); ?>"
|
||||||
|
aria-label="Отправить ссылку">
|
||||||
|
<i class="social-icon social-icon-link" aria-hidden="true"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
4
template-parts/subscripts.php
Normal file
4
template-parts/subscripts.php
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<div class="subscripts"> Подпишитесь на Спорт
|
||||||
|
<a class="btn_sub_social" href="https://dzen.ru/sportpressa.ru" target="_blank"> Дзен </a>
|
||||||
|
<a class="btn_sub_social" href="https://t.me/sportpressa" target="_blank">Telegram</a>
|
||||||
|
</div>
|
||||||
41
vite.config.php
Executable file
41
vite.config.php
Executable file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (! defined( 'ABSPATH' )) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// default server address, port, and entry point can be customized in vite.config.js
|
||||||
|
define('VITE_SERVER', 'http://185.175.44.194:5173');
|
||||||
|
define('VITE_ENTRY_POINT', '/main.js');
|
||||||
|
|
||||||
|
// Define dist directory, base uri, and path
|
||||||
|
define('DIST_DIR', 'dist');
|
||||||
|
define('DIST_URI', get_template_directory_uri() . '/' . DIST_DIR);
|
||||||
|
define('DIST_PATH', get_template_directory() . '/' . DIST_DIR);
|
||||||
|
|
||||||
|
function vite_head_module_hook() {
|
||||||
|
echo '<script type="module" crossorigin src="'. VITE_SERVER .'/@vite/client"></script>';
|
||||||
|
echo '<script type="module" crossorigin src="'. VITE_SERVER . VITE_ENTRY_POINT . '"></script>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
add_action( 'wp_enqueue_scripts', function () {
|
||||||
|
if (defined('VITE_ENV') && VITE_ENV === 'dev') {
|
||||||
|
add_action( 'wp_head', 'vite_head_module_hook' );
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// Production version
|
||||||
|
$style_ver = filemtime(get_template_directory() . '/frontend/dist/assets/style.css');
|
||||||
|
$script_ver = filemtime(get_template_directory() . '/frontend/dist/assets/main.js');
|
||||||
|
|
||||||
|
wp_enqueue_style('main-style', get_template_directory_uri() . '/frontend/dist/assets/style.css', array(), $style_ver);
|
||||||
|
wp_enqueue_script('main-script', get_template_directory_uri() . '/frontend/dist/assets/main.js', array(), $script_ver, true);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user