Example #1
0
/**
 * 
 *
 * @package Kopa
 * @subpackage Core
 * @author thethangtran <*****@*****.**>
 * @since 1.0.0
 *      
 */
function kopa_shortcode_tabs($atts, $content = null)
{
    extract(shortcode_atts(array('style' => 'horizontal', 'width' => 200), $atts));
    $style = !empty($atts['style']) && in_array($atts['style'], array('horizontal', 'vertical')) ? $atts['style'] : 'horizontal';
    $width = '';
    if ('vertical' == $style) {
        $width = !empty($atts['width']) ? (int) $atts['width'] : 200;
        $width = sprintf('style="width:%spx;"', $width > 0 ? $width : 200);
    }
    $items = KopaUtil::get_shortcode($content, true, array('tab'));
    $navs = array();
    $panels = array();
    if ($items) {
        $active = 'active';
        foreach ($items as $item) {
            $title = $item['atts']['title'];
            $item_id = 'tab-' . wp_generate_password(4, false, false);
            $navs[] = sprintf('<li><a href="#%s">%s</a></li>', $item_id, do_shortcode($title));
            $panels[] = sprintf('<div id="%s">%s</div>', $item_id, do_shortcode($item['content']));
            $active = '';
        }
    }
    $output = sprintf('<div class="kp-tabs tab-%s">', $style);
    $output .= sprintf('<ul %s>', $width);
    $output .= implode('', $navs);
    $output .= '</ul>';
    $output .= implode('', $panels);
    $output .= '</div>';
    return apply_filters('kopa_shortcode_tabs', $output);
}
Example #2
0
    public function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        $instance['orderby'] = 'popular';
        $instance['posts_per_page'] = 5;
        $query = $this->build_query($instance);
        $posts = new WP_Query($query);
        if ($posts->have_posts()) {
            ?>
            <div class="widget-content">
                <ul class="list-unstyled">
                    <?php 
            $loop_index = 0;
            while ($posts->have_posts()) {
                $posts->the_post();
                $post_id = get_the_ID();
                $percent = 100 - $loop_index * 10;
                ?>
                        <li>
                            <div class="item clearfix" style="width: <?php 
                echo $percent;
                ?>
%;">
                                <h4 class="post-title" ><a href="<?php 
                echo get_permalink();
                ?>
"><?php 
                echo get_the_title();
                ?>
</a></h4>
                                <span><?php 
                echo KopaUtil::get_views($post_id);
                ?>
</span>
                            </div>
                        </li>
                        <?php 
                $loop_index++;
            }
            ?>
                </ul>
            </div>
            <?php 
        } else {
            _e('Posts not found. Pleae config this widget again!', kopa_get_domain());
        }
        wp_reset_postdata();
        echo $after_widget;
    }
Example #3
0
 /**
  * 
  *
  * @package Kopa
  * @subpackage Core
  * @author thethangtran <*****@*****.**>
  * @since 1.0.0
  *      
  */
 public static function get_current_setting()
 {
     $settings = get_option(KOPA_OPT_PREFIX . 'layout_settings');
     $setting = array('layout' => '', 'sidebars' => array());
     if (!empty($settings) && is_main_query()) {
         if (is_archive()) {
             $setting = $settings['archive'];
             if (is_tag() || is_category()) {
                 $setting = $settings['taxonomy'];
                 $term_id = get_queried_object_id();
                 if ('true' == get_option(KOPA_OPT_PREFIX . 'is_use_custom_layout_' . $term_id, 'false')) {
                     $setting = get_option(KOPA_OPT_PREFIX . 'layout_' . $term_id, $setting);
                 }
             } else {
                 if (is_author()) {
                     $setting = $settings['author'];
                 }
             }
         } else {
             if (is_search()) {
                 $setting = $settings['search'];
             } else {
                 if (is_singular()) {
                     global $post;
                     if (is_page()) {
                         $setting = $settings['page'];
                         if (is_front_page()) {
                             $setting = $settings['front-page'];
                         } else {
                             if ('true' == KopaUtil::get_post_meta($post->ID, KOPA_OPT_PREFIX . 'is_use_custom_layout', TRUE, 'String', 'false')) {
                                 $setting = KopaUtil::get_post_meta($post->ID, KOPA_OPT_PREFIX . 'layout', true, NULL, $setting);
                             }
                         }
                     } else {
                         if (is_single()) {
                             $setting = $settings['post'];
                             if ('true' == KopaUtil::get_post_meta($post->ID, KOPA_OPT_PREFIX . 'is_use_custom_layout', TRUE, 'String', 'false')) {
                                 $setting = KopaUtil::get_post_meta($post->ID, KOPA_OPT_PREFIX . 'layout', true, NULL, $setting);
                             }
                         }
                     }
                 } else {
                     if (is_404()) {
                         $setting = $settings['_404'];
                     } else {
                         $setting = $settings['home'];
                     }
                 }
             }
         }
     }
     return apply_filters('kopa_layout_get_current_setting', $setting);
 }
Example #4
0
/**
 * 
 *
 * @package Kopa
 * @subpackage Core
 * @author thethangtran <*****@*****.**>
 * @since 1.0.0
 *      
 */
function kopa_shortcode_row($atts, $content = null)
{
    extract(shortcode_atts(array(), $atts));
    $items = KopaUtil::get_shortcode($content, true, array('col'));
    $panels = array();
    if ($items) {
        foreach ($items as $item) {
            $panels[] = sprintf('<div class="col-sm-%s">%s</div>', $item['atts']['col'], do_shortcode($item['content']));
        }
    }
    $output = '<div class="row clearfix">';
    $output .= implode('', $panels);
    $output .= '</div>';
    return apply_filters('kopa_shortcode_row', $output);
}
Example #5
0
/**
 * 
 *
 * @package Kopa
 * @subpackage Core
 * @author thethangtran <*****@*****.**>
 * @since 1.0.0
 *      
 */
function kopa_shortcode_accordions($atts, $content = null)
{
    extract(shortcode_atts(array(), $atts));
    $items = KopaUtil::get_shortcode($content, true, array('accordion'));
    $panels = array();
    if ($items) {
        foreach ($items as $item) {
            $title = $item['atts']['title'];
            $tmp = sprintf('<h3>%s</h3>', $title);
            $tmp .= sprintf('<div>%s</div>', do_shortcode($item['content']));
            $panels[] = $tmp;
        }
    }
    $output = '<div class="kp-accordion style-2">';
    $output .= implode('', $panels);
    $output .= '</div>';
    return apply_filters('kopa_shortcode_tabs', $output);
}
Example #6
0
 /**
  * 
  *
  * @package Kopa
  * @subpackage Core
  * @author thethangtran <*****@*****.**>
  * @since 1.0.0
  *      
  */
 public static function get_post_image_src($post_id = 0, $size = NULL, $width = NULL, $height = NULL, $crop = true)
 {
     $src = NULL;
     if ($size) {
         $size = self::detect_image_size($size);
     }
     if (isset($post_id) && !empty($post_id) && has_post_thumbnail($post_id)) {
         if ('true' == KopaUtil::get_post_meta($post_id, KOPA_OPT_PREFIX . 'is_use_custom_thumbnail', TRUE, 'String', false) && 'true' == KopaOptions::get_option('is_use_custom_thumbnail', 'false') && !empty($size)) {
             $tmp = KopaUtil::get_post_meta($post_id, KOPA_OPT_PREFIX . "thumbnail_{$size}", true);
             if ($tmp) {
                 $src = do_shortcode($tmp);
             }
         }
         if (empty($src)) {
             $feature_image = KopaUtil::get_image_src($post_id, 'full');
             $src = self::get_image_src($feature_image, $size, $width, $height, $crop);
         }
     }
     return apply_filters('kopa_image_get_post_image_src', $src);
 }
    public function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        $query = $this->build_query($instance);
        $posts = new WP_Query($query);
        if ($posts->have_posts()) {
            global $post;
            $metadata = array();
            $metadata['date'] = 'true' != $instance['is_hide_created_date'] ? true : false;
            $metadata['comments'] = 'true' != $instance['is_hide_comments'] ? true : false;
            $metadata['views'] = 'true' != $instance['is_hide_views'] ? true : false;
            $metadata['likes'] = 'true' != $instance['is_hide_likes'] ? true : false;
            ?>
            <div class="widget-content">
                <div class="owl-carousel">
                    <?php 
            while ($posts->have_posts()) {
                $posts->the_post();
                $post_id = get_the_ID();
                $post_title = get_the_title();
                $post_url = get_permalink();
                if (has_post_thumbnail()) {
                    $image_croped = KopaImage::get_post_image_src($post_id, 'size_05');
                    ?>
                            <div <?php 
                    post_class('item');
                    ?>
>

                                <a href="<?php 
                    echo $post_url;
                    ?>
"><img src="<?php 
                    echo $image_croped;
                    ?>
" alt="<?php 
                    echo $post_title;
                    ?>
"></a>

                                <div class="kp-caption">
                                    <?php 
                    if ('true' != $instance['is_hide_title']) {
                        ?>
                                        <h3 class="post-title"><a href="<?php 
                        echo $post_url;
                        ?>
"><?php 
                        echo $post_title;
                        ?>
</a></h3>
                                    <?php 
                    }
                    ?>
                                </div>

                                <?php 
                    if ($metadata['date'] || $metadata['comments'] || $metadata['views'] || $metadata['likes']) {
                        ?>
                                    <footer>
                                        <ul class="kp-meta-post list-inline">    
                                            <?php 
                        $is_metadata_first = true;
                        foreach ($metadata as $key => $val) {
                            if ($val) {
                                $class = $is_metadata_first ? 'metadata-first' : '';
                                $is_metadata_first = false;
                                switch ($key) {
                                    case 'date':
                                        printf('<li class="%s">%s<span>%s</span></li>', $class, KopaIcon::getIconDatetime(), get_the_date());
                                        break;
                                    case 'comments':
                                        ?>
                                                            <li class="<?php 
                                        echo $class;
                                        ?>
"><?php 
                                        echo KopaIcon::getIconComment();
                                        ?>
<span><?php 
                                        comments_popup_link(__('No Comment', kopa_get_domain()), __('1 Comment', kopa_get_domain()), __('% Comments', kopa_get_domain()), '', __('0 Comment', kopa_get_domain()));
                                        ?>
</span></li>                                            
                                                            <?php 
                                        break;
                                    case 'views':
                                        printf('<li class="%s">%s<span>%s</span></li>', $class, KopaIcon::getIconView(), KopaUtil::get_views($post_id, true));
                                        break;
                                    case 'likes':
                                        printf('<li class="%s">%s</li>', $class, KopaUtil::kopa_get_like_button($post_id, true));
                                        break;
                                }
                            }
                        }
                        ?>
                                   
                                        </ul> 
                                    </footer>
                                <?php 
                    }
                    ?>

                            </div>
                            <?php 
                }
            }
            ?>
                </div>
            </div>
            <?php 
        } else {
            _e('Posts not found. Pleae config this widget again!', kopa_get_domain());
        }
        wp_reset_postdata();
        echo $after_widget;
    }
