Exemplo n.º 1
0
 /**
  * @param string $element_id
  * @param array $attributes
  * @param string $response_html
  * @return string
  */
 public function get_visible_fields($element_id, array $attributes = array(), $response_html = '')
 {
     $replacements = array('{n}' => $element_id, '{response}' => $response_html);
     $visible_fields = MC4WP_Tools::replace_variables($this->content, $replacements, array_values($this->settings['lists']));
     // insert captcha
     if (function_exists('cptch_display_captcha_custom')) {
         $captcha_fields = '<input type="hidden" name="_mc4wp_has_captcha" value="1" /><input type="hidden" name="cntctfrm_contact_action" value="true" />' . cptch_display_captcha_custom();
         $visible_fields = str_ireplace(array('{captcha}', '[captcha]'), $captcha_fields, $visible_fields);
     }
     /**
      * @filter mc4wp_form_content
      * @param int $form_id The ID of the form that is being shown
      * @expects string
      *
      * Can be used to customize the content of the form mark-up, eg adding additional fields.
      */
     $visible_fields = (string) apply_filters('mc4wp_form_content', $visible_fields, $this->ID);
     return $visible_fields;
 }
 /**
  * Returns the HTML for success or error messages
  *
  * @return string
  */
 public function get_response_html()
 {
     // get all form messages
     $messages = $this->form->get_messages();
     // retrieve correct message
     $message = isset($messages[$this->message_type]) ? $messages[$this->message_type] : $messages['error'];
     // replace variables in message text
     $message['text'] = MC4WP_Tools::replace_variables($message['text'], array(), array_values($this->get_lists()));
     $html = '<div class="mc4wp-alert mc4wp-' . esc_attr($message['type']) . '">' . $message['text'] . '</div>';
     // show additional MailChimp API errors to administrators
     if (!$this->success && current_user_can('manage_options')) {
         if ('' !== $this->mailchimp_error) {
             $html .= '<div class="mc4wp-alert mc4wp-error"><strong>Admin notice:</strong> ' . $this->mailchimp_error . '</div>';
         }
     }
     return $html;
 }
Exemplo n.º 3
0
 /**
  * Get the text for the label element
  *
  * @return string
  */
 public function get_label_text()
 {
     $opts = $this->get_options();
     // Get general label text
     $label = $opts['label'];
     // Override label text if a specific text for this integration is set
     if (isset($opts['text_' . $this->type . '_label']) && !empty($opts['text_' . $this->type . '_label'])) {
         // custom label text was set
         $label = $opts['text_' . $this->type . '_label'];
     }
     // replace label variables
     $label = MC4WP_Tools::replace_variables($label, array(), array_values($opts['lists']));
     return $label;
 }
Exemplo n.º 4
0
 /**
  * Returns the HTML for success or error messages
  *
  * @return string
  */
 public function get_response_html()
 {
     // get all form messages
     $messages = $this->form->get_messages();
     // retrieve correct message
     $message = isset($messages[$this->status]) ? $messages[$this->status] : $messages['error'];
     // replace variables in message text
     $message['text'] = MC4WP_Tools::replace_variables($message['text'], array(), array_values($this->get_lists()));
     $html = '<div class="mc4wp-alert mc4wp-' . esc_attr($message['type']) . '">' . $message['text'] . '</div>';
     // show additional MailChimp API errors to administrators
     if (!$this->success && current_user_can('manage_options')) {
         if (!empty($this->responses[0]->error)) {
             $html .= '<div class="mc4wp-alert mc4wp-error">';
             $html .= $this->responses[0]->error;
             $html .= '<br /><small>' . __('This message is only visible to logged-in administrators.', 'mailchimp-for-wp') . '</small>';
             $html .= '</div>';
         }
     }
     return $html;
 }