|
15 | 15 |
|
16 | 16 | function quick_weblog_form() { |
17 | 17 | ?> |
18 | | - <form method="post" action="<?php echo esc_url( admin_url('admin-post.php') ); ?>"> |
19 | | - <label for="title"><?php _e( 'Title', 'quick-weblog' ); ?></label> |
20 | | - <input type="text" name="title" id="title" required> |
21 | | - |
22 | | - <label for="image_url"><?php _e( 'Image URL', 'quick-weblog' ); ?></label> |
23 | | - <input type="text" name="image_url" id="image_url" required> |
24 | | - |
25 | | - <label for="image_description"><?php _e( 'Image Description', 'quick-weblog' ); ?></label> |
26 | | - <textarea name="image_description" id="image_description" required></textarea> |
27 | | - |
28 | | - <label for="quote"><?php _e( 'Quote', 'quick-weblog' ); ?></label> |
29 | | - <textarea name="quote" id="quote" required></textarea> |
30 | | - |
31 | | - <label for="url"><?php _e( 'URL', 'quick-weblog' ); ?></label> |
32 | | - <input type="text" name="url" id="url" required> |
33 | | - |
34 | | - <label for="category"><?php _e( 'Category', 'quick-weblog' ); ?></label> |
35 | | - <?php wp_dropdown_categories( array( 'name' => 'category', 'orderby' => 'name', 'taxonomy' => 'category' ) ); ?> |
36 | | - |
37 | | - <label for="tags"><?php _e( 'Tags', 'quick-weblog' ); ?></label> |
38 | | - <input type="text" name="tags" id="tags" required> |
39 | | - |
40 | | - <input type="hidden" name="action" value="quick_weblog_submit_form"> |
41 | | - <?php wp_nonce_field( 'quick_weblog_submit_form', 'quick_weblog_form_nonce' ); ?> |
42 | | - <input type="submit" value="<?php _e( 'Submit', 'quick-weblog' ); ?>"> |
| 18 | + <style> |
| 19 | + #quick-weblog { |
| 20 | + background-color: red; |
| 21 | + padding: 20px; |
| 22 | + } |
| 23 | + #quick-weblog div { |
| 24 | + border: 2px solid yellow; |
| 25 | + background-color: lightblue; |
| 26 | + padding: 20px; |
| 27 | + } |
| 28 | + </style> |
| 29 | + |
| 30 | + <form id="quick-weblog" method="post" action="<?php echo esc_url( admin_url('admin-post.php') ); ?>"> |
| 31 | + <div> |
| 32 | + <label for="title"><?php _e( 'Title', 'quick-weblog' ); ?></label> |
| 33 | + <input type="text" name="title" id="title" required> |
| 34 | + </div> |
| 35 | + |
| 36 | + <div> |
| 37 | + <label for="image_url"><?php _e( 'Image URL', 'quick-weblog' ); ?></label> |
| 38 | + <input type="text" name="image_url" id="image_url" required> |
| 39 | + </div> |
| 40 | + |
| 41 | + <div> |
| 42 | + <label for="image_description"><?php _e( 'Image Description', 'quick-weblog' ); ?></label> |
| 43 | + <textarea name="image_description" id="image_description" required></textarea> |
| 44 | + </div> |
| 45 | + |
| 46 | + <div> |
| 47 | + <label for="quote"><?php _e( 'Quote', 'quick-weblog' ); ?></label> |
| 48 | + <textarea name="quote" id="quote" required></textarea> |
| 49 | + </div> |
| 50 | + |
| 51 | + <div> |
| 52 | + <label for="url"><?php _e( 'URL', 'quick-weblog' ); ?></label> |
| 53 | + <input type="text" name="url" id="url" required> |
| 54 | + </div> |
| 55 | + |
| 56 | + <div> |
| 57 | + <label for="category"><?php _e( 'Category', 'quick-weblog' ); ?></label> |
| 58 | + <?php wp_dropdown_categories( array( 'name' => 'category', 'orderby' => 'name', 'taxonomy' => 'category' ) ); ?> |
| 59 | + </div> |
| 60 | + |
| 61 | + <div> |
| 62 | + <label for="tags"><?php _e( 'Tags', 'quick-weblog' ); ?></label> |
| 63 | + <input type="text" name="tags" id="tags" required> |
| 64 | + </div> |
| 65 | + |
| 66 | + <div> |
| 67 | + <input type="hidden" name="action" value="quick_weblog_submit_form"> |
| 68 | + <?php wp_nonce_field( 'quick_weblog_submit_form', 'quick_weblog_form_nonce' ); ?> |
| 69 | + <input type="submit" value="<?php _e( 'Submit', 'quick-weblog' ); ?>"> |
| 70 | + </div> |
43 | 71 | </form> |
44 | 72 | <?php |
45 | 73 | } |
@@ -89,7 +117,15 @@ function quick_weblog_submit_form() { |
89 | 117 | // Create a new post |
90 | 118 | $post_data = array( |
91 | 119 | 'post_title' => $title, |
92 | | - 'post_content' => sprintf( '<blockquote class="wp-block-quote"><figure class="wp-block-image"><img decoding="async" src="%s" alt><figcaption class="wp-element-caption">%s</figcaption></figure><p>%s</p><cite><a href="%s" target="_blank" rel="noreferrer noopener">%s</a></cite></blockquote>', $image_url, $image_description, $quote, $url, $url ), |
| 120 | + 'post_content' => sprintf( ' |
| 121 | + <blockquote class="wp-block-quote"> |
| 122 | + <figure class="wp-block-image"> |
| 123 | + <img decoding="async" src="%s" alt> |
| 124 | + <figcaption class="wp-element-caption">%s</figcaption> |
| 125 | + </figure><p>%s</p> |
| 126 | + <cite><a href="%s" target="_blank" rel="noreferrer noopener">%s</a></cite> |
| 127 | + </blockquote>' |
| 128 | + , $image_url, $image_description, $quote, $url, $url ), |
93 | 129 | 'post_category' => array( $category ), |
94 | 130 | 'tags_input' => $tags, |
95 | 131 | 'post_status' => 'publish' |
|
0 commit comments