isDir() || $template_file->getExtension() !== 'php') { continue; } // Получаем относительный путь (например, "pages/template-landing.php") $relative_path = str_replace($custom_templates_dir, '', $template_file->getPathname()); // Формируем имя шаблона (убираем .php и заменяем слэши на дефисы) $template_name = str_replace(['/', '.php'], [' - ', ''], $relative_path); // Добавляем в список шаблонов $templates['/modules/static-pages/' . $relative_path] = $template_name; } return $templates; }); /** * Подключает статические CSS и JS файлы из указанной директории и прописываем version в src * * @param string $dir_name Название директории в папке /static/ * @param array $options Дополнительные параметры: * - 'css' => false - отключить подключение CSS * - 'js' => false - отключить подключение JS * - 'version' => string - версия файлов (по умолчанию использует время модификации файла) */ /* find ./ -not -path "*cache*" -type f -exec grep -Ho --color=always 'enqueue_static_assets' {} \; ./wp-content/themes/cosmopet/temp-functions/modules-logic.php:enqueue_static_assets ./wp-content/themes/cosmopet/templates/about/template-about.php:enqueue_static_assets ./wp-content/themes/cosmopet/templates/production/template-prod-page.php:enqueue_static_assets */ function enqueue_static_assets($dir_name, $options = []) { // Устанавливаем пути к директориям $static_dir = get_template_directory() . '/static/' . $dir_name; $static_uri = get_template_directory_uri() . '/static/' . $dir_name; // Подключаем CSS файлы if (!isset($options['css']) || $options['css'] !== false) { $css_dir = $static_dir . '/css/'; if (file_exists($css_dir)) { $css_files = scandir($css_dir); foreach ($css_files as $file) { if (pathinfo($file, PATHINFO_EXTENSION) === 'css') { $handle = $dir_name . '-' . pathinfo($file, PATHINFO_FILENAME); $src = $static_uri . '/css/' . $file; $ver = isset($options['version']) ? $options['version'] : filemtime($css_dir . $file); wp_enqueue_style( $handle, $src, array(), $ver ); } } } } // Подключаем JS файлы if (!isset($options['js']) || $options['js'] !== false) { $js_dir = $static_dir . '/js/'; if (file_exists($js_dir)) { $js_files = scandir($js_dir); foreach ($js_files as $file) { if (pathinfo($file, PATHINFO_EXTENSION) === 'js') { $handle = $dir_name . '-' . pathinfo($file, PATHINFO_FILENAME); $src = $static_uri . '/js/' . $file; $ver = isset($options['version']) ? $options['version'] : filemtime($js_dir . $file); $in_footer = strpos($file, 'admin') === 0 ? false : true; wp_enqueue_script( $handle, $src, array(), $ver, $in_footer ); } } } } } /* Вставить в поиск по модулям */ $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')) { include_component('shop', 'checkout'); } }