| Server IP : 69.72.244.102 / Your IP : 216.73.216.164 Web Server : LiteSpeed System : Linux s3434.fra1.stableserver.net 4.18.0-513.24.1.lve.2.el8.x86_64 #1 SMP Fri May 24 12:42:50 UTC 2024 x86_64 User : konzalta ( 1271) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/thread-self/cwd/wp-content/plugins/portx-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'),
'layout-3' => esc_html__('Layout 3', '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-3']);
}
// style_tab_content
protected function style_tab_content(){
$this->tp_section_style_controls('blog_section', 'Section Style', '.tp-el-section');
}
/**
* 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' ) : ?>
<div class="blog-area-2 blog-padding pt-15 pb-80">
<div class="container">
<div class="row">
<?php if ($query->have_posts()) :
$i = 0.0;
while ($query->have_posts()) :
$query->the_post();
global $post;
$categories = get_the_category($post->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']); ?>">
<div class="tpblog-2 wow fadeInUp mb-40" data-wow-duration=".9s" data-wow-delay="<?php echo esc_attr($i); ?>s" >
<div class="tpblog-2__content">
<div class="tpblog-2__meta mb-15">
<?php if(!empty($categories[0]->name)) : ?>
<span class="catagori "><?php echo esc_html($categories[0]->name); ?></span>
<?php endif; ?>
<span class="date"><?php the_time( 'M j, Y' ); ?></span>
</div>
<h3 class="tpblog-2__title"><a href="<?php the_permalink(); ?>"><?php echo wp_trim_words(get_the_title(), $settings['tp_blog_title_word'], ''); ?></a></h3>
<?php if (!empty($settings['tp_post_content'])):
$tp_post_content_limit = (!empty($settings['tp_post_content_limit'])) ? $settings['tp_post_content_limit'] : '';
?>
<p><?php print wp_trim_words(get_the_excerpt(get_the_ID()), $tp_post_content_limit, ''); ?></p>
<?php endif; ?>
</div>
<div class="tpblog-2__thumb p-relative fix">
<?php if(!empty(has_post_thumbnail())) : ?>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
<?php endif; ?>
<div class="tpblog-2__plus-icon">
<a href="<?php the_permalink(); ?>"><i class="fa-sharp fa-solid fa-plus"></i></a>
</div>
</div>
<?php if(!empty($settings['tp_post_button'])) : ?>
<div class="tpblog-2__link">
<div class="tpblog-2__button blog-border d-flex align-items-center fix">
<span class="f-left tpblog-2__more-btn">
<a href="<?php the_permalink(); ?>" tabindex="0">
<span class="tpblog-2__blog-more"><?php echo tp_kses($settings['tp_post_button']); ?></span>
<i class="fa-regular fa-arrow-right"></i>
</a>
</span>
</div>
</div>
<?php endif; ?>
</div>
</div>
<?php endwhile; wp_reset_query(); endif; ?>
</div>
</div>
</div>
<?php elseif ( $settings['tp_design_style'] == 'layout-3' ) : ?>
<section class="blog-area-3">
<div class="container">
<div class="row">
<?php if ($query->have_posts()) :
$i = 0.0;
while ($query->have_posts()) :
$query->the_post();
global $post;
$categories = get_the_category($post->ID);
$i+=0.3;
?>
<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']); ?>">
<div class="tp-blog-3 pb-30 wow fadeInUp" data-wow-duration="1.5s" data-wow-delay="<?php echo esc_attr($i); ?>s">
<?php if(!empty(has_post_thumbnail())) : ?>
<div class="tp-blog-3__thumb p-relative fix">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
<div class="tp-blog-3__icon">
<a href="<?php the_permalink(); ?>"><i class="fa-sharp fa-regular fa-arrow-right"></i></a>
</div>
</div>
<?php endif; ?>
<div class="tp-blog-3__content p-relative">
<div class="tp-blog-3__meta mb-10 mt-25">
<span class="date pr-25"><?php the_time( 'F d, Y' ); ?></span>
</div>
<h3 class="tp-blog-3__title mb-25"><a href="<?php the_permalink(); ?>"><?php echo wp_trim_words(get_the_title(), $settings['tp_blog_title_word'], ''); ?></a></h3>
<?php if (!empty($settings['tp_post_content'])):
$tp_post_content_limit = (!empty($settings['tp_post_content_limit'])) ? $settings['tp_post_content_limit'] : '';
?>
<p><?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-feed-link d-flex align-items-center">
<a class="blog-btn" href="<?php the_permalink(); ?>"><?php echo tp_kses($settings['tp_post_button']); ?></a>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php endwhile; wp_reset_query(); endif; ?>
</div>
</div>
</section>
<?php else : ?>
<div class="blog-area pt-10 pb-10">
<div class="container">
<div class="row">
<?php if ($query->have_posts()) :
$i = 0.0;
while ($query->have_posts()) :
$query->the_post();
global $post;
$categories = get_the_category($post->ID);
$i+=0.3;
?>
<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']); ?>">
<div class="tpblog pb-30 wow fadeInUp " data-wow-duration=".9s" data-wow-delay="<?php echo esc_attr($i); ?>s">
<?php if(!empty(has_post_thumbnail())) : ?>
<div class="tpblog__thumb fix">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
</div>
<?php endif; ?>
<div class="tpblog__content fix p-relative">
<div class="tpblog__meta mb-10 mt-15">
<span class="date pr-25"><?php the_time( 'F d, Y' ); ?> </span>
<span class="user"><?php echo esc_html__('by ', 'tpcore'); ?><?php the_author(); ?></span>
</div>
<h3 class="tp-blog-title mb-25"><a href="<?php the_permalink(); ?>"><?php echo wp_trim_words(get_the_title(), $settings['tp_blog_title_word'], ''); ?></a></h3>
<?php if (!empty($settings['tp_post_content'])):
$tp_post_content_limit = (!empty($settings['tp_post_content_limit'])) ? $settings['tp_post_content_limit'] : '';
?>
<p><?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-feed-link d-flex align-items-center">
<a class="blog-btn" href="<?php the_permalink(); ?>"><?php echo tp_kses($settings['tp_post_button']); ?></a>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php endwhile; wp_reset_query(); endif; ?>
</div>
</div>
</div>
<?php endif;
}
}
$widgets_manager->register( new TP_Blog_Post() );