Exemplo n.º 1
0
/**
 * The form.
 *
 * @param $atts
 *
 * @return mixed|string|void
 */
function wpmtst_form_view($atts)
{
    global $strong_templates;
    if (isset($_GET['success'])) {
        // Load stylesheet
        do_action('wpmtst_form_rendered', $atts);
        return apply_filters('wpmtst_form_success_message', '<div class="testimonial-success">' . wpmtst_get_form_message('submission-success') . '</div>');
    }
    // TODO no need to extract
    extract(normalize_empty_atts($atts));
    $fields = wpmtst_get_form_fields($form_id);
    $form_values = array('category' => $category);
    foreach ($fields as $key => $field) {
        $form_values[$field['name']] = '';
    }
    $previous_values = WPMST()->get_form_values();
    if ($previous_values) {
        $form_values = array_merge($form_values, $previous_values);
    }
    WPMST()->set_form_values($form_values);
    /**
     * Add filters here.
     */
    /**
     * Load template
     */
    $template_file = $strong_templates->get_template_attr($atts, 'template');
    ob_start();
    /** @noinspection PhpIncludeInspection */
    include $template_file;
    $html = ob_get_contents();
    ob_end_clean();
    /**
     * Remove filters here.
     */
    do_action('wpmtst_form_rendered', $atts);
    $html = apply_filters('strong_view_form_html', $html);
    return $html;
}
Exemplo n.º 2
0
 public function form_handler2()
 {
     if (isset($_POST['wpmtst_form_nonce'])) {
         require_once WPMTST_INC . 'shortcodes.php';
         require_once WPMTST_INC . 'form-handler-functions.php';
         $success = wpmtst_form_handler();
         if ($success) {
             $return = array('success' => true, 'message' => '<div class="testimonial-success">' . wpmtst_get_form_message('submission-success') . '</div>');
         } else {
             $return = array('success' => false, 'errors' => WPMST()->get_form_errors());
         }
         echo json_encode($return);
     }
     die;
 }
Exemplo n.º 3
0
function wpmtst_form_message($part)
{
    echo wpmtst_get_form_message($part);
}