api.php
5 years ago
common.php
4 years ago
cpt.php
5 years ago
list-model.php
4 years ago
widget-config.php
4 years ago
widget.php
4 years ago
widget.php
74 lines
| 1 | <?php |
| 2 | namespace ShopEngine\Base; |
| 3 | |
| 4 | defined('ABSPATH') || exit; |
| 5 | |
| 6 | use ShopEngine\Widgets\Products; |
| 7 | use ShopEngine\Utils\Controls_Helper; |
| 8 | use ShopEngine\Core\Elementor_Controls\Controls_Manager as ShopEngine_Controls_Manager; |
| 9 | |
| 10 | |
| 11 | abstract class Widget extends \Elementor\Widget_Base{ |
| 12 | abstract public function config(); |
| 13 | |
| 14 | abstract protected function screen(); |
| 15 | |
| 16 | public function get_help_url() { |
| 17 | return 'https://help.wpmet.com/docs-cat/shopengine/?ref__widget=' . $this->config()->get_name(); |
| 18 | } |
| 19 | |
| 20 | public function show_in_panel(){ |
| 21 | $territory = $this->config()->get_template_territory(); |
| 22 | |
| 23 | if(empty($territory)){ |
| 24 | return true; |
| 25 | } |
| 26 | |
| 27 | $current_template = Products::instance()->get_template_type_by_id(get_the_ID()); |
| 28 | |
| 29 | return in_array($current_template, $territory); |
| 30 | } |
| 31 | |
| 32 | public function shopengine_widget_before_render() { |
| 33 | //todo - remove shopengine later |
| 34 | |
| 35 | echo '<div class="shopengine shopengine-widget">'; |
| 36 | } |
| 37 | |
| 38 | public function shopengine_widget_after_render() { |
| 39 | echo '</div>'; |
| 40 | } |
| 41 | |
| 42 | public function render() { |
| 43 | if(\ShopEngine\Widgets\Products::instance()->get_a_simple_product_id() === false){ |
| 44 | echo \ShopEngine\Widgets\Products::instance()->no_product_to_preview(); |
| 45 | return; |
| 46 | } |
| 47 | |
| 48 | $this->shopengine_widget_before_render(); |
| 49 | $this->screen(); |
| 50 | $this->shopengine_widget_after_render(); |
| 51 | } |
| 52 | |
| 53 | public function get_name() { |
| 54 | return 'shopengine-' . $this->config()->get_name(); |
| 55 | } |
| 56 | |
| 57 | public function get_title() { |
| 58 | return $this->config()->get_title(); |
| 59 | } |
| 60 | |
| 61 | public function get_icon() { |
| 62 | return $this->config()->get_icon(); |
| 63 | } |
| 64 | |
| 65 | public function get_categories() { |
| 66 | return $this->config()->get_categories(); |
| 67 | } |
| 68 | |
| 69 | public function get_keywords() { |
| 70 | return $this->config()->get_keywords(); |
| 71 | } |
| 72 | |
| 73 | } |
| 74 |