/**
  * Populate the attribute $data with all informations of current slider
  *
  * @return void
  * @since 1.0
  * @author Antonino Scarfì <*****@*****.**>
  */
 protected function _populate()
 {
     if (is_null($this->config)) {
         global $wpdb;
         $this->config = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE post_name = %s AND post_type = %s", $this->name, YIT_Slider()->sliders_post_type));
     }
     //wpml fix
     $translated_id = yit_wpml_get_translated_id($this->config->ID, YIT_Slider()->sliders_post_type);
     if ($translated_id != $this->config->ID) {
         global $wpdb;
         $this->config = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE id = %s", $translated_id));
         $this->name = $this->config->post_name;
     }
     // extra metadata
     $post_id = $this->config->ID;
     $this->post_type = get_post_meta($post_id, '_post_type', true);
     $this->config->layout = get_post_meta($post_id, '_type', true);
     $this->config->rewrite = get_post_meta($post_id, '_rewrite', true);
     $this->config->label_singular = get_post_meta($post_id, '_label_singular', true);
     $this->config->label_plural = get_post_meta($post_id, '_label_plural', true);
     $this->config->taxonomy = get_post_meta($post_id, '_taxonomy', true);
     $this->config->taxonomy_rewrite = get_post_meta($post_id, '_taxonomy_rewrite', true);
 }
Example #2
0
 /**
  * Shortcode Callback
  *
  * Callback for contact forms shortcode; load the correct template whit variables inserted and return the html markup
  *
  * @param $atts      array() Attributes array for shortcode
  * @param $content   string Shortcode content
  * @param $shortcode string Shortcode Tag
  *
  * @return string
  * @since  1.0.0
  * @author Francesco Licandro <*****@*****.**>
  */
 public function shortcode_callback($atts, $content = null, $shortcode)
 {
     //$shortcode_contact = $this->contactform_shortcode();
     //foreach( $shortcode_contact as $short ){}
     global $wpdb;
     $all_atts = $atts;
     $all_atts['content'] = $content;
     $all_atts['button_style'] = isset($all_atts['button_style']) ? $all_atts['button_style'] : 'btn btn-flat';
     // get post id of contact form
     $this->current_form_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_name = %s AND post_type = %s", $all_atts['name'], 'contact-form'));
     //wpml control
     $this->current_form_id = yit_wpml_get_translated_id($this->current_form_id, 'contact-form');
     $fields = $this->get('_items');
     if (!is_array($fields) or empty($fields)) {
         return null;
     }
     ob_start();
     yit_plugin_get_template(untrailingslashit($this->plugin_path), 'contact-form/contactform-template.php', array('fields' => $fields, 'post_id' => $this->current_form_id, 'button_style' => $all_atts['button_style'], 'title_position' => $this->get('_title_position')));
     $shortcode_html = ob_get_clean();
     return apply_filters('yit_shortcode_' . $shortcode, $shortcode_html, $shortcode);
 }
    function widget($args, $instance)
    {
        extract($args);
        wp_enqueue_script('owl-carousel');
        $title = apply_filters('widget_title', apply_filters('yit_recent_reviews_widget_title', empty($instance['title']) ? __('Recent reviews', 'yit') : $instance['title']));
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        $id = isset($instance['product']) && ($instance['product'] != '' || $instance['product'] != 'all') ? (int) $instance['product'] : 0;
        $attribute = array('number' => $instance['number'], 'type' => 'comment', 'status' => 'approve', 'orderby' => 'date', 'order' => 'DESC');
        if ($id != 0) {
            $id = yit_wpml_get_translated_id($id, 'product');
            $attribute['post_id'] = $id;
        } else {
            $attribute['post_type'] = 'product';
        }
        $reviews = get_comments($attribute);
        ?>
        <div class="reviews_container_widget">

            <ul class="slides-reviews-widget" data-slidespeed="<?php 
        echo $instance['slidespeed'];
        ?>
" data-autoplay="<?php 
        echo $instance['autoplay'];
        ?>
">
                <?php 
        foreach ($reviews as $review) {
            ?>
                    <li class="clearfix">

                        <?php 
            if ($instance['show_avatar'] == 'yes') {
                ?>
                            <div class="avatar-thumb">
                                <?php 
                echo get_avatar($review->comment_author_email, $size = '49');
                ?>
                            </div>
                        <?php 
            }
            ?>

                        <div class="clearfix meta">
                            <div itemprop="author"><?php 
            echo $review->comment_author;
            ?>
</div>
                            <div class="product-review-link">
                                <a href="<?php 
            echo get_permalink($review->ID);
            ?>
"><?php 
            _e('on ', 'yit');
            echo $review->post_title;
            ?>
</a>
                            </div>
                            <?php 
            if ($instance['show_rating'] == 'yes') {
                $rating = esc_attr(get_comment_meta($review->comment_ID, 'rating', true));
                ?>
                                <div class="reviews-rating">
                                    <span class="star-empty"><span class="star" style="width: <?php 
                echo $rating * 20;
                ?>
%;"></span></span>
                                </div>
                            <?php 
            }
            ?>
                        </div>

                        <div class="clear"></div>

                        <div class="review-content <?php 
            if ($instance['show_avatar'] == 'yes') {
                ?>
arrow<?php 
            }
            ?>
">
                            <p itemprop="description" class="description"><?php 
            yit_excerpt_text(strip_tags($review->comment_content), $instance['excerpt_length'], '...');
            ?>
</p>
                        </div>

                        <div class="clear"></div>
                    </li>
                <?php 
        }
        ?>
            </ul>

        </div>

        <div class="clear"></div>
        <?php 
        echo $after_widget;
    }