Example #8
0
/**
 * @package Kopa
 * @subpackage Core
 * @author thethangtran <*****@*****.**>
 * @since 1.0.0         
 */
function kopa_update_notices()
{
    $xml = KopaUtil::get_theme_info();
    if ($xml) {
        $theme_data = wp_get_theme();
        if (version_compare($theme_data['Version'], $xml->version) == -1) {
            $out = '<div class="updated kopa_update_info">';
            $out .= sprintf('<p>Latest version of  <b>%1$s</b> theme is <b>%2$s</b> - <a href="%3$s">Update Now</a> - <a href="%4$s" target="_blank">View Change Log</a></p>', $xml->name, $xml->version, $xml->download, $xml->changelog);
            $out .= '</div>';
            echo $out;
        }
    }
}
    public function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        $query = $this->build_query($instance);
        $posts = new WP_Query($query);
        if ($posts->have_posts()) {
            global $post;
            ?>
            <div class="widget-content clearfix">
                <?php 
            $metadata = array();
            $metadata['date'] = 'true' != $instance['is_hide_created_date'] ? true : false;
            $metadata['comments'] = 'true' != $instance['is_hide_comments'] ? true : false;
            $metadata['views'] = 'true' != $instance['is_hide_views'] ? true : false;
            $metadata['likes'] = 'true' != $instance['is_hide_likes'] ? true : false;
            while ($posts->have_posts()) {
                $posts->the_post();
                $post_id = get_the_ID();
                $post_title = get_the_title();
                $post_url = get_permalink();
                ?>
                    <div <?php 
                post_class('item');
                ?>
>

                        <?php 
                if (has_category()) {
                    ?>
                            <h5 class="post-cat">
                                <?php 
                    the_category(', ');
                    ?>
                            </h5>
                        <?php 
                }
                ?>

                        <?php 
                if ('true' != $instance['is_hide_title']) {
                    ?>
                                        
                            <h4 class="post-title"><a href="<?php 
                    echo $post_url;
                    ?>
"><?php 
                    echo $post_title;
                    ?>
</a></h4>
                        <?php 
                }
                ?>

                        <?php 
                if ('true' != $instance['is_hide_excerpt']) {
                    if ((int) $instance['excerpt_character_limit'] > 0) {
                        $excerpt = KopaUtil::substr($post->post_content, (int) $instance['excerpt_character_limit']);
                        echo $excerpt ? sprintf('<p>%s</p>', $excerpt) : '';
                    } else {
                        the_excerpt();
                    }
                }
                ?>


                        <?php 
                if ($metadata['date'] || $metadata['comments'] || $metadata['views'] || $metadata['likes']) {
                    ?>
                            <footer>
                                <ul class="kp-meta-post list-inline">    
                                    <?php 
                    $is_metadata_first = true;
                    foreach ($metadata as $key => $val) {
                        if ($val) {
                            $class = $is_metadata_first ? 'metadata-first' : '';
                            $is_metadata_first = false;
                            switch ($key) {
                                case 'date':
                                    printf('<li class="%s">%s<span>%s</span></li>', $class, KopaIcon::getIconDatetime(), get_the_date());
                                    break;
                                case 'comments':
                                    ?>
                                                    <li class="<?php 
                                    echo $class;
                                    ?>
"><?php 
                                    echo KopaIcon::getIconComment();
                                    ?>
<span><?php 
                                    comments_popup_link(__('No Comment', kopa_get_domain()), __('1 Comment', kopa_get_domain()), __('% Comments', kopa_get_domain()), '', __('0 Comment', kopa_get_domain()));
                                    ?>
</span></li>                                            
                                                    <?php 
                                    break;
                                case 'views':
                                    printf('<li class="%s">%s<span>%s</span></li>', $class, KopaIcon::getIconView(), KopaUtil::get_views($post_id, true));
                                    break;
                                case 'likes':
                                    printf('<li class="%s">%s</li>', $class, KopaUtil::kopa_get_like_button($post_id, true));
                                    break;
                            }
                        }
                    }
                    ?>
                                   
                                </ul> 
                            </footer>
                        <?php 
                }
                ?>

                    </div>
                    <?php 
            }
            ?>
                
            </div>
            <?php 
        } else {
            _e('Posts not found. Pleae config this widget again!', kopa_get_domain());
        }
        wp_reset_postdata();
        echo $after_widget;
    }
Example #10
0
    public function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        $instance['posts_per_page'] = 4;
        $query = $this->build_query($instance);
        $posts = new WP_Query($query);
        if ($posts->have_posts()) {
            ?>
    
            <div class="widget-content container clearfix">
                <div class="owl-slider-col-left pull-left">
                    <?php 
            $is_first = true;
            $loop_index = 0;
            while ($posts->have_posts()) {
                $posts->the_post();
                if (has_post_thumbnail()) {
                    $classes = array('owl-slider-navigation-post-title');
                    if ($is_first) {
                        $classes[] = 'active';
                        $classes[] = 'first';
                        $is_first = false;
                    }
                    ?>
                            <p class="<?php 
                    echo implode(' ', $classes);
                    ?>
" data-index="<?php 
                    echo $loop_index;
                    ?>
">
                                <?php 
                    echo get_the_title();
                    ?>
                            </p>
                            <?php 
                    $loop_index++;
                }
            }
            ?>
                
                </div>

                <div class="owl-slider-col-center pull-left">
                    <div class="owl-carousel" data-transition="<?php 
            echo $instance['transition_type'];
            ?>
">
                        <?php 
            $is_first = true;
            global $post;
            while ($posts->have_posts()) {
                $posts->the_post();
                $post_id = get_the_ID();
                $post_title = get_the_title();
                $post_url = get_permalink();
                $post_format = get_post_format();
                if (has_post_thumbnail()) {
                    $classes = array('owl-slider-single-slide');
                    if ($is_first) {
                        $classes[] = 'active';
                        $classes[] = 'first';
                        $classes[] = 'synced';
                        $is_first = false;
                    }
                    $image_croped = KopaImage::get_post_image_src($post_id, 'size_11');
                    ?>
                                <div class="<?php 
                    echo implode(' ', $classes);
                    ?>
">
                                    <?php 
                    if ('video' == $post_format) {
                        $video = KopaUtil::get_video($post->post_content, array('youtube', 'vimeo'));
                        if ($video) {
                            $url = '';
                            if ('youtube' == $video['type']) {
                                $url = 'http://www.youtube.com/watch?v=' . $video['id'];
                            } else {
                                if ('vimeo' == $video['type']) {
                                    $url = 'https://vimeo.com/' . $video['id'];
                                }
                            }
                            printf('<a class="kss-icon kss-icon-play" href="%s"><span class="fa fa-play"></span></a>', $url);
                        }
                    }
                    ?>
         

                                    <img src="<?php 
                    echo $image_croped;
                    ?>
" alt="<?php 
                    echo $post_title;
                    ?>
">
                                    <a href="<?php 
                    echo $post_url;
                    ?>
" title="<?php 
                    echo $post_title;
                    ?>
"><?php 
                    echo $post_title;
                    ?>
</a>                                                                       
                                </div>
                                <?php 
                }
            }
            ?>
                    </div>
                </div>

                <div class="owl-slider-col-right pull-left">
                    <div class="owl-carousel">
                        <?php 
            $is_first = true;
            while ($posts->have_posts()) {
                $posts->the_post();
                $post_id = get_the_ID();
                $post_title = get_the_title();
                $post_url = get_permalink();
                $post_format = get_post_format();
                if (has_post_thumbnail()) {
                    $classes = array('owl-slider-single-slide-detail');
                    if ($is_first) {
                        $classes[] = 'first';
                        $classes[] = 'synced';
                        $is_first = false;
                    }
                    ?>
                                <div class="<?php 
                    echo implode(' ', $classes);
                    ?>
">

                                    <span class="kopa-icon-post-format"><?php 
                    echo KopaIcon::getIconPostFormat($post_format, 'span');
                    ?>
</span>

                                    <?php 
                    if ('true' != $instance['is_hide_created_date']) {
                        ?>
                                        <span class="kopa-date"><?php 
                        echo get_the_date('M, j');
                        ?>
<br/><?php 
                        echo get_the_date('Y');
                        ?>
</span>                                                    
                                    <?php 
                    }
                    ?>


                                    <?php 
                    if ('true' != $instance['is_hide_views'] || 'true' != $instance['is_hide_comments'] || 'true' != $instance['is_hide_views']) {
                        ?>
                                        <ul class="kopa-metadata">                                               
                                            <?php 
                        if ('true' != $instance['is_hide_comments']) {
                            ?>
                                                <li class="metadata-first"><i class="fa fa-comment"></i><span><?php 
                            echo KopaUtil::get_comments($post_id, true);
                            ?>
</span></li>                                            
                                            <?php 
                        }
                        ?>

                                            <?php 
                        if ('true' != $instance['is_hide_views']) {
                            ?>
                                                <li><?php 
                            echo KopaIcon::getIconView();
                            ?>
<span><?php 
                            echo KopaUtil::get_views($post_id, false);
                            ?>
</span></li>
                                            <?php 
                        }
                        ?>

                                            <?php 
                        if ('true' != $instance['is_hide_likes']) {
                            ?>
                                                <li class="metadata-last"><?php 
                            echo KopaIcon::getIconLike();
                            ?>
<span><?php 
                            echo KopaUtil::get_likes($post_id, false);
                            ?>
</span></li>
                                                    <?php 
                        }
                        ?>
                                        </ul>      
                                    <?php 
                    }
                    ?>

                                </div>
                                <?php 
                }
            }
            ?>
                    </div>
                </div>
            </div>
            <?php 
        }
        wp_reset_postdata();
        echo $after_widget;
    }
