start_controls_section( 'section_detail', array( 'label' => esc_html__( 'Section Setting', 'accesspress-parallax' ), ) ); $this->add_control( 'categories', [ 'label' => esc_html__( 'Product Categories', 'accesspress-parallax' ), 'type' => Controls_Manager::SELECT2, 'label_block' => true, 'multiple' => true, 'options' => accesspress_parallax_get_product_categories(), ] ); $this->add_control( 'showposts', [ 'label' => esc_html__( 'Posts To Show', 'accesspress-parallax' ), 'type' => Controls_Manager::NUMBER, 'default' => '-1' ] ); $this->end_controls_section(); //styling tab $this->start_controls_section( 'section_general_style', [ 'label' => esc_html__( 'General Styles', 'accesspress-parallax' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); //element title $this->add_control( 'content_title_color', [ 'label' => esc_html__( 'Product Title Color', 'accesspress-parallax' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .ap-product-wrapper .woocommerce-loop-product__title' => 'color: {{VALUE}};', ], ] ); //element title $this->add_control( 'content_price_color', [ 'label' => esc_html__( 'Product price Color', 'accesspress-parallax' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .price' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'content_addtocart_color', [ 'label' => esc_html__( 'Add to Cart Color', 'accesspress-parallax' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .add_to_cart_button' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'content_addtocart_color_hover', [ 'label' => esc_html__( 'Add to Cart Color: Hover', 'accesspress-parallax' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .add_to_cart_button:hover' => 'background-color: {{VALUE}};border-color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'content_title_typography', 'label' => esc_html__( 'Product Title Typography', 'accesspress-parallax' ), 'scheme' => Scheme_Typography::TYPOGRAPHY_4, 'selector' => '{{WRAPPER}} .ap-product-wrapper .woocommerce-loop-product__title', ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'content_price_typography', 'label' => esc_html__( 'Product Price Typography', 'accesspress-parallax' ), 'scheme' => Scheme_Typography::TYPOGRAPHY_4, 'selector' => '{{WRAPPER}} .price', ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'content_addtocart_typography', 'label' => esc_html__( 'Add to Cart', 'accesspress-parallax' ), 'scheme' => Scheme_Typography::TYPOGRAPHY_4, 'selector' => '{{WRAPPER}} .add_to_cart_button, {{WRAPPER}} li.product a.added_to_cart', ] ); $this->end_controls_section();//end for styling tab } /** * Render Accesspress_Parallax_Shop_Slider widget output on the frontend. * * Written in PHP and used to generate the final HTML. * * @access protected */ protected function render() { $settings = $this->get_settings(); $this->add_render_attribute( 'ap-shop', 'class', 'ap-shop-section' ); $showposts = isset( $settings[ 'showposts' ] )? $settings[ 'showposts' ] : '-1'; $categories = isset( $settings[ 'categories' ] )? $settings[ 'categories' ] : array(); $block_args = array( 'post_type' => 'product', 'posts_per_page' => $showposts, ); if( $categories ){ $block_args['tax_query'] = "array( array( 'taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $categories ) )"; } $query = new \WP_Query( $block_args ); ?>