pageMash > Page Management - Version 1.1.0

Version Description

Download this release

Release Info

Developer jmash
Plugin Icon wp plugin pageMash > Page Management
Version 1.1.0
Comparing to
See all releases

Code changes from version 1.0.4 to 1.1.0

Files changed (7) hide show
  1. README.txt +44 -22
  2. inlineEdit.v1.2.js +47 -0
  3. nested.js +4 -3
  4. pagemash-css.php +91 -0
  5. pagemash-js.php +194 -0
  6. pagemash.php +65 -237
  7. saveList.php +25 -7
README.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: JoelStarnes
3
  Tags: order pages, ajax, re-order, drag-and-drop, admin, manage, page, pages, sidebar, header, hide,
4
  Requires at least: 2.1
5
  Tested up to: 2.5
6
- Stable tag: 1.0.4
7
 
8
  Organise page order and manage page structure with this simple drag-and-drop Ajax interface.
9
 
@@ -11,8 +11,7 @@ Organise page order and manage page structure with this simple drag-and-drop Aja
11
 
12
  Customise the order your pages are listed in and manage the parent structure with this simple Ajax drag-and-drop administrative interface with an option to toggle the page to be hidden from output. Great tool to quickly re-arrange your page menus.
13
 
14
- Checkout the example admin page: http://joelstarnes.co.uk/pagemash/example
15
-
16
  Feedback is greatly appreciated: http://joelstarnes.co.uk/contact
17
 
18
  == Installation ==
