📄 pricing-table.php
📁 Path: /home/s/t/a/stakrfrcol/agency/wp-content/themes/xhyre/includes/elementor/pricing-table.php
📊 Size: 16.95 KB
🔒 Perm: 0644
📝 MIME: text/x-php
<?php
namespace Elementor; // Custom widgets must be defined in the Elementor namespace
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly (security measure)
/**
* Widget Name: Projects Carousel
*/
class PBMIT_PTableElement extends Widget_Base{
// The get_name() method is a simple one, you just need to return a widget name that will be used in the code.
public function get_name() {
return 'pbmit_ptable_element';
}
// The get_title() method, which again, is a very simple one, you need to return the widget title that will be displayed as the widget label.
public function get_title() {
return esc_attr__( 'Xhyre Pricing Table Element', 'xhyre' );
}
// The get_icon() method, is an optional but recommended method, it lets you set the widget icon. you can use any of the eicon or font-awesome icons, simply return the class name as a string.
public function get_icon() {
return 'fas fa-dollar-sign';
}
// The get_categories method, lets you set the category of the widget, return the category name as a string.
public function get_categories() {
return [ 'xhyre_category' ];
}
public function __construct($data = [], $args = null) {
parent::__construct($data, $args);
}
protected function register_controls() {
// Style
$this->start_controls_section(
'style_section',
[
'label' => esc_attr__( 'Select Style', 'xhyre' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'style',
[
'label' => esc_attr__( 'Select Pricing Table View Style', 'xhyre' ),
'description' => esc_attr__( 'Select Pricing Table View style.', 'xhyre' ),
'type' => 'pbmit_imgselect',
'label_block' => true,
'thumb_width' => '110px',
'default' => '1',
'options' => pbmit_element_template_list( 'pricing-table', true ),
]
);
$this->end_controls_section();
// HTML Tags
$this->start_controls_section(
'advanced_section',
[
'label' => pbmit_esc_kses('<img class="pbmit-tab-small-logo" src="'.get_template_directory_uri() . '/includes/images/pbm-small-logo.png" /> ') . esc_attr__( 'Tag & Gap Settings', 'xhyre' ),
'tab' => Controls_Manager::TAB_ADVANCED,
]
);
$this->add_control(
'tag_options',
[
'label' => esc_attr__( 'Tags for SEO', 'xhyre' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_control(
'title_tag',
[
'label' => esc_attr__( 'Heading Tag', 'xhyre' ),
'type' => Controls_Manager::SELECT,
'options' => [
'h1' => esc_attr( 'H1' ),
'h2' => esc_attr( 'H2' ),
'h3' => esc_attr( 'H3' ),
'h4' => esc_attr( 'H4' ),
'h5' => esc_attr( 'H5' ),
'h6' => esc_attr( 'H6' ),
'div' => esc_attr( 'DIV' ),
],
'default' => esc_attr( 'h2' ),
]
);
$this->add_control(
'subtitle_tag',
[
'label' => esc_attr__( 'Subheading Tag', 'xhyre' ),
'type' => Controls_Manager::SELECT,
'options' => [
'h1' => esc_attr( 'H1' ),
'h2' => esc_attr( 'H2' ),
'h3' => esc_attr( 'H3' ),
'h4' => esc_attr( 'H4' ),
'h5' => esc_attr( 'H5' ),
'h6' => esc_attr( 'H6' ),
'div' => esc_attr( 'DIV' ),
],
'default' => esc_attr( 'h4' ),
]
);
$this->end_controls_section();
// Highlight Column
$this->start_controls_section(
'highlight_col_section',
[
'label' => esc_attr__( 'Highlight Column', 'xhyre' ),
]
);
$this->add_control(
'highlight_col',
[
'label' => esc_attr__( 'Highlight Column', 'xhyre' ),
'description' => esc_attr__( 'Select column which is highlighted in pricing table', 'xhyre' ),
'type' => Controls_Manager::SELECT,
'options' => [
'1' => esc_attr__( 'First Column', 'xhyre' ),
'2' => esc_attr__( 'Second Column', 'xhyre' ),
'3' => esc_attr__( 'Third Column', 'xhyre' ),
'4' => esc_attr__( 'Fourth Column', 'xhyre' ),
'5' => esc_attr__( 'Fifth Column', 'xhyre' ),
],
'default' => esc_attr( '2' ),
]
);
$this->add_control(
'highlight_text',
[
'label' => esc_attr__( 'Highlight Text', 'xhyre' ),
'type' => Controls_Manager::TEXT,
'dynamic' => [
'active' => true,
],
'placeholder' => esc_attr__( 'This will appear as special text', 'xhyre' ),
'default' => esc_attr( 'popular', 'xhyre' ),
'label_block' => true,
]
);
$this->end_controls_section();
for( $x=1; $x<=5; $x++ ){
$default_heading = '';
$default_price = '';
if( $x == 1 ){
$default_heading = esc_attr__( 'Basic Plan', 'xhyre' );
$default_price = esc_attr__( '247', 'xhyre' );
$default_desc = esc_attr__( 'The argument in favor of using to filler text goes something.', 'xhyre' );
$default_icon = [
'value' => 'fas fa-user-alt',
'library' => 'fa-solid',
'url' => '',
];
} else if( $x == 2 ){
$default_heading = esc_attr__( 'Premium Plan', 'xhyre' );
$default_price = esc_attr__( '341', 'xhyre' );
$default_desc = esc_attr__( 'The argument in favor of using to filler text goes something.', 'xhyre' );
$default_icon = [
'value' => 'fas fa-user-alt',
'library' => 'fa-solid',
'url' => '',
];
} else if( $x == 3 ){
$default_heading = esc_attr__( 'Standard Plan', 'xhyre' );
$default_price = esc_attr__( '299', 'xhyre' );
$default_desc = esc_attr__( 'The argument in favor of using to filler text goes something.', 'xhyre' );
$default_icon = [
'value' => 'fas fa-user-alt',
'library' => 'fa-solid',
'url' => '',
];
}
//Content
$this->start_controls_section(
$x.'_col_section',
[
'label' => sprintf( esc_attr__( '%1$s Column in Pricing Table', 'xhyre' ) , pbmit_ordinal($x) ) ,
]
);
$this->add_control(
$x.'_heading',
[
'label' => esc_attr__( 'Heading', 'xhyre' ),
'type' => Controls_Manager::TEXT,
'default' => esc_attr( $default_heading ),
'description' => esc_attr__( 'Enter text used as main heading. This will be plan title like "Basic", "Pro" etc.', 'xhyre' ),
'label_block' => true,
]
);
$this->add_control(
$x.'_desc',
[
'label' => esc_attr__( 'Description', 'xhyre' ),
'type' => Controls_Manager::TEXT,
'default' => esc_attr( $default_desc ),
'description' => esc_attr__( 'Enter text used as description.', 'xhyre' ),
'separator' => 'after',
'label_block' => true,
]
);
$this->add_control(
$x.'_price',
[
'label' => esc_attr__( 'Price', 'xhyre' ),
'type' => Controls_Manager::TEXT,
'default' => esc_attr( $default_price ),
'description' => esc_attr__( 'Enter Price.', 'xhyre' ),
]
);
$this->add_control(
$x.'_cur_symbol',
[
'label' => esc_attr__( 'Currency symbol', 'xhyre' ),
'type' => Controls_Manager::TEXT,
'default' => esc_attr( '$' ),
'description' => esc_attr__( 'Enter currency symbol', 'xhyre' ),
]
);
$this->add_control(
$x.'_cur_symbol_position',
[
'label' => esc_html__( 'Currency Symbol position', 'xhyre' ),
'description' => esc_html__( 'Select currency position.', 'xhyre' ),
'type' => Controls_Manager::SELECT,
'default' => esc_attr('before'),
'options' => [
'after' => esc_attr__( 'After Price', 'xhyre' ),
'before' => esc_attr__( 'Before Price', 'xhyre' ),
],
]
);
$this->add_control(
$x.'_price_frequency',
[
'label' => esc_attr__( 'Price Frequency', 'xhyre' ),
'type' => Controls_Manager::TEXT,
'default' => esc_attr__( 'Monthly', 'xhyre' ),
'description' => esc_attr__( 'Enter currency frequency like "Monthly", "Yearly" or "Weekly" etc.', 'xhyre' ),
'separator' => 'after',
]
);
$this->add_control(
$x.'_btn_text',
[
'label' => esc_attr__( 'Button Text', 'xhyre' ),
'type' => Controls_Manager::TEXT,
'default' => esc_attr__( 'Purchase Now', 'xhyre' ),
'description' => esc_attr__( 'Like "Read More" or "Buy Now".', 'xhyre' ),
]
);
$this->add_control(
$x.'_btn_link',
[
'label' => esc_attr__( 'Button Link', 'xhyre' ),
'type' => Controls_Manager::URL,
'default' => array (
'url' => '#',
'is_external' => '',
'nofollow' => '',
'custom_attributes' => '',
),
'description' => esc_attr__( 'Set link for button', 'xhyre' ),
'separator' => 'after',
]
);
$repeater = new Repeater();
$repeater->add_control(
'text',
[
'label' => esc_attr__( 'Line Label', 'xhyre' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
]
);
$this->add_control(
$x.'_lines',
[
'label' => esc_attr__( 'Each Line (Features)', 'xhyre' ),
'description' => esc_attr__( 'Enter features that will be shown in spearate lines.', 'xhyre' ),
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'default' => [
[
'text' => esc_attr__( 'Individuals & small projects', 'xhyre' ),
],
[
'text' => esc_attr__( 'Access to design features', 'xhyre' ),
],
[
'text' => esc_attr__( 'Limited library of decorative items', 'xhyre' ),
],
[
'text' => esc_attr__( 'Email support', 'xhyre' ),
],
[
'text' => esc_attr__( 'Monthly updates', 'xhyre' ),
],
],
'title_field' => '{{{ text }}}',
]
);
$this->end_controls_section();
} // end for loop
// Heading and Subheading
$this->start_controls_section(
'heading_section',
[
'label' => esc_attr__( 'Heading and Subheading', 'xhyre' ),
]
);
$this->add_control(
'title_animation',
[
'label' => esc_attr__( 'Heading Animation', 'xhyre' ),
'description' => esc_attr__( 'Select Heading Text Animation View style.', 'xhyre' ) . ' ' . pbmit_esc_kses('<br><a target="_blank" href="' . esc_url('https://xhyre-demo.pbminfotech.com/demo1/element/#heading-animations') . '">' . esc_attr__( 'See all anmiation demo here.', 'xhyre' ) . '</a>' ),
'type' => Controls_Manager::SELECT,
'default' => '4',
'options' => [
'4' => esc_attr__( 'No animation', 'xhyre' ),
'1' => esc_attr__( 'Animation Style 1', 'xhyre' ),
'2' => esc_attr__( 'Animation Style 2', 'xhyre' ),
'3' => esc_attr__( 'Animation Style 3', 'xhyre' ),
],
'separator' => 'before',
]
);
$this->add_control(
'title',
[
'label' => esc_attr__( 'Heading', 'xhyre' ),
'type' => Controls_Manager::TEXTAREA,
'dynamic' => [
'active' => true,
],
'default' => esc_attr__( 'Our Plans', 'xhyre' ),
'placeholder' => esc_attr__( 'Enter your heading', 'xhyre' ),
'label_block' => true,
]
);
$this->add_control(
'title_link',
[
'label' => esc_attr__( 'Heading Link', 'xhyre' ),
'type' => Controls_Manager::URL,
'label_block' => true,
]
);
$this->add_control(
'subtitle',
[
'label' => esc_attr__( 'Subheading', 'xhyre' ),
'type' => Controls_Manager::TEXTAREA,
'dynamic' => [
'active' => true,
],
'placeholder' => esc_attr__( 'Enter your subtitle', 'xhyre' ),
'label_block' => true,
]
);
$this->add_control(
'subtitle_link',
[
'label' => esc_attr__( 'Subheading Link', 'xhyre' ),
'type' => Controls_Manager::URL,
'label_block' => true,
]
);
$this->add_control(
'desc',
[
'label' => esc_attr__( 'Description', 'xhyre' ),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_attr__( 'Type your description here', 'xhyre' ),
]
);
$this->add_control(
'reverse_title',
[
'label' => esc_attr__( 'Reverse Heading', 'xhyre' ),
'description' => esc_attr__( 'Show Subheading before Heading', 'xhyre' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_attr__( 'Yes', 'xhyre' ),
'label_off' => esc_attr__( 'No', 'xhyre' ),
'return_value' => 'yes',
'default' => '',
]
);
$this->add_responsive_control(
'text_align',
[
'label' => esc_attr__( 'Alignment', 'xhyre' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => esc_attr__( 'Left', 'xhyre' ),
'icon' => 'fa fa-align-left',
],
'center' => [
'title' => esc_attr__( 'Center', 'xhyre' ),
'icon' => 'fa fa-align-center',
],
'right' => [
'title' => esc_attr__( 'Right', 'xhyre' ),
'icon' => 'fa fa-align-right',
],
],
'selectors' => [
'{{WRAPPER}} .pbmit-heading-subheading' => 'text-align: {{VALUE}};',
],
'dynamic' => [
'active' => true,
],
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
extract($settings);
$return = '';
?>
<div class="pbminfotech-ele pbminfotech-ele-pricing-table pbminfotech-ele-ptable-style-<?php echo esc_attr($style); ?>">
<?php pbmit_heading_subheading($settings, true); ?>
<?php
$columns = array();
for ($x = 0; $x <= 5; $x++) {
if( !empty( $settings[$x.'_heading'] ) ){
$columns[$x] = $x;
}
}
$col_start_div = '';
$col_end_div = '';
if( !empty($columns) ){
switch( count($columns) ){
case 1:
$col_start_div = '<div class="pbmit-ptable-col col-md-12">';
$col_end_div = '</div>';
break;
case 2:
$col_start_div = '<div class="pbmit-ptable-col col-md-6">';
$col_end_div = '</div>';
break;
case 3:
$col_start_div = '<div class="pbmit-ptable-col col-lg-4 col-md-6 col-sm-12">';
$col_end_div = '</div>';
break;
case 4:
$col_start_div = '<div class="pbmit-ptable-col col-md-3">';
$col_end_div = '</div>';
break;
case 5:
$col_start_div = '<div class="pbmit-ptable-col col-md-20percent">';
$col_end_div = '</div>';
break;
}
}
if( !empty($columns) ){
?>
<div class="pbmit-element-posts-wrapper pbmit-ptable-cols row multi-columns-row">
<?php
foreach( $columns as $col => $highlight_col ){
// add highlighted class
$featured = '';
if( $settings['highlight_col'] == $col ){
$col_start_div = str_replace( 'class="', 'class="pbmit-pricing-table-featured-col ', $col_start_div );
$featured = ( !empty($settings['highlight_col']) ) ? '<div class="pbmit-feature-wrap"><div class="pbmit-ptablebox-featured-w">'.$settings['highlight_text'].'</div></div>' : '' ;
} else {
$col_start_div = str_replace( 'class="pbmit-pricing-table-featured-col ', 'class="', $col_start_div );
}
// Heading
$heading = ( !empty($settings[$col.'_heading']) ) ? '<h3 class="pbminfotech-ptable-heading">'.$settings[$col.'_heading'].'</h3>' : '' ;
// Description
$desc = ( !empty($settings[$col.'_desc']) ) ? '<div class="pbminfotech-ptable-desc">'.$settings[$col.'_desc'].'</div>' : '' ;
// Currency Symbol
$currency_symbol = ( !empty($settings[$col.'_cur_symbol']) ) ? '<div class="pbminfotech-ptable-symbol">'.$settings[$col.'_cur_symbol'].'</div>' : '' ;
// Price Frequency
$frequency = ( !empty($settings[$col.'_price_frequency']) ) ? '<div class="pbminfotech-ptable-frequency">'.$settings[$col.'_price_frequency'].'</div>' : '' ;
// Price
$price = ( !empty($settings[$col.'_price']) ) ? '<div class="pbminfotech-ptable-price">'.$settings[$col.'_price'].'</div>' : '' ;
// Add currently symbol in price
$price = ( !empty($settings[$col.'_cur_symbol_position']) && $settings[$col.'_cur_symbol_position']=='before' ) ? $currency_symbol.' '.$price : $price.' '.$currency_symbol ;
// list of features
$lines_html = '';
$values = (array) $settings[$col.'_lines'];
if( is_array($values) && count($values)>0 ){
foreach ( $values as $data ) {
$lines_html .= isset( $data['text'] ) ? '<div class="pbmit-ptable-line">'.$data['text'].'</div>' : '';
}
}
// Button
$button = '';
if( !empty($settings[$col.'_btn_text']) && !empty($settings[$col.'_btn_link']['url']) ){
$button = '<div class="pbmit-price-btn">' . pbmit_link_render($settings[$col.'_btn_link'], 'start' ) . pbmit_esc_kses($settings[$col.'_btn_text']) . pbmit_link_render($settings[$col.'_btn_link'], 'end' ) . '</div>';
}
// Template output
echo pbmit_esc_kses( $col_start_div );
include( get_template_directory() . '/theme-parts/pricing-table/pricing-table-style-'.esc_attr($style).'.php' );
echo pbmit_esc_kses( $col_end_div );
} ?>
</div>
<?php } ?>
</div><!-- pbminfotech-ele pbminfotech-ele-pricing-table -->
<?php
}
protected function content_template() {}
protected function select_category() {
$category = get_terms( array( 'taxonomy' => 'pbmit-ptable-category', 'hide_empty' => false ) );
$cat = array();
foreach( $category as $item ) {
$cat_count = get_category( $item );
if( $item ) {
$cat[$item->slug] = $item->name . ' ('.$cat_count->count.')';
}
}
return $cat;
}
}
// After the Schedule class is defined, I must register the new widget class with Elementor:
Plugin::instance()->widgets_manager->register( new PBMIT_PTableElement() );