function hocwp_theme_translation_comments_list_callback($comment, $args, $depth)
{
    $GLOBALS['comment'] = $comment;
    $comment_id = $comment->comment_ID;
    $style = isset($args['style']) ? $args['style'] : 'ol';
    $avatar_size = isset($args['avatar_size']) ? absint($args['avatar_size']) : 64;
    $avatar_size = apply_filters('hocwp_comment_avatar_size', $avatar_size);
    $max_depth = isset($args['max_depth']) ? absint($args['max_depth']) : '';
    $comment_permalink = get_comment_link($comment);
    if ('div' == $style) {
        $tag = 'div';
        $add_below = 'comment';
    } else {
        $tag = 'li';
        $add_below = 'div-comment';
    }
    $comment_date = get_comment_date('Y-m-d H:i:s', $comment_id);
    $comment_author = '<div class="comment-author vcard">' . get_avatar($comment, $avatar_size) . '<b class="fn">' . get_comment_author_link() . '</b> <span class="says">nói:</span></div>';
    $comment_metadata = '<div class="comment-metadata"><a href="' . $comment_permalink . '"><time datetime="' . get_comment_time('c') . '">' . hocwp_human_time_diff_to_now($comment_date) . ' ' . 'trước' . '</time></a> <a class="comment-edit-link" href="' . get_edit_comment_link($comment_id) . '">(' . 'Sửa' . ')</a></div>';
    if ($comment->comment_approved == '0') {
        $comment_metadata .= '<p class="comment-awaiting-moderation">' . 'Bình luận của bạn đang được chờ để xét duyệt.' . '</p>';
    }
    $footer = new HOCWP_HTML('footer');
    $footer->set_class('comment-meta');
    $footer->set_text($comment_author . $comment_metadata);
    $comment_text = get_comment_text($comment_id);
    $comment_text = apply_filters('comment_text', $comment_text, $comment);
    $comment_content = '<div class="comment-content">' . $comment_text . '</div>';
    $reply = '<div class="reply comment-tools">';
    $reply .= get_comment_reply_link(array_merge($args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $max_depth)));
    $comment_tools_enabled = apply_filters('hocwp_comment_tools_enabled', true);
    if ($comment_tools_enabled) {
        $class = 'comment-like comment-likes';
        $session_comment_liked_key = 'comment_' . $comment_id . '_likes';
        $liked = intval(isset($_SESSION[$session_comment_liked_key]) ? $_SESSION[$session_comment_liked_key] : '');
        if ($liked == 1) {
            hocwp_add_string_with_space_before($class, 'disabled');
        }
        $a = new HOCWP_HTML('a');
        $a->set_class($class);
        $a->set_attribute('href', 'javascript:;');
        $a->set_attribute('data-session-likes-key', $session_comment_liked_key);
        $likes = hocwp_get_comment_likes($comment_id);
        $a->set_attribute('data-likes', $likes);
        $a->set_text('<span class="text">' . 'Thích' . '</span> <i class="fa fa-thumbs-o-up"></i><span class="sep-dot">.</span> <span class="count">' . $likes . '</span>');
        $reply .= $a->build();
        $a->set_class('comment-report');
        $a->remove_attribute('data-session-liked-key');
        $a->set_text('Báo cáo vi phạm' . '<i class="fa fa-flag"></i>');
        $reply .= $a->build();
        $a->set_class('comment-share');
        $share_text = '<span class="text">' . 'Chia sẻ' . '<i class="fa fa-angle-down"></i></span>';
        $share_text .= '<span class="list-share">';
        $share_text .= '<i class="fa fa-facebook facebook" data-url="' . hocwp_get_social_share_url(array('social_name' => 'facebook', 'permalink' => $comment_permalink)) . '"></i>';
        $share_text .= '<i class="fa fa-google-plus google" data-url="' . hocwp_get_social_share_url(array('social_name' => 'googleplus', 'permalink' => $comment_permalink)) . '"></i>';
        $share_text .= '<i class="fa fa-twitter twitter" data-url="' . hocwp_get_social_share_url(array('social_name' => 'twitter', 'permalink' => $comment_permalink)) . '"></i>';
        $share_text .= '</span>';
        $a->set_text($share_text);
        $reply .= $a->build();
    }
    $reply .= '</div>';
    $article = new HOCWP_HTML('article');
    $article->set_attribute('id', 'div-comment-' . $comment_id);
    $article->set_class('comment-body');
    $article_text = $footer->build();
    $article_text .= $comment_content;
    $article_text .= $reply;
    $article->set_text($article_text);
    $html = new HOCWP_HTML($tag);
    $comment_class = get_comment_class(empty($args['has_children']) ? '' : 'parent');
    $comment_class = implode(' ', $comment_class);
    $html_atts = array('class' => $comment_class, 'id' => 'comment-' . $comment_id, 'data-comment-id' => $comment_id);
    $html->set_attribute_array($html_atts);
    $html->set_text($article->build());
    $html->set_close(false);
    $html->output();
}
Ejemplo n.º 2
0
function hocwp_facebook_comment($args = array())
{
    $args = apply_filters('hocwp_facebook_comment_args', $args);
    $colorscheme = isset($args['colorscheme']) ? $args['colorscheme'] : 'light';
    $colorscheme = apply_filters('hocwp_facebook_comment_colorscheme', $colorscheme, $args);
    $href = isset($args['href']) ? $args['href'] : '';
    if (empty($href)) {
        if (is_single() || is_page() || is_singular()) {
            $href = get_the_permalink();
        }
    }
    if (empty($href)) {
        $href = $this->get_current_url();
    }
    $href = apply_filters('hocwp_facebook_comment_href', $href, $args);
    $mobile = isset($args['mobile']) ? $args['mobile'] : '';
    $num_posts = isset($args['num_posts']) ? $args['num_posts'] : 10;
    $num_posts = apply_filters('hocwp_facebook_comment_num_posts', $num_posts, $args);
    $order_by = isset($args['order_by']) ? $args['order_by'] : 'social';
    $width = isset($args['width']) ? $args['width'] : '100%';
    $width = apply_filters('hocwp_facebook_comment_width', $width, $args);
    $loading_text = hocwp_get_value_by_key($args, 'loading_text', __('Loading...', 'hocwp-theme'));
    $div = new HOCWP_HTML('div');
    $div->set_class('fb-comments');
    $atts = array('data-colorscheme' => $colorscheme, 'data-href' => $href, 'data-mobile' => $mobile, 'data-numposts' => $num_posts, 'data-order-by' => $order_by, 'data-width' => $width);
    $atts = apply_filters('hocwp_facebook_comment_attributes', $atts, $args);
    $div->set_attribute_array($atts);
    $div->set_text($loading_text);
    $div->output();
}
Ejemplo n.º 3
0
function hocwp_field_select($args = array())
{
    $args = hocwp_field_sanitize_args($args);
    $id = isset($args['id']) ? $args['id'] : '';
    $name = isset($args['name']) ? $args['name'] : '';
    $list_options = isset($args['list_options']) ? $args['list_options'] : array();
    $options = isset($args['options']) ? $args['options'] : array();
    if (!hocwp_array_has_value($options)) {
        $options = hocwp_get_value_by_key($args, array('field_args', 'options'));
    }
    $load_item = isset($args['load_item']) ? $args['load_item'] : true;
    $value = isset($args['value']) ? $args['value'] : '';
    $field_class = isset($args['field_class']) ? $args['field_class'] : 'widefat';
    if (!is_array($options) || count($options) < 1) {
        $options = $list_options;
    }
    $all_option = isset($args['all_option']) ? $args['all_option'] : '';
    $autocomplete = isset($args['autocomplete']) ? $args['autocomplete'] : false;
    if (!$autocomplete) {
        $autocomplete = 'off';
    }
    $select_option = isset($args['default_option']) ? $args['default_option'] : '';
    if ($load_item && empty($all_option)) {
        foreach ($options as $key => $text) {
            $select_option .= hocwp_field_get_option(array('value' => $key, 'text' => $text, 'selected' => $value));
        }
    } else {
        $select_option .= $all_option;
    }
    if (!$load_item) {
        $custom_options = isset($args['custom_options']) ? $args['custom_options'] : '';
        $select_option .= $custom_options;
    }
    hocwp_field_before($args);
    $html = new HOCWP_HTML('select');
    $attributes = isset($args['attributes']) ? hocwp_sanitize_array($args['attributes']) : array();
    $atts = array('id' => hocwp_sanitize_id($id), 'name' => $name, 'class' => $field_class, 'autocomplete' => $autocomplete, 'text' => $select_option);
    $html->set_attribute_array($atts);
    foreach ($attributes as $key => $value) {
        $html->set_attribute($key, $value);
    }
    $html->output();
    hocwp_field_after($args);
}