我一直在研究 functions.php ,并希望基于当前环境创建Wordpress环境开发和生产。我想在生产环境中包含/导入带有哈希码的CSS文件,没有发展。
我想在生产模式下显示不同的CSS输出。
functions.php :
<?php
// Theme defines (NM).
define('THEME_DIR_ROOT', get_template_directory() . 'theme');
define('THEME_DIR_URI', get_template_directory_uri());
define('THEME_DIR_PARTS', THEME_DIR_ROOT . '/template-parts');
define('THEME_DIR_INCLUDES', THEME_DIR_ROOT . '/includes');
define('THEME_DIR_BUILD', THEME_DIR_URI . '/build');
define('THEME_DIR_CSS', THEME_DIR_BUILD . '/css');
define('THEME_DIR_JS', THEME_DIR_BUILD . '/js');
define('THEME_DIR_FONTS', THEME_DIR_BUILD . '/fonts');
define('THEME_DIR_IMAGES', THEME_DIR_BUILD . '/images');
// Theme Setup & requires
if (!function_exists('nm_setup')):
function nm_setup() {
// Theme includes
require THEME_DIR_INCLUDES . '/disable-comments.php';
require THEME_DIR_INCLUDES . '/remove-dashboard-widgets.php';
require THEME_DIR_INCLUDES . '/global-settings.php';
require THEME_DIR_INCLUDES . '/remove-wp-head.php';
// Theme supports
require THEME_DIR_ROOT . 'theme-supports.php';
// Functions which enhance the theme by hooking into WordPress.
require THEME_DIR_ROOT . 'template-functions.php';
// Theme register navigation menus
require THEME_DIR_ROOT . 'menus.php';
// Theme register sidebars
require THEME_DIR_ROOT . 'sidebars.php';
// Theme styles
require THEME_DIR_ROOT . 'styles.php';
// Theme Javascript
require THEME_DIR_ROOT . 'scripts.php';
}
endif;
add_action('after_setup_theme', 'nm_setup');
styles.php :
function nm_enqueue_style() {
wp_enqueue_style('nm-style', get_stylesheet_uri());
wp_enqueue_style('theme', THEME_DIR_CSS . '/prestigexotics.css', array());
}
add_action('wp_enqueue_scripts', 'nm_enqueue_style');