PATH:
home
/
letacommog
/
newrdv1
/
wp-content
/
themes
/
besa
/
inc
/
vendors
/
elementor
/
abstract
<?php if (!defined('ABSPATH') || function_exists('Besa_Elementor_Widget_Base') ) { exit; // Exit if accessed directly. } use Elementor\Controls_Manager; use Elementor\Scheme_Color; use Elementor\Group_Control_Typography; abstract class Besa_Elementor_Widget_Base extends Elementor\Widget_Base { public function get_name_template() { return str_replace('besa-', '', $this->get_name()); } public function get_categories() { return [ 'besa-elements' ]; } public function get_name() { return 'besa-base'; } /** * Get view template * * @param string $tpl_name */ protected function get_view_template( $tpl_slug, $tpl_name, $settings = [] ) { $located = ''; $templates = []; if ( ! $settings ) { $settings = $this->get_settings_for_display(); } if ( !empty($tpl_name) ) { $tpl_name = trim( str_replace( '.php', '', $tpl_name ), DIRECTORY_SEPARATOR ); $templates[] = 'elementor_templates/' . $tpl_slug . '-' . $tpl_name . '.php'; $templates[] = 'elementor_templates/' . $tpl_slug . '/' . $tpl_name . '.php'; } $templates[] = 'elementor_templates/' . $tpl_slug . '.php'; foreach ( $templates as $template ) { if ( file_exists( BESA_THEMEROOT . '/' . $template ) ) { $located = BESA_THEMEROOT . '/' . $template; break; } else { $located = false; } } if ( $located ) { include $located; } else { echo sprintf( __( 'Failed to load template with slug "%s" and name "%s".', 'besa' ), $tpl_slug, $tpl_name ); } } protected function render() { $settings = $this->get_settings_for_display(); $this->add_render_attribute('wrapper', 'class', 'tbay-element tbay-element-'. $this->get_name_template() ); $this->get_view_template($this->get_name_template(), '', $settings); } protected function register_controls_heading($condition = array()) { $this->start_controls_section( 'section_heading', [ 'label' => esc_html__( 'Heading', 'besa' ), 'condition' => $condition, ] ); $this->add_responsive_control( 'align', [ 'label' => esc_html__('Alignment', 'besa'), 'type' => Controls_Manager::CHOOSE, 'options' => [ 'left' => [ 'title' => esc_html__('Left', 'besa'), 'icon' => 'fa fa-align-left', ], 'center' => [ 'title' => esc_html__('Center', 'besa'), 'icon' => 'fa fa-align-center', ], 'right' => [ 'title' => esc_html__('Right', 'besa'), 'icon' => 'fa fa-align-right', ], ], 'default' => '', 'selectors' => [ '{{WRAPPER}} .heading-tbay-title' => 'text-align: {{VALUE}};', ], ] ); $this->add_control( 'heading_title', [ 'label' => esc_html__('Title', 'besa'), 'type' => Controls_Manager::TEXT, ] ); $this->add_control( 'heading_title_tag', [ 'label' => esc_html__( 'Title HTML Tag', 'besa' ), 'type' => Controls_Manager::SELECT, 'options' => [ 'h1' => 'H1', 'h2' => 'H2', 'h3' => 'H3', 'h4' => 'H4', 'h5' => 'H5', 'h6' => 'H6', 'div' => 'div', 'span' => 'span', 'p' => 'p', ], 'default' => 'h3', ] ); $this->add_control( 'heading_subtitle', [ 'label' => esc_html__('Sub Title', 'besa'), 'type' => Controls_Manager::TEXT, ] ); $this->end_controls_section(); $this->start_controls_section( 'section_style_heading', [ 'label' => esc_html__( 'Heading', 'besa' ), 'tab' => Controls_Manager::TAB_STYLE, 'condition' => $condition, ] ); $this->register_title_styles(); $this->register_sub_title_styles(); $this->register_content_styles(); $this->end_controls_section(); } private function register_content_styles() { $this->add_control( 'heading_stylecontent', [ 'label' => esc_html__( 'Content', 'besa' ), 'type' => Controls_Manager::HEADING, 'separator' => 'before', ] ); $this->add_responsive_control( 'heading_style_margin', [ 'label' => esc_html__( 'Margin', 'besa' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%' ], 'selectors' => [ '{{WRAPPER}} .heading-tbay-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'heading_style_padding', [ 'label' => esc_html__( 'Padding', 'besa' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%' ], 'selectors' => [ '{{WRAPPER}} .heading-tbay-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_control( 'heading_style_bg', [ 'label' => esc_html__( 'Background', 'besa' ), 'type' => Controls_Manager::COLOR, 'default' => '', 'selectors' => [ '{{WRAPPER}} .heading-tbay-title' => 'background: {{VALUE}};', ], ] ); } private function register_title_styles() { $this->add_control( 'heading_styletitle', [ 'label' => esc_html__( 'Title', 'besa' ), 'type' => Controls_Manager::HEADING, 'separator' => 'before', ] ); $this->add_responsive_control( 'heading_title_size', [ 'label' => esc_html__('Font Size', 'besa'), 'type' => Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 10, 'max' => 80, ], ], 'selectors' => [ '{{WRAPPER}} .heading-tbay-title .title' => 'font-size: {{SIZE}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'heading_title_line_height', [ 'label' => esc_html__('Line Height', 'besa'), 'type' => Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 10, 'max' => 80, ], ], 'selectors' => [ '{{WRAPPER}} .heading-tbay-title .title' => 'line-height: {{SIZE}}{{UNIT}};', ], ] ); $this->add_control( 'heading_title_color', [ 'label' => esc_html__( 'Color', 'besa' ), 'type' => Controls_Manager::COLOR, 'default' => '', 'selectors' => [ '{{WRAPPER}} .heading-tbay-title .title' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'heading_title_color_hover', [ 'label' => esc_html__( 'Hover Color', 'besa' ), 'type' => Controls_Manager::COLOR, 'default' => '', 'scheme' => [ 'type' => Scheme_Color::get_type(), 'value' => Scheme_Color::COLOR_1, ], 'selectors' => [ '{{WRAPPER}}:hover .heading-tbay-title .title' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'heading_title_typography', 'selector' => '{{WRAPPER}} .heading-tbay-title .title', ] ); $this->add_responsive_control( 'heading_title_bottom_space', [ 'label' => esc_html__( 'Spacing', 'besa' ), 'type' => Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 0, 'max' => 100, ], ], 'selectors' => [ '{{WRAPPER}} .heading-tbay-title .title' => 'margin-bottom: {{SIZE}}{{UNIT}};', ], ] ); } private function register_sub_title_styles() { $this->add_control( 'heading_stylesubtitle', [ 'label' => esc_html__( 'Sub title', 'besa' ), 'type' => Controls_Manager::HEADING, 'separator' => 'before', ] ); $this->add_responsive_control( 'heading_subtitle_size', [ 'label' => esc_html__('Font Size', 'besa'), 'type' => Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 10, 'max' => 80, ], ], 'selectors' => [ '{{WRAPPER}} .heading-tbay-title .subtitle' => 'font-size: {{SIZE}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'heading_subtitle_line_height', [ 'label' => esc_html__('Line Height', 'besa'), 'type' => Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 10, 'max' => 80, ], ], 'selectors' => [ '{{WRAPPER}} .heading-tbay-title .subtitle' => 'line-height: {{SIZE}}{{UNIT}};', ], ] ); $this->add_control( 'heading_subtitle_color', [ 'label' => esc_html__( 'Color', 'besa' ), 'type' => Controls_Manager::COLOR, 'default' => '', 'selectors' => [ '{{WRAPPER}} .heading-tbay-title .subtitle' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'heading_subtitle_color_hover', [ 'label' => esc_html__( 'Hover Color', 'besa' ), 'type' => Controls_Manager::COLOR, 'default' => '', 'scheme' => [ 'type' => Scheme_Color::get_type(), 'value' => Scheme_Color::COLOR_1, ], 'selectors' => [ '{{WRAPPER}}:hover .heading-tbay-title .subtitle' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'heading_subtitle_typography', 'selector' => '{{WRAPPER}} .heading-tbay-title .subtitle', ] ); $this->add_responsive_control( 'heading_subtitle_bottom_space', [ 'label' => esc_html__( 'Spacing', 'besa' ), 'type' => Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 0, 'max' => 100, ], ], 'selectors' => [ '{{WRAPPER}} .heading-tbay-title .subtitle' => 'margin-bottom: {{SIZE}}{{UNIT}};', ], ] ); } protected function get_available_pages() { $pages = get_pages(); $options = []; foreach ($pages as $page) { $options[$page->ID] = $page->post_title; } return $options; } protected function get_available_on_sale_products() { $args = array( 'post_type' => 'product', 'posts_per_page' => -1 ); $product_ids_on_sale = wc_get_product_ids_on_sale(); $product_ids_on_sale[] = 0; $args['post__in'] = $product_ids_on_sale; $loop = new WP_Query( $args ); $options = []; if ( $loop->have_posts() ): while ( $loop->have_posts() ): $loop->the_post(); global $product; $options[$product->get_id()] = $product->get_title(); endwhile; endif; wp_reset_postdata(); return $options; } protected function get_available_menus() { $menus = wp_get_nav_menus(); $options = []; foreach ($menus as $menu) { $options[$menu->slug] = $menu->name; } return $options; } public function render_element_heading() { $heading_title = $heading_title_tag = $heading_subtitle = ''; $settings = $this->get_settings_for_display(); extract( $settings ); if( !empty($heading_subtitle) || !empty($heading_title) ) : ?> <<?php echo trim($heading_title_tag); ?> class="heading-tbay-title"> <?php if( !empty($heading_title) ) : ?> <span class="title"><?php echo trim($heading_title); ?></span> <?php endif; ?> <?php if( !empty($heading_subtitle) ) : ?> <span class="subtitle"><?php echo trim($heading_subtitle); ?></span> <?php endif; ?> </<?php echo trim($heading_title_tag); ?>> <?php endif; } protected function get_template_product_grid() { return apply_filters( 'besa_get_template_product_grid', 'v1' ); } protected function get_template_product_vertical() { return apply_filters( 'besa_get_template_product_vertical', 'vertical-v1' ); } protected function get_template_product() { return apply_filters( 'besa_get_template_product', 'v1' ); } protected function get_product_type() { $type = [ 'newest' => esc_html__('Newest Products', 'besa'), 'on_sale' => esc_html__('On Sale Products', 'besa'), 'best_selling' => esc_html__('Best Selling', 'besa'), 'top_rated' => esc_html__('Top Rated', 'besa'), 'featured' => esc_html__('Featured Product', 'besa'), 'random_product' => esc_html__('Random Product', 'besa'), ]; return apply_filters( 'besa_woocommerce_product_type', $type); } protected function get_title_product_type($key) { $array = $this->get_product_type(); return $array[$key]; } protected function get_attribute_query_product_type($args, $product_type) { global $woocommerce; switch ($product_type) { case 'best_selling': $args['meta_key'] = 'total_sales'; $args['order'] = 'desc'; $args['orderby'] = 'meta_value_num'; $args['ignore_sticky_posts'] = 1; $args['meta_query'] = array(); $args['meta_query'][] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'][] = $woocommerce->query->visibility_meta_query(); break; case 'featured': $args['ignore_sticky_posts'] = 1; $args['meta_query'] = array(); $args['meta_query'][] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'][] = $woocommerce->query->visibility_meta_query(); $args['tax_query'][] = array( array( 'taxonomy' => 'product_visibility', 'field' => 'name', 'terms' => 'featured', 'operator' => 'IN' ) ); break; case 'top_rated': $args['meta_key'] = '_wc_average_rating'; $args['orderby'] = 'meta_value_num'; $args['order'] = 'desc'; break; case 'newest': $args['meta_query'] = array(); $args['meta_query'][] = $woocommerce->query->stock_status_meta_query(); break; case 'random_product': $args['orderby'] = 'rand'; $args['meta_query'] = array(); $args['meta_query'][] = $woocommerce->query->stock_status_meta_query(); break; case 'deals': $product_ids_on_sale = wc_get_product_ids_on_sale(); $product_ids_on_sale[] = 0; $args['post__in'] = $product_ids_on_sale; $args['meta_query'] = array(); $args['meta_query'][] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'][] = $woocommerce->query->visibility_meta_query(); $args['meta_query'][] = array( 'relation' => 'AND', array( 'relation' => 'OR', array( 'key' => '_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'numeric' ), array( 'key' => '_min_variation_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'numeric' ), ), array( 'key' => '_sale_price_dates_to', 'value' => time(), 'compare' => '>', 'type' => 'numeric' ), ); break; case 'on_sale': $product_ids_on_sale = wc_get_product_ids_on_sale(); $product_ids_on_sale[] = 0; $args['post__in'] = $product_ids_on_sale; break; } return $args; } protected function get_query_products($categories = array(), $cat_operator = '', $product_type = 'newest', $limit = '', $orderby = '', $order = '') { $atts = [ 'limit' => $limit, 'orderby' => $orderby, 'order' => $order ]; if (!empty($categories)) { if( !is_array( $categories ) ) { $atts['category'] = $categories; } else { $atts['category'] = implode(', ', $categories); $atts['cat_operator'] = $cat_operator; } } $type = 'products'; $shortcode = new WC_Shortcode_Products($atts, $type); $args = $shortcode->get_query_args(); $args = $this->get_attribute_query_product_type($args, $product_type); return new WP_Query($args); } protected function get_product_categories($number = '') { $args = array( 'taxonomy' => 'product_cat', 'hide_empty' => false, ); if ($number === 0) { return; } if( !empty($number) && $number !== -1 ) { $args['number'] = $number; } $category = get_terms($args); $results = array(); if (!is_wp_error($category)) { foreach ($category as $category) { $results[$this->transliterate($category->slug)] = $category->name.' ('.$category->count.') '; } } return $results; } protected function transliterate( $title ) { $title = urldecode( $title ); if ( function_exists( 'iconv' ) ) { $title = iconv( 'UTF-8', 'UTF-8//TRANSLIT//IGNORE', $title ); } return $title; } protected function get_cat_operator() { $operator = [ 'AND' => esc_html__('AND', 'besa'), 'IN' => esc_html__('IN', 'besa'), 'NOT IN' => esc_html__('NOT IN', 'besa'), ]; return apply_filters( 'besa_woocommerce_cat_operator', $operator); } protected function get_woo_order_by() { $oder_by = [ 'date' => esc_html__('Date', 'besa'), 'title' => esc_html__('Title', 'besa'), 'id' => esc_html__('ID', 'besa'), 'price' => esc_html__('Price', 'besa'), 'popularity' => esc_html__('Popularity', 'besa'), 'rating' => esc_html__('Rating', 'besa'), 'rand' => esc_html__('Random', 'besa'), 'menu_order' => esc_html__('Menu Order', 'besa'), ]; return apply_filters( 'besa_woocommerce_oder_by', $oder_by); } protected function get_woo_order() { $order = [ 'asc' => esc_html__('ASC', 'besa'), 'desc' => esc_html__('DESC', 'besa'), ]; return apply_filters( 'besa_woocommerce_order', $order); } protected function register_woocommerce_order() { $this->add_control( 'orderby', [ 'label' => esc_html__('Order By', 'besa'), 'type' => Controls_Manager::SELECT, 'default' => 'date', 'options' => $this->get_woo_order_by(), 'conditions' => [ 'relation' => 'AND', 'terms' => [ [ 'name' => 'product_type', 'operator' => '!==', 'value' => 'top_rated', ], [ 'name' => 'product_type', 'operator' => '!==', 'value' => 'random_product', ], [ 'name' => 'product_type', 'operator' => '!==', 'value' => 'best_selling', ], ], ], ] ); $this->add_control( 'order', [ 'label' => esc_html__('Order', 'besa'), 'type' => Controls_Manager::SELECT, 'default' => 'asc', 'options' => $this->get_woo_order(), 'conditions' => [ 'relation' => 'AND', 'terms' => [ [ 'name' => 'product_type', 'operator' => '!==', 'value' => 'top_rated', ], [ 'name' => 'product_type', 'operator' => '!==', 'value' => 'random_product', ], [ 'name' => 'product_type', 'operator' => '!==', 'value' => 'best_selling', ], ], ], ] ); } protected function register_woocommerce_categories_operator() { $categories = $this->get_product_categories(); $this->add_control( 'categories', [ 'label' => esc_html__('Categories', 'besa'), 'type' => Controls_Manager::SELECT2, 'default' => array_keys($categories)[0], 'options' => $categories, 'multiple' => true, ] ); $this->add_control( 'cat_operator', [ 'label' => esc_html__('Category Operator', 'besa'), 'type' => Controls_Manager::SELECT, 'default' => 'IN', 'options' => $this->get_cat_operator(), 'condition' => [ 'categories!' => '' ], ] ); } protected function get_woocommerce_tags() { $tags = array(); $args = array( 'order' => 'ASC', ); $product_tags = get_terms( 'product_tag', $args ); foreach ( $product_tags as $key => $tag ) { $tags[$tag->slug] = $tag->name . ' (' .$tag->count .')'; } return $tags; } public function settings_layout() { $settings = $this->get_settings_for_display(); extract( $settings ); if( !isset($layout_type) ) return; $this->add_render_attribute('row', 'class', $this->get_name_template()); if( isset($rows) && !empty($rows) ) { $this->add_render_attribute( 'row', 'class', 'row-'. $rows); } if($layout_type === 'carousel') { $this->settings_carousel($settings); }else{ $this->settings_responsive($settings); } } protected function get_widget_field_img( $image ) { $image_id = $image['id']; $img = ''; if( !empty($image_id) ) { $img = wp_get_attachment_image($image_id, 'full'); } else if( !empty($image['url']) ) { $img = '<img src="'. $image['url'] .'">'; } return $img; } }
[+]
..
[-] image.php
[edit]
[-] .abstract.php
[edit]
[-] responsive.php
[edit]
[-] base.php
[edit]
[-] carousel.php
[edit]