| @@ -7,9 +7,9 @@ | ||
| 7 | 7 | use Elementor\Group_Control_Border; |
| 8 | 8 | use Elementor\Group_Control_Box_Shadow; |
| 9 | 9 | use Elementor\Group_Control_Image_Size; |
| 10 | 10 | use Elementor\Group_Control_Typography; |
| 11 | -use Elementor\Utils; | |
| 11 | +use UltimateStoreKit\Classes\Utils; | |
| 12 | 12 | use UltimateStoreKit\Base\Module_Base; |
| 13 | 13 | |
| 14 | 14 | if (!defined('ABSPATH')) { |
| 15 | 15 | exit; |
| @@ -14,8 +14,10 @@ | ||
| 14 | 14 | if (!defined('ABSPATH')) { |
| 15 | 15 | exit; |
| 16 | 16 | } // Exit if accessed directly |
| 17 | 17 | |
| 18 | +// phpcs:disable WordPressVIPMinimum.Performance.WPQueryParams -- WordPressVIPMinimum targets the VIP platform, not the plugin directory. These exclusionary parameters come from a widget's own "exclude" control: the list is whatever the site owner picked in Elementor, applied to a bounded result set, not an unbounded catalogue scan. | |
| 19 | + | |
| 18 | 20 | class Featured_Box extends Module_Base { |
| 19 | 21 | |
| 20 | 22 | public function get_name() { |
| 21 | 23 | return 'usk-featured-box'; |
| @@ -48,9 +50,12 @@ | ||
| 48 | 50 | // public function get_custom_help_url() { |
| 49 | 51 | // return 'https://youtu.be/a_wJL950Kz4'; |
| 50 | 52 | // } |
| 51 | 53 | |
| 52 | - protected function register_controls() { | |
| 54 | + public function has_widget_inner_wrapper(): bool { | |
| 55 | + return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); | |
| 56 | + } | |
| 57 | + protected function register_controls() { | |
| 53 | 58 | |
| 54 | 59 | $this->start_controls_section( |
| 55 | 60 | 'section_layout', |
| 56 | 61 | [ |
| @@ -131,10 +136,11 @@ | ||
| 131 | 136 | 'image', |
| 132 | 137 | [ |
| 133 | 138 | 'label' => __('Image', 'ultimate-store-kit'), |
| 134 | 139 | 'type' => Controls_Manager::MEDIA, |
| 140 | + 'dynamic' => [ 'active' => true ], | |
| 135 | 141 | 'default' => [ |
| 136 | - 'url' => Utils::get_placeholder_image_src(), | |
| 142 | + 'url' => \Elementor\Utils::get_placeholder_image_src(), | |
| 137 | 143 | ], |
| 138 | 144 | 'selectors' => [ |
| 139 | 145 | '{{WRAPPER}} .usk-featured-box .usk-image-wrap' => 'background-image: url("{{URL}}");', |
| 140 | 146 | ], |
| @@ -144,24 +150,24 @@ | ||
| 144 | 150 | ); |
| 145 | 151 | $this->add_responsive_control( |
| 146 | 152 | 'position', |
| 147 | 153 | [ |
| 148 | - 'label' => esc_html__( 'Position', 'elementor' ), | |
| 154 | + 'label' => esc_html__( 'Position', 'ultimate-store-kit' ), | |
| 149 | 155 | 'type' => Controls_Manager::SELECT, |
| 150 | 156 | 'default' => '', |
| 151 | 157 | 'separator' => 'before', |
| 152 | 158 | 'options' => [ |
| 153 | - '' => esc_html__( 'Default', 'elementor' ), | |
| 154 | - 'center center' => esc_html__( 'Center Center', 'elementor' ), | |
| 155 | - 'center left' => esc_html__( 'Center Left', 'elementor' ), | |
| 156 | - 'center right' => esc_html__( 'Center Right', 'elementor' ), | |
| 157 | - 'top center' => esc_html__( 'Top Center', 'elementor' ), | |
| 158 | - 'top left' => esc_html__( 'Top Left', 'elementor' ), | |
| 159 | - 'top right' => esc_html__( 'Top Right', 'elementor' ), | |
| 160 | - 'bottom center' => esc_html__( 'Bottom Center', 'elementor' ), | |
| 161 | - 'bottom left' => esc_html__( 'Bottom Left', 'elementor' ), | |
| 162 | - 'bottom right' => esc_html__( 'Bottom Right', 'elementor' ), | |
| 163 | - 'initial' => esc_html__( 'Custom', 'elementor' ), | |
| 159 | + '' => esc_html__( 'Default', 'ultimate-store-kit' ), | |
| 160 | + 'center center' => esc_html__( 'Center Center', 'ultimate-store-kit' ), | |
| 161 | + 'center left' => esc_html__( 'Center Left', 'ultimate-store-kit' ), | |
| 162 | + 'center right' => esc_html__( 'Center Right', 'ultimate-store-kit' ), | |
| 163 | + 'top center' => esc_html__( 'Top Center', 'ultimate-store-kit' ), | |
| 164 | + 'top left' => esc_html__( 'Top Left', 'ultimate-store-kit' ), | |
| 165 | + 'top right' => esc_html__( 'Top Right', 'ultimate-store-kit' ), | |
| 166 | + 'bottom center' => esc_html__( 'Bottom Center', 'ultimate-store-kit' ), | |
| 167 | + 'bottom left' => esc_html__( 'Bottom Left', 'ultimate-store-kit' ), | |
| 168 | + 'bottom right' => esc_html__( 'Bottom Right', 'ultimate-store-kit' ), | |
| 169 | + 'initial' => esc_html__( 'Custom', 'ultimate-store-kit' ), | |
| 164 | 170 | |
| 165 | 171 | ], |
| 166 | 172 | 'selectors' => [ |
| 167 | 173 | '{{WRAPPER}} .usk-featured-box .usk-image-wrap' => 'background-position: {{VALUE}};', |
| @@ -174,9 +180,9 @@ | ||
| 174 | 180 | |
| 175 | 181 | $this->add_responsive_control( |
| 176 | 182 | 'xpos', |
| 177 | 183 | [ |
| 178 | - 'label' => esc_html__( 'X Position', 'elementor' ), | |
| 184 | + 'label' => esc_html__( 'X Position', 'ultimate-store-kit' ), | |
| 179 | 185 | 'type' => Controls_Manager::SLIDER, |
| 180 | 186 | 'responsive' => true, |
| 181 | 187 | 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ], |
| 182 | 188 | 'default' => [ |
| @@ -219,9 +225,9 @@ | ||
| 219 | 225 | |
| 220 | 226 | $this->add_responsive_control( |
| 221 | 227 | 'ypos', |
| 222 | 228 | [ |
| 223 | - 'label' => esc_html__( 'Y Position', 'elementor' ), | |
| 229 | + 'label' => esc_html__( 'Y Position', 'ultimate-store-kit' ), | |
| 224 | 230 | 'type' => Controls_Manager::SLIDER, |
| 225 | 231 | 'responsive' => true, |
| 226 | 232 | 'size_units' => [ 'px', '%', 'em', 'rem', 'vh', 'custom' ], |
| 227 | 233 | 'default' => [ |
| @@ -264,17 +270,17 @@ | ||
| 264 | 270 | |
| 265 | 271 | $this->add_responsive_control( |
| 266 | 272 | 'repeat', |
| 267 | 273 | [ |
| 268 | - 'label' => esc_html_x( 'Repeat', 'Background Control', 'elementor' ), | |
| 274 | + 'label' => esc_html_x( 'Repeat', 'Background Control', 'ultimate-store-kit' ), | |
| 269 | 275 | 'type' => Controls_Manager::SELECT, |
| 270 | 276 | 'default' => '', |
| 271 | 277 | 'options' => [ |
| 272 | - '' => esc_html__( 'Default', 'elementor' ), | |
| 273 | - 'no-repeat' => esc_html__( 'No-repeat', 'elementor' ), | |
| 274 | - 'repeat' => esc_html__( 'Repeat', 'elementor' ), | |
| 275 | - 'repeat-x' => esc_html__( 'Repeat-x', 'elementor' ), | |
| 276 | - 'repeat-y' => esc_html__( 'Repeat-y', 'elementor' ), | |
| 278 | + '' => esc_html__( 'Default', 'ultimate-store-kit' ), | |
| 279 | + 'no-repeat' => esc_html__( 'No-repeat', 'ultimate-store-kit' ), | |
| 280 | + 'repeat' => esc_html__( 'Repeat', 'ultimate-store-kit' ), | |
| 281 | + 'repeat-x' => esc_html__( 'Repeat-x', 'ultimate-store-kit' ), | |
| 282 | + 'repeat-y' => esc_html__( 'Repeat-y', 'ultimate-store-kit' ), | |
| 277 | 283 | ], |
| 278 | 284 | 'selectors' => [ |
| 279 | 285 | '{{WRAPPER}} .usk-featured-box .usk-image-wrap' => 'background-repeat: {{VALUE}};', |
| 280 | 286 | ], |
| @@ -286,17 +292,17 @@ | ||
| 286 | 292 | |
| 287 | 293 | $this->add_responsive_control( |
| 288 | 294 | 'size', |
| 289 | 295 | [ |
| 290 | - 'label' => esc_html__( 'Display Size', 'elementor' ), | |
| 296 | + 'label' => esc_html__( 'Display Size', 'ultimate-store-kit' ), | |
| 291 | 297 | 'type' => Controls_Manager::SELECT, |
| 292 | 298 | 'default' => '', |
| 293 | 299 | 'options' => [ |
| 294 | - '' => esc_html__( 'Default', 'elementor' ), | |
| 295 | - 'auto' => esc_html__( 'Auto', 'elementor' ), | |
| 296 | - 'cover' => esc_html__( 'Cover', 'elementor' ), | |
| 297 | - 'contain' => esc_html__( 'Contain', 'elementor' ), | |
| 298 | - 'initial' => esc_html__( 'Custom', 'elementor' ), | |
| 300 | + '' => esc_html__( 'Default', 'ultimate-store-kit' ), | |
| 301 | + 'auto' => esc_html__( 'Auto', 'ultimate-store-kit' ), | |
| 302 | + 'cover' => esc_html__( 'Cover', 'ultimate-store-kit' ), | |
| 303 | + 'contain' => esc_html__( 'Contain', 'ultimate-store-kit' ), | |
| 304 | + 'initial' => esc_html__( 'Custom', 'ultimate-store-kit' ), | |
| 299 | 305 | ], |
| 300 | 306 | 'selectors' => [ |
| 301 | 307 | '{{WRAPPER}} .usk-featured-box .usk-image-wrap' => 'background-size: {{VALUE}};', |
| 302 | 308 | ], |
| @@ -308,9 +314,9 @@ | ||
| 308 | 314 | |
| 309 | 315 | $this->add_responsive_control( |
| 310 | 316 | 'bg_width', |
| 311 | 317 | [ |
| 312 | - 'label' => esc_html__( 'Width', 'elementor' ), | |
| 318 | + 'label' => esc_html__( 'Width', 'ultimate-store-kit' ), | |
| 313 | 319 | 'type' => Controls_Manager::SLIDER, |
| 314 | 320 | 'responsive' => true, |
| 315 | 321 | 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ], |
| 316 | 322 | 'range' => [ |
| @@ -370,8 +376,23 @@ | ||
| 370 | 376 | 'separator' => 'before', |
| 371 | 377 | ] |
| 372 | 378 | ); |
| 373 | 379 | |
| 380 | + $this->add_control( | |
| 381 | + 'badge_text', | |
| 382 | + [ | |
| 383 | + 'label' => esc_html__('Badge Text', 'ultimate-store-kit'), | |
| 384 | + 'type' => Controls_Manager::TEXT, | |
| 385 | + 'dynamic' => ['active' => true], | |
| 386 | + 'default' => esc_html__('New', 'ultimate-store-kit'), | |
| 387 | + 'condition' => [ | |
| 388 | + 'badge' => 'yes', | |
| 389 | + ], | |
| 390 | + 'separator' => 'before', | |
| 391 | + ] | |
| 392 | + ); | |
| 393 | + | |
| 394 | + | |
| 374 | 395 | $this->end_controls_tab(); |
| 375 | 396 | $this->end_controls_tabs(); |
| 376 | 397 | $this->end_controls_section(); |
| 377 | 398 | |
| @@ -417,9 +438,9 @@ | ||
| 417 | 438 | 'max' => 1200, |
| 418 | 439 | ], |
| 419 | 440 | ], |
| 420 | 441 | 'selectors' => [ |
| 421 | - '{{WRAPPER}} .usk-featured-box .usk-content' => 'width: {{SIZE}}{{UNIT}};', | |
| 442 | + '{{WRAPPER}} .usk-featured-box .usk-content' => 'max-width: {{SIZE}}{{UNIT}};', | |
| 422 | 443 | ], |
| 423 | 444 | ] |
| 424 | 445 | ); |
| 425 | 446 | |
| @@ -521,8 +542,15 @@ | ||
| 521 | 542 | 'type' => Controls_Manager::SWITCHER, |
| 522 | 543 | 'default' => 'yes', |
| 523 | 544 | ] |
| 524 | 545 | ); |
| 546 | + $this->add_control( | |
| 547 | + 'badge', | |
| 548 | + [ | |
| 549 | + 'label' => esc_html__('Badge', 'ultimate-store-kit') . BDTUSK_NC, | |
| 550 | + 'type' => Controls_Manager::SWITCHER, | |
| 551 | + ] | |
| 552 | + ); | |
| 525 | 553 | |
| 526 | 554 | $this->add_control( |
| 527 | 555 | 'show_wrapper_link', |
| 528 | 556 | [ |
| @@ -846,8 +874,111 @@ | ||
| 846 | 874 | ], |
| 847 | 875 | ] |
| 848 | 876 | ); |
| 849 | 877 | |
| 878 | + $this->add_control( | |
| 879 | + 'button_offset_toggle', | |
| 880 | + [ | |
| 881 | + 'label' => __('Offset', 'ultimate-store-kit'), | |
| 882 | + 'type' => Controls_Manager::POPOVER_TOGGLE, | |
| 883 | + 'label_off' => __('None', 'ultimate-store-kit'), | |
| 884 | + 'label_on' => __('Custom', 'ultimate-store-kit'), | |
| 885 | + 'return_value' => 'yes', | |
| 886 | + ] | |
| 887 | + ); | |
| 888 | + $this->start_popover(); | |
| 889 | + $this->add_responsive_control( | |
| 890 | + 'button_x_position', | |
| 891 | + [ | |
| 892 | + 'label' => __( 'X', 'ultimate-store-kit' ), | |
| 893 | + 'type' => Controls_Manager::SLIDER, | |
| 894 | + 'default' => [ | |
| 895 | + 'size' => 0, | |
| 896 | + ], | |
| 897 | + 'tablet_default' => [ | |
| 898 | + 'size' => 0, | |
| 899 | + ], | |
| 900 | + 'mobile_default' => [ | |
| 901 | + 'size' => 0, | |
| 902 | + ], | |
| 903 | + 'range' => [ | |
| 904 | + 'px' => [ | |
| 905 | + 'min' => -800, | |
| 906 | + 'max' => 800, | |
| 907 | + ], | |
| 908 | + ], | |
| 909 | + 'condition' => [ | |
| 910 | + 'button_offset_toggle' => 'yes' | |
| 911 | + ], | |
| 912 | + 'render_type' => 'ui', | |
| 913 | + 'selectors' => [ | |
| 914 | + '{{WRAPPER}}' => '--usk-button-x-offset: {{SIZE}}px;' | |
| 915 | + ], | |
| 916 | + ] | |
| 917 | + ); | |
| 918 | + | |
| 919 | + $this->add_responsive_control( | |
| 920 | + 'button_y_position', | |
| 921 | + [ | |
| 922 | + 'label' => __( 'Y', 'ultimate-store-kit' ), | |
| 923 | + 'type' => Controls_Manager::SLIDER, | |
| 924 | + 'default' => [ | |
| 925 | + 'size' => 0, | |
| 926 | + ], | |
| 927 | + 'tablet_default' => [ | |
| 928 | + 'size' => 0, | |
| 929 | + ], | |
| 930 | + 'mobile_default' => [ | |
| 931 | + 'size' => 0, | |
| 932 | + ], | |
| 933 | + 'range' => [ | |
| 934 | + 'px' => [ | |
| 935 | + 'min' => -800, | |
| 936 | + 'max' => 800, | |
| 937 | + ], | |
| 938 | + ], | |
| 939 | + 'condition' => [ | |
| 940 | + 'button_offset_toggle' => 'yes' | |
| 941 | + ], | |
| 942 | + 'render_type' => 'ui', | |
| 943 | + 'selectors' => [ | |
| 944 | + '{{WRAPPER}}' => '--usk-button-y-offset: {{SIZE}}px;' | |
| 945 | + ], | |
| 946 | + ] | |
| 947 | + ); | |
| 948 | + | |
| 949 | + $this->add_responsive_control( | |
| 950 | + 'button_rotate', | |
| 951 | + [ | |
| 952 | + 'label' => __( 'Rotate', 'ultimate-store-kit' ), | |
| 953 | + 'type' => Controls_Manager::SLIDER, | |
| 954 | + 'default' => [ | |
| 955 | + 'size' => 0, | |
| 956 | + ], | |
| 957 | + 'tablet_default' => [ | |
| 958 | + 'size' => 0, | |
| 959 | + ], | |
| 960 | + 'mobile_default' => [ | |
| 961 | + 'size' => 0, | |
| 962 | + ], | |
| 963 | + 'range' => [ | |
| 964 | + 'px' => [ | |
| 965 | + 'min' => -180, | |
| 966 | + 'max' => 180, | |
| 967 | + 'step' => 5, | |
| 968 | + ], | |
| 969 | + ], | |
| 970 | + 'condition' => [ | |
| 971 | + 'button_offset_toggle' => 'yes' | |
| 972 | + ], | |
| 973 | + 'render_type' => 'ui', | |
| 974 | + 'selectors' => [ | |
| 975 | + '{{WRAPPER}}' => '--usk-button-rotate: {{SIZE}}deg;' | |
| 976 | + ], | |
| 977 | + ] | |
| 978 | + ); | |
| 979 | + $this->end_popover(); | |
| 980 | + | |
| 850 | 981 | $this->start_controls_tabs('tabs_readmore_style'); |
| 851 | 982 | |
| 852 | 983 | $this->start_controls_tab( |
| 853 | 984 | 'tab_readmore_normal', |
| @@ -998,11 +1129,267 @@ | ||
| 998 | 1129 | ] |
| 999 | 1130 | ); |
| 1000 | 1131 | |
| 1001 | 1132 | $this->end_controls_tab(); |
| 1133 | + $this->end_controls_tabs(); | |
| 1134 | + $this->end_controls_section(); | |
| 1002 | 1135 | |
| 1136 | + $this->start_controls_section( | |
| 1137 | + 'section_style_badge', | |
| 1138 | + [ | |
| 1139 | + 'label' => esc_html__('Badge', 'ultimate-store-kit'), | |
| 1140 | + 'tab' => Controls_Manager::TAB_STYLE, | |
| 1141 | + 'condition' => [ | |
| 1142 | + 'badge' => 'yes', | |
| 1143 | + 'badge_text!' => '', | |
| 1144 | + ], | |
| 1145 | + ] | |
| 1146 | + ); | |
| 1147 | + $this->add_responsive_control( | |
| 1148 | + 'badge_position', | |
| 1149 | + [ | |
| 1150 | + 'label' => esc_html__('Position', 'ultimate-store-kit'), | |
| 1151 | + 'type' => Controls_Manager::SELECT, | |
| 1152 | + 'default' => 'top-right', | |
| 1153 | + 'options' => [ | |
| 1154 | + 'top-left' => esc_html__('Top Left', 'ultimate-store-kit'), | |
| 1155 | + 'top-right' => esc_html__('Top Right', 'ultimate-store-kit'), | |
| 1156 | + 'bottom-left' => esc_html__('Bottom Left', 'ultimate-store-kit'), | |
| 1157 | + 'bottom-right' => esc_html__('Bottom Right', 'ultimate-store-kit'), | |
| 1158 | + ], | |
| 1159 | + 'selectors_dictionary' => [ | |
| 1160 | + 'top-left' => 'top: 0; left: 0;', | |
| 1161 | + 'top-right' => 'top: 0; right: 0;', | |
| 1162 | + 'bottom-left' => 'bottom: 0; left: 0;', | |
| 1163 | + 'bottom-right' => 'bottom: 0; right: 0;', | |
| 1164 | + ], | |
| 1165 | + 'selectors' => [ | |
| 1166 | + '{{WRAPPER}} .usk-featured-box .usk-badge' => '{{VALUE}};', | |
| 1167 | + ], | |
| 1168 | + ] | |
| 1169 | + ); | |
| 1170 | + $this->start_controls_tabs('tabs_badge_style'); | |
| 1171 | + $this->start_controls_tab( | |
| 1172 | + 'tab_badge_normal', | |
| 1173 | + [ | |
| 1174 | + 'label' => esc_html__('Normal', 'ultimate-store-kit'), | |
| 1175 | + ] | |
| 1176 | + ); | |
| 1177 | + $this->add_control( | |
| 1178 | + 'badge_color', | |
| 1179 | + [ | |
| 1180 | + 'label' => esc_html__('Color', 'ultimate-store-kit'), | |
| 1181 | + 'type' => Controls_Manager::COLOR, | |
| 1182 | + 'selectors' => [ | |
| 1183 | + '{{WRAPPER}} .usk-featured-box .usk-badge' => 'color: {{VALUE}};', | |
| 1184 | + ], | |
| 1185 | + ] | |
| 1186 | + ); | |
| 1187 | + $this->add_group_control( | |
| 1188 | + Group_Control_Background::get_type(), | |
| 1189 | + [ | |
| 1190 | + 'name' => 'badge_background', | |
| 1191 | + 'exclude' => ['image'], | |
| 1192 | + 'selector' => '{{WRAPPER}} .usk-featured-box .usk-badge', | |
| 1193 | + ] | |
| 1194 | + ); | |
| 1195 | + $this->add_group_control( | |
| 1196 | + Group_Control_Border::get_type(), | |
| 1197 | + [ | |
| 1198 | + 'name' => 'badge_border', | |
| 1199 | + 'selector' => '{{WRAPPER}} .usk-featured-box .usk-badge', | |
| 1200 | + 'separator' => 'before', | |
| 1201 | + ] | |
| 1202 | + ); | |
| 1203 | + $this->add_responsive_control( | |
| 1204 | + 'badge_border_radius', | |
| 1205 | + [ | |
| 1206 | + 'label' => esc_html__('Border Radius', 'ultimate-store-kit'), | |
| 1207 | + 'type' => Controls_Manager::DIMENSIONS, | |
| 1208 | + 'size_units' => ['px', '%'], | |
| 1209 | + 'selectors' => [ | |
| 1210 | + '{{WRAPPER}} .usk-featured-box .usk-badge' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 1211 | + ], | |
| 1212 | + ] | |
| 1213 | + ); | |
| 1214 | + $this->add_responsive_control( | |
| 1215 | + 'badge_padding', | |
| 1216 | + [ | |
| 1217 | + 'label' => esc_html__('Padding', 'ultimate-store-kit'), | |
| 1218 | + 'type' => Controls_Manager::DIMENSIONS, | |
| 1219 | + 'size_units' => ['px', 'em', '%'], | |
| 1220 | + 'selectors' => [ | |
| 1221 | + '{{WRAPPER}} .usk-featured-box .usk-badge' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 1222 | + ], | |
| 1223 | + ] | |
| 1224 | + ); | |
| 1225 | + $this->add_responsive_control( | |
| 1226 | + 'badge_margin', | |
| 1227 | + [ | |
| 1228 | + 'label' => esc_html__('Margin', 'ultimate-store-kit'), | |
| 1229 | + 'type' => Controls_Manager::DIMENSIONS, | |
| 1230 | + 'size_units' => ['px', 'em', '%'], | |
| 1231 | + 'selectors' => [ | |
| 1232 | + '{{WRAPPER}} .usk-featured-box .usk-badge' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 1233 | + ], | |
| 1234 | + ] | |
| 1235 | + ); | |
| 1236 | + $this->add_group_control( | |
| 1237 | + Group_Control_Typography::get_type(), | |
| 1238 | + [ | |
| 1239 | + 'name' => 'badge_typography', | |
| 1240 | + 'selector' => '{{WRAPPER}} .usk-featured-box .usk-badge', | |
| 1241 | + ] | |
| 1242 | + ); | |
| 1243 | + $this->add_group_control( | |
| 1244 | + Group_Control_Box_Shadow::get_type(), | |
| 1245 | + [ | |
| 1246 | + 'name' => 'badge_box_shadow', | |
| 1247 | + 'selector' => '{{WRAPPER}} .usk-featured-box .usk-badge', | |
| 1248 | + ] | |
| 1249 | + ); | |
| 1250 | + $this->add_control( | |
| 1251 | + 'badge_offset_toggle', | |
| 1252 | + [ | |
| 1253 | + 'label' => __('Offset', 'ultimate-store-kit'), | |
| 1254 | + 'type' => Controls_Manager::POPOVER_TOGGLE, | |
| 1255 | + 'label_off' => __('None', 'ultimate-store-kit'), | |
| 1256 | + 'label_on' => __('Custom', 'ultimate-store-kit'), | |
| 1257 | + 'return_value' => 'yes', | |
| 1258 | + ] | |
| 1259 | + ); | |
| 1260 | + $this->start_popover(); | |
| 1261 | + $this->add_responsive_control( | |
| 1262 | + 'badge_x_position', | |
| 1263 | + [ | |
| 1264 | + 'label' => __( 'X', 'ultimate-store-kit' ), | |
| 1265 | + 'type' => Controls_Manager::SLIDER, | |
| 1266 | + 'default' => [ | |
| 1267 | + 'size' => 0, | |
| 1268 | + ], | |
| 1269 | + 'tablet_default' => [ | |
| 1270 | + 'size' => 0, | |
| 1271 | + ], | |
| 1272 | + 'mobile_default' => [ | |
| 1273 | + 'size' => 0, | |
| 1274 | + ], | |
| 1275 | + 'range' => [ | |
| 1276 | + 'px' => [ | |
| 1277 | + 'min' => -800, | |
| 1278 | + 'max' => 800, | |
| 1279 | + ], | |
| 1280 | + ], | |
| 1281 | + 'condition' => [ | |
| 1282 | + 'badge_offset_toggle' => 'yes' | |
| 1283 | + ], | |
| 1284 | + 'render_type' => 'ui', | |
| 1285 | + 'selectors' => [ | |
| 1286 | + '{{WRAPPER}}' => '--usk-badge-x-offset: {{SIZE}}px;' | |
| 1287 | + ], | |
| 1288 | + ] | |
| 1289 | + ); | |
| 1290 | + | |
| 1291 | + $this->add_responsive_control( | |
| 1292 | + 'badge_y_position', | |
| 1293 | + [ | |
| 1294 | + 'label' => __( 'Y', 'ultimate-store-kit' ), | |
| 1295 | + 'type' => Controls_Manager::SLIDER, | |
| 1296 | + 'default' => [ | |
| 1297 | + 'size' => 0, | |
| 1298 | + ], | |
| 1299 | + 'tablet_default' => [ | |
| 1300 | + 'size' => 0, | |
| 1301 | + ], | |
| 1302 | + 'mobile_default' => [ | |
| 1303 | + 'size' => 0, | |
| 1304 | + ], | |
| 1305 | + 'range' => [ | |
| 1306 | + 'px' => [ | |
| 1307 | + 'min' => -800, | |
| 1308 | + 'max' => 800, | |
| 1309 | + ], | |
| 1310 | + ], | |
| 1311 | + 'condition' => [ | |
| 1312 | + 'badge_offset_toggle' => 'yes' | |
| 1313 | + ], | |
| 1314 | + 'render_type' => 'ui', | |
| 1315 | + 'selectors' => [ | |
| 1316 | + '{{WRAPPER}}' => '--usk-badge-y-offset: {{SIZE}}px;' | |
| 1317 | + ], | |
| 1318 | + ] | |
| 1319 | + ); | |
| 1320 | + | |
| 1321 | + $this->add_responsive_control( | |
| 1322 | + 'badge_rotate', | |
| 1323 | + [ | |
| 1324 | + 'label' => __( 'Rotate', 'ultimate-store-kit' ), | |
| 1325 | + 'type' => Controls_Manager::SLIDER, | |
| 1326 | + 'default' => [ | |
| 1327 | + 'size' => 0, | |
| 1328 | + ], | |
| 1329 | + 'tablet_default' => [ | |
| 1330 | + 'size' => 0, | |
| 1331 | + ], | |
| 1332 | + 'mobile_default' => [ | |
| 1333 | + 'size' => 0, | |
| 1334 | + ], | |
| 1335 | + 'range' => [ | |
| 1336 | + 'px' => [ | |
| 1337 | + 'min' => -180, | |
| 1338 | + 'max' => 180, | |
| 1339 | + 'step' => 5, | |
| 1340 | + ], | |
| 1341 | + ], | |
| 1342 | + 'condition' => [ | |
| 1343 | + 'badge_offset_toggle' => 'yes' | |
| 1344 | + ], | |
| 1345 | + 'render_type' => 'ui', | |
| 1346 | + 'selectors' => [ | |
| 1347 | + '{{WRAPPER}}' => '--usk-badge-rotate: {{SIZE}}deg;' | |
| 1348 | + ], | |
| 1349 | + ] | |
| 1350 | + ); | |
| 1351 | + $this->end_popover(); | |
| 1352 | + $this->end_controls_tab(); | |
| 1353 | + $this->start_controls_tab( | |
| 1354 | + 'tab_badge_hover', | |
| 1355 | + [ | |
| 1356 | + 'label' => esc_html__('Hover', 'ultimate-store-kit'), | |
| 1357 | + ] | |
| 1358 | + ); | |
| 1359 | + $this->add_control( | |
| 1360 | + 'badge_hover_color', | |
| 1361 | + [ | |
| 1362 | + 'label' => esc_html__('Color', 'ultimate-store-kit'), | |
| 1363 | + 'type' => Controls_Manager::COLOR, | |
| 1364 | + 'selectors' => [ | |
| 1365 | + '{{WRAPPER}} .usk-featured-box .usk-badge:hover' => 'color: {{VALUE}};', | |
| 1366 | + ], | |
| 1367 | + ] | |
| 1368 | + ); | |
| 1369 | + $this->add_group_control( | |
| 1370 | + Group_Control_Background::get_type(), | |
| 1371 | + [ | |
| 1372 | + 'name' => 'badge_hover_background', | |
| 1373 | + 'exclude' => ['image'], | |
| 1374 | + 'selector' => '{{WRAPPER}} .usk-featured-box .usk-badge:hover', | |
| 1375 | + ] | |
| 1376 | + ); | |
| 1377 | + $this->add_control( | |
| 1378 | + 'badge_hover_border_color', | |
| 1379 | + [ | |
| 1380 | + 'label' => esc_html__('Border Color', 'ultimate-store-kit'), | |
| 1381 | + 'type' => Controls_Manager::COLOR, | |
| 1382 | + 'condition' => [ | |
| 1383 | + 'badge_border_border!' => '', | |
| 1384 | + ], | |
| 1385 | + 'selectors' => [ | |
| 1386 | + '{{WRAPPER}} .usk-featured-box .usk-badge:hover' => 'border-color: {{VALUE}};', | |
| 1387 | + ], | |
| 1388 | + ] | |
| 1389 | + ); | |
| 1390 | + $this->end_controls_tab(); | |
| 1003 | 1391 | $this->end_controls_tabs(); |
| 1004 | - | |
| 1005 | 1392 | $this->end_controls_section(); |
| 1006 | 1393 | } |
| 1007 | 1394 | |
| 1008 | 1395 | public function render_title() { |
| @@ -1011,22 +1398,19 @@ | ||
| 1011 | 1398 | if (!$settings['show_title']) { |
| 1012 | 1399 | return; |
| 1013 | 1400 | } |
| 1014 | 1401 | |
| 1015 | - $this->add_render_attribute( | |
| 1016 | - [ | |
| 1017 | - 'title-link' => [ | |
| 1018 | - 'href' => isset($settings['title_link']['url']) && !empty($settings['title_link']['url']) ? esc_url($settings['title_link']['url']) : 'javascript:void(0);', | |
| 1019 | - 'target' => $settings['title_link']['is_external'] ? '_blank' : '_self', | |
| 1020 | - ], | |
| 1021 | - ], | |
| 1022 | - '', | |
| 1023 | - '', | |
| 1024 | - true | |
| 1025 | - ); | |
| 1402 | + if ( ! empty($settings['title_link']['url']) && ! empty($settings['title']) ) { | |
| 1403 | + $this->add_link_attributes('title-link', $settings['title_link'], true); | |
| 1404 | + } | |
| 1026 | 1405 | |
| 1027 | 1406 | if (!empty($settings['title'])) { |
| 1028 | - printf('<%1$s class="usk-title"><a %2$s title="%3$s">%3$s</a></%1$s>', esc_attr($settings['title_tag']), wp_kses_post($this->get_render_attribute_string('title-link')), wp_kses_post($settings['title'])); | |
| 1407 | + printf( | |
| 1408 | + '<%1$s class="usk-title"><a %2$s title="%3$s">%3$s</a></%1$s>', | |
| 1409 | + esc_attr( Utils::get_valid_html_tag($settings['title_tag']) ), | |
| 1410 | + $this->get_render_attribute_string('title-link'), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1411 | + esc_attr($settings['title']) | |
| 1412 | + ); | |
| 1029 | 1413 | } |
| 1030 | 1414 | } |
| 1031 | 1415 | |
| 1032 | 1416 | public function render_text() { |
| @@ -1079,19 +1463,11 @@ | ||
| 1079 | 1463 | if (!$settings['show_readmore']) { |
| 1080 | 1464 | return; |
| 1081 | 1465 | } |
| 1082 | 1466 | |
| 1083 | - $this->add_render_attribute( | |
| 1084 | - [ | |
| 1085 | - 'readmore-link' => [ | |
| 1086 | - 'href' => isset($settings['readmore_link']['url']) ? esc_url($settings['readmore_link']['url']) : '#', | |
| 1087 | - 'target' => $settings['readmore_link']['is_external'] ? '_blank' : '_self', | |
| 1088 | - ], | |
| 1089 | - ], | |
| 1090 | - '', | |
| 1091 | - '', | |
| 1092 | - true | |
| 1093 | - ); | |
| 1467 | + if (!empty($settings['readmore_link']['url'])) { | |
| 1468 | + $this->add_link_attributes('readmore-link', $settings['readmore_link'], true); | |
| 1469 | + } | |
| 1094 | 1470 | |
| 1095 | 1471 | ?> |
| 1096 | 1472 | <?php if ((!empty($settings['readmore_link']['url'])) && ($settings['show_readmore'])): ?> |
| 1097 | 1473 | <div class="usk-link-btn"> |
| @@ -1105,21 +1481,14 @@ | ||
| 1105 | 1481 | |
| 1106 | 1482 | protected function render() { |
| 1107 | 1483 | $settings = $this->get_settings_for_display(); |
| 1108 | 1484 | |
| 1109 | - $this->add_render_attribute('featured-box', 'class', 'usk-featured-box usk-fb-content-position-' . $settings['position']); | |
| 1485 | + $this->add_render_attribute('featured-box', 'class', 'usk-featured-box usk-fb-content-position-' . $settings['content_position']); | |
| 1110 | 1486 | |
| 1111 | - $this->add_render_attribute( | |
| 1112 | - [ | |
| 1113 | - 'link' => [ | |
| 1114 | - 'href' => isset($settings['wrapper_link']['url']) && !empty($settings['wrapper_link']['url']) ? esc_url($settings['wrapper_link']['url']) : 'javascript:void(0);', | |
| 1115 | - 'target' => $settings['show_wrapper_link'] == 'yes' and $settings['wrapper_link']['is_external'] ? '_blank' : '_self', | |
| 1116 | - ], | |
| 1117 | - ], | |
| 1118 | - '', | |
| 1119 | - '', | |
| 1120 | - true | |
| 1121 | - ); | |
| 1487 | + if (!empty($settings['wrapper_link']['url'])) { | |
| 1488 | + $this->add_link_attributes('link', $settings['wrapper_link'], true); | |
| 1489 | + } | |
| 1490 | + $this->add_render_attribute('link', 'class', 'usk-featured-box-wrapper-link', true); | |
| 1122 | 1491 | |
| 1123 | 1492 | ?> |
| 1124 | 1493 | <div <?php $this->print_render_attribute_string('featured-box');?>> |
| 1125 | 1494 | |
| @@ -1132,11 +1501,14 @@ | ||
| 1132 | 1501 | <?php $this->render_readmore();?> |
| 1133 | 1502 | </div> |
| 1134 | 1503 | </div> |
| 1135 | 1504 | <?php |
| 1136 | - if ($settings['show_wrapper_link'] == 'yes' and !empty($settings['wrapper_link']['url'])) { | |
| 1137 | - printf('<a %1$s class="usk-featured-box-wrapper-link"></a>', wp_kses_post($this->get_render_attribute_string('link'))); | |
| 1138 | - }?> | |
| 1505 | + if ($settings['badge'] == 'yes' and !empty($settings['badge_text'])) { | |
| 1506 | + printf('<div class="usk-badge">%1$s</div>', esc_html($settings['badge_text'])); | |
| 1507 | + } | |
| 1508 | + if ($settings['show_wrapper_link'] == 'yes' and !empty($settings['wrapper_link']['url'])) { ?> | |
| 1509 | + <a <?php $this->print_render_attribute_string('link'); ?>></a> | |
| 1510 | + <?php } ?> | |
| 1139 | 1511 | |
| 1140 | 1512 | </div> |
| 1141 | 1513 | <?php |
| 1142 | 1514 | } |