Current File : /home/bravrvjk/cepurhuye.rw/wp-content/plugins/bopea-function/block//simple-menu.php
<?php
namespace bopeaElementor\Widgets;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Image_Size;
use Elementor\Group_Control_Typography;
use Elementor\Schemes\Color;
use Elementor\Schemes\Typography;
use Elementor\Utils;
use Elementor\Control_Media;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Text_Shadow;
use Elementor\Group_Control_Background;
use Elementor\Repeater;
use Elementor\Icons_Manager;
defined('ABSPATH') || die();
class bopea_section_simple_menu extends Widget_Base {
public function get_name() {
return 'bopea-simple-menu';
}
public function get_title() {
return esc_html__( 'Jelly Simple Menu', 'bopea-function' );
}
public function get_icon() {
return 'eicon-editor-list-ol jl-icons';
}
public function get_categories() {
return [ 'bopea-elements-head' ];
}
protected function register_controls() {
$this->start_controls_section(
'content_section',
[
'label' => esc_html__( 'Inline Menu ', 'bopea-function' ),
]
);
$this->add_control(
'menu_style',
[
'label' => esc_html__( 'Menu Layout', 'bopea-function' ),
'type' => Controls_Manager::SELECT,
'default' => 'jl_menu_list',
'options' => [
'jl_menu_list' => esc_html__( 'Menu List', 'bopea-function' ),
'jl_menu_inline' => esc_html__( 'Menu Inline', 'bopea-function' ),
],
]
);
$this->add_control(
'jl_label_title', [
'label' => esc_html__( 'Label title', 'bopea-function' ),
'default' => 'Quick Links',
'type' => Controls_Manager::TEXT,
'label_block' => true,
'condition' => [
'menu_style' => ['jl_menu_inline']
]
]
);
$this->add_control(
'jl_menu_options',
array(
'label' => __( 'Custom Menu Link', 'bopea-function' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'bopea-function' ),
'label_off' => esc_html__( 'No', 'bopea-function' ),
'return_value' => 'yes',
'default' => 'no',
)
);
if ( ! empty( bopea_get_menus() ) ) {
$this->add_control(
'inline_menu_slug',
[
'label' => esc_html__( 'Menu', 'bopea-function' ),
'type' => Controls_Manager::SELECT,
'options' => bopea_get_menus(),
'default' => array_keys( bopea_get_menus() )[0],
'save_default' => true,
'separator' => 'after',
'description' => sprintf( __( 'Go to the <a href="%s" target="_blank">Menus Option</a> to manage your menus.', 'bopea-function' ), admin_url( 'nav-menus.php' ) ),
'condition' =>[
'jl_menu_options!' => 'yes'
]
]
);
} else {
$this->add_control(
'inline_menu_notice',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => sprintf( __( '<strong>There are no menus in your site.</strong><br>Go to the <a href="%s" target="_blank">Menus Option</a> to create one.', 'bopea-function' ), admin_url( 'nav-menus.php?action=edit&menu=0' ) ),
'separator' => 'after',
'condition' =>[
'jl_menu_options!' => 'yes'
]
]
);
}
$repeater = new Repeater();
$repeater->add_control(
'jl_list_text',
[
'label' => esc_html__( 'Menu Text', 'bopea-function' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'default' => esc_html__( 'List Text', 'bopea-function' ),
]
);
$repeater->add_control(
'jl_list_link',
[
'label' => __( 'Menu URL', 'bopea-function' ),
'type' => Controls_Manager::URL,
'placeholder' => __( 'https://your-link.com', 'bopea-function' ),
'show_external' => true,
'default' => [
'url' => '#',
]
]
);
$this->add_control(
'jl_list_group',
[
'label' => __( 'Menu Items', 'bopea-function' ),
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'default' => [
[
'jl_list_text' => 'Menu Item #1'
],
[
'jl_list_text' => 'Menu Item #2'
],
[
'jl_list_text' => 'Menu Item #3'
],
[
'jl_list_text' => 'Menu Item #4'
],
[
'jl_list_text' => 'Menu Item #5'
],
],
'title_field' => '{{{ jl_list_text }}}',
'condition' =>[
'jl_menu_options' => 'yes'
]
]
);
$this->end_controls_section();
$this->start_controls_section(
'section_tab_style', [
'label' => esc_html__( 'Menu Style', 'bopea-function' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'menu_position',
[
'label' => esc_html__( 'Menu position', 'bopea-function' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'flex-start' => [
'title' => esc_html__( 'Left', 'bopea-function' ),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => esc_html__( 'Center', 'bopea-function' ),
'icon' => 'eicon-text-align-center',
],
'flex-end' => [
'title' => esc_html__( 'Right', 'bopea-function' ),
'icon' => 'eicon-text-align-right',
]
],
'selectors' => [
'{{WRAPPER}} .jl_jinm' => 'justify-content: {{VALUE}};',
],
'condition' => [
'menu_style' => ['jl_menu_inline']
]
]
);
$this->add_responsive_control(
'area_alignment',
[
'label' => esc_html__( 'Text alignment', 'bopea-function' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => esc_html__( 'Left', 'bopea-function' ),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => esc_html__( 'Center', 'bopea-function' ),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => esc_html__( 'Right', 'bopea-function' ),
'icon' => 'eicon-text-align-right',
],
],
'selectors' => [
'{{WRAPPER}} .jlcm-main-jl_menu_list.widget_nav_menu ul li' => 'text-align: {{VALUE}};',
],
'condition' => [
'menu_style' => ['jl_menu_list']
]
]
);
$this->add_group_control(
\Elementor\Group_Control_Typography::get_type(),
[
'name' => 'menu_item_typography',
'label' => esc_html__( 'Typography', 'bopea-function' ),
'selector' => '{{WRAPPER}} .jlcm-main-jl_menu_list.widget_nav_menu ul li a, {{WRAPPER}} .jlcm-main-jl_menu_inline.widget_nav_menu ul li a',
]
);
$this->add_control(
'jl_menu_uline',
array(
'label' => __( 'Enable hover underline', 'bopea-function' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'bopea-function' ),
'label_off' => esc_html__( 'No', 'bopea-function' ),
'selectors' => [
'{{WRAPPER}} .jl_jinm li a:hover' => 'text-decoration: underline !important; text-decoration-color: currentColor;',
],
)
);
$this->add_control(
'jl_menu_sep',
array(
'label' => __( 'Enable menu divider', 'bopea-function' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'bopea-function' ),
'label_off' => esc_html__( 'No', 'bopea-function' ),
'selectors' => [
'{{WRAPPER}} .jl_jinm li a:after' => 'content: ""; width: 1.5px; height: 0.6em; background: var(--jl-m-divider); margin-left: var(--jl-min-gap); display: inline-flex;',
],
'condition' => [
'menu_style' => ['jl_menu_inline']
]
)
);
$this->add_responsive_control(
'menu_item_space',
[
'label' => esc_html__( 'Space menu', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 10,
],
'range' => [
'px' => [
'min' => 1,
'max' => 300,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}} .jlcm-main-jl_menu_inline.widget_nav_menu ul' => '--jl-min-gap:{{SIZE}}px; gap: 0px var(--jl-min-gap) !important; display: flex !important; padding: 0px; flex-direction: row !important; flex-wrap: wrap;margin-top: 0px !important;',
'{{WRAPPER}} .jlcm-main-jl_menu_inline.widget_nav_menu ul li' => 'list-style: none;',
],
'condition' => [
'menu_style' => ['jl_menu_inline']
]
]
);
$this->add_responsive_control(
'menu_item_col',
[
'label' => esc_html__( 'Number col', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 2,
],
'range' => [
'px' => [
'min' => 1,
'max' => 12,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}} .jlcm-main-jl_menu_list.widget_nav_menu ul' => 'grid-template-columns: repeat({{SIZE}},minmax(0,1fr)) !important; display: grid !important; padding: 0px;',
'{{WRAPPER}} .jlcm-main-jl_menu_list.widget_nav_menu ul li' => 'list-style: none;',
],
'condition' => [
'menu_style' => ['jl_menu_list']
]
]
);
$this->add_responsive_control(
'menu_item_space_col',
[
'label' => esc_html__( 'Space columns', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 7,
],
'range' => [
'px' => [
'min' => 0,
'max' => 300,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}} .jlcm-main-jl_menu_list.widget_nav_menu ul' => 'grid-column-gap: {{SIZE}}{{UNIT}} !important;',
],
'condition' => [
'menu_style' => ['jl_menu_list']
]
]
);
$this->add_responsive_control(
'menu_item_space_row',
[
'label' => esc_html__( 'Space row', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 7,
],
'range' => [
'px' => [
'min' => 0,
'max' => 300,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}} .jlcm-main-jl_menu_list.widget_nav_menu ul' => 'grid-row-gap: {{SIZE}}{{UNIT}} !important;',
],
'condition' => [
'menu_style' => ['jl_menu_list']
]
]
);
$this->add_control(
'menu_normal_color',
[
'label' => esc_html__( 'Color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .jlcm-main-jl_menu_list.widget_nav_menu ul li a, {{WRAPPER}} .jlcm-main-jl_menu_inline.widget_nav_menu ul li a' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'menu_normal_color_dark',
[
'label' => esc_html__( 'Color dark mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}} .jlcm-main-jl_menu_list.widget_nav_menu ul li a, .options_dark_skin {{WRAPPER}} .jlcm-main-jl_menu_inline.widget_nav_menu ul li a' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'menu_hover_color',
[
'label' => esc_html__( 'Color hover', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .jlcm-main-jl_menu_list.widget_nav_menu ul li a:hover, {{WRAPPER}} .jlcm-main-jl_menu_inline.widget_nav_menu ul li a:hover' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'menu_hover_color_dark',
[
'label' => esc_html__( 'Color hover dark mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}} .jlcm-main-jl_menu_list.widget_nav_menu ul li a:hover, .options_dark_skin {{WRAPPER}} .jlcm-main-jl_menu_inline.widget_nav_menu ul li a:hover' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'jl_mdcor',
[
'label' => esc_html__( 'Divider color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'default' => '#00000030',
'selectors' => [
'{{WRAPPER}}' => '--jl-m-divider: {{VALUE}};',
],
'condition' => [
'jl_menu_sep!' => ['']
]
]
);
$this->add_control(
'jl_mdcor_dark',
[
'label' => esc_html__( 'Divider color dark mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'default' => '#FFFFFF30',
'selectors' => [
'.options_dark_skin {{WRAPPER}}' => '--jl-m-divider: {{VALUE}};',
],
'condition' => [
'jl_menu_sep!' => ['']
]
]
);
$this->end_controls_section();
$this->start_controls_section(
'section_label_style', [
'label' => esc_html__( 'Label Style', 'bopea-function' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'jl_label_typography',
'label' => __( 'Label Typography', 'bopea-function' ),
'selector' => '{{WRAPPER}} .jl_lbl_op',
]
);
$this->add_control(
'jl_label_color',
[
'label' => __( 'Label Color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .jl_lbl_op' => 'color: {{VALUE}}',
],
]
);
$this->add_control(
'jl_label_color_dark',
[
'label' => __( 'Label Color Dark Mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}} .jl_lbl_op' => 'color: {{VALUE}}',
],
]
);
$this->add_control(
'jl_label_background',
[
'label' => __( 'Label Background', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .jl_lbl_op' => 'background: {{VALUE}}',
],
]
);
$this->add_control(
'jl_label_background_dark',
[
'label' => __( 'Label Background Dark Mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}} .jl_lbl_op' => 'background: {{VALUE}}',
],
]
);
$this->add_responsive_control(
'jl_label_spacing',
[
'label' => esc_html__( 'Label spacing', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px'],
'range' => [
'px' => [
'min' => 0,
'max' => 300,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}}' => '--jl-gap-lbl: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'jl_label_rounded',
[
'label' => esc_html__( 'Label border rounded', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px'],
'range' => [
'px' => [
'min' => 0,
'max' => 300,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}} .jl_lbl_op' => 'border-radius: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'jl_label_padding',
[
'label' => __( 'Label padding', 'bopea-function' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%'],
'selectors' => [
'{{WRAPPER}} .jl_lbl_op' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
]
]
);
$this->end_controls_section();
}
protected function render( ) {
$settings = $this->get_settings_for_display();
$jl_label_title = $settings['jl_label_title'];
$id = $this->get_id();
$this->add_render_attribute( 'area_attr', 'class', 'jlcm--simple-menu widget_nav_menu jlcm-main-'.$settings['menu_style'] );
$args = [
'echo' => false,
'menu' => $settings['inline_menu_slug'],
'menu_class' => 'menu',
'menu_id' => 'menu-'. $id,
'fallback_cb' => '__return_empty_string',
'container' => ''
];
$menu_html = wp_nav_menu( $args );
?>
<div class="jl_jinm jl_lbl_in">
<?php if (!empty($jl_label_title)) {?><span class="jl_lbl_op"><?php echo $jl_label_title;?></span><?php }?>
<div <?php echo $this->get_render_attribute_string( 'area_attr' ); ?> >
<?php if( $settings['jl_menu_options'] != 'yes' ){?>
<?php if( !empty( $menu_html ) ){
echo $menu_html;
}?>
<?php }else{?>
<ul class="menu">
<?php foreach( $settings['jl_list_group'] as $list ) : ?>
<?php
if ( !empty( $list['jl_list_link']['url'] ) ) {
$target = $list['jl_list_link']['is_external'] ? ' target="_blank"' : '';
$nofollow = $list['jl_list_link']['nofollow'] ? ' rel="nofollow"' : '';
}?>
<li>
<?php if ( !empty( $list['jl_list_link']['url'] ) ) { ?>
<a href="<?php echo $list['jl_list_link']['url']; ?>" <?php echo $target; ?> <?php echo $nofollow; ?>>
<?php } ?>
<?php if ( !empty( $list['jl_list_text'] ) ) { ?>
<span class="jl-list-group-text"><?php echo $list['jl_list_text']; ?></span>
<?php } ?>
<?php if ( !empty( $list['jl_list_link']['url'] ) ) { ?>
</a>
<?php } ?>
</li>
<?php endforeach; ?>
</ul>
<?php }?>
</div>
</div>
<?php
}
}