documents->is_document_type( 'archive' ); } protected function _register_controls() { $css_scheme = apply_filters( 'jet-woo-builder/jet-archive-sale-badge/css-scheme', array( 'wrapper' => '.jet-woo-builder-archive-product-sale-badge', 'badge' => '.jet-woo-product-badge__sale' ) ); $this->start_controls_section( 'section_badge_content', array( 'label' => esc_html__( 'Content', 'jet-woo-builder' ), 'tab' => Controls_Manager::TAB_CONTENT, 'show_label' => false, ) ); $this->add_control( 'archive_badge_text', array( 'type' => 'text', 'label' => esc_html__( 'Sale Badge Text', 'jet-woo-builder' ), 'default' => 'Sale!', 'description' => esc_html__( 'Use %percentage_sale% and %numeric_sale% macros to display a withdrawal of discounts as a percentage or numeric of the initial price.', 'jet-woo-builder' ), ) ); $this->end_controls_section(); $this->start_controls_section( 'section_archive_badge_style', array( 'label' => esc_html__( 'General', 'jet-woo-builder' ), 'tab' => Controls_Manager::TAB_STYLE, 'show_label' => false, ) ); $this->add_control( 'archive_badge_color', array( 'label' => esc_html__( 'Color', 'jet-woo-builder' ), 'type' => Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} ' . $css_scheme['badge'] => 'color: {{VALUE}}', ), ) ); $this->add_control( 'archive_badge_background', array( 'label' => esc_html__( 'Background', 'jet-woo-builder' ), 'type' => Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} ' . $css_scheme['badge'] => 'background-color: {{VALUE}}', ), ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => 'archive_badge_typography', 'selector' => '{{WRAPPER}} ' . $css_scheme['badge'], ) ); $this->add_group_control( Group_Control_Border::get_type(), array( 'name' => 'archive_badge_border', 'label' => esc_html__( 'Border', 'jet-woo-builder' ), 'placeholder' => '1px', 'default' => '1px', 'selector' => '{{WRAPPER}} ' . $css_scheme['badge'], ) ); $this->add_responsive_control( 'archive_badge_border_radius', array( 'label' => __( 'Border Radius', 'jet-woo-builder' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', '%' ), 'selectors' => array( '{{WRAPPER}} ' . $css_scheme['badge'] => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ) ); $this->add_group_control( Group_Control_Box_Shadow::get_type(), array( 'name' => 'archive_badge_box_shadow', 'selector' => '{{WRAPPER}} ' . $css_scheme['badge'], ) ); $this->add_responsive_control( 'archive_badge_content_padding', array( 'label' => __( 'Padding', 'jet-woo-builder' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', '%' ), 'selectors' => array( '{{WRAPPER}} ' . $css_scheme['badge'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ) ); $this->add_responsive_control( 'archive_badge_content_margin', array( 'label' => esc_html__( 'Margin', 'jet-woo-builder' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', '%' ), 'selectors' => array( '{{WRAPPER}} ' . $css_scheme['wrapper'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ) ); $this->add_responsive_control( 'archive_badge_alignment', array( 'label' => esc_html__( 'Alignment', 'jet-woo-builder' ), 'type' => Controls_Manager::CHOOSE, 'options' => array( 'left' => array( 'title' => esc_html__( 'Left', 'jet-woo-builder' ), 'icon' => 'eicon-text-align-left', ), 'center' => array( 'title' => esc_html__( 'Center', 'jet-woo-builder' ), 'icon' => 'eicon-text-align-center', ), 'right' => array( 'title' => esc_html__( 'Right', 'jet-woo-builder' ), 'icon' => 'eicon-text-align-right', ), ), 'selectors' => array( '{{WRAPPER}} ' . $css_scheme['wrapper'] => 'text-align: {{VALUE}};', ), 'classes' => 'elementor-control-align', ) ); $this->end_controls_section(); } /** * Returns CSS selector for nested element * * @param [type] $el [description] * * @return [type] [description] */ public function css_selector( $el = null ) { return sprintf( '{{WRAPPER}} .%1$s %2$s', $this->get_name(), $el ); } public static function render_callback( $settings = array() ) { $badge_text = jet_woo_builder()->macros->do_macros( $settings['archive_badge_text'] ); $badge_content = jet_woo_builder_template_functions()->get_product_sale_flash( $badge_text ); if ( null !== $badge_content ){ echo '
'; echo $badge_content; echo '
'; } } protected function render() { $settings = $this->get_settings(); $macros_settings = array( 'archive_badge_text' => $settings['archive_badge_text'], ); if ( jet_woo_builder_tools()->is_builder_content_save() ) { echo jet_woo_builder()->parser->get_macros_string( $this->get_name(), $macros_settings ); } else { echo self::render_callback( $macros_settings ); } } }