function contact_form_submit() { if (!count($_POST)) { return; } _load_plugins_class('validation', 'helpers', true); $t = $GLOBALS['_sh_base']; //printr($t); $settings = $t->option(); $post_test = sh_set($_POST, 'test'); $rec_email = sanitize_email($post_test) ? sanitize_email($post_test) : _sh_generate_salt($post_test, true); /** set validation rules for contact form */ $t->validation->set_rules('contact_name', '<strong>' . __('Name', SH_NAME) . '</strong>', 'required|min_length[4]|max_lenth[30]'); //$t->validation->set_rules('aplus_l_name','<strong>'.__('Last Name', SH_NAME).'</strong>', 'required|min_length[4]|max_lenth[30]'); $t->validation->set_rules('contact_email', '<strong>' . __('Email', SH_NAME) . '</strong>', 'required|valid_email'); $t->validation->set_rules('contact_website', '<strong>' . __('Website', SH_NAME) . '</strong>'); $t->validation->set_rules('contact_subject', '<strong>' . __('Subject', SH_NAME) . '</strong>', 'min_length[5]'); $t->validation->set_rules('contact_message', '<strong>' . __('Message', SH_NAME) . '</strong>', 'required|min_length[5]'); if (sh_set($settings, 'contact_captcha_status')) { include_once get_template_directory() . '/includes/thirdparty/recaptchalib.php'; $privatekey = sh_set($settings, 'recaptcha_private'); $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { $t->validation->_error_array['captcha'] = __('Invalid captcha entered, please try again.', SH_NAME); } } $messages = ''; if ($t->validation->run() !== FALSE && empty($t->validation->_error_array)) { $name = $t->validation->post('contact_name'); $email = $t->validation->post('contact_email'); $message = __("Nombre:\t", SH_NAME) . $name . "\r\n"; //$message .= "\r\n".__("Contact Website:\t", SH_NAME).$t->validation->post('contact_website')."\r\n"; $message .= "\r\n" . __("Titutlo:\t", SH_NAME) . sh_set($_POST, 'contact_subject') . "\r\n"; $message .= "\r\n" . $t->validation->post('contact_message'); $contact_to = sanitize_email($rec_email) ? $rec_email : get_option('admin_email'); $headers = 'From: ' . $name . ' <' . $email . '>' . "\r\n"; wp_mail($contact_to, sprintf(__('Nueva persona interesada en %s', SH_NAME), get_bloginfo('name')), $message, $headers); echo "<fieldset>"; echo "<div id='success_page' class='alert alert-success'>"; echo "<h1>" . __('Email enviado satisfactoriamente.', SH_NAME) . "</h1>"; echo "<p>" . sprintf(__("Gracias <strong>%s</strong>, tu mensaje fue enviado.", SH_NAME), $name) . "</p>"; echo "</div>"; echo "</fieldset>"; exit; } else { if (is_array($t->validation->_error_array)) { foreach ($t->validation->_error_array as $msg) { $messages .= '<div class="alert alert-danger">' . __('Error! ', SH_NAME) . $msg . '</div>'; } } } echo $messages; exit; }
function post() { _load_plugins_class('validation', 'helpers', true); $t = _WSH(); $settings = $t->option(); $message = ''; $nonce = sh_set($_POST, 'form_secret'); if (!wp_verify_nonce($nonce, 'form-builder')) { $t->validation->_error_array['form_secret'] = __('You are spamming', SH_NAME); } foreach ($this->fields as $f) { $field_name = sh_set($f, 'name'); $validation = array(); $placehold = sh_set($f, 'placeholder'); foreach ((array) sh_set($f, 'validation') as $valid) { $validation[] = $valid; } /** set validation rules for contact form */ $t->validation->set_rules($field_name, '<strong>' . sh_set($f, 'placeholder') . '</strong>', implode('|', $validation)); $message .= "{$placehold}\t" . $t->validation->post($field_name) . "\r\n"; } //if( sh_set( $_POST, 'form_secret' ) !== $this->_old_hash ) //$t->validation->_error_array['form_secret'] = __('There is form validation error or spamming issue', SH_NAME); if ($t->validation->run() !== FALSE && empty($t->validation->_error_array)) { $contact_to = sh_set($this->meta, 'form_email') ? sh_set($this->meta, 'form_email') : get_option('admin_email'); $headers = 'From: ' . get_option('name') . ' <' . get_option('admin_email') . '>' . "\r\n"; wp_mail($contact_to, sprintf(__('%s - Form Submitted', SH_NAME), get_the_title($this->id)), $message, $headers); $response = sh_set($this->meta, 'form_success_msg') ? $this->meta['form_success_msg'] : sprintf(__('Form is successfully submitted, we\'ll response you shortly.', SH_NAME), $name); return "<div id='success_page' class=\"alert alert-success\" style=\"margin-bottom:0;\">" . "<h1>" . __("Successful", SH_NAME) . "</h1>" . "<p>" . $response . "</p>" . "</div>"; } else { $messages = ''; if (is_array($t->validation->_error_array)) { foreach ($t->validation->_error_array as $msg) { $messages .= '<p>' . __('Error! ', SH_NAME) . $msg . '</p>'; } } return '<div class="alert alert-danger">' . $messages . '</div>'; } return ''; }
function _sh_plugin_init() { global $pagenow; include_once 'library/functions.php'; _load_plugins_class('post_types', 'helpers', false); _load_plugins_class('taxonomies', 'helpers', false); _load_plugins_class('ajax', 'helpers', false); _load_plugins_class('forms', 'helpers', false); //_load_class( 'validation', 'helpers', true ); //_load_plugins_class( 'seo', 'helpers', false ); _load_plugins_class('update_theme', 'update', false); _load_plugins_class('shortcodes', 'helpers', true); //_load_plugins_class( 'mega_menu', 'helpers', false ); /** * Include Custom Data Sources */ require_once 'vafpress/admin/data_sources.php'; /** * Load options, metaboxes, and shortcode generator array templates. */ // metaboxes $tmpl_mb1 = (include SH_TH_ROOT . 'includes/vafpress/admin/metabox/meta_boxes.php'); // * Create instances of Metaboxes foreach ($tmpl_mb1 as $tmb) { new VP_Metabox($tmb); } $tmpl_mb1 = (include SH_TH_ROOT . 'includes/vafpress/admin/taxonomy/taxonomy.php'); include_once 'vp_new/taxonomy.php'; foreach ($tmpl_mb1 as $tmb) { new SH_Metabox($tmb); } if (is_admin()) { include_once 'helpers/backup_class.php'; $backup = new SH_Backup_class(); if (sh_set($_GET, 'page') == SH_NAME . '_option') { if (sh_set($_GET, 'sh_dummydata_export')) { $backup->export(); } /*if( sh_set( $_GET, 'sh_dummydata_import' ) ){ include_once( 'helpers/backup_class.php' ); $backup = new SH_Backup_class; $backup->import(); }*/ } } if (function_exists('vc_map')) { include_once 'vc_map.php'; } // options $tmpl_opt = SH_TH_ROOT . 'includes/vafpress/admin/option/option.php'; /** * Create instance of Options */ $theme_options = new VP_Option(array('is_dev_mode' => false, 'option_key' => SH_NAME . '_theme_options', 'page_slug' => SH_NAME . '_option', 'template' => $tmpl_opt, 'menu_page' => 'themes.php', 'use_auto_group_naming' => true, 'use_util_menu' => true, 'minimum_role' => 'edit_theme_options', 'layout' => 'fluid', 'page_title' => __('Theme Options', SH_NAME), 'menu_label' => __('Theme Options', SH_NAME))); _WSH()->user_extra(array('designation' => __('Designation', SH_NAME), 'facebook' => __('Facebook', SH_NAME), 'twitter' => __('Twitter', SH_NAME), 'dribbble' => __('Dribble', SH_NAME), 'github' => __('Github', SH_NAME), 'flickr' => __('Flickr', SH_NAME), 'google-plus' => __('Google+', SH_NAME), 'youtube' => __('Youtube', SH_NAME))); $sh_exlude_hooks = (include_once 'resource/remove_action.php'); foreach ($sh_exlude_hooks as $k => $v) { foreach ($v as $value) { remove_action($k, $value[0], $value[1]); } } // shortocode generators $tmpl_sg1 = SH_TH_ROOT . 'includes/vafpress/admin/shortcode_generator/shortcodes1.php'; $tmpl_sg = array('name' => 'sg_1', 'template' => $tmpl_sg1, 'modal_title' => __('Bloxo Shortcodes', SH_NAME), 'button_title' => __('Bloxo', SH_NAME), 'types' => array('page'), 'main_image' => SH_TH_URL . '/includes/vafpress/public/img/vp_shortcode_icon.png', 'sprite_image' => SH_TH_URL . '/includes/vafpress/public/img/vp_shortcode_icon_sprite.png', 'included_pages' => array('appearance_page_vpt_option')); //$sg = new VP_ShortcodeGenerator($tmpl_sg); }