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 / dashboard.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
dashboard.php
141 lines
1 <?php
2
3 function wpcmp_get_custom_post_types(){
4
5 $all_post_types = array( 'post', 'page' );
6
7 $args = array(
8 'public' => true,
9 '_builtin' => false,
10 );
11
12 $output = 'names'; // names or objects, note names is the default
13
14 $operator = 'and'; // 'and' or 'or'
15
16 $post_types = get_post_types( $args, $output, $operator );
17
18 if ( !empty( $post_types ) ) {
19
20 $all_post_types = array_merge( $all_post_types, $post_types );
21 }
22
23 return $all_post_types;
24 }
25
26 add_action('admin_menu', 'wpcmp_add_dashboard_page');
27
28 // ---------------------------------------------------------
29 // Add Plugin Settings page to wp dashboard
30 // ---------------------------------------------------------
31
32 function wpcmp_add_dashboard_page() {
33
34 add_menu_page( "Multiple Posts", "Multiple Posts", "manage_options" , "wp-add-multiple-posts", "wp_add_multiple_posts", "dashicons-menu" );
35 }
36
37 function wp_add_multiple_posts(){
38
39 wpcmp_get_custom_post_types();
40
41 require_once WPCMP_PLUGIN_PATH . 'includes/settings.php'; ?>
42
43 <div class="wrap">
44
45 <h2>Create Multiple Posts</h2>
46
47 <?php if ( isset( $wpcmp_show_message ) ) : ?>
48
49 <div class="notice notice-<?php echo $wpcmp_show_message; ?> is-dismissible posts_create_success_failure_message">
50 <p><?php echo $wpcmp_message; ?></p>
51 </div>
52
53 <?php $i = 0; ?>
54
55 <div class="notice notice-success is-dismissible row" style="padding-right: 10px;">
56
57 <h2>Created Posts :</h2>
58
59 <?php foreach ( $created_posts as $id ) : $i++; ?>
60
61 <p class="col-md-11" style="line-height: 28px;"><?php echo esc_html( get_the_title( $id ) ); ?></p>
62
63 <p class="col-md-1"><a href="<?php echo get_the_permalink($id); ?>" class='button' style="margin-right: 10px;">View</a><a href="<?php echo get_edit_post_link( $id ); ?>" class='button'>Edit</a></p>
64
65 <?php endforeach; ?>
66
67 </div>
68
69 <?php endif; ?>
70
71 <form action="" method="post">
72 <div class="form-group">
73 <p class="col-form-label insert_note">Insert Posts Title One Per Line...</p>
74 <textarea class="form-control new_line_bg new_line_number" name="wpcmp_posts_titles" id="wpcmp_posts_titles" cols="30" rows="8"></textarea>
75 </div>
76 <div class="form-group">
77 <div class="row">
78 <div class="col">
79 <p class="col-form-label insert_note">Post Type</p>
80 <select name="wpcmp_new_post_type" id="wpcmp_new_post_type" class="form-control" disabled>
81
82 <?php foreach ( wpcmp_get_custom_post_types() as $post_type ) : ?>
83
84 <option value="<?php echo $post_type; ?>"><?php echo ucfirst( $post_type ) ?></option>
85
86 <?php endforeach ?>
87
88 </select>
89 </div>
90 <div class="col">
91 <p class="col-form-label insert_note">Post Status</p>
92 <select name="wpcmp_new_post_status" id="wpcmp_new_post_status" class="form-control" disabled>
93 <!-- <option value="" disabled selected style="display:none"></option> -->
94 <option value="publish">Publish</option>
95 <option value="draft">Draft</option>
96 <option value="pending">Pending</option>
97 <option value="private">Private</option>
98 </select>
99 </div>
100
101 <div class="col">
102 <p class="col-form-label insert_note">Post Author</p>
103 <select name="wpcmp_new_post_author" id="wpcmp_new_post_author" class="form-control" disabled>
104 <!-- <option value="" disabled selected style="display:none"></option> -->
105 <?php
106
107 $users = get_users( 'who=authors' );
108
109 foreach ( $users as $user ) {
110
111 echo '<option value="'.$user->ID.'">'.ucwords( str_replace( "_", " ", $user->user_login ) ).'</option>';
112 }
113 ?>
114 </select>
115 </div>
116
117 <div class="col">
118 <p class="col-form-label insert_note">Post Category (<small>Posts Only)</small></p>
119 <select name="wpcmp_new_post_category[]" id="wpcmp_new_post_category" class="form-control" multiple disabled>
120 <?php
121
122 foreach ( get_categories() as $category ) {
123
124 echo '<option value="'.$category->term_id.'">'.ucwords( str_replace( "_", " ", $category->cat_name ) ).'</option>';
125 }
126 ?>
127 </select>
128 </div>
129 </div>
130 </div>
131
132 <?php wp_nonce_field( 'wpcmp_create_posts', 'wpcmp_nonce' ); ?>
133
134 <button type="submit" class="button" name="wpcmp_submit_for_create_posts" id="wpcmp_submit_for_create_posts" disabled>Add Posts</button>
135
136 </form>
137 </div>
138
139 <?php }
140
141 ?>