<commit_before><?php
/**
 * Berclub Bern functions and definitions
 *
 * Set up the theme and provides some helper functions, which are used in the
 * theme as custom template tags. Others are attached to action and filter
 * hooks in WordPress to change core functionality.
 *
 * @package WordPress
 * @subpackage Bergclub_Bern
 */

/**
 * Only works in WordPress 4.1 or later.
 */
if (version_compare($GLOBALS['wp_version'], '4.1-alpha', '<')) {
    require get_template_directory() . '/inc/back-compat.php';
}

if (!function_exists('bcb_setup')) {
    /**
     * Sets up theme defaults and registers support for various WordPress features.
     *
     * Note that this function is hooked into the after_setup_theme hook, which
     * runs before the init hook. The init hook is too late for some features, such
     * as indicating support for post thumbnails.
     */
    function bcb_setup()
    {
        /*
         * Let WordPress manage the document title.
         * By adding theme support, we declare that this theme does not use a
         * hard-coded <title> tag in the document head, and expect WordPress to
         * provide it for us.
         */
        add_theme_support('title-tag');

        /*
         * Enable support for Post Thumbnails on posts and pages.
         *
         * See: https://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
         */
        add_theme_support('post-thumbnails');
        set_post_thumbnail_size(825, 510, true);

        // This theme uses wp_nav_menu() in one location.
        register_nav_menus(array(
            'header-menu' => __('Hauptmenü', 'header-navigation'),
        ));

        /*
         * Switch default core markup for search form, comment form, and comments
         * to output valid HTML5.
         */
        add_theme_support('html5', array(
            'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
        ));

        /*
         * Enable support for Post Formats.
         *
         * See: https://codex.wordpress.org/Post_Formats
         */
        add_theme_support('post-formats', array(
            'aside', 'image', 'video', 'quote', 'link', 'gallery', 'status', 'audio', 'chat'
        ));
    }
};

add_action('after_setup_theme', 'bcb_setup');

if ( ! function_exists( 'bcb_post_thumbnail' ) ) {
    /**
     * Display an optional post thumbnail.
     *
     * Wraps the post thumbnail in an anchor element on index views, or a div
     * element when on single views.
     */
    function bcb_post_thumbnail() {
        if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
            return;
        }

        if ( is_singular() ) {
            ?>

            <div class="post-thumbnail">
                <?php the_post_thumbnail(); ?>
            </div><!-- .post-thumbnail -->

        <?php }else{ ?>

            <a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true">
                <?php
                the_post_thumbnail( 'post-thumbnail', array( 'alt' => get_the_title() ) );
                ?>
            </a>

        <?php }
    }
}