Example #11
0
/**
 * @package Kopa
 * @subpackage Core
 * @author thethangtran <*****@*****.**>
 * @since 1.0.0
 */
function kopa_dynamic_sidebar_params($params)
{
    if (!in_array($params[0]['widget_name'], array('Kopa Slider Text', 'Kopa Slider Steel'))) {
        return $params;
    }
    global $wp_registered_widgets;
    $widget_id = $params[0]['widget_id'];
    $widget_obj = $wp_registered_widgets[$widget_id];
    $widget_opt = get_option($widget_obj['callback'][0]->option_name);
    $widget_num = $widget_obj['params'][0]['number'];
    if (isset($widget_opt[$widget_num]['bonus-background']) && 'true' == $widget_opt[$widget_num]['bonus-background']) {
        $widget_styles = array();
        if (!empty($widget_opt[$widget_num]['background-color'])) {
            $color = $widget_opt[$widget_num]['background-color'];
            $opacity = (int) $widget_opt[$widget_num]['background-opacity'];
            $widget_styles[] = sprintf('background-color:%s', KopaUtil::convert_hex2rgba($color, $opacity / 100));
        }
        if (!empty($widget_opt[$widget_num]['background-image'])) {
            $background_image = $widget_opt[$widget_num]['background-image'];
            $background_type = $widget_opt[$widget_num]['background-type'];
            $parallax_height = (int) $widget_opt[$widget_num]['parallax-height'];
            if (!empty($background_image)) {
                $parallax_before = '';
                $parallax_after = '';
                $parallax_args = array();
                $widget_styles[] = sprintf('background-image:url(%s)', do_shortcode($background_image));
                if ($parallax_height > 0) {
                    $widget_obj['callback'][0]->widget_options['classname'] .= ' parallax';
                    $widget_styles[] = sprintf('height:%1$spx', $parallax_height);
                    $parallax_before = sprintf('<div class="widget-inner" style="height:%1$spx">', $parallax_height);
                    $parallax_after = '</div>';
                    $parallax_args[] = 'data-speed="10"';
                    $parallax_args[] = 'data-type="background"';
                }
                switch ($background_type) {
                    case 'repeat':
                        $widget_styles[] = 'background-repeat: repeat';
                        break;
                    case 'no-repeat':
                        $widget_styles[] = 'background-repeat: no-repeat';
                        break;
                    default:
                        $widget_styles[] = 'background-repeat: no-repeat';
                        $widget_styles[] = 'background-size: cover';
                        $widget_styles[] = '-webkit-background-size: cover';
                        $widget_styles[] = '-moz-background-size: cover';
                        $widget_styles[] = '-o-background-size: cover';
                        break;
                }
                $params[0]['before_widget'] = sprintf('<div id="%1$s" class="widget %2$s clearfix" style="%3$s;" %4$s>', $widget_id, $widget_obj['callback'][0]->widget_options['classname'], implode('; ', $widget_styles), implode(' ', $parallax_args)) . $parallax_before;
                $params[0]['after_widget'] = $parallax_after . '</div>';
            }
        } else {
            $params[0]['before_widget'] = sprintf('<div id="%1$s" class="widget %2$s clearfix" style="%3$s;">', $widget_id, $widget_obj['callback'][0]->widget_options['classname'], implode('; ', $widget_styles));
        }
    }
    return $params;
}
Example #12
0
                        echo $class;
                        ?>
"><?php 
                        echo KopaIcon::getIconComment();
                        ?>
<span><?php 
                        comments_popup_link(__('No Comment', kopa_get_domain()), __('1 Comment', kopa_get_domain()), __('% Comments', kopa_get_domain()), '', __('0 Comment', kopa_get_domain()));
                        ?>
