
內容簡介
總結:Post Engagement Widget 提供了一個簡單而強大的方式來收集使用者對內容的反饋。這個外掛設計輕量且易於使用,讓您輕鬆地在文章和評論上添加美觀、AJAX 強化的讚和不喜歡按鈕,鼓勵訪客與您網站互動。
1. 這個外掛的主要功能有哪些?
- AJAX 強化的投票功能,無需頁面重新加載。
- 讓文章和評論都可以添加讚和不喜歡按鈕。
- 可選擇允許未登錄使用者投票,並使用 Cookie 防止重覆投票。
- 提供完整的自定義功能,您可以根據主題的設計使用內建的顏色選擇器來調配按鈕外觀。
- 可選擇使用經典的「讚/不喜歡」文字或現代的👍/👎表情標籤。
- 自動在文章結尾添加投票按鈕。
- 通用的縮碼,讓您可以手動在任何頁面、產品或自訂文章類型中放置按鈕。
- 在刪除外掛時,自動清除所有設置和數據,不留下任何蹤跡。
- 提供完整的操作和過濾器集合以便於高級自定義。
2. 開發者提供了哪些進階自定義功能?
- 可以透過增加 filters 修改自動顯示按鈕的文章類型清單。
- 例如增加支持 'portfolio' 這一自定義文章類型的投票功能。
外掛標籤
開發者團隊
原文外掛簡介
The Post Engagement Widget provides a simple yet powerful way to gather user feedback on your content. With just a few clicks, you can add beautiful, AJAX-powered Like and Dislike buttons to your posts and comments, encouraging visitors to interact with your site.
The plugin is designed to be lightweight and easy to use. The settings panel gives you full control over colors, labels, and display rules, while the included shortcode allows you to place the voting buttons anywhere you want.
Key Features for Initial Release:
AJAX-Powered Voting: No page reloads. The interface updates instantly for a smooth, modern user experience.
Post & Comment Engagement: Add like/dislike buttons to both posts and comments right out of the box.
Guest Voting: Optionally allow non-logged-in users to vote (uses cookies to prevent duplicate votes).
Full Customization: Use the built-in color pickers to match the buttons to your theme’s design.
Emoji or Text Labels: Choose between classic “Like/Dislike” text or modern 👍/👎 emoji labels.
Automatic Display on Posts: Automatically add voting buttons to the end of all your blog posts with a single checkbox.
Universal Shortcode: Use the [engage_widgetment_widget] shortcode to manually place buttons on any page, product, or custom post type.
Clean Uninstall: When you delete the plugin, it cleans up all its settings and data from your database, leaving no trace behind.
Developer Friendly: Highly extensible with a complete set of actions and filters for advanced customization.
For Developers (Advanced Customization)
We’ve included several hooks to allow you to extend the plugin’s functionality. Here are some examples of what you can do.
Filters
engage_widget_auto_display_post_types
Modify the list of post types where buttons are automatically displayed.
add_filter( 'engage_widget_auto_display_post_types', 'add_my_cpt_for_voting' );
function add_my_cpt_for_voting( $post_types ) {
// Add support for a 'portfolio' custom post type
$post_types[] = 'portfolio';
return $post_types;
}
engage_widget_render_buttons_html
Filter the final HTML of the buttons for posts.
add_filter( 'engage_widget_render_buttons_html', 'my_custom_post_buttons_wrapper', 10, 2 );
function my_custom_post_buttons_wrapper( $html, $post_id ) {
return '
';
}
engage_widget_render_comment_buttons_html
Filter the final HTML of the buttons for comments.
add_filter( 'engage_widget_render_comment_buttons_html', 'my_custom_comment_buttons_wrapper', 10, 2 );
function my_custom_comment_buttons_wrapper( $html, $comment_object ) {
return '
';
}
engage_widget_user_can_vote
Add custom permission logic to prevent a vote. Return false to block the vote.
add_filter( 'engage_widget_user_can_vote', 'prevent_voting_on_own_post', 10, 4 );
function prevent_voting_on_own_post( $permission, $item_type, $item_id, $user_id ) {
if ( $item_type === 'post' && $user_id > 0 ) {
if ( get_post_field( 'post_author', $item_id ) == $user_id ) {
return false; // Prevent users from voting on their own posts
}
}
return $permission;
}
Actions
engage_widget_after_vote_processed
Fire a custom action after a vote is successfully recorded.
add_action( 'engage_widget_after_vote_processed', 'my_custom_action_on_vote', 10, 4 );
function my_custom_action_on_vote( $item_type, $item_id, $vote, $user_id ) {
if ( $item_type === 'post' && $vote === 'like' ) {
// Example: Send a notification or update a transient
error_log( "User {$user_id} liked post {$item_id}." );
}
}
engage_widget_after_settings_fields
Add your own custom fields to the plugin’s settings page.
add_action( 'engage_widget_after_settings_fields', 'my_custom_engage_widget_setting' );
function my_custom_engage_widget_setting( $settings ) {
// HTML for your new setting field
}
