File: /var/www/html/site/newsite/wp-content/themes/ooze/inc/widgets/double-column-2-widget.php
<?php
if (!defined('ABSPATH')) {
exit;
}
class Ooze_Double_Column_2_Post extends Ooze_Widget_Base
{
/**
* Sets up a new widget instance.
*
* @since 1.0.0
*/
public function __construct()
{
$this->widget_cssclass = 'widget_ooze_double_column_2_posts';
$this->widget_description = __("Displays Double colum with multiple category widget", 'ooze');
$this->widget_id = 'ooze_double_column_2_posts';
$this->widget_name = __('Ooze: Double Category Style - 2', 'ooze');
$this->settings = array(
'title' => array(
'type' => 'text',
'label' => __('Title Column - 1', 'ooze'),
),
'select_category' => array(
'type' => 'dropdown-taxonomies',
'label' => __('Select Category', 'ooze'),
'desc' => __('Leave empty if you don\'t want the posts to be category specific', 'ooze'),
'args' => array(
'taxonomy' => 'category',
'class' => 'widefat',
'hierarchical' => true,
'show_count' => 1,
'show_option_all' => __('— Select —', 'ooze'),
),
),
'show_categroy' => array(
'type' => 'checkbox',
'label' => __('Show Category', 'ooze'),
'std' => true,
),
'show_author' => array(
'type' => 'checkbox',
'label' => __('Show Author', 'ooze'),
'std' => true,
),
'show_date' => array(
'type' => 'checkbox',
'label' => __('Show Date', 'ooze'),
'std' => true,
),
'date_format' => array(
'type' => 'select',
'label' => __('Date Format', 'ooze'),
'options' => array(
'format_1' => __('Format 1', 'ooze'),
'format_2' => __('Format 2', 'ooze'),
),
'std' => 'format_1',
),
'title_2' => array(
'type' => 'text',
'label' => __('Title Column - 2', 'ooze'),
),
'select_category_1' => array(
'type' => 'dropdown-taxonomies',
'label' => __('Select Category', 'ooze'),
'desc' => __('Leave empty if you don\'t want the posts to be category specific', 'ooze'),
'args' => array(
'taxonomy' => 'category',
'class' => 'widefat',
'hierarchical' => true,
'show_count' => 1,
'show_option_all' => __('— Select —', 'ooze'),
),
),
'show_categroy_1' => array(
'type' => 'checkbox',
'label' => __('Show Category', 'ooze'),
'std' => true,
),
'show_author_1' => array(
'type' => 'checkbox',
'label' => __('Show Author', 'ooze'),
'std' => true,
),
'show_date_1' => array(
'type' => 'checkbox',
'label' => __('Show Date', 'ooze'),
'std' => true,
),
'date_format_1' => array(
'type' => 'select',
'label' => __('Date Format', 'ooze'),
'options' => array(
'format_1' => __('Format 1', 'ooze'),
'format_2' => __('Format 2', 'ooze'),
),
'std' => 'format_1',
),
);
parent::__construct();
}
/**
* Output widget.
*
* @param array $args
* @param array $instance
* @see WP_Widget
*
*/
public function widget($args, $instance)
{
ob_start();
$double_column_single_arg = array(
'posts_per_page' => 3,
'post_status' => 'publish',
'no_found_rows' => 1,
'ignore_sticky_posts' => 1,
);
if (!empty($instance['select_category']) && -1 != $instance['select_category'] && 0 != $instance['select_category']) {
$double_column_single_arg['tax_query'][] = array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => $instance['select_category'],
);
}
$double_column_single_arg_2 = array(
'posts_per_page' => 3,
'post_status' => 'publish',
'no_found_rows' => 1,
'ignore_sticky_posts' => 1,
);
if (!empty($instance['select_category_1']) && -1 != $instance['select_category_1'] && 0 != $instance['select_category_1']) {
$double_column_single_arg_2['tax_query'][] = array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => $instance['select_category_1'],
);
} ?>
<div class="theme-article-group theme-block">
<div class="wrapper">
<div class="column-row">
<div class="column column-8">
<?php if (!empty($instance['title'])) { ?>
<div class="theme-section-header mb-24">
<h2 class="section-header-title m-0">
<?php echo esc_html($instance['title']); ?> </h2>
</h2>
</div>
<?php } ?>
<div class="theme-section-body">
<div class="column-row">
<?php
$count = 1;
$ooze_double_column_single_query = new WP_Query($double_column_single_arg);
if ($ooze_double_column_single_query->have_posts()):
while ($ooze_double_column_single_query->have_posts()):
$ooze_double_column_single_query->the_post();
$featured_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'medium');
$featured_image = isset($featured_image[0]) ? $featured_image[0] : '';?>
<?php if ($count = 1) { ?>
<div class="column column-8">
<article class="theme-news-article mb-16 line-clamp line-clamp-3">
<?php if ($featured_image) { ?>
<div class="data-bg image-size-xmedium mb-8"
data-background="<?php echo esc_url($featured_image); ?>">
</div>
<?php } ?>
<div class="entry-meta entry-meta-top mb-8">
<?php if ($instance['show_categroy']) { ?>
<div class="entry-meta entry-meta-top mb-8">
<?php ooze_post_category(); ?>
</div>
<?php } ?>
<?php if ($instance['show_author']) { ?>
<div class="entry-meta entry-meta-top mb-8">
<?php ooze_posted_by(); ?>
</div>
<?php } ?>
<?php
if ($instance['show_date']) {
?>
<div class="ooze-meta post-date">
<span class="meta-icon">
<span class="screen-reader-text">
<?php _e('Post Date', 'ooze'); ?>
</span>
<?php ooze_theme_svg('calendar'); ?>
</span>
<span class="meta-text">
<?php
$date_format = $instance['date_format'];
if ('format_1' == $date_format) {
echo esc_html(human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ' . __('ago', 'ooze'));
} else {
echo esc_html(get_the_date());
}
?>
</span>
</div>
<?php
}
?>
</div>
<h2 class="entry-title font-size-medium mb-8">
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</h2>
<div class="theme-article-excerpt line-clamp line-clamp-3">
<p> <?php the_excerpt(); ?></p>
</div>
</article>
</div>
<div class="column column-4">
<?php $count++; } else {?>
<article class="theme-news-article mb-16 line-clamp line-clamp-3">
<?php if ($featured_image) { ?>
<div class="data-bg image-size-xsmall mb-8"
data-background="<?php echo esc_url($featured_image); ?>">
</div>
<?php } ?>
<div class="entry-meta entry-meta-top mb-8">
<?php if ($instance['show_categroy']) { ?>
<div class="entry-meta entry-meta-top mb-8">
<?php ooze_post_category(); ?>
</div>
<?php } ?>
<?php if ($instance['show_author']) { ?>
<div class="entry-meta entry-meta-top mb-8">
<?php ooze_posted_by(); ?>
</div>
<?php } ?>
<?php
if ($instance['show_date']) {
?>
<div class="ooze-meta post-date">
<span class="meta-icon">
<span class="screen-reader-text">
<?php _e('Post Date', 'ooze'); ?>
</span>
<?php ooze_theme_svg('calendar'); ?>
</span>
<span class="meta-text">
<?php
$date_format = $instance['date_format'];
if ('format_1' == $date_format) {
echo esc_html(human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ' . __('ago', 'ooze'));
} else {
echo esc_html(get_the_date());
}
?>
</span>
</div>
<?php
}
?>
</div>
<h2 class="entry-title font-size-global line-clamp line-clamp-2 m-0">
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</h2>
</article>
<?php if ($ooze_double_column_single_query->current_post +1 == $ooze_double_column_single_query->post_count) { ?>
</div>
<?php } ?>
<?php } ?>
<?php
endwhile;
endif;
wp_reset_postdata();
?>
</div>
</div>
</div>
<div class="column column-4">
<?php if (!empty($instance['title_2'])) { ?>
<div class="theme-section-header mb-24">
<h2 class="section-header-title m-0">
<?php echo esc_html($instance['title']); ?> </h2>
</h2>
</div>
<?php } ?>
<div class="theme-section-body">
<?php
$count = 1;
$ooze_double_column_single_query_2 = new WP_Query($double_column_single_arg_2);
if ($ooze_double_column_single_query_2->have_posts()):
while ($ooze_double_column_single_query_2->have_posts()):
$ooze_double_column_single_query_2->the_post();
$featured_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'medium');
$featured_image = isset($featured_image[0]) ? $featured_image[0] : '';?>
<?php if ($count = 1) { ?>
<article class="theme-news-article article-content-overlay mb-16">
<?php if ($featured_image) { ?>
<div class="data-bg image-size-small data-bg-overlay"
data-background="<?php echo esc_url($featured_image); ?>">
</div>
<?php } ?>
<div class="theme-article-content">
<div class="entry-meta entry-meta-top">
<?php if ($instance['show_categroy_1']) { ?>
<div class="entry-meta entry-meta-top mb-8">
<?php ooze_post_category(); ?>
</div>
<?php } ?>
<?php if ($instance['show_author_1']) { ?>
<div class="entry-meta entry-meta-top mb-8">
<?php ooze_posted_by(); ?>
</div>
<?php } ?>
<?php
if ($instance['show_date_1']) {
?>
<div class="ooze-meta post-date">
<span class="meta-icon">
<span class="screen-reader-text">
<?php _e('Post Date', 'ooze'); ?>
</span>
<?php ooze_theme_svg('calendar'); ?>
</span>
<span class="meta-text">
<?php
$date_format = $instance['date_format_1'];
if ('format_1' == $date_format) {
echo esc_html(human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ' . __('ago', 'ooze'));
} else {
echo esc_html(get_the_date());
}
?>
</span>
</div>
<?php
}
?>
</div>
<h2 class="entry-title font-size-small line-clamp line-clamp-2 m-0">
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</h2>
</div>
</article>
<?php $count++; } else {?>
<article class="theme-news-article theme-article-split article-split-big theme-article-flex">
<?php if ($featured_image) { ?>
<div class="data-bg image-size-thumbnail"
data-background="<?php echo esc_url($featured_image); ?>">
</div>
<?php } ?>
<div class="theme-article-content">
<div class="entry-meta entry-meta-top mb-8">
<?php if ($instance['show_categroy_1']) { ?>
<div class="entry-meta entry-meta-top mb-8">
<?php ooze_post_category(); ?>
</div>
<?php } ?>
<?php if ($instance['show_author_1']) { ?>
<div class="entry-meta entry-meta-top mb-8">
<?php ooze_posted_by(); ?>
</div>
<?php } ?>
<?php
if ($instance['show_date_1']) {
?>
<div class="ooze-meta post-date">
<span class="meta-icon">
<span class="screen-reader-text">
<?php _e('Post Date', 'ooze'); ?>
</span>
<?php ooze_theme_svg('calendar'); ?>
</span>
<span class="meta-text">
<?php
$date_format = $instance['date_format_1'];
if ('format_1' == $date_format) {
echo esc_html(human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ' . __('ago', 'ooze'));
} else {
echo esc_html(get_the_date());
}
?>
</span>
</div>
<?php
}
?>
</div>
<h2 class="entry-title font-size-global line-clamp line-clamp-2 m-0">
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</h2>
</div>
</article>
<?php } ?>
<?php
endwhile;
endif;
wp_reset_postdata();
?>
</div>
</div>
</div>
</div>
</div>
<?php
echo ob_get_clean();
}
}