Exemplo n.º 1
0
function dk_speakup_settings_page()
{
    // security check
    if (!current_user_can('manage_options')) {
        wp_die('Insufficient privileges: You need to be an administrator to do that.');
    }
    include_once 'class.speakup.php';
    include_once 'class.settings.php';
    include_once 'class.wpml.php';
    $the_settings = new dk_speakup_Settings();
    $wpml = new dk_speakup_WPML();
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
    $tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : 'dk-speakup-tab-01';
    switch ($action) {
        case 'update':
            // security check
            check_admin_referer('dk_speakup-update_settings');
            $the_settings->update();
            $the_settings->retrieve();
            // attempt to resgister strings for translation in WPML
            $options = get_option('dk_speakup_options');
            $wpml->register_options($options);
            $message_update = __('Settings updated.', 'dk_speakup');
            break;
        default:
            $the_settings->retrieve();
            $message_update = '';
    }
    $nonce = 'dk_speakup-update_settings';
    $action = 'update';
    include_once dirname(__FILE__) . '/settings.view.php';
}
Exemplo n.º 2
0
function dk_speakup_install()
{
    global $wpdb, $db_petitions, $db_signatures, $dk_speakup_version;
    dk_speakup_translate();
    $sql_create_tables = "\n\t\tCREATE TABLE `{$db_petitions}` (\n\t\t\t`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t`title` TEXT CHARACTER SET utf8 NOT NULL,\n\t\t\t`target_email` VARCHAR(300) CHARACTER SET utf8 NOT NULL,\n\t\t\t`email_subject` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\n\t\t\t`greeting` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\n\t\t\t`petition_message` LONGTEXT CHARACTER SET utf8 NOT NULL,\n\t\t\t`address_fields` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\n\t\t\t`expires` CHAR(1) BINARY NOT NULL,\n\t\t\t`expiration_date` DATETIME NOT NULL,\n\t\t\t`created_date` DATETIME NOT NULL,\n\t\t\t`goal` INT(11) NOT NULL,\n\t\t\t`sends_email` CHAR(1) BINARY NOT NULL,\n\t\t\t`twitter_message` VARCHAR(120) CHARACTER SET utf8 NOT NULL,\n\t\t\t`requires_confirmation` CHAR(1) BINARY NOT NULL,\n\t\t\t`return_url` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\n\t\t\t`displays_custom_field` CHAR(1) BINARY NOT NULL,\n\t\t\t`custom_field_label` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\n\t\t\t`displays_optin` CHAR(1) BINARY NOT NULL,\n\t\t\t`optin_label` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\n\t\t\t`is_editable` CHAR(1) BINARY NOT NULL,\n\t\t\tUNIQUE KEY  (`id`)\n\t\t);\n\t\tCREATE TABLE `{$db_signatures}` (\n\t\t\t`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t`petitions_id` BIGINT(20) NOT NULL,\n\t\t\t`first_name` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\n\t\t\t`last_name` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\n\t\t\t`email` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\n\t\t\t`street_address` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\n\t\t\t`city` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\n\t\t\t`state` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\n\t\t\t`postcode` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\n\t\t\t`country` VARCHAR(200) CHARACTER SET utf8 NOT NULL,\n\t\t\t`custom_field` VARCHAR(400) CHARACTER SET utf8 NOT NULL,\n\t\t\t`optin` CHAR(1) BINARY NOT NULL,\n\t\t\t`date` DATETIME NOT NULL,\n\t\t\t`confirmation_code` VARCHAR(32) NOT NULL,\n\t\t\t`is_confirmed` CHAR(1) BINARY NOT NULL,\n\t\t\t`custom_message` LONGTEXT CHARACTER SET utf8 NOT NULL,\n\t\t\t`language` VARCHAR(10) CHARACTER SET utf8 NOT NULL,\n\t\t\tUNIQUE KEY  (`id`)\n\t\t);";
    // create database tables
    require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    dbDelta($sql_create_tables);
    // set default options
    $options = array("petitions_rows" => "20", "signatures_rows" => "50", "petition_theme" => "default", "button_text" => __("Sign Now", "dk_speakup"), "expiration_message" => __("This petition is now closed.", "dk_speakup"), "success_message" => "<strong>" . __("Thank you", "dk_speakup") . ", %first_name%.</strong>\r\n<p>" . __("Your signature has been added.", "dk_speakup") . "</p>", "already_signed_message" => __("This petition has already been signed using your email address.", "dk_speakup"), "share_message" => __("Share this with your friends:", "dk_speakup"), "confirm_subject" => __("Please confirm your email address", "dk_speakup"), "confirm_message" => __("Hello", "dk_speakup") . " %first_name%\r\n\r\n" . __("Thank you for singing our petition", "dk_speakup") . ". " . __("Please confirm your email address by clicking the link below:", "dk_speakup") . "\r\n%confirmation_link%\r\n\r\n" . get_bloginfo("name"), "confirm_email" => get_bloginfo("name") . " <" . get_bloginfo("admin_email") . ">", "optin_default" => "unchecked", "display_count" => "1", "signaturelist_theme" => "default", "signaturelist_header" => __("Latest Signatures", "dk_speakup"), "signaturelist_rows" => "50", "signaturelist_columns" => serialize(array("sig_date")), "widget_theme" => "default", "csv_signatures" => "all");
    // add plugin options to wp_options table
    add_option('dk_speakup_options', $options);
    add_option('dk_speakup_version', $dk_speakup_version);
    // register options for translation in WPML
    include_once 'class.wpml.php';
    $wpml = new dk_speakup_WPML();
    $wpml->register_options($options);
}