Developer Functions
PHP function reference — counts, user status, popular items, meta API, and custom templates.
Public PHP functions use the wp_ulike_ prefix. Always wrap calls in function_exists() from themes or third-party plugins.
Options
wp_ulike_get_option( $option, $default = null )
Read a setting from wp_ulike_settings.
$toast = wp_ulike_get_option('enable_toast_notice', true);
$posts = wp_ulike_get_option('posts_group', array());
Counters
wp_ulike_get_counter_value( $ID, $type, $status = 'like', $is_distinct = true, $date_range = null )
Returns formatted counter string for display.
| Param | Values |
|---|---|
$type | post, comment, activity, topic |
$status | like, unlike, dislike, undislike |
$is_distinct | true = distinct voters; false = raw log count |
$date_range | Optional date filter array |
wp_ulike_get_counter_value_info( ... )
Same params — returns raw numeric info array instead of formatted string.
Convenience wrappers
wp_ulike_get_post_likes( $post_id, $status = 'like' );
wp_ulike_get_comment_likes( $comment_id, $status = 'like' );
wp_ulike_get_rating_value( $post_id, $is_distinct = true ) [pro]
Returns approval ratio (0–100) from like/dislike counts — used by Schema Generator.
wp_ulike_format_number( $number, $status = 'like' )
Applies K/M/B compact format and prefix/suffix from General settings.
User vote status
wp_ulike_is_user_liked( $item_id, $user_id, $type = 'likeThis' )
Returns 0 if not voted, >0 if voted.
Third arg $type: 'likeThis', 'dislikeThis', or status-specific checks.
wp_ulike_get_user_item_history( $args )
Returns array keyed by item ID with current vote status.
| Arg | Description |
|---|---|
item_id | Single item or array |
item_type | post, comment, etc. |
current_user | User ID |
settings | Content type settings group |
is_user_logged_in | bool |
Popular items & rankings
wp_ulike_get_popular_items_info( $args )
Returns items with IDs and counts.
wp_ulike_get_popular_items_ids( $args )
Returns ID list only.
wp_ulike_get_popular_items_total_number( $args )
Total matching items count.
Common $args keys:
| Key | Values |
|---|---|
type | post, comment, activity, topic |
rel_type | Related content type |
status | like, dislike, etc. |
period | all, day, week, month, year, today, yesterday, … |
limit | Max items |
offset | Pagination offset |
is_popular | bool |
wp_ulike_get_most_liked_posts( $limit, $post_types, $rel_type, $period, $status )
Legacy helper — returns WP_Post objects.
Likers & engagers
wp_ulike_get_likers_list_per_post( $table, $column, $item_id, $limit )
$table | $column | Content |
|---|---|---|
'ulike' | 'post_id' | Posts |
'ulike_comments' | 'comment_id' | Comments |
'ulike_activities' | 'activity_id' | BuddyPress |
'ulike_forums' | 'topic_id' | bbPress |
Pass $limit = null for all likers.
wp_ulike_get_best_likers_info( $limit, $period, $offset, $status )
Most active voters site-wide.
wp_ulike_get_top_enagers_total_number( $period, $status )
Unique engager count (note: function name uses legacy spelling enagers).
User activity
wp_ulike_get_user_data( $user_id, $args )
Paginated vote history for a user.
Args: period, status (array), page, per_page, type.
wp_ulike_get_user_latest_activity( $item_id, $user_id, $type )
Latest vote row for user on item.
wp_ulike_get_user_item_count_per_day( $args )
Daily vote counts for charts.
Meta data API
wp_ulike_add_meta_data( $object_id, $meta_group, $meta_key, $meta_value, $unique );
wp_ulike_update_meta_data( $object_id, $meta_group, $meta_key, $meta_value, $prev_value );
wp_ulike_get_meta_data( $object_id, $meta_group, $meta_key, $single );
wp_ulike_delete_meta_data( $meta_group, $object_id, $meta_key, $meta_value, $delete_all );
Meta groups: post, comment, activity, topic, user, statistics
Standard WP meta [pro]: like_amount, dislike_amount, net_votes on posts/comments when enabled.
Utilities
| Function | Returns |
|---|---|
wp_ulike_get_the_id( $post_id ) | WPML-aware post ID |
wp_ulike_get_user_ip() | Visitor IP (respects anonymization settings) |
wp_ulike_generate_user_id( $ip ) | Guest fingerprint ID |
wp_ulike_get_button_text( $status, $setting_key ) | Button label from settings |
wp_ulike_is_true( $var ) | Normalized bool check |
wp_ulike_is_cache_exist() | Whether caching flag is on |
wp_ulike_get_log_table_names() | Array of log table suffixes |
Template registration
add_filter('wp_ulike_add_templates_list', function($templates) {
$templates['my-template'] = array(
'name' => 'My Template',
'callback' => 'my_ulike_template',
'is_text_support' => true,
'is_percentage_support' => false, // [pro]
'has_subtotal' => false, // [pro]
);
return $templates;
});
Template callback receives $args with: ID, type, slug, wrapper_class, button_class, up_vote_inner_text, display_counters, formatted_total_likes, and more.
Pro dislike templates also fire: wp_ulike_inside_dislike_button, wp_ulike_after_down_vote_button.
Use: [wp_ulike style="my-template"]
Pro-only helpers (selection)
| Function | Purpose |
|---|---|
wp_ulike_pro_get_current_user_id() | Profile context user ID |
wp_ulike_pro_get_public_template( $name, $user_id ) | Render profile/form templates |
See Hooks & Filters for Pro template, profile, and form action hooks.
Next: Database & Meta · Front-End AJAX
Related articles
Continue with these guides
Did this article help?
Pick how you feel, add a note if you want, then hit Send. It takes two seconds and helps us improve this guide.