/** * function Dvin_Wcql_activate, called at the action hook "register_activation_hook". Creates required tables and sets default preferences */ function Dvin_Wcql_activate() { global $wpdb; //wpdb var //create quotelist page $page_data = array('post_status' => 'publish', 'post_type' => 'page', 'post_author' => 1, 'post_name' => 'Quotelist', 'post_title' => 'Request For a Quote', 'post_content' => '[dvin-wcql-listing][dvin-wcql-form]', 'comment_status' => 'closed'); $quotelistpage_id = wp_insert_post($page_data); update_option('dvin_quotelist_pageid', $quotelistpage_id); //for default settings, if exists, do not create if (get_option('dvin_wcql_email_subject') == '') { Dvin_Wcql_default_settings(); //set default settings (excludes email settings) update_option('dvin_wcql_email_subject', 'Sharing [%req_name%] quotelist'); //if Dvin_Wcql_email_msg not exists if (get_option('dvin_wcql_email_msg') == '') { update_option('dvin_wcql_email_msg', 'Hello, Following is the quote list of the [%req_name%]: [%quotelist%] Comments: [%comments%] Thanks, [%req_name%]'); } //end if } //end if }
/** * function init * @static */ static function init() { //process the form, if submitted for update if (isset($_POST['wcqlupdateSettings'])) { $settings_arr = array(); //get all settings $settings_arr = maybe_unserialize(get_option('dvin_wcql_settings')); $settings_arr['apply_individual_settings'] = isset($_POST['apply_individual_settings']) ? 'on' : ''; $settings_arr['link_position'] = $_POST['link_position']; $settings_arr['link_bgcolor'] = $_POST['link_bgcolor']; $settings_arr['link_fontcolor'] = $_POST['link_fontcolor']; $settings_arr['link_sameas_addtocart_default_colors'] = isset($_POST['link_sameas_addtocart_default_colors']) ? 'on' : ''; $settings_arr['link_sameas_addtocart'] = isset($_POST['link_sameas_addtocart']) ? 'on' : ''; $settings_arr['custom_css'] = $_POST['custom_css']; $settings_arr['show_quotelist_link_always'] = isset($_POST['show_quotelist_link_always']) ? 'on' : ''; $settings_arr['show_on_shop'] = isset($_POST['show_on_shop']) ? 'on' : ''; $settings_arr['no_price'] = isset($_POST['no_price']) ? 'on' : ''; $settings_arr['no_quote_enabled_price'] = isset($_POST['no_quote_enabled_price']) ? 'on' : ''; $settings_arr['show_price_login'] = isset($_POST['show_price_login']) ? 'on' : ''; $settings_arr['no_qty'] = isset($_POST['no_qty']) ? 'on' : ''; $settings_arr['remove_price_col'] = isset($_POST['remove_price_col']) ? 'on' : ''; $settings_arr['use_gravity_forms'] = isset($_POST['use_gravity_forms']) ? 'on' : ''; $settings_arr['gravity_form_select'] = $_POST['gravity_form_select']; $settings_arr['use_formidable_forms'] = isset($_POST['use_formidable_forms']) ? 'on' : ''; $settings_arr['formidable_form_select'] = $_POST['formidable_form_select']; $settings_arr['add_sku_toemail'] = isset($_POST['add_sku_toemail']) ? 'on' : ''; $settings_arr['add_price_toemail'] = isset($_POST['add_price_toemail']) ? 'on' : ''; $settings_arr['dvin_wcql_redirect_url'] = $_POST['dvin_wcql_redirect_url']; $settings_arr['redirect_to_listpage_afteradd'] = isset($_POST['redirect_to_listpage_afteradd']) ? 'on' : ''; $settings_arr['dvin_wcql_quotelist_url'] = $_POST['dvin_wcql_quotelist_url']; $settings_arr['use_contactform7'] = isset($_POST['use_contactform7']) ? 'on' : ''; $settings_arr['contactform7_form_select'] = $_POST['contactform7_form_select']; $settings_arr['create_order'] = isset($_POST['create_order']) ? 'on' : ''; $settings_arr['show_sku_col'] = isset($_POST['show_sku_col']) ? 'on' : ''; //update settings in database update_option('dvin_wcql_settings', maybe_serialize($settings_arr)); //update the custom_styles file file_put_contents(DVIN_QLIST_PLUGIN_URL . "css/custom_styles.css", $_POST['custom_css']); header('Location: ?page=dvinqlistmainpage&updated=true'); exit; } //process the form, if submitted for update if (isset($_POST['updateEmailSettings'])) { if (get_magic_quotes_gpc()) { $_POST['dvin_wcql_email_subject'] = stripslashes($_POST['dvin_wcql_email_subject']); $_POST['dvin_wcql_email_msg'] = stripslashes($_POST['dvin_wcql_email_msg']); } //save the settings update_option('dvin_wcql_email_subject', $_POST['dvin_wcql_email_subject']); update_option('dvin_wcql_email_msg', $_POST['dvin_wcql_email_msg']); update_option('dvin_wcql_admin_email', $_POST['dvin_wcql_admin_email']); update_option('dvin_wcql_copy_toreq', isset($_POST['dvin_wcql_copy_toreq']) ? 'on' : ''); update_option('dvin_wcql_email_tbl_style', $_POST['dvin_wcql_email_tbl_style']); update_option('dvin_wcql_email_tbl_hdr_style', $_POST['dvin_wcql_email_tbl_hdr_style']); update_option('dvin_wcql_email_tbl_row_style', $_POST['dvin_wcql_email_tbl_row_style']); update_option('dvin_wcql_email_tbl_cell_style', $_POST['dvin_wcql_email_tbl_cell_style']); update_option('dvin_wcql_admin_postfix_email', $_POST['dvin_wcql_admin_postfix_email']); header('Location: ?page=dvinqlistmainpage&updated=true'); exit; } //end if //process the form if (isset($_POST['updatemapSettings'])) { unset($_POST['updatemapSettings']); //get all settings $settings_arr = maybe_unserialize(get_option('dvin_wcql_settings')); foreach ($_POST as $key => $val) { $settings_arr['address_fields']["{$key}"] = $val; } update_option('dvin_wcql_settings', maybe_serialize($settings_arr)); $dvin_wcql_settings = maybe_unserialize(get_option('dvin_wcql_settings')); header('Location: ?page=dvinqlistmainpage&updated=true'); exit; } //end if //action to reset to default settings if (isset($_POST['resettodefaultsettings'])) { Dvin_Wcql_default_settings(); header('Location: ?page=dvinqlistmainpage&updated=true'); exit; } }