@@ -38,8 +37,10 @@ The code here is very simple and flexible, for more information look up `wp_list
38
  If you have any questions or comments, please drop me an email: http://joelstarnes.co.uk/contact
39
 
40
  = Do I need any special code in my template =
41
- No. You no longer need to add the pageMash parameter as you did with the previous versions [<1.0.2]. You can leave the code in as it will do no harm, but it's good to keep your template clean of unnecessary code.
42
 
 
 
43
 
44
  == Screenshots ==
45
 
@@ -50,24 +51,45 @@ No. You no longer need to add the pageMash parameter as you did with the previou
50
 
51
  ==Change Log==
52
 
53
- 0.1.0 > Initial Release
54
-
55
- 0.1.1 > Removed version check since some hosts will not allow external includes.
56
-
57
- 0.1.2 > Fixed CSS&JS headers to only display on pageMash admin
58
-
59
- 0.1.3 > Fixed exclude pages feature
60
-
61
- 1.0.0 beta > Major rebuild > Recusive page handles unlimited nested children, collapsable list items, interface makeover...
62
-
63
- 1.0.1 beta > fixed IE drag selects text
64
-
65
- 1.0.2 > Major code rewrite for exclude pages
66
-
67
- 1.0.3 > Fixed datatype bug causing array problems
68
-
69
- 1.0.4 > Removed shorthand PHP and updated CSS and JS headers to admin_print_scripts hook.
70
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
  == Localization ==
73
 
3
  Tags: order pages, ajax, re-order, drag-and-drop, admin, manage, page, pages, sidebar, header, hide,
4
  Requires at least: 2.1
5
  Tested up to: 2.5
6
+ Stable tag: 1.1.0
7
 
8
  Organise page order and manage page structure with this simple drag-and-drop Ajax interface.
9
 
11
 
12
  Customise the order your pages are listed in and manage the parent structure with this simple Ajax drag-and-drop administrative interface with an option to toggle the page to be hidden from output. Great tool to quickly re-arrange your page menus.
13
 
14
+ Checkout the example page: http://joelstarnes.co.uk/pagemash/example
 
15
  Feedback is greatly appreciated: http://joelstarnes.co.uk/contact
16
 
17
  == Installation ==
37
  If you have any questions or comments, please drop me an email: http://joelstarnes.co.uk/contact
38
 
39
  = Do I need any special code in my template =
40
+ No. You no longer need to add the pageMash parameter as you did with the previous versions [<1.0.2]. You can leave the code in as it will do no harm, but it's a good idea to keep your template clean of unnecessary code.
41
 
42
+ = Which browsers are supported =
43
+ Any good up-to-date browser should work fine. I test in Firefox, IE7, Safari and Opera. (NB in IE7 you need to use the page name as a drag handle.)
44
 
45
  == Screenshots ==
46
 
51
 
52
  ==Change Log==
53
 
54
+ * 1.1.0
55
+ * Added quick rename
56
+ * Externalised scripts
57
+ * Changed display of edit|hide|rename links
58
+ * Deregisters prototypes
59
+
60
+ * 1.0.4
61
+ * Removed shorthand PHP
62
+ * Updated CSS and JS headers to admin_print_scripts hook.
63
+
64
+ * 1.0.3
65
+ * Fixed datatype bug causing array problems
66
+
67
+ * 1.0.3
68
+ * Fixed datatype bug causing array problems
69
+
70
+ * 1.0.2
71
+ * Major code rewrite for exclude pages
72
+
73
+ * 1.0.1 beta
74
+ * fixed IE drag selects text
75
+
76
+ * 1.0.0 beta
77
+ * Major rebuild to use vladimir's sortables class extension
78
+ * Recusive page handles unlimited nested children
79
+ * Collapsable list items
80
+ * Interface makeover...
81
+
82
+ * 0.1.3
83
+ * Fixed exclude pages feature
84
+
85
+ * 0.1.2
86
+ * Fixed CSS&JS headers to only display on pageMash admin
87
+
88
+ * 0.1.1
89
+ * Removed version check since some hosts will not allow external includes.
90
+
91
+ * 0.1.0
92
+ * Initial Release
93
 
94
  == Localization ==
95
 
inlineEdit.v1.2.js ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var inlineEdit = new Class({
2
+ getOptions: function(){
3
+ return {
4
+ onComplete: function(el,oldContent,newContent){
5
+ },
6
+ type: 'input'
7
+ };
8
+ },
9
+ initialize: function(element,options){
10
+ this.setOptions(this.getOptions(), options);
11
+ if(!element.innerHTML.toLowerCase().match('<'+this.options.type)){
12
+ this.editting = element;
13
+ this.oldContent = element.innerHTML;
14
+ var content = this.oldContent.trim().replace(new RegExp("<br>", "gi"), "\n");
15
+ this.inputBox = new Element(this.options.type).setProperty('value',content).setStyles('margin:0;background:transparent;width:99.5%;font-size:100%;border:0;');
16
+ if(!this.inputBox.value){this.inputBox.setHTML(content)}
17
+ this.editting.setHTML('');
18
+ this.inputBox.injectInside(this.editting);
19
+ (function(){this.inputBox.focus()}.bind(this)).delay(300);
20
+ this.inputBox.addEvent('change',this.onSave.bind(this));
21
+ this.inputBox.addEvent('blur',this.onSave.bind(this));
22
+ this.inputBox.addEvent('keyup',this.onKeyUp.bindWithEvent(this));
23
+ this.fireEvent('onStart', [this.editting]);
24
+ }
25
+ },
26
+ onKeyUp: function(e){
27
+ if("enter" == e.key)
28
+ {
29
+ this.onSave();
30
+ }
31
+ },
32
+ onSave: function(){
33
+ this.inputBox.removeEvents();
34
+ this.newContent = this.inputBox.value.trim().replace(new RegExp("\n", "gi"), "<br>");
35
+ this.editting.setHTML(this.newContent);
36
+ this.fireEvent('onComplete', [this.editting,this.oldContent,this.newContent]);
37
+ }
38
+ });
39
+
40
+ Element.extend({
41
+ inlineEdit: function(options) {
42
+ return new inlineEdit(this, options);
43
+ }
44
+ });
45
+
46
+ inlineEdit.implement(new Events);
47
+ inlineEdit.implement(new Options);
nested.js CHANGED
@@ -231,10 +231,11 @@ var Nested = new Class({
231
  $$(listEl.childNodes).each(function(node, i) {
232
  kids = $E('ul', node); /* set 'this.options.parentTag' straight to 'ul' to avoid safari bug */
233
  serial[i] = {
234
- id: node.id,
235
- hide: (node.hasClass('remove')) ? 'exclude' : "",
236
- children: (kids) ? this.serialize(kids) : []
237
  };
 
 
 
238
  }.bind(this));
239
  return serial;
240
  },
231
  $$(listEl.childNodes).each(function(node, i) {
232
  kids = $E('ul', node); /* set 'this.options.parentTag' straight to 'ul' to avoid safari bug */
233
  serial[i] = {
234
+ id: node.id
 
 
235
  };
236
+ if (node.hasClass('remove')) serial[i].hide = true;
237
+ if (node.hasClass('renamed')) serial[i].renamed = $E('span.title', node).innerHTML;
238
+ if (kids) serial[i].children = this.serialize(kids);
239
  }.bind(this));
240
  return serial;
241
  },
pagemash-css.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ header('Content-Type: text/css');
3
+ require_once('../../../wp-config.php');
4
+ global $instantUpdateFeature, $excludePagesFeature, $pageMash_abs_dir;
5
+ ?>
6
+ /* __ __ _
7
+ WordPress Plugin | \/ | | |
8
+ _ __ __ _ __ _ ___| \ / | __ _ ___| |__
9
+ | '_ \ / _` |/ _` |/ _ \ |\/| |/ _` / __| '_ \
10
+ | |_) | (_| | (_| | __/ | | | (_| \__ \ | | |
11
+ | .__/ \__,_|\__, |\___|_| |_|\__,_|___/_| |_|
12
+ | | __/ | Author: Joel Starnes
13
+ |_| |___/ URL: pagemash.joelstarnes.co.uk
14
+
15
+ >>CSS styling for pageMash Admin
16
+ */
17
+
18
+
19
+
20
+ body.wp-admin div#wpwrap div#wpcontent ul#pageMash_pages {
21
+ margin:0 0 0 0;
22
+ list-style:none;
23
+ }
24
+ ul#pageMash_pages li.collapsed ul { display:none; }
25
+ ul#pageMash_pages li.children {
26
+ background-image: url('<?php echo $pageMash_abs_dir; ?>collapse.png');
27
+ }
28
+ ul#pageMash_pages li.collapsed.children {
29
+ background-image: url('<?php echo $pageMash_abs_dir; ?>expand.png');
30
+ }
31
+ ul#pageMash_pages li {
32
+ display:block;
33
+ margin:2px 0 0 0;
34
+ border-bottom:1px solid #aaa; border-right:1px solid #aaa; border-top:1px solid #ccc; border-left:1px solid #ccc;
35
+ padding:4px 6px 4px 24px;
36
+ background:#F1F1F1 url('<?php echo $pageMash_abs_dir; ?>page.png') no-repeat 4px 4px;
37
+ list-style-type:none;
38
+ }
39
+ ul#pageMash_pages li span.title { font-weight: bold; }
40
+ ul#pageMash_pages li.collapsed.children span.title { text-decoration: underline; }
41
+ ul#pageMash_pages li.collapsed.children li span.title { text-decoration: none; }
42
+ #update_status {
43
+ font-weight:bold;
44
+ display:block;
45
+ border:2px solid #AC604C;
46
+ background-color: #DDA37A;
47
+ padding: 2px 6px;
48
+ }
49
+ ul#pageMash_pages li.remove {
50
+ color:grey;
51
+ border-style:dashed;
52
+ border-color:#aaa;
53
+ opacity:.5;
54
+ filter:alpha(opacity=50); zoom:1; /* ie hack[has layout] for opacity */
55
+ }
56
+ ul#pageMash_pages li.remove a { color:grey; }
57
+ ul#pageMash_pages li span.pageMash_box {
58
+ font-weight:normal;
59
+ font-size: 1em;
60
+ line-height: 110%;
61
+ border:1px solid #bbb;
62
+ background-color: #eee;
63
+ padding: 0px 3px;
64
+ margin: 0;
65
+ opacity:.5;
66
+ filter:alpha(opacity=50); zoom:1; /* ie hack[has layout] for opacity */
67
+ }
68
+ ul#pageMash_pages li .pageMash_box:hover {
69
+ opacity:1;
70
+ filter:alpha(opacity=100); zoom:1; /* ie hack[has layout] for opacity */
71
+ }
72
+ ul#pageMash_pages li .pageMash_box .pageMash_pageFunctions { display:none; }
73
+ ul#pageMash_pages li .pageMash_box:hover .more { display:none; }
74
+ ul#pageMash_pages li .pageMash_box:hover .pageMash_pageFunctions { display:inline; }
75
+ ul#pageMash_pages li .pageMash_box a { border:0; }
76
+ ul#pageMash_pages li.renaming>.pageMash_box { display:none; }
77
+ ul#pageMash_pages li.renaming>span.title {
78
+ border:1px solid #aaa;
79
+ background-color: #ccc;
80
+ }
81
+ ul#pageMash_pages li.renaming li span.title input {
82
+ font-weight:bold;
83
+ }
84
+
85
+ #pageMash_code {display:block; border:solid 3px #858EF4; background-color:#211E1E; padding:7px; margin:0px;}
86
+ #pageMash_code .white{color:#DADADA;}
87
+ #pageMash_code .purple{color:#9B2E4D; font-weight:bold;}
88
+ #pageMash_code .green{color:#00FF00;}
89
+ #pageMash_code .blue{color:#858EF4;}
90
+ #pageMash_code .yellow{color:#C1C144;}
91
+ #pageMash_code .orange{color:#EC9E00;}
pagemash-js.php ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once('../../../wp-config.php');
3
+ cache_javascript_headers();
4
+ global $instantUpdateFeature, $excludePagesFeature, $pageMash_abs_dir;
5
+ ?>
6
+ /* __ __ _
7
+ WordPress Plugin | \/ | | |
8
+ _ __ __ _ __ _ ___| \ / | __ _ ___| |__
9
+ | '_ \ / _` |/ _` |/ _ \ |\/| |/ _` / __| '_ \
10
+ | |_) | (_| | (_| | __/ | | | (_| \__ \ | | |
11
+ | .__/ \__,_|\__, |\___|_| |_|\__,_|___/_| |_|
12
+ | | __/ | Author: Joel Starnes
13
+ |_| |___/ URL: pagemash.joelstarnes.co.uk
14
+
15
+ >>Main javascript include
16
+ */
17
+
18
+ window.addEvent('domready', function(){
19
+ // When logging debug messages with console.warn
20
+ // if user doesn't have Firebug, write them to the DOM instead
21
+ if (typeof console == "undefined") {
22
+ // Create an unordered list to display warning messages
23
+ var logsOutput = document.createElement('ul');
24
+ $("debug_list").appendChild(logsOutput);
25
+
26
+ // Define console.warn() function
27
+ console = {
28
+ warn: function(msg) {
29
+ logsOutput.innerHTML += '<li>' + msg + '</li>';
30
+ }
31
+ };
32
+ // Create an empty function for all other console methods
33
+ var consoleMethods = ["log", "debug", "info", "error", "assert", "dir", "dirxml", "group",
34
+ "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
35
+ for (var i = 0; i < consoleMethods.length; ++i)
36
+ console[consoleMethods[i]] = function() {}
37
+ }
38
+ });
39
+
40
+ /* add timeout to Ajax class */
41
+ Ajax = Ajax.extend({
42
+ request: function(){
43
+ if (this.options.timeout) {
44
+ this.timeoutTimer=window.setTimeout(this.callTimeout.bindAsEventListener(this), this.options.timeout);
45
+ this.addEvent('onComplete', this.removeTimer);
46
+ }
47
+ this.parent();
48
+ },
49
+ callTimeout: function () {
50
+ this.transport.abort();
51
+ this.onFailure();
52
+ if (this.options.onTimeout) {
53
+ this.options.onTimeout();
54
+
55
+ }
56
+ },
57
+ removeTimer: function() {
58
+ window.clearTimeout(this.timeoutTimer);
59
+ }
60
+ });
61
+ /* function to retrieve list data and send to server in JSON format */
62
+ var SaveList = function() {
63
+ var theDump = sortIt.serialize();
64
+ console.group('Database Update');
65
+ console.time('Update Chronometer');
66
+ new Ajax('<?php echo $pageMash_abs_dir; ?>saveList.php', {
67
+ method: 'post',
68
+ postBody: 'm='+Json.toString(theDump),
69
+ // update: "debug_list",
70
+ onComplete: function() {
71
+ $('update_status').setText('Database Updated');
72
+ new Fx.Style($('update_status'), 'opacity', {duration: 500}).start(0,1).chain(function() {
73
+ new Fx.Style($('update_status'), 'opacity', {duration: 1500}).start(1,0);
74
+ });
75
+ console.log('Database Successfully Updated');
76
+ console.timeEnd('Update Chronometer');
77
+ console.groupEnd();
78
+ },
79
+ timeout: 8500,
80
+ onTimeout: function() {
81
+ $('update_status').setText('Error: Update Timeout');
82
+ new Fx.Style($('update_status'), 'opacity', {duration: 200}).start(0,1);
83
+ console.timeEnd('Update Chronometer');
84
+ console.error('Error: update confirmation not recieved');
85
+ console.groupEnd();
86
+ }
87
+ }).request();
88
+ };
89
+ /* toggle the remove class of grandparent */
90
+ <?php if($excludePagesFeature): ?>
91
+ var toggleRemove = function(el) {
92
+ el.parentNode.parentNode.parentNode.toggleClass('remove');
93
+ console.log("Page: '%s' has been %s", $E('span.title', el.parentNode.parentNode.parentNode).innerHTML, (el.parentNode.parentNode.hasClass('remove') ? 'HIDDEN': 'MADE VISIBLE' ));
94
+ }
95
+ <?php endif; ?>
96
+
97
+
98
+ /* ******** dom ready ******** */
99
+ window.addEvent('domready', function(){
100
+ sortIt = new Nested('pageMash_pages', {
101
+ collapse: true,
102
+ onComplete: function(el) {
103
+ el.setStyle('background-color', '#F1F1F1');
104
+ sortIt.altColor();
105
+ <?php if($instantUpdateFeature): ?>SaveList();<?php endif; ?>
106
+
107
+ $ES('li','pageMash_pages').each(function(el) {
108
+ if( el.getElement('ul') ){
109
+ el.addClass('children');
110
+ } else {
111
+ el.removeClass('children');
112
+ }
113
+ });
114
+ }
115
+ });
116
+ Nested.implement({
117
+ /* alternate the colours of top level nodes */
118
+ altColor: function(){
119
+ var odd = 1;
120
+ this.list.getChildren().each(function(element, i){
121
+ if(odd==1){
122
+ odd=0;
123
+ element.setStyle('background-color', '#CFE8A8');
124
+ }else{
125
+ odd=1;
126
+ element.setStyle('background-color', '#D8E8E6');
127
+ }
128
+ });
129
+ }
130
+ });
131
+ sortIt.altColor();
132
+ $('update_status').setStyle('opacity', 0);
133
+
134
+ <?php if(!$instantUpdateFeature): ?>
135
+ $('pageMash_submit').addEvent('click', function(e){
136
+ e = new Event(e);
137
+ SaveList();
138
+ e.stop();
139
+ });
140
+ <?php endif; ?>
141
+
142
+ var pageMashInfo = new Fx.Slide('pageMashInfo');
143
+ $('pageMashInfo_toggle').addEvent('click', function(e){
144
+ e = new Event(e);
145
+ pageMashInfo.toggle();
146
+ e.stop();
147
+ switch($('pageMashInfo_toggle').getText()) {
148
+ case "Show Further Info":
149
+ $('pageMashInfo_toggle').setText('Hide Further Info');
150
+ break
151
+ case "Hide Further Info":
152
+ $('pageMashInfo_toggle').setText('Show Further Info');
153
+ break
154
+ }
155
+ });
156
+ pageMashInfo.hide();
157
+ $('pageMashInfo_toggle').setText('Show Further Info');
158
+
159
+
160
+ /* loop through each page */
161
+ $ES('li','pageMash_pages').each(function(el) {
162
+ /* If the li has a 'ul' child; it has children pages */
163
+ if( el.getElement('ul') ) el.addClass('children');
164
+
165
+ /* on page dblClick add this event */
166
+ el.addEvent('dblclick', function(e){
167
+ e = new Event(e);
168
+ if(el.hasClass('children')) el.toggleClass('collapsed');
169
+ e.stop();
170
+ });
171
+ });
172
+
173
+ /* disable drag text-selection for IE */
174
+ if (typeof document.body.onselectstart!="undefined")
175
+ document.body.onselectstart=function(){return false}
176
+
177
+ /* InlineEdit: rename pages */
178
+ $$('#pageMash_pages li span.title').each(function(el){ //#pageMash_pages li span.title
179
+ el.setStyle('cursor','pointer');
180
+ $E('a.rename', el.parentNode).addEvent('click',function(){
181
+ el.inlineEdit({
182
+ onStart:function(el){
183
+ el.parentNode.addClass('renaming');
184
+ },
185
+ onComplete:function(el,oldContent,newContent){
186
+ el.parentNode.removeClass('renaming').addClass('renamed');
187
+ console.log("Page: '%s' has been RENAMED to: '%s'", oldContent, newContent);
188
+ }
189
+ });
190
+ });
191
+ });
192
+
193
+ console.info("We're all up and running.")
194
+ }); /* close dom ready */
pagemash.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: pageMash
4
  Plugin URI: http://joelstarnes.co.uk/pagemash/
5
  Description: pageMash > pageManagement [WP_Admin > Manage > pageMash]
6
  Author: Joel Starnes
7
- Version: 1.0.4
8
  Author URI: http://joelstarnes.co.uk/
9
 
10
  CHANGELOG:
@@ -12,15 +12,16 @@ Release: Date: Description:
12
  0.1.0 10 Feb 2008 Initial release
13
  0.1.1 12 Feb 2008 Minor fixes > Removed external include
14
  0.1.2 15 Feb 2008 Minor fixes > Fixed CSS&JS headers to only display on pagemash
15
- 1.0.0 beta 19 Feb 2008 Major update > Recusive page handles unlimited nested children,
16
- collapsable list items, interface makeover...
17
  1.0.1 beta 14 Mar 2008 Fixed IE > drag selects text
18
  1.0.2 16 Mar 2008 Major code rewrite for exclude pages, funct hooks onto wp_list_pages
19
  1.0.3 18 Mar 2008 Fixed datatype bug causing array problems
20
  1.0.4 11 Apr 2008 removed shorthand PHP and updated CSS and JS headers to admin_print_scripts hook.
 
21
 
22
  FIXME:
23
  @fixme with instantUpdateFeature hide will not send the update
 
24
 
25
  */
26
  #########CONFIG OPTIONS############################################
@@ -63,6 +64,9 @@ Garrett Murphey - Page Link Manager [http://gmurphey.com/2006/10/05/wordpress-pl
63
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
64
  */
65
 
 
 
 
66
 
67
  function pageMash_getPages($post_parent){
68
  //this is a recurrsive function which calls itself to produce a nested list of elements
@@ -75,19 +79,20 @@ function pageMash_getPages($post_parent){
75
  }
76
 
77
  if ($pageposts == true){ //if $pageposts == true then it does have sub-page(s), so list them.
78
- echo '<ul ';
79
- if($post_parent==0) echo 'id="pageMash_pages" '; //add this ID only to root 'ul' element
80
- echo '>';
81
-
82
- foreach ($pageposts as $page): //list pages, [the 'li' ID must be the page ID] ?>
83
- <li id="pm_<?php echo $page->ID; ?>" <?php if(get_option('exclude_pages')){ if(in_array($page->ID, $excludePagesList)) echo 'class="remove"'; }//if page is in exclude list, add class remove ?>>
84
- <span class="title"><?php echo $page->post_title; ?></span>
85
- <span class="pageMash_pageFunctions">
86
- id:<?php echo $page->ID; ?>
87
- [<a href="<?php echo get_settings('siteurl').'/wp-admin/post.php?action=edit&post='.$page->ID; ?>" title="Edit This Page">edit</a>]
88
- <?php if($excludePagesFeature): ?>
89
- [<a href="#" title="Show|Hide" class="excludeLink" onclick="toggleRemove(this); return false">hide</a>]
90
- <?php endif; ?>
 
91
  </span>
92
  <?php pageMash_getPages($page->ID) //call this function to list any sub-pages (passing it the pageID) ?>
93
  </li>
@@ -105,248 +110,70 @@ function pageMash_main(){
105
  ?>
106
  <div id="debug_list"></div>
107
  <div id="pageMash" class="wrap">
108
- <div id="pageMash_checkVersion" style="float:right; font-size:.7em; margin-top:5px;">
109
- version [1.0.4]
110
- </div>
111
- <h2 style="margin-bottom:0; clear:none;">pageMash - pageManagement</h2>
112
- <p style="margin-top:4px;">
113
- Just drag the pages <strong>up</strong> or <strong>down</strong> to change the page order and <strong>left</strong> or <strong>right</strong> to change the page's parent, then hit 'update'.<br />
114
- The icon to the left of each page shows if it has child pages, <strong>double click</strong> anywhere on that item to toggle <strong>expand|collapse</strong> of it's children.
115
- </p>
116
 
117
- <div>
118
- <?php pageMash_getPages(0); //pass 0, as initial parent ?>
119
- </div>
120
-
121
- <p class="submit">
122
- <div id="update_status" style="float:left; margin-left:40px; opacity:0;"></div>
123
- <?php if(!$instantUpdateFeature): ?>
124
- <input type="submit" id="pageMash_submit" tabindex="2" style="font-weight: bold; float:right;" value="Update" name="submit"/>
125
- <?php endif; ?>
126
- </p>
127
- <br style="margin-bottom: .8em;" />
128
  </div>
129
 
130
  <div class="wrap" style="width:160px; margin-bottom:0; padding:2px; text-align:center;"><a href="#" id="pageMashInfo_toggle" style="text-align:center;">Show|Hide Further Info</a></div>
131
  <div class="wrap" id="pageMashInfo" style="margin-top:-1px;">
132
  <h2>How to Use</h2>
133
  <p>pageMash works with the wp_list_pages function. The easiest way to use it is to put the pages widget in your sidebar [WP admin page > Presentation > Widgets]. Click the configure button on the widget and ensure that 'sort by' is set to 'page order'. Hey presto, you're done.</p>
134
- <p>You can also use the function anywhere in your theme code. e.g. in your sidebar.php file (but the code in here will not run if you're using any widgets) or your header.php file (somewhere under the body tag, you may want to use the depth=1 parameter to only show top levle pages). The code should look something like the following:</p>
135
  <p style="margin-bottom:0; font-weight:bold;">Code:</p>
136
  <code id="pageMash_code">
137
  <span class="white">&lt;?php</span> <span class="blue">wp_list_pages(</span><span class="orange">'title_li=&lt;h2&gt;Pages&lt;/h2&gt;&amp;depth=0'</span><span class="blue">);</span> <span class="white">?&gt;</span>
138
  </code>
139
  <p>You can also hard-code pages to exclude and these will be merged with the pages you set to exclude in your pageMash admin.</p>
140
  <p>The code here is very simple and flexible, for more information look up <a href="http://codex.wordpress.org/Template_Tags/wp_list_pages" title="wp_list_pages Documentation">wp_list_pages() in the Wordpress Codex</a> as it is very well documented and if you have any further questions or feedback I like getting messages, so <a href="http://joelstarnes.co.uk/contact/" title="email Joel Starnes">drop me an email</a>.</p>
 
141
  </div>
142
  <?php
143
  }
144
 
145
  function pageMash_head(){
146
  //stylesheet & javascript to go in page header
147
- global $instantUpdateFeature, $excludePagesFeature;
148
- ?>
149
- <style type="text/css">
150
- ul#pageMash_pages {
151
- margin:0 0 0 0;
152
- list-style:none;
153
- }
154
- ul#pageMash_pages li.collapsed ul { display:none; }
155
- ul#pageMash_pages li.children {
156
- background-image: url('<?php echo get_settings("siteurl") ?>/wp-content/plugins/pagemash/collapse.png');
157
- }
158
- ul#pageMash_pages li.collapsed.children {
159
- background-image: url('<?php echo get_settings("siteurl") ?>/wp-content/plugins/pagemash/expand.png');
160
- }
161
- ul#pageMash_pages li {
162
- display:block;
163
- margin:2px 0 0 0;
164
- border-bottom:1px solid #aaa; border-right:1px solid #aaa; border-top:1px solid #ccc; border-left:1px solid #ccc;
165
- padding:4px 6px 4px 24px;
166
- background:#F1F1F1 url('<?php echo get_settings("siteurl") ?>/wp-content/plugins/pagemash/page.png') no-repeat 4px 4px;
167
- list-style-type:none;
168
- }
169
- ul#pageMash_pages li span.title { font-weight: bold; }
170
- ul#pageMash_pages li.collapsed.children span.title { text-decoration: underline; }
171
- ul#pageMash_pages li.collapsed.children li span.title { text-decoration: none; }
172
- #update_status {
173
- font-weight:bold;
174
- display:block;
175
- border:2px solid #AC604C;
176
- background-color: #DDA37A;
177
- padding: 2px 6px;
178
- }
179
- ul#pageMash_pages li.remove {
180
- color:grey;
181
- border-style:dashed;
182
- border-color:#aaa;
183
- opacity:.5;
184
- filter:alpha(opacity=50); zoom:1; /* ie hack[has layout] for opacity */
185
- }
186
- ul#pageMash_pages li.remove a { color:grey; }
187
- ul#pageMash_pages li span.pageMash_pageFunctions {
188
- border:1px solid #ccc;
189
- background-color: #eee;
190
- padding: 1px 3px;
191
- }
192
- ul#pageMash_pages li span.pageMash_pageFunctions a { border:0; }
193
-
194
- /* Show [page id, 'edit page' link and 'hide' link] function box on hover */
195
- ul#pageMash_pages li span.pageMash_pageFunctions { display:none; }
196
- ul#pageMash_pages li:hover span.pageMash_pageFunctions { display:inline; }
197
- ul#pageMash_pages li:hover li span.pageMash_pageFunctions { display:none; }
198
- ul#pageMash_pages li:hover li:hover span.pageMash_pageFunctions { display:inline; }
199
- ul#pageMash_pages li:hover li:hover li span.pageMash_pageFunctions { display:none; }
200
- ul#pageMash_pages li:hover li:hover li:hover span.pageMash_pageFunctions { display:inline; }
201
- ul#pageMash_pages li:hover li:hover li:hover li span.pageMash_pageFunctions { display:none; }
202
- ul#pageMash_pages li:hover li:hover li:hover li:hover span.pageMash_pageFunctions { display:inline; }
203
- ul#pageMash_pages li:hover li:hover li:hover li:hover li span.pageMash_pageFunctions { display:none; }
204
- ul#pageMash_pages li:hover li:hover li:hover li:hover li:hover span.pageMash_pageFunctions { display:inline; }
205
- ul#pageMash_pages li:hover li:hover li:hover li:hover li:hover li span.pageMash_pageFunctions { display:none; }
206
- ul#pageMash_pages li:hover li:hover li:hover li:hover li:hover li:hover span.pageMash_pageFunctions { display:inline; }
207
 
