%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/hudvard.eco-n-tech.co.uk/wp-content/themes/hudvardskliniken/
Upload File :
Create Path :
Current File : /var/www/hudvard.eco-n-tech.co.uk/wp-content/themes/hudvardskliniken/functions.php

<?php

class ChildTheme
{
    public function __construct()
    {
        // Cleaner WordPress markup
        add_theme_support('soil', 'clean-up');

        // Disable REST API
        add_theme_support('soil', 'disable-rest-api');

        // Disable asset versioning
        add_theme_support('soil', 'disable-asset-versioning');

        // Disable trackbacks
        add_theme_support('soil', 'disable-trackbacks');

        // Move all JS to the footer
        add_theme_support('soil', 'js-to-footer');

        $this->add_includes();
        $this->remove_actions();
        $this->add_shortcodes();
        $this->add_actions();
        $this->add_filters();
    }

    public function add_includes()
    {
    }

    public function remove_actions()
    {
    }

    public function add_shortcodes()
    {
        add_shortcode('custom_grid', [$this, 'custom_grid']);
        add_shortcode('custom_grid_second', [$this, 'custom_grid_second']);
        add_shortcode('custom_grid_kategori', [$this, 'custom_grid_kategori']);
        add_shortcode('prices_shortcode', [$this, 'prices_shortcode']);
    }

    public function add_actions()
    {
        add_action('wp_enqueue_scripts', [$this, 'add_scripts']);
        add_action('wp_enqueue_scripts', [$this, 'add_styles']);
        add_action('admin_enqueue_scripts', [$this, 'add_admin_styles']);
        add_action('vc_before_init', [$this, 'acf_prices_shortcode_vc_integration']);

        // Remove all junk from parent theme, e.g. the overflow of image size
        // Saves a ton of space on the server as well.
        add_action('init', function () {
            add_image_size('anstalld-small', 400, 600, ['center', 'center']);
            add_image_size('anstalld-medium', 600, 900, ['center', 'center']);

            remove_image_size('image-size-550x550');
            remove_image_size('portrait-mobile');
            remove_image_size('portrait-tablet');
            remove_image_size('portrait-desktop');
            remove_image_size('landscape-mobile');
            remove_image_size('landscape-tablet');
            remove_image_size('landscape-desktop');
            remove_image_size('portfolio-four_x_two_x-@mobile');
            remove_image_size('portfolio-three_x_two_x-@mobile');
            remove_image_size('portfolio-three_x_x-@mobile');
            remove_image_size('portfolio-four_x_x-@mobile');
            remove_image_size('portfolio-four_x_two_x-@2x');
            remove_image_size('portfolio-three_x_two_x-@2x');
            remove_image_size('portfolio-three_x_x-@2x');
            remove_image_size('portfolio-two_x_two_x-@2x');
            remove_image_size('portfolio-x_two_x-@2x');
            remove_image_size('portfolio-four_x_x-@2x');
            remove_image_size('portfolio-two_x_x-@2x');
            remove_image_size('portfolio-x_x-@2x');
            remove_image_size('portfolio-four_x_two_x');
            remove_image_size('portfolio-three_x_x');
            remove_image_size('portfolio-three_x_two_x');
            remove_image_size('portfolio-two_x_two_x');
            remove_image_size('portfolio-x_two_x');
            remove_image_size('portfolio-four_x_x');
            remove_image_size('portfolio-two_x_x');
            remove_image_size('portfolio-x_x');
            remove_image_size('blog-showcase-@2x');
            remove_image_size('blog-showcase');
            remove_image_size('blog-carousel-@2x');
            remove_image_size('blog-carousel');
            remove_image_size('image-size-550x55');
            remove_image_size('woocommerce-recent-carousel');
            remove_image_size('blog-magazine-thumbnail-@2x');
            remove_image_size('blog-magazine-thumbnail');
            remove_image_size('employees-small');
            remove_image_size('employees-large');
            remove_image_size('photo-album-thumbnail-square');
            remove_image_size('photo-album-thumbnail-small');
            remove_image_size('image-size-550x550-@2x');
            remove_image_size('image-size-150x150');
        });
    }

    public function add_filters()
    {
    }

    public function add_styles()
    {
        wp_enqueue_style('outlined-cf7-css', get_stylesheet_directory_uri() . '/assets/css/outline-transparent-cf7-form.css');
        wp_enqueue_style('bootstrap-style', get_stylesheet_directory_uri() . '/assets/css/bootstrap.min.css');
    }

    public function add_admin_styles()
    {
        wp_enqueue_style('mimmi-admin-css', get_stylesheet_directory_uri() . '/assets/css/admin.css');
    }

    public function add_scripts()
    {
        wp_enqueue_script('custom-js', get_stylesheet_directory_uri() . '/assets/js/custom.js');
        wp_enqueue_script('bootstrap-script', get_stylesheet_directory_uri() . '/assets/js/bootstrap.min.js');
    }

    function acf_prices_shortcode_vc_integration()
    {
        try {
            vc_map([
                "name" => __("Priser"),
                "base" => "prices_shortcode",
                "class" => "",
                "category" => __("Content"),
                "show_settings_on_create" => false,
            ]);
        } catch (Exception $e) {
        }
    }

