exists() ? $user->display_name : ''; $format = current_theme_supports('html5', 'comment-form') ? 'html5' : 'xhtml'; $format = apply_filters('fansub_comment_form_format', $format); $req = get_option('require_name_email'); $aria_req = ($req ? " aria-required='true'" : ''); $html_req = ($req ? " required='required'" : ''); $required_text = sprintf(' ' . __('Những mục bắt buộc được đánh dấu %s', 'fansub'), '*'); $html5 = 'html5' === $format; $defaults = array( 'comment_field' => '

', 'must_log_in' => '

' . sprintf(__('Bạn phải đăng nhập trước khi có thể đăng bình luận.', 'fansub'), wp_login_url(apply_filters('the_permalink', get_permalink(get_the_ID())))) . '

', 'logged_in_as' => '

' . sprintf(__('Bạn đang đăng nhập với tài khoản %2$s. Thoát?', 'fansub'), get_edit_user_link(), $user_identity, wp_logout_url(apply_filters('the_permalink', get_permalink(get_the_ID())))) . '

', 'comment_notes_before' => '

' . __('Địa chỉ email của bạn sẽ được giữ bí mật.', 'fansub') . ''. ($req ? $required_text : '') . '

', 'title_reply' => '' . __('Gửi bình luận', 'fansub') . '', 'title_reply_to' => __('Gửi trả lời cho %s', 'fansub'), 'cancel_reply_link' => __('Nhấn vào đây để hủy trả lời.', 'fansub'), 'label_submit' => __('Gửi bình luận', 'fansub') ); return $defaults; } add_filter('comment_form_defaults', 'fansub_theme_translation_comment_form_defaults'); function fansub_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; $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 = '
' . get_avatar($comment, $avatar_size) . '' . get_comment_author_link() . ' nói:
'; $comment_metadata = '
(' . __('Sửa', 'fansub') . ')
'; if($comment->comment_approved == '0') { $comment_metadata .= '

' . __('Bình luận của bạn đang được chờ để xét duyệt.', 'fansub') . '

'; } $footer = new FANSUB_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 = '
' . $comment_text . '
'; $reply = '
'; $reply .= get_comment_reply_link(array_merge($args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $max_depth))); $comment_tools_enabled = apply_filters('fansub_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) { fansub_add_string_with_space_before($class, 'disabled'); } $a = new FANSUB_HTML('a'); $a->set_class($class); $a->set_attribute('href', 'javascript:;'); $a->set_attribute('data-session-likes-key', $session_comment_liked_key); $likes = fansub_get_comment_likes($comment_id); $a->set_attribute('data-likes', $likes); $a->set_text('' . __('Thích', 'fansub') . ' . ' . $likes . ''); $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', 'fansub') . ''); $reply .= $a->build(); $a->set_class('comment-share'); $share_text = '' . __('Chia sẻ', 'fansub') . ''; $share_text .= ''; $share_text .= ''; $share_text .= ''; $share_text .= ''; $share_text .= ''; $a->set_text($share_text); $reply .= $a->build(); } $reply .= '
'; $article = new FANSUB_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 FANSUB_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(); } function fansub_theme_translation_comment_form_default_fields($fields) { $commenter = wp_get_current_commenter(); $user = wp_get_current_user(); $user_identity = $user->exists() ? $user->display_name : ''; $format = current_theme_supports('html5', 'comment-form') ? 'html5' : 'xhtml'; $format = apply_filters('fansub_comment_form_format', $format); $req = get_option('require_name_email'); $aria_req = ($req ? "aria-required='true'" : ''); $html_req = ($req ? "required='required'" : ''); $require_attr = $aria_req . ' ' . $html_req; $html5 = 'html5' === $format; $fields = array( 'author' => '

' . ' ' . '

', 'email' => '

' . '

', 'url' => '

' . '

', ); return $fields; } add_filter('comment_form_default_fields', 'fansub_theme_translation_comment_form_default_fields'); function fansub_theme_translation_wp_list_comments_args($args) { $args['reply_text'] = '' . __('Trả lời', 'fansub') . ''; $args['callback'] = 'fansub_theme_translation_comments_list_callback'; return $args; } add_filter('wp_list_comments_args', 'fansub_theme_translation_wp_list_comments_args', 10); function fansub_theme_translation_gettext($translation, $text) { switch($text) { case 'Nothing Found': $translation = 'Không tìm thấy nội dung'; break; case 'Ready to publish your first post? Get started here.': $translation = 'Bạn đã sẵn sàng viết bài? Bắt đầu từ đây.'; break; case 'Sorry, but nothing matched your search terms. Please try again with some different keywords.': $translation = 'Xin lỗi, nhưng hệ thống không tìm thấy nội dung bạn đang tìm kiếm, có thể thử lại bằng cách dùng từ khóa khác.'; break; case 'It seems we can’t find what you’re looking for. Perhaps searching can help.': $translation = 'Hệ thống không tìm thấy nội dung bạn đang muốn xem. Bạn có thể thử dùng công cụ tìm kiếm để trợ giúp.'; break; case 'It looks like nothing was found at this location. Maybe try a search?': $translation = 'Dường như không có gì được tìm thấy trong đường dẫn này. Bạn có thể thử công cụ tìm kiếm?'; break; case 'Oops! That page can’t be found.': $translation = 'Xin lỗi! Trang này không được tìm thấy'; break; } return $translation; } add_filter('gettext', 'fansub_theme_translation_gettext', 10, 2); function fansub_theme_translation_gettext_with_context($translations, $text, $context, $domain = 'default') { switch($text) { case 'Search for:': $translations = 'Tìm kiếm cho:'; break; case 'Search …': $translations = 'Từ khóa…'; break; case 'Search': $translations = 'Tìm kiếm'; break; } return $translations; } add_filter('gettext_with_context', 'fansub_theme_translation_gettext_with_context', 10, 3); function fansub_theme_translation_ngettext($translation, $single, $plural, $number, $domain = 'default') { $translations = get_translations_for_domain($domain); $translation = $translations->translate_plural($single, $plural, $number); switch($translation) { case '%s second': case '%s seconds': $translation = '%s giây'; break; case '%s min': case '%s mins': case '%s minute': case '%s minutes': $translation = '%s phút'; break; case '%s hour': case '%s hours': $translation = '%s giờ'; break; case '%s day': case '%s days': $translation = '%s ngày'; break; case '%s week': case '%s weeks': $translation = '%s tuần'; break; case '%s month': case '%s months': $translation = '%s tháng'; break; case '%s year': case '%s years': $translation = '%s năm'; break; } return $translation; } add_filter('ngettext', 'fansub_theme_translation_ngettext', 10, 4); function fansub_theme_translation_comment_list_class($classes) { $classes[] = 'custom'; return $classes; } add_filter('fansub_comment_list_class', 'fansub_theme_translation_comment_list_class');