This commit is contained in:
Roman Pyrih
2025-09-10 12:12:21 +02:00
parent 948446c06e
commit 13a0060106
3 changed files with 132 additions and 0 deletions

View File

@@ -16,10 +16,12 @@ function register_hello_world_widget( $widgets_manager ) {
require_once( __DIR__ . '/widgets/images-list.php' );
require_once( __DIR__ . '/widgets/acf-product-parameters.php' );
require_once( __DIR__ . '/widgets/places-map.php' );
require_once( __DIR__ . '/widgets/product-featured-image.php' );
$widgets_manager->register( new \Elementor_Images_List() );
$widgets_manager->register( new \Elementor_ACF_Product_Parameters() );
$widgets_manager->register( new \Elementor_Places_Map() );
$widgets_manager->register( new \Elementor_Product_Featured_Image() );
}
add_action( 'elementor/widgets/register', 'register_hello_world_widget' );

View File

@@ -44,10 +44,14 @@ class Elementor_ACF_Product_Parameters extends \Elementor\Widget_Base {
protected function render() {
$settings = $this->get_settings_for_display();
$acf_product_parameters = get_field('parametry_produktu');
$acf_product_parameters_status = get_field('ukryc_parametry_produktu');
if (empty($acf_product_parameters)) {
return;
}
if ($acf_product_parameters_status == 1) {
return;
}
?>
<ul class="product-parameters">
<?php foreach ($acf_product_parameters as $parameter) : ?>

View File

@@ -0,0 +1,126 @@
<?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',
]);
}
}
}