    function custom_grid($atts)
    {
        $a = shortcode_atts([
            'over_page' => 0
        ], $atts);

        $args = [
            'post_parent' => get_the_ID(),
            'post_type' => 'page',
            'posts_per_page' => -1,
            'post_status' => 'published'
        ];

        $children = get_children($args);

        foreach ($children as $child) {
            $imageUrl = get_the_post_thumbnail_url($child->ID, 'large');
            ?>
            <div class="col-lg-4 col-md-4 col-xs-12 col-sm-6 custom-grid-item-container">
                <a href="<?php echo get_permalink($child->ID); ?>">
                    <div class="custom-grid-item">
                        <div class="custom-grid-image" style="background-image:url(<?php echo $imageUrl; ?>)"></div>
                        <div class="custom-grid-info-container">
                            <h4 class="custom-grid-title"><?php echo get_the_title($child->ID); ?></h4>
                            <p class="custom-grid-text">
                                <?php echo get_the_excerpt($child->ID); ?>
                            </p>
                        </div>
                    </div>
                </a>
            </div>

            <?php
        }
    }

    function custom_grid_second($atts)
    {
        $a = shortcode_atts([
            'over_page' => 0
        ], $atts);

        $args = [
            'post_parent' => get_the_ID(),
            'post_type' => 'page',
            'posts_per_page' => -1,
            'post_status' => 'published'
        ];

        $children = get_children($args);

        foreach ($children as $child) {
            $imageUrl = get_the_post_thumbnail_url($child->ID, 'large');
            ?>
            <div class="col-lg-6 col-md-6 col-xs-12 col-sm-6 custom-grid-2-item-container">
                <a href="<?php echo get_permalink($child->ID); ?>">
                    <div class="custom-grid-2-item">
                        <div class="custom-grid-2-image" style="background-image:url(<?php echo $imageUrl; ?>)">
                            <div class="custom-grid-2-info-container">
                                <div class="custom-grid-2-cont">
                                    <h4 class="custom-grid-2-title"><?php echo get_the_title($child->ID); ?></h4>
                                    <p class="custom-grid-2-text">
                                        <?php echo get_the_excerpt($child->ID); ?>
                                    </p>
                                </div>
                            </div>
                        </div>

                    </div>
                </a>
            </div>

            <?php
        }
    }

    function my_add_excerpts_to_pages()
    {
        add_post_type_support('page', 'excerpt');
    }

    // create two taxonomies, genres and writers for the post type "book"
    function create_page_taxonomies()
    {
        // Add new taxonomy, make it hierarchical (like categories)

        $args = [
            'hierarchical' => true,
            'show_ui' => true,
            'show_admin_column' => true,
            'query_var' => true,
            'rewrite' => ['slug' => 'kategori'],
        ];

        register_taxonomy('kategori', ['page'], $args);
    }

    function custom_grid_kategori($atts)
    {
        $a = shortcode_atts([
            'category' => 0
        ], $atts);
        $args = [
            'post_type' => 'page',
            'posts_per_page' => -1,
            'post_status' => 'published',
            'tax_query' => [
                [
                    'taxonomy' => 'kategori',
                    'field' => 'slug',
                    'terms' => $a['category']
                ],
            ],
        ];

        $children = new WP_Query($args);

        foreach ($children->posts as $child) {
            $imageUrl = get_the_post_thumbnail_url($child->ID, 'full');
            ?>
            <div class="col-lg-4 col-md-4 col-xs-12 col-sm-6 custom-grid-item-container personal">
                <a href="<?php echo get_permalink($child->ID); ?>">
                    <div class="custom-grid-item">
                        <img src="<?php echo $imageUrl; ?>"/>
                        <div class="custom-grid-info-container">
                            <h4 class="custom-grid-title"><?php echo get_the_title($child->ID); ?></h4>
                            <p class="custom-grid-text">
                                <?php echo get_field('yrkestitel', $child->ID); ?>
                            </p>

                        </div>
                    </div>
                </a>
            </div>

            <?php
        }
    }

    function prices_shortcode()
    {
        ob_start();

        if (have_rows('priser')):

            while (have_rows('priser')) : the_row();
                ?>

                <table class="custom-price-table">
                <thead>
                <tr>
                    <th>
                        <strong><?php echo get_sub_field('titel'); ?></strong>
                    </th>
                    <th>
                        <strong>Pris från</strong>
                    </th>
                </tr>
                </thead>
                <?php
                if (have_rows('specpris')) {
                    while (have_rows('specpris')) : the_row();

                        ?>
                        <tr>
                            <td>
                                <?php the_sub_field('namn'); ?>
                            </td>
                            <td>
                                <?php the_sub_field('pris'); ?>
                            </td>
                        </tr>
                    <?php
                    endwhile;
                    ?>
                    </table>
                    <?php
                }

            endwhile;

        endif;

        return ob_get_clean();
    }
}

new ChildTheme();

Zerion Mini Shell 1.0