/** * Finds any bible references in an array of tag links and adds tooltips to them * * Should be used to filter 'term_links-post_tag', called in get_the_term_list() * * @param array $tag_links * @return array */ function bfox_add_tag_ref_tooltips($tag_links) { if (!empty($tag_links)) { foreach ($tag_links as &$tag_link) { if (preg_match('/<a.*>(.*)<\\/a>/', $tag_link, $matches)) { $tag = $matches[1]; $ref = bfox_ref_from_tag($tag); if ($ref->is_valid()) { $tag_link = bfox_ref_link($ref->get_string(), array('text' => $tag)); } } } } return $tag_links; }
/** * Calculates the bible references for an activity before it is saved * * @param $activity */ function bfox_bp_activity_before_save($activity) { global $bp; // For blog posts, index the full post content and tags if ($activity->component == $bp->blogs->id && $activity->type == 'new_blog_post') { switch_to_blog($activity->item_id); $ref = bfox_blog_post_get_ref($activity->secondary_item_id); restore_current_blog(); } elseif ($activity->component == $bp->groups->id && ($activity->type == 'new_forum_post' || $activity->type == 'new_forum_topic')) { // Get the forum post if ($activity->type == 'new_forum_topic') { list($post) = bp_forums_get_topic_posts(array('topic_id' => $activity->secondary_item_id, 'per_page' => 1)); } else { $post = bp_forums_get_post($activity->secondary_item_id); } // Index the post text $ref = bfox_ref_from_content($post->post_text); // Only index the tags for the first post in a topic if ($activity->type == 'new_forum_topic') { $tags = bb_get_topic_tags($post->topic_id, array('fields' => 'names')); foreach ($tags as $tag) { $ref->add_ref(bfox_ref_from_tag($tag)); } } } else { $ref = bfox_ref_from_content($activity->content); } // Add any 'Bible Tag' read passage strings if ('activity_update' == $activity->type && isset($_REQUEST['bfox_read_ref_str'])) { $tag_ref = new BfoxRef($_REQUEST['bfox_read_ref_str']); if ($tag_ref->is_valid()) { $activity->bfox_read_ref_str = $tag_ref->get_string(); $activity->action = str_replace('posted an update', __('posted an update about ', 'bfox') . $activity->bfox_read_ref_str, $activity->action); $ref->add_ref($tag_ref); } } if ($ref->is_valid()) { $activity->bfox_ref = $ref; } }