Exemple #1
0
/**
 * Plugin activation hook
 */
function iphorm_activate()
{
    // Create the database table
    global $wpdb;
    require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    $formsTable = iphorm_get_form_table_name();
    $formEntriesTable = iphorm_get_form_entries_table_name();
    $formEntryDataTable = iphorm_get_form_entry_data_table_name();
    $charset = '';
    if (!empty($wpdb->charset)) {
        $charset .= "DEFAULT CHARACTER SET {$wpdb->charset}";
    }
    if (!empty($wpdb->collate)) {
        $charset .= " COLLATE {$wpdb->collate}";
    }
    $sql = "CREATE TABLE {$formsTable} (\r\n        id int UNSIGNED NOT NULL AUTO_INCREMENT,\r\n        config longtext NOT NULL,\r\n        active boolean NOT NULL DEFAULT 1,\r\n        PRIMARY KEY  (id)\r\n    ) " . $charset . ";";
    dbDelta($sql);
    $sql = "CREATE TABLE {$formEntriesTable} (\r\n        id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,\r\n        form_id int(11) UNSIGNED NOT NULL,\r\n        unread tinyint (1) UNSIGNED NOT NULL DEFAULT 1,\r\n        date_added datetime NOT NULL,\r\n        ip varchar(32) NOT NULL,\r\n        form_url varchar(512) NOT NULL,\r\n        referring_url varchar(512) NOT NULL,\r\n        post_id varchar(32) NOT NULL,\r\n        post_title varchar(128) NOT NULL,\r\n        user_display_name varchar(128) NOT NULL,\r\n        user_email varchar(128) NOT NULL,\r\n        user_login varchar(128) NOT NULL,\r\n        PRIMARY KEY  (id),\r\n        KEY form_id (form_id)\r\n    ) " . $charset . ";";
    dbDelta($sql);
    $sql = "CREATE TABLE {$formEntryDataTable} (\r\n        entry_id int(11) UNSIGNED NOT NULL,\r\n        element_id int(11) UNSIGNED NOT NULL,\r\n        value text,\r\n        PRIMARY KEY  (entry_id,element_id),\r\n        KEY element_id (element_id)\r\n    ) " . $charset . ";";
    dbDelta($sql);
    // Give the administrator capabilities to manage forms
    $role = get_role('administrator');
    if (!empty($role)) {
        $allCaps = iphorm_get_all_capabilities();
        foreach ($allCaps as $cap) {
            $role->add_cap($cap);
        }
    }
    // Schedule the upload cleanup cron job
    if (!wp_next_scheduled('iphorm_upload_cleanup')) {
        wp_schedule_event(time(), 'twicedaily', 'iphorm_upload_cleanup');
    }
    // Create the options
    add_option('iphorm_recaptcha_site_key', '');
    add_option('iphorm_recaptcha_secret_key', '');
    add_option('iphorm_active_themes', array());
    add_option('iphorm_active_uniform_themes', array());
    add_option('iphorm_active_datepickers', array());
    add_option('iphorm_hide_nag_message', 0);
    add_option('iphorm_licence_key', '');
    add_option('iphorm_email_sending_method', 'mail');
    add_option('iphorm_smtp_settings', array('host' => '', 'port' => 25, 'encryption' => '', 'username' => '', 'password' => ''));
    add_option('iphorm_email_returnpath', '');
    add_option('iphorm_disable_fancybox_output', 0);
    add_option('iphorm_fancybox_requested', 0);
    add_option('iphorm_disable_uniform_output', 0);
    add_option('iphorm_disable_qtip_output', 0);
    add_option('iphorm_disable_infieldlabels_output', 0);
    add_option('iphorm_disable_smoothscroll_output', 0);
    add_option('iphorm_disable_jqueryui_output', 0);
    add_option('iphorm_disable_uniform_output', 0);
    add_option('iphorm_disable_swfupload_output', 0);
    $dbVersion = get_option('iphorm_db_version');
    if ($dbVersion !== false) {
        // This isn't a first install, so process any upgrades if required
        if ($dbVersion < 4) {
            iphorm_upgrade_4();
        }
        if ($dbVersion < 6) {
            iphorm_upgrade_6();
        }
        if ($dbVersion < 7) {
            iphorm_upgrade_7();
        }
        if ($dbVersion < 10) {
            iphorm_upgrade_10();
        }
        // Save the new DB version
        update_option('iphorm_db_version', IPHORM_DB_VERSION);
    } else {
        // This is a first install, add the DB version option
        add_option('iphorm_db_version', IPHORM_DB_VERSION);
    }
    iphorm_update_active_themes();
}
Exemple #2
0
    $savedSmtpSettings = get_option('iphorm_smtp_settings');
    update_option('iphorm_recaptcha_site_key', sanitize_text_field(stripslashes($_POST['recaptcha_site_key'])));
    update_option('iphorm_recaptcha_secret_key', sanitize_text_field(stripslashes($_POST['recaptcha_secret_key'])));
    update_option('iphorm_email_sending_method', $_POST['global_email_sending_method']);
    update_option('iphorm_smtp_settings', array('host' => stripslashes($_POST['smtp_host']), 'port' => stripslashes($_POST['smtp_port']), 'encryption' => $_POST['smtp_encryption'], 'username' => stripslashes($_POST['smtp_username']), 'password' => isset($_POST['smtp_password']) ? stripslashes($_POST['smtp_password']) : $savedSmtpSettings['password']));
    update_option('iphorm_email_returnpath', sanitize_text_field(stripslashes($_POST['email_returnpath'])));
    update_option('iphorm_disable_fancybox_output', isset($_POST['disable_fancybox_output']) && $_POST['disable_fancybox_output'] == 1);
    update_option('iphorm_disable_qtip_output', isset($_POST['disable_qtip_output']) && $_POST['disable_qtip_output'] == 1);
    update_option('iphorm_disable_infieldlabels_output', isset($_POST['disable_infieldlabels_output']) && $_POST['disable_infieldlabels_output'] == 1);
    update_option('iphorm_disable_smoothscroll_output', isset($_POST['disable_smoothscroll_output']) && $_POST['disable_smoothscroll_output'] == 1);
    update_option('iphorm_disable_jqueryui_output', isset($_POST['disable_jqueryui_output']) && $_POST['disable_jqueryui_output'] == 1);
    update_option('iphorm_disable_uniform_output', isset($_POST['disable_uniform_output']) && $_POST['disable_uniform_output'] == 1);
    update_option('iphorm_disable_swfupload_output', isset($_POST['disable_swfupload_output']) && $_POST['disable_swfupload_output'] == 1);
    update_option('iphorm_fancybox_requested', isset($_POST['fancybox_requested']) && $_POST['fancybox_requested'] == 1);
    if (isset($_POST['iphorm_update']) && $_POST['iphorm_update'] == '1') {
        iphorm_update_active_themes();
    }
    ?>
        <div class="updated below-h2" id="message">
            <p><?php 
    esc_html_e('Settings saved.', 'iphorm');
    ?>
</p>
        </div>
    <?php 
}
?>
    <form method="post" action="">
        <h3 class="ifb-sub-head"><span><?php 
esc_html_e('Product license', 'iphorm');
?>