You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Fakel-Gym/functions.php

168 lines
3.9 KiB

<?php
/**
* Theme setup.
*/
function tailpress_setup() {
add_theme_support( 'title-tag' );
register_nav_menus(
array(
'primary' => __( 'Primary Menu', 'tailpress' ),
)
);
add_theme_support(
'html5',
array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
)
);
add_theme_support( 'custom-logo' );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'align-wide' );
add_theme_support( 'wp-block-styles' );
add_theme_support( 'responsive-embeds' );
add_theme_support( 'editor-styles' );
add_editor_style( 'css/editor-style.css' );
}
add_action( 'after_setup_theme', 'tailpress_setup' );
/**
* Enqueue theme assets.
*/
function tailpress_enqueue_scripts() {
$theme = wp_get_theme();
wp_enqueue_style( 'tailpress', tailpress_asset( 'css/app.css' ), array(), $theme->get( 'Version' ) );
wp_enqueue_script( 'tailpress', tailpress_asset( 'js/app.js' ), array(), $theme->get( 'Version' ) );
}
add_action( 'wp_enqueue_scripts', 'tailpress_enqueue_scripts' );
/**
* Get asset path.
*
* @param string $path Path to asset.
*
* @return string
*/
function tailpress_asset( $path ) {
if ( wp_get_environment_type() === 'production' ) {
return get_stylesheet_directory_uri() . '/' . $path;
}
return add_query_arg( 'time', time(), get_stylesheet_directory_uri() . '/' . $path );
}
/**
* Adds option 'li_class' to 'wp_nav_menu'.
*
* @param string $classes String of classes.
* @param mixed $item The current item.
* @param WP_Term $args Holds the nav menu arguments.
*
* @return array
*/
function tailpress_nav_menu_add_li_class( $classes, $item, $args, $depth ) {
if ( isset( $args->li_class ) ) {
$classes[] = $args->li_class;
}
if ( isset( $args->{"li_class_$depth"} ) ) {
$classes[] = $args->{"li_class_$depth"};
}
return $classes;
}
add_filter( 'nav_menu_css_class', 'tailpress_nav_menu_add_li_class', 10, 4 );
/**
* Adds option 'submenu_class' to 'wp_nav_menu'.
*
* @param string $classes String of classes.
* @param mixed $item The current item.
* @param WP_Term $args Holds the nav menu arguments.
*
* @return array
*/
function tailpress_nav_menu_add_submenu_class( $classes, $args, $depth ) {
if ( isset( $args->submenu_class ) ) {
$classes[] = $args->submenu_class;
}
if ( isset( $args->{"submenu_class_$depth"} ) ) {
$classes[] = $args->{"submenu_class_$depth"};
}
return $classes;
}
add_filter( 'nav_menu_submenu_css_class', 'tailpress_nav_menu_add_submenu_class', 10, 3 );
function get_current_room() {
return pll_current_language() === 'gym' ? 'gym' : 'fitness';
}
$modal_file = get_template_directory() . '/template-parts/la-components/functions/modals.php';
$block_file = get_template_directory() . '/template-parts/la-components/functions/blocks.php';
if (file_exists($block_file)) {
require_once $block_file;
}
if (file_exists($modal_file)) {
require_once $modal_file;
}
function enqueue_swiper_assets() {
wp_enqueue_style(
'swiper-css',
'https://cdnjs.cloudflare.com/ajax/libs/Swiper/8.4.7/swiper-bundle.min.css',
array(),
'8.4.7'
);
wp_enqueue_script(
'swiper-js',
'https://cdnjs.cloudflare.com/ajax/libs/Swiper/8.4.7/swiper-bundle.min.js',
array(),
'8.4.7',
true
);
}
add_action('wp_enqueue_scripts', 'enqueue_swiper_assets');
add_action('admin_enqueue_scripts', 'enqueue_swiper_assets');
add_action('enqueue_block_editor_assets', 'enqueue_swiper_assets');
function display_icon($field_name)
{
$icon = get_field($field_name, 'option');
$icon_id = isset($icon['icon_url']) ? $icon['icon_url'] : 0;
if ($icon_id) {
echo wp_get_attachment_image($icon_id, 'full');
}
}
function wider_language_cols() {
echo '<style>
.wp-list-table td[class*=column-language_],
.wp-list-table th[class*=column-language_] {
width: 3em !important;
}
</style>';
}
add_action('admin_head', 'wider_language_cols');