PluginProbe ʕ •ᴥ•ʔ
WP Create Multiple Posts & Pages / 1.0.4
WP Create Multiple Posts & Pages v1.0.4
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 / wp-create-multiple-posts-pages.php
wp-create-multiple-posts-pages Last commit date
assets 4 years ago includes 4 years ago readme.txt 4 years ago wp-create-multiple-posts-pages.php 4 years ago
wp-create-multiple-posts-pages.php
210 lines
1 <?php
2 /**
3 * Plugin Name: WP Create Multiple Posts & Pages
4 * Plugin URI: https://wordpress.org/plugins/wp-create-multiple-posts-pages/
5 * Description: Create Multiple Wordpress Posts & Pages At Once With a Single Click.
6 * Author: Sajjad Hossain Sagor
7 * Author URI: http://profiles.wordpress.org/sajjad67
8 * Version: 1.0.4
9 * License: GPL
10 * Text Domain: wp-create-multiple-posts-pages
11 */
12
13 /* Exit if accessed directly */
14 if ( ! defined( 'ABSPATH' ) ) exit;
15
16 // ---------------------------------------------------------
17 // Define Plugin Folders Path
18 // ---------------------------------------------------------
19 define( "WPCMP_PLUGIN_PATH", plugin_dir_path( __FILE__ ) );
20 define( "WPCMP_PLUGIN_URL", plugin_dir_url( __FILE__ ) );
21
22 /**
23 * Main Class
24 */
25 class WP_CREATE_MULTI_POSTS_PAGES
26 {
27 /**
28 * Load Plugin Files & Add Hooks
29 */
30 public function __construct()
31 {
32 add_action( 'init', array( $this, 'init' ) );
33
34 add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
35 }
36
37 /**
38 *
39 */
40 public function init()
41 {
42 add_action( 'admin_menu', array( $this, 'add_menu_page' ) );
43 }
44
45 /**
46 * Add Plugin Settings page to wp menu dashboard
47 */
48 public function add_menu_page()
49 {
50 add_menu_page( 'Multiple Posts', 'Multiple Posts', 'manage_options' , 'wp-add-multiple-posts', array( $this, 'wp_add_multiple_posts' ), 'dashicons-menu' );
51 }
52
53 /**
54 * Multi Post Creating Form
55 */
56 public function wp_add_multiple_posts()
57 {
58 $post_types = $this->get_custom_post_types();
59
60 require_once WPCMP_PLUGIN_PATH . 'includes/settings.php'; ?>
61
62 <div class="wrap">
63
64 <h2>Create Multiple Posts</h2>
65
66 <?php if ( isset( $wpcmp_show_message ) ) : ?>
67
68 <div class="notice notice-<?php echo $wpcmp_show_message; ?> is-dismissible posts_create_success_failure_message">
69 <p><?php echo $wpcmp_message; ?></p>
70 </div>
71
72 <?php $i = 0; ?>
73
74 <div class="notice notice-success is-dismissible" style="padding-right: 10px;">
75
76 <h2>Created Posts :</h2>
77
78 <div class="container-fluid">
79 <?php foreach ( $created_posts as $id ) : $i++; ?>
80 <div class="row" style="border-bottom: 1px solid lightgrey;">
81 <p class="col-md-11" style="line-height: 28px;"><?php echo esc_html( get_the_title( $id ) ); ?></p>
82
83 <p class="col-md-1" style="text-align: right;"><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>
84 </div>
85 <?php endforeach; ?>
86 </div>
87 </div>
88
89 <?php endif; ?>
90
91 <form action="" method="post">
92 <div class="form-group">
93 <p class="col-form-label insert_note">Insert Posts Title One Per Line...</p>
94 <textarea class="form-control new_line_bg new_line_number" name="wpcmp_posts_titles" id="wpcmp_posts_titles" cols="30" rows="8"></textarea>
95 </div>
96 <div class="form-group">
97 <div class="row">
98 <div class="col">
99 <p class="col-form-label insert_note">Post Type</p>
100 <select name="wpcmp_new_post_type" id="wpcmp_new_post_type" class="form-control" disabled>
101
102 <?php foreach ( $post_types as $post_type ) : ?>
103
104 <option value="<?php echo $post_type; ?>"><?php echo ucfirst( $post_type ) ?></option>
105
106 <?php endforeach ?>
107
108 </select>
109 </div>
110 <div class="col">
111 <p class="col-form-label insert_note">Post Status</p>
112 <select name="wpcmp_new_post_status" id="wpcmp_new_post_status" class="form-control" disabled>
113 <!-- <option value="" disabled selected style="display:none"></option> -->
114 <option value="publish">Publish</option>
115 <option value="draft">Draft</option>
116 <option value="pending">Pending</option>
117 <option value="private">Private</option>
118 </select>
119 </div>
120
121 <div class="col">
122 <p class="col-form-label insert_note">Post Author</p>
123 <select name="wpcmp_new_post_author" id="wpcmp_new_post_author" class="form-control" disabled>
124 <!-- <option value="" disabled selected style="display:none"></option> -->
125 <?php
126
127 $users = get_users( 'who=authors' );
128
129 foreach ( $users as $user ) {
130
131 echo '<option value="'.$user->ID.'">'.ucwords( str_replace( "_", " ", $user->user_login ) ).'</option>';
132 }
133 ?>
134 </select>
135 </div>
136
137 <div class="col">
138 <p class="col-form-label insert_note">Post Category (<small>Posts Only)</small></p>
139 <select name="wpcmp_new_post_category[]" id="wpcmp_new_post_category" class="form-control" multiple disabled>
140 <?php
141 foreach ( get_categories() as $category ) {
142
143 echo '<option value="'.$category->term_id.'">'.ucwords( str_replace( "_", " ", $category->cat_name ) ).'</option>';
144 }
145 ?>
146 </select>
147 </div>
148 </div>
149 </div>
150
151 <?php wp_nonce_field( 'wpcmp_create_posts', 'wpcmp_nonce' ); ?>
152
153 <button type="submit" class="button" name="wpcmp_submit_for_create_posts" id="wpcmp_submit_for_create_posts" disabled>Add Posts</button>
154
155 </form>
156 </div>
157
158 <?php }
159
160 /**
161 * Enqueue JS & CSS Files
162 */
163 public function admin_enqueue_scripts()
164 {
165 wp_enqueue_style ( 'wpcmp_bootstrap_css', WPCMP_PLUGIN_URL . '/assets/css/bootstrap.css', false );
166
167 wp_enqueue_style ( 'wpcmpselect2_css', WPCMP_PLUGIN_URL . 'assets/css/select2.min.css', true );
168
169 wp_enqueue_style ( 'wpcmp_style_css', WPCMP_PLUGIN_URL . '/assets/css/style.css', false );
170
171 wp_enqueue_script( 'wpcmpselect2_js', WPCMP_PLUGIN_URL . 'assets/js/select2.min.js', true );
172
173 wp_enqueue_script( 'wpcmp_popper_js', WPCMP_PLUGIN_URL . '/assets/js/popper.min.js', true );
174
175 wp_enqueue_script( 'wpcmp_bootstrap_js', WPCMP_PLUGIN_URL . '/assets/js/bootstrap.min.js', array( 'jquery', 'wpcmp_popper_js' ), true );
176
177 wp_enqueue_script( 'wpcmp_linedtextarea', WPCMP_PLUGIN_URL . '/assets/js/linedtextarea.js', array( 'jquery' ), true );
178
179 wp_enqueue_script( 'wpcmp_script', WPCMP_PLUGIN_URL . '/assets/js/script.js', array( 'jquery' ), true );
180 }
181
182 /**
183 * Get All Custom Post Types Registered By Others
184 */
185 function get_custom_post_types()
186 {
187 $all_post_types = array( 'post', 'page' );
188
189 $args = array(
190 'public' => true,
191 '_builtin' => false,
192 );
193
194 $output = 'names'; // names or objects, note names is the default
195
196 $operator = 'and'; // 'and' or 'or'
197
198 $post_types = get_post_types( $args, $output, $operator );
199
200 if ( ! empty( $post_types ) )
201 {
202 $all_post_types = array_merge( $all_post_types, $post_types );
203 }
204
205 return $all_post_types;
206 }
207 }
208
209 $WP_CREATE_MULTI_POSTS_PAGES = new WP_CREATE_MULTI_POSTS_PAGES();
210