PluginProbe ʕ •ᴥ•ʔ
WP Create Multiple Posts & Pages / trunk
WP Create Multiple Posts & Pages vtrunk
trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4
wp-create-multiple-posts-pages / includes / settings.php
wp-create-multiple-posts-pages / includes Last commit date
dashboard.php 6 years ago enqueue.php 6 years ago settings.php 6 years ago
settings.php
68 lines
1 <?php
2
3 if( isset( $_POST['wpcmp_submit_for_create_posts'] ) ){
4
5 if (
6 ! isset( $_POST['wpcmp_nonce'] )
7 || ! wp_verify_nonce( $_POST['wpcmp_nonce'], 'wpcmp_create_posts' )
8 ) {
9
10 print 'Sorry, your nonce did not verify.';
11 exit;
12
13 }else{
14
15 extract( $_POST );
16
17 if ( !empty( $wpcmp_posts_titles ) ) {
18
19 $posts_titles = explode( "\n", $wpcmp_posts_titles );
20
21 $category_id = array(1);
22
23 if ( !empty( $wpcmp_new_post_category ) ) {
24
25 foreach ( $wpcmp_new_post_category as $id ) {
26
27 if ( !in_array( $id, $category_id ) ) {
28
29 $category_id[] = $id;
30 }
31 }
32 }
33
34 $created_posts = array();
35
36 foreach ( $posts_titles as $post_title ) {
37
38 $post = array(
39 'post_title' => wp_strip_all_tags( $post_title ),
40 'post_content' => '',
41 'post_type' => $wpcmp_new_post_type,
42 'post_status' => $wpcmp_new_post_status,
43 'post_author' => $wpcmp_new_post_author,
44 'post_category' => $category_id
45 );
46
47 // Insert the post into the database
48 $post_id = wp_insert_post( $post );
49
50 if( !is_wp_error( $post_id ) ){
51
52 //the post is valid
53 $wpcmp_show_message = 'success';
54
55 $created_posts[] = $post_id;
56
57 }
58 }
59
60 if ( $wpcmp_show_message && $wpcmp_show_message == 'success' ) {
61
62 $wpcmp_message = 'Posts Successfully Created!';
63 }
64 }
65 }
66 }
67
68 ?>