| Server IP : 119.59.104.26 / Your IP : 216.73.217.169 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
class piTabsposts extends WP_Widget
{
public $aDef = array('pi_popular'=>'Popular', 'pi_recent_posts'=>'Recent Posts', 'pi_recent_comments'=>'Recent Comments', 'number_of_posts'=>5, 'order_of_tabs'=>'pi_popular,pi_recent_posts,pi_recent_comments');
public function __construct()
{
parent::__construct('pi_tabs_posts', PI_THEMENAME . 'Tabs Posts', array('class'=>'pi_tabs_posts'));
}
public function form($aInstance)
{
$aInstance = wp_parse_args($aInstance, $this->aDef);
?>
<ul class="pi_widget_sortable">
<?php
if ( strpos($this->id, '__i__') )
{
echo '<p><code>'.__('Click Save button to be able to change the order of tabs', 'titan').'</code></p>';
}
$aOrderOfTabs = explode(",", $this->aDef['order_of_tabs']);
foreach ( $aOrderOfTabs as $tab) :
?>
<li data-tab="<?php echo esc_attr($tab); ?>">
<?php
echo sprintf( (__('%s', 'titan')), esc_html($aInstance[$tab]) );
piWidgets::pi_text_field('Title', $this->get_field_id($tab), $this->get_field_name($tab), $aInstance[$tab]);
?>
</li>
<?php
endforeach;
?>
</ul>
<?php
echo '<div class="pi-order-of-tabs hidden">';
piWidgets::pi_text_field('Order', $this->get_field_id('pi_order_of_tabs'), $this->get_field_name('order_of_tabs'), $aInstance['order_of_tabs']);
echo '</div>';
piWidgets::pi_text_field('Number of items to show: ', $this->get_field_id('number_of_posts'), $this->get_field_name('number_of_posts'), $aInstance['number_of_posts']);
?>
<script>
jQuery(document).ready(function($){
$(".pi_widget_sortable").each(function(){
var $self = $(this);
$self.piWidgetsSortable({
stop: function(event, ui){
var _getOrder = [];
$(event.target).children().each(function(){
_getOrder.push($(this).data("tab"));
})
console.log(_getOrder);
$self.next().find('input').val(_getOrder).trigger("change");
}
});
})
})
</script>
<?php
}
public function update($newInstance, $oldInstance)
{
$aInstance = $oldInstance;
foreach ( $newInstance as $key => $val )
{
$aInstance[$key] = strip_tags($val);
}
return $aInstance;
}
public function widget($atts, $aInstance)
{
print $atts['before_widget'];
$aOrder = explode(',', $aInstance['order_of_tabs']);
$aIds = array();
?>
<div class="tab-wrapper">
<ul class="tab-control nav nav-tabs">
<?php
foreach ( $aOrder as $key => $tab )
{
$aIds[$tab] = uniqid("tab_");
$key = $key == 0 ? 'active' : '';
?>
<li class="tab-item <?php echo esc_attr($key); ?>">
<a data-toggle="tab" href="#<?php echo esc_attr($aIds[$tab]); ?>"><span><?php printf( (__('%s', 'titan')), wp_unslash($aInstance[$tab]) ); ?></span></a>
</li>
<?php
}
?>
</ul>
<div class="tab-content">
<?php
foreach ( $aOrder as $key => $tab )
{
$key = $key == 0 ? 'active' : '';
?>
<div id="<?php echo esc_attr($aIds[$tab]) ?>" class="tab-pane <?php echo esc_attr($key); ?>">
<?php
$args = array('post_type'=>'post', 'post_status'=>'publish', 'posts_per_page'=>$aInstance['number_of_posts']);
switch ($tab)
{
case 'pi_popular':
$args['meta_key'] = 'pi_post_views_count';
$args['orderby'] = 'meta_value_num';
$args['order'] = 'DESC';
piWidgets::pi_list_of_posts($args);
break;
case 'pi_recent_comments':
$args = array(
'number' => (int)$aInstance['number_of_posts'],
'status' => 'approve',
'post_type' => 'post',
'post_status' => 'publish',
);
piWidgets::pi_list_of_commented($args);
break;
case 'pi_recent_posts':
piWidgets::pi_list_of_posts($args);
break;
}
?>
</div>
<?php
}
?>
</div>
</div>
<?php
print $atts['after_widget'];
}
}