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-nav.php
<?php
if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly.
}


use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;

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

/**
 * Class Service
 */
class Motiox_Elementor_Service_Nav extends Elementor\Widget_Base {

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

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

    public function get_icon() {
        return 'eicon-gallery-grid';
    }

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


    protected function register_controls() {

        $this->start_controls_section(
            'section_query',
            [
                'label' => esc_html__('Single Product Nav', 'motiox'),
                'tab'   => Controls_Manager::TAB_CONTENT,
            ]
        );

        $this->add_control(
            'name_service',
            [
                'label'   => esc_html__('Display Name', 'motiox'),
                'type'    => \Elementor\Controls_Manager::SWITCHER,
                'default' => 'yes',
            ]
        );

        $this->add_control(
            'text',
            [
                'label'   => esc_html__('Display Text', 'motiox'),
                'type'    => \Elementor\Controls_Manager::SWITCHER,
                'default' => 'yes',
            ]
        );

        $this->end_controls_section();

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

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'     => 'label_typography',
                'selector' => '{{WRAPPER}} .button-service-nav i',
            ]
        );

        $this->add_control(
            'nav_color',
            [
                'label'     => esc_html__('Color', 'motiox'),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .button-service-nav i' => 'color: {{VALUE}}',
                ],
            ]
        );

        $this->add_control(
            'nav_color_hover',
            [
                'label'     => esc_html__('Color Hover', 'motiox'),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .button-service-nav:hover i' => 'color: {{VALUE}}',
                ],
            ]
        );

        $this->add_responsive_control(
            'gap',
            [
                'label'      => esc_html__('Spacing', 'motiox'),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => ['px', 'em', 'rem', 'custom'],
                'range'      => [
                    'px' => [
                        'min' => 0,
                        'max' => 100,
                    ],
                ],
                'selectors'  => [
                    '{{WRAPPER}} .nav-prev i' => 'margin-right: {{SIZE}}{{UNIT}}',
                    '{{WRAPPER}} .nav-next i' => 'margin-left: {{SIZE}}{{UNIT}}',
                ],
            ]
        );

        $this->end_controls_section();

        $this->start_controls_section(
            'section_text',
            [
                'label'     => esc_html__('Text', 'motiox'),
                'tab'       => Controls_Manager::TAB_STYLE,
                'condition' => [
                    'text' => 'yes',
                ],
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'     => 'text_typography',
                'selector' => '{{WRAPPER}} .button-service-nav .reader-text',
            ]
        );

        $this->add_control(
            'text_color',
            [
                'label'     => esc_html__('Color', 'motiox'),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .button-service-nav .reader-text' => 'color: {{VALUE}}',
                ],
            ]
        );

        $this->add_control(
            'text_color_hover',
            [
                'label'     => esc_html__('Color Hover', 'motiox'),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .button-service-nav:hover .reader-text' => 'color: {{VALUE}}',
                ],
            ]
        );

        $this->end_controls_section();

        $this->start_controls_section(
            'section_title',
            [
                'label'     => esc_html__('Title', 'motiox'),
                'tab'       => Controls_Manager::TAB_STYLE,
                'condition' => [
                    'name_service' => 'yes',
                ],
            ]
        );

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

        $this->add_control(
            'title_color',
            [
                'label'     => esc_html__('Color', 'motiox'),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .button-service-nav .title' => 'color: {{VALUE}}',
                ],
            ]
        );

        $this->add_control(
            'title_color_hover',
            [
                'label'     => esc_html__('Color Hover', 'motiox'),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .button-service-nav:hover .title' => 'color: {{VALUE}}',
                ],
            ]
        );

        $this->end_controls_section();
    }


    public function render() {

        $obj        = $this->motiox_get_post_link();
        $prev_link  = $obj->previous_post;
        $next_link  = $obj->next_post;
        $prev_title = $obj->previous_title;
        $next_title = $obj->next_title;

        $settings = $this->get_settings_for_display();

        if (!empty($prev_link) || !empty($next_link)):
            ?>
            <div class="single-service-navigation single-navigation">
                <?php if (!empty($prev_link)): ?>
                    <div class="nav-prev">
                        <a class="button-service-nav" href="<?php echo esc_url($prev_link); ?>">
                        <span class="icon">
                            <i class="motiox-icon-long-arrow-left"></i>
                        </span>
                            <span class="content">
                                <?php if ($settings['text']) { ?>
                                    <span class="reader-text"><?php echo esc_html__('prev service', 'motiox') ?></span>
                                <?php } ?>
                                <?php if ($settings['name_service']) { ?>
                                    <span class="title"><?php echo esc_html($prev_title) ?></span>
                                <?php } ?>
                        </span>

                        </a>
                    </div>
                <?php endif; ?>

                <?php if (!empty($next_link)): ?>
                    <div class="nav-next">
                        <a class="button-service-nav" href="<?php echo esc_url($next_link); ?>">
                            <span class="content">
                                <?php if ($settings['text']) { ?>
                                    <span class="reader-text"><?php echo esc_html__('next service', 'motiox') ?></span>
                                <?php } ?>
                                <?php if ($settings['name_service']) { ?>
                                    <span class="title"><?php echo esc_html($next_title) ?></span>
                                <?php } ?>
                            </span>
                            <span class="icon">
                                <i class="motiox-icon-long-arrow-right"></i>
                            </span>
                        </a>
                    </div>
                <?php endif; ?>
            </div>
        <?php endif;
    }

    public function motiox_get_post_link($taxonomy = 'motiox_service_cat', $post_type = 'motiox_service') {

        $id    = get_queried_object_id(); // Get the current post ID
        $links = [
            'previous_post'  => null,
            'previous_title' => null,
            'next_post'      => null,
            'next_title'     => null,
            'previous'       => null,
            'next'           => null
        ];

        // Use a tax_query to get all posts from the given term
        // Just retrieve the ids to speed up the query
        $post_args = [
            'post_type'      => $post_type,
            'fields'         => 'ids',
            'posts_per_page' => -1,
        ];

        // Get all the posts having the given term from all post types
        $q = get_posts($post_args);

        //Get the current post position. Will be used to determine next/previous post
        $current_post_position = array_search($id, $q);

        // Get the previous/older post ID
        if (array_key_exists($current_post_position + 1, $q)) {
            $previous = $q[$current_post_position + 1];
        }
        // Get post title link to the previous post
        if (isset($previous)) {
            $previous_post_link = get_permalink($previous);
        }
        if (isset($previous)) {
            $previous_post  = get_post($previous);
            $previous_title = $previous_post->post_title;
        }

        // Get the next/newer post ID
        if (array_key_exists($current_post_position - 1, $q)) {
            $next = $q[$current_post_position - 1];
        }

        // Get post title link to the next post
        if (isset($next)) {
            $next_post_link = get_permalink($next);
        }
        if (isset($next)) {
            $next_post  = get_post($next);
            $next_title = $next_post->post_title;
        }

        if (isset($previous_post_link)) {
            $links['previous_post'] = $previous_post_link;

        }
        if (isset($previous_post_link)) {
            $links['previous_title'] = $previous_title;

        }

        if (isset($next_post_link)) {
            $links['next_post'] = $next_post_link;
        }
        if (isset($next_post_link)) {
            $links['next_title'] = $next_title;
        }

        return (object)$links;
    }


}

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