| Server IP : 119.59.104.26 / Your IP : 216.73.217.55 Web Server : Apache/2 System : Linux ns69.hostinglotus.net 4.18.0-553.141.2.el8_10.x86_64 #1 SMP Wed Jul 8 10:28:18 EDT 2026 x86_64 User : com12370 ( 1517) PHP Version : 7.2.34 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/com12370/public_html/wp-content/themes/titan/admin/widgets/plugins/ |
Upload File : |
<?php
/**
* Created by ninhle - wiloke tema.
* Date: 7/14/15
* Time: 3:47 PM
*/
class piPostsListing extends WP_Widget
{
public $aDef = array('title'=>'', 'number_of_posts'=>4, 'display'=>'latest_posts');
public function __construct()
{
parent::__construct('pi_postslisting', PI_THEMENAME . 'Posts Listing', array('classname'=>'postslisting'));
}
public function form($aInstance)
{
$aInstance = wp_parse_args($aInstance, $this->aDef);
piWidgets::pi_text_field( 'Title', $this->get_field_id('title'), $this->get_field_name('title'), $aInstance['title']);
piWidgets::pi_text_field( 'Number of posts', $this->get_field_id('number_of_posts'), $this->get_field_name('number_of_posts'), $aInstance['number_of_posts']);
piWidgets::pi_select_field( 'Display', $this->get_field_id('display'), $this->get_field_name('display'), array('latest_posts'=>'Latest posts', 'popular_posts'=>'Popular Posts'), $aInstance['display']);
}
public function update($aNewinstance, $aOldinstance)
{
$aInstance = $aOldinstance;
foreach ( $aNewinstance as $key => $val )
{
if ( $key == 'number_of_posts' )
{
$aInstance[$key] = (int)$val;
}else{
$aInstance[$key] = strip_tags($val);
}
}
return $aInstance;
}
public function widget($atts, $aInstance)
{
$aInstance = wp_parse_args($aInstance, $this->aDef);
$args = array('post_type'=>'post', 'post_status'=>'publish', 'posts_per_page'=>$aInstance['number_of_posts'], 'ignore_sticky_posts'=>1);
if ( $aInstance['display'] == 'popular_posts' )
{
$args['meta_key'] = 'pi_post_views_count';
$args['orderby'] = 'meta_value_num';
$args['order'] = 'DESC';
}
$query = new WP_Query($args);
print $atts['before_widget'];
if ( !empty($aInstance['title']) )
{
print $atts['before_title'] . esc_html($aInstance['title']) . $atts['after_title'];
}
echo '<div class="widget-list">';
if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $query->the_post();
$link = get_permalink($query->post->ID);
?>
<div class="item">
<div class="item-image">
<div class="image-cover">
<?php if ( has_post_thumbnail($query->post->ID) ) : ?>
<a href="<?php echo esc_url($link); ?>">
<?php echo get_the_post_thumbnail($query->post->ID, 'pi-postlisting'); ?>
</a>
<?php endif; ?>
</div>
</div>
<div class="item-content">
<h3 class="item-title" data-number-line="2">
<a href="<?php echo esc_url($link); ?>"><?php echo get_the_title($query->post->ID); ?></a>
</h3>
<span class="item-meta"><?php echo pi_get_the_date($query->post->ID); ?></span>
</div>
</div>
<?php
endwhile;
else :
echo '<p>'.__('There are no posts yet', 'titan').'</p>';
endif;wp_reset_postdata();
echo '</div>';
print $atts['after_widget'];
}
}