</span></li>                                            
                                                    <?php 
                        break;
                    case 'views':
                        printf('<li class="singular-view-count %s">%s<span>%s</span></li>', $class, KopaIcon::getIconView(), KopaUtil::get_views($post_id, true));
                        break;
                    case 'likes':
                        printf('<li class="%s">%s</li>', $class, KopaUtil::kopa_get_like_button($post_id, true));
                        break;
                    case 'shares':
                        printf('<li class="singular-shares %s"><a class="addthis_button_compact" addthis:url="%s" href="#" rel="nofollow">%s&nbsp;%s</a></li>', $class, $post_url, KopaIcon::getIconShare(), __('Share', kopa_get_domain()));
                        break;
                }
            }
        }
        ?>
                                  
                                </ul>
                            </div>
                        </header>
                        
                            <?php 
        if (has_post_thumbnail()) {
    public function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        $query = $this->build_query($instance);
        $posts = new WP_Query($query);
        if ($posts->have_posts()) {
            $metadata = array();
            $metadata['date'] = 'true' != $instance['is_hide_created_date'] ? true : false;
            $metadata['comments'] = 'true' != $instance['is_hide_comments'] ? true : false;
            global $post;
            ?>
            <div class="widget-content">
                <ul class="list-unstyled">
                    <?php 
            $is_first = true;
            while ($posts->have_posts()) {
                $posts->the_post();
                $post_id = get_the_ID();
                $post_title = get_the_title();
                $post_url = get_permalink();
                if ($is_first) {
                    $is_first = false;
                    ?>
                            <li <?php 
                    post_class('style-1');
                    ?>
>
                                <div class="item clearfix">
                                    <?php 
                    if (has_post_thumbnail()) {
                        $image_croped = KopaImage::get_post_image_src($post_id, 'size_02');
                        ?>
                                        <a href="<?php 
                        echo $post_url;
                        ?>
" class="pull-left">
                                            <img src="<?php 
                        echo $image_croped;
                        ?>
" alt="">                                            
                                        </a>               
                                        <?php 
                    }
                    ?>
                                    

                                    <div class="item-right">
                                        <?php 
                    if ('true' != $instance['is_hide_title']) {
                        ?>
                                        
                                            <h4 class="post-title"><a href="<?php 
                        echo $post_url;
                        ?>
"><?php 
                        echo $post_title;
                        ?>
</a></h4>
                                        <?php 
                    }
                    ?>

                                        <?php 
                    if ($metadata['date'] || $metadata['comments']) {
                        ?>

                                            <ul class="kp-meta-post list-inline">    
                                                <?php 
                        $is_metadata_first = true;
                        foreach ($metadata as $key => $val) {
                            if ($val) {
                                $class = $is_metadata_first ? 'metadata-first' : '';
                                $is_metadata_first = false;
                                switch ($key) {
                                    case 'date':
                                        printf('<li class="%s">%s<span>%s</span></li>', $class, KopaIcon::getIconDatetime(), get_the_date());
                                        break;
                                    case 'comments':
                                        ?>
                                                                <li class="<?php 
                                        echo $class;
                                        ?>
"><?php 
                                        echo KopaIcon::getIconComment();
                                        ?>
<span><?php 
                                        comments_popup_link(__('No Comment', kopa_get_domain()), __('1 Comment', kopa_get_domain()), __('% Comments', kopa_get_domain()), '', __('0 Comment', kopa_get_domain()));
                                        ?>
</span></li>                                            
                                                                <?php 
                                        break;
                                }
                            }
                        }
                        ?>
                                   
                                            </ul> 

                                        <?php 
                    }
                    ?>

                                        <?php 
                    if ('true' != $instance['is_hide_excerpt']) {
                        if ((int) $instance['excerpt_character_limit'] > 0) {
                            $excerpt = KopaUtil::substr($post->post_content, (int) $instance['excerpt_character_limit']);
                            echo $excerpt ? sprintf('<p>%s</p>', $excerpt) : '';
                        } else {
                            the_excerpt();
                        }
                    }
                    ?>
                                        <?php 
                    if ('true' != $instance['is_hide_readmore']) {
                        ?>
                                            
                                            <a class="read-more" href="<?php 
                        echo $post_url;
                        ?>
"><?php 
                        _e('Read more', kopa_get_domain());
                        ?>
</a>
                                        <?php 
                    }
                    ?>

                                    </div>

                                </div>
                            </li>
                            <?php 
                } else {
                    ?>
                            <li>
                                <div class="item clearfix">
                                    <?php 
                    if (has_post_thumbnail()) {
                        $image_croped = KopaImage::get_post_image_src($post_id, 'size_00');
                        ?>
                                        <a href="<?php 
                        echo $post_url;
                        ?>
" class="pull-left">
                                            <img src="<?php 
                        echo $image_croped;
                        ?>
" alt="">                                            
                                        </a>               
                                        <?php 
                    }
                    ?>

                                    <div class="item-right">
                                        <?php 
                    if ('true' != $instance['is_hide_title']) {
                        ?>
                                        
                                            <h4 class="post-title"><a href="<?php 
                        echo $post_url;
                        ?>
"><?php 
                        echo $post_title;
                        ?>
</a></h4>
                                        <?php 
                    }
                    ?>

                                        <?php 
                    if ($metadata['date'] || $metadata['comments']) {
                        ?>

                                            <ul class="kp-meta-post list-inline">    
                                                <?php 
                        $is_metadata_first = true;
                        foreach ($metadata as $key => $val) {
                            if ($val) {
                                $class = $is_metadata_first ? 'metadata-first' : '';
                                $is_metadata_first = false;
                                switch ($key) {
                                    case 'date':
                                        printf('<li class="%s">%s<span>%s</span></li>', $class, KopaIcon::getIconDatetime(), get_the_date());
                                        break;
                                        break;
                                }
                            }
                        }
                        ?>
                                   
                                            </ul> 

                                        <?php 
                    }
                    ?>

                                    </div>
                                </div>
                            </li>
                        <?php 
                }
            }
            ?>
                </ul>
            </div>
            <?php 
        } else {
            _e('Posts not found. Pleae config this widget again!', kopa_get_domain());
        }
        wp_reset_postdata();
        echo $after_widget;
    }
Example #14
0
    } else {
        $tab_classes[] = 'tab_deactive';
    }
    ?>
                    <div class="<?php 
    echo implode(' ', $tab_classes);
    ?>
" id="<?php 
    printf('tab-%s', $slug);
    ?>
