PluginProbe ʕ •ᴥ•ʔ
WP Create Multiple Posts & Pages / 1.0.3
WP Create Multiple Posts & Pages v1.0.3
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
settings.php 5 years ago
settings.php
65 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.'; exit;
11
12 }else{
13
14 extract( $_POST );
15
16 if ( ! empty( $wpcmp_posts_titles ) ) {
17
18 $posts_titles = explode( "\n", $wpcmp_posts_titles );
19
20 $category_id = array( 1 );
21
22 if ( ! empty( $wpcmp_new_post_category ) ) {
23
24 foreach ( $wpcmp_new_post_category as $id ) {
25
26 if ( ! in_array( $id, $category_id ) ) {
27
28 $category_id[] = $id;
29 }
30 }
31 }
32
33 $created_posts = array();
34
35 foreach ( $posts_titles as $post_title ) {
36
37 $post = array(
38 'post_title' => wp_strip_all_tags( $post_title ),
39 'post_content' => '',
40 'post_type' => $wpcmp_new_post_type,
41 'post_status' => $wpcmp_new_post_status,
42 'post_author' => $wpcmp_new_post_author,
43 'post_category' => $category_id
44 );
45
46 // Insert the post into the database
47 $post_id = wp_insert_post( $post );
48
49 if( ! is_wp_error( $post_id ) ){
50
51 //the post is valid
52 $wpcmp_show_message = 'success';
53
54 $created_posts[] = $post_id;
55 }
56 }
57
58 if ( $wpcmp_show_message && $wpcmp_show_message == 'success' ) {
59
60 $wpcmp_message = 'Posts Successfully Created!';
61 }
62 }
63 }
64 }
65