Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)

  • Carco
    Participant

    @carco

    all right on my site
    here is the complete code
    maybe this will help

    http://pastebin.com/LiyXA2WS


    Carco
    Participant

    @carco

    function bp_like_check_installed() {
    global $wpdb;

    if ( !is_site_admin() )
    return false;

    if ( !get_site_option( ‘bp_like_settings’ ) || get_site_option( ‘bp-like-db-version’ ) )
    bp_like_install();

    if ( get_site_option( ‘bp_like_db_version’ ) < BP_LIKE_DB_VERSION )
    bp_like_install();
    }
    add_action( ‘admin_menu’, ‘bp_like_check_installed’ );
    add_action( ‘network_admin_menu’, ‘bp_like_check_installed’ );

    /**
    * for notifications
    */

    function bp_like_setup_globals() {
    global $bp, $current_blog;
    $bp->bp_like=new stdClass();
    $bp->bp_like->id = ‘bp-like’;
    $bp->bp_like->slug = ‘bp_like’;
    $bp->bp_like->notification_callback = ‘bp_like_format_notifications’;
    $bp->active_components[$bp->bp_like->slug] = $bp->bp_like->id;
    do_action( ‘bp_like_setup_globals’ );
    }
    add_action( ‘bp_setup_globals’, ‘bp_like_setup_globals’ );

    function bp_like_format_notifications( $action, $item_id, $secondary_item_id, $total_items,$format=’string’) {
    global $bp;
    $glue=”;
    $user_names=array();
    $activity = new BP_Activity_Activity( $item_id );
    $link=like_notifier_activity_get_permalink( $item_id );

    if($activity->user_id==$bp->loggedin_user->id){
    $text=__(“your”);
    $also=””;
    }
    else{
    $text=sprintf(__(“%s’s”), bp_core_get_user_displayname ($activity->user_id));//somone’s
    $also=” also”;
    }

    $users = array_keys( bp_activity_get_meta( $item_id, ‘liked_count’ ) );
    $total_user= $count=count($users);

    if ($count==0){
    bp_core_delete_notifications_by_item_id( $bp->loggedin_user->id, $activity->id, $bp->bp_like->slug, ‘new_bp_like_’.$activity->id);
    }

    if($count>2){
    $users=array_slice($users, $count-2);
    $count=$count-2;
    $glue=”, “;
    }

    else if($total_user==2)
    $glue=” and “;

    foreach((array)$users as $id)
    $user_names[]=bp_core_get_user_displayname ($id);

    if(!empty($user_names))
    $commenting_users=join ($glue, $user_names);
    else
    $commenting_users=”Somebody remove it after”;

    if($total_user>2)
    $text=$commenting_users.” and “.$count.” others”.$also.” liked on “.$text. ” post”;
    else
    $text=$commenting_users.$also .” liked on “.$text. ” post”;

    return array(‘link’=>$link,
    ‘text’=>$text);

    }

    function like_notifier_activity_get_permalink( $activity_id, $activity_obj = false ) {
    global $bp;

    if ( !$activity_obj )
    $activity_obj = new BP_Activity_Activity( $activity_id );

    $link = bp_get_activity_directory_permalink() . ‘p/’ . $activity_obj->id . ‘/’;

    return apply_filters( ‘like_notifier_activity_get_permalink’, $link );
    }

    function like_notifier_remove_notification($activity,$has_access){
    global $bp;
    if($has_access)
    bp_core_delete_notifications_by_item_id( $bp->loggedin_user->id, $activity->id, $bp->bp_like->slug, ‘new_bp_like_’.$activity->id);

    }
    add_action(“bp_activity_screen_single_activity_permalink”,”like_notifier_remove_notification”,10,2);

    ….

    bp_core_add_notification( $item_id, $activity[‘activities’][0]->user_id, $bp->bp_like->slug, ‘new_bp_like_’.$item_id );

Viewing 2 replies - 1 through 2 (of 2 total)
Skip to toolbar