">
                        <?php 
    foreach ($tab['groups'] as $groups) {
        ?>
                            <div id="<?php 
        printf('kopa-group-%s', KopaUtil::str_uglify($groups['title']));
        ?>
">                        
                                <p class="kopa-tab-title clearfix"><span class="kopa-tab-title-left pull-left"><?php 
        echo $groups['title'];
        ?>
</span></p>
                                <div class="kopa-tab-body" style="display: <?php 
        echo $sub_tab_display;
        ?>
;">
                                    <?php 
        foreach ($groups['fields'] as $field) {
            $field['value'] = KopaOptions::get_option($field['name'], $field['default']);
            if (empty($field['label']) || !isset($field['label'])) {
                $theme_options_args['control_begin'] = '<div class="col-xs-12">';
Example #15
0
    /**
     * Print custom style from Color Scheme, Typography, Custom CSS
     *
     * @package Kopa
     * @subpackage Core
     * @author thethangtran <*****@*****.**>
     * @since 1.0.0
     *      
     * @return NULL
     */
    function wp_footer()
    {
        $css = array();
        /*
         * --------------------------------------------------
         * COLOR
         * --------------------------------------------------
         */
        $primary_colors = strtolower(KopaOptions::get_option('primary_color', '#d40202'));
        if ('#d40202' != $primary_colors) {
            ?>
            <style type="text/css">
                body,
                a,
                .search-form .search-submit,
                .breadcrumb span:last-child a:hover,                
                .kp-cat .list-post-cat ul.page-numbers li > a i, .kp-cat .list-post-cat ul.page-numbers li > span i,
                .ui-accordion .ui-accordion-header:after,
                ul.page-numbers li > a i, ul.page-numbers li > span i,
                .kp-blog-timeline .kp-isotope .item .kopa-thumb span, .kp-blog-timeline .kp-isotope .item .kopa-thumb a,
                .form-contact .contact-form .form-control {
                    color: #7c7c7c;
                }

                .read-more{
                    border-color: <?php 
            echo $primary_colors;
            ?>
;
                    color: <?php 
            echo $primary_colors;
            ?>
;
                }
                .read-more:hover{
                    background-color: <?php 
            echo $primary_colors;
            ?>
; 
                }               
                .widget-gallery .sync2{
                    background-color: <?php 
            echo $primary_colors;
            ?>
; 
                }               
                .widget-lastest-post .owl-carousel .item .post-title a:hover, 
                .widget-random .item .post-title a:hover, 
                .widget-list-video .item .post-title a:hover, 
                .kp-blog .feature-post .item .post-title a:hover, 
                .last-post-review .item .post-title a:hover,
                h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover,
                a:hover,
                .index-4 h1 a, .index-4 h2 a, .index-4 h3 a, .index-4 h4 a, .index-4 h5 a, .index-4 h6 a,
                .load-more span,                
                #main-content .widget-newsletter .widget-title,
                #sidebar .widget-newsletter .widget-title,
                .widget-popular .post-cat a,
                .widget-popular ul.page-numbers li a:hover, .widget-popular ul.page-numbers li span.current,
                .widget-popular ul.page-numbers li a:hover i, .widget-popular ul.page-numbers li span.current i,
                .widget-hot-news .post-cat a,
                .widget_archive ul li a:hover,
                .widget_categories ul li a:hover,
                .widget_pages ul li a:hover,
                .widget_meta ul li a:hover,
                .widget_recent_comments ul li a:hover,
                .widget_recent_entries ul li a:hover,
                .widget_rss ul li a:hover,
                .widget_nav_menu ul li a:hover,
                .widget-area-4 a:hover,
                .widget-area-4 .widget_text p span,
                .widget-area-4 .widget_text a:hover,
                .widget-twitters .tweetList .timestamp,
                .widget-twitters .tweetList a:hover,
                #page-footer .bottom-menu a:hover,
                .index-3 .widget-area-2 .widget-feature-slider .kp-caption .post-title a:hover,
                .header-2 .main-menu .menu-primary.sf-menu ul li a:hover,
                .bottom-sidebar.bottom-sidebar-2 .widget-area-4 .widget-twitters .tweetList a,
                .bottom-sidebar.bottom-sidebar-2 .widget-area-4 .widget-latest-news .post-title a:hover,
                .bottom-sidebar.bottom-sidebar-2 .widget-area-4 .widget_text p span,
                .bottom-sidebar.bottom-sidebar-2 .widget-area-4 .widget_text a:hover,
                .widget-feature-images .item .kp-caption .post-title a:hover,
                .widget-tool-2 .item .kp-icon .tool-icon:hover,
                .header-3 .main-menu .sf-menu > li > a:hover,
                .header-3 .main-menu .sf-menu .curent-menu-item a,
                .header-3 .main-menu .sf-menu ul li a:hover,
                .site-1 .post-content .kp-author .social-box.style-2 a:hover,
                .sub-page .post-content .page-links a:hover,
                .sub-page .post-content .page-links > span,
                .sub-page .post-content .pager-page a.prev, .sub-page .post-content .pager-page a.next,
                .sub-page.site-2 .post-content .page-links a:hover, .sub-page.site-2 .post-content .page-links > span,
                #comments .comment-list .comment-body .comment-content header h4,
                #comments .comment-list .comment-body .comment-content header .kp-metadata a:hover,
                #comments .pagination > a:hover,
                #comments .pagination .current,
                #respond .comment-form label.error,
                #respond .comment-notes span,
                #respond label span,                
                .site-2 .post-content .pager-page a.prev, .site-2 .post-content .pager-page a.next, .site-2 .post-content .pager-page a.prev:before, .site-2 .post-content .pager-page a.next:after,
                .site-2 #comments .comment-list .comment-body .comment-content header h4,                
                .kp-cat .list-post-cat ul.page-numbers li > a:hover, .kp-cat .list-post-cat ul.page-numbers li > a:hover i, .kp-cat .list-post-cat ul.page-numbers li .current,
                .widget-gallery .sync1 .item .post-title a:hover,
                .ui-accordion.style-2 .ui-accordion-header:hover,
                .ui-accordion.style-2 .ui-accordion-header-active,
                ul.page-numbers li > a:hover, ul.page-numbers li > a:hover i, ul.page-numbers li .current,
                .kp-dropcap.style-3,
                .kp-blog-timeline .filter-isotope .kp-year.show > span,
                .kp-blog-timeline .kp-isotope .load-more span,
                .form-contact .form-group label.error {
                    color: <?php 
            echo $primary_colors;
            ?>
; }


                #page-header .header-bottom,
                .main-menu .header-bottom-inner,                
                #main-content .widget-newsletter input[type="submit"],
                #sidebar .widget-newsletter input[type="submit"],
                .widget-newsletter .like-box a,
                .widget-popular .post-cat:before,
                .widget_tag_cloud .tagcloud a:hover,
                .widget-feature-news-slider .owl-carousel .kp-caption,
                .widget-latest-article > header .widget-title,
                .widget-latest-article .item figure a span,
                .header-2 #page-header .search-form .search-submit,
                .header-2 .main-menu .header-bottom-inner,
                .widget-area-4 .widget-newsletter .newsletter-form input[type="submit"],
                .widget-area-4 .widget-social a:hover,
                .site-1 .post-content .kp-author .social-box.style-2 a:hover,
                .sub-page .post-content .kp-tags a:hover,
                .site-2 #main-content .related-article .kp-caption,
                .site-2 .post-content .kp-tags a:hover,
                .widget-gallery .sync1 .owl-controls .owl-buttons div,
                .ui-accordion .ui-accordion-header:hover:after,
                .ui-accordion .ui-accordion-header-active:after,
                .ui-accordion.style-2 .ui-accordion-header:hover,
                .ui-accordion.style-2 .ui-accordion-header-active,
                .ui-tabs .ui-tabs-nav .ui-state-default[aria-selected=false] a,
                .btn,
                ul.page-numbers.style-2 li > a:hover,
                ul.page-numbers.style-2 li span.current,
                .kp-dropcap,
                .kp-blockquote-2:after,
                .social-box.style-2 a:hover,
                .kp-blog-timeline .filter-isotope .kp-year:hover,
                .kp-blog-timeline .filter-isotope .kp-year ul li a:hover,
                .kp-blog-timeline .filter-isotope .kp-year ul .active a,
                .kp-blog-timeline .filter-isotope .kp-now,
                .kp-blog-timeline .kp-isotope .item .more-i .more-time,
                .kp-blog-timeline .kp-isotope .item .more-i > i,
                .contact-info .item span,
                .form-contact .contact-form input[type="submit"] {
                    background: <?php 
            echo $primary_colors;
            ?>
;
                }                
                .widget_tag_cloud .tagcloud a:hover {
                    border-color: <?php 
            echo $primary_colors;
            ?>
; }
                .header-2 .main-menu .menu-primary.sf-menu ul li a:hover {
                    border-left-color: <?php 
            echo $primary_colors;
            ?>
;}
                .site-1 .post-content .kp-author .social-box.style-2 a:hover {
                    border-color: <?php 
            echo $primary_colors;
            ?>
; }
                .ui-accordion.style-2 .ui-accordion-header:hover {
                    border-color: <?php 
            echo $primary_colors;
            ?>
;}
                .ui-accordion.style-2 .ui-accordion-header-active {
                    border-color: <?php 
            echo $primary_colors;
            ?>
;}
                ul.page-numbers.style-2 li > a:hover {
                    border-color: <?php 
            echo $primary_colors;
            ?>
;}
                ul.page-numbers.style-2 li span.current {
                    border-color: <?php 
            echo $primary_colors;
            ?>
;}
                .social-box.style-2 a:hover {
                    border-color: <?php 
            echo $primary_colors;
            ?>
; }
                .kp-blog-timeline .filter-isotope .kp-year ul li a:hover {
                    border-left-color: <?php 
            echo $primary_colors;
            ?>
; }
                .kp-blog-timeline .filter-isotope .kp-year ul .active a {
                    border-left-color: <?php 
            echo $primary_colors;
            ?>
; }
                .breaking-news > span:before{
                    border-left-color: <?php 
            echo $primary_colors;
            ?>
; }
                .breaking-news > span:after{
                    border-right-color: <?php 
            echo $primary_colors;
            ?>
; }                
                #main-content .widget-title span span span, #sidebar .widget-title span span span{
                    border-bottom-color: <?php 
            echo $primary_colors;
            ?>
; }  
                .widget-hot-news .post-cat a{
                    border-bottom-color: <?php 
            echo $primary_colors;
            ?>
; }  
                #main-content .widget-newsletter .widget-title span span span, #sidebar .widget-newsletter .widget-title span span span{
                    border-bottom-color: <?php 
            echo $primary_colors;
            ?>
; }  
                .widget-most-review .index0 a{
                    background-color:<?php 
            echo KopaUtil::convert_hex2rgba($primary_colors, 0.75);
            ?>
                }
                .kp-blog-timeline .filter-isotope .kp-now:before{
                    border-top-color: <?php 
            echo $primary_colors;
            ?>
; }  
                .kp-blog-timeline .kp-isotope .item .more-i > i:after{
                    border-right-color: <?php 
            echo $primary_colors;
            ?>
; }  
                #comments .comments-title span span span, #comments .comment-reply-title span span span{
                    border-bottom-color: <?php 
            echo $primary_colors;
            ?>
; }  
                .widget.kopa_owl_slider .owl-slider-col-right .owl-slider-single-slide-detail .kopa-icon-post-format{
                    background-color: <?php 
            echo $primary_colors;
            ?>
;
                }
                .widget.kopa_owl_slider .owl-slider-col-right .owl-slider-single-slide-detail .kopa-metadata li i.fa{
                    color: <?php 
            echo $primary_colors;
            ?>
;
                }
                .widget.kopa_owl_slider .owl-slider-col-left .owl-slider-navigation-post-title:hover, .widget.kopa_owl_slider .owl-slider-col-left .owl-slider-navigation-post-title.active{
                    border-left-color: <?php 
            echo $primary_colors;
            ?>
;
                }
                .btn:hover{
                    border-color: <?php 
            echo $primary_colors;
            ?>
;
                }
                blockquote{
                    border-left-color: <?php 
            echo $primary_colors;
            ?>
;
                }
                .widget-popular h5.post-cat{
                    color: <?php 
            echo $primary_colors;
            ?>
;
                }
                .widget-hot-news h5.post-cat{
                    color: <?php 
            echo $primary_colors;
            ?>
;
                }
            </style>
            <?php 
        }
        $header_style = kopa_get_header_style();
        if ('' == $header_style) {
            $header_bg_color = KopaOptions::get_option('header_background_color', '#141414');
            ?>
            <style type="text/css">
                body.header-1 #page-header .header-middle{
                    background-color: <?php 
            echo $header_bg_color;
            ?>
; 
                }                
            </style>
            <?php 
        }
        /*
         * --------------------------------------------------
         * FONT
         * --------------------------------------------------
         */
        $typo_selector = array();
        foreach ($this->typography as $slug => $typo) {
            if ('off' != $typo['family']) {
                switch ($slug) {
                    case 'body_font':
                        $typo_selector[$slug] = 'body';
                        break;
                    case 'widget_title_font':
                        $typo_selector[$slug] = '#sidebar .widget-newsletter h3.widget-title, .widget-area-4 h3.widget-title, #sidebar h3.widget-title, #main-content h3.widget-title, h3.widget-title';
                        break;
                    case 'entry_title_font':
                        $typo_selector[$slug] = '.sub-page .post-content .title-post, h1.title-post.entry-title';
                        break;
                    case 'entry_content_font':
                        $typo_selector[$slug] = '#main-content .entry-content, #main-content .entry-content p';
                        break;
                    case 'nav_top_font':
                        $typo_selector[$slug] = '#menu-second li a';
                        break;
                    case 'nav_bottom_font':
                        $typo_selector[$slug] = '#bottom-menu li a';
                        break;
                    case 'nav_primary_font':
                        $typo_selector[$slug] = '#menu-primary li a';
                        break;
                    case 'h1_font':
                        $typo_selector[$slug] = 'h1';
                        break;
                    case 'h2_font':
                        $typo_selector[$slug] = 'h2';
                        break;
                    case 'h3_font':
                        $typo_selector[$slug] = 'h3';
                        break;
                    case 'h4_font':
                        $typo_selector[$slug] = 'h4';
                        break;
                    case 'h5_font':
                        $typo_selector[$slug] = 'h5';
                        break;
                    case 'h6_font':
                        $typo_selector[$slug] = 'h6';
                        break;
                }
            }
        }
        if (!empty($typo_selector)) {
            foreach ($typo_selector as $slug => $selector) {
                $css[$selector]['font-family'] = "'{$this->typography[$slug]['family']}'";
                $css[$selector]['font-size'] = $this->typography[$slug]['size'] . 'px';
                $css[$selector]['font-weight'] = $this->typography[$slug]['weight'];
                $css[$selector]['line-height'] = $this->typography[$slug]['line-height'] . 'px';
                $css[$selector]['text-transform'] = $this->typography[$slug]['text-transform'];
            }
        }
        /*
         * --------------------------------------------------
         * LOGO MARGIN
         * --------------------------------------------------
         */
        $css['#logo-image']['margin-top'] = sprintf('%spx', KopaOptions::get_option('logo_margin_top', 40));
        $css['#logo-image']['margin-bottom'] = sprintf('%spx', KopaOptions::get_option('logo_margin_bottom', 10));
        $css['#logo-image']['margin-left'] = sprintf('%spx', KopaOptions::get_option('logo_margin_left', 0));
        $css['#logo-image']['margin-right'] = sprintf('%spx', KopaOptions::get_option('logo_margin_right', 0));
        /*
         * --------------------------------------------------
         * PRINT CUSTOMIZE RULES
         * --------------------------------------------------
         */
        $css = apply_filters('kopa_customize', $css);
        if (!empty($css)) {
            $out = '';
            foreach ($css as $element => $rules) {
                $tmp = '';
                foreach ($rules as $rule => $value) {
                    $tmp .= sprintf('%s : %s;', $rule, $value);
                }
                $out .= sprintf('%s{%s}', $element, $tmp);
            }
            printf('<style id="kopa-customize-style" type="text/css">%s</style>', $out);
        }
        /*
         * --------------------------------------------------
         * PRINT CUSTOMIZE CSS (from theme options)
         * --------------------------------------------------
         */
        $custom_css = htmlspecialchars_decode(stripslashes(KopaOptions::get_option('custom_css')));
        if ($custom_css) {
            printf('<style type="text/css">%s</style>', $custom_css);
        }
    }
    public function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        $query = $this->build_query($instance);
        $posts = new WP_Query($query);
        if ($posts->have_posts()) {
            global $post;
            $max = (int) $instance['posts_per_page'];
            $limit_carousel = $max >= 3 ? $posts->post_count - 2 : -1;
            $loop_index = 0;
            $metadata = array();
            $metadata['date'] = 'true' != $instance['is_hide_created_date'] ? true : false;
            $metadata['comments'] = 'true' != $instance['is_hide_comments'] ? true : false;
            $metadata['views'] = 'true' != $instance['is_hide_views'] ? true : false;
            $metadata['likes'] = 'true' != $instance['is_hide_likes'] ? true : false;
            ?>
            <div class="widget-content clearfix">
                <div class="owl-carousel pull-left">
                    <?php 
            while ($posts->have_posts()) {
                $posts->the_post();
                $post_id = get_the_ID();
                $post_title = get_the_title();
                $post_url = get_permalink();
                if (-1 != $limit_carousel && $limit_carousel == $loop_index) {
                    break;
                } else {
                    $loop_index++;
                }
                ?>
     
                        <div <?php 
                post_class('item');
                ?>
>
                            <?php 
                if (has_post_thumbnail()) {
                    $image_croped = KopaImage::get_post_image_src($post_id, 'size_04');
                    ?>
                                <a href="<?php 
                    echo $post_url;
                    ?>
"><img src="<?php 
                    echo $image_croped;
                    ?>
" alt="<?php 
                    echo $post_title;
                    ?>
"/></a>
                                <?php 
                }
                ?>

                            <?php 
                if ('true' != $instance['is_hide_title'] || 'true' != $instance['is_hide_excerpt']) {
                    ?>
                                <div class="kp-caption">
                                    <?php 
                    if ('true' != $instance['is_hide_title']) {
                        ?>
                                        <?php 
                        $h4_class = 'true' != $instance['is_hide_excerpt'] ? '' : 'hide_excerpt';
                        ?>
                                        <h4 class="post-title <?php 
                        echo $h4_class;
                        ?>
"><a href="<?php 
                        echo $post_url;
                        ?>
"><?php 
                        echo $post_title;
                        ?>
</a></h4>
                                    <?php 
                    }
                    ?>

                                    <?php 
                    if ('true' != $instance['is_hide_excerpt']) {
                        if ((int) $instance['excerpt_character_limit'] > 0) {
                            $excerpt = KopaUtil::substr($post->post_content, (int) $instance['excerpt_character_limit']);
                            echo $excerpt ? sprintf('<p>%s</p>', $excerpt) : '';
                        } else {
                            the_excerpt();
                        }
                    }
                    ?>
                                
                                </div>
                            <?php 
                }
                ?>

                            <?php 
                if ($metadata['date'] || $metadata['comments'] || $metadata['views'] || $metadata['likes']) {
                    ?>
                                <footer>
                                    <ul class="kp-meta-post list-inline">    
                                        <?php 
                    $is_metadata_first = true;
                    foreach ($metadata as $key => $val) {
                        if ($val) {
                            $class = $is_metadata_first ? 'metadata-first' : '';
                            $is_metadata_first = false;
                            switch ($key) {
                                case 'date':
                                    printf('<li class="%s">%s<span>%s</span></li>', $class, KopaIcon::getIconDatetime(), get_the_date());
                                    break;
                                case 'comments':
                                    ?>
                                                        <li class="<?php 
                                    echo $class;
                                    ?>
"><?php 
                                    echo KopaIcon::getIconComment();
                                    ?>
<span><?php 
                                    comments_popup_link(__('No Comment', kopa_get_domain()), __('1 Comment', kopa_get_domain()), __('% Comments', kopa_get_domain()), '', __('0 Comment', kopa_get_domain()));
                                    ?>
</span></li>                                            
                                                        <?php 
                                    break;
                                case 'views':
                                    printf('<li class="%s">%s<span>%s</span></li>', $class, KopaIcon::getIconView(), KopaUtil::get_views($post_id, true));
                                    break;
                                case 'likes':
                                    printf('<li class="%s">%s</li>', $class, KopaUtil::kopa_get_like_button($post_id, true));
                                    break;
                            }
                        }
                    }
                    ?>
                                   
                                    </ul> 
                                </footer>
                            <?php 
                }
                ?>

                        </div>
                        <?php 
            }
            wp_reset_postdata();
            ?>
                </div>

                <?php 
            if (-1 != $limit_carousel) {
                ?>
                    <ul class="list-content pull-left list-unstyled">
                        <?php 
                $sub_posts = new WP_Query($query);
                $sub_loop_index = 0;
                while ($sub_posts->have_posts()) {
                    $sub_posts->the_post();
                    $post_id = get_the_ID();
                    $post_title = get_the_title();
                    $post_url = get_permalink();
                    if ($sub_loop_index >= $limit_carousel) {
                        ?>
     
                                <li>
                                    <?php 
                        if (has_post_thumbnail()) {
                            $image_croped = KopaImage::get_post_image_src($post_id, 'size_02');
                            ?>
                                        <a href="<?php 
                            echo $post_url;
                            ?>
"><img src="<?php 
                            echo $image_croped;
                            ?>
" alt="<?php 
                            echo $post_title;
                            ?>
"/></a>
                                        <?php 
                        }
                        ?>

                                    <?php 
                        if ('true' != $instance['is_hide_title']) {
                            ?>
                                        <h4 class="post-title"><a href="<?php 
                            echo $post_url;
                            ?>
"><?php 
                            echo $post_title;
                            ?>
</a></h4>
                                    <?php 
                        }
                        ?>

                                    <?php 
                        if ($metadata['date'] || $metadata['comments'] || $metadata['views'] || $metadata['likes']) {
                            ?>
                                        <footer>
                                            <ul class="kp-meta-post list-inline">    
                                                <?php 
                            $is_metadata_first = true;
                            foreach ($metadata as $key => $val) {
                                if ($val) {
                                    $class = $is_metadata_first ? 'metadata-first' : '';
                                    $is_metadata_first = false;
                                    switch ($key) {
                                        case 'date':
                                            printf('<li class="%s">%s<span>%s</span></li>', $class, KopaIcon::getIconDatetime(), get_the_date());
                                            break;
                                        case 'comments':
                                            ?>
                                                                <li class="<?php 
                                            echo $class;
                                            ?>
"><?php 
                                            echo KopaIcon::getIconComment();
                                            ?>
<span><?php 
                                            comments_popup_link(__('No Comment', kopa_get_domain()), __('1 Comment', kopa_get_domain()), __('% Comments', kopa_get_domain()), '', __('0 Comment', kopa_get_domain()));
                                            ?>
</span></li>                                            
                                                                <?php 
                                            break;
                                    }
                                }
                            }
                            ?>
                                   
                                            </ul> 
                                        </footer>
                                    <?php 
                        }
                        ?>

                                </li>
                                <?php 
                    }
                    $sub_loop_index++;
                }
                wp_reset_postdata();
                ?>
                    </ul>
                <?php 
            }
            ?>
            </div>                      
            <?php 
        } else {
            _e('Posts not found. Pleae config this widget again!', kopa_get_domain());
        }
        echo $after_widget;
    }
