@@ -132,18 +132,25 @@ function quick_weblog_submit_form() {
132
132
$ category = intval ( $ _POST ['category ' ] );
133
133
$ tags = sanitize_text_field ( $ _POST ['tags ' ] );
134
134
135
+ // Create block content
136
+ $ image_block = '<!-- wp:image {"url":" ' . esc_attr ($ image_url ) . '","alt":" ' . esc_attr ($ image_description ) . '"} --> ' .
137
+ '<figure class="wp-block-image"> ' .
138
+ '<img src=" ' . esc_url ($ image_url ) . '" alt=" ' . esc_attr ($ image_description ) . '"> ' .
139
+ '<figcaption> ' . esc_html ($ image_description ) . '</figcaption> ' .
140
+ '</figure><!-- /wp:image --> ' ;
141
+
142
+ $ quote_block = '<!-- wp:quote {"citation":" ' . esc_attr ($ url ) . '"} --> ' .
143
+ '<blockquote class="wp-block-quote"> ' .
144
+ '<p> ' . esc_html ($ quote ) . '</p> ' .
145
+ '<cite><a href=" ' . esc_url ($ url ) . '" target="_blank" rel="noreferrer noopener"> ' . esc_html ($ url ) . '</a></cite> ' .
146
+ '</blockquote><!-- /wp:quote --> ' ;
147
+
148
+ $ block_content = $ image_block . $ quote_block ;
149
+
135
150
// Create a new post
136
151
$ post_data = array (
137
152
'post_title ' => $ title ,
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 ),
153
+ 'post_content ' => $ block_content ,
147
154
'post_category ' => array ( $ category ),
148
155
'tags_input ' => $ tags ,
149
156
'post_status ' => 'publish '
0 commit comments