function st_insert_post_type_location() { if (!empty($_REQUEST['btn_insert_post_type_location'])) { if (wp_verify_nonce($_REQUEST['st_insert_post_location'], 'user_setting')) { $current_user = wp_get_current_user(); $title = $_REQUEST['title']; $st_content = $_REQUEST['st_content']; $desc = $_REQUEST['desc']; $post_parent = $_REQUEST['post_parent']; $my_post = array('post_title' => $title, 'post_content' => $st_content, 'post_status' => "publish", 'post_author' => $current_user->ID, 'post_type' => 'location', 'post_excerpt' => $desc, 'post_parent' => $post_parent); $id_post = wp_insert_post($my_post); if (!empty($id_post)) { $featured_image = $_FILES['featured-image']; $id_featured_image = self::upload_image_return($featured_image, 'featured-image', $featured_image['type']); set_post_thumbnail($id_post, $id_featured_image); $logo = $_FILES['logo']; $id_logo = self::upload_image_return($logo, 'logo', $logo['type']); update_post_meta($id_post, 'logo', $id_logo); update_post_meta($id_post, 'zipcode', $_REQUEST['zipcode']); update_post_meta($id_post, 'map_lat', $_REQUEST['map_lat']); update_post_meta($id_post, 'map_lng', $_REQUEST['map_lng']); update_post_meta($id_post, 'is_featured', $_REQUEST['is_featured']); self::$msg = array('status' => 'success', 'msg' => __('Create Location successfully !', ST_TEXTDOMAIN)); } else { self::$msg = array('status' => 'danger', 'msg' => __('Error : Create Location not successfully !', ST_TEXTDOMAIN)); } } } }