Example #17
0
if (post_password_required()) {
    return;
}
if (is_single() && 'true' != KopaOptions::get_option('is_display_post_comments_system', 'true')) {
    return;
}
global $kopaCurrentLayout;
?>
<div id="comments">    
        <?php 
if (have_comments()) {
    global $post;
    ?>
     
            <h3 class="comments-title"><span><span><span><?php 
    echo KopaUtil::get_comments($post->ID);
    ?>
</span></span></span></h3>        

            <ul class="comment-list clearfix">
                <?php 
    wp_list_comments(array('walker' => null, 'style' => 'ul', 'short_ping' => true, 'callback' => 'kopa_list_comments', 'type' => 'all'));
    ?>
            </ul>

            <?php 
    if (get_comment_pages_count() > 1 && get_option('page_comments')) {
        ?>
           
                <div class="pagination kopa-comment-pagination">  
                    <?php 
    public function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $limit = empty($instance['limit']) ? 4 : absint($instance['limit']);
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        $comments = get_comments(array('number' => $limit, 'status' => 'approve', 'post_status' => 'publish'));
        if ($comments) {
            ?>
            <div class="widget-content">
                <ul class="list-unstyled">
                    <?php 
            foreach ((array) $comments as $comment) {
                $date = get_comment_date('U', $comment->comment_ID);
                $post_url = get_permalink($comment->comment_post_ID);
                ?>
                        <li class="clearfix">
                            <?php 
                if ('true' != $instance['is_hide_gravatar'] && '' != $comment->comment_author_email) {
                    ?>
                                <a href="<?php 
                    echo $post_url;
                    ?>
" class="pull-left">
                                    <?php 
                    echo get_avatar($comment->comment_author_email, 80);
                    ?>
                                </a>
                            <?php 
                }
                ?>
                            <div class="item-right">
                                <?php 
                if ('true' != $instance['is_hide_author']) {
                    ?>
                                    <h4><a href="<?php 
                    echo $post_url;
                    ?>
"><?php 
                    echo get_comment_author_link($comment->comment_ID);
                    ?>
</a></h4>
                                <?php 
                }
                ?>

                                <?php 
                $comment_content = get_comment_text($comment->comment_ID);
                if ('true' != $instance['is_hide_comment'] && !empty($comment_content)) {
                    ?>
                                    <?php 
                    $character_limit = absint($instance['comment_character_limit']);
                    if ($character_limit > 0) {
                        $comment_content = KopaUtil::substr($comment_content, $character_limit);
                    }
                    printf('<p>%s</p>', $comment_content);
                    ?>
                                    <?php 
                }
                ?>

                                <?php 
                if ('true' != $instance['is_hide_created_date']) {
                    ?>
                                    <span class="kp-meta-post"><?php 
                    echo KopaUtil::human_time_diff($date);
                    ?>
</span>
                                <?php 
                }
                ?>
                            </div>
                        </li>
                        <?php 
            }
            ?>
                </ul>
            </div>
            <?php 
        }
        echo $after_widget;
    }
    public function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        $query = $this->build_query($instance);
        $posts = new WP_Query($query);
        if ($posts->have_posts()) {
            global $post;
            ?>
            <div class="widget-content">
                <div class="container">
                    <ul class="list-unstyled">
                        <?php 
            while ($posts->have_posts()) {
                $posts->the_post();
                $post_id = get_the_ID();
                $post_title = get_the_title();
                $post_url = get_permalink();
                if (has_post_thumbnail()) {
                    ?>
   
                                <li>                                    
                                    <div <?php 
                    post_class('item');
                    ?>
>
                                        <?php 
                    $image_croped = KopaImage::get_post_image_src($post_id, 'size_01');
                    ?>
                                        <a href="<?php 
                    echo $post_url;
                    ?>
">
                                            <img src="<?php 
                    echo $image_croped;
                    ?>
" alt="">
                                            <div class="mask"></div>
                                            <div class="mask-2"></div>
                                        </a>               

                                        <div class="kp-caption">
                                            <?php 
                    if ('true' != $instance['is_hide_title']) {
                        ?>
                                        
                                                <h4 class="post-title"><a href="<?php 
                        echo $post_url;
                        ?>
"><?php 
                        echo $post_title;
                        ?>
</a></h4>
                                            <?php 
                    }
                    ?>

                                            <?php 
                    if ('true' != $instance['is_hide_created_date']) {
                        ?>
                                                <span class="kp-meta-post date updated"><?php 
                        echo get_the_date();
                        ?>
</span>
                                            <?php 
                    }
                    ?>

                                            <?php 
                    if ('true' != $instance['is_hide_excerpt']) {
                        if ((int) $instance['excerpt_character_limit'] > 0) {
                            $excerpt = KopaUtil::substr($post->post_content, (int) $instance['excerpt_character_limit']);
                            echo $excerpt ? sprintf('<p>%s</p>', $excerpt) : '';
                        } else {
                            the_excerpt();
                        }
                    }
                    ?>

                                        </div>
                                    </div>  
                                </li>
                                <?php 
                }
            }
            ?>
                    </ul>
                </div>
            </div>
            <?php 
        } else {
            _e('Posts not found. Pleae config this widget again!', kopa_get_domain());
        }
        wp_reset_postdata();
        echo $after_widget;
    }