if ( ! function_exists( 'bcb_enqueue_scripts' ) ) {
    /**
     * Adds needed style and script files
     */
    function bcb_enqueue_scripts()
    {
        wp_dequeue_script('jquery-core');
        wp_deregister_script('jquery-core');

        wp_enqueue_style('bootstrap', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
        wp_enqueue_style('font-roboto', 'https://fonts.googleapis.com/css?family=Roboto:400,400i', ['bootstrap']);
        //wp_enqueue_style('font-touren',  get_template_directory_uri() . '/css/fonts/touren.css', ['bootstrap']);
        if (!bcb_is_jugend()) {
            wp_enqueue_style('default', get_template_directory_uri() . '/css/bergclub.css', ['bootstrap']);
        } else {
            wp_enqueue_style('default', bcb_add_jugend_to_url(get_template_directory_uri() . '/css/jugend.css'), ['bootstrap']);
        }
        wp_enqueue_style('carousel', bcb_add_jugend_to_url(get_template_directory_uri() . '/css/carousel.css', true), ['bootstrap']);

        wp_add_inline_style('carousel', bcb_carousel_images_css());

        wp_enqueue_script('ielt9', bcb_add_jugend_to_url(get_template_directory_uri() . '/js/html5.js', true));
        wp_script_add_data('ielt9', 'conditional', 'lt IE 9');

        wp_enqueue_script('jquery-own', 'https://code.jquery.com/jquery-3.1.1.min.js', null, null, true);
        wp_enqueue_script('bootstrap', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js', ['jquery-own'], null, true);
        wp_enqueue_script('bergclub', bcb_add_jugend_to_url(get_template_directory_uri() . '/js/bergclub.js', true), ['jquery-own'], null, true);
    }
}

add_action( 'wp_enqueue_scripts', 'bcb_enqueue_scripts' );

if ( ! function_exists( 'bcb_carousel_images_css' ) ) {
    /**
     * Creates inline css for the background images located in folder img/carousel.
     * Adds the images in random order.
     *
     * @return string the needed inline style to include with `wp_enqueue_style`.
     */
    function bcb_carousel_images_css()
    {
        $images = get_option('bcb_background_images');
        shuffle($images);
        $carouselImages = "";
        $index = 0;
        foreach ($images as $image) {
            if ($image['active']) {
                $index++;
                $carouselImages .= ".item:nth-child(" . $index . "){background: url(" . bcb_add_jugend_to_url(get_template_directory_uri() . $image['filename'], true) . ") no-repeat " . $image['vertical'] . " ". $image['horizontal'] . " fixed;}";
            }<commit_msg>Add bergclub.css as wisywig editor style<commit_after><?php
/**
 * Berclub Bern functions and definitions
 *
 * Set up the theme and provides some helper functions, which are used in the
 * theme as custom template tags. Others are attached to action and filter
 * hooks in WordPress to change core functionality.
 *
 * @package WordPress
 * @subpackage Bergclub_Bern
 */

/**
 * Only works in WordPress 4.1 or later.
 */
if (version_compare($GLOBALS['wp_version'], '4.1-alpha', '<')) {
    require get_template_directory() . '/inc/back-compat.php';
}

if (!function_exists('bcb_setup')) {
    /**
     * Sets up theme defaults and registers support for various WordPress features.
     *
     * Note that this function is hooked into the after_setup_theme hook, which
     * runs before the init hook. The init hook is too late for some features, such
     * as indicating support for post thumbnails.
     */
    function bcb_setup()
    {
        /*
         * Let WordPress manage the document title.
         * By adding theme support, we declare that this theme does not use a
         * hard-coded <title> tag in the document head, and expect WordPress to
         * provide it for us.
         */
        add_theme_support('title-tag');

        /*
         * Enable support for Post Thumbnails on posts and pages.
         *
         * See: https://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
         */
        add_theme_support('post-thumbnails');
        set_post_thumbnail_size(825, 510, true);

        // This theme uses wp_nav_menu() in one location.
        register_nav_menus(array(
            'header-menu' => __('Hauptmenü', 'header-navigation'),
        ));

        /*
         * Switch default core markup for search form, comment form, and comments
         * to output valid HTML5.
         */
        add_theme_support('html5', array(
            'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
        ));

        /*
         * Enable support for Post Formats.
         *
         * See: https://codex.wordpress.org/Post_Formats
         */
        add_theme_support('post-formats', array(
            'aside', 'image', 'video', 'quote', 'link', 'gallery', 'status', 'audio', 'chat'
        ));
    }
};

add_action('after_setup_theme', 'bcb_setup');

if ( ! function_exists( 'bcb_post_thumbnail' ) ) {
    /**
     * Display an optional post thumbnail.
     *
     * Wraps the post thumbnail in an anchor element on index views, or a div
     * element when on single views.
     */
    function bcb_post_thumbnail() {
        if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
            return;
        }

        if ( is_singular() ) {
            ?>

            <div class="post-thumbnail">
                <?php the_post_thumbnail(); ?>
            </div><!-- .post-thumbnail -->

        <?php }else{ ?>

            <a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true">
                <?php
                the_post_thumbnail( 'post-thumbnail', array( 'alt' => get_the_title() ) );
                ?>
            </a>

        <?php }
    }
}

if ( ! function_exists( 'bcb_enqueue_scripts' ) ) {
    /**
     * Adds needed style and script files
     */
    function bcb_enqueue_scripts()
    {
        wp_dequeue_script('jquery-core');
        wp_deregister_script('jquery-core');

        wp_enqueue_style('bootstrap', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
        wp_enqueue_style('font-roboto', 'https://fonts.googleapis.com/css?family=Roboto:400,400i', ['bootstrap']);
        //wp_enqueue_style('font-touren',  get_template_directory_uri() . '/css/fonts/touren.css', ['bootstrap']);
        if (!bcb_is_jugend()) {
            wp_enqueue_style('default', get_template_directory_uri() . '/css/bergclub.css', ['bootstrap']);
        } else {
            wp_enqueue_style('default', bcb_add_jugend_to_url(get_template_directory_uri() . '/css/jugend.css'), ['bootstrap']);
        }
        wp_enqueue_style('carousel', bcb_add_jugend_to_url(get_template_directory_uri() . '/css/carousel.css', true), ['bootstrap']);

        wp_add_inline_style('carousel', bcb_carousel_images_css());

        wp_enqueue_script('ielt9', bcb_add_jugend_to_url(get_template_directory_uri() . '/js/html5.js', true));
        wp_script_add_data('ielt9', 'conditional', 'lt IE 9');

        wp_enqueue_script('jquery-own', 'https://code.jquery.com/jquery-3.1.1.min.js', null, null, true);
        wp_enqueue_script('bootstrap', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js', ['jquery-own'], null, true);
        wp_enqueue_script('bergclub', bcb_add_jugend_to_url(get_template_directory_uri() . '/js/bergclub.js', true), ['jquery-own'], null, true);
    }
}

add_action( 'wp_enqueue_scripts', 'bcb_enqueue_scripts' );

add_editor_style(  get_template_directory_uri() . '/css/bergclub.css' );

if ( ! function_exists( 'bcb_carousel_images_css' ) ) {
    /**
     * Creates inline css for the background images located in folder img/carousel.
     * Adds the images in random order.
     *
     * @return string the needed inline style to include with `wp_enqueue_style`.
     */
    function bcb_carousel_images_css()
    {
        $images = get_option('bcb_background_images');
        shuffle($images);
        $carouselImages = "";
        $index = 0;
        foreach ($images as $image) {
            if ($image['active']) {
                $index++;
                $carouselImages .= ".item:nth-child(" . $index . "){background: url(" . bcb_add_jugend_to_url(get_template_directory_uri() . $image['filename'], true) . ") no-repeat " . $image['vertical'] . " ". $image['horizontal'] . " fixed;}";
            }
{'fraction_non_alphanumeric': 0.13847090545359658, 'fraction_numerical': 0.005566669565973732, 'mean_word_length': 2.6043887147335423, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2493001', 'n_tokens_mistral': 3571, 'n_tokens_neox': 3463, 'n_words': 786}