|
|
|
@ -144,76 +144,76 @@ function include_module($module_name) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Регистрируем стили и скрипты |
|
|
|
|
add_action('wp_enqueue_scripts', function() use ($module_name, $module_dir) { |
|
|
|
|
// Подключаем стили |
|
|
|
|
$css_dir = $module_dir . '/assets/css'; |
|
|
|
|
if (is_dir($css_dir)) { |
|
|
|
|
$css_files = scandir($css_dir); |
|
|
|
|
|
|
|
|
|
// Приоритетные файлы |
|
|
|
|
$priority_files = [ |
|
|
|
|
'normalize.css', |
|
|
|
|
'gp-style-core.css', |
|
|
|
|
'gp-style-desktop.css', |
|
|
|
|
'gp-style-tablet.css', |
|
|
|
|
'gp-style-mobile.css' |
|
|
|
|
]; |
|
|
|
|
// Регистрируем стили и скрипты |
|
|
|
|
add_action('wp_enqueue_scripts', function() use ($module_name, $module_dir) { |
|
|
|
|
// Подключаем стили |
|
|
|
|
$css_dir = $module_dir . '/assets/css'; |
|
|
|
|
if (is_dir($css_dir)) { |
|
|
|
|
$css_files = scandir($css_dir); |
|
|
|
|
|
|
|
|
|
// Подключаем приоритетные файлы в заданном порядке |
|
|
|
|
foreach ($priority_files as $priority_file) { |
|
|
|
|
$file_path = $css_dir . '/' . $priority_file; |
|
|
|
|
if (file_exists($file_path)) { |
|
|
|
|
wp_enqueue_style( |
|
|
|
|
$module_name . '-' . pathinfo($priority_file, PATHINFO_FILENAME), |
|
|
|
|
get_template_directory_uri() . '/modules/' . $module_name . '/assets/css/' . $priority_file, |
|
|
|
|
[], |
|
|
|
|
filemtime($file_path) |
|
|
|
|
); |
|
|
|
|
// Приоритетные файлы |
|
|
|
|
$priority_files = [ |
|
|
|
|
'normalize.css', |
|
|
|
|
'gp-style-core.css', |
|
|
|
|
'gp-style-desktop.css', |
|
|
|
|
'gp-style-tablet.css', |
|
|
|
|
'gp-style-mobile.css' |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
// Подключаем приоритетные файлы в заданном порядке |
|
|
|
|
foreach ($priority_files as $priority_file) { |
|
|
|
|
$file_path = $css_dir . '/' . $priority_file; |
|
|
|
|
if (file_exists($file_path)) { |
|
|
|
|
wp_enqueue_style( |
|
|
|
|
$module_name . '-' . pathinfo($priority_file, PATHINFO_FILENAME), |
|
|
|
|
get_template_directory_uri() . '/modules/' . $module_name . '/assets/css/' . $priority_file, |
|
|
|
|
[], |
|
|
|
|
filemtime($file_path) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Подключаем остальные CSS-файлы |
|
|
|
|
foreach ($css_files as $css_file) { |
|
|
|
|
if ( |
|
|
|
|
pathinfo($css_file, PATHINFO_EXTENSION) === 'css' && |
|
|
|
|
$css_file !== '.' && |
|
|
|
|
$css_file !== '..' && |
|
|
|
|
!in_array($css_file, $priority_files) |
|
|
|
|
) { |
|
|
|
|
$file_path = $css_dir . '/' . $css_file; |
|
|
|
|
wp_enqueue_style( |
|
|
|
|
$module_name . '-' . pathinfo($css_file, PATHINFO_FILENAME), |
|
|
|
|
get_template_directory_uri() . '/modules/' . $module_name . '/assets/css/' . $css_file, |
|
|
|
|
[], |
|
|
|
|
filemtime($file_path) |
|
|
|
|
); |
|
|
|
|
// Подключаем остальные CSS-файлы |
|
|
|
|
foreach ($css_files as $css_file) { |
|
|
|
|
if ( |
|
|
|
|
pathinfo($css_file, PATHINFO_EXTENSION) === 'css' && |
|
|
|
|
$css_file !== '.' && |
|
|
|
|
$css_file !== '..' && |
|
|
|
|
!in_array($css_file, $priority_files) |
|
|
|
|
) { |
|
|
|
|
$file_path = $css_dir . '/' . $css_file; |
|
|
|
|
wp_enqueue_style( |
|
|
|
|
$module_name . '-' . pathinfo($css_file, PATHINFO_FILENAME), |
|
|
|
|
get_template_directory_uri() . '/modules/' . $module_name . '/assets/css/' . $css_file, |
|
|
|
|
[], |
|
|
|
|
filemtime($file_path) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Подключаем скрипты |
|
|
|
|
$js_dir = $module_dir . '/assets/js'; |
|
|
|
|
if (is_dir($js_dir)) { |
|
|
|
|
$js_files = scandir($js_dir); |
|
|
|
|
foreach ($js_files as $js_file) { |
|
|
|
|
if ( |
|
|
|
|
pathinfo($js_file, PATHINFO_EXTENSION) === 'js' && |
|
|
|
|
$js_file !== '.' && |
|
|
|
|
$js_file !== '..' |
|
|
|
|
) { |
|
|
|
|
$file_path = $js_dir . '/' . $js_file; |
|
|
|
|
wp_enqueue_script( |
|
|
|
|
$module_name . '-' . pathinfo($js_file, PATHINFO_FILENAME), |
|
|
|
|
get_template_directory_uri() . '/modules/' . $module_name . '/assets/js/' . $js_file, |
|
|
|
|
['jquery'], |
|
|
|
|
filemtime($file_path), |
|
|
|
|
true |
|
|
|
|
); |
|
|
|
|
// Подключаем скрипты |
|
|
|
|
$js_dir = $module_dir . '/assets/js'; |
|
|
|
|
if (is_dir($js_dir)) { |
|
|
|
|
$js_files = scandir($js_dir); |
|
|
|
|
foreach ($js_files as $js_file) { |
|
|
|
|
if ( |
|
|
|
|
pathinfo($js_file, PATHINFO_EXTENSION) === 'js' && |
|
|
|
|
$js_file !== '.' && |
|
|
|
|
$js_file !== '..' |
|
|
|
|
) { |
|
|
|
|
$file_path = $js_dir . '/' . $js_file; |
|
|
|
|
wp_enqueue_script( |
|
|
|
|
$module_name . '-' . pathinfo($js_file, PATHINFO_FILENAME), |
|
|
|
|
get_template_directory_uri() . '/modules/' . $module_name . '/assets/js/' . $js_file, |
|
|
|
|
['jquery'], |
|
|
|
|
filemtime($file_path), |
|
|
|
|
true |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Подключаем контроллер модуля |
|
|
|
@ -325,6 +325,7 @@ add_filter('theme_page_templates', function ($templates) { |
|
|
|
|
return $templates; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
/* Подключаем все файлы с глобальными функциями */ |
|
|
|
|
includeFilesFromFolder(get_template_directory() . '/global-functions'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|