/** * Page Indictor * * This displays if the form contains pagebreaks and is configured to show * a page indicator in the top pagebreak settings. * * @since 1.2.1 * @param array $form_data * @param object $form * @param mixed $title * @param mixed $description * @param array $errors */ public function page_indicator($form_data, $form, $title, $description, $errors) { $pagebreak_top = wpforms_get_pagebreak($form_data, 'top'); if (empty($pagebreak_top['indicator']) || 'none' == apply_filters('wpforms_frontend_indicator_theme', $pagebreak_top['indicator'], $form_data)) { return; } $pagebreak = array('indicator' => sanitize_html_class($pagebreak_top['indicator']), 'color' => wpforms_sanitize_hex_color($pagebreak_top['indicator_color']), 'pages' => wpforms_get_pagebreak($form_data, 'pages')); $p = 1; printf('<div class="wpforms-page-indicator %s" data-indicator="%s" data-indicator-color="%s">', $pagebreak['indicator'], $pagebreak['indicator'], $pagebreak['color']); if ('circles' == $pagebreak['indicator']) { // Circles theme foreach ($pagebreak['pages'] as $page) { $class = 1 === $p ? 'active' : ''; $bg = 1 === $p ? 'style="background-color:' . $pagebreak['color'] . '"' : ''; printf('<div class="wpforms-page-indicator-page %s wpforms-page-indicator-page-%d">', $class, $p); printf('<span class="wpforms-page-indicator-page-number" %s>%d</span>', $bg, $p); if (!empty($page['title'])) { printf('<span class="wpforms-page-indicator-page-title">%s<span>', esc_html($page['title'])); } echo '</div>'; $p++; } } elseif ('connector' == $pagebreak['indicator']) { // Connector theme foreach ($pagebreak['pages'] as $page) { $class = 1 === $p ? 'active ' : ''; $bg = 1 === $p ? 'style="background-color:' . $pagebreak['color'] . '"' : ''; $border = 1 === $p ? 'style="border-top-color:' . $pagebreak['color'] . '"' : ''; $width = 100 / count($pagebreak['pages']) . '%'; printf('<div class="wpforms-page-indicator-page %s wpforms-page-indicator-page-%d" style="width:%s;">', $class, $p, $width); printf('<span class="wpforms-page-indicator-page-number" %s>%d<span class="wpforms-page-indicator-page-triangle" %s></span></span>', $bg, $p, $border); if (!empty($page['title'])) { printf('<span class="wpforms-page-indicator-page-title">%s<span>', esc_html($page['title'])); } echo '</div>'; $p++; } } elseif ('progress' == $pagebreak['indicator']) { // Progress theme $p1 = !empty($pagebreak['pages'][0]['title']) ? esc_html($pagebreak['pages'][0]['title']) : ''; $sep = empty($p1) ? 'style="display:none;"' : ''; $width = 100 / count($pagebreak['pages']) . '%'; $prog = 'style="width:' . $width . ';background-color:' . $pagebreak['color'] . ';"'; $names = ''; $step = __('Step', 'wpforms'); $of = __('of', 'wpforms'); foreach ($pagebreak['pages'] as $page) { if (!empty($page['title'])) { $names .= sprintf('data-page-%d-title="%s" ', $p, esc_attr($page['title'])); } $p++; } printf('<span class="wpforms-page-indicator-page-title" %s>%s</span>', $names, $p1); printf('<span class="wpforms-page-indicator-page-title-sep" %s> - </span>', $sep); printf('<span class="wpforms-page-indicator-steps">%s <span class="wpforms-page-indicator-steps-current">1</span> %s %d</span>', $step, $of, count($pagebreak['pages'])); printf('<div class="wpforms-page-indicator-page-progress-wrap"><div class="wpforms-page-indicator-page-progress" %s></div></div>', $prog); } do_action('wpforms_frontend_indicator', $pagebreak, $form_data); echo '</div>'; }
/** * Build the output for General tab on the settings page and check for save. * * @since 1.0.0 */ public function settings_page_tab_general() { // Check for save, if found let's dance if (!empty($_POST['wpforms-settings-general-nonce'])) { // Do we have a valid nonce and permission? if (!wp_verify_nonce($_POST['wpforms-settings-general-nonce'], 'wpforms-settings-general-nonce') || !current_user_can(apply_filters('wpforms_manage_cap', 'manage_options'))) { // No funny business printf('<div class="error below-h2"><p>%s</p></div>', __('Settings check failed.', 'wpforms')); } else { // Save General Settings if (isset($_POST['submit-general'])) { // Prep and sanatize settings for save $this->options['email-template'] = !empty($_POST['email-template']) ? esc_attr($_POST['email-template']) : 'default'; $this->options['email-header-image'] = !empty($_POST['email-header-image']) ? esc_url_raw($_POST['email-header-image']) : ''; $this->options['email-background-color'] = !empty($_POST['email-background-color']) ? wpforms_sanitize_hex_color($_POST['email-background-color']) : '#e9eaec'; $this->options['disable-css'] = !empty($_POST['disable-css']) ? intval($_POST['disable-css']) : '1'; $this->options['global-assets'] = !empty($_POST['global-assets']) ? '1' : false; $this->options['recaptcha-site-key'] = !empty($_POST['recaptcha-site-key']) ? esc_html($_POST['recaptcha-site-key']) : ''; $this->options['recaptcha-secret-key'] = !empty($_POST['recaptcha-secret-key']) ? esc_html($_POST['recaptcha-secret-key']) : ''; $this->options = apply_filters('wpforms_settings_save', $this->options, $_POST, 'general'); // Update settings in DB update_option('wpforms_settings', $this->options); printf('<div class="updated below-h2"><p>%s</p></div>', __('General settings updated.', 'wpforms')); } } } ?> <div id="wpforms-settings-general"> <form method="post"> <?php wp_nonce_field('wpforms-settings-general-nonce', 'wpforms-settings-general-nonce'); ?> <table class="form-table"> <tbody> <tr> <th scope="row"> <label for="wpforms-settings-general-css"><?php _e('Include Form Styling', 'wpforms'); ?> </label> </th> <td> <select name="disable-css" id="wpforms-settings-general-css"> <option value="1" <?php selected('1', $this->get('disable-css')); ?> ><?php _e('Base and form theme styling', 'wpforms'); ?> </option> <option value="2" <?php selected('2', $this->get('disable-css')); ?> ><?php _e('Base styling only', 'wpforms'); ?> </option> <option value="3" <?php selected('3', $this->get('disable-css')); ?> ><?php _e('None', 'wpforms'); ?> </option> </select> <p class="description"><?php _e('Determines which CSS files to load for the site.', 'wpforms'); ?> </p> </td> </tr> <tr> <th scope="row"> <label for="wpforms-settings-general-global-assets"><?php _e('Load Assets Globally', 'wpforms'); ?> </label> </th> <td> <input type="checkbox" name="global-assets" id="wpforms-settings-general-global-assets" value="1" <?php checked('1', $this->get('global-assets')); ?> > <label for="wpforms-settings-general-global-assets"><?php _e('Check this if you would like to load WPForms assets site-wide. Only check if your site is having compatibility issues or instructed to by support.', 'wpforms_paypals'); ?> </label> </td> </tr> <tr> <td class="section" colspan="2"> <hr> <h4><?php _e('Email', 'wpforms'); ?> </h4> </td> </tr> <tr> <th scope="row"> <label for="wpforms-settings-general-email-template"><?php _e('Email Template', 'wpforms'); ?> </label> </th> <td> <select name="email-template" id="wpforms-settings-general-email-template"> <option value="default" <?php selected('default', $this->get('email-template')); ?> ><?php _e('Default HTML template', 'wpforms'); ?> </option> <option value="none" <?php selected('none', $this->get('email-template')); ?> ><?php _e('Plain Text', 'wpforms'); ?> </option> </select> <p class="description"><?php _e('Determines how email notifications will be formatted.', 'wpforms'); ?> </p> </td> </tr> <tr> <th scope="row"> <label for="wpforms-settings-general-email-header-image"><?php _e('Email Header Image ', 'wpforms'); ?> </label> </th> <td> <label for="wpforms-settings-general-email-header-image" class="wpforms-settings-upload-image-display"> <?php $email_header = $this->get('email-header-image'); if ($email_header) { echo '<img src="' . esc_url_raw($email_header) . '">'; } ?> </label> <input type="text" name="email-header-image" id="wpforms-settings-email-header-image" class="wpforms-settings-upload-image-value" value="<?php echo esc_url_raw($this->get('email-header-image')); ?> " /> <a href="#" class="button button-secondary wpforms-settings-upload-image"><?php _e('Upload Image', 'wpforms'); ?> </a> <p class="description"> <?php _e('Upload or choose a logo to be displayed at the top of email notifications.', 'wpforms'); ?> <br> <?php _e('Recommended size is 300x100 or smaller for best support on all devices.', 'wpforms'); ?> </p> </td> </tr> <tr> <th scope="row"> <label for="wpforms-settings-general-email-background-color"><?php _e('Email Background Color', 'wpforms'); ?> </label> </th> <td> <input type="text" name="email-background-color" value="<?php echo esc_attr($this->get('email-background-color', '#e9eaec')); ?> " id="wpforms-settings-general-email-background-color" class="wpforms-color-picker"> <p class="description"><?php _e('Customize the background color of the HTML email template.', 'wpforms'); ?> </p> </td> </tr> <tr> <td class="section" colspan="2"> <hr> <h4><?php _e('reCAPTCHA', 'wpforms'); ?> </h4> <p><?php _e('reCAPTCHA is a free anti-spam service from Google. Its helps protect your website from spam and abuse while letting real people pass through with ease. <a href="http://www.google.com/recaptcha/intro/index.html" target="_blank">Visit reCAPTCHA</a> to learn more and sign up for a free account or <a href="https://wpforms.com/docs/setup-captcha-wpforms/" target="_blank">read our walk through</a> for step-by-step directions.', 'wpforms'); ?> </p> </td> </tr> <tr> <th scope="row"> <label for="wpforms-settings-general-recaptcha-site-key"><?php _e('reCAPTCHA Site key', 'wpforms'); ?> </label> </th> <td> <input type="text" name="recaptcha-site-key" value="<?php echo esc_attr($this->get('recaptcha-site-key')); ?> " id="wpforms-settings-general-recaptcha-site-key"> </td> </tr> <tr> <th scope="row"> <label for="wpforms-settings-general-recaptcha-secret-key"><?php _e('reCAPTCHA Secret key', 'wpforms'); ?> </label> </th> <td> <input type="text" name="recaptcha-secret-key" value="<?php echo esc_attr($this->get('recaptcha-secret-key')); ?> " id="wpforms-settings-general-recaptcha-secret-key"> </td> </tr> </tbody> </table> <?php submit_button(__('Save General Settings', 'wpforms'), 'primary', 'submit-general'); ?> </form> </div> <?php }