Uname: Linux webm012.cluster130.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
Software: Apache
PHP version: 8.0.30 [ PHP INFO ] PHP os: Linux
Server Ip: 145.239.37.162
Your Ip: 216.73.216.190
User: dreampi (1009562) | Group: users (100)
Safe Mode: OFF
Disable Function:
_dyuweyrj4,_dyuweyrj4r,dl

name : service.php
<?php

if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly.
}

use Motiox\Elementor\Motiox_Base_Widgets;
use Elementor\Controls_Manager;
use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
use Elementor\Group_Control_Background;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Border;

/**
 * Class Motiox_Elementor_Blog
 */
class Motiox_Elementor_Service extends Motiox_Base_Widgets {

    public function get_name() {
        return 'motiox-service';
    }

    public function get_title() {
        return esc_html__('Motiox Service', 'motiox');
    }

    /**
     * Get widget icon.
     *
     * Retrieve testimonial widget icon.
     *
     * @return string Widget icon.
     * @since  1.0.0
     * @access public
     *
     */
    public function get_icon() {
        return 'eicon-archive';
    }

    public function get_categories() {
        return array('motiox-addons');
    }

    public function get_script_depends() {
        return ['motiox-elementor-service'];
    }

    public function get_style_depends() {
        return [ 'e-swiper' ];
    }

