@@ -316,8 +316,9 @@ private static function generate_pattern_content(
316
316
* Function to generate the site meta according to the arguments passed
317
317
*
318
318
* @param array $site_info The Site Info object, will be validated for required params.
319
+ * @param array $site_classification The Site Classification object.
319
320
*/
320
- public static function generate_site_posts ( $ site_info ) {
321
+ public static function generate_site_posts ( $ site_info, $ site_classification ) {
321
322
322
323
// Generate AI Post Title and Content
323
324
$ site_posts = wp_remote_post (
@@ -349,12 +350,24 @@ public static function generate_site_posts( $site_info ) {
349
350
self ::cache_sitegen_response ( 'site-posts ' , $ site_posts );
350
351
}
351
352
353
+ $ post_patterns = self ::get_patterns_for_category ( 'text ' , $ site_classification );
354
+ $ post_patterns_slugs = Patterns::get_custom_post_patterns ();
355
+
352
356
$ post_dates = array ( '3 ' , '5 ' , '10 ' , '12 ' , '17 ' , '19 ' );
353
357
foreach ( $ site_posts ['posts ' ] as $ idx => $ post_data ) {
358
+
359
+ $ post_content = '' ;
360
+ if ( isset ( $ post_patterns_slugs [ $ idx ] ) ) {
361
+ foreach ( $ post_patterns_slugs [ $ idx ] as $ pattern_slug ) {
362
+ $ post_content .= $ post_patterns [ $ pattern_slug ]['content ' ];
363
+ }
364
+ }
365
+
354
366
$ post = array (
355
367
'post_status ' => 'publish ' ,
356
368
'post_title ' => $ post_data ['title ' ],
357
- 'post_content ' => $ post_data ['content ' ],
369
+ 'post_excerpt ' => $ post_data ['content ' ],
370
+ 'post_content ' => $ post_content ,
358
371
'post_date ' => gmdate ( 'Y-m-d H:i:s ' , strtotime ( 'last sunday - ' . $ post_dates [ $ idx ] . ' days ' ) ),
359
372
);
360
373
\wp_insert_post ( $ post );
@@ -448,7 +461,7 @@ public static function generate_site_meta( $site_info, $identifier, $skip_cache
448
461
}
449
462
450
463
if ( true === $ site_classification_mapping ['blog-posts-custom ' ][ $ parsed_response ['primaryType ' ] ][ $ parsed_response ['slug ' ] ] ) {
451
- self ::generate_site_posts ( $ site_info );
464
+ self ::generate_site_posts ( $ site_info, $ parsed_response );
452
465
}
453
466
}
454
467
0 commit comments