Maks | wip: рефактинг проекта

dev_10_refactoring
parent bee34901be
commit 865ec23ab6
  1. 53
      wp-content/themes/cosmopet/functions.php
  2. 1
      wp-content/themes/cosmopet/global-functions/multisite-functions.php
  3. 2
      wp-content/themes/cosmopet/modules/blog/components/archive/component-controller.php
  4. 29
      wp-content/themes/cosmopet/temp-functions/modules-logic.php
  5. 28
      wp-content/themes/cosmopet/temp-functions/timber-logic.php

@ -37,32 +37,10 @@ add_action('init', function() {
}, 1); }, 1);
/* Вставить в поиск по модулям */
$modules_path = get_template_directory() . '/modules/*/editor-blocks/*/editor-block-controller.php';
foreach (glob($modules_path) as $file) {
require_once $file; // Подключаем каждый найденный файл
}
// include_module('blog');
require_once('modules/blog/module-ajax-controller.php'); // !!! внутри него include_module('blog');
require_once('modules/forms/module-ajax-controller.php');
require_once('modules/shop/module-ajax-controller.php');
require_once('modules/profile/module-ajax-controller.php');
require_once('modules/footer/module-ajax-controller.php');
require_once('modules/author/module-ajax-controller.php');
add_action('wp', 'my_custom_checkout_code');
function my_custom_checkout_code() {
if (function_exists('is_checkout') && is_checkout() && !is_order_received_page()) {
include_component('shop', 'checkout');
}
}
include_module('forms');
include_module('layout');
// include_module('forms'); // include_module('forms');
// include_module('shop'); // include_module('shop');
@ -72,38 +50,7 @@ include_module('layout');
// include_module('layout'); // include_module('layout');
class WooProduct extends Timber\Post {
protected $wc_product;
public function __construct ($pid = null) {
parent::__construct($pid);
$this->wc_product = wc_get_product($this->ID);
}
public function price() {
return $this->wc_product->get_price();
}
public function get_price_html() {
return $this->wc_product->get_price_html();
}
public function get_attr() {
return $this->wc_product->get_attribute('pa_compound');
}
public function get_test() {
return 'test';
}
};
add_filter('timber/post/classmap', function ($classmap) {
$custom_classmap = [
'product' => WooProduct::class,
];
return array_merge($classmap, $custom_classmap);
});
//Ajax подгрузка товаров в архиве //Ajax подгрузка товаров в архиве
add_action( 'wp_ajax_nopriv_get_products', 'get_products' ); add_action( 'wp_ajax_nopriv_get_products', 'get_products' );

@ -11,6 +11,7 @@ class SiteEnvironment
$map = [ $map = [
'cosmopet.ru' => ['mode' => 'production', 'region' => 'ru'], 'cosmopet.ru' => ['mode' => 'production', 'region' => 'ru'],
'cosmopet.ae' => ['mode' => 'production', 'region' => 'ae'], 'cosmopet.ae' => ['mode' => 'production', 'region' => 'ae'],
'cosmopet-test-dumb.cp.good-production.xyz' => ['mode' => 'develope', 'region' => 'ru'],
'cosmopet-test-ru.cp.good-production.xyz' => ['mode' => 'develope', 'region' => 'ru'], 'cosmopet-test-ru.cp.good-production.xyz' => ['mode' => 'develope', 'region' => 'ru'],
'cosmopet-test-ae.cp.good-production.xyz' => ['mode' => 'develope', 'region' => 'ae'], 'cosmopet-test-ae.cp.good-production.xyz' => ['mode' => 'develope', 'region' => 'ae'],
]; ];

@ -1,4 +1,4 @@
<?php <?php
include_component('blog', 'featured-slider'); include_component('blog', 'featured-slider');
include_component('blog', 'themes'); include_component('blog', 'themes');

@ -313,3 +313,32 @@ function enqueue_static_assets($dir_name, $options = []) {
} }
/* Вставить в поиск по модулям */
$modules_path = get_template_directory() . '/modules/*/editor-blocks/*/editor-block-controller.php';
foreach (glob($modules_path) as $file) {
require_once $file; // Подключаем каждый найденный файл
}
// include_module('blog');
require_once(__DIR__ . '/../modules/blog/module-ajax-controller.php'); // !!! внутри него include_module('blog');
require_once(__DIR__ . '/../modules/forms/module-ajax-controller.php');
require_once(__DIR__ . '/../modules/shop/module-ajax-controller.php');
require_once(__DIR__ . '/../modules/profile/module-ajax-controller.php');
require_once(__DIR__ . '/../modules/footer/module-ajax-controller.php');
require_once(__DIR__ . '/../modules/author/module-ajax-controller.php');
include_module('forms');
include_module('layout');
add_action('wp', 'my_custom_checkout_code');
function my_custom_checkout_code() {
if (function_exists('is_checkout') && is_checkout() && !is_order_received_page()) {
include_component('shop', 'checkout');
}
}

@ -41,3 +41,31 @@ add_action('init', function() {
return $context; return $context;
}); });
}, 1); }, 1);
class WooProduct extends Timber\Post {
protected $wc_product;
public function __construct ($pid = null) {
parent::__construct($pid);
$this->wc_product = wc_get_product($this->ID);
}
public function price() {
return $this->wc_product->get_price();
}
public function get_price_html() {
return $this->wc_product->get_price_html();
}
public function get_attr() {
return $this->wc_product->get_attribute('pa_compound');
}
};
add_filter('timber/post/classmap', function ($classmap) {
$custom_classmap = [
'product' => WooProduct::class,
];
return array_merge($classmap, $custom_classmap);
});

Loading…
Cancel
Save