diff options
| author | Your Name <[email protected]> | 2025-11-14 20:45:04 -0500 |
|---|---|---|
| committer | Your Name <[email protected]> | 2025-11-14 20:45:04 -0500 |
| commit | e3aa629c7f8f8827dd540d5582e50b67dc53de07 (patch) | |
| tree | 9f9555e0d3c8ea96335685c645bb478a163338be /functions.php | |
| parent | 1743bc1b52f390e3942158fa7e911417bc869ee3 (diff) | |
| download | malcz-wordpress-theme-e3aa629c7f8f8827dd540d5582e50b67dc53de07.tar.gz malcz-wordpress-theme-e3aa629c7f8f8827dd540d5582e50b67dc53de07.zip | |
progress
Diffstat (limited to 'functions.php')
| -rw-r--r-- | functions.php | 70 |
1 files changed, 68 insertions, 2 deletions
diff --git a/functions.php b/functions.php index d971ab2..4358df1 100644 --- a/functions.php +++ b/functions.php @@ -1,9 +1,75 @@ <?php +$theme = wp_get_theme(); +define('THEME_VERSION', $theme->get('Version')); + +function malcz_theme_setup() { + add_theme_support('title-tag'); +} +add_action('after_setup_theme', 'malcz_theme_setup'); + function load_css() { - wp_register_style('picocss', get_template_directory_uri() . '/css/pico.css.min', array(), false, 'all' ); - wp_enqueue_style('picocss'); + wp_enqueue_style( + 'picocss', + get_template_directory_uri() . '/css/pico.min.css', + array(), + THEME_VERSION, + 'all' + ); + + wp_enqueue_style( + 'header', + get_template_directory_uri() . '/css/header.css', + array('picocss'), + THEME_VERSION, + 'all' + ); } add_action('wp_enqueue_scripts', 'load_css'); +function load_js() { + wp_enqueue_script( + 'theme-switcher', + get_template_directory_uri() . '/js/minimal-theme-switcher-picocss.js', + array(), + THEME_VERSION, + true + ); + + + wp_enqueue_script( + 'parallax-header', + get_template_directory_uri() . '/js/parallax-header.js', + array(), + THEME_VERSION, + true + ); +} +add_action('wp_enqueue_scripts', 'load_js'); + +add_theme_support('menus'); + +register_nav_menus( + + array( + 'top-menu' => 'Top Menu Location', + 'mobile-menu' => 'Mobile Menu Location' + ) + +); + +add_filter('nav_menu_link_attributes', function($atts, $item, $args, $depth) { + // Only target the top-menu + if ($args->theme_location === 'top-menu') { + // Add 'contrast' only to links that are NOT the current page + if (empty($atts['aria-current']) || $atts['aria-current'] === 'false') { + if (!empty($atts['class'])) { + $atts['class'] .= ' contrast'; + } else { + $atts['class'] = 'contrast'; + } + } + } + return $atts; +}, 10, 4); |
