/** * @param string $element_id * @param array $attributes * @return string */ public function generate_html($element_id = 'mc4wp-form', array $attributes = array()) { // generate response html $response_html = $this->is_submitted($element_id) ? $this->request->get_response_html() : ''; // Some vars we might fill later on $form_opening_html = ''; $form_closing_html = ''; $visible_fields = ''; $hidden_fields = ''; // add HTML that's needed for AJAX if ($this->settings['ajax']) { $response_html .= '<div class="mc4wp-response"></div>'; $hidden_fields .= '<span class="mc4wp-ajax-loader" style="display: none;"></span>'; } // generate before & after HTML $opening_html = '<!-- MailChimp for WordPress Pro v' . MC4WP_VERSION . ' - https://mc4wp.com/ -->'; $opening_html .= '<div id="' . esc_attr($element_id) . '" class="' . esc_attr($this->get_css_classes($element_id)) . '">'; $before_fields = apply_filters('mc4wp_form_before_fields', ''); $after_fields = apply_filters('mc4wp_form_after_fields', ''); $before_form = $this->get_html_before_fields($response_html); $after_form = $this->get_html_after_fields($response_html); $closing_html = '</div><!-- / MailChimp for WP Pro Plugin -->'; // only generate form & fields HTML if necessary if (!$this->is_submitted($element_id) || !$this->settings['hide_after_success'] || !$this->request->success) { $form_opening_html = '<form method="post">'; $visible_fields = $this->get_visible_fields($element_id, $attributes, $response_html); $hidden_fields .= $this->get_hidden_fields($element_id, $attributes); $form_closing_html = '</form>'; } ob_start(); // echo HTML parts of form echo $opening_html; echo $before_form; echo $form_opening_html; echo $before_fields; echo $visible_fields; echo $hidden_fields; echo $after_fields; echo $form_closing_html; echo $after_form; echo $closing_html; $output = ob_get_contents(); ob_end_clean(); return $output; }
/** * @param string $element_id * @param array $attributes * @return string */ public function generate_html($element_id = 'mc4wp-form', array $attributes = array()) { // generate response html $response_html = $this->is_submitted($element_id) ? $this->request->get_response_html() : ''; // Some vars we might fill later on $form_opening_html = ''; $form_closing_html = ''; $visible_fields = ''; $hidden_fields = ''; // Start building content string $opening_html = '<!-- MailChimp for WordPress v' . MC4WP_LITE_VERSION . ' - https://wordpress.org/plugins/mailchimp-for-wp/ -->'; $opening_html .= '<div id="' . esc_attr($element_id) . '" class="' . esc_attr($this->get_css_classes($element_id)) . '">'; $before_fields = apply_filters('mc4wp_form_before_fields', ''); $after_fields = apply_filters('mc4wp_form_after_fields', ''); $before_form = $this->get_html_before_fields($response_html); $after_form = $this->get_html_after_fields($response_html); $closing_html = '</div><!-- / MailChimp for WordPress Plugin -->'; // only generate form & fields HTML if necessary if (!$this->is_submitted($element_id) || !$this->settings['hide_after_success'] || !$this->request->success) { $form_opening_html = '<form method="post" role="form">'; $visible_fields = $this->get_visible_fields($element_id, $attributes, $response_html); $hidden_fields = $this->get_hidden_fields($element_id, $attributes); $form_closing_html = '</form>'; } ob_start(); // echo HTML parts of form echo $opening_html; echo $before_form; echo $form_opening_html; echo $before_fields; echo $visible_fields; echo $hidden_fields; echo $after_fields; echo $form_closing_html; echo $after_form; echo $closing_html; $output = ob_get_contents(); ob_end_clean(); return $output; }