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.
 
 
 
 
cosmopet-architecture/wp-content/themes/cosmopet/temp-functions/timber-logic.php

102 lines
3.0 KiB

<<<<<<< HEAD
<?
use Timber;
use Timber\PostCollection;
use Timber\Integrations\WooCommerce\Product as TimberProduct;
Timber::$dirname = [
'views',
'modules'
];
// Настройка путей для WooCommerce шаблонов
add_filter('timber/loader/paths', function($paths) {
$paths[] = get_template_directory() . '/views/woocommerce';
return $paths;
});
add_filter( 'timber/integrations', function ( array $integrations ): array {
$integrations[] = new \Timber\Integrations\WooCommerce\WooCommerceIntegration();
return $integrations;
} );
// Add the function to the Timber context
add_filter('timber/context', function($context) {
$context['template_path'] = get_template_directory_uri();
$current_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$context['current_url'] = htmlspecialchars($current_url);
// Добавляем WooCommerce контекст если WooCommerce активен
if (class_exists('WooCommerce')) {
// WooCommerce автоматически добавляет свой контекст через интеграцию
// Но мы можем его расширить
if (is_woocommerce()) {
$context['is_woocommerce'] = true;
}
}
return $context;
});
add_action('init', function() {
add_filter('timber/context', function($context) {
$context['current_lang'] = pll_current_language();
// Добавляем функцию для получения иконки термина
$context['get_term_icon'] = function($term_id, $taxonomy) {
$product = new CosmopetProduct();
return $product->getTermIcon($term_id, $taxonomy);
};
return $context;
});
}, 1);
=======
<?
use Timber;
use Timber\PostCollection;
use Timber\Integrations\WooCommerce\Product as TimberProduct;
Timber::$dirname = [
[
'modules',
'views'
],
];
add_filter( 'timber/integrations', function ( array $integrations ): array {
$integrations[] = new \Timber\Integrations\WooCommerce\WooCommerceIntegration();
return $integrations;
} );
add_action('timber/init', function() {
// Инициализируем WooCommerce интеграцию
if (class_exists('Timber\Integrations\WooCommerce\WooCommerce')) {
Timber\Integrations\WooCommerce\WooCommerce::init();
}
});
// Add the function to the Timber context
add_filter('timber/context', function($context) {
$context['template_path'] = get_template_directory_uri();
$current_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$context['current_url'] = htmlspecialchars($current_url);
return $context;
});
add_action('init', function() {
add_filter('timber/context', function($context) {
$context['current_lang'] = pll_current_language();
return $context;
});
}, 1);
>>>>>>> 7da02c80 (Task 7719 | натяжка верстки single страницы товара)