1. Home
  2. Docs
  3. WTI Like Post PRO
  4. Hooks

Hooks

This plugin also has hooks so that developers can add their custom functionalities.

Thumb styles:

The hook is wti_like_post_style_options which you can use as below

add_filter( 'wti_like_post_style_options', 'wti_like_post_style_options', 10, 2);

function wti_like_post_style_options($style_options, $voting_style) {
    $style_options .= '<option value="style7" ';
    $style_options .= ('style7' == $voting_style) ? 'selected="selected">' : '>';
    $style_options .= 'Style7</option>';
    return $style_options;
}
  • You can upload new icons using the media section with names thumb_up7.png and thumb_down7.png with preferable size 16×32 or 16×36. You can also put these directly in your active theme’s images folder.
  • Then you need to add the above code in your active theme’s functions.php file which will allow you to select an option Style7 in our plugin admin section.
  • Once this is done, you will have to add the related css code for the above style. You can refer to the css for Style1 in our plugin’s css file. You can copy that and make necessary changes. We can help you in providing correct css code.
  • We use css sprite so that it load only one image but you can use 2, one for the page load and another for hover effect.

Vote action:

The hook is wti_like_post_vote_action which you can use as below

// Hook for adding any activity to successful voting
add_action( 'wti_like_post_vote_action', 'wti_like_post_vote_action', 10, 6 );

function wti_like_post_vote_action( $post_id, $ip, $user_id, $task, $msg, $error ) {
	// Put the logic as per your requirement
}

So if you want to notify the site owner about the successful like/unlike activity, then you can send mail here which can include the post details and user details (if only logged in users are allowed to vote). You can also send Thank You mail to the corresponding user. The variables used are:

$post_id: The id of the post/page successfully voted.

$ip: The IP address from where the request was sent.

$user_id: The user id of the logged in user.

$task: The task by the user. It can be like or unlike.

$msg: The plugin generated message.

$error: The response status. Since this hook is for successful voting, it’s value will be 0.

Default message:

// Hook for customizing the default message which shows on page load
add_filter( 'wti_like_post_load_message', 'wti_like_post_load_message', 10, 1 );

function wti_like_post_load_message( $msg ) {
	// Put the logic as per your requirement
}

Vote process message:

// Hook for customizing the ajax message which shows after the vote process
add_filter( 'wti_like_post_ajax_message', 'wti_like_post_ajax_message', 10, 2 );

function wti_like_post_ajax_message( $msg, $error ) {
	// Put the logic as per your requirement
}

How can we help?