Пример #1
0
function hookpress_ajax_set_enabled()
{
    $nonce = $_POST['_nonce'];
    $id = $_POST['id'];
    $enabled = $_POST['enabled'];
    $nonce_compare = $enabled == 'true' ? 'activate-webhook-' . $id : 'deactivate-webhook-' . $id;
    if (wp_verify_nonce($nonce, $nonce_compare)) {
        // update the webhook
        $webhooks = hookpress_get_hooks();
        $webhooks[$id]['enabled'] = $enabled == 'true' ? true : false;
        hookpress_update_hook($id, $webhooks[$id]);
    }
    header("Content-Type: text/html; charset=UTF-8");
    echo hookpress_print_webhook_row($id);
    exit;
}
Пример #2
0
function hookpress_print_webhooks_table()
{
    global $page;
    $webhooks = null;
    #	$webhooks = get_option('hookpress_webhooks');
    $webhooks = hookpress_get_hooks();
    ?>
<table class="widefat" cellspacing="0" id="webhooks">
	<thead>
	<tr>
		<th scope="col" class="manage-column" style="width:15%"><?php 
    _e("Hook", "hookpress");
    ?>
</th>
		<th scope="col" class="manage-column" style="width:25%"><?php 
    _e("URL", "hookpress");
    ?>
</th>
		<th scope="col" class="manage-column"><?php 
    _e("Fields", "hookpress");
    ?>
</th>
	</tr>
	</thead>

	<tfoot>
	<tr>
		<th scope="col" class="manage-column"><?php 
    _e("Hook", "hookpress");
    ?>
</th>
		<th scope="col" class="manage-column"><?php 
    _e("URL", "hookpress");
    ?>
</th>
		<th scope="col" class="manage-column"><?php 
    _e("Fields", "hookpress");
    ?>
</th>
	</tr>
	</tfoot>

	<tbody class="webhooks">
<?php 
    if (!empty($webhooks)) {
        foreach ((array) $webhooks as $id => $desc) {
            if (!empty($desc)) {
                hookpress_print_webhook_row($id);
            }
        }
    }
    ?>
	</tbody>
</table>
<?php 
}