Posted on April 10th, 2009 in WP Plugins | 10,766 views

Bạn thấy đấy, WordPress không cho phép chúng ta di chuyển comment từ bài viết này sang bài viết khác. Đây quả là một bất tiện khi bạn muốn sắp xếp các comment ở đúng vị trí của chúng bởi vì không phải lúc nào người xem cũng viết comment ở đúng nơi bạn mong muốn. Tuy nhiên vẫn có thể giải quyết được vấn đề này bằng cách dùng một trong bốn plugin mà tôi sắp giới thiệu dưới đây.

1. WP Move Comments

Một sản phẩm "made in VietNam" do rilwis viết. Sau khi cài, plugin này sẽ tự động thêm chữ Move vào bên dưới mỗi comment.
wp-move-comments
Muốn chuyển comment nào thì bạn click vào chữ Move sau đó nhập ID của bài viết cần chuyển đến. Cách lấy ID của bài viết thì mời bạn xem tại trang chủ của plugin.
-- Ưu điểm: gọn nhẹ, dễ sử dụng, tác giả là người Việt nên dễ liên hệ. :D
-- Nhược điểm: người dùng phải tự lấy ID bài viết và không chuyển nhiều comment cùng một lúc được.

2. Comment Move

Sau khi cài plugin, để di chuyển comment, bạn bấm vào chữ Edit (nhớ rê chuột vào comment thì menu mới hiện ra)
comment-move-1
Kế tiếp, bạn chọn bài viết cần chuyển comment đến, plugin sẽ tự động lấy ID của bài viết đó và bạn chỉ việc bấm nút Update Comment là xong.
comment-move-3
-- Ưu điểm: lấy ID bài viết một cách tự động
-- Nhược điểm: không chuyển nhiều comment cùng một lúc được.

3. BDP Move Comments

Sau khi cài, plugin này sẽ thêm một page trong phần quản lý comment (Dashboard > Comments > Move Comments). Khi vào, bạn sẽ thấy phần tùy chọn cho plugin và bên dưới là một bảng chứa tất cả comment trên blog đã được phân trang (mỗi trang gồm 20 comment).

Ý nghĩa của từng tùy chọn như sau:

1) Enable the "Move it!" button for blog superusers when they browse comments
=> Hiện thêm nút "Move it!" bên dưới mỗi comment (bên ngoài blog chứ không phải trong wp-admin)

2) List all possible destinations for a move
=> Liệt kê tất cả bài viết trên blog (kể cả attachment) để bạn chọn khi muốn chuyển comment đến. Lưu ý: sẽ rất chậm nếu blog có quá nhiều bài viết.

3) When not listing all possible destinations, list destination posts within how many days of today
=> Nếu không dùng tùy chọn số 2 thì chỉ liệt kê những bài trong khoảng thời gian bao nhiêu ngày trở lại

4) When not listing all possible destinations, be sure to include these page and post IDs as destinations
=> Nếu không dùng tùy chọn số 2 thì bắt buộc lúc nào cũng phải liệt kê những bài có ID mà bạn chỉ định

Sau khi thiết lập tùy chọn xong, bạn chỉ việc chọn những comment cần chuyển sau đó kéo xuống dưới và bấm nút "Bulk move checked comments »". Sang trang kế tiếp, bạn lưu ý ở cột TypeStatus, bạn phải chọn những bài có type là 'post' (hoặc page) với status là 'publish' thì ra ngoài mới thấy có tác dụng.
move-comments-4
-- Ưu điểm: có thể chuyển được nhiều comment, có thêm nút "Move it!" ở bên ngoài để admin tiện sử dụng.
-- Nhược điểm: phải cấu hình thêm, không cần thiết phải liệt kê cả những attachment.

4. Move Comments

Tương tự như plugin số 3, plugin này cũng thêm một page tên là Move trong Dashboard > Comments nhưng nó không có phần tùy chọn và cách hoạt động hơi khác một chút.

