-
Notifications
You must be signed in to change notification settings - Fork 1
/
bfox_tool.php
41 lines (31 loc) · 922 Bytes
/
bfox_tool.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/*
Theme Templates
*/
function update_selected_bfox_tool() {
if (is_singular('bfox_tool')) {
global $post, $_selected_bfox_tool_post_id;
$_selected_bfox_tool_post_id = $post->ID;
$_COOKIE['selected_bfox_tool'] = $post->ID;
setcookie('selected_bfox_tool', $_COOKIE['selected_bfox_tool'], /* 30 days from now: */ time() + 60 * 60 * 24 * 30, '/');
}
}
add_action('wp', 'update_selected_bfox_tool');
function bfox_tool_shortcode($atts) {
// [bible-tool tool="esv" ref="Matthew 1"]
extract( shortcode_atts( array(
'tool' => '',
'ref' => '',
), $atts ) );
$bfoxTools = BfoxBibleToolController::sharedInstance();
$tool = $bfoxTools->toolForShortName($tool);
if (is_null($tool)) return;
$ref = new BfoxRef($ref);
if (!$ref->is_valid()) return;
ob_start();
$tool->echoContentForRef($ref);
$content = ob_get_clean();
return $content;
}
add_shortcode('bible-tool', 'bfox_tool_shortcode');
?>