208
- #pageMash_code {display:block; border:solid 3px #858EF4; background-color:#211E1E; padding:7px; margin:0px;}
209
- #pageMash_code .white{color:#DADADA;}
210
- #pageMash_code .purple{color:#9B2E4D; font-weight:bold;}
211
- #pageMash_code .green{color:#00FF00;}
212
- #pageMash_code .blue{color:#858EF4;}
213
- #pageMash_code .yellow{color:#C1C144;}
214
- #pageMash_code .orange{color:#EC9E00;}
215
- </style>
216
- <!-- Current code not compatible with newer releases of moo -->
217
- <script type="text/javascript" src="<?php echo get_settings('siteurl') ?>/wp-content/plugins/pagemash/nest-mootools.v1.11.js"></script>
218
- <script type="text/javascript" src="<?php echo get_settings('siteurl') ?>/wp-content/plugins/pagemash/nested.js"></script>
219
- <script type="text/javascript">
220
 
221
- /* add timeout to Ajax class */
222
- Ajax = Ajax.extend({
223
- request: function(){
224
- if (this.options.timeout) {
225
- this.timeoutTimer=window.setTimeout(this.callTimeout.bindAsEventListener(this), this.options.timeout);
226
- this.addEvent('onComplete', this.removeTimer);
227
- }
228
- this.parent();
229
- },
230
- callTimeout: function () {
231
- this.transport.abort();
232
- this.onFailure();
233
- if (this.options.onTimeout) {
234
- this.options.onTimeout();
235
- }
236
- },
237
- removeTimer: function() {
238
- window.clearTimeout(this.timeoutTimer);
239
- }
240
- });
241
- /* function to retrieve list data and send to server in JSON format */
242
- var SaveList = function() {
243
- var theDump = sortIt.serialize();
244
- new Ajax('<?php echo get_settings("siteurl") ?>/wp-content/plugins/pagemash/saveList.php', {
245
- method: 'post',
246
- postBody: 'm='+Json.toString(theDump),
247
- // update: "debug_list",
248
- onComplete: function() {
249
- $('update_status').setText('Database Updated');
250
- new Fx.Style($('update_status'), 'opacity', {duration: 500}).start(0,1).chain(function() {
251
- new Fx.Style($('update_status'), 'opacity', {duration: 1500}).start(1,0);
252
- });
253
- },
254
- timeout: 8500,
255
- onTimeout: function() {
256
- $('update_status').setText('Error: Update Timeout');
257
- new Fx.Style($('update_status'), 'opacity', {duration: 200}).start(0,1);
258
- }
259
- }).request();
260
- };
261
- /* toggle the remove class of grandparent */
262
- <?php if($excludePagesFeature): ?>
263
- var toggleRemove = function(el) {
264
- el.parentNode.parentNode.toggleClass('remove');
265
- }
266
- <?php endif; ?>
267
-
268
-
269
- /* ******** dom ready ******** */
270
- window.addEvent('domready', function(){
271
- sortIt = new Nested('pageMash_pages', {
272
- collapse: true,
273
- onComplete: function(el) {
274
- el.setStyle('background-color', '#F1F1F1');
275
- sortIt.altColor();
276
- <?php if($instantUpdateFeature): ?>SaveList();<?php endif; ?>
277
-
278
- $ES('li','pageMash_pages').each(function(el) {
279
- if( el.getElement('ul') ){
280
- el.addClass('children');
281
- } else {
282
- el.removeClass('children');
283
- }
284
- });
285
- }
286
- });
287
- Nested.implement({
288
- /* alternate the colours of top level nodes */
289
- altColor: function(){
290
- var odd = 1;
291
- this.list.getChildren().each(function(element, i){
292
- if(odd==1){
293
- odd=0;
294
- element.setStyle('background-color', '#CFE8A8');
295
- }else{
296
- odd=1;
297
- element.setStyle('background-color', '#D8E8E6');
298
- }
299
- });
300
- }
301
- });
302
- sortIt.altColor();
303
- $('update_status').setStyle('opacity', 0);
304
-
305
- <?php if(!$instantUpdateFeature): ?>
306
- $('pageMash_submit').addEvent('click', function(e){
307
- e = new Event(e);
308
- SaveList();
309
- e.stop();
310
- });
311
- <?php endif; ?>
312
-
313
- var pageMashInfo = new Fx.Slide('pageMashInfo');
314
- $('pageMashInfo_toggle').addEvent('click', function(e){
315
- e = new Event(e);
316
- pageMashInfo.toggle();
317
- e.stop();
318
- switch($('pageMashInfo_toggle').getText()) {
319
- case "Show Further Info":
320
- $('pageMashInfo_toggle').setText('Hide Further Info');
321
- break
322
- case "Hide Further Info":
323
- $('pageMashInfo_toggle').setText('Show Further Info');
324
- break
325
- }
326
- });
327
- pageMashInfo.hide();
328
- $('pageMashInfo_toggle').setText('Show Further Info');
329
-
330
-
331
- /* loop through each page */
332
- $ES('li','pageMash_pages').each(function(el) {
333
- /* If the li has a 'ul' child; it has children pages */
334
- if( el.getElement('ul') ) el.addClass('children');
335
-
336
- /* on page dblClick add this event */
337
- el.addEvent('dblclick', function(e){
338
- e = new Event(e);
339
- if(el.hasClass('children')) el.toggleClass('collapsed');
340
- e.stop();
341
- });
342
- });
343
-
344
- //disable drag text-selection for IE
345
- if (typeof document.body.onselectstart!="undefined")
346
- document.body.onselectstart=function(){return false}
347
 
348
- }); /* close dom ready */
349
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
350
  <?php
