133 lines
5.1 KiB
PHP
133 lines
5.1 KiB
PHP
<?php
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
require_once get_stylesheet_directory() . '/inc/theme-data.php';
|
|
require_once get_stylesheet_directory() . '/inc/routes.php';
|
|
require_once get_stylesheet_directory() . '/inc/forms.php';
|
|
|
|
add_action( 'after_setup_theme', 'sev_tort_theme_setup' );
|
|
function sev_tort_theme_setup() {
|
|
add_theme_support( 'title-tag' );
|
|
add_theme_support( 'post-thumbnails' );
|
|
}
|
|
|
|
add_action( 'wp_enqueue_scripts', 'sev_tort_enqueue_assets' );
|
|
function sev_tort_enqueue_assets() {
|
|
$theme_version = wp_get_theme()->get( 'Version' );
|
|
$uri = get_stylesheet_directory_uri();
|
|
$page = sev_tort_current_page_config();
|
|
|
|
wp_enqueue_style( 'sev-tort-normalize', $uri . '/assets/css/normalize.min.css', array(), $theme_version );
|
|
wp_enqueue_style( 'sev-tort-reset', $uri . '/assets/css/reset.min.css', array( 'sev-tort-normalize' ), $theme_version );
|
|
wp_enqueue_style( 'sev-tort-core', $uri . '/assets/css/style-core.css', array( 'sev-tort-reset' ), $theme_version );
|
|
wp_enqueue_style( 'sev-tort-layout', $uri . '/assets/css/layout.css', array( 'sev-tort-core' ), $theme_version );
|
|
|
|
$responsive_dependencies = array( 'sev-tort-layout' );
|
|
|
|
if ( $page ) {
|
|
$style = 'portfolio' === $page['slug'] ? 'portfolio-page.css' : ( isset( $page['style'] ) ? $page['style'] : 'service-page.css' );
|
|
wp_enqueue_style( 'sev-tort-page', $uri . '/assets/css/' . $style, array( 'sev-tort-layout' ), $theme_version );
|
|
$responsive_dependencies = array( 'sev-tort-page' );
|
|
} elseif ( is_front_page() ) {
|
|
wp_enqueue_style( 'sev-tort-page', $uri . '/assets/css/home-page.css', array( 'sev-tort-layout' ), $theme_version );
|
|
$responsive_dependencies = array( 'sev-tort-page' );
|
|
}
|
|
|
|
wp_enqueue_style( 'sev-tort-responsive', $uri . '/assets/css/responsive.css', $responsive_dependencies, $theme_version );
|
|
wp_enqueue_script( 'sev-tort-site', $uri . '/assets/js/site.js', array(), $theme_version, true );
|
|
}
|
|
|
|
add_action( 'wp_enqueue_scripts', 'sev_tort_dequeue_parent_assets', 30 );
|
|
function sev_tort_dequeue_parent_assets() {
|
|
$handles = array(
|
|
'twentytwentyfive-style',
|
|
'twentytwentyfive-custom-header',
|
|
'twentytwentyfive-custom-footer',
|
|
'twentytwentyfive-custom-home',
|
|
);
|
|
|
|
foreach ( $handles as $handle ) {
|
|
wp_dequeue_style( $handle );
|
|
wp_deregister_style( $handle );
|
|
wp_dequeue_script( $handle );
|
|
wp_deregister_script( $handle );
|
|
}
|
|
}
|
|
|
|
add_filter( 'body_class', 'sev_tort_body_classes' );
|
|
function sev_tort_body_classes( $classes ) {
|
|
$page = sev_tort_current_page_config();
|
|
|
|
$classes[] = 'site-page';
|
|
|
|
if ( $page ) {
|
|
$classes[] = 'page-' . sanitize_html_class( $page['slug'] );
|
|
$classes[] = 'sev-page--' . sanitize_html_class( $page['slug'] );
|
|
} elseif ( is_front_page() ) {
|
|
$classes[] = 'page-home';
|
|
$classes[] = 'sev-page--home';
|
|
}
|
|
|
|
return $classes;
|
|
}
|
|
|
|
add_action( 'wp_head', 'sev_tort_meta_tags', 1 );
|
|
function sev_tort_meta_tags() {
|
|
$page = sev_tort_current_page_config();
|
|
|
|
if ( ! $page ) {
|
|
return;
|
|
}
|
|
|
|
$robots = ! empty( $page['indexable'] ) ? 'index, follow' : 'noindex, nofollow';
|
|
printf( '<meta name="robots" content="%s">' . "\n", esc_attr( $robots ) );
|
|
|
|
if ( 'politika-konfidencialnosti' === $page['slug'] ) {
|
|
printf( '<meta name="description" content="%s">' . "\n", esc_attr( 'Политика в отношении обработки персональных данных посетителей сайта sevastopol-tort.ru.' ) );
|
|
printf( '<link rel="canonical" href="%s">' . "\n", esc_url( home_url( '/' . $page['slug'] . '/' ) ) );
|
|
return;
|
|
}
|
|
|
|
if ( ! empty( $page['description'] ) ) {
|
|
printf( '<meta name="description" content="%s">' . "\n", esc_attr( $page['description'] ) );
|
|
}
|
|
|
|
printf( '<link rel="canonical" href="%s">' . "\n", esc_url( home_url( '/' . $page['slug'] . '/' ) ) );
|
|
}
|
|
|
|
add_action( 'wp_head', 'sev_tort_favicon_tags', 2 );
|
|
function sev_tort_favicon_tags() {
|
|
$favicon_uri = get_stylesheet_directory_uri() . '/assets/images/favicon/';
|
|
|
|
printf( '<link rel="icon" href="%s" sizes="any">' . "\n", esc_url( home_url( '/favicon.ico' ) ) );
|
|
printf( '<link rel="icon" type="image/png" sizes="32x32" href="%s">' . "\n", esc_url( $favicon_uri . 'favicon-32x32.png' ) );
|
|
printf( '<link rel="icon" type="image/png" sizes="16x16" href="%s">' . "\n", esc_url( $favicon_uri . 'favicon-16x16.png' ) );
|
|
printf( '<link rel="apple-touch-icon" sizes="180x180" href="%s">' . "\n", esc_url( $favicon_uri . 'apple-touch-icon.png' ) );
|
|
printf( '<link rel="icon" type="image/png" sizes="192x192" href="%s">' . "\n", esc_url( $favicon_uri . 'android-chrome-192x192.png' ) );
|
|
echo '<meta name="theme-color" content="#fff8f3">' . "\n";
|
|
}
|
|
|
|
add_filter( 'pre_get_document_title', 'sev_tort_document_title' );
|
|
function sev_tort_document_title( $title ) {
|
|
$page = sev_tort_current_page_config();
|
|
|
|
if ( ! $page ) {
|
|
return $title;
|
|
}
|
|
|
|
if ( 'politika-konfidencialnosti' === $page['slug'] ) {
|
|
return 'Политика в отношении обработки персональных данных';
|
|
}
|
|
|
|
return $page['title'];
|
|
}
|
|
|
|
add_action( 'after_switch_theme', 'sev_tort_flush_rewrite_rules' );
|
|
function sev_tort_flush_rewrite_rules() {
|
|
sev_tort_register_rewrite_rules();
|
|
flush_rewrite_rules();
|
|
}
|