PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.8.0
Kubio AI Page Builder v2.8.0
2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / lib / AI / Blog / BlogContent.php
kubio / lib / AI / Blog Last commit date
BlogContent.php 9 months ago index.php 1 year ago
BlogContent.php
48 lines
1 <?php
2 namespace Kubio\Ai;
3
4 class BlogContent {
5 public static function generate_ipsum( $paragraphs = 6 ) {
6 $faker = \Faker\Factory::create();
7 // faker lorem
8 return $faker->paragraphs( $paragraphs, true );
9 }
10
11 public static function save_articles_by_category( $articles = array(), $category_id = 0 ) {
12 $posts = array();
13 if ( ! empty( $articles ) ) {
14 foreach ( $articles as $article ) {
15 $content = self::generate_ipsum(
16 wp_rand( 5, 8 )
17 );
18
19 $post_id = wp_insert_post(
20 array(
21 'post_title' => $article['title'],
22 'post_status' => 'publish',
23 'post_type' => 'post',
24 'post_content' => $content,
25 'meta_input' => array(
26 '_kubio_created_post' => 1,
27 '_kubio_post_image_keywords' => $article['imageKeywords'],
28 ),
29 )
30 );
31
32 if ( ! is_wp_error( $post_id ) ) {
33 wp_set_post_categories( $post_id, $category_id, false );
34 $attach_id = PostImage::get_featured_image_from_keywords(
35 $article['imageKeywords']
36 );
37 if ( is_int( $attach_id ) ) {
38 set_post_thumbnail( $post_id, $attach_id );
39 }
40
41 $posts[] = $post_id;
42 }
43 }
44 }
45 return $posts;
46 }
47 }
48