/** * function Form, displays the form * @param $atts Array - an associative array of attributes (preferences) * @param $content String - the enclosed content * @param $code String - the shortcode name * @code * @static */ static function form($atts, $content = null, $code = "") { global $dvin_wcql_settings, $dvin_qlist_products; if (!isset($_POST['qlist_process'])) { if (!isset($dvin_qlist_products) || isset($dvin_qlist_products) && count($dvin_qlist_products) == 0) { return; } } if (isset($dvin_wcql_settings['use_gravity_forms']) && $dvin_wcql_settings['use_gravity_forms'] == 'on') { return do_shortcode('[gravityform id="' . $dvin_wcql_settings['gravity_form_select'] . '" title=false description=false ajax="true"]'); } else { if (isset($dvin_wcql_settings['use_formidable_forms']) && $dvin_wcql_settings['use_formidable_forms'] == 'on') { return do_shortcode('[formidable id="' . $dvin_wcql_settings['formidable_form_select'] . '"]'); } else { if (isset($dvin_wcql_settings['use_contactform7']) && $dvin_wcql_settings['use_contactform7'] == 'on') { return do_shortcode('[contact-form-7 id="' . $dvin_wcql_settings['contactform7_form_select'] . '"]'); } else { ob_start(); if (file_exists(TEMPLATEPATH . '/' . Dvin_Wcql::template_path() . 'templates/form.php')) { include TEMPLATEPATH . '/' . Dvin_Wcql::template_path() . 'templates/form.php'; } elseif (file_exists(STYLESHEETPATH . '/' . Dvin_Wcql::template_path() . 'templates/form.php')) { include STYLESHEETPATH . '/' . Dvin_Wcql::template_path() . 'templates/form.php'; } else { echo '<div class="woocommerce">'; include 'templates/form.php'; echo '</div>'; } return ob_get_clean(); } } } }
public static function dvin_qlist_validate_form() { global $dvin_qlist_products; $errors = array(); //validate the form if (isset($_POST['req_name']) && trim($_POST['req_name']) == '') { $errors[] = __("Please enter ", 'dvinwcql') . __('Name', 'dvinwcql'); } if (isset($_POST['req_email']) && trim($_POST['req_email']) == '') { $errors[] = __("Please enter ", 'dvinwcql') . __('Email', 'dvinwcql'); } else { if (isset($_POST['req_email'])) { $regex = '/^[_a-zA-Z0-9-]+(\\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*(\\.[a-zA-Z]{2,63})$/'; // Run the preg_match() function on regex against the email address if (!preg_match($regex, $_POST['req_email'])) { $errors[] = "Please enter valid " . __('Email', 'dvinwcql'); } } } //apply filters for to do validations for the custom fileds $errors = apply_filters('dvin_wcql_custom_fields_validation', $errors); //include the validation file if exists if (file_exists(TEMPLATEPATH . '/' . Dvin_Wcql::template_path() . 'form-validation.php')) { include TEMPLATEPATH . '/' . Dvin_Wcql::template_path() . 'form-validation.php'; } elseif (file_exists(STYLESHEETPATH . '/' . Dvin_Wcql::template_path() . 'form-validation.php')) { include STYLESHEETPATH . '/' . Dvin_Wcql::template_path() . 'form-validation.php'; } return $errors; }
function get_qlist_table($atts) { global $dvin_qlist_products, $dvin_wcql_settings; //get the all the style values $dvin_wcql_email_tbl_style = get_option('dvin_wcql_email_tbl_style'); $dvin_wcql_email_tbl_hdr_style = get_option('dvin_wcql_email_tbl_hdr_style'); $dvin_wcql_email_tbl_row_style = get_option('dvin_wcql_email_tbl_row_style'); $dvin_wcql_email_tbl_cell_style = get_option('dvin_wcql_email_tbl_cell_style'); //get all the required variables $add_sku_toemail = isset($dvin_wcql_settings['add_sku_toemail']) ? $dvin_wcql_settings['add_sku_toemail'] : ''; $remove_price_col = isset($dvin_wcql_settings['remove_price_col']) ? $dvin_wcql_settings['remove_price_col'] : ''; $no_qty = isset($dvin_wcql_settings['no_qty']) ? $dvin_wcql_settings['no_qty'] : ''; $add_price_toemail = isset($dvin_wcql_settings['add_price_toemail']) ? $dvin_wcql_settings['add_price_toemail'] : ''; $add_price_col = $remove_price_col != 'on' || $add_price_toemail == 'on' ? 'on' : ''; //Add column SKU, if show_sku_col setting is on if (isset($dvin_wcql_settings['show_sku_col']) && $dvin_wcql_settings['show_sku_col'] == 'on') { $add_sku_toemail = "on"; } //Remove column PRiCE, if show_price_login setting is on and not loggedin if (isset($dvin_wcql_settings['show_price_login']) && $dvin_wcql_settings['show_price_login'] == 'on' && !is_user_logged_in()) { $add_price_col = ''; } //consider the shortcode attributes if (isset($atts['show_sku']) && $atts['show_sku']) { $add_sku_toemail = 'on'; } if (isset($atts['show_price']) && $atts['show_price']) { $add_price_col = 'on'; } //include the template file if (file_exists(TEMPLATEPATH . '/' . Dvin_Wcql::template_path() . 'templates/email_quotelist_template.php')) { include TEMPLATEPATH . '/' . Dvin_Wcql::template_path() . 'templates/email_quotelist_template.php'; } elseif (file_exists(STYLESHEETPATH . '/' . Dvin_Wcql::template_path() . 'templates/email_quotelist_template.php')) { include STYLESHEETPATH . '/' . Dvin_Wcql::template_path() . 'templates/email_quotelist_template.php'; } else { require 'templates/email_quotelist_template.php'; } return array($grand_total_price, $quote_list); }
public static function add_localisation() { //define constants if not if (!defined('TEMPLATEPATH_QLIST')) { define('TEMPLATEPATH_QLIST', get_template_directory()); } if (!defined('STYLESHEETPATH_QLIST')) { define('STYLESHEETPATH_QLIST', get_stylesheet_directory()); } //include the language file if (file_exists(TEMPLATEPATH_QLIST . '/' . Dvin_Wcql::template_path() . 'languages/')) { $langdir_path = TEMPLATEPATH_QLIST . '/' . Dvin_Wcql::template_path() . 'languages/'; } elseif (file_exists(STYLESHEETPATH_QLIST . '/' . Dvin_Wcql::template_path() . 'languages/')) { $langdir_path = STYLESHEETPATH_QLIST . '/' . Dvin_Wcql::template_path() . 'languages/'; } else { $langdir_path = dirname(plugin_basename(__FILE__)) . '/languages/'; } load_plugin_textdomain('dvinwcql', false, $langdir_path); }