| 1 |
<?php |
| 2 |
|
| 3 |
use Elementor\Core\Base\Document; |
| 4 |
use Elementor\Plugin; |
| 5 |
|
| 6 |
defined( 'ABSPATH' ) || die(); |
| 7 |
|
| 8 |
class Sellkit_Elementor_Product_Description_Widget extends Sellkit_Elementor_Upsell_Base_Widget { |
| 9 |
|
| 10 |
public static function is_active() { |
| 11 |
return class_exists( 'woocommerce' ); |
| 12 |
} |
| 13 |
|
| 14 |
public function get_name() { |
| 15 |
return 'sellkit-product-description'; |
| 16 |
} |
| 17 |
|
| 18 |
public function get_title() { |
| 19 |
return __( 'Product Description', 'sellkit' ); |
| 20 |
} |
| 21 |
|
| 22 |
public function get_icon() { |
| 23 |
return 'sellkit-element-icon sellkit-product-description-icon'; |
| 24 |
} |
| 25 |
|
| 26 |
protected function register_controls() { |
| 27 |
$this->register_content_section_controls(); |
| 28 |
$this->register_style_section_controls(); |
| 29 |
} |
| 30 |
|
| 31 |
private function register_content_section_controls() { |
| 32 |
$this->start_controls_section( |
| 33 |
'content_tab', |
| 34 |
[ |
| 35 |
'label' => __( 'Content', 'sellkit' ), |
| 36 |
'tab' => 'content', |
| 37 |
] |
| 38 |
); |
| 39 |
|
| 40 |
$this->add_control( |
| 41 |
'content_type', |
| 42 |
[ |
| 43 |
'label' => __( 'Content Type', 'sellkit' ), |
| 44 |
'type' => 'select', |
| 45 |
'default' => 'full_desc', |
| 46 |
'options' => [ |
| 47 |
'full_desc' => __( 'Full Description', 'sellkit' ), |
| 48 |
'short_desc' => __( 'Short Description', 'sellkit' ), |
| 49 |
], |
| 50 |
] |
| 51 |
); |
| 52 |
|
| 53 |
$this->end_controls_section(); |
| 54 |
} |
| 55 |
|
| 56 |
private function register_style_section_controls() { |
| 57 |
$this->start_controls_section( |
| 58 |
'style_tab', |
| 59 |
[ |
| 60 |
'label' => __( 'Style', 'sellkit' ), |
| 61 |
'tab' => 'style', |
| 62 |
] |
| 63 |
); |
| 64 |
|
| 65 |
$this->add_responsive_control( |
| 66 |
'align', |
| 67 |
[ |
| 68 |
'label' => __( 'Alignment', 'sellkit' ), |
| 69 |
'type' => 'choose', |
| 70 |
'options' => [ |
| 71 |
'left' => [ |
| 72 |
'title' => __( 'Left', 'sellkit' ), |
| 73 |
'icon' => 'fa fa-align-left', |
| 74 |
], |
| 75 |
'center' => [ |
| 76 |
'title' => __( 'Center', 'sellkit' ), |
| 77 |
'icon' => 'fa fa-align-center', |
| 78 |
], |
| 79 |
'right' => [ |
| 80 |
'title' => __( 'Right', 'sellkit' ), |
| 81 |
'icon' => 'fa fa-align-right', |
| 82 |
], |
| 83 |
'justify' => [ |
| 84 |
'title' => __( 'Justified', 'sellkit' ), |
| 85 |
'icon' => 'fa fa-align-justify', |
| 86 |
], |
| 87 |
], |
| 88 |
'default' => 'left', |
| 89 |
'selectors' => [ |
| 90 |
'{{WRAPPER}} .sellkit-product-description-widget' => 'text-align: {{VALUE}}', |
| 91 |
], |
| 92 |
] |
| 93 |
); |
| 94 |
|
| 95 |
$this->add_group_control( |
| 96 |
'typography', |
| 97 |
[ |
| 98 |
'name' => 'input_typography', |
| 99 |
'scheme' => '3', |
| 100 |
'selector' => '{{WRAPPER}} .sellkit-product-description-widget', |
| 101 |
] |
| 102 |
); |
| 103 |
|
| 104 |
$this->add_control( |
| 105 |
'input_color', |
| 106 |
[ |
| 107 |
'label' => __( 'Text Color', 'sellkit' ), |
| 108 |
'type' => 'color', |
| 109 |
'selectors' => [ |
| 110 |
'{{WRAPPER}} .sellkit-product-description-widget' => 'color: {{SIZE}};', |
| 111 |
], |
| 112 |
] |
| 113 |
); |
| 114 |
|
| 115 |
$this->add_group_control( |
| 116 |
'text-shadow', |
| 117 |
[ |
| 118 |
'name' => 'play_icon_shadow', |
| 119 |
'fields_options' => [ |
| 120 |
'text_shadow_type' => [ |
| 121 |
'label' => __( 'Text Shadow', 'sellkit' ), |
| 122 |
], |
| 123 |
], |
| 124 |
'selector' => '{{WRAPPER}} .sellkit-product-description-widget', |
| 125 |
] |
| 126 |
); |
| 127 |
|
| 128 |
$this->end_controls_section(); |
| 129 |
} |
| 130 |
|
| 131 |
protected function render() { |
| 132 |
$product = $this->get_product_object(); |
| 133 |
$settings = $this->get_settings_for_display(); |
| 134 |
|
| 135 |
if ( empty( $product ) ) { |
| 136 |
return; |
| 137 |
} |
| 138 |
?> |
| 139 |
<p class="sellkit-product-description-widget"> |
| 140 |
<?php |
| 141 |
echo 'short_desc' === $settings['content_type'] ? $product->get_short_description() : $product->get_description(); |
| 142 |
?> |
| 143 |
</p> |
| 144 |
<?php |
| 145 |
} |
| 146 |
} |
| 147 |
|