Ejemplo n.º 1
0
 public function render_form($atts)
 {
     $defaults = array('title' => __('Subscribe to our MailChimp list.', MAILCHIMP_LANG_DOMAIN), 'success_text' => __('Thank you, your email has been added to the list.', MAILCHIMP_LANG_DOMAIN), 'button_text' => __('Subscribe!', MAILCHIMP_LANG_DOMAIN), 'lastname' => 1, 'firstname' => 1);
     $atts = wp_parse_args($atts, $defaults);
     extract($atts);
     $args['text'] = $title;
     $args['subscribed_placeholder'] = $success_text;
     $args['button_text'] = $button_text;
     $args['form_id'] = 'incsub-mailchimp-shortcode-form-' . self::$number;
     $args['submit_name'] = 'submit-subscribe-shortcode-user';
     $args['firstname'] = !empty($_POST['subscription-firstname']) ? stripslashes($_POST['subscription-firstname']) : '';
     $args['lastname'] = !empty($_POST['subscription-lastname']) ? stripslashes($_POST['subscription-lastname']) : '';
     $args['email'] = !empty($_POST['subscription-email']) ? stripslashes($_POST['subscription-email']) : '';
     $settings = array('require_firstname' => isset($firstname) ? (bool) $firstname : false, 'require_lastname' => isset($lastname) ? (bool) $lastname : false);
     $this->validate_shortcode($settings);
     $args['errors'] = isset($this->errors[self::$number]) ? $this->errors[self::$number] : array();
     $args['subscribed'] = isset($_POST['submit-subscribe-shortcode-user']) && empty($this->errors[self::$number]);
     $args['require_fn'] = $settings['require_firstname'];
     $args['require_ln'] = $settings['require_lastname'];
     self::$number++;
     $this->enqueue_styles = true;
     ob_start();
     WPMUDEV_MailChimp_Form::render_form($args);
     return ob_get_clean();
 }
Ejemplo n.º 2
0
 /**
  * How to display the widget on the screen.
  */
 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     $firstname = !empty($_POST['subscription-firstname']) ? stripslashes($_POST['subscription-firstname']) : '';
     $lastname = !empty($_POST['subscription-lastname']) ? stripslashes($_POST['subscription-lastname']) : '';
     $email = !empty($_POST['subscription-email']) ? stripslashes($_POST['subscription-email']) : '';
     $form_id = 'incsub-mailchimp-widget-form-' . $this->number;
     $subscribed = isset($_GET['mailchimp-subscribed-' . $this->number]);
     $submit_name = 'submit-subscribe-widget-user';
     $errors = isset($this->errors[$this->number]) ? $this->errors[$this->number] : array();
     $args = compact('submit_name', 'form_id', 'subscribed', 'firstname', 'lastname', 'email', 'errors');
     $args['button_text'] = $instance['button_text'];
     $args['subscribed_placeholder'] = $instance['subscribed_placeholder'];
     $args['text'] = $instance['text'];
     $args['require_fn'] = $instance['require_firstname'];
     $args['require_ln'] = $instance['require_lastname'];
     WPMUDEV_MailChimp_Form::render_form($args);
     echo $after_widget;
 }