How can i implement “your plugin” to my front end posting?
-
Hy,on the bottom of Tags: I want to add something to be able to select from existing tags.
https://i.stack.imgur.com/5dveJ.png
Here it’s html and php code :case "window-image": $format = 'image'; $title = esc_html($_POST['title_image']); $tags = $_POST['tags_image']; $comments = isset($_POST['comments_image']) ? 1 : 0; $user_id = $id; if(($_FILES['file']['error'] != 0) || $title == '' || str_word_count($tags) < 3) { wp_redirect(home_url('/') . '?posterror=1'); exit; } $post = array( 'comment_status' => $comment_status, 'ping_status' => 'open', 'post_author' => $user_id, 'post_content' => '', 'post_status' => $status, 'post_title' => $title, 'post_type' => 'post', ); $post_id = wp_insert_post($post); #Upload and Create attachment if (!function_exists('wp_generate_attachment_metadata')){ require_once(ABSPATH . "wp-admin" . '/includes/image.php'); require_once(ABSPATH . "wp-admin" . '/includes/file.php'); require_once(ABSPATH . "wp-admin" . '/includes/media.php'); } $upload = wp_upload_bits( $_FILES['file']['name'], null, file_get_contents( $_FILES['file']['tmp_name'] ) ); $wp_filetype = wp_check_filetype( basename( $upload['file'] ), null ); $check = getimagesize($_FILES["file"]["tmp_name"]); if($check !== false) { $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; wp_trash_post( $post_id ); } $wp_upload_dir = wp_upload_dir(); $attachment = array( guid' => $wp_upload_dir['baseurl'] . _wp_relative_upload_path( $upload['file'] ), 'post_mime_type' => $wp_filetype['type'], 'post_title' => preg_replace('/\.[^.]+$/', '', basename( $upload['file'] )), 'post_content' => '', 'post_author' => $user_id, 'post_status' => 'inherit' ); $attach_id = wp_insert_attachment( $attachment, $upload['file'], $post_id ); require_once(ABSPATH . 'wp-admin/includes/image.php'); $attach_data = wp_generate_attachment_metadata( $attach_id, $upload['file'] ); wp_update_attachment_metadata( $attach_id, $attach_data ); #Upload and Create attachment #Use attachment update_post_meta( $post_id, '_thumbnail_id', $attach_id ); #Use attachment break;
———— HTML ———–
<div class="post-window window-image"> <div class="window-left"> <textarea name="title_image" class="form-control" rows="1" placeholder="<?php _e('Post title', 'Aruna');?>"></textarea> Memes and GIFs -- Max size: 10MB <input type="file" class="upload" name="file" accept="image/*"/> <hr> <center><button type="button" class="btn btn-danger" data-toggle="collapse" data-target="#Info-ImagePost">Please read before posting</button></center> <div id="Info-ImagePost" class="collapse"> <div class="alert alert-info"> <em><p>If you dont know how to post please take a look at FAQ page: <a href="https://www.9tanks.com/faq/"><button type="button" class="btn btn-success btn-xs">FAQ</button></a></p></em> <em><p>If your post doesnt show or has a problem please report the post and in the shortest time we will resolve or you can delete your own post and try again</p></em> </div> </div> </div> <aside>
- The topic ‘How can i implement “your plugin” to my front end posting?’ is closed to new replies.