Thay vì chọn comment trước thì plugin này cho bạn chọn bài viết trước. Có hai danh sách chứa tất cả bài viết trên blog, bạn chọn một bài trong ô -- Move From -- rồi chọn comment cần di chuyển đến một bài trong ô -- Move To --, sau đó bấm nút Update Options »
-- Ưu điểm: có thể chuyển được nhiều comment, không cần cấu hình thêm
-- Nhược điểm: không phân biệt bài nào là post, bài nào là page trong hai danh sách

Kết luận

Như bạn thấy, cả 4 plugin trên đều có ưu-nhược điểm riêng, hai plugin đầu thì gọn nhẹ, đơn giản nhưng chỉ tác động lên một comment còn hai plugin sau thì mạnh hơn, có thể chuyển nhiều comment cùng một lúc. Vì vậy tùy theo tình huống mà bạn hãy chọn plugin cho phù hợp. :)

Tôi đã test qua 4 plugin trên và đã hiểu phần nào về cách thức hoạt động của chúng. Nếu muốn khắc phục nhược điểm của plugin số 3, số 4 thì bạn cứ comment ở đây, tôi sẽ gửi cho bạn bản update của hai plugin đó. Ngoài ra nếu bạn còn biết thêm plugin nào khác hoặc có ý tưởng mới để dễ thao tác hơn thì xin mời bạn chia sẻ, biết đâu những ý tưởng của bạn có thể giúp tôi viết ra một plugin mới tốt hơn. :D

Posted on April 5th, 2009 in WP Plugins | 15,434 views

Vừa rồi tôi có hướng dẫn bạn cách tùy biến Smilies trong WordPress mà không cần dùng đến plugin bằng cách sửa file wp-config.php. Tuy có hơi thủ công một chút nhưng theo tôi cách đó là đơn giản và nhanh chóng nhất, khỏi phải cài plugin - cái mà tôi hạn chế càng ít càng tốt (không biết bạn thế nào :D )

Tuy nhiên, nếu bạn ngại việc sửa file cấu hình hoặc không thích đụng tới code, bạn vẫn có thể dùng plugin cho tiện. Nói về plugin cho vụ này thì có rất nhiều, bạn chỉ việc lựa chọn plugin thích hợp rồi cài vào sử dụng là xong. Tôi có liệt kê sẵn bên dưới một số cái mà tôi biết để giúp bạn đỡ mất thời gian tìm kiếm.

1. Đầu tiên phải kể đến là WP Grins của Alexking. Đây là một plugin khá đơn giản mà Alexking gọi là "A Clickable Smilies hack for WordPress", bằng cách dùng Prototype, nó sẽ tự động thêm một thẻ div (có id là wp_grins) chứa các smilies vào 2 nơi: trước ô nhập nội dung comment trên theme và dưới phần soạn thảo bài viết trong wp-admin. Các smilies được lấy từ biến $wpsmiliestrans nên bạn có thể dùng plugin này kết hợp với cách sửa file wp-config.php mà tôi đã hướng dẫn (xem ở đây)

2. WordPress Yahoo/MSN Messenger Style Smileys - Một plugin của Priyadi (người Indonesia) được khá nhiều người sử dụng, chức năng của nó là thay thế các smilies mặc định của WordPress bằng smilies của Yahoo! Messenger hoặc MSN Messenger.

priyadi-smilies

Priyadi không dùng biến $wpsmiliestrans mà tự định nghĩa thêm 2 biến khác là $yahoosmiliestrans$msnsmiliestrans lần lượt chứa tất cả smilies của Yahoo! và MSN Messenger. Để hiện smilies, bạn chèn <?php smilies_clickable(); ?> vào chỗ bạn thích trong file comments.php, plugin sẽ không hiện tất cả smilies mà chỉ hiện các smilies phổ biến, bạn có thể tùy biến chúng trong 2 biến $smilies_yahoo_always_shown và $smilies_msn_always_shown.

Lưu ý: khi sử dụng plugin này, bạn phải tắt tùy chọn Convert emoticons like :-) and :-P to graphics on display nằm trong "Settings > Writing" để WordPress không dùng các smilies mặc định nữa.

