/home/moonrcjl/www/test/wp-content/plugins/arsha-core/include/elementor/contact-info.php
<?php
namespace TPCore\Widgets;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use \Elementor\Group_Control_Background;
use \Elementor\Group_Control_Image_Size;
use \Elementor\Repeater;
use \Elementor\Utils;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Tp Core
*
* Elementor widget for hello world.
*
* @since 1.0.0
*/
class TP_Contact_Info extends Widget_Base {
use \TPCore\Widgets\TPCoreElementFunctions;
/**
* Retrieve the widget name.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget name.
*/
public function get_name() {
return 'tp-contact-info';
}
/**
* Retrieve the widget title.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget title.
*/
public function get_title() {
return __( 'Contact Info', 'tpcore' );
}
/**
* Retrieve the widget icon.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget icon.
*/
public function get_icon() {
return 'tp-icon';
}
/**
* Retrieve the list of categories the widget belongs to.
*
* Used to determine where to display the widget in the editor.
*
* Note that currently Elementor supports only one category.
* When multiple categories passed, Elementor uses the first one.
*
* @since 1.0.0
*
* @access public
*
* @return array Widget categories.
*/
public function get_categories() {
return [ 'tpcore' ];
}
/**
* Retrieve the list of scripts the widget depended on.
*
* Used to set scripts dependencies required to run the widget.
*
* @since 1.0.0
*
* @access public
*
* @return array Widget scripts dependencies.
*/
public function get_script_depends() {
return [ 'tpcore' ];
}
/**
* Register the widget controls.
*
* Adds different input fields to allow the user to change and customize the widget settings.
*
* @since 1.0.0
*
* @access protected
*/
private function get_tp_contact_form(){
if ( ! class_exists( 'WPCF7' ) ) {
return;
}
$tp_cfa = array();
$tp_cf_args = array( 'posts_per_page' => -1, 'post_type'=> 'wpcf7_contact_form' );
$tp_forms = get_posts( $tp_cf_args );
$tp_cfa = ['0' => esc_html__( 'Select Form', 'tpcore' ) ];
if( $tp_forms ){
foreach ( $tp_forms as $tp_form ){
$tp_cfa[$tp_form->ID] = $tp_form->post_title;
}
}else{
$tp_cfa[ esc_html__( 'No contact form found', 'tpcore' ) ] = 0;
}
return $tp_cfa;
}
protected static function get_profile_names()
{
return [
'500px' => esc_html__('500px', 'tpcore'),
'apple' => esc_html__('Apple', 'tpcore'),
'behance' => esc_html__('Behance', 'tpcore'),
'bitbucket' => esc_html__('BitBucket', 'tpcore'),
'codepen' => esc_html__('CodePen', 'tpcore'),
'delicious' => esc_html__('Delicious', 'tpcore'),
'deviantart' => esc_html__('DeviantArt', 'tpcore'),
'digg' => esc_html__('Digg', 'tpcore'),
'dribbble' => esc_html__('Dribbble', 'tpcore'),
'email' => esc_html__('Email', 'tpcore'),
'facebook-f' => esc_html__('Facebook', 'tpcore'),
'flickr' => esc_html__('Flicker', 'tpcore'),
'foursquare' => esc_html__('FourSquare', 'tpcore'),
'github' => esc_html__('Github', 'tpcore'),
'houzz' => esc_html__('Houzz', 'tpcore'),
'instagram' => esc_html__('Instagram', 'tpcore'),
'jsfiddle' => esc_html__('JS Fiddle', 'tpcore'),
'linkedin' => esc_html__('LinkedIn', 'tpcore'),
'medium' => esc_html__('Medium', 'tpcore'),
'pinterest' => esc_html__('Pinterest', 'tpcore'),
'product-hunt' => esc_html__('Product Hunt', 'tpcore'),
'reddit' => esc_html__('Reddit', 'tpcore'),
'slideshare' => esc_html__('Slide Share', 'tpcore'),
'snapchat' => esc_html__('Snapchat', 'tpcore'),
'soundcloud' => esc_html__('SoundCloud', 'tpcore'),
'spotify' => esc_html__('Spotify', 'tpcore'),
'stack-overflow' => esc_html__('StackOverflow', 'tpcore'),
'tripadvisor' => esc_html__('TripAdvisor', 'tpcore'),
'tumblr' => esc_html__('Tumblr', 'tpcore'),
'twitch' => esc_html__('Twitch', 'tpcore'),
'twitter' => esc_html__('Twitter', 'tpcore'),
'vimeo' => esc_html__('Vimeo', 'tpcore'),
'vk' => esc_html__('VK', 'tpcore'),
'website' => esc_html__('Website', 'tpcore'),
'whatsapp' => esc_html__('WhatsApp', 'tpcore'),
'wordpress' => esc_html__('WordPress', 'tpcore'),
'xing' => esc_html__('Xing', 'tpcore'),
'yelp' => esc_html__('Yelp', 'tpcore'),
'youtube' => esc_html__('YouTube', 'tpcore'),
];
}
protected function register_controls(){
$this->register_controls_section();
$this->style_tab_content();
}
protected function register_controls_section() {
// layout Panel
$this->start_controls_section(
'tp_layout',
[
'label' => esc_html__('Design Layout', 'tpcore'),
]
);
$this->add_control(
'tp_design_style',
[
'label' => esc_html__('Select Layout', 'tpcore'),
'type' => Controls_Manager::SELECT,
'options' => [
'layout-1' => esc_html__('Layout 1', 'tpcore'),
],
'default' => 'layout-1',
]
);
$this->end_controls_section();
// Contact group
$this->start_controls_section(
'_tp_contact_info',
[
'label' => esc_html__('Contact List', 'tpcore'),
'description' => esc_html__( 'Control all the style settings from Style tab', 'tpcore' ),
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
]
);
$repeater = new \Elementor\Repeater();
$repeater->add_control(
'tp_box_icon_type',
[
'label' => esc_html__('Select Icon Type', 'tpcore'),
'type' => \Elementor\Controls_Manager::SELECT,
'default' => 'icon',
'options' => [
'image' => esc_html__('Image', 'tpcore'),
'icon' => esc_html__('Icon', 'tpcore'),
'svg' => esc_html__('SVG', 'tpcore'),
],
]
);
$repeater->add_control(
'tp_box_icon_svg',
[
'show_label' => false,
'type' => Controls_Manager::TEXTAREA,
'label_block' => true,
'placeholder' => esc_html__('SVG Code Here', 'tpcore'),
'condition' => [
'tp_box_icon_type' => 'svg',
]
]
);
$repeater->add_control(
'tp_box_icon_image',
[
'label' => esc_html__('Upload Icon Image', 'tpcore'),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
'condition' => [
'tp_box_icon_type' => 'image',
]
]
);
if (tp_is_elementor_version('<', '2.6.0')) {
$repeater->add_control(
'tp_box_icon',
[
'show_label' => false,
'type' => Controls_Manager::ICON,
'label_block' => true,
'default' => 'fa fa-star',
'condition' => [
'tp_box_icon_type' => 'icon',
]
]
);
} else {
$repeater->add_control(
'tp_box_selected_icon',
[
'show_label' => false,
'type' => Controls_Manager::ICONS,
'fa4compatibility' => 'icon',
'label_block' => true,
'default' => [
'value' => 'fas fa-star',
'library' => 'solid',
],
'condition' => [
'tp_box_icon_type' => 'icon',
]
]
);
}
$repeater->add_control(
'tp_contact_info_title',
[
'label' => esc_html__('Title', 'tpcore'),
'description' => tp_get_allowed_html_desc( 'intermediate' ),
'type' => \Elementor\Controls_Manager::TEXT,
'default' => __('Title Here', 'tpcore'),
'label_block' => true,
]
);
$repeater->add_control(
'tp_contact_info_des',
[
'label' => esc_html__('Description', 'tpcore'),
'description' => tp_get_allowed_html_desc( 'intermediate' ),
'type' => \Elementor\Controls_Manager::TEXTAREA,
'default' => __('info@company.com', 'tpcore'),
'label_block' => true,
]
);
$this->add_control(
'tp_list',
[
'label' => esc_html__('Contact - List', 'tpcore'),
'type' => \Elementor\Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'default' => [
[
'tp_contact_info_title' => esc_html__('united states', 'tpcore'),
],
[
'tp_contact_info_title' => esc_html__('south Africa', 'tpcore')
],
[
'tp_contact_info_title' => esc_html__('United Kingdom', 'tpcore')
]
],
'title_field' => '{{{ tp_contact_info_title }}}',
]
);
$this->end_controls_section();
}
// TAB_STYLE
protected function style_tab_content(){
$this->tp_section_style_controls('section_info', 'Section - Style', '.tp-el-section');
# repeater
$this->tp_icon_style('rep_icon_style', 'Repeater Icon/Image/SVG', '.tp-el-rep-icon', ['layout-1', 'layout-2', 'layout-3', 'layout-5']);
$this->tp_basic_style_controls('rep_title_style', 'Repeater Title', '.tp-el-rep-title', ['layout-1', 'layout-2', 'layout-3', 'layout-4', 'layout-5']);
$this->tp_basic_style_controls('rep_des_style', 'Repeater Description', '.tp-el-rep-des', 'layout-4');
}
/**
* Render the widget output on the frontend.
*
* Written in PHP and used to generate the final HTML.
*
* @since 1.0.0
*
* @access protected
*/
protected function render() {
$settings = $this->get_settings_for_display();
?>
<?php if ( $settings['tp_design_style'] == 'layout-2' ) : ?>
<?php else:
$this->add_render_attribute('title_args', 'class', 'contact-inner-title-sm tp-el-title');
?>
<section class="mtcontact__area-3 pb-100 tp-el-section">
<div class="container">
<div class="row">
<?php foreach ($settings['tp_list'] as $key => $item) : ?>
<div class="col-lg-4">
<div class="mtcontact__box-wrap mb-30">
<div class="mtcontact__box-item d-flex ">
<div class="mtcontact__box-icon mr-20">
<?php if($item['tp_box_icon_type'] == 'icon') : ?>
<?php if (!empty($item['tp_box_icon']) || !empty($item['tp_box_selected_icon']['value'])) : ?>
<span
class="tp-el-rep-icon"><?php tp_render_icon($item, 'tp_box_icon', 'tp_box_selected_icon'); ?></span>
<?php endif; ?>
<?php elseif( $item['tp_box_icon_type'] == 'image' ) : ?>
<?php if (!empty($item['tp_box_icon_image']['url'])): ?>
<span class="tp-el-rep-icon"><img src="<?php echo $item['tp_box_icon_image']['url']; ?>"
alt="<?php echo get_post_meta(attachment_url_to_postid($item['tp_box_icon_image']['url']), '_wp_attachment_image_alt', true); ?>"></span>
<?php endif; ?>
<?php else : ?>
<?php if (!empty($item['tp_box_icon_svg'])): ?>
<span class="tp-el-rep-icon"><?php echo $item['tp_box_icon_svg']; ?></span>
<?php endif; ?>
<?php endif; ?>
</div>
<div class="mtcontact__box-content">
<h5 class="mtcontact__box-title tp-el-rep-title">
<?php echo tp_kses($item['tp_contact_info_title']); ?></h5>
<?php echo tp_kses($item['tp_contact_info_des']); ?>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</section>
<?php endif;
}
}
$widgets_manager->register( new TP_Contact_Info() );