| Server IP : 172.67.71.254 / Your IP : 216.73.216.4 Web Server : nginx/1.27.1 System : Linux in-5 5.15.0-143-generic #153-Ubuntu SMP Fri Jun 13 19:10:45 UTC 2025 x86_64 User : arabianexpress ( 1872) PHP Version : 8.0.30 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /storage/v9321/leapdubai/public_html/wp-content/plugins/printx-core/include/elementor/ |
Upload File : |
<?php
namespace TPCore\Widgets;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use \Elementor\Group_Control_Image_Size;
use \Elementor\Group_Control_Background;
use \Elementor\Control_Media;
use \Elementor\Utils;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Tp Core
*
* Elementor widget for hello world.
*
* @since 1.0.0
*/
class TP_Portfolio 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-portfolio';
}
/**
* Retrieve the widget title.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget title.
*/
public function get_title() {
return __( 'Portfolio', '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
*/
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();
$this->start_controls_section(
'tp_portfolio_sec',
[
'label' => esc_html__( 'Portfolio', 'tpcore' ),
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'tp_image',
[
'label' => esc_html__( 'Portfolio Image', 'tpcore' ),
'type' => \Elementor\Controls_Manager::MEDIA,
'default' => [
'url' => \Elementor\Utils::get_placeholder_image_src(),
],
]
);
$this->add_group_control(
Group_Control_Image_Size::get_type(),
[
'name' => 'tp_image_size',
'default' => 'full',
'exclude' => [
'custom'
]
]
);
$this->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'),
],
]
);
$this->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',
]
]
);
$this->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')) {
$this->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 {
$this->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',
]
]
);
}
$this->add_control(
'tp_portfolio_box_title',
[
'label' => esc_html__( 'Portfolio Title', 'tpcore' ),
'type' => \Elementor\Controls_Manager::TEXT,
'description' => tp_get_allowed_html_desc( 'basic' ),
'default' => esc_html__( 'Title', 'tpcore' ),
'label_block' => true,
]
);
$this->add_control(
'tp_portfolio_box_sub_title',
[
'label' => esc_html__( 'Sub Title', 'tpcore' ),
'type' => \Elementor\Controls_Manager::TEXT,
'description' => tp_get_allowed_html_desc( 'basic' ),
'default' => esc_html__( 'Subtitle', 'tpcore' ),
'label_block' => true,
]
);
$this->add_control(
'tp_portfolio_link_switcher',
[
'label' => esc_html__( 'Add Portfolio link', 'tpcore' ),
'type' => \Elementor\Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'tpcore' ),
'label_off' => esc_html__( 'No', 'tpcore' ),
'return_value' => 'yes',
'default' => 'yes',
'separator' => 'before',
]
);
$this->add_control(
'tp_portfolio_link_type',
[
'label' => esc_html__( 'Portfolio Link Type', 'tpcore' ),
'type' => \Elementor\Controls_Manager::SELECT,
'options' => [
'1' => 'Custom Link',
'2' => 'Internal Page',
],
'default' => '1',
'condition' => [
'tp_portfolio_link_switcher' => 'yes'
]
]
);
$this->add_control(
'tp_portfolio_link',
[
'label' => esc_html__( 'Portfolio Link link', 'tpcore' ),
'type' => \Elementor\Controls_Manager::URL,
'dynamic' => [
'active' => true,
],
'placeholder' => esc_html__( 'https://your-link.com', 'tpcore' ),
'show_external' => true,
'default' => [
'url' => '#',
'is_external' => false,
'nofollow' => false,
],
'condition' => [
'tp_portfolio_link_type' => '1',
'tp_portfolio_link_switcher' => 'yes',
]
]
);
$this->add_control(
'tp_portfolio_page_link',
[
'label' => esc_html__( 'Select Portfolio Link Page', 'tpcore' ),
'type' => \Elementor\Controls_Manager::SELECT2,
'label_block' => true,
'options' => tp_get_all_pages(),
'condition' => [
'tp_portfolio_link_type' => '2',
'tp_portfolio_link_switcher' => 'yes',
]
]
);
$this->end_controls_section();
}
// style_tab_content
protected function style_tab_content(){
$this->tp_section_style_controls('portfolio_section', 'Section Style', '.ele-section');
$this->tp_icon_style('sec_icon', 'Icon/Image/SVG', '.tp-el-icon', 'layout-1');
$this->tp_basic_style_controls('heading_title', 'Title', '.tp-el-title', 'layout-1');
$this->tp_basic_style_controls('heading_subtitle', 'Subtitle', '.tp-el-subtitle', 'layout-1');
}
/**
* 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 :
// thumbnail
if ( !empty($settings['tp_image']['url']) ) {
$tp_image = !empty($settings['tp_image']['id']) ? wp_get_attachment_image_url( $settings['tp_image']['id'], $settings['tp_image_size_size']) : $settings['tp_image']['url'];
$tp_image_alt = get_post_meta($settings["tp_image"]["id"], "_wp_attachment_image_alt", true);
}
// Link
if ('2' == $settings['tp_portfolio_link_type']) {
$this->add_render_attribute('tp-button-arg', 'href', get_permalink($settings['tp_portfolio_page_link']));
$this->add_render_attribute('tp-button-arg', 'target', '_self');
$this->add_render_attribute('tp-button-arg', 'rel', 'nofollow');
} else {
if ( ! empty( $settings['tp_portfolio_link']['url'] ) ) {
$this->add_link_attributes( 'tp-button-arg', $settings['tp_portfolio_link'] );
}
}
?>
<?php if(!empty($tp_image )) : ?>
<div class="tp-work-2__thumb ele-section">
<a class="popup-image" href="<?php echo esc_url($tp_image ); ?>"><img class="w-100" src="<?php echo esc_url($tp_image ); ?>" alt="<?php echo esc_attr($tp_image_alt); ?>"></a>
<div class="tp-work-2__thumb-text">
<?php echo $settings['tp_portfolio_link_switcher'] ? "<a ".$this->get_render_attribute_string( 'tp-button-arg' ).">" : NULL; ?>
<span class="tp-el-icon tp-el-title">
<?php if($settings['tp_box_icon_type'] == 'icon') : ?>
<?php if (!empty($settings['tp_box_icon']) || !empty($settings['tp_box_selected_icon']['value'])) : ?>
<?php tp_render_icon($settings, 'tp_box_icon', 'tp_box_selected_icon'); ?>
<?php endif; ?>
<?php elseif( $settings['tp_box_icon_type'] == 'image' ) : ?>
<?php if (!empty($settings['tp_box_icon_image']['url'])): ?>
<img src="<?php echo $settings['tp_box_icon_image']['url']; ?>"
alt="<?php echo get_post_meta(attachment_url_to_postid($settings['tp_box_icon_image']['url']), '_wp_attachment_image_alt', true); ?>">
<?php endif; ?>
<?php else : ?>
<?php if (!empty($settings['tp_box_icon_svg'])): ?>
<?php echo $settings['tp_box_icon_svg']; ?>
<?php endif; ?>
<?php endif; ?>
<?php echo $settings['tp_portfolio_box_title'] ? tp_kses($settings['tp_portfolio_box_title']) : NULL; ?>
</span>
<?php echo $settings['tp_portfolio_link_switcher'] ? "</a>" : NULL; ?>
<?php if(!empty($settings['tp_portfolio_box_sub_title'])) : ?>
<div class="tp-work-2__thumb-text-2">
<span class="tp-el-subtitle"><?php echo tp_kses($settings['tp_portfolio_box_sub_title']); ?></span>
</div>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<?php endif;
}
}
$widgets_manager->register( new TP_Portfolio() );