product-share.php
68 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Elementor; |
| 4 | |
| 5 | defined('ABSPATH') || exit; |
| 6 | |
| 7 | use ShopEngine\Core\Template_Cpt; |
| 8 | use ShopEngine\Widgets\Products; |
| 9 | |
| 10 | |
| 11 | class ShopEngine_Product_Share extends \ShopEngine\Base\Widget |
| 12 | { |
| 13 | |
| 14 | public function config() { |
| 15 | return new ShopEngine_Product_Share_Config(); |
| 16 | } |
| 17 | |
| 18 | |
| 19 | protected function register_controls() { |
| 20 | /* |
| 21 | * Style Tab - Product Share |
| 22 | */ |
| 23 | $this->start_controls_section( |
| 24 | 'shopengine_section_share_styles', |
| 25 | [ |
| 26 | 'label' => esc_html__('Styles', 'shopengine'), |
| 27 | 'tab' => Controls_Manager::TAB_STYLE, |
| 28 | ] |
| 29 | ); |
| 30 | |
| 31 | $this->add_control( |
| 32 | 'shopengine_product_share_note', |
| 33 | [ |
| 34 | 'type' => Controls_Manager::RAW_HTML, |
| 35 | 'raw' => sprintf( |
| 36 | '%1$s <a title="' . esc_html__("Wp Social Page","shopengine") . '" href="https://wordpress.org/plugins/wp-social/" target="_blank" rel="noopener">Wp Social</a> %2$s', |
| 37 | esc_html__('You need to install', 'shopengine'), |
| 38 | esc_html__('plugin or sharing plugins like this one can hook into here or you can add your own code directly. Hook: woocommerce_share', 'shopengine') |
| 39 | ), |
| 40 | 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info', |
| 41 | ] |
| 42 | ); |
| 43 | |
| 44 | $this->end_controls_section(); |
| 45 | } |
| 46 | |
| 47 | |
| 48 | protected function screen() { |
| 49 | |
| 50 | $settings = $this->get_settings_for_display(); |
| 51 | |
| 52 | $post_type = get_post_type(); |
| 53 | |
| 54 | if($post_type == 'product' || $post_type == Template_Cpt::TYPE) { |
| 55 | |
| 56 | $product = Products::instance()->get_product($post_type); |
| 57 | |
| 58 | $tpl = Products::instance()->get_widget_template($this->get_name()); |
| 59 | |
| 60 | include $tpl; |
| 61 | |
| 62 | } else { |
| 63 | |
| 64 | esc_html_e('You are trying to view the page outside the builder or the Product page.', 'shopengine'); |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 |