File: /home/tvypkwena2lu/public_html/wp-content/plugins/widgets/ele-theme-book.php
<?php
/**
* Elementor About Us Widget.
*
* Elementor widget that inserts an embbedable content into the page, from any given URL.
*
* @since 1.0.0
*/
class Elementor_Book_Widget extends \Elementor\Widget_Base {
public function get_name() {
return 'book_on_home';
}
public function get_title() {
return __( 'Theme | Display Book', 'plugin-name' );
}
public function get_icon() {
return 'eicon-post-content';
}
public function get_categories() {
return [ 'theme-specific-category' ];
}
protected function _register_controls() {
$this->start_controls_section(
'content_section',
[
'label' => __( 'Content', 'plugin-name' ),
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'product_query',
[
'label' => __('Select Book', 'livemesh-el-addons'),
'type' => \Elementor\Controls_Manager::SELECT2,
'options' => lae_get_all_books_options(),
'multiple' => true,
'label_block' => true
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
$target = $settings['website_link']['is_external'] ? ' target="_blank"' : '';
$nofollow = $settings['website_link']['nofollow'] ? ' rel="nofollow"' : '';
$this->add_inline_editing_attributes( 'description','advanced' );
$readmore=(!empty($settings['website_link_label'])) ? ('<a title="'.$settings['title_'].'" class="btn btn-primary btn-lg" href="'.$settings['website_link']['url']. '"' . $target . $nofollow . '>'.$settings['website_link_label'].'</a>') : ('<a title="'.$settings['title_'].'" class="btn btn-primary btn-lg" href="'.$settings['website_link']['url']. '"' . $target . $nofollow . '>Read More</a>');
//var_dump($settings['image']);
if($settings['image']['id']){
$image=wp_get_attachment_image_src( $settings['image']['id'], 'full' );
$image=$image[0];
} else {
$image=$settings['image']['url'];
}
if (!empty($settings['product_query'])) {
$product=$settings['product_query'];
foreach ($product as $tq) {
list($tax, $term) = explode(':', $tq);
if (empty($tax) || empty($term))
continue;
$query_args[] = $term;
}
$args = array(
'post__in' => $query_args,
'post_type' => array( 'page' ),
'posts_per_page'=>-1,
);
//$query = new WC_Product_Query($args);
$query = new \WP_Query($args);
if ( $query->have_posts() ) {
$bs_c1=0;
while ( $query->have_posts() ) {
//echo $bs_c1%2;
if($bs_c1%2==0) {
$alt_cl='bs_book_section';
}
else {
$alt_cl='bs_book_section bs_book_section_alt';
}
$query->the_post();
//the_title();
?>
<section class="<?php echo $alt_cl; ?>">
<?php include(locate_template('template_part/template_pagebooks_sub.php')); ?>
<?php //get_template_part( 'template_part/template_pagebooks_sub', '' ); ?>
</section>
<?php
//the_title();
// do something
$bs_c1++;
}
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();
}
}
}