示例#1
0
function dk_speakup_paginate_signaturelist()
{
    include_once 'class.signaturelist.php';
    $list = new dk_speakup_Signaturelist();
    $table = $list->table($_POST['id'], $_POST['start'], $_POST['limit'], 'ajax', $_POST['dateformat']);
    echo $table;
    // end AJAX processing
    die;
}
function dk_speakup_signatures_shortcode($attr)
{
    include_once 'class.signaturelist.php';
    $options = get_option('dk_speakup_options');
    $id = 1;
    $rows = $options['signaturelist_rows'];
    $nextbuttontext = '>';
    $prevbuttontext = '<';
    $dateformat = 'M d, Y';
    if (isset($attr['id']) && is_numeric($attr['id'])) {
        $id = $attr['id'];
    }
    if (isset($attr['rows']) && is_numeric($attr['rows'])) {
        $rows = absint($attr['rows']);
    }
    if (isset($attr['nextbuttontext'])) {
        $nextbuttontext = $attr['nextbuttontext'];
    }
    if (isset($attr['prevbuttontext'])) {
        $prevbuttontext = $attr['prevbuttontext'];
    }
    if (isset($attr['dateformat'])) {
        $dateformat = $attr['dateformat'];
    }
    // make sure ajax callback url works on both https and http
    $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
    $params = array('ajaxurl' => admin_url('admin-ajax.php', $protocol), 'dateformat' => $dateformat);
    wp_enqueue_script('dk_speakup_signaturelist_js', plugins_url('speakup-email-petitions/js/signaturelist.js'), array('jquery'));
    wp_localize_script('dk_speakup_signaturelist_js', 'dk_speakup_signaturelist_js', $params);
    $table_html = dk_speakup_Signaturelist::table($id, 0, $rows, 'shortcode', $dateformat, $nextbuttontext, $prevbuttontext);
    return $table_html;
}