This topic has 4 replies, 3 voices, and was last updated 9 years by efullman.

  • Author

    Tagged: ,

  • #78697
     efullman
    Participant

    Hi,

    I was hoping to add the kleo likes item to Buddypress Activity. (<?php get_template_part( ‘page-parts/posts-social-share-small’ ); ?>)

    I would love to stick it in the entry loop. I can get it to show, but it shows every activity with the same number of likes. I don’t think it’s getting a post-id it can use.

    Any thoughts.

    Thanks.

    #78788
     Radu
    Moderator

    Hi,

    Unfortunately this is not possible but i recommend you to test this plugin : https://wordpress.org/plugins/buddypress-like/

    Regards

    Radu

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #78814
     efullman
    Participant

    Radu,

    I tried that plugin, and it just came up with a white screen.

    Looking through the Items-Like.php code it seems like you could get it to stop looking at the Post_id and repurpose it to look at bp_activity_id() and install the call for post-social-share.php in the entry.php file as the activity loop calls it to iterate, I was thinking that it would know the post_id. I guess the challenge might be clicking on the heart, and having it grab the activity_id. My thought was to create a BP version of post-social-share and items-like.php.

    If you think that would work, my only challenge is how to get the bp_activity_id() into the process.

    This seems like the key part


    function do_likes_bp( $post_id = null )
    {
    if ( ! $post_id ) {
    global $post;
    $post_id = $post->ID;
    }

    if ( defined('ICL_SITEPRESS_VERSION') ){
    global $sitepress;
    $post_id = icl_object_id( $post_id, 'post', true, $sitepress->get_default_language() );
    }

    $output = $this->like_this_bp($post_id, sq_option('likes_zero_text', ''), sq_option('likes_one_text', ''), sq_option('likes_more_text', ''));

    $class = 'item-likes';
    $title = sq_option('like_this_text', 'Like this');
    if( isset($_COOKIE['item_likes_'. $post_id]) ){
    $class = 'item-likes liked';
    $title = sq_option('likes_already', 'You already like this');
    }

    return ''. $output .'';
    }

    Any thoughts?

    #80006
     Andrei
    Moderator

    @efullman, yes the code could be adapted but it’s better to use radu’s suggestion.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #81321
     efullman
    Participant

    I got that code to work. However, the posted plugin actually has include files missing so it won’t actually run. I had to download the develop branch off the Github for this plugin and then debug a few things.

    However, now it works. I wouldn’t direct anyone to WordPress Plugins to download this directly.

Viewing 5 posts - 1 through 5 (of 5 total)

The forum ‘General questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?