예제 #1
0
function bfox_tool_content_ajax()
{
    header('Content-Type: application/json');
    $context = $_REQUEST['context'];
    if (empty($context)) {
        echo json_encode(array('html' => 'Invalid Context'));
        exit;
    }
    if (!wp_verify_nonce($_REQUEST['nonce'], 'bfox-tool-context-' . $context)) {
        echo json_encode(array('html' => 'Context failed nonce verification'));
        exit;
    }
    bfox_tool_update_ref_str(urldecode($_REQUEST['ref']));
    bfox_tool_update_tool(urldecode($_REQUEST['tool']));
    if (!empty($_REQUEST['id'])) {
        // Bible links update the same id that was just updated
        push_bfox_ref_link_defaults(bfox_ref_link_defaults_update_selector('#' . $_REQUEST['id']));
    }
    ob_start();
    load_bfox_template('content-bfox_tool');
    $html = ob_get_clean();
    $nonce = bfox_tool_context_nonce($context);
    $response = json_encode(array('html' => $html, 'dataUrl' => bfox_tool_context_ajax_url($context, $nonce), 'nonce' => $nonce));
    echo $response;
    exit;
}
<?php

/**
 * The template for displaying Bible Tools on the Edit Post admin screen.
 *
 */
$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">