/** * @param string $title */ public function check_mentions($question_id, $contents, $title, $user_id, $type, $answer_id = 0) { $users = ap_find_mentioned_users($contents); if (false !== $users) { $user_title = ap_activity_user_name($user_id); foreach ($users as $user) { if ($user->id != $user_id) { $activity_arr = array('user_id' => $user_id, 'type' => 'mention', 'secondary_user' => $user->id, 'question_id' => $question_id, 'answer_id' => $answer_id, 'permalink' => wp_get_shortlink($question_id), 'content' => sprintf(__('%s mentioned you in %s %s', 'anspress-question-answer'), $user_title, $type, $title)); $activity_id = ap_new_activity($activity_arr); ap_new_notification($activity_id, $user->id); } } } }
/** * Insert activity about new follower * @param integer $user_to_follow Whom to follow. * @param integer $current_user_id Current user ID. */ public function follower($user_to_follow, $current_user_id) { $activity_arr = array('user_id' => $user_to_follow, 'type' => 'follower', 'secondary_user' => $current_user_id, 'item_id' => $current_user_id, 'parent_type' => 'user', 'permalink' => ap_user_link($user_to_follow), 'content' => sprintf(__('%s started following %s', 'ap'), ap_activity_user_name($current_user_id), ap_activity_user_name($user_to_follow))); $activity_id = ap_new_activity($activity_arr); ap_new_notification($activity_id, $user_to_follow); }