126 lines
3.3 KiB
PHP
126 lines
3.3 KiB
PHP
<?php
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
use Elementor\Controls_Manager;
|
|
use Elementor\Icons_Manager;
|
|
use Elementor\Repeater;
|
|
use Elementor\Utils;
|
|
|
|
class Elementor_Product_Featured_Image extends \Elementor\Widget_Base {
|
|
|
|
public function get_name() {
|
|
return 'product-featured-image';
|
|
}
|
|
|
|
public function get_title() {
|
|
return esc_html__('Product Featured Image', 'elementor-addon');
|
|
}
|
|
|
|
public function get_icon() {
|
|
return 'eicon-code';
|
|
}
|
|
|
|
public function get_categories() {
|
|
return ['basic'];
|
|
}
|
|
|
|
public function get_keywords() {
|
|
return ['Product', 'Featured Image', 'Image'];
|
|
}
|
|
|
|
protected function register_controls() {
|
|
$this->start_controls_section(
|
|
'settings_section',
|
|
[
|
|
'label' => esc_html__('Settings', 'elementor-addon'),
|
|
]
|
|
);
|
|
|
|
$this->end_controls_section();
|
|
|
|
|
|
$this->start_controls_section(
|
|
'style_section',
|
|
[
|
|
'label' => esc_html__('Style', 'elementor-addon'),
|
|
'tab' => Controls_Manager::TAB_STYLE,
|
|
]
|
|
);
|
|
|
|
$this->add_responsive_control(
|
|
'width',
|
|
[
|
|
'label' => esc_html__('Width', 'elementor-addon'),
|
|
'type' => Controls_Manager::SLIDER,
|
|
'default' => [
|
|
'unit' => '%',
|
|
],
|
|
'size_units' => ['%', 'px', 'em'],
|
|
'range' => [
|
|
'%' => [
|
|
'min' => 0,
|
|
'max' => 100,
|
|
],
|
|
'px' => [
|
|
'min' => 0,
|
|
'max' => 1000,
|
|
],
|
|
],
|
|
'selectors' => [
|
|
'{{WRAPPER}} .elementor-product-featured-image' => 'width: {{SIZE}}{{UNIT}};',
|
|
],
|
|
]
|
|
);
|
|
|
|
$this->add_responsive_control(
|
|
'max_width',
|
|
[
|
|
'label' => esc_html__('Max Width', 'elementor-addon'),
|
|
'type' => Controls_Manager::SLIDER,
|
|
'default' => [
|
|
'unit' => '%',
|
|
],
|
|
'size_units' => ['%', 'px', 'em'],
|
|
'range' => [
|
|
'%' => [
|
|
'min' => 0,
|
|
'max' => 100,
|
|
],
|
|
'px' => [
|
|
'min' => 0,
|
|
'max' => 1000,
|
|
],
|
|
],
|
|
'selectors' => [
|
|
'{{WRAPPER}} .elementor-product-featured-image' => 'max-width: {{SIZE}}{{UNIT}};',
|
|
],
|
|
]
|
|
);
|
|
|
|
$this->end_controls_section();
|
|
}
|
|
|
|
protected function render() {
|
|
global $post;
|
|
$settings = $this->get_settings_for_display();
|
|
|
|
$featured_image_status = get_field('ukryc_obrazek_wyrozniajacy', $post->ID);
|
|
|
|
if ( ! $post ) {
|
|
return;
|
|
}
|
|
|
|
if ( $featured_image_status == 1 ) {
|
|
return;
|
|
}
|
|
|
|
if ( has_post_thumbnail( $post->ID ) ) {
|
|
echo get_the_post_thumbnail( $post->ID, 'large', [
|
|
'class' => 'elementor-product-featured-image',
|
|
'loading' => 'lazy',
|
|
]);
|
|
}
|
|
}
|
|
} |