3. Smilies Themer - plugin này không giống như 2 plugin trên, nó không hiện các smilies ra bên ngoài mà chỉ thay đổi hệ thống smilies theo ý riêng của bạn. Nói một cách dễ hiểu là thay vì bạn sửa file wp-config.php bằng tay thì bạn có thể dùng plugin này để thay thế, nó cung cấp khá nhiều bộ smilies cho bạn lựa chọn, sau khi chọn xong, WordPress sẽ chỉ hiện các smilies đó mà thôi. Tôi nghĩ nếu các phiên bản kế tiếp của WordPress mà có tính năng này thì quá tuyệt! :D

4. Smilies Themer Toolbar - đây là plugin dạng "cơm thêm" cho Smilies Themer. Bạn chọn bộ smiles nào trong Smilies Themer thì plugin này sẽ hiện các smilies đó ở bên dưới ô nhập comment hoặc bạn muốn hiện ở chỗ khác thì dùng đoạn code này:

<?php if (function_exists('sm_toolbar_show')) sm_toolbar_show(); ?>

Lưu ý: plugin này chỉ chạy chung với Smilies Themer, nếu Smilies Themer chưa được cài thì plugin này không có tác dụng.
smilies-themer
5. Smiley JS Buttons - đúng như tên gọi của nó, plugin này dùng Javascript để tạo ra các smilies, nó tương tự như plugin WP Grins của Alexking nhưng đơn giản hơn một chút là nó không dùng Prototype và cũng không tự động hiện smilies ở comment form mà bạn phải chèn thêm code sau:

<?php if (function_exists('SJB_outputSmilies')) SJB_outputSmilies(); ?>

smiley_js_buttons

Đón xem tiếp phần 2....

Posted on March 13th, 2009 in WP Tips-Tricks | 9,147 views

Vừa rồi tôi đã hướng dẫn bạn cách đếm số comment, còn bây giờ tôi sẽ hướng dẫn đến cách đếm số post và page. Tương tự như comment nhưng post và page lại nằm ở table 'wp_posts' và có kèm theo vài điều kiện khác.

Đoạn code dưới đây sẽ đếm số post:

1
2
3
4
5
6
<?php
global $wpdb;
$num_posts = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' AND post_password = ''");
if ($num_posts > 0) $num_posts = number_format($num_posts);
echo 'Có tổng cộng ' . $num_posts . ' bài viết trên blog của tôi';
?>

Các điều kiện đã dùng trong câu SQL trên là:

  • post_type = 'post'
  • post_status = 'publish'
  • post_password = ''

Để đếm số page, bạn chỉ việc thay 'post' thành 'page' ở chỗ post_type, còn nếu bạn muốn đếm luôn cả bài viết có đặt password thì bạn chỉ cần xóa đi điều kiện post_password = '' là xong. :D

Mặc dù hiện nay có khá nhiều plugin có chức năng tạo bảng thống kê trên blog của bạn nhưng nếu bạn chỉ đơn thuần muốn đếm số lượng post/page và comment thì tại sao bạn không tự tạo một bảng thống kê nho nhỏ cho riêng mình chỉ với vài dòng code đơn giản? Những blog chia sẻ software hay ebook mà đặt đoạn code trên ở sidebar thì tuyệt vời. >:d<

Posted on March 12th, 2009 in WP Tips-Tricks | 10,952 views

This article will guide you how to display the number of comments on your blog (of course those are approved comments) by a simple php code below.

1
2
3
4
5
6
<?php
global $wpdb;
$num_comments = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = '1'");
if ($num_comments > 0) $num_comments = number_format($num_comments);
echo "There are " . $num_comments . " comments on my blog";
?>

Paste the code to places you like in your theme's php files. And this is a live demo :D

There are 1,226 comments on my blog

In the next article, I will guide you how to count the number of posts/pages on your blog. Remember to read! :)

Posted on December 15th, 2008 in WP Plugins | 57,191 views

This is a plugin for WordPress 2.6+ that can help you know where your commenters come from, which type of web browser and OS they used when they left a comment on your blog. It provides two functions that take IP and User Agent as parameters and then return HTML string contains country flag, web browser and OS icons. You can put these icons anywhere you like in each comment.
In fact, this plugin is a combination of two plugins: WordPress Browser Detection Plugin and Easy IP2Country that I have intergrated as a built-in plugin for my premium theme before, see this page for example, but now I decide to separate it as a new plugin with some enhancements and share it for everyone. :)

