function bfox_tool_source_url($post_id = 0, BfoxRef $ref = null)
{
    if (empty($post_id)) {
        $post_id = $GLOBALS['post']->ID;
    }
    $template = bfox_tool_meta('url', $post_id);
    if (empty($template)) {
        if (is_null($ref)) {
            $ref = bfox_ref();
        }
        return add_query_arg('src', true, bfox_ref_url($ref->get_string(), $post_id));
    }
    $linker = bfox_tool_source_linker($ref);
    return $linker->urlForTemplate($template);
}
function bfox_previous_chapter_ref_str($format = '')
{
    $ref = bfox_ref();
    return $ref->prev_chapter_string($format);
}
function bfox_bp_before_activity_post_form()
{
    $ref = bfox_ref();
    $ref_str = $ref->get_string();
    ?>
		<div class="ref-read">
		<label><?php 
    _e('Bible tags', 'bfox');
    ?>
&nbsp;<input type="text" id="bfox_read_ref_str" name="bfox_read_ref_str" value="<?php 
    echo attribute_escape($ref_str);
    ?>
" /></label>
		</div>
	<?php 
}
function bfox_tool_update_ref_str($ref_str)
{
    // Bible Tools need to have a Bible Reference
    $ref = bfox_ref();
    if (!$ref->is_valid()) {
        // If no Bible reference is passed in try to use the last viewed ref
        if (empty($ref_str)) {
            $ref = new BfoxRef(bfox_tool_last_viewed_ref_str());
        } else {
            $ref = new BfoxRef($ref_str);
        }
        // If we still don't have a valid ref, use Genesis 1
        if (!$ref->is_valid()) {
            $ref = new BfoxRef('Genesis 1');
        }
        // Set the active Bible reference
        set_bfox_ref($ref);
    }
    $ref_str = $ref->get_string();
    // Save the ref_str as the last viewed ref str
    bfox_tool_set_last_viewed_ref_str($ref_str);
    return $ref_str;
}
$ref_str = bfox_ref_str();
?>
	<?php 
push_bfox_ref_link_defaults(bfox_ref_link_defaults_update_selector('#bfox-tool-ref-global'));
// Bible links update #bfox-tool-ref-global
?>

	<?php 
if (empty($ref_str)) {
    ?>
		<p>This post currently has no bible references.</p>
	<?php 
} else {
    ?>
		<p>This post is currently referencing: <?php 
    echo bfox_ref_links(bfox_ref());
    ?>
</p>
	<?php 
}
?>

		<p>Add more bible references by typing them into the post, or adding them to the post tags.</p>

		<div id="bible-form" class="bfox-tool-form">
			<input type="text" id="bfox-tool-ref-global" class="field bfox-tool-ref bfox-tool-ref-refresh" name="ref" placeholder="<?php 
esc_attr_e('Search');
?>
" value="<?php 
echo bfox_ref_str(BibleMeta::name_short);
?>
function bfox_bp_plans_add_sidebar()
{
    global $bp;
    if (BFOX_BIBLE_SLUG == bp_current_component() && bp_is_directory() && $bp->loggedin_user->id) {
        $ref = bfox_ref();
        $schedule_ids = bfox_bp_plans_get_active_schedule_ids();
        $revision_ids = array();
        foreach ($schedule_ids as $schedule_id) {
            if ($_schedule->revision_id) {
                $revision_ids[] = $_schedule->revision_id;
            }
        }
        $args = array('show_checks' => true, 'user_id' => $bp->loggedin_user->id);
        ?>
		<div id="bible-readings-for-passage" class="widget">
			<h3 class="widgettitle"><?php 
        printf(__('Readings for %s', 'bfox'), $ref->get_string());
        ?>
</h3>
			<form action="" method="post">
			<?php 
        $checked_ids = bfox_bp_plans_list_readings($schedule_ids, BfoxReadingPlan::get_readings(array('revision_id' => $revision_ids, 'ref' => $ref)), $args);
        ?>
			<input type="hidden" name="bible_reading_plan_old_checks" value="<?php 
        echo implode(',', $checked_ids);
        ?>
" />
			<input type="submit" name="bible_reading_save_checks" value="<?php 
        _e('Save', 'bfox');
        ?>
" />
			</form>
		</div>
		<?php 
    }
}
			</header><!-- .entry-header -->

			<nav class='passage-nav'>
				<div class="nav-previous"><?php 
echo bfox_ref_link(bfox_previous_chapter_ref_str());
?>
</div>
				<div class="nav-next"><?php 
echo bfox_ref_link(bfox_next_chapter_ref_str());
?>
</div>
			</nav><!-- #nav-above -->

			<div class="entry-content">
				<?php 
$tool->echoContentForRef(bfox_ref());
?>
			</div><!-- .entry-content -->

			<nav class='passage-nav'>
				<div class="nav-previous"><?php 
echo bfox_ref_link(bfox_previous_chapter_ref_str());
?>
</div>
				<div class="nav-next"><?php 
echo bfox_ref_link(bfox_next_chapter_ref_str());
?>
</div>
			</nav><!-- #nav-above -->

		</article><!-- #bfox_bible-<?php