Version Description
Added template support - if templates exist in the theme will create a template dropdown to choose from when adding pages
=
Download this release
Release Info
Developer | DaganLev |
Plugin | Bulk Page Creator |
Version | 1.0.8 |
Comparing to | |
See all releases |
Code changes from version 1.0.7 to 1.0.8
- bulk-page-creator.php +18 -4
- my-script.js +8 -3
- my-style.css +0 -0
- readme.txt +8 -1
- screenshot-1.jpg +0 -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.
|
7 |
Author: Dagan Lev
|
8 |
Author URI: http://solid-code.co.uk
|
9 |
|
@@ -60,10 +60,10 @@ if (!class_exists("sc_bulk_page_creator")) {
|
|
60 |
function sc_bpc_page_create(){
|
61 |
if(isset($_POST['sc-pages'])&&$_POST['sc-pages']!=''){
|
62 |
//form submitted
|
63 |
-
if(preg_match_all('/(\d+\|(-|new)?\d+\|[^\n]*)/',$_POST['sc-pages'],$match_pg)){
|
64 |
$newpage = array();
|
65 |
foreach($match_pg[0] as $pg_res){
|
66 |
-
if(preg_match('/((\d+)\|((-|new)?\d+)\|(.*))/',$pg_res,$rres)){
|
67 |
$parent = -1;
|
68 |
if($rres[4]=='new'){
|
69 |
$parent = $newpage[str_ireplace('new','',$rres[3])];
|
@@ -82,12 +82,13 @@ if (!class_exists("sc_bulk_page_creator")) {
|
|
82 |
'post_status' => $_POST['posttype'],
|
83 |
'post_parent' => $parent,
|
84 |
'post_title' => rtrim($rres[5]),
|
|
|
85 |
'post_content' => $pcontent);
|
86 |
|
87 |
global $wpdb;
|
88 |
$params['menu_order'] = $wpdb->get_var("SELECT MAX(menu_order)+1 AS menu_order FROM {$wpdb->posts} WHERE post_type='page'");
|
89 |
$wpdb->flush();
|
90 |
-
|
91 |
$newpage[$rres[2]] = wp_insert_post($params);
|
92 |
}
|
93 |
}
|
@@ -113,10 +114,12 @@ if (!class_exists("sc_bulk_page_creator")) {
|
|
113 |
<input type="checkbox" id="multiPages" name="multiPages" checked="checked" /> Multiple Pages mode<br />
|
114 |
<small>allows you to create multiple pages by seperating them with a comma; I.E. test1,test2,test3 - will create three pages (do not leave any spaces).</small>
|
115 |
</p>
|
|
|
116 |
<table>
|
117 |
<tr>
|
118 |
<td>Page Name</td>
|
119 |
<td>Parent</td>
|
|
|
120 |
<td> </td>
|
121 |
</tr>
|
122 |
<tr>
|
@@ -124,6 +127,17 @@ if (!class_exists("sc_bulk_page_creator")) {
|
|
124 |
<td id="page_ids">
|
125 |
<?php wp_dropdown_pages('sort_column=menu_order&post_status=draft,publish&show_option_none=(No Parent)'); ?>
|
126 |
</td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
<td><input onclick="sc_add_page();" type="button" class="button-secondary" value="Add Page" /></td>
|
128 |
</tr>
|
129 |
</table>
|
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.8
|
7 |
Author: Dagan Lev
|
8 |
Author URI: http://solid-code.co.uk
|
9 |
|
60 |
function sc_bpc_page_create(){
|
61 |
if(isset($_POST['sc-pages'])&&$_POST['sc-pages']!=''){
|
62 |
//form submitted
|
63 |
+
if(preg_match_all('/(\d+\|(-|new)?\d+\|[^\|]*\|[^\n]*)/',$_POST['sc-pages'],$match_pg)){
|
64 |
$newpage = array();
|
65 |
foreach($match_pg[0] as $pg_res){
|
66 |
+
if(preg_match('/((\d+)\|((-|new)?\d+)\|([^\|]*)\|(.*))/',$pg_res,$rres)){
|
67 |
$parent = -1;
|
68 |
if($rres[4]=='new'){
|
69 |
$parent = $newpage[str_ireplace('new','',$rres[3])];
|
82 |
'post_status' => $_POST['posttype'],
|
83 |
'post_parent' => $parent,
|
84 |
'post_title' => rtrim($rres[5]),
|
85 |
+
'page_template' => rtrim($rres[6]),
|
86 |
'post_content' => $pcontent);
|
87 |
|
88 |
global $wpdb;
|
89 |
$params['menu_order'] = $wpdb->get_var("SELECT MAX(menu_order)+1 AS menu_order FROM {$wpdb->posts} WHERE post_type='page'");
|
90 |
$wpdb->flush();
|
91 |
+
|
92 |
$newpage[$rres[2]] = wp_insert_post($params);
|
93 |
}
|
94 |
}
|
114 |
<input type="checkbox" id="multiPages" name="multiPages" checked="checked" /> Multiple Pages mode<br />
|
115 |
<small>allows you to create multiple pages by seperating them with a comma; I.E. test1,test2,test3 - will create three pages (do not leave any spaces).</small>
|
116 |
</p>
|
117 |
+
<?php $templates = get_page_templates(); ?>
|
118 |
<table>
|
119 |
<tr>
|
120 |
<td>Page Name</td>
|
121 |
<td>Parent</td>
|
122 |
+
<?php echo($templates ? '<td>Template</td>' : ''); ?>
|
123 |
<td> </td>
|
124 |
</tr>
|
125 |
<tr>
|
127 |
<td id="page_ids">
|
128 |
<?php wp_dropdown_pages('sort_column=menu_order&post_status=draft,publish&show_option_none=(No Parent)'); ?>
|
129 |
</td>
|
130 |
+
<?php
|
131 |
+
if($templates){
|
132 |
+
echo '<td>
|
133 |
+
<select id="page_template" name="page_template">
|
134 |
+
<option value="">Default</option>';
|
135 |
+
foreach ( $templates as $template_name => $template_filename ) {
|
136 |
+
echo "<option value=\"$template_filename\">$template_name</option>";
|
137 |
+
}
|
138 |
+
echo '</select></td>';
|
139 |
+
}
|
140 |
+
?>
|
141 |
<td><input onclick="sc_add_page();" type="button" class="button-secondary" value="Add Page" /></td>
|
142 |
</tr>
|
143 |
</table>
|
my-script.js
CHANGED
@@ -68,9 +68,14 @@ function sc_add_page(){
|
|
68 |
}
|
69 |
}
|
70 |
var parent = jQuery('#page_id').val();
|
|
|
|
|
|
|
|
|
|
|
71 |
if(parent==''){
|
72 |
parent = -1;
|
73 |
-
jQuery('ul.sc-pages').append('<li class="page-item-new' + pageid + '">' + jQuery('#sc-page-name').val() + ' <a href="JavaScript:sc_del_page(' + pageid + ');">Remove</a></li>');
|
74 |
jQuery('#page_id').append('<option value="new' + pageid + '">' + jQuery('#sc-page-name').val() + '</option>');
|
75 |
}else{
|
76 |
var parentname = jQuery('#page_id option[value=' + parent + ']').html();
|
@@ -81,10 +86,10 @@ function sc_add_page(){
|
|
81 |
parentspace += ' ';
|
82 |
}
|
83 |
}
|
84 |
-
jQuery('li.page-item-' + parent).append('<li class="page-item-new' + pageid + '">' + jQuery('#sc-page-name').val() + ' <a href="JavaScript:sc_del_page(' + pageid + ');">Remove</a></li>');
|
85 |
jQuery('#page_id option[value=' + parent + ']').after('<option class="p_' + parent + '" value="new' + pageid + '">' + parentspace + jQuery('#sc-page-name').val() + '</option>');
|
86 |
}
|
87 |
-
jQuery('#sc-pages').val(jQuery('#sc-pages').val() + pageid + '|' + parent + '|' + jQuery('#sc-page-name').val() + '\n');
|
88 |
|
89 |
//reset the form
|
90 |
pageid++;
|
68 |
}
|
69 |
}
|
70 |
var parent = jQuery('#page_id').val();
|
71 |
+
var template = jQuery('#page_template').val();
|
72 |
+
var template_text = jQuery('#page_template option[value="'+ template +'"]').text();
|
73 |
+
if(!template) template = '';
|
74 |
+
if(!template_text) template_text = '';
|
75 |
+
|
76 |
if(parent==''){
|
77 |
parent = -1;
|
78 |
+
jQuery('ul.sc-pages').append('<li class="page-item-new' + pageid + '">' + jQuery('#sc-page-name').val() + (template!='' ? ' (' + template_text + ')' : '') + ' <a href="JavaScript:sc_del_page(' + pageid + ');">Remove</a></li>');
|
79 |
jQuery('#page_id').append('<option value="new' + pageid + '">' + jQuery('#sc-page-name').val() + '</option>');
|
80 |
}else{
|
81 |
var parentname = jQuery('#page_id option[value=' + parent + ']').html();
|
86 |
parentspace += ' ';
|
87 |
}
|
88 |
}
|
89 |
+
jQuery('li.page-item-' + parent).append('<li class="page-item-new' + pageid + '">' + jQuery('#sc-page-name').val() + (template!='' ? ' (' + template_text + ')' : '') + ' <a href="JavaScript:sc_del_page(' + pageid + ');">Remove</a></li>');
|
90 |
jQuery('#page_id option[value=' + parent + ']').after('<option class="p_' + parent + '" value="new' + pageid + '">' + parentspace + jQuery('#sc-page-name').val() + '</option>');
|
91 |
}
|
92 |
+
jQuery('#sc-pages').val(jQuery('#sc-pages').val() + pageid + '|' + parent + '|' + jQuery('#sc-page-name').val() + '|' + template + '\n');
|
93 |
|
94 |
//reset the form
|
95 |
pageid++;
|
my-style.css
CHANGED
File without changes
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Contributors: DaganLev
|
3 |
Tags: Solid Code, Dagan Lev, Bulk Page Creator, batch action, add pages, add posts
|
4 |
Requires at least: 3.1
|
5 |
-
Tested up to:
|
6 |
Stable tag: trunk
|
7 |
|
8 |
Allows you to create multiple pages in a batch/bulk manner saving time when initially setting up your WordPress site
|
@@ -43,6 +43,13 @@ Amended potential issue with safari and draft pages in JavaScript
|
|
43 |
= 1.0.7 =
|
44 |
Added script to add pages in the page section when accedently submitting form
|
45 |
|
|
|
|
|
|
|
46 |
== Screenshots ==
|
47 |
|
48 |
1. View of bulk page creator screen
|
|
|
|
|
|
|
|
2 |
Contributors: DaganLev
|
3 |
Tags: Solid Code, Dagan Lev, Bulk Page Creator, batch action, add pages, add posts
|
4 |
Requires at least: 3.1
|
5 |
+
Tested up to: 4.1
|
6 |
Stable tag: trunk
|
7 |
|
8 |
Allows you to create multiple pages in a batch/bulk manner saving time when initially setting up your WordPress site
|
43 |
= 1.0.7 =
|
44 |
Added script to add pages in the page section when accedently submitting form
|
45 |
|
46 |
+
= 1.0.8 =
|
47 |
+
Added template support - if templates exist in the theme will create a template dropdown to choose from when adding pages
|
48 |
+
|
49 |
== Screenshots ==
|
50 |
|
51 |
1. View of bulk page creator screen
|
52 |
+
|
53 |
+
== Upgrade Notice ==
|
54 |
+
|
55 |
+
Added template support - if templates exist in the theme will create a template dropdown to choose from when adding pages
|
screenshot-1.jpg
CHANGED
File without changes
|