/**
  * Init Support Section Taxonomy
  *
  * Adds a general term to the support sections taxonomy if no terms exist.
  */
 public static function init_taxonomies()
 {
     // Check if there are terms in support sections taxonomy, if not - create "General" term.
     $sections_terms = get_terms(get_ip_support_section_taxonomy(), array('hide_empty' => false));
     if (empty($sections_terms)) {
         wp_insert_term("General", get_ip_support_section_taxonomy());
     }
 }
 /**
  * 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);
     }
 }
示例#3
0
/**
 * Return array of Support Sections by Request ID
 *
 * @since			1.0.0
 * @uses			wp_get_post_terms()
 * @return		Array		The list of sections a post has set.
 */
function get_ip_sections_by_id($support_request_id, $args = array())
{
    return wp_get_post_terms($support_request_id, get_ip_support_section_taxonomy(), $args);
}