/** * Ajax function that processes data submitted by users and prints out the appropriate response as a json encoded string. * * @param array The $_POST array. * @return string A json encoded string. **/ public function handle_submission_ajax() { $form_id = $_POST['form_id']; $form = new WPFEPP_Form($this->version, $form_id); if ($_POST['req_type'] == 'submit') { $result = $form->handle_submission($_POST); } elseif ($_POST['req_type'] == 'save') { $result = $form->save_draft($_POST); } die(json_encode($result)); }
/** * Callback function for the [wpfepp_submission_form] shortcode registered in add_actions() **/ public function submission_form_shortcode($_args) { wp_enqueue_style('wpfepp-style'); wp_enqueue_script('wpfepp-script'); wp_enqueue_media(); $args = shortcode_atts(array('form' => -1), $_args); ob_start(); $form_obj = new WPFEPP_Form($this->version, $args['form']); $form_obj->display(); return ob_get_clean(); }
/** * Outputs the HTML of the post list or the form (depending on $_GET variables). **/ public function display() { if (!$this->valid) { _e("No form with the specified ID was found", 'wpfepp-plugin'); return; } if (!is_user_logged_in()) { printf(__('You need to %s first.', 'wpfepp-plugin'), sprintf('<a href="%s">%s</a>', wp_login_url(), __('log in', 'wpfepp-plugin'))); return; } if (isset($_GET['wpfepp_post']) && isset($_GET['wpfepp_action']) && is_numeric($_GET['wpfepp_post']) && $_GET['wpfepp_action'] == 'edit') { $this->form->display($_GET['wpfepp_post']); } else { $this->print_list(); } }