header-info.php
288 lines
| 1 | <?php |
| 2 | namespace Elementor; |
| 3 | |
| 4 | use \Elementor\ElementsKit_Widget_Header_Info_Handler as Handler; |
| 5 | use \ElementsKit_Lite\Modules\Controls\Controls_Manager as ElementsKit_Controls_Manager; |
| 6 | |
| 7 | defined('ABSPATH') || exit; |
| 8 | |
| 9 | class ElementsKit_Widget_Header_Info extends Widget_Base |
| 10 | { |
| 11 | use \ElementsKit_Lite\Widgets\Widget_Notice; |
| 12 | |
| 13 | public $base; |
| 14 | |
| 15 | public function get_name() { |
| 16 | return Handler::get_name(); |
| 17 | } |
| 18 | |
| 19 | public function get_title() { |
| 20 | return Handler::get_title(); |
| 21 | } |
| 22 | |
| 23 | public function get_icon() { |
| 24 | return Handler::get_icon(); |
| 25 | } |
| 26 | |
| 27 | public function get_categories() { |
| 28 | return Handler::get_categories(); |
| 29 | } |
| 30 | |
| 31 | public function get_keywords() { |
| 32 | return Handler::get_keywords(); |
| 33 | } |
| 34 | |
| 35 | public function get_help_url() { |
| 36 | return 'https://wpmet.com/doc/header-info/'; |
| 37 | } |
| 38 | |
| 39 | public function get_style_depends() { |
| 40 | return ['ekit-header-info']; |
| 41 | } |
| 42 | |
| 43 | protected function is_dynamic_content(): bool { |
| 44 | return false; |
| 45 | } |
| 46 | |
| 47 | public function has_widget_inner_wrapper(): bool { |
| 48 | return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); |
| 49 | } |
| 50 | |
| 51 | protected function register_controls() |
| 52 | { |
| 53 | |
| 54 | $this->start_controls_section( |
| 55 | 'ekit_header_info', |
| 56 | [ |
| 57 | 'label' => esc_html__('Header Info', 'elementskit-lite'), |
| 58 | ] |
| 59 | ); |
| 60 | |
| 61 | $headerinfogroup = new Repeater(); |
| 62 | $headerinfogroup->add_control( |
| 63 | 'ekit_headerinfo_icons', |
| 64 | [ |
| 65 | 'label' => esc_html__('Icon', 'elementskit-lite'), |
| 66 | 'label_block' => true, |
| 67 | 'type' => Controls_Manager::ICONS, |
| 68 | 'default' => [ |
| 69 | 'value' => 'icon icon-map', |
| 70 | 'library' => 'ekiticons', |
| 71 | ], |
| 72 | |
| 73 | ] |
| 74 | ); |
| 75 | |
| 76 | $headerinfogroup->add_control( |
| 77 | 'ekit_headerinfo_text', |
| 78 | [ |
| 79 | 'label' => esc_html__('Text', 'elementskit-lite'), |
| 80 | 'label_block' => true, |
| 81 | 'type' => Controls_Manager::TEXT, |
| 82 | 'default' => '463 7th Ave, NY 10018, USA', |
| 83 | 'dynamic' => [ |
| 84 | 'active' => true, |
| 85 | ], |
| 86 | ] |
| 87 | ); |
| 88 | $headerinfogroup->add_control( |
| 89 | 'ekit_headerinfo_link', |
| 90 | [ |
| 91 | 'label' => esc_html__( 'Link', 'elementskit-lite' ), |
| 92 | 'type' => Controls_Manager::URL, |
| 93 | 'placeholder' => esc_html__( 'https://wpmet.com', 'elementskit-lite' ), |
| 94 | 'show_external' => true, |
| 95 | 'default' => [ |
| 96 | 'url' => '', |
| 97 | 'is_external' => true, |
| 98 | 'nofollow' => true, |
| 99 | ], |
| 100 | 'dynamic' => [ |
| 101 | 'active' => true, |
| 102 | ], |
| 103 | ] |
| 104 | ); |
| 105 | |
| 106 | $this->add_control( |
| 107 | 'ekit_headerinfo_group', |
| 108 | [ |
| 109 | 'label' => esc_html__( 'Header Info', 'elementskit-lite' ), |
| 110 | 'type' => Controls_Manager::REPEATER, |
| 111 | 'fields' => $headerinfogroup->get_controls(), |
| 112 | 'default' => [ |
| 113 | [ |
| 114 | 'ekit_headerinfo_text' => esc_html__( '463 7th Ave, NY 10018, USA', 'elementskit-lite' ), |
| 115 | ], |
| 116 | |
| 117 | ], |
| 118 | 'title_field' => '{{{ ekit_headerinfo_text }}}', |
| 119 | ] |
| 120 | ); |
| 121 | |
| 122 | $this->end_controls_section(); |
| 123 | $this->start_controls_section( |
| 124 | 'ekit_header_icon_style', |
| 125 | [ |
| 126 | 'label' => esc_html__( 'Header Info', 'elementskit-lite' ), |
| 127 | 'tab' => Controls_Manager::TAB_STYLE, |
| 128 | ] |
| 129 | ); |
| 130 | |
| 131 | $this->add_responsive_control( |
| 132 | 'ekit_info_item_margin', |
| 133 | [ |
| 134 | 'label' => esc_html__( 'Margin', 'elementskit-lite' ), |
| 135 | 'type' => Controls_Manager::DIMENSIONS, |
| 136 | 'size_units' => [ 'px', '%', 'em' ], |
| 137 | 'selectors' => [ |
| 138 | '{{WRAPPER}} .ekit-header-info > li' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 139 | ], |
| 140 | ] |
| 141 | ); |
| 142 | |
| 143 | $this->add_responsive_control( |
| 144 | 'ekit_info_item_padding', |
| 145 | [ |
| 146 | 'label' => esc_html__( 'Padding', 'elementskit-lite' ), |
| 147 | 'type' => Controls_Manager::DIMENSIONS, |
| 148 | 'size_units' => [ 'px', '%', 'em' ], |
| 149 | 'selectors' => [ |
| 150 | '{{WRAPPER}} .ekit-header-info > li' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 151 | ], |
| 152 | ] |
| 153 | ); |
| 154 | |
| 155 | $this->add_control( |
| 156 | 'ekit_info_text_color', |
| 157 | [ |
| 158 | 'label' => esc_html__( 'Text Color', 'elementskit-lite' ), |
| 159 | 'type' => Controls_Manager::COLOR, |
| 160 | 'default' => '', |
| 161 | 'selectors' => [ |
| 162 | '{{WRAPPER}} .ekit-header-info > li > a' => 'color: {{VALUE}};', |
| 163 | ], |
| 164 | ] |
| 165 | ); |
| 166 | |
| 167 | $this->add_control( |
| 168 | 'item_bg', |
| 169 | [ |
| 170 | 'label' => esc_html__( 'Background Color', 'elementskit-lite' ), |
| 171 | 'type' => Controls_Manager::COLOR, |
| 172 | 'selectors' => [ |
| 173 | '{{WRAPPER}} .ekit-header-info > li' => 'background-color: {{VALUE}};', |
| 174 | ], |
| 175 | ] |
| 176 | ); |
| 177 | |
| 178 | $this->add_group_control( |
| 179 | Group_Control_Typography::get_type(), |
| 180 | [ |
| 181 | 'name' => 'elementskit_content_typography', |
| 182 | 'label' => esc_html__( 'Typography', 'elementskit-lite' ), |
| 183 | 'selector' => '{{WRAPPER}} .ekit-header-info > li > a', |
| 184 | ] |
| 185 | ); |
| 186 | |
| 187 | $this->add_control( |
| 188 | 'icon', |
| 189 | [ |
| 190 | 'label' => __( 'Icon', 'elementskit-lite' ), |
| 191 | 'type' => \Elementor\Controls_Manager::HEADING, |
| 192 | 'separator' => 'before', |
| 193 | ] |
| 194 | ); |
| 195 | |
| 196 | $this->add_control( |
| 197 | 'ekit_info_icon_color', |
| 198 | [ |
| 199 | 'label' => esc_html__( 'Icon Color', 'elementskit-lite' ), |
| 200 | 'type' => Controls_Manager::COLOR, |
| 201 | 'default' => '', |
| 202 | 'selectors' => [ |
| 203 | '{{WRAPPER}} .ekit-header-info > li > a i' => 'color: {{VALUE}};', |
| 204 | '{{WRAPPER}} .ekit-header-info > li > a svg' => 'fill: {{VALUE}};', |
| 205 | ], |
| 206 | ] |
| 207 | ); |
| 208 | $this->add_responsive_control( |
| 209 | 'ekit_simple_tab_title_icon_size', |
| 210 | [ |
| 211 | 'label' => esc_html__( 'Icon Size', 'elementskit-lite' ), |
| 212 | 'type' => Controls_Manager::SLIDER, |
| 213 | 'size_units' => [ 'px', '%' ], |
| 214 | 'range' => [ |
| 215 | 'px' => [ |
| 216 | 'min' => 1, |
| 217 | 'max' => 100, |
| 218 | 'step' => 5, |
| 219 | ] |
| 220 | ], |
| 221 | 'selectors' => [ |
| 222 | '{{WRAPPER}} .ekit-header-info > li > a i' => 'font-size: {{SIZE}}{{UNIT}};', |
| 223 | '{{WRAPPER}} .ekit-header-info > li > a svg' => 'max-width: {{SIZE}}{{UNIT}}; height: auto', |
| 224 | ], |
| 225 | ] |
| 226 | ); |
| 227 | $this->add_responsive_control( |
| 228 | 'ekit_info_icon_spacing', |
| 229 | [ |
| 230 | 'label' => esc_html__( 'Icon Spacing', 'elementskit-lite' ), |
| 231 | 'type' => Controls_Manager::SLIDER, |
| 232 | 'default' => [ |
| 233 | 'size' => 10, |
| 234 | 'unit' => 'px', |
| 235 | ], |
| 236 | 'range' => [ |
| 237 | 'px' => [ |
| 238 | 'min' => 0, |
| 239 | 'max' => 100, |
| 240 | ], |
| 241 | ], |
| 242 | 'selectors' => [ |
| 243 | '{{WRAPPER}} .ekit-header-info > li > a i, {{WRAPPER}} .ekit-header-info > li > a svg' => 'margin-right: {{SIZE}}{{UNIT}};', |
| 244 | ], |
| 245 | ] |
| 246 | ); |
| 247 | |
| 248 | $this->end_controls_section(); |
| 249 | |
| 250 | $this->insert_pro_message(); |
| 251 | } |
| 252 | |
| 253 | |
| 254 | protected function render( ) { |
| 255 | echo '<div class="ekit-wid-con" >'; |
| 256 | $this->render_raw(); |
| 257 | echo '</div>'; |
| 258 | } |
| 259 | |
| 260 | protected function render_raw( ) { |
| 261 | $settings = $this->get_settings_for_display(); |
| 262 | ?> |
| 263 | <ul class="ekit-header-info"> |
| 264 | <?php |
| 265 | if ( $settings['ekit_headerinfo_group'] ){ |
| 266 | foreach ( $settings['ekit_headerinfo_group'] as $key => $item ){ |
| 267 | if ( ! empty( $item['ekit_headerinfo_link']['url'] ) ) { |
| 268 | $this->add_link_attributes( 'button-' . $key, $item['ekit_headerinfo_link'] ); |
| 269 | } |
| 270 | ?> |
| 271 | <li> |
| 272 | <a <?php echo $this->get_render_attribute_string( 'button-' . $key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Already escaped by elementor ?>> |
| 273 | <?php Icons_Manager::render_icon( $item['ekit_headerinfo_icons'], [ 'aria-hidden' => 'true' ] ); ?> |
| 274 | <?php echo esc_html($item['ekit_headerinfo_text']);?> |
| 275 | </a> |
| 276 | </li> |
| 277 | |
| 278 | <?php |
| 279 | |
| 280 | |
| 281 | } |
| 282 | } |
| 283 | ?> |
| 284 | </ul> |
| 285 | <?php |
| 286 | } |
| 287 | } |
| 288 |