351
  }
352
 
@@ -363,10 +190,11 @@ function pageMash_add_pages(){
363
  //add link in the management tab
364
  global $minlevel;
365
  $page = add_management_page('pageMash page order', 'pageMash', $minlevel, __FILE__, 'pageMash_main');
366
- add_action( "admin_print_scripts-$page", 'pageMash_head' ); //add css styles and JS code to head
367
  }
368
 
369
  add_action('admin_menu', 'pageMash_add_pages'); //add admin menu under management tab
370
  add_filter('wp_list_pages_excludes', 'pageMash_add_excludes'); //add exclude pages to wp_list_pages funct
371
 
 
372
  ?>
4
  Plugin URI: http://joelstarnes.co.uk/pagemash/
5
  Description: pageMash > pageManagement [WP_Admin > Manage > pageMash]
6
  Author: Joel Starnes
7
+ Version: 1.1.0
8
  Author URI: http://joelstarnes.co.uk/
9
 
10
  CHANGELOG:
12
  0.1.0 10 Feb 2008 Initial release
13
  0.1.1 12 Feb 2008 Minor fixes > Removed external include
14
  0.1.2 15 Feb 2008 Minor fixes > Fixed CSS&JS headers to only display on pagemash
15
+ 1.0.0 beta 19 Feb 2008 Major update > Recusive page handles unlimited nested children, collapsable list items, interface makeover...
 
