breadcrumbs.php
199 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Elementor; |
| 4 | |
| 5 | defined('ABSPATH') || exit; |
| 6 | |
| 7 | use ShopEngine\Widgets\Products; |
| 8 | |
| 9 | |
| 10 | class ShopEngine_Breadcrumbs extends \ShopEngine\Base\Widget |
| 11 | { |
| 12 | |
| 13 | public function config() { |
| 14 | return new ShopEngine_Breadcrumbs_Config(); |
| 15 | } |
| 16 | |
| 17 | protected function register_controls() { |
| 18 | |
| 19 | $this->start_controls_section( |
| 20 | 'shopengine_section_breadcrumbs_style', |
| 21 | [ |
| 22 | 'label' => esc_html__('Style', 'shopengine'), |
| 23 | 'tab' => Controls_Manager::TAB_STYLE, |
| 24 | ] |
| 25 | ); |
| 26 | |
| 27 | $this->add_control( |
| 28 | 'shopengine_breadcrumbs_text_color', |
| 29 | [ |
| 30 | 'label' => esc_html__('Text Color', 'shopengine'), |
| 31 | 'type' => Controls_Manager::COLOR, |
| 32 | 'default' => '#999999', |
| 33 | 'alpha' => false, |
| 34 | 'selectors' => [ |
| 35 | '{{WRAPPER}} .shopengine-breadcrumbs :is( .woocommerce-breadcrumb, i )' => 'color: {{VALUE}}', |
| 36 | ], |
| 37 | ] |
| 38 | ); |
| 39 | |
| 40 | $this->add_control( |
| 41 | 'shopengine_breadcrumbs_link_color', |
| 42 | [ |
| 43 | 'label' => esc_html__('Link Color', 'shopengine'), |
| 44 | 'type' => Controls_Manager::COLOR, |
| 45 | 'alpha' => false, |
| 46 | 'default' => '#999999', |
| 47 | 'selectors' => [ |
| 48 | '{{WRAPPER}} .shopengine-breadcrumbs .woocommerce-breadcrumb a' => 'color: {{VALUE}}', |
| 49 | ], |
| 50 | ] |
| 51 | ); |
| 52 | |
| 53 | $this->add_control( |
| 54 | 'shopengine_breadcrumbs_link_hover_color', |
| 55 | [ |
| 56 | 'label' => esc_html__('Link Hover Color', 'shopengine'), |
| 57 | 'type' => Controls_Manager::COLOR, |
| 58 | 'default' => '#101010', |
| 59 | 'alpha' => false, |
| 60 | 'selectors' => [ |
| 61 | '{{WRAPPER}} .shopengine-breadcrumbs .woocommerce-breadcrumb a:hover' => 'color: {{VALUE}}', |
| 62 | ], |
| 63 | ] |
| 64 | ); |
| 65 | |
| 66 | $this->add_group_control( |
| 67 | Group_Control_Typography::get_type(), |
| 68 | [ |
| 69 | 'name' => 'shopengine_breadcrumbs_text_typography', |
| 70 | 'selector' => '{{WRAPPER}} .shopengine-breadcrumbs .woocommerce-breadcrumb', |
| 71 | 'exclude' => ['text_decoration', 'letter_spacing'], |
| 72 | 'fields_options' => [ |
| 73 | 'typography' => [ |
| 74 | 'default' => 'custom', |
| 75 | ], |
| 76 | 'font_size' => [ |
| 77 | 'default' => [ |
| 78 | 'size' => '14', |
| 79 | 'unit' => 'px' |
| 80 | ], |
| 81 | 'label' => 'Font size (px)', |
| 82 | 'size_units' => ['px'], |
| 83 | ], |
| 84 | 'font_weight' => [ |
| 85 | 'default' => '500', |
| 86 | ], |
| 87 | 'text_transform' => [ |
| 88 | 'default' => 'uppercase', |
| 89 | ], |
| 90 | 'line_height' => [ |
| 91 | 'default' => [ |
| 92 | 'size' => '17', |
| 93 | 'unit' => 'px' |
| 94 | ] |
| 95 | ], |
| 96 | 'letter_spacing' => [ |
| 97 | 'default' => [ |
| 98 | 'size' => '0', |
| 99 | ] |
| 100 | ], |
| 101 | ], |
| 102 | ] |
| 103 | ); |
| 104 | |
| 105 | $this->add_responsive_control( |
| 106 | 'shopengine_breadcrumbs_alignment', |
| 107 | [ |
| 108 | 'label' => esc_html__('Alignment', 'shopengine'), |
| 109 | 'type' => Controls_Manager::CHOOSE, |
| 110 | 'options' => [ |
| 111 | 'flex-start' => [ |
| 112 | 'title' => esc_html__('Left', 'shopengine'), |
| 113 | 'icon' => 'eicon-text-align-left', |
| 114 | ], |
| 115 | 'center' => [ |
| 116 | 'title' => esc_html__('Center', 'shopengine'), |
| 117 | 'icon' => 'eicon-text-align-center', |
| 118 | ], |
| 119 | 'flex-end' => [ |
| 120 | 'title' => esc_html__('Right', 'shopengine'), |
| 121 | 'icon' => 'eicon-text-align-right', |
| 122 | ], |
| 123 | ], |
| 124 | 'selectors' => [ |
| 125 | '{{WRAPPER}} .shopengine-breadcrumbs .woocommerce-breadcrumb' => 'justify-content: {{VALUE}};', |
| 126 | ] |
| 127 | ] |
| 128 | ); |
| 129 | |
| 130 | $this->add_control( |
| 131 | 'shopengine_breadcrumbs_icon', |
| 132 | [ |
| 133 | 'label' => esc_html__('Icon', 'shopengine'), |
| 134 | 'type' => Controls_Manager::ICONS, |
| 135 | 'default' => [ |
| 136 | 'value' => 'fas fa-arrow-right', |
| 137 | 'library' => 'fa-solid', |
| 138 | ], |
| 139 | ] |
| 140 | ); |
| 141 | |
| 142 | $this->add_control( |
| 143 | 'shopengine_breadcrumbs_icon_size', |
| 144 | [ |
| 145 | 'label' => esc_html__('Icon Size (px)', 'shopengine'), |
| 146 | 'type' => Controls_Manager::SLIDER, |
| 147 | 'size_units' => ['px'], |
| 148 | 'default' => [ |
| 149 | 'size' => 9, |
| 150 | ], |
| 151 | 'selectors' => [ |
| 152 | '{{WRAPPER}} .shopengine-breadcrumbs i, |
| 153 | {{WRAPPER}} .shopengine-breadcrumbs .divider, |
| 154 | {{WRAPPER}} .shopengine-breadcrumbs .delimeter' => 'font-size: {{SIZE}}{{UNIT}};', |
| 155 | ] |
| 156 | ] |
| 157 | ); |
| 158 | |
| 159 | $this->add_control( |
| 160 | 'shopengine_breadcrumbs_space_between', |
| 161 | [ |
| 162 | 'label' => esc_html__('Space In-between', 'shopengine'), |
| 163 | 'type' => Controls_Manager::SLIDER, |
| 164 | 'default' => [ |
| 165 | 'size' => 8, |
| 166 | 'unit' => 'px' |
| 167 | ], |
| 168 | 'size_units' => ['px'], |
| 169 | 'range' => [ |
| 170 | 'px' => [ |
| 171 | 'min' => 0, |
| 172 | 'max' => 200, |
| 173 | ] |
| 174 | ], |
| 175 | 'selectors' => [ |
| 176 | '{{WRAPPER}} .shopengine-breadcrumbs .woocommerce-breadcrumb i' => 'margin: 0 {{SIZE}}{{UNIT}};', |
| 177 | '{{WRAPPER}} .shopengine-breadcrumbs .woocommerce-breadcrumb' => 'margin: 0;', |
| 178 | ], |
| 179 | 'separator' => 'before', |
| 180 | ] |
| 181 | ); |
| 182 | |
| 183 | $this->end_controls_section(); |
| 184 | } |
| 185 | |
| 186 | protected function screen() { |
| 187 | |
| 188 | $settings = $this->get_settings_for_display(); |
| 189 | |
| 190 | $post_type = get_post_type(); |
| 191 | |
| 192 | $product = Products::instance()->get_product($post_type); |
| 193 | |
| 194 | $tpl = Products::instance()->get_widget_template($this->get_name()); |
| 195 | |
| 196 | include $tpl; |
| 197 | } |
| 198 | } |
| 199 |