PluginProbe ʕ •ᴥ•ʔ
WP Create Multiple Posts & Pages / 1.0.5
WP Create Multiple Posts & Pages v1.0.5
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
197 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.5
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 <h2>Create Multiple Posts</h2>
64 <?php if ( isset( $wpcmp_show_message ) ) : ?>
65 <div class="notice notice-<?php echo $wpcmp_show_message; ?> is-dismissible posts_create_success_failure_message">
66 <p><?php echo $wpcmp_message; ?></p>
67 </div>
68 <?php $i = 0; ?>
69 <div class="notice notice-success is-dismissible" style="padding-right: 10px;">
70 <h2>Created Posts :</h2>
71 <div class="container-fluid">
72 <?php foreach ( $created_posts as $id ) : $i++; ?>
73 <div class="row" style="border-bottom: 1px solid lightgrey;">
74 <p class="col-md-11" style="line-height: 28px;"><?php echo esc_html( get_the_title( $id ) ); ?></p>
75
76 <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>
77 </div>
78 <?php endforeach; ?>
79 </div>
80 </div>
81
82 <?php endif; ?>
83
84 <form action="" method="post">
85 <div class="form-group">
86 <p class="col-form-label insert_note">Insert Posts Title One Per Line...</p>
87 <textarea class="form-control new_line_bg new_line_number" name="wpcmp_posts_titles" id="wpcmp_posts_titles" cols="30" rows="8"></textarea>
88 </div>
89 <div class="form-group">
90 <div class="row">
91 <div class="col">
92 <p class="col-form-label insert_note">Post Type</p>
93 <select name="wpcmp_new_post_type" id="wpcmp_new_post_type" class="form-control" disabled>
94 <?php foreach ( $post_types as $post_type ) : ?>
95 <option value="<?php echo $post_type; ?>"><?php echo ucfirst( $post_type ) ?></option>
96 <?php endforeach ?>
97 </select>
98 </div>
99 <div class="col">
100 <p class="col-form-label insert_note">Post Status</p>
101 <select name="wpcmp_new_post_status" id="wpcmp_new_post_status" class="form-control" disabled>
102 <!-- <option value="" disabled selected style="display:none"></option> -->
103 <option value="publish">Publish</option>
104 <option value="draft">Draft</option>
105 <option value="pending">Pending</option>
106 <option value="private">Private</option>
107 </select>
108 </div>
109
110 <div class="col">
111 <p class="col-form-label insert_note">Post Author</p>
112 <select name="wpcmp_new_post_author" id="wpcmp_new_post_author" class="form-control" disabled>
113 <!-- <option value="" disabled selected style="display:none"></option> -->
114 <?php
115
116 $users = get_users( 'who=authors' );
117
118 foreach ( $users as $user ) {
119
120 echo '<option value="'.$user->ID.'">'.ucwords( str_replace( "_", " ", $user->user_login ) ).'</option>';
121 }
122 ?>
123 </select>
124 </div>
125
126 <div class="col">
127 <p class="col-form-label insert_note">Post Category (<small>Posts Only)</small></p>
128 <select name="wpcmp_new_post_category[]" id="wpcmp_new_post_category" class="form-control" multiple disabled>
129 <?php
130 foreach ( get_categories() as $category ) {
131
132 echo '<option value="'.$category->term_id.'">'.ucwords( str_replace( "_", " ", $category->cat_name ) ).'</option>';
133 }
134 ?>
135 </select>
136 </div>
137 </div>
138 </div>
139 <?php wp_nonce_field( 'wpcmp_create_posts', 'wpcmp_nonce' ); ?>
140
141 <button type="submit" class="button" name="wpcmp_submit_for_create_posts" id="wpcmp_submit_for_create_posts" disabled>Add Posts</button>
142 </form>
143 </div>
144
145 <?php }
146
147 /**
148 * Enqueue JS & CSS Files
149 */
150 public function admin_enqueue_scripts()
151 {
152 wp_enqueue_style ( 'wpcmp_bootstrap_css', WPCMP_PLUGIN_URL . '/assets/css/bootstrap.css', false );
153
154 wp_enqueue_style ( 'wpcmpselect2_css', WPCMP_PLUGIN_URL . 'assets/css/select2.min.css', true );
155
156 wp_enqueue_style ( 'wpcmp_style_css', WPCMP_PLUGIN_URL . '/assets/css/style.css', false );
157
158 wp_enqueue_script( 'wpcmpselect2_js', WPCMP_PLUGIN_URL . 'assets/js/select2.min.js', true );
159
160 wp_enqueue_script( 'wpcmp_popper_js', WPCMP_PLUGIN_URL . '/assets/js/popper.min.js', true );
161
162 wp_enqueue_script( 'wpcmp_bootstrap_js', WPCMP_PLUGIN_URL . '/assets/js/bootstrap.min.js', array( 'jquery', 'wpcmp_popper_js' ), true );
163
164 wp_enqueue_script( 'wpcmp_linedtextarea', WPCMP_PLUGIN_URL . '/assets/js/linedtextarea.js', array( 'jquery' ), true );
165
166 wp_enqueue_script( 'wpcmp_script', WPCMP_PLUGIN_URL . '/assets/js/script.js', array( 'jquery' ), true );
167 }
168
169 /**
170 * Get All Custom Post Types Registered By Others
171 */
172 function get_custom_post_types()
173 {
174 $all_post_types = array( 'post', 'page' );
175
176 $args = array(
177 'public' => true,
178 '_builtin' => false,
179 );
180
181 $output = 'names'; // names or objects, note names is the default
182
183 $operator = 'and'; // 'and' or 'or'
184
185 $post_types = get_post_types( $args, $output, $operator );
186
187 if ( ! empty( $post_types ) )
188 {
189 $all_post_types = array_merge( $all_post_types, $post_types );
190 }
191
192 return $all_post_types;
193 }
194 }
195
196 $WP_CREATE_MULTI_POSTS_PAGES = new WP_CREATE_MULTI_POSTS_PAGES();
197