Example #20
0
                printf('<p>%s</p>', get_the_excerpt());
            } else {
                global $post;
                if (strpos($post->post_content, '<!--more-->')) {
                    the_content(' ');
                } else {
                    printf('<p>%s</p>', get_the_excerpt());
                }
            }
        } elseif ('full' == $exceprt_type) {
            global $more;
            $more = true;
            the_content();
        } else {
            if ($excerpt_limit) {
                $excerpt = KopaUtil::substr($post->post_content, $excerpt_limit);
                echo $excerpt ? sprintf('<p>%s</p>', $excerpt) : '';
            }
        }
        ?>
                                        </div>
                                        <?php 
        if ($metadata['readmore'] && 'full' != $exceprt_type) {
            ?>
                                            <a href="<?php 
            echo $post_url;
            ?>
" class="read-more"><?php 
            _e('Read more', kopa_get_domain());
            ?>
</a>
Example #21
0
 /**
  * 
  *
  * @package Kopa
  * @subpackage Core
  * @author thethangtran <*****@*****.**>
  * @since 1.0.0
  *      
  */
 public function uglify($string)
 {
     return KopaUtil::str_uglify($string);
 }
Example #22
0
 /**
  * @package Kopa
  * @subpackage Core
  * @author thethangtran <*****@*****.**>
  * @since 1.0.0         
  */
 public static function kopa_get_like_button($post_id, $include_text = false)
 {
     $class = '';
     if (self::is_liked($post_id)) {
         $class = 'kopa-button-likes-disable';
     } else {
         $class = 'kopa-button-likes-enable';
     }
     $onclick = sprintf('onclick="KopaFrontend.click_likes_button(event, jQuery(this), %s, \'%s\')"', $post_id, $include_text);
     $out = sprintf('<span class="%s" %s>%s<span>%s</span></span>', $class, $onclick, KopaIcon::getIconLike(), KopaUtil::get_likes($post_id, $include_text));
     return apply_filters('kopa_get_like_button', $out, $post_id);
 }
Example #23
0
    public function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $id = $instance['id'];
        $limit = empty($instance['limit']) ? 2 : (int) $instance['limit'];
        $consumer_key = $instance['consumer_key'];
        $consumer_secret = $instance['consumer_secret'];
        $oauth_access_token = $instance['oauth_access_token'];
        $oauth_access_token_secret = $instance['oauth_access_token_secret'];
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        if ($id && $consumer_key && $consumer_secret && $oauth_access_token && $oauth_access_token_secret) {
            require_once trailingslashit(get_template_directory()) . '/library/addon/api/twitter-api-exchange.php';
            $settings = array('oauth_access_token' => $oauth_access_token, 'oauth_access_token_secret' => $oauth_access_token_secret, 'consumer_key' => $consumer_key, 'consumer_secret' => $consumer_secret);
            $url = "https://api.twitter.com/1.1/statuses/user_timeline.json";
            $requestMethod = "GET";
            $getfield = "?screen_name={$id}&count={$limit}";
            $twitter = new TwitterAPIExchange($settings);
            $data = json_decode($twitter->setGetfield($getfield)->buildOauth($url, $requestMethod)->performRequest(), TRUE);
            ?>
            <div class="widget-content">
                <div id="tweets" class="tweets" data-username="******" data-limit="<?php 
            echo $limit;
            ?>
">
                    <?php 
            if (isset($data["errors"][0]["message"]) && $data["errors"][0]["message"] != '') {
                _e("Sorry, there was a problem when load", kopa_get_domain());
            } else {
                ?>
                        
                        <ul class="tweetList">
                            <?php 
                if (!empty($data)) {
                    ?>
                                <?php 
                    foreach ($data as $items) {
                        ?>
                                    <?php 
                        preg_match('!https?://[\\S]+!', $items['text'], $matches);
                        $url = '';
                        if (isset($matches) && !empty($matches)) {
                            $url = $matches[0];
                        }
                        $pattern = '~http://[^\\s]*~i';
                        $title = preg_replace($pattern, '', $items['text']);
                        ?>
                                    <li class="tweet_content_0">
                                        <p class="tweet_link_0"><?php 
                        echo $title;
                        ?>
                                            <?php 
                        if (!empty($url)) {
                            ?>
                                                <a href="<?php 
                            echo $url;
                            ?>
"><?php 
                            echo $url;
                            ?>
</a>
                                            <?php 
                        }
                        ?>
                                
                                        <p class="timestamp">
                                            <?php 
                        $date = date_create($items['created_at']);
                        if (version_compare(PHP_VERSION, '5.3') >= 0) {
                            $created_at = $date->getTimestamp();
                            echo KopaUtil::human_time_diff($created_at);
                        } else {
                            echo date_format($date, "Y/m/d H:iP");
                        }
                        ?>
                                        </p>
                                        </p>
                                    </li>
                                <?php 
                    }
                    ?>
                            <?php 
                }
                ?>
                        </ul>                        
                        <?php 
            }
            ?>
                </div>
            </div>
            <?php 
        }
        echo $after_widget;
    }
