예제 #1
0
 /**
  * Frontend Shortcode Handler
  *
  * @param array $atts array of attributes
  * @param string $content text within enclosing form of shortcode element
  * @param string $shortcodename the shortcode found, when == callback name
  * @return string $output returns the modified html string
  */
 function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "")
 {
     $atts = shortcode_atts(array('email' => get_option('admin_email'), 'button' => __("Submit", 'avia_framework'), 'autorespond' => '', 'captcha' => '', 'subject' => '', 'on_send' => '', 'link' => '', 'sent' => __("Your message has been sent!", 'avia_framework'), 'title' => __("Send us mail", 'avia_framework')), $atts, $this->config['shortcode']);
     extract($atts);
     $post_id = function_exists('avia_get_the_id') ? avia_get_the_id() : get_the_ID();
     $redirect = !empty($on_send) ? AviaHelper::get_url($link) : "";
     $form_args = array("heading" => $title ? "<h3>" . $title . "</h3>" : "", "success" => "<h3 class='avia-form-success'>" . $sent . "</h3>", "submit" => $button, "myemail" => $email, "action" => get_permalink($post_id), "myblogname" => get_option('blogname'), "autoresponder" => $autorespond, "autoresponder_subject" => __('Thank you for your Message!', 'avia_framework'), "autoresponder_email" => $email, "subject" => $subject, "form_class" => $meta['el_class'], "multiform" => true, "label_first" => true, "redirect" => $redirect);
     if (trim($form_args['myemail']) == '') {
         $form_args['myemail'] = get_option('admin_email');
     }
     //form fields passed by the user
     $form_fields = $this->helper_array2form_fields(ShortcodeHelper::shortcode2array($content, 1));
     //fake username field that is not visible. if the field has a value a spam bot tried to send the form
     $elements['avia_username'] = array('type' => 'decoy', 'label' => '', 'check' => 'must_empty');
     //captcha field for the user to verify that he is real
     if ($captcha) {
         $elements['avia_age'] = array('type' => 'captcha', 'check' => 'captcha', 'label' => __('Please prove that you are human by solving the equation', 'avia_framework'));
     }
     //merge all fields
     $form_fields = apply_filters('avia_contact_form_elements', array_merge($form_fields, $elements));
     $form_args = apply_filters('avia_contact_form_args', $form_args, $post_id);
     $contact_form = new avia_form($form_args);
     $contact_form->create_elements($form_fields);
     $output = $contact_form->display_form(true);
     return $output;
 }
예제 #2
0
 /**
  * Frontend Shortcode Handler
  *
  * @param array $atts array of attributes
  * @param string $content text within enclosing form of shortcode element
  * @param string $shortcodename the shortcode found, when == callback name
  * @return string $output returns the modified html string
  */
 function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "")
 {
     if (empty($this->api_key)) {
         return;
     }
     $lists = get_option('av_chimplist');
     $newlist = array();
     if (empty($lists)) {
         return;
     }
     foreach ($lists as $key => $list_item) {
         $newlist[$list_item['name']] = $key;
     }
     $lists = $newlist;
     $atts = shortcode_atts(apply_filters('avf_sc_mailchimp_atts', array('list' => "", 'email' => get_option('admin_email'), 'button' => __("Submit", 'avia_framework'), 'captcha' => '', 'subject' => '', 'on_send' => '', 'link' => '', 'sent' => __("Thank you for subscribing to our newsletter!", 'avia_framework'), 'color' => "", 'hide_labels' => "", 'form_align' => "", 'listonly' => false, 'double_opt_in' => "")), $atts, $this->config['shortcode']);
     if (empty($atts['list'])) {
         return;
     }
     //extract form fields
     if ($atts['listonly']) {
         $form_fields = $this->convert_fields_from_list($atts['list']);
     } else {
         $content = str_replace("\\,", "&#44;", $content);
         $form_fields = $this->helper_array2form_fields(ShortcodeHelper::shortcode2array($content, 1));
     }
     if (empty($form_fields)) {
         return;
     }
     extract($atts);
     $post_id = function_exists('avia_get_the_id') ? avia_get_the_id() : get_the_ID();
     $redirect = !empty($on_send) ? AviaHelper::get_url($link) : "";
     if (!empty($form_align)) {
         $meta['el_class'] .= " av-centered-form ";
     }
     $form_args = array("heading" => "", "success" => "<h3 class='avia-form-success avia-mailchimp-success'>" . $sent . "</h3>", "submit" => $button, "myemail" => $email, "action" => get_permalink($post_id), "myblogname" => get_option('blogname'), "subject" => $subject, "form_class" => $meta['el_class'] . " " . $color . " avia-mailchimp-form", "form_data" => array('av-custom-send' => 'mailchimp_send'), "multiform" => true, "label_first" => true, "redirect" => $redirect, "placeholder" => $hide_labels, "mailchimp" => $atts['list'], "custom_send" => array($this, 'send'), "double_opt_in" => $atts['double_opt_in']);
     if (trim($form_args['myemail']) == '') {
         $form_args['myemail'] = get_option('admin_email');
     }
     $content = str_replace("\\,", "&#44;", $content);
     //fake username field that is not visible. if the field has a value a spam bot tried to send the form
     $elements['avia_username'] = array('type' => 'decoy', 'label' => '', 'check' => 'must_empty');
     //captcha field for the user to verify that he is real
     if ($captcha) {
         $elements['avia_age'] = array('type' => 'captcha', 'check' => 'captcha', 'label' => __('Please prove that you are human by solving the equation', 'avia_framework'));
     }
     //merge all fields
     $form_fields = apply_filters('ava_mailchimp_contact_form_elements', array_merge($form_fields, $elements));
     $form_fields = apply_filters('avf_sc_mailchimp_form_elements', $form_fields, $atts);
     $form_args = apply_filters('avia_mailchimp_form_args', $form_args, $post_id);
     $contact_form = new avia_form($form_args);
     $contact_form->create_elements($form_fields);
     $output = $contact_form->display_form(true);
     return $output;
 }
예제 #3
0
<?php

/**
 *  The Contact form gets generated by the avia_form class located in framework/php/class-form-generator.php
 */
$form_args = array("heading" => "<h3>" . __('Send us mail', 'avia_framework') . "</h3>", "success" => "<h3>" . __('Your message has been sent!', 'avia_framework') . "</h3><p>" . __('Thank you!', 'avia_framework') . "</p>", "submit" => __('Send', 'avia_framework'), "action" => get_permalink());
$elements = array('yourname' => array('type' => 'text', 'label' => __('Name', 'avia_framework'), 'check' => 'is_empty'), 'email' => array('type' => 'text', 'label' => __('E-Mail', 'avia_framework'), 'check' => 'is_email'), 'website' => array('type' => 'text', 'label' => __('Website', 'avia_framework'), 'check' => ''), 'subject' => array('type' => 'text', 'label' => __('Subject', 'avia_framework'), 'check' => 'is_empty'), 'message' => array('type' => 'textarea', 'label' => __('Message', 'avia_framework'), 'check' => 'is_empty'), 'myemail' => array('type' => 'hidden', 'label' => '', 'check' => '', 'value' => avia_get_option('email')), 'myblogname' => array('type' => 'hidden', 'label' => '', 'check' => '', 'value' => get_option('blogname')), 'username' => array('type' => 'decoy', 'label' => '', 'check' => 'must_empty'));
$contact_form = new avia_form($form_args);
$contact_form->create_elements($elements);
$contact_form->display_form();