- 1. init_plugin_suite_review_system_auto_insert_enabled_score
- 2. init_plugin_suite_review_system_auto_insert_enabled_vote
- 3. init_plugin_suite_review_system_default_score_shortcode
- 4. init_plugin_suite_review_system_default_vote_shortcode
- 5. init_plugin_suite_review_system_schema_type
- 6. init_plugin_suite_review_system_schema_data
- Kết luận
1. init_plugin_suite_review_system_auto_insert_enabled_score
Bật hoặc tắt auto-insert khối điểm số (score) tại các vị trí trong bài viết.
Tham số:
bool $enabled– Mặc định làtruestring $position– Vị trí nhưbefore,afterstring $post_type– Loại post hiện tại
// Vô hiệu hóa auto-insert score ở cuối bài viết cho post type 'product'
add_filter('init_plugin_suite_review_system_auto_insert_enabled_score', function($enabled, $position, $post_type) {
if ($post_type === 'product' && $position === 'after') {
return false;
}
return $enabled;
}, 10, 3);
2. init_plugin_suite_review_system_auto_insert_enabled_vote
Bật hoặc tắt auto-insert khối đánh giá (vote) tại các vị trí trước/sau nội dung hoặc bình luận.
Tham số: Như trên
// Chặn hiện vote form trong khung bình luận nếu là post type 'page'
add_filter('init_plugin_suite_review_system_auto_insert_enabled_vote', function($enabled, $position, $post_type) {
if ($post_type === 'page') return false;
return $enabled;
}, 10, 3);
3. init_plugin_suite_review_system_default_score_shortcode
Tuỳ biến shortcode mặc định của khối điểm số được auto-insert.
Tham số: string $shortcode
// Thêm class tuỳ chỉnh khi auto-insert score
add_filter('init_plugin_suite_review_system_default_score_shortcode', function($shortcode) {
return '[init_review_score icon="true" class="highlight-score"]';
});
4. init_plugin_suite_review_system_default_vote_shortcode
Tuỳ biến shortcode mặc định của khối vote được auto-insert.
Tham số: string $shortcode
// Bật schema mặc định cho block vote
add_filter('init_plugin_suite_review_system_default_vote_shortcode', function($shortcode) {
return '[init_review_system schema="true"]';
});
5. init_plugin_suite_review_system_schema_type
Điều chỉnh loại schema.org cho block vote.
Tham số:
string $type– Schema type mặc địnhstring $post_type– Loại post hiện tại
// Đổi thành Movie nếu post type là 'movie'
add_filter('init_plugin_suite_review_system_schema_type', function($type, $post_type) {
return $post_type === 'movie' ? 'Movie' : $type;
}, 10, 2);
6. init_plugin_suite_review_system_schema_data
Tuỳ biến nội dung JSON-LD schema cho khối vote.
Tham số:
array $schema_data– Dữ liệu schema đã generateint $post_id– ID bài viếtstring $schema_type– Loại schema đang dùng
// Thêm trường 'author' vào schema
add_filter('init_plugin_suite_review_system_schema_data', function($schema, $post_id, $type) {
$schema['author'] = get_bloginfo('name');
return $schema;
}, 10, 3);
Kết luận
Hệ thống hook của Init Review System được thiết kế đơn giản, nhưng đủ mở rộng để bạn có thể điều chỉnh mọi hành vi từ việc hiển thị, schema cho đến xử lý vote.
Bình luận