Features:

  • Detects and shows commenter's country flag, web browser and operating system
  • Supports many web browsers and operating systems: major desktop browsers, antiquated browsers, blogging software (for trackbacks and pingbacks), text based browsers, various PDAs and cell phones.
  • Uses a binay file for IP to country resolution and supports database sources from Webhosting.info - Software77.net
  • The returned string can be configed as a template to suite your theme

Screenshot:

comment info detector

Download:

download

Installation:

  1. Download the plugin and extract its content
  2. Upload the complete folder "comment-info-detector" to the "/wp-content/plugins/" directory
  3. Activate the plugin through the 'Plugins' menu in WP-Admin
  4. Go to 'WP-Admin -> Settings -> Comment Info Detector' to configure the plugin

Update:

To update new version for this plugin, please deactivate it => delete the old plugin-folder from your server => upload the new plugin-folder => activate the new plugin.

Usage:

  1. Open wp-content/themes/<YOUR THEME NAME>/comment.php
  2. Find the comment loop:
    1
    
    foreach ($comments as $comment)
  3. Add anywhere you like below the comment loop:
    1
    
    <?php if (function_exists("CID_init")) { CID_print_comment_flag(); echo ' '; CID_print_comment_browser(); } ?>
  4. Optional: you can change the CSS style for flag - web browser - OS icons, open and edit:/wp-content/plugins/comment-info-detector/comment-info-detector.css

Credits

Comment Info Detector is written by me, HieuDT. Big thanks to Priyadi Iman Nurcahyo for web browser, OS detection code and Omry Yadan for IP2Country library.

Changelog:

  • 1.0.0 [12-15-2008]: First released.
  • 1.0.1 [12-16-2008]: Added two quick-tags for web browser and operating system to return result correctly.
  • 1.0.2 [01-12-2009]: Updated database for ip2country library and increase ability to detect some new web browsers - operating systems.
  • 1.0.3 [01-18-2009]: Added two options that automatically display icons, no need to modify comments.php file.
  • 1.0.4 [03-02-2009]: Updated database for ip2country and added icons for IE8, Vista.
  • 1.0.5 [09-07-2009]: Updated database for ip2country and added icons for Windows 7.

Now I still continue to develop this plugin and I'm very glad to receive feedback from you. If you feel this plugin is missing or not working well, you are welcome, please let me know! :D

Posted on December 2nd, 2008 in WP Plugins | 12,762 views

Normally, if you want to moderate your blog comments, most of us usually login to WordPress Admin to check for any new comments awaiting to be moderated. Now you don't have to do that because there is a plugin can help you to view and moderate your blog comments directly from your desktop.

That plugin is Moderator - written by Daniel Dura. It's not only a WP plugin but also an application that notifies whenever there is a new comment submitted on your blog, something similar to Yahoo Messenger or Gtalk.

Plugin Features:

  • Viewing unmoderated comments.
  • Dock and system tray notifications of the number of unmoderated comments.
  • Accept, delete, and spam comments from within the desktop client.
  • Close application window, or minimize it to the system tray while running.
  • Shows the Gravatar icons for the user who posted the comment.

Requirements

Moderator currently requires version 2.6+ of WordPress be installed. Also, you will need Adobe AIR 1.1, which runs on Mac, Windows, and is currently in beta on Linux.

Installation

  1. Download the current plugin bundle from here. (moderator_plugin.zip | 72KB)
  2. Unzip the contents of the archive and place them in your WordPress install directory under {wordpress install}/wp-content/plugins. You should now have a directory called ‘moderator’ in the plugins folder.
  3. Login to your administration panel, and go to the Plugins page. Activate the Moderator plugin by clicking on the ‘Activate’ link in the entry for this plugin.
  4. Now that the plugin is activated, go to the Settings tab and select the Moderator admin page. Follow the instructions on that page to install the desktop client.

I think this is a very useful plugin that you can start using to make your comment moderation easily!