|
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' ); ?>"> |
43 |
| - </form> |
| 18 | + <style> |
| 19 | + #quick-weblog { |
| 20 | + padding: 1em 0; |
| 21 | + } |
| 22 | + #quick-weblog div { |
| 23 | + padding: 0.75em 0; |
| 24 | + } |
| 25 | + #quick-weblog div:nth-last-child(1) { |
| 26 | + padding-bottom: 0; |
| 27 | + } |
| 28 | + #quick-weblog div:nth-child(1) { |
| 29 | + padding-top: 0; |
| 30 | + } |
| 31 | + #quick-weblog div label { |
| 32 | + font-weight: 600; |
| 33 | + } |
| 34 | + #quick-weblog div input, |
| 35 | + #quick-weblog div textarea, |
| 36 | + #quick-weblog div select { |
| 37 | + display: block; |
| 38 | + max-width: 600px; |
| 39 | + width: 99%; |
| 40 | + } |
| 41 | + #quick-weblog div input[type=submit] { |
| 42 | + width: auto; |
| 43 | + } |
| 44 | + </style> |
| 45 | + |
| 46 | + <div class="card"> |
| 47 | + <form id="quick-weblog" method="post" action="<?php echo esc_url( admin_url('admin-post.php') ); ?>"> |
| 48 | + <div> |
| 49 | + <label for="url"><?php _e( 'Post URL', 'quick-weblog' ); ?></label> |
| 50 | + <input type="text" name="url" id="url" required> |
| 51 | + </div> |
| 52 | + |
| 53 | + <div> |
| 54 | + <label for="title"><?php _e( 'Post Title', 'quick-weblog' ); ?></label> |
| 55 | + <input type="text" name="title" id="title" required> |
| 56 | + </div> |
| 57 | + |
| 58 | + <div> |
| 59 | + <label for="image_url"><?php _e( 'Image URL', 'quick-weblog' ); ?></label> |
| 60 | + <input type="text" name="image_url" id="image_url" required> |
| 61 | + </div> |
| 62 | + |
| 63 | + <div> |
| 64 | + <label for="image_description"><?php _e( 'Image Description', 'quick-weblog' ); ?></label> |
| 65 | + <input type="text" name="image_description" id="image_description" required> |
| 66 | + </div> |
| 67 | + |
| 68 | + <div> |
| 69 | + <label for="quote"><?php _e( 'Quote', 'quick-weblog' ); ?></label> |
| 70 | + <textarea name="quote" id="quote" rows="6" required></textarea> |
| 71 | + </div> |
| 72 | + |
| 73 | + <div> |
| 74 | + <label for="category"><?php _e( 'Category', 'quick-weblog' ); ?></label> |
| 75 | + <?php wp_dropdown_categories( array( 'name' => 'category', 'orderby' => 'name', 'taxonomy' => 'category', 'selected' => 1) ); ?> |
| 76 | + </div> |
| 77 | + |
| 78 | + <div> |
| 79 | + <label for="tags"><?php _e( 'Tags', 'quick-weblog' ); ?></label> |
| 80 | + <input type="text" name="tags" id="tags" required> |
| 81 | + </div> |
| 82 | + |
| 83 | + <div> |
| 84 | + <input type="hidden" name="action" value="quick_weblog_submit_form"> |
| 85 | + <?php wp_nonce_field( 'quick_weblog_submit_form', 'quick_weblog_form_nonce' ); ?> |
| 86 | + <input type="submit" value="<?php _e( 'Submit', 'quick-weblog' ); ?>"> |
| 87 | + </div> |
| 88 | + </form> |
| 89 | + </div> |
44 | 90 | <?php
|
45 | 91 | }
|
46 | 92 |
|
@@ -89,7 +135,15 @@ function quick_weblog_submit_form() {
|
89 | 135 | // Create a new post
|
90 | 136 | $post_data = array(
|
91 | 137 | 'post_title' => $title,
|
92 |
| - 'post_content' => sprintf( '<blockquote>%s</blockquote><img src="%s" alt="%s"><p><a href="%s" target="_blank">%s</a></p>', $quote, $image_url, $image_description, $url, $url ), |
| 138 | + 'post_content' => sprintf( ' |
| 139 | + <blockquote class="wp-block-quote"> |
| 140 | + <figure class="wp-block-image"> |
| 141 | + <img decoding="async" src="%s" alt> |
| 142 | + <figcaption class="wp-element-caption">%s</figcaption> |
| 143 | + </figure><p>%s</p> |
| 144 | + <cite><a href="%s" target="_blank" rel="noreferrer noopener">%s</a></cite> |
| 145 | + </blockquote>' |
| 146 | + , $image_url, $image_description, $quote, $url, $url ), |
93 | 147 | 'post_category' => array( $category ),
|
94 | 148 | 'tags_input' => $tags,
|
95 | 149 | 'post_status' => 'publish'
|
|
0 commit comments