    protected function register_controls() {
        $this->start_controls_section(
            'section_query',
            [
                'label' => esc_html__('Query', 'motiox'),
                'tab'   => Controls_Manager::TAB_CONTENT,
            ]
        );

        $this->add_control(
            'posts_per_page',
            [
                'label'   => esc_html__('Posts Per Page', 'motiox'),
                'type'    => Controls_Manager::NUMBER,
                'default' => 6,
            ]
        );


        $this->add_control(
            'advanced',
            [
                'label' => esc_html__('Advanced', 'motiox'),
                'type'  => Controls_Manager::HEADING,
            ]
        );

        $this->add_control(
            'orderby',
            [
                'label'   => esc_html__('Order By', 'motiox'),
                'type'    => Controls_Manager::SELECT,
                'default' => 'post_date',
                'options' => [
                    'post_date'  => esc_html__('Date', 'motiox'),
                    'post_title' => esc_html__('Title', 'motiox'),
                    'menu_order' => esc_html__('Menu Order', 'motiox'),
                    'rand'       => esc_html__('Random', 'motiox'),
                ],
            ]
        );

        $this->add_control(
            'order',
            [
                'label'   => esc_html__('Order', 'motiox'),
                'type'    => Controls_Manager::SELECT,
                'default' => 'desc',
                'options' => [
                    'asc'  => esc_html__('ASC', 'motiox'),
                    'desc' => esc_html__('DESC', 'motiox'),
                ],
            ]
        );

        $this->add_control(
            'categories',
            [
                'label'       => esc_html__('Categories', 'motiox'),
                'type'        => Controls_Manager::SELECT2,
                'options'     => $this->get_post_categories(),
                'label_block' => true,
                'multiple'    => true,
            ]
        );

        $this->add_control(
            'cat_operator',
            [
                'label'     => esc_html__('Category Operator', 'motiox'),
                'type'      => Controls_Manager::SELECT,
                'default'   => 'IN',
                'options'   => [
                    'AND'    => esc_html__('AND', 'motiox'),
                    'IN'     => esc_html__('IN', 'motiox'),
                    'NOT IN' => esc_html__('NOT IN', 'motiox'),
                ],
                'condition' => [
                    'categories!' => ''
                ],
            ]
        );

        $this->add_control(
            'posts',
            [
                'label'       => esc_html__('Posts', 'motiox'),
                'type'        => Controls_Manager::SELECT2,
                'options'     => $this->get_posts(),
                'label_block' => true,
                'multiple'    => true,
            ]
        );

        $this->add_control(
            'layout',
            [
                'label' => esc_html__('Layout', 'motiox'),
                'type'  => Controls_Manager::HEADING,
            ]
        );

        $this->add_control(
            'service_style',
            [
                'label'   => esc_html__('Style', 'motiox'),
                'type'    => \Elementor\Controls_Manager::SELECT,
                'options' => [
                    '1' => esc_html__('Style 1', 'motiox'),
                    '2' => esc_html__('Style 2', 'motiox'),
                    '3' => esc_html__('Style 3', 'motiox'),
                    '4' => esc_html__('Style 4', 'motiox'),
                ],
                'default' => '1'
            ]
        );

        $this->add_control(
            'title_scrolling',
            [
                'label'   => esc_html__('Title Scrolling', 'motiox'),
                'type'    => Controls_Manager::TEXT,
                'default' => 'Our Services',
                'condition' => [
                    'service_style' => '4'
                ],
            ]
        );

        $this->end_controls_section();

        // Style
        // Content
        $this->start_controls_section(
            'section_style_content',
            [
                'label' => esc_html__('Content', 'motiox'),
                'tab'   => Controls_Manager::TAB_STYLE,
            ]
        );

        $this->add_responsive_control(
            'style_content_padding',
            [
                'label'      => esc_html__('Padding', 'motiox'),
                'type'       => Controls_Manager::DIMENSIONS,
                'size_units' => ['px', 'em', '%'],
                'selectors'  => [
                    '{{WRAPPER}} .service-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );

        $this->add_responsive_control(
            'style_content_margin',
            [
                'label'      => esc_html__('Margin', 'motiox'),
                'type'       => Controls_Manager::DIMENSIONS,
                'size_units' => ['px', 'em', '%'],
                'selectors'  => [
                    '{{WRAPPER}} .service-content' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
                'condition' => [
                    'service_style!' => '4'
                ],
            ]
        );

        $this->add_responsive_control(
            'style_content_height',
            [
                'label'      => esc_html__('Height', 'motiox'),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => ['px', 'em', 'rem', '%', 'custom'],
                'range'      => [
                    'px' => [
                        'min' => 1,
                        'max' => 500,
                    ],
                ],
                'selectors'  => [
                    '{{WRAPPER}} .service-style-4' => '--height-service-4: {{SIZE}}{{UNIT}}',
                ],
                'condition' => [
                    'service_style' => '4'
                ],
            ]
        );

        $this->end_controls_section();

        // Title
        $this->start_controls_section(
            'section_style_title',
            [
                'label' => esc_html__('Title', 'motiox'),
                'tab'   => Controls_Manager::TAB_STYLE,
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'     => 'title_typography',
                'selector' => '{{WRAPPER}} .service-content .entry-title',
            ]
        );

        $this->add_responsive_control(
            'style_title_margin',
            [
                'label'      => esc_html__('Margin', 'motiox'),
                'type'       => Controls_Manager::DIMENSIONS,
                'size_units' => ['px', 'em', '%'],
                'selectors'  => [
                    '{{WRAPPER}} .service-content .entry-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );

        $this->end_controls_section();

        // Number
        $this->start_controls_section(
            'section_style_number',
            [
                'label' => esc_html__('Number', 'motiox'),
                'tab'   => Controls_Manager::TAB_STYLE,
                'condition' => [
                    'service_style' => '1'
                ],
            ]
        );

        $this->add_responsive_control(
            'style_number_margin',
            [
                'label'      => esc_html__('Margin', 'motiox'),
                'type'       => Controls_Manager::DIMENSIONS,
                'size_units' => ['px', 'em', '%'],
                'selectors'  => [
                    '{{WRAPPER}} .service-content .entry-index' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'     => 'number_typography',
                'selector' => '{{WRAPPER}} .service-content .entry-index',
            ]
        );

        $this->end_controls_section();

        // Image
        $this->start_controls_section(
            'section_style_image',
            [
                'label' => esc_html__('Image', 'motiox'),
                'tab'   => Controls_Manager::TAB_STYLE,
                'condition' => [
                    'service_style!' => ['2', '4']
                ],
            ]
        );

        $this->add_responsive_control(
            'style_image_width',
            [
                'label'      => esc_html__('Width', 'motiox'),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => ['px', 'em', 'rem', '%', 'custom'],
                'range'      => [
                    'px' => [
                        'min' => 1,
                        'max' => 500,
                    ],
                ],
                'selectors'  => [
                    '{{WRAPPER}} .service-image' => 'width: {{SIZE}}{{UNIT}}',
                ],
            ]
        );

        $this->add_responsive_control(
            'style_image_height',
            [
                'label'      => esc_html__('Height', 'motiox'),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => ['px', 'em', 'rem', '%', 'custom'],
                'range'      => [
                    'px' => [
                        'min' => 1,
                        'max' => 500,
                    ],
                ],
                'selectors'  => [
                    '{{WRAPPER}} .service-image' => 'height: {{SIZE}}{{UNIT}}',
                ],
            ]
        );

        $this->end_controls_section();

        // Icon
        $this->start_controls_section(
            'section_style_icon',
            [
                'label' => esc_html__('Icon', 'motiox'),
                'tab'   => Controls_Manager::TAB_STYLE,
                'condition' => [
                    'service_style' => '2'
                ],
            ]
        );

        $this->add_responsive_control(
            'style_icon_width',
            [
                'label'      => esc_html__('Width', 'motiox'),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => ['px', 'em', 'rem', '%', 'custom'],
                'range'      => [
                    'px' => [
                        'min' => 1,
                        'max' => 500,
                    ],
                ],
                'selectors'  => [
                    '{{WRAPPER}} .service-content .entry-icon ' => 'width: {{SIZE}}{{UNIT}}',
                ],
            ]
        );

        $this->add_responsive_control(
            'style_icon_height',
            [
                'label'      => esc_html__('Height', 'motiox'),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => ['px', 'em', 'rem', '%', 'custom'],
                'range'      => [
                    'px' => [
                        'min' => 1,
                        'max' => 500,
                    ],
                ],
                'selectors'  => [
                    '{{WRAPPER}} .service-content .entry-icon ' => 'height: {{SIZE}}{{UNIT}}',
                ],
            ]
        );

        $this->end_controls_section();

        // Description
        $this->start_controls_section(
            'section_style_description',
            [
                'label' => esc_html__('Description', 'motiox'),
                'tab'   => Controls_Manager::TAB_STYLE,
                'condition' => [
                    'service_style!' => '1'
                ],
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'     => 'description_typography',
                'selector' => '{{WRAPPER}} .service-content .excerpt-content',
            ]
        );

        $this->end_controls_section();

        // Button
        $this->start_controls_section(
            'section_style_button',
            [
                'label' => esc_html__('Button', 'motiox'),
                'tab'   => Controls_Manager::TAB_STYLE,
            ]
        );

        $this->add_responsive_control(
            'style_button_width',
            [
                'label'      => esc_html__('Width', 'motiox'),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => ['px', 'em', 'rem', 'custom'],
                'range'      => [
                    'px' => [
                        'min' => 1,
                        'max' => 500,
                    ],
                ],
                'selectors'  => [
                    '{{WRAPPER}} .service-content .entry-btn' => 'width: {{SIZE}}{{UNIT}}',
                    '{{WRAPPER}} .service-content .entry-bottom .entry-btn' => 'width: {{SIZE}}{{UNIT}}',
                ],
                'condition' => [
                    'service_style!' => ['2', '3']
                ],
            ]
        );

        $this->add_responsive_control(
            'style_button_height',
            [
                'label'      => esc_html__('Height', 'motiox'),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => ['px', 'em', 'rem', 'custom'],
                'range'      => [
                    'px' => [
                        'min' => 1,
                        'max' => 500,
                    ],
                ],
                'selectors'  => [
                    '{{WRAPPER}} .service-content .entry-btn' => 'height: {{SIZE}}{{UNIT}}',
                    '{{WRAPPER}} .service-content .entry-bottom .entry-btn' => 'height: {{SIZE}}{{UNIT}}',
                ],
                'condition' => [
                    'service_style!' => ['2', '3']
                ],
            ]
        );

        $this->add_responsive_control(
            'style_button_font-size_icon',
            [
                'label'      => esc_html__('Icon Size', 'motiox'),
                'type'       => Controls_Manager::SLIDER,
                'range'      => [
                    'px' => [
                        'min' => 0,
                        'max' => 100,
                    ],
                ],
                'size_units' => ['px', 'em'],
                'selectors'  => [
                    '{{WRAPPER}} .service-content .entry-btn i' => 'font-size: {{SIZE}}{{UNIT}};',
                    '{{WRAPPER}} .service-content .entry-bottom .entry-btn i' => 'font-size: {{SIZE}}{{UNIT}};',
                ],
                'condition' => [
                    'service_style!' => '2'
                ],
            ]
        );

        $this->add_responsive_control(
            'style_button_font-size_title',
            [
                'label'      => esc_html__('Font Size', 'motiox'),
                'type'       => Controls_Manager::SLIDER,
                'range'      => [
                    'px' => [
                        'min' => 0,
                        'max' => 100,
                    ],
                ],
                'size_units' => ['px', 'em'],
                'selectors'  => [
                    '{{WRAPPER}} .service-content .entry-btn' => 'font-size: {{SIZE}}{{UNIT}};',
                    '{{WRAPPER}} .service-content .entry-bottom .entry-btn' => 'font-size: {{SIZE}}{{UNIT}};',
                ],
                'condition' => [
                    'service_style' => ['2', '3']
                ],
            ]
        );

        $this->end_controls_section();


        $this->get_control_pagination();
        $this->get_controls_column();
        $this->get_control_carousel();
    }

    protected function get_post_categories() {
        $categories = get_terms(array(
                'taxonomy'   => 'motiox_service_cat',
                'hide_empty' => false,
            )
        );
        $results    = array();
        if (!is_wp_error($categories)) {
            foreach ($categories as $category) {
                $results[$category->slug] = $category->name;
            }
        }
        return $results;
    }

    protected function get_posts() {
        $argc = [
            'numberposts' => -1,
            'post_type'   => 'motiox_service',
        ];

        $posts = get_posts($argc);

        $results = array();

        if (!empty($posts)) {
            foreach ($posts as $post) {
                $results[$post->ID] = html_entity_decode(get_the_title($post->ID), ENT_QUOTES, 'UTF-8');
            }
        }

        return $results;
    }

    public static function get_query_args($settings) {
        $query_args = [
            'post_type'           => 'motiox_service',
            'orderby'             => $settings['orderby'],
            'order'               => $settings['order'],
            'ignore_sticky_posts' => 1,
            'post_status'         => 'publish',
        ];

        if (!empty($settings['categories'])) {
            $categories = array();
            foreach ($settings['categories'] as $category) {
                $cat = get_term_by('slug', $category, 'motiox_service_cat');
                if (!is_wp_error($cat) && is_object($cat)) {
                    $categories[] = $cat->term_id;
                }
            }

            $cat_operator = isset($settings['cat_operator']) ? $settings['cat_operator'] : 'IN';

            $query_args['tax_query'] = [
                'relation' => 'AND',
                [
                    'taxonomy' => 'motiox_service_cat',
                    'field'    => 'term_id',
                    'terms'    => $categories,
                    'operator' => $cat_operator,
                ],
            ];

        } elseif (!empty($settings['posts'])) {
            $query_args['post__in'] = $settings['posts'];
        }

        $query_args['posts_per_page'] = $settings['posts_per_page'];

        if (is_front_page()) {
            $query_args['paged'] = (get_query_var('page')) ? get_query_var('page') : 1;
        } else {
            $query_args['paged'] = (get_query_var('paged')) ? get_query_var('paged') : 1;
        }

        return $query_args;
    }

    public function query_posts() {
        $query_args = $this->get_query_args($this->get_settings());
        return new WP_Query($query_args);
    }


    protected function render() {
        $settings = $this->get_settings_for_display();

        $query = $this->query_posts();

        if (!$query->found_posts) {
            return;
        }
        $this->add_render_attribute('wrapper', 'class', ['elementor-service-wrapper']);
        $this->add_render_attribute('container', 'data-count', $query->post_count);
        // Item
        $this->add_render_attribute('item', 'class', 'elementor-service-item');
        $this->get_data_elementor_columns();

        ?>

        <div <?php $this->print_render_attribute_string('wrapper'); ?>>
            <div <?php $this->print_render_attribute_string('container'); ?>>
                <div <?php $this->print_render_attribute_string('inner'); ?>>
                    <?php
                        $i = 0;
                        while ($query->have_posts()) {
                            $i++;
                            $query->the_post(); ?>
                            <div <?php $this->print_render_attribute_string('item'); ?>>
                                <?php include get_theme_file_path('template-parts/service/content-style-'.$settings['service_style'].'.php');?>
                            </div>
                    <?php } ?>
                </div>
                <?php $this->get_swiper_navigation($query->post_count); ?>
            </div>
            <?php $this->render_loop_footer(); ?>
        </div>
        <?php
        wp_reset_postdata();
    }

}

$widgets_manager->register(new Motiox_Elementor_Service());
© 2026 GrazzMean-Shell