Home Forums WTI Like Post PRO Change Like this and Dislike this text for some categories

  • This topic has 1 reply, 1 voice, and was last updated 8 years ago by D.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #400
    D
    Participant

    I’m trying to change the text print out after each vote is processed. USERNAME Like This and User Name Dislike to my own custom text but only for specified categories. I would still however like to keep User Name Like This and Dislike like this for others Categories. How can I go about this. I’ve already tried this from the plugin documentation and nothing happened.

    // 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 ) {
    $categories = wp_get_post_categories( $post_id );
    $ex_categories = array(7,183,184);
    if ( count( array_intersect( $ex_categories, $categories ) ) > 0 )
    {
    $msg = 'Voted to Create this';
    }
    return $msg;
    }
    

    // Hook for customizing the ajax message which shows after the vote process

    add_filter( 'wti_like_post_ajax_message_dont_make', 'wti_like_post_ajax_message', 10, 2 );
    function wti_like_post_ajax_message_dont_make( $msg, $error ) {
    $categories = wp_get_post_categories( $post_id );
    $ex_categories = array(7,183,184);
    if ( count( array_intersect( $ex_categories, $categories ) ) > 0 )
    {
    $msg = 'Voted to Not Create this';
    }
    return $msg;
    }
    #426
    D
    Participant

    Figured it out, thanks for the push and the help Web Techies. I’m posting the solution for anyone that might want this functionality: in wti_like_post.php
    locate:

    $wti_user_likes .= ($users_count > 1 || ($users_count == 1 && $flag == true)) ? __('like this', 'wti-like-post') : __('likes this', 'wti-like-post');
    

    copy this line of code giving you two lines of the same block of code, one to customize for your own text targeting specified categories and the other to leave the same for remaining categories. When you’re finished your code block should look like this, with targeting categories:

    
    $my_cat_ids = array(PLACE CATEGORY NUMBERS HERE);
    $category_ids = wp_get_post_categories( $post_id );
    $match_array = array_intersect( $my_cat_ids, $category_ids );
    if ( !empty( $match_array ) ) {
    
    $wti_user_likes .= ($users_count > 1 || ($users_count == 1 && $flag == true)) ? __('MY CUSTOM TEXT', 'wti-like-post') : __('MY CUSTOM TEXT', 'wti-like-post');
    
    }else{
    
    $wti_user_likes .= ($users_count > 1 || ($users_count == 1 && $flag == true)) ? __('like this', 'wti-like-post') : __('likes this', 'wti-like-post');
    
    } ADDED CLOSING BRACKET
     }
       }
    • This reply was modified 8 years ago by D.
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘WTI Like Post PRO’ is closed to new topics and replies.