Version Description
- Initial setup
=
Download this release
Release Info
Developer | DaganLev |
Plugin | Bulk Page Creator |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- bulk-page-creator.php +130 -0
- my-script.js +55 -0
- my-style.css +6 -0
- readme.txt +31 -0
- screenshot-1.jpg +0 -0
bulk-page-creator.php
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
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.0
|
7 |
+
Author: Dagan Lev
|
8 |
+
Author URI: http://solid-code.co.uk
|
9 |
+
|
10 |
+
Copyright 2011 Solid Code (email : dagan@solid-code.co.uk)
|
11 |
+
|
12 |
+
This program is free software; you can redistribute it and/or modify
|
13 |
+
it under the terms of the GNU General Public License, version 2, as
|
14 |
+
published by the Free Software Foundation.
|
15 |
+
|
16 |
+
This program is distributed in the hope that it will be useful,
|
17 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
+
GNU General Public License for more details.
|
20 |
+
|
21 |
+
You should have received a copy of the GNU General Public License
|
22 |
+
along with this program; if not, write to the Free Software
|
23 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
24 |
+
*/
|
25 |
+
if (!class_exists("sc_bulk_page_creator")) {
|
26 |
+
class sc_bulk_page_creator{
|
27 |
+
//the constructor that initializes the class
|
28 |
+
function sc_bulk_page_creator() {
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
//initialize the class to a variable
|
33 |
+
$sc_bpc_var = new sc_bulk_page_creator();
|
34 |
+
|
35 |
+
//Actions and Filters
|
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(){
|
44 |
+
//add the options page for this plugin
|
45 |
+
add_options_page('Bulk Page Creator','Bulk Page Creator','manage_options','sc_bpc_page','sc_bpc_page_create');
|
46 |
+
}
|
47 |
+
|
48 |
+
function sc_bpc_scripts(){
|
49 |
+
wp_register_script('sc-bpc-js', WP_PLUGIN_URL.'/bulk-page-creator/my-script.js', array('jquery'));
|
50 |
+
wp_enqueue_script('sc-bpc-js');
|
51 |
+
}
|
52 |
+
|
53 |
+
function sc_bpc_styles(){
|
54 |
+
wp_register_style('sc-bpc-css',WP_PLUGIN_URL.'/bulk-page-creator/my-style.css');
|
55 |
+
wp_enqueue_style('sc-bpc-css');
|
56 |
+
}
|
57 |
+
|
58 |
+
function sc_bpc_page_create(){
|
59 |
+
if(isset($_POST['sc-pages'])&&$_POST['sc-pages']!=''){
|
60 |
+
//form submitted
|
61 |
+
if(preg_match_all('/(\d+\|(-|new)?\d+\|[^\n]*)/',$_POST['sc-pages'],$match_pg)){
|
62 |
+
$newpage = array();
|
63 |
+
foreach($match_pg[0] as $pg_res){
|
64 |
+
if(preg_match('/((\d+)\|((-|new)?\d+)\|(.*))/',$pg_res,$rres)){
|
65 |
+
$parent = -1;
|
66 |
+
if($rres[4]=='new'){
|
67 |
+
$parent = $newpage[str_ireplace('new','',$rres[3])];
|
68 |
+
}else{
|
69 |
+
$parent = $rres[3];
|
70 |
+
}
|
71 |
+
if($parent==-1) $parent = 0;
|
72 |
+
|
73 |
+
$params = array(
|
74 |
+
'post_type' => 'page',
|
75 |
+
'post_status' => 'publish',
|
76 |
+
'post_parent' => $parent,
|
77 |
+
'post_title' => $rres[5],
|
78 |
+
'post_content' => '<h1>' . htmlentities($rres[5]) . '</h1>');
|
79 |
+
|
80 |
+
global $wpdb;
|
81 |
+
$params['menu_order'] = $wpdb->get_var("SELECT MAX(menu_order)+1 AS menu_order FROM {$wpdb->posts} WHERE post_type='page'");
|
82 |
+
$wpdb->flush();
|
83 |
+
|
84 |
+
$newpage[$rres[2]] = wp_insert_post($params);
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
echo '<script type="text/javascript">window.location=\'options-general.php?page=sc_bpc_page&saved=1\';</script>';
|
89 |
+
}
|
90 |
+
}
|
91 |
+
?>
|
92 |
+
<div class="wrap" id="sc-bpc-div">
|
93 |
+
<?php if($_GET['saved']=='1'){ ?>
|
94 |
+
<div id="setting-error-settings_updated" class="updated settings-error"><p><strong>Settings saved.</strong></p></div>
|
95 |
+
<?php } ?>
|
96 |
+
<h2>Bulk Page Creator</h2>
|
97 |
+
<p>Use the form below to add pages to the site, you can also remove pages you added and eventually just click on "Update Site" to bulk execute and create all pages on site.</p>
|
98 |
+
<h3>Site Pages</h3>
|
99 |
+
<ul class="sc-pages">
|
100 |
+
<?php
|
101 |
+
echo preg_replace('/<a[^>]*>([^<]*)<\/a>/','\\1',wp_list_pages('title_li=&echo=0'));
|
102 |
+
?>
|
103 |
+
</ul>
|
104 |
+
<h3>Add pages</h3>
|
105 |
+
|
106 |
+
<table>
|
107 |
+
<tr>
|
108 |
+
<td>Page Name</td>
|
109 |
+
<td>Parent</td>
|
110 |
+
<td> </td>
|
111 |
+
</tr>
|
112 |
+
<tr>
|
113 |
+
<td><input size="50" type="text" id="sc-page-name" name="sc-page-name" /></td>
|
114 |
+
<td id="page_ids">
|
115 |
+
<?php wp_dropdown_pages('sort_column=menu_order&show_option_none=(No Parent)'); ?>
|
116 |
+
</td>
|
117 |
+
<td><input onclick="sc_add_page();" type="button" class="button-secondary" value="Add Page" /></td>
|
118 |
+
</tr>
|
119 |
+
</table>
|
120 |
+
|
121 |
+
<form id="sc-add-pages" name="sc-add-pages" method="post" action="?page=<?php echo $_GET['page']; ?>">
|
122 |
+
<textarea id="sc-pages" name="sc-pages" style="display:none;"></textarea>
|
123 |
+
<p>When you are ready to commit your changes to the site just click the button below...</p>
|
124 |
+
<input type="submit" class="button-primary" value="Update Site" />
|
125 |
+
</form>
|
126 |
+
</div>
|
127 |
+
<?php
|
128 |
+
}
|
129 |
+
}
|
130 |
+
?>
|
my-script.js
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var pageid = 0;
|
2 |
+
|
3 |
+
jQuery(document).ready(function(){
|
4 |
+
if(jQuery('#page_id').size()==0){
|
5 |
+
jQuery('#page_ids').append('<select id="page_id" name="page_id"><option value="">(No Parent)</option></select>');
|
6 |
+
}
|
7 |
+
});
|
8 |
+
|
9 |
+
function sc_add_page(){
|
10 |
+
//sc-page-name
|
11 |
+
//page_id
|
12 |
+
var chkfrm = '';
|
13 |
+
if(jQuery('#sc-page-name').val()=='') chkfrm += 'Please enter a page name\n';
|
14 |
+
|
15 |
+
if(chkfrm==''){
|
16 |
+
var parent = jQuery('#page_id').val();
|
17 |
+
if(parent==''){
|
18 |
+
parent = -1;
|
19 |
+
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>');
|
20 |
+
jQuery('#page_id').append('<option value="new' + pageid + '">' + jQuery('#sc-page-name').val() + '</option>');
|
21 |
+
}else{
|
22 |
+
var parentname = jQuery('#page_id option[value=' + parent + ']').html();
|
23 |
+
var parentspace = ' ';
|
24 |
+
if(parentname.match(/ /g)){
|
25 |
+
var nums = parentname.match(/ /g).length;
|
26 |
+
for(inums=0;inums<nums;inums++){
|
27 |
+
parentspace += ' ';
|
28 |
+
}
|
29 |
+
}
|
30 |
+
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>');
|
31 |
+
jQuery('#page_id option[value=' + parent + ']').after('<option class="p_' + parent + '" value="new' + pageid + '">' + parentspace + jQuery('#sc-page-name').val() + '</option>');
|
32 |
+
}
|
33 |
+
jQuery('#sc-pages').val(jQuery('#sc-pages').val() + pageid + '|' + parent + '|' + jQuery('#sc-page-name').val() + '\n');
|
34 |
+
|
35 |
+
//reset the form
|
36 |
+
pageid++;
|
37 |
+
jQuery('#sc-page-name').val('');
|
38 |
+
jQuery('#page_id').attr('selectedIndex', 0);
|
39 |
+
}else{
|
40 |
+
alert(chkfrm);
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
function sc_del_page(pageid){
|
45 |
+
jQuery('li.page-item-new' + pageid).remove();
|
46 |
+
jQuery('#page_id option[value=new' + pageid + ']').remove();
|
47 |
+
jQuery('#page_id option.p_new' + pageid).remove();
|
48 |
+
|
49 |
+
var maintext = jQuery('#sc-pages').val();
|
50 |
+
//remove the page
|
51 |
+
maintext = maintext.replace(new RegExp(pageid + '\\|[^\\n]*\\n', "i"), "");
|
52 |
+
//remove the children
|
53 |
+
maintext = maintext.replace(new RegExp('\\d*\\|new' + pageid + '\\|[^\\n]*\\n', "i"), "");
|
54 |
+
jQuery('#sc-pages').val(maintext);
|
55 |
+
}
|
my-style.css
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#sc-bpc-div li{
|
2 |
+
list-style:none;
|
3 |
+
margin-left:20px;
|
4 |
+
font-size:14px;
|
5 |
+
font-style:italic;
|
6 |
+
}
|
readme.txt
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Plugin Name ===
|
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: 3.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
|
9 |
+
|
10 |
+
== Description ==
|
11 |
+
|
12 |
+
Allows you to create multiple pages in a batch/bulk manner saving time when initially setting up your WordPress site,
|
13 |
+
This plugin will give you a startup screen in which you can add as many pages in a quick manner and then by clicking one button will create all the pages
|
14 |
+
|
15 |
+
|
16 |
+
For backwards compatibility, if this section is missing, the full length of the short description will be used, and
|
17 |
+
Markdown parsed.
|
18 |
+
|
19 |
+
== Installation ==
|
20 |
+
|
21 |
+
To install this plugin please use the "install" feature from the WordPress site.
|
22 |
+
|
23 |
+
== Changelog ==
|
24 |
+
|
25 |
+
= 1.0.0 =
|
26 |
+
* Initial setup
|
27 |
+
|
28 |
+
|
29 |
+
== Screenshots ==
|
30 |
+
|
31 |
+
1. View of bulk page creator screen
|
screenshot-1.jpg
ADDED
Binary file
|