<?php
namespace Elementor;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class Pricing_table_two extends Widget_Base {
public function get_name() {
return 'cyarb-pricingtwo';
}
public function get_title() {
return __( 'Pricing Table Two', 'cyarb-hero' );
}
public function get_icon() {
return ' eicon-price-list';
}
public function get_categories() {
return [ 'cyarb-elements' ];
}
protected function register_controls() {
// Pricing Plan controls
$this-> start_controls_section(
'cyarb_monthly_plan',
[
'label' => esc_html__('Pricing Plan', 'cyarb-toolkit'),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'sec_title', [
'label' => esc_html__( 'Section Title', 'cyarb-toolkit' ),
'type' => Controls_Manager:: TEXTAREA,
]
);
$this->add_control(
'title_tag',
[
'label' => __( 'Title Tag', 'cyarb-toolkit' ),
'type' => Controls_Manager::SELECT,
'options' => [
'h1' => __( 'h1', 'cyarb-toolkit' ),
'h2' => __( 'h2', 'cyarb-toolkit' ),
'h3' => __( 'h3', 'cyarb-toolkit' ),
'h4' => __( 'h4', 'cyarb-toolkit' ),
'h5' => __( 'h5', 'cyarb-toolkit' ),
'h6' => __( 'h6', 'cyarb-toolkit' ),
],
'default' => 'h2',
]
);
$this->add_control(
'columns',
[
'label' => esc_html__( 'Choose Columns', 'cyarb-toolkit' ),
'type' => Controls_Manager::SELECT,
'options' => [
'1' => esc_html__( '1', 'cyarb-toolkit' ),
'2' => esc_html__( '2', 'cyarb-toolkit' ),
'3' => esc_html__( '3', 'cyarb-toolkit' ),
'4' => esc_html__( '4', 'cyarb-toolkit' ),
],
'default' => '4',
]
);
$repeater = new Repeater();
$repeater->add_control(
'monthly_type', [
'label' => esc_html__( 'Pricing Type', 'cyarb-toolkit' ),
'type' => Controls_Manager:: TEXT,
]
);
$repeater->add_control(
'price_content_text',
[
'label' => esc_html__('Pricing Content', 'cyarb-toolkit'),
'type' => Controls_Manager:: TEXT,
]
);
$repeater->add_control(
'monthly_price', [
'label' => esc_html__( 'Price Amount', 'cyarb-toolkit' ),
'type' => Controls_Manager:: TEXT,
]
);
$repeater->add_control(
'duration_type', [
'label' => esc_html__( 'Duration Type', 'cyarb-toolkit' ),
'type' => Controls_Manager:: TEXT,
]
);
$repeater->add_control(
'price_bottom_text', [
'label' => esc_html__( 'Price Bottom Text', 'cyarb-toolkit' ),
'type' => Controls_Manager:: TEXT,
]
);
$repeater->add_control(
'btn_text',
[
'label' => esc_html__('Button Title', 'cyarb-toolkit'),
'type' => Controls_Manager:: TEXT,
]
);
$repeater->add_control(
'link_type',
[
'label' => esc_html__( 'Link Type', 'cyarb-toolkit' ),
'type' => Controls_Manager::SELECT,
'label_block' => true,
'options' => [
'1' => esc_html__( 'Link To Page', 'cyarb-toolkit' ),
'2' => esc_html__( 'External Link', 'cyarb-toolkit' ),
],
]
);
$repeater->add_control(
'link_to_page',
[
'label' => esc_html__( 'Link Page', 'cyarb-toolkit' ),
'type' => Controls_Manager::SELECT,
'label_block' => true,
'options' => cyarb_toolkit_get_page_as_list(),
'condition' => [
'link_type' => '1',
]
]
);
$repeater->add_control(
'external_link',
[
'label' => esc_html__('External Link', 'cyarb-toolkit'),
'type' => Controls_Manager:: TEXT,
'condition' => [
'link_type' => '2',
]
]
);
//Target Page
$repeater->add_control(
'target_page',
[
'label' => esc_html__( 'Link Open In New Tab?', 'cyarb-toolkit' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'cyarb-toolkit' ),
'label_off' => esc_html__( 'No', 'cyarb-toolkit' ),
'return_value' => 'yes',
'default' => 'yes',
]
);
$repeater->add_control(
'feature_text',
[
'label' => esc_html__('Feature Text', 'cyarb-toolkit'),
'type' => Controls_Manager:: TEXT,
]
);
$repeater->add_control(
'price_list', [
'label' => esc_html__( 'Pricing List', 'cyarb-toolkit' ),
'type' => Controls_Manager:: TEXTAREA,
'description' => __('Please use a comma for seperating each list','cyarb-toolkit'),
]
);
$repeater->add_control(
'popular_text',
[
'label' => esc_html__('Popular Text', 'cyarb-toolkit'),
'type' => Controls_Manager:: TEXT,
]
);
$this->add_control(
'all_monthly_plan',
[
'label' => esc_html__( 'Add Pricing Plan', 'cyarb-toolkit' ),
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
]
);
$this-> end_controls_section();
$this->start_controls_section(
'section_style',
[
'label' => esc_html__( 'Style', 'cyarb-toolkit' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'sectitle_color',
[
'label' => esc_html__( 'Section Title Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .section-title h2, .section-title h1, .section-title h3, .section-title h4, .section-title h5, .section-title h6' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'sec_title_typography',
'label' => __( 'Section Title Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .section-title h2, .section-title h1, .section-title h3, .section-title h4, .section-title h5, .section-title h6',
]
);
$this->add_control(
'title_color',
[
'label' => esc_html__( 'Card Title Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-pricing-card .pricing-header h3' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title_typography',
'label' => __( 'Title Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .single-pricing-card .pricing-header h3',
]
);
$this->add_control(
'price_content_color',
[
'label' => esc_html__( 'Price Content Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-pricing-card .pricing-header p' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'price_content_typography',
'label' => __( 'Price Content Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .single-pricing-card .pricing-header p',
]
);
$this->add_control(
'price_color',
[
'label' => esc_html__( 'Price Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-pricing-card .price h4' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'price_typography',
'label' => __( 'Price Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .single-pricing-card .price h4',
]
);
$this->add_control(
'price_duration_color',
[
'label' => esc_html__( 'Price Duration Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-pricing-card .price h4 span' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'price_duration_typography',
'label' => __( 'Price Duration Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .single-pricing-card .price h4 span',
]
);
$this->add_control(
'price_b_color',
[
'label' => esc_html__( 'Price Bottom Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-pricing-card .price p' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'price_b_typography',
'label' => __( 'Price Bottom Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .single-pricing-card .price p',
]
);
$this->add_control(
'feature_text_color',
[
'label' => esc_html__( 'Feature Text Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-pricing-card .features-list h5' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'feature_text_typography',
'label' => __( 'Feature Text Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .single-pricing-card .features-list h5',
]
);
$this->add_control(
'price_list_color',
[
'label' => esc_html__( 'Price Lists Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-pricing-card .features-list ul li' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'price_list_typography',
'label' => __( 'Price Lists Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .single-pricing-card .features-list ul li',
]
);
$this->add_control(
'check_icon_color',
[
'label' => esc_html__( 'Check Icons Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-pricing-card .features-list ul li i' => 'color: {{VALUE}}',
],
]
);
$this->add_control(
'cross_icon_color',
[
'label' => esc_html__( 'Cross Icons Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-pricing-card .features-list ul li i.lni-close' => 'color: {{VALUE}}',
],
]
);
$this->add_control(
'btn_divider',
[
'type' => Controls_Manager::DIVIDER,
]
);
$this->add_control(
'btn2_divider',
[
'type' => Controls_Manager::DIVIDER,
]
);
$this->add_control(
'pop_tetx_head',
[
'label' => esc_html__( 'Popular Text Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'pop_color',
'types' => ['gradient' ],
'selector' => '{{WRAPPER}} .single-pricing-card .ribbon span',
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'pop_text_typography',
'label' => __( 'Popular Text Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .single-pricing-card .ribbon span',
]
);
$this->add_control(
'pop_btn_divider',
[
'type' => Controls_Manager::DIVIDER,
]
);
$this->add_control(
'btn_color',
[
'label' => esc_html__( 'Button Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-pricing-card .link-btn' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'btn_typography',
'label' => __( 'Button Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .single-pricing-card .link-btn',
]
);
$this->add_control(
'btn_text_head',
[
'label' => esc_html__( 'Button Background Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'btn_bg_color',
'types' => ['gradient' ],
'selector' => '{{WRAPPER}} .single-pricing-card .link-btn',
]
);
$this->add_control(
'popbtn_text_head',
[
'label' => esc_html__( 'Popular Text Button Background Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'popbtn_bg_color',
'types' => ['gradient' ],
'selector' => '{{WRAPPER}} .single-pricing-card .link-btn.blue-gradient',
]
);
$this->add_control(
'ccard_bg_color',
[
'label' => esc_html__( 'Card Background Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-pricing-card' => 'background-color: {{VALUE}}',
],
]
);
$this->add_control(
'card_bor_color',
[
'label' => esc_html__( 'Card Border Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-pricing-card:hover' => 'border-color: {{VALUE}}',
],
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
// Card Columns
$columns = $settings['columns'];
if($columns == '1') {
$column = 'col-xl-12 col-lg-12 col-md-6 col-sm-6';
}elseif ($columns == '2') {
$column = 'col-xl-6 col-lg-6 col-md-6 col-sm-6';
}elseif ($columns == '3') {
$column = 'col-xl-4 col-lg-6 col-md-6 col-sm-6';
}elseif ($columns == '4') {
$column = 'col-xl-3 col-lg-6 col-md-6 col-sm-6';
}
?>
<div class="pricing-style-two-area pt-100 pb-75">
<div class="container">
<?php if( $settings['sec_title'] != '' ) : ?>
<div class="section-title">
<<?php echo esc_attr( $settings['title_tag'] ); ?>><?php echo esc_html( $settings['sec_title'] ); ?></<?php echo esc_attr( $settings['title_tag'] ); ?>>
</div>
<?php endif; ?>
<div class="row justify-content-center">
<?php if ( $settings['all_monthly_plan'] !='' ) :
foreach ( $settings['all_monthly_plan'] as $item ) :
if( $item['monthly_type'] != '' || $item['monthly_price'] != '' ) {
// Get Plan Button link
$link_source = '';
if( $item['link_type'] == 1 ){
$link_source = get_page_link( $item['link_to_page'] );
} else {
$link_source = $item['external_link'];
} ?>
<div class="<?php echo esc_attr( $column ); ?>">
<div class="single-pricing-card">
<div class="pricing-header">
<h3><?php echo esc_html($item['monthly_type']); ?></h3>
<p><?php echo esc_html($item['price_content_text']); ?></p>
</div>
<div class="price">
<h4>
<?php echo esc_html($item['monthly_price']); ?>
<?php if( $item['duration_type'] != '' ) : ?>
<span><?php echo esc_html($item['duration_type']); ?></span>
<?php endif; ?>
</h4>
<p><?php echo esc_html($item['price_bottom_text']); ?></p>
</div>
<?php if( $item['btn_text'] !='' ) :
if ( 'yes' === $item['target_page'] ) { ?>
<a target="_blank" href="<?php echo esc_url($link_source); ?>" class="link-btn <?php if( $item['popular_text'] !='' ) : ?> blue-gradient <?php endif; ?>"><?php echo esc_html($item['btn_text']); ?></a> <?php
} else { ?>
<a href="<?php echo esc_url($link_source); ?>" class="link-btn <?php if( $item['popular_text'] !='' ) : ?> blue-gradient <?php endif; ?>"><?php echo esc_html($item['btn_text']); ?></a><?php
}
endif; ?>
<div class="features-list">
<h5><?php echo esc_html($item['feature_text']); ?></h5>
<ul>
<?php $inner_list = explode(",", $item['price_list']);
foreach( $inner_list as $list ) :
if( $list !='' ) : ?>
<li> <?php echo wp_kses_post( $list ); ?></li>
<?php endif;
endforeach;
?>
</ul>
</div>
<?php if( $item['popular_text'] !='' ) : ?>
<div class="ribbon"><span><?php echo esc_html($item['popular_text']); ?></span></div>
<?php endif; ?>
</div>
</div>
<?php }
endforeach;
endif;
?>
</div>
</div>
</div>
<?php
}
}
Plugin::instance()->widgets_manager->register_widget_type( new Pricing_table_two );