/** * Adds inline CSS in header. */ function bootswatch_css() { $css = ''; /** * Fix overlapping with WordPress admin bar. */ $css .= 'body.admin-bar .navbar-fixed-top{ top: 32px; }'; /** * Fix overlapping with Bootstrap's fixed navbar. */ if (bootswatch_use('fixed_navbar')) { $variables_path = bootswatch_get_option('theme') ? get_template_directory() . '/vendor/thomaspark/bootswatch/' . bootswatch_get_option('theme') . '/variables.less' : get_template_directory() . '/vendor/thomaspark/bootswatch/bower_components/bootstrap/less/variables.less'; $less_parser = new Less_Parser(); $less_parser->parseFile($variables_path, home_url()); $less_parser->parse('body { padding-top: (@navbar-height + @navbar-margin-bottom); }'); $css .= $less_parser->getCss(); } printf('<style>%s</style>', $css); // WPCS: xss ok. }
/** * Checks if an option is being used. * * @param string $option_id The Option id. * @return boolean Weither or not that option is being used */ function bootswatch_use($option_id) { return 'yes' === bootswatch_get_option($option_id); }
/** * Enqueue scripts and styles. */ function bootswatch_scripts() { /** * Bootswatch theme setting value. * * @var string */ $bootswatch_theme = bootswatch_get_option('theme'); /** * Selected Bootswatch theme, if none is selected, use Bootstrap. */ if ($bootswatch_theme) { $variables_overrides = ['@icon-font-path' => '../vendor/thomaspark/bootswatch/fonts/']; $variables_overrides = apply_filters('bootswatch_variables_overrides', $variables_overrides, $bootswatch_theme); $css_file_path = bootswatch_build($bootswatch_theme, $variables_overrides); $css_file_url = site_url(substr($css_file_path, strlen(ABSPATH))); wp_enqueue_style('bootswatch' . $bootswatch_theme, $css_file_url); } else { wp_enqueue_style('bootswatch-bootstrap', get_template_directory_uri() . '/vendor/thomaspark/bootswatch/bower_components/bootstrap/dist/css/bootstrap.min.css'); wp_enqueue_style('bootswatch-bootstrap-theme', get_template_directory_uri() . '/vendor/thomaspark/bootswatch/bower_components/bootstrap/dist/css/bootstrap-theme.min.css'); } /** * Style.css and company */ wp_enqueue_style('bootswatch', get_template_directory_uri() . '/style.css'); wp_enqueue_style('wordpress-core', get_template_directory_uri() . '/css/wordpress-core.css'); wp_enqueue_style('wordpress-core-overrides', get_template_directory_uri() . '/css/wordpress-core-overrides.css'); /** * Scripts. */ wp_enqueue_script('bootswatch-bootstrap', get_template_directory_uri() . '/vendor/thomaspark/bootswatch/bower_components/bootstrap/dist/js/bootstrap.min.js', array('jquery')); wp_enqueue_script('bootswatch', get_template_directory_uri() . '/js/script.js', array('jquery')); /** * Comment reply script. */ if (is_singular() && comments_open() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } }