<select name="ip_support_status"> <option value="open" ><?php _e('Open', $this->name); ?> </option> <option value="closed" ><?php _e('Closed', $this->name); ?> </option> </select> </p> <?php // Support Request Section - Default From Settings $sections = get_ip_sections(); $default_section = get_ip_default_section(); $current_section = get_ip_sections_by_id($support_request->ID); if (empty($current_section)) { $current_section = $default_section; } else { $current_section = $current_section[0]->term_id; } ?> <p> <label for="ip_support_section"><?php _e('Section:', $this->name); ?> </label> <select name="ip_support_section"> <option value="">-- Select a Section --</option> <?php
/** * Returns the IP Section Select Form Element * * @since 1.0.0 * @return String The html markup to display the section select element */ function get_ip_form_section_select() { if (!ip_has_sections()) { return; } $sections = get_ip_sections(); $default_section = get_ip_default_section(); $section_select_output = '<div id="ip-support-section-select-wrapper"><label for="ip-support-section">Section: </label> <select id="ip-support-section-select" name="ip-support-section" class="ip-select">'; foreach ($sections as $section) { $selected = ''; if ($default_section == $section->term_id) { $selected = 'selected'; } $section_select_output .= '<option value="' . $section->term_id . '" ' . $selected . '>' . $section->name . '</option>'; } $section_select_output .= '</select></div>'; return $section_select_output; }
/** * Handles support request form submissions * * @since 1.0.0 */ public function ip_new_support_request_handler($action = '') { // Bail if action is not ip-create-support-request if ($action !== 'ip-create-support-request') { return; } // Nonce check if (!wp_verify_nonce($_REQUEST['_wpnonce'], $action)) { return; } $request_author = get_current_user_id(); $request_content = $request_title = ''; if (!empty($_POST['ip-support-description'])) { $request_content = esc_attr(strip_tags($_POST['ip-support-description'])); } else { ip_add_error('ip_support_content', __('<strong>ERROR</strong>: Support Requests require a description.', $this->name)); } if (!empty($_POST['ip-support-title'])) { $request_title = esc_attr(strip_tags($_POST['ip-support-title'])); } else { ip_add_error('ip_support_title', __('<strong>ERROR</strong>: Support Requests require a title.', $this->name)); } if (!empty($_POST['ip-support-section'])) { $request_section = $_POST['ip-support-section']; } else { $request_section = get_ip_default_section(); } if (ip_has_errors()) { return; } $post_status = $this->plugin->get_plugin_setting_by_key('ip_default_post_status'); $support_request_data = apply_filters('ip_new_support_request_pre_insert', array('post_author' => $request_author, 'post_title' => $request_title, 'post_content' => $request_content, 'post_type' => get_ip_support_request_post_type(), 'post_status' => $post_status ? $post_status : 'draft', 'comment_status' => 'open', 'ping_status' => 'closed')); $support_request_id = wp_insert_post($support_request_data); if (!empty($support_request_id)) { update_post_meta($support_request_id, 'status', 'open'); wp_set_post_terms($support_request_id, $request_section, get_ip_support_section_taxonomy()); do_action('ip_new_support_request_post_insert', $support_request_id); } }
if (!empty($sections)) { ?> <select id="ip_default_support_section" name="<?php echo $this->plugin->get_options_key(); ?> [ip_default_support_section]"> <option value=""><?php _e('Select Section', $this->name); ?> </option> <?php foreach ($sections as $section) { $selected = ''; if ($section->term_id == get_ip_default_section()) { $selected = 'selected'; } $output = '<option value="' . $section->term_id . '" ' . $selected . '>' . $section->name . '</option>'; echo $output; } ?> </select> <?php if (!$this->plugin->get_plugin_setting_by_key('ip_default_support_section')) { ?> <!-- <button class="button secondary" id="create-new-support-section"><?php