Bulk Page Creator - Version 1.0.4

Version Description

Added a "draft" option to publish pages in draft status

=

Download this release

Release Info

Developer DaganLev
Plugin Icon wp plugin Bulk Page Creator
Version 1.0.4
Comparing to
See all releases

Code changes from version 1.0.3 to 1.0.4

Files changed (3) hide show
  1. bulk-page-creator.php +25 -8
  2. my-script.js +22 -0
  3. readme.txt +3 -0
bulk-page-creator.php CHANGED
@@ -3,7 +3,7 @@
3
Plugin Name: Bulk Page Creator
4
Plugin URI: http://solid-code.co.uk/2011/05/bulk-page-creator/
5
Description: Allows you to create multiple pages in a batch/bulk manner saving time when initially setting up your WordPress site.
6
- Version: 1.0.3
7
Author: Dagan Lev
8
Author URI: http://solid-code.co.uk
9
@@ -36,8 +36,10 @@ if (!class_exists("sc_bulk_page_creator")) {
36
if (isset($sc_bpc_var)) {
37
//Add Actions
38
add_action('admin_menu', 'sc_bpc_page');
39
- add_action('admin_print_scripts', 'sc_bpc_scripts');
40
- add_action('admin_print_styles', 'sc_bpc_styles');
41
}
42
43
function sc_bpc_page(){
@@ -77,7 +79,7 @@ if (!class_exists("sc_bulk_page_creator")) {
77
78
$params = array(
79
'post_type' => 'page',
80
- 'post_status' => 'publish',
81
'post_parent' => $parent,
82
'post_title' => rtrim($rres[5]),
83
'post_content' => $pcontent);
@@ -103,11 +105,10 @@ if (!class_exists("sc_bulk_page_creator")) {
103
<h3>Site Pages</h3>
104
<ul class="sc-pages">
105
<?php
106
- echo preg_replace('/<a[^>]*>([^<]*)<\/a>/','\\1',wp_list_pages('title_li=&echo=0'));
107
?>
108
</ul>
109
<h3>Add pages</h3>
110
-
111
<table>
112
<tr>
113
<td>Page Name</td>
@@ -117,7 +118,7 @@ if (!class_exists("sc_bulk_page_creator")) {
117
<tr>
118
<td><input size="50" type="text" id="sc-page-name" name="sc-page-name" /></td>
119
<td id="page_ids">
120
- <?php wp_dropdown_pages('sort_column=menu_order&show_option_none=(No Parent)'); ?>
121
</td>
122
<td><input onclick="sc_add_page();" type="button" class="button-secondary" value="Add Page" /></td>
123
</tr>
@@ -129,7 +130,11 @@ if (!class_exists("sc_bulk_page_creator")) {
129
<select id="pcontent" name="pcontent">
130
<option value="1">Create Empty Pages</option>
131
<option value="2">Set Pages Content</option>
132
- </select>
133
<div id="sc-pages-content-div" style="display:none;">
134
<p>
135
You can specify default content for all the pages in the text area below.<br />
@@ -140,6 +145,18 @@ if (!class_exists("sc_bulk_page_creator")) {
140
<input type="submit" class="button-primary" value="Update Site" />
141
</form>
142
</div>
143
<?php
144
}
145
}
3
Plugin Name: Bulk Page Creator
4
Plugin URI: http://solid-code.co.uk/2011/05/bulk-page-creator/
5
Description: Allows you to create multiple pages in a batch/bulk manner saving time when initially setting up your WordPress site.
6
+ Version: 1.0.4
7
Author: Dagan Lev
8
Author URI: http://solid-code.co.uk
9
36
if (isset($sc_bpc_var)) {
37
//Add Actions
38
add_action('admin_menu', 'sc_bpc_page');
39
+ if(isset($_GET['page'])&&$_GET['page']=='sc_bpc_page'){
40
+ add_action('admin_print_scripts', 'sc_bpc_scripts');
41
+ add_action('admin_print_styles', 'sc_bpc_styles');
42
+ }
43
}
44
45
function sc_bpc_page(){
79
80
$params = array(
81
'post_type' => 'page',
82
+ 'post_status' => $_POST['posttype'],
83
'post_parent' => $parent,
84
'post_title' => rtrim($rres[5]),
85
'post_content' => $pcontent);
105
<h3>Site Pages</h3>
106
<ul class="sc-pages">
107
<?php
108
+ echo preg_replace('/<a[^>]*>([^<]*)<\/a>/','\\1',wp_list_pages('title_li=&echo=0&post_status=draft,publish'));
109
?>
110
</ul>
111
<h3>Add pages</h3>
112
<table>
113
<tr>
114
<td>Page Name</td>
118
<tr>
119
<td><input size="50" type="text" id="sc-page-name" name="sc-page-name" /></td>
120
<td id="page_ids">
121
+ <?php wp_dropdown_pages('sort_column=menu_order&post_status=draft,publish&show_option_none=(No Parent)'); ?>
122
</td>
123
<td><input onclick="sc_add_page();" type="button" class="button-secondary" value="Add Page" /></td>
124
</tr>
130
<select id="pcontent" name="pcontent">
131
<option value="1">Create Empty Pages</option>
132
<option value="2">Set Pages Content</option>
133
+ </select><br /><br />
134
+ Pages Status: <select id="posttype" name="posttype">
135
+ <option value="publish">published</option>
136
+ <option value="draft">draft</option>
137
+ </select><br /><br />
138
<div id="sc-pages-content-div" style="display:none;">
139
<p>
140
You can specify default content for all the pages in the text area below.<br />
145
<input type="submit" class="button-primary" value="Update Site" />
146
</form>
147
</div>
148
+ <input type="hidden" id="pagesDraft" name="pagesDraft" value="<?php
149
+ $tmpDrafts = '';
150
+ $drafts = get_pages('post_status=draft&post_type=page&hierarchical=0');
151
+ foreach($drafts as $draft){
152
+ if($tmpDrafts==''){
153
+ $tmpDrafts = $draft->ID;
154
+ }else{
155
+ $tmpDrafts .= ',' . $draft->ID;
156
+ }
157
+ }
158
+ echo $tmpDrafts;
159
+ ?>" />
160
<?php
161
}
162
}
my-script.js CHANGED
@@ -20,6 +20,28 @@ jQuery(document).ready(function(){
20
}
21
}
22
});
23
});
24
25
function sc_add_page(){
20
}
21
}
22
});
23
+
24
+ //get the draft pages
25
+ var valDrafts = jQuery('#pagesDraft').val();
26
+ if(valDrafts!=''){
27
+ if(valDrafts.match(',')){
28
+ //its an array
29
+ var arrDrafts = valDrafts.split(",");
30
+ for(idraft=0;idraft<arrDrafts.length;idraft++){
31
+ if(jQuery('ul.sc-pages li.page-item-' + arrDrafts[idraft]).children('ul').size()>0){
32
+ jQuery('ul.sc-pages li.page-item-' + arrDrafts[idraft]).children('ul').before(' - <b style="font-size:12px;color:red;">draft</b>');
33
+ }else{
34
+ jQuery('ul.sc-pages li.page-item-' + arrDrafts[idraft]).append(' - <b style="font-size:12px;color:red;">draft</b>');
35
+ }
36
+ }
37
+ }else{
38
+ if(jQuery('ul.sc-pages li.page-item-' + valDrafts).children('ul').size()>0){
39
+ jQuery('ul.sc-pages li.page-item-' + valDrafts).children('ul').before(' - <b style="font-size:12px;color:red;">draft</b>');
40
+ }else{
41
+ jQuery('ul.sc-pages li.page-item-' + valDrafts).append(' - <b style="font-size:12px;color:red;">draft</b>');
42
+ }
43
+ }
44
+ }
45
});
46
47
function sc_add_page(){
readme.txt CHANGED
@@ -31,6 +31,9 @@ Fixed issue with extra spaces at end of page titles
31
= 1.0.3 =
32
Added a trigger when pressing enter on the page name to add it automatically to the list
33
34
== Screenshots ==
35
36
1. View of bulk page creator screen
31
= 1.0.3 =
32
Added a trigger when pressing enter on the page name to add it automatically to the list
33
34
+ = 1.0.4 =
35
+ Added a "draft" option to publish pages in draft status
36
+
37
== Screenshots ==
38
39
1. View of bulk page creator screen