16
  1.0.1 beta 14 Mar 2008 Fixed IE > drag selects text
17
  1.0.2 16 Mar 2008 Major code rewrite for exclude pages, funct hooks onto wp_list_pages
18
  1.0.3 18 Mar 2008 Fixed datatype bug causing array problems
19
  1.0.4 11 Apr 2008 removed shorthand PHP and updated CSS and JS headers to admin_print_scripts hook.
20
+ 1.1.0 24 Apr 2008 Added quick rename, externalised scripts, changed display of edit|hide|rename links, deregisters prototype
21
 
22
  FIXME:
23
  @fixme with instantUpdateFeature hide will not send the update
24
+ @todo readme txt CMS, mass edit pages, exclude pages, manage, organise,
25
 
26
  */
27
  #########CONFIG OPTIONS############################################
64
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
65
  */
66
 
67
+ //Global Vars
68
+ $pageMash_rel_dir = 'wp-content/plugins/pagemash/';
69
+ $pageMash_abs_dir = get_bloginfo('wpurl').'/'.$pageMash_rel_dir;
70
 
71
  function pageMash_getPages($post_parent){
72
  //this is a recurrsive function which calls itself to produce a nested list of elements
79
  }
80
 
81
  if ($pageposts == true){ //if $pageposts == true then it does have sub-page(s), so list them.
82
+ echo (0 === $post_parent) ? '<ul id="pageMash_pages">' : '<ul>'; //add this ID only to root 'ul' element
83
+ foreach ($pageposts as $page): //list pages, [the 'li' ID must be pm_'page ID'] ?>
84
+ <li id="pm_<?php echo $page->ID;?>" <?php if(get_option('exclude_pages')){ if(in_array($page->ID, $excludePagesList)) echo 'class="remove"'; }//if page is in exclude list, add class remove ?>>
85
+ <span class="title"><?php echo $page->post_title;?></span>
86
+ <span class="pageMash_box">
87
+ <span class="pageMash_more">&raquo;</span>
88
+ <span class="pageMash_pageFunctions">
89
+ id:<?php echo $page->ID;?>
90
+ [<a href="<?php echo get_bloginfo('wpurl').'/wp-admin/post.php?action=edit&post='.$page->ID; ?>" title="Edit This Page">edit</a>]
91
+ <?php if($excludePagesFeature): ?>
92
+ [<a href="#" title="Show|Hide" class="excludeLink" onclick="toggleRemove(this); return false">hide</a>]
93
+ <?php endif; ?>
94
+ [<a href="#" title="Rename Page" class="rename">Rename</a>]
95
+ </span>
96
  </span>
97
  <?php pageMash_getPages($page->ID) //call this function to list any sub-pages (passing it the pageID) ?>
98
  </li>
110
  ?>
111
  <div id="debug_list"></div>
112
  <div id="pageMash" class="wrap">
113
+ <div id="pageMash_checkVersion" style="float:right; font-size:.7em; margin-top:5px;">
114
+ version [1.1.0]
115
+ </div>
116
+ <h2 style="margin-bottom:0; clear:none;">pageMash - pageManagement</h2>
117
+ <p style="margin-top:4px;">
118
+ Just drag the pages <strong>up</strong> or <strong>down</strong> to change the page order and <strong>left</strong> or <strong>right</strong> to change the page's parent, then hit 'update'.<br />
119
+ The icon to the left of each page shows if it has child pages, <strong>double click</strong> anywhere on that item to toggle <strong>expand|collapse</strong> of it's children.
120
+ </p>
121
 
122
+ <?php pageMash_getPages(0); //pass 0, as initial parent ?>
123
+
124
+ <p class="submit">
125
+ <div id="update_status" style="float:left; margin-left:40px; opacity:0;"></div>
126
+ <?php if(!$instantUpdateFeature): ?>
127
+ <input type="submit" id="pageMash_submit" tabindex="2" style="font-weight: bold; float:right;" value="Update" name="submit"/>
128
+ <?php endif; ?>
129
+ </p>
130
+ <br style="margin-bottom: .8em;" />
 
 
131
  </div>
132
 
133
  <div class="wrap" style="width:160px; margin-bottom:0; padding:2px; text-align:center;"><a href="#" id="pageMashInfo_toggle" style="text-align:center;">Show|Hide Further Info</a></div>
134
  <div class="wrap" id="pageMashInfo" style="margin-top:-1px;">
135
  <h2>How to Use</h2>
136
  <p>pageMash works with the wp_list_pages function. The easiest way to use it is to put the pages widget in your sidebar [WP admin page > Presentation > Widgets]. Click the configure button on the widget and ensure that 'sort by' is set to 'page order'. Hey presto, you're done.</p>
137
+ <p>You can also use the function anywhere in your theme code. e.g. in your sidebar.php file (but the code in here will not run if you're using any widgets) or your header.php file (somewhere under the body tag, you may want to use the depth=1 parameter to only show top level pages). The code should look something like the following:</p>
138
  <p style="margin-bottom:0; font-weight:bold;">Code:</p>
139
  <code id="pageMash_code">
140
  <span class="white">&lt;?php</span> <span class="blue">wp_list_pages(</span><span class="orange">'title_li=&lt;h2&gt;Pages&lt;/h2&gt;&amp;depth=0'</span><span class="blue">);</span> <span class="white">?&gt;</span>
141
  </code>
142
  <p>You can also hard-code pages to exclude and these will be merged with the pages you set to exclude in your pageMash admin.</p>
143
  <p>The code here is very simple and flexible, for more information look up <a href="http://codex.wordpress.org/Template_Tags/wp_list_pages" title="wp_list_pages Documentation">wp_list_pages() in the Wordpress Codex</a> as it is very well documented and if you have any further questions or feedback I like getting messages, so <a href="http://joelstarnes.co.uk/contact/" title="email Joel Starnes">drop me an email</a>.</p>
144
+ <br />
145
  </div>
146
  <?php
147
  }
148
 
149
  function pageMash_head(){
150
  //stylesheet & javascript to go in page header
151
+ global $pageMash_rel_dir;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
 
153
+ wp_deregister_script('prototype');//remove prototype since it is incompatible with mootools
154
+ wp_enqueue_script('pagemash_mootools', '/'.$pageMash_rel_dir.'nest-mootools.v1.11.js', false, false); //code is not compatible with other releases of moo
155
+ wp_enqueue_script('pagemash_nested', '/'.$pageMash_rel_dir.'nested.js', array('pagemash_mootools'), false);
156
+ wp_enqueue_script('pagemash_inlineEdit', '/'.$pageMash_rel_dir.'inlineEdit.v1.2.js', array('pagemash_mootools'), false);
157
+ wp_enqueue_script('pagemash', '/'.$pageMash_rel_dir.'pagemash-js.php', array('pagemash_mootools'), false);
158
+ add_action('admin_head', 'pageMash_add_css', 1);
 
 
 
 
 
 
159
 
160
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
 
162
+ function pageMash_add_css(){
163
+ global $pageMash_abs_dir;
164
+ ?>
165
+ <link rel="stylesheet" type="text/css" href="<?php echo $pageMash_abs_dir ?>pagemash-css.php" />
166
+ <!-- __ __ _
167
+ WordPress Plugin | \/ | | |
168
+ _ __ __ _ __ _ ___| \ / | __ _ ___| |__
169
+ | '_ \ / _` |/ _` |/ _ \ |\/| |/ _` / __| '_ \
170
+ | |_) | (_| | (_| | __/ | | | (_| \__ \ | | |
171
+ | .__/ \__,_|\__, |\___|_| |_|\__,_|___/_| |_|
172
+ | | __/ | Author: Joel Starnes
173
+ |_| |___/ URL: pagemash.joelstarnes.co.uk
174
+
175
+ >>pageMash Admin Page
176
+ -->
177
  <?php
178
  }
179
 
190
  //add link in the management tab
191
  global $minlevel;
192
  $page = add_management_page('pageMash page order', 'pageMash', $minlevel, __FILE__, 'pageMash_main');
193
+ add_action("admin_print_scripts-$page", 'pageMash_head'); //add css styles and JS code to head
194
  }
195
 
196
  add_action('admin_menu', 'pageMash_add_pages'); //add admin menu under management tab
197
  add_filter('wp_list_pages_excludes', 'pageMash_add_excludes'); //add exclude pages to wp_list_pages funct
198
 
199
+
200
  ?>
saveList.php CHANGED
@@ -1,8 +1,20 @@
1
  <?php
2
- error_reporting(E_ALL);
 
 
 
 
 
 
 
 
 
 
3
 
4
- require('myjson.php'); //JSON decode lib
5
- require('./../../../wp-config.php'); //config to connect to database
 
 
6
 
7
  global $wpdb, $excludePages;
8
  $excludePages = array();
@@ -23,12 +35,15 @@ function saveList($parent, $children) {
23
  $id = (int) substr($children[$k]->id, 3);
24
 
25
  //if it had the remove class it is now added to the excludePages array
26
- if($v->hide=='exclude') $excludePages[] = $id;
27
 
28
  //update pages in db
29
- $postquery = "UPDATE $wpdb->posts SET menu_order='$i', post_parent='$parent' WHERE ID='$id'";
30
- $wpdb->query($postquery);
 
 
31
 
 
32
  echo $postquery;
33
  echo "\n";
34
 
@@ -36,8 +51,11 @@ function saveList($parent, $children) {
36
  $i++;
37
  }
38
  }
39
-
40
  echo saveList(0, $aMenu);
 
 
 
41
 
42
  //update excludePages option in database
43
  update_option("exclude_pages", $excludePages, '', 'yes');
1
  <?php
2
+ /* __ __ _
3
+ WordPress Plugin | \/ | | |
4
+ _ __ __ _ __ _ ___| \ / | __ _ ___| |__
5
+ | '_ \ / _` |/ _` |/ _ \ |\/| |/ _` / __| '_ \
6
+ | |_) | (_| | (_| | __/ | | | (_| \__ \ | | |
7
+ | .__/ \__,_|\__, |\___|_| |_|\__,_|___/_| |_|
8
+ | | __/ | Author: Joel Starnes
9
+ |_| |___/ URL: pagemash.joelstarnes.co.uk
10
+
11
+ >>Decodes JSON data and updates database accordingly
12
+ */
13
 
14
+ if(!$_POST['m']) die('no data'); //die if no data is sent
15
+ error_reporting(E_ALL);
16
+ require_once('myjson.php'); //JSON decode lib
17
+ require_once('./../../../wp-config.php'); //config to connect to database
18
 
19
  global $wpdb, $excludePages;
20
  $excludePages = array();
35
  $id = (int) substr($children[$k]->id, 3);
36
 
37
  //if it had the remove class it is now added to the excludePages array
38
+ if(isset($v->hide)) $excludePages[] = $id;
39
 
40
  //update pages in db
41
+ $postquery = "UPDATE $wpdb->posts SET ";
42
+ $postquery .= "menu_order='$i', post_parent='$parent'";
43
+ if (isset($v->renamed)) $postquery .= ", post_title='$v->renamed'";
44
+ $postquery .= " WHERE ID='$id'";
45
 
46
+ $wpdb->query($postquery); //$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET menu_order = %d, post_parent = %s WHERE ID = %d" ), $i, $parent, $id );
47
  echo $postquery;
48
  echo "\n";
49
 
51
  $i++;
52
  }
53
  }
54
+ echo "Update Pages: \n";
55
  echo saveList(0, $aMenu);
56
+ $wpdb->print_error();
57
+ echo "\n \nExclude Pages: \n";
58
+ print_r($excludePages);
59
 
60
  //update excludePages option in database
61
  update_option("exclude_pages", $excludePages, '', 'yes');