/** * 表示画面でのプラグインの処理等 * * @param string $template * @return string $template */ public function template_include($template) { global $post; $this->ExecShortcode = new MW_WP_Form_Exec_Shortcode($post, $template); $has_shortcode = $this->ExecShortcode->has_shortcode(); if (!$has_shortcode) { return $template; } $form_key = $this->ExecShortcode->get('key'); $form_id = $this->ExecShortcode->get_form_id(); $this->Setting = new MW_WP_Form_Setting($form_id); $this->Data = MW_WP_Form_Data::getInstance($form_key, $_POST, $_FILES); foreach ($this->validation_rules as $validation_name => $validation_rule) { if (is_callable(array($validation_rule, 'set_Data'))) { $validation_rule->set_Data($this->Data); } } nocache_headers(); $Error = new MW_WP_Form_Error(); $this->Validation = new MW_WP_Form_Validation($Error); $this->Validation->set_validation_rules($this->validation_rules); $this->Validation->set_rules($this->Setting); $this->Validation = apply_filters('mwform_validation_' . $form_key, $this->Validation, $this->Data->gets(), clone $this->Data); $token_check = $this->token_check(); $post_condition = $this->Data->get_post_condition($token_check); $is_valid = $this->Validation->check(); $this->Redirected = new MW_WP_Form_Redirected($this->ExecShortcode->get('input_url'), $this->ExecShortcode->get('confirmation_url'), $this->ExecShortcode->get('complete_url'), $this->ExecShortcode->get('validation_error_url'), $is_valid, $post_condition, $this->Setting->get('querystring')); $url = $this->Redirected->get_url(); $view_flg = $this->Redirected->get_view_flg(); // confirm もしくは complete のとき if (in_array($post_condition, array('confirm', 'complete'))) { $this->file_upload(); } // complete のとき if ($view_flg === 'complete') { if (!$this->is_complete_twice()) { $this->send(); do_action('mwform_after_send_' . $form_key); } // 手動フォームの場合は完了画面に ExecShortcode が無く footer の clear_values が // 効かないためここで消す if (!$form_id) { $this->Data->clear_values(); } } $this->redirect($url); // スクロール用スクリプトのロード if ($this->Setting->get('scroll')) { if ($post_condition !== 'input') { add_action('wp_enqueue_scripts', array($this, 'scroll_script')); } } // 画面表示用のショートコードを登録 do_action('mwform_add_shortcode', new MW_WP_Form_Form(), $view_flg, $Error, $form_key, $this->Data); $Form = new MW_WP_Form_Form(); $this->ExecShortcode->add_shortcode($view_flg, $this->Setting, $Form); add_action('wp_footer', array($this->Data, 'clear_values')); add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts')); return $template; }
/** * tearDown */ public function tearDown() { parent::tearDown(); $this->Data->clear_values(); }