| Server IP : 104.26.4.103 / 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_Background;
use \Elementor\Group_Control_Image_Size;
use \Elementor\Group_Control_Typography;
use \Elementor\Group_Control_Box_Shadow;
use \Elementor\Utils;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Tp Core
*
* Elementor widget for hello world.
*
* @since 1.0.0
*/
class TP_Blog_Post 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 'blogpost';
}
/**
* Retrieve the widget title.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget title.
*/
public function get_title() {
return __( 'Blog Post', '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'),
'layout-2' => esc_html__('Layout 2', 'tpcore'),
],
'default' => 'layout-1',
]
);
$this->end_controls_section();
// Blog Query
$this->tp_query_controls('blog', 'Blog','post');
// section column
$this->tp_columns('col', ['layout-1', 'layout-2']);
// layout Panel
$this->start_controls_section(
'add_features_sec',
[
'label' => esc_html__('Additional Features', 'tpcore'),
]
);
$this->add_control(
'tp_post_pagination',
[
'label' => esc_html__( 'Pagination On/Off', 'tpcore' ),
'type' => \Elementor\Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Show', 'tpcore' ),
'label_off' => esc_html__( 'Hide', 'tpcore' ),
'return_value' => 'yes',
'default' => '0',
]
);
$this->end_controls_section();
}
// style_tab_content
protected function style_tab_content(){
$this->tp_section_style_controls('blog_section', 'Section Style', '.tp-el-section');
// rep
$this->tp_basic_style_controls('rep_date', 'Blog List Date', '.tp-el-date', 'layout-1');
$this->tp_basic_style_controls('rep_author', 'Blog List Author', '.tp-el-author', 'layout-2');
$this->start_controls_section(
'blog_img_sec',
[
'label' => esc_html__( 'Blog List Image', 'tpcore' ),
'tab' => \Elementor\Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'blogImg_width',
[
'label' => esc_html__( 'Width', 'textdomain' ),
'type' => \Elementor\Controls_Manager::SLIDER,
'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
'selectors' => [
'{{WRAPPER}} .tp-blog-img img' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'blogImg_height',
[
'label' => esc_html__( 'Height', 'textdomain' ),
'type' => \Elementor\Controls_Manager::SLIDER,
'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
'selectors' => [
'{{WRAPPER}} .tp-blog-img img' => 'height: {{SIZE}}{{UNIT}};',
],
]
);
$this->end_controls_section();
$this->tp_basic_style_controls('rep_meta', 'Blog List Meta', '.tp-el-meta', ['layout-1', 'layout-2']);
$this->tp_text_link_controls_style('rep_title', 'Blog List Title', '.tp-el-rep-title', ['layout-1', 'layout-2']);
$this->tp_basic_style_controls('rep_content', 'Blog List Content', '.tp-el-content', ['layout-1', 'layout-2']);
$this->tp_text_link_controls_style('rep_btn', 'Blog List Button', '.tp-el-rep-btn', ['layout-1', 'layout-2']);
}
/**
* 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();
/**
* Setup the post arguments.
*/
$query_args = TP_Helper::get_query_args('post', 'category', $this->get_settings());
// The Query
$query = new \WP_Query($query_args);
$filter_list = $settings['category'];
?>
<?php if ( $settings['tp_design_style'] == 'layout-2' ) : ?>
<section class="tp-el-section">
<div class="container">
<div class="row">
<?php if ($query->have_posts()) :
$i = 0.1;
while ($query->have_posts()) :
$query->the_post();
global $post;
$categories = get_the_category($post->ID);
$author_id = get_the_author_meta('ID');
$author_avatar_url = get_avatar_url($author_id);
$i+=0.2;
?>
<div class="col-xl-<?php echo esc_attr($settings['tp_col_for_desktop']); ?> col-lg-<?php echo esc_attr($settings['tp_col_for_laptop']); ?> col-md-<?php echo esc_attr($settings['tp_col_for_tablet']); ?> col-<?php echo esc_attr($settings['tp_col_for_mobile']); ?> mb-50 wow tpfadeUp" data-wow-duration=".9s" data-wow-delay="<?php echo esc_attr($i); ?>s">
<div class="tp-blog-4__item">
<?php if(has_post_thumbnail()) : ?>
<div class="tp-blog-4__thumb p-relative tp-blog-img">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
<div class="tp-blog-4__thumb-text">
<span class="tp-el-author"><?php echo esc_html__('By:', 'tpcore'); ?> <?php echo ucwords(get_the_author()); ?></span>
</div>
</div>
<?php endif; ?>
<div class="tp-blog-4__content">
<h4 class="tp-blog-4__title tp-el-rep-title">
<a href="<?php the_permalink(); ?>"><?php echo wp_trim_words(get_the_title(), $settings['tp_blog_title_word'], ''); ?></a>
</h4>
<?php if (!empty($settings['tp_post_content'])):
$tp_post_content_limit = (!empty($settings['tp_post_content_limit'])) ? $settings['tp_post_content_limit'] : '';
?>
<p class="tp-el-rep-des tp-el-content"><?php print wp_trim_words(get_the_excerpt(get_the_ID()), $tp_post_content_limit, ''); ?></p>
<?php endif; ?>
</div>
<div class="tp-blog-4__meta ">
<span class="tp-el-meta"><?php the_time( 'd M Y' ); ?></span>
<span class="tp-el-meta"><?php comments_number();?></span>
</div>
<?php if(!empty($settings['tp_post_button'])) : ?>
<div class="tp-blog__link">
<a class="tp-el-rep-btn" href="<?php the_permalink(); ?>"><?php echo tp_kses($settings['tp_post_button']); ?><i
class="far fa-long-arrow-alt-right"></i></a>
</div>
<?php endif; ?>
</div>
</div>
<?php endwhile; wp_reset_query(); endif; ?>
<?php if($settings['tp_post_pagination'] == 'yes' && '-1' != $settings['posts_per_page']) :?>
<div class="basic-pagination mt-30 text-center">
<?php
$big = 999999999;
if (get_query_var('paged')) {
$paged = get_query_var('paged');
} else if (get_query_var('page')) {
$paged = get_query_var('page');
} else {
$paged = 1;
}
echo paginate_links( array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'current' => $paged,
'total' => $query->max_num_pages,
'type' =>'list',
'prev_text' =>'<i class="fa-regular fa-angles-left"></i>',
'next_text' =>'<i class="fa-regular fa-angles-right"></i>',
'show_all' => false,
'end_size' => 1,
'mid_size' => 4,
) );
?>
</div>
<?php endif; ?>
</div>
</div>
</section>
<?php else : ?>
<section class="tp-el-section">
<div class="container">
<div class="row">
<?php if ($query->have_posts()) :
$i = 0.1;
while ($query->have_posts()) :
$query->the_post();
global $post;
$categories = get_the_category($post->ID);
$author_id = get_the_author_meta('ID');
$author_avatar_url = get_avatar_url($author_id);
$i+=0.2;
?>
<div class="col-xl-<?php echo esc_attr($settings['tp_col_for_desktop']); ?> col-lg-<?php echo esc_attr($settings['tp_col_for_laptop']); ?> col-md-<?php echo esc_attr($settings['tp_col_for_tablet']); ?> col-<?php echo esc_attr($settings['tp_col_for_mobile']); ?> mb-30 wow tpfadeUp"
data-wow-duration=".9s" data-wow-delay="<?php echo esc_attr($i); ?>s">
<div class="tp-blog__item">
<?php if(has_post_thumbnail()) : ?>
<div class="tp-blog__thumb tp-blog-img">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
<div class="tp-blog__thumb-text tp-el-date">
<span><?php the_time( 'd' ); ?> <br>
<b><?php the_time( 'M' ); ?></b></span>
</div>
</div>
<?php endif; ?>
<div class="tp-blog__content">
<div class="tp-blog__meta">
<span class="tp-el-meta"><?php echo esc_html('Posted by ', 'tpcore'); echo ucwords(get_the_author()); ?>
-<b><?php the_time( 'M j, Y' ); ?></b></span>
</div>
<h5 class="tp-blog__title tp-el-rep-title"><a
href="<?php the_permalink(); ?>"><?php echo wp_trim_words(get_the_title(), $settings['tp_blog_title_word'], ''); ?></a>
</h5>
<?php if (!empty($settings['tp_post_content'])):
$tp_post_content_limit = (!empty($settings['tp_post_content_limit'])) ? $settings['tp_post_content_limit'] : '';
?>
<p class="tp-el-content"><?php print wp_trim_words(get_the_excerpt(get_the_ID()), $tp_post_content_limit, ''); ?></p>
<?php endif; ?>
<?php if(!empty($settings['tp_post_button'])) : ?>
<div class="tp-blog__link">
<a class="tp-el-rep-btn" href="<?php the_permalink(); ?>"><?php echo tp_kses($settings['tp_post_button']); ?><i
class="far fa-long-arrow-alt-right"></i></a>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php endwhile; wp_reset_query(); endif; ?>
<?php if($settings['tp_post_pagination'] == 'yes' && '-1' != $settings['posts_per_page']) :?>
<div class="basic-pagination mt-30 text-center">
<?php
$big = 999999999;
if (get_query_var('paged')) {
$paged = get_query_var('paged');
} else if (get_query_var('page')) {
$paged = get_query_var('page');
} else {
$paged = 1;
}
echo paginate_links( array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'current' => $paged,
'total' => $query->max_num_pages,
'type' =>'list',
'prev_text' =>'<i class="fa-regular fa-angles-left"></i>',
'next_text' =>'<i class="fa-regular fa-angles-right"></i>',
'show_all' => false,
'end_size' => 1,
'mid_size' => 4,
) );
?>
</div>
<?php endif; ?>
</div>
</div>
</section>
<?php endif;
}
}
$widgets_manager->register( new TP_Blog_Post() );