Example #24
0
    function kopa_load_timeline_posts_fn($month, $year, $paged)
    {
        $args = array('date_query' => array('post_type' => array('post'), 'post_status' => array('publish'), 'ignore_sticky_posts' => true, array('year' => $year, 'month' => $month)));
        if ($paged) {
            $args['paged'] = $paged;
        }
        $posts = new WP_Query($args);
        $exceprt_type = KopaOptions::get_option('exceprt_type', 'limit');
        $excerpt_limit = KopaOptions::get_option('excerpt_limit', 200, 'Int');
        $metadata = array();
        $metadata['date'] = false;
        $metadata['comments'] = KopaOptions::get_option('is_display_comments', true, 'Boolean');
        $metadata['views'] = KopaOptions::get_option('is_display_views', true, 'Boolean');
        $metadata['likes'] = KopaOptions::get_option('is_display_likes', true, 'Boolean');
        $metadata['readmore'] = KopaOptions::get_option('is_display_readmore', true, 'Boolean');
        global $post;
        while ($posts->have_posts()) {
            $posts->the_post();
            $post_id = get_the_ID();
            $post_title = get_the_title();
            $post_url = get_permalink();
            $post_format = get_post_format();
            if (!is_sticky()) {
                ?>
                <div class="item clearfix">
                    <p class="kopa-timeline-date-small"><?php 
                echo get_the_date();
                ?>
</p>
                    <?php 
                if (has_post_thumbnail()) {
                    $image_full = KopaImage::get_post_image_src($post_id, 'full');
                    $image_croped = KopaImage::get_post_image_src($post_id, 'size_09');
                    ?>
                        <div class="kopa-thumb">
                            <img src="<?php 
                    echo $image_croped;
                    ?>
" alt="<?php 
                    echo $post_title;
                    ?>
"/>
                            <div class="mask"></div>
                            <a href="<?php 
                    echo $post_url;
                    ?>
" class="icon-link fa fa-link fa-flip-horizontal"></a>
                            <span class="icon-zoom-in fa fa-search-plus" onclick="KopaLightbox.open_image('<?php 
                    echo $image_full;
                    ?>
');"></span>
                        </div>
                        <?php 
                }
                ?>

                    <div class="kp-caption">
                        <h4 class="post-title"><a href="<?php 
                echo $post_url;
                ?>
" title="<?php 
                echo $post_title;
                ?>
"><?php 
                echo $post_title;
                ?>
</a></h4>

                        <ul class="kp-meta-post list-inline">       
                            <?php 
                $is_first = true;
                foreach ($metadata as $key => $val) {
                    if ($val) {
                        $class = $is_first ? 'metadata-first' : '';
                        $is_first = false;
                        switch ($key) {
                            case 'date':
                                printf('<li class="%s">%s<span>%s</span></li>', $class, KopaIcon::getIconDatetime(), get_the_date());
                                break;
                            case 'comments':
                                ?>
                                            <li class="<?php 
                                echo $class;
                                ?>
"><?php 
                                echo KopaIcon::getIconComment();
                                ?>
<span><?php 
                                comments_popup_link(__('No Comment', kopa_get_domain()), __('1 Comment', kopa_get_domain()), __('% Comments', kopa_get_domain()), '', __('0 Comment', kopa_get_domain()));
                                ?>
</span></li>                                            
                                            <?php 
                                break;
                            case 'views':
                                printf('<li class="%s">%s<span>%s</span></li>', $class, KopaIcon::getIconView(), KopaUtil::get_views($post_id, true));
                                break;
                            case 'likes':
                                printf('<li class="%s">%s</li>', $class, KopaUtil::kopa_get_like_button($post_id, true));
                                break;
                        }
                    }
                }
                ?>
                        </ul>

                        <?php 
                if ('excerpt' == $exceprt_type) {
                    if (has_excerpt()) {
                        printf('<p>%s</p>', get_the_excerpt());
                    } else {
                        global $post;
                        if (strpos($post->post_content, '<!--more-->')) {
                            the_content(' ');
                        } else {
                            printf('<p>%s</p>', get_the_excerpt());
                        }
                    }
                } elseif ('full' == $exceprt_type) {
                    global $more;
                    $more = true;
                    the_content();
                } else {
                    if ($excerpt_limit) {
                        $excerpt = KopaUtil::substr($post->post_content, $excerpt_limit);
                        echo $excerpt ? sprintf('<p>%s</p>', $excerpt) : '';
                    }
                }
                ?>

                        <?php 
                if ($metadata['readmore'] && 'full' != $exceprt_type) {
                    ?>
                            <a href="<?php 
                    echo $post_url;
                    ?>
" class="read-more"><?php 
                    _e('Read more', kopa_get_domain());
                    ?>
</a>
                        <?php 
                }
                ?>

                    </div>
                    <!-- kp-caption -->
                    <div class="more-i">
                        <div class="more-time">
                            <span><?php 
                echo get_the_date('M d');
                ?>
</span> 
                            <i><?php 
                echo get_the_date('Y');
                ?>
</i>
                        </div>
                        <span></span>
                        <?php 
                echo KopaIcon::getIconPostFormat($post_format);
                ?>
                        
                    </div>
                    <!-- more i -->
                </div>
                <?php 
            }
        }
        wp_reset_postdata();
    }
    public static function get_html($query, $params, $paged = 1, $orderby = 'date')
    {
        global $post;
        $query['paged'] = (int) $paged;
        $posts = new WP_Query($query);
        while ($posts->have_posts()) {
            $posts->the_post();
            $post_id = get_the_ID();
            $post_title = get_the_title();
            $post_url = get_permalink();
            $post_format = get_post_format();
            ?>
            <div class="item">
                <?php 
            if (has_post_thumbnail()) {
                $image_croped = KopaImage::get_post_image_src($post_id, 'size_07');
                ?>
                    <figure>
                        <a href="<?php 
                echo $post_url;
                ?>
" class="pull-left">
                            <img src="<?php 
                echo $image_croped;
                ?>
" alt="">                                            
                            <span><?php 
                echo KopaIcon::getIconPostFormat($post_format);
                ?>
</span>
                        </a>                            
                    </figure>
                    <?php 
            }
            ?>

                <div class="item-content">
                    <?php 
            if (!$params['is_hide_title']) {
                ?>
                        <h4 class="post-title"><a href="<?php 
                echo $post_url;
                ?>
"><?php 
                echo $post_title;
                ?>
</a></h4>
                    <?php 
            }
            ?>
                   


                    <?php 
            if (!$params['is_hide_excerpt']) {
                if ((int) $params['excerpt_character_limit'] > 0) {
                    $excerpt = KopaUtil::substr($post->post_content, (int) $params['excerpt_character_limit']);
                    echo $excerpt ? sprintf('<p>%s</p>', $excerpt) : '';
                } else {
                    the_excerpt();
                }
            }
            ?>

                </div>

                <ul class="kp-meta-post bottom list-inline">
                    <li class="metadata-first"><?php 
            echo KopaIcon::getIconDatetime();
            ?>
<span><?php 
            echo get_the_date();
            ?>
</span></li>

                    <?php 
            switch ($orderby) {
                case 'views':
                    printf('<li>%s<span>%s</span></li>', KopaIcon::getIconView(), KopaUtil::get_views($post_id, true));
                    break;
                case 'likes':
                    printf('<li>%s</li>', KopaUtil::kopa_get_like_button($post_id, true));
                    break;
                default:
                    ?>
                            <li><?php 
                    echo KopaIcon::getIconComment();
                    comments_popup_link(__('No Comment', kopa_get_domain()), __('1 Comment', kopa_get_domain()), __('% Comments', kopa_get_domain()), '', __('0 Comment', kopa_get_domain()));
                    ?>
</li>
                            <?php 
                    break;
            }
            ?>
 
                </ul>

            </div>
            <?php 
        }
        wp_reset_postdata();
    }