init_allowed_functions(); } public function get_name() { return 'wc-single-elements'; } public function get_title() { return esc_html__( 'Woo - Single Elements', 'elementor-pro' ); } public function get_icon() { return 'eicon-woocommerce'; } /* Deprecated Widget */ public function show_in_panel() { return false; } /** * @return void */ private function init_allowed_functions(): void { $this->allowed_functions = [ '' => '— ' . esc_html__( 'Select', 'elementor-pro' ) . ' —', 'woocommerce_output_product_data_tabs' => esc_html__( 'Data Tabs', 'elementor-pro' ), 'woocommerce_template_single_title' => esc_html__( 'Title', 'elementor-pro' ), 'woocommerce_template_single_rating' => esc_html__( 'Rating', 'elementor-pro' ), 'woocommerce_template_single_price' => esc_html__( 'Price', 'elementor-pro' ), 'woocommerce_template_single_excerpt' => esc_html__( 'Excerpt', 'elementor-pro' ), 'woocommerce_template_single_meta' => esc_html__( 'Meta', 'elementor-pro' ), 'woocommerce_template_single_sharing' => esc_html__( 'Sharing', 'elementor-pro' ), 'woocommerce_show_product_sale_flash' => esc_html__( 'Sale Flash', 'elementor-pro' ), 'woocommerce_product_additional_information_tab' => esc_html__( 'Additional Information Tab', 'elementor-pro' ), 'woocommerce_upsell_display' => esc_html__( 'Upsell', 'elementor-pro' ), 'wc_get_stock_html' => esc_html__( 'Stock Status', 'elementor-pro' ), ]; } protected function register_controls() { $this->start_controls_section( 'section_product', [ 'label' => esc_html__( 'Element', 'elementor-pro' ), ] ); $this->add_control( 'element', [ 'label' => esc_html__( 'Element', 'elementor-pro' ), 'type' => Controls_Manager::SELECT, 'options' => $this->allowed_functions, ] ); $this->end_controls_section(); } public function remove_description_tab( $tabs ) { unset( $tabs['description'] ); return $tabs; } private function get_element() { global $product; $product = $this->get_product(); $settings = $this->get_settings(); $html = ''; switch ( $settings['element'] ) { case '': break; case 'wc_get_stock_html': $html = wc_get_stock_html( $product ); break; case 'woocommerce_output_product_data_tabs': add_filter( 'woocommerce_product_tabs', [ $this, 'remove_description_tab' ], 11 /* after default tabs*/ ); ob_start(); woocommerce_output_product_data_tabs(); // Wrap with the internal woocommerce `product` class $html = '