diff --git a/README.txt b/README.txt index a4a5b4b..1a4ed99 100644 --- a/README.txt +++ b/README.txt @@ -3,7 +3,7 @@ Contributors: JoelStarnes Tags: order pages, ajax, re-order, drag-and-drop, admin, manage, page, pages, sidebar, header, hide, Requires at least: 2.1 Tested up to: 2.5 -Stable tag: 1.1.1 +Stable tag: 1.1.2 Organise page order and manage page structure with this simple drag-and-drop Ajax interface. @@ -51,6 +51,9 @@ Any good up-to-date browser should work fine. I test in Firefox, IE7, Safari and ==Change Log== +* 1.1.2 + * Added Expand all | Collapse all buttons + * 1.1.1 * Fix a bug with console.log for safari * Removed php code from js&css scripts to fix error diff --git a/pagemash.js b/pagemash.js index af10658..f3d22ff 100644 --- a/pagemash.js +++ b/pagemash.js @@ -150,26 +150,38 @@ window.addEvent('domready', function(){ e.stop(); }); }); + + $('collapse_all').addEvent('click', function(e){ e = new Event(e); + $ES('li','pageMash_pages').each(function(el) { + if(el.hasClass('children')) el.addClass('collapsed'); + }); + e.stop(); }); + + $('expand_all').addEvent('click', function(e){ e = new Event(e); + $ES('li','pageMash_pages').each(function(el) { + if(el.hasClass('children')) el.removeClass('collapsed'); + }); + e.stop(); }); /* disable drag text-selection for IE */ if (typeof document.body.onselectstart!="undefined") document.body.onselectstart=function(){return false} - -/* InlineEdit: rename pages */ -$$('#pageMash_pages li span.title').each(function(el){ //#pageMash_pages li span.title - el.setStyle('cursor','pointer'); - $E('a.rename', el.parentNode).addEvent('click',function(){ - el.inlineEdit({ - onStart:function(el){ - el.parentNode.addClass('renaming'); - }, - onComplete:function(el,oldContent,newContent){ - el.parentNode.removeClass('renaming').addClass('renamed'); - console.log("Page: '%s' has been RENAMED to: '%s'", oldContent, newContent); - } + + /* InlineEdit: rename pages */ + $$('#pageMash_pages li span.title').each(function(el){ //#pageMash_pages li span.title + el.setStyle('cursor','pointer'); + $E('a.rename', el.parentNode).addEvent('click',function(){ + el.inlineEdit({ + onStart:function(el){ + el.parentNode.addClass('renaming'); + }, + onComplete:function(el,oldContent,newContent){ + el.parentNode.removeClass('renaming').addClass('renamed'); + console.log("Page: '%s' has been RENAMED to: '%s'", oldContent, newContent); + } + }); }); }); -}); - -console.info("We're all up and running.") + + console.info("We're all up and running.") }); /* close dom ready */ \ No newline at end of file diff --git a/pagemash.php b/pagemash.php index 7118f2c..11c210f 100644 --- a/pagemash.php +++ b/pagemash.php @@ -4,7 +4,7 @@ Plugin Name: pageMash Plugin URI: http://joelstarnes.co.uk/pagemash/ Description: pageMash > pageManagement [WP_Admin > Manage > pageMash] Author: Joel Starnes -Version: 1.1.1 +Version: 1.1.2 Author URI: http://joelstarnes.co.uk/ CHANGELOG: @@ -18,7 +18,8 @@ Release: Date: Description: 1.0.3 18 Mar 2008 Fixed datatype bug causing array problems 1.0.4 11 Apr 2008 removed shorthand PHP and updated CSS and JS headers to admin_print_scripts hook. 1.1.0 24 Apr 2008 Added quick rename, externalised scripts, changed display of edit|hide|rename links, deregisters prototype -1.11 29 Apr 2008 Fix a bug with console.log for safari, removed php code from js&css scripts to fix error +1.1.1 29 Apr 2008 Fix a bug with console.log for safari, removed php code from js&css scripts to fix error +1.1.2 24 May 2008 Added Expand all | Collapse all buttons */ #########CONFIG OPTIONS############################################ @@ -28,6 +29,12 @@ $minlevel = 7; /*[deafult=7]*/ $excludePagesFeature = true; /*[deafult=true]*/ /* Allows you to set pages not to be listed */ +$renamePagesFeature = true; /*[deafult=true]*/ +/* Lets you rename pages */ + +$CollapsePagesOnLoad = false; /*[deafult=true]*/ +/* Collapse all parent pages on load */ + ################################################################### /* INSPIRATIONS/CREDITS: @@ -62,7 +69,7 @@ $pageMash_abs_dir = get_bloginfo('wpurl').'/'.$pageMash_rel_dir; function pageMash_getPages($post_parent){ //this is a recurrsive function which calls itself to produce a nested list of elements //$post_parent should be 0 for root pages, or contain a pageID to return it's sub-pages - global $wpdb, $wp_version, $excludePagesFeature, $excludePagesList; + global $wpdb, $wp_version, $excludePagesFeature, $excludePagesList, $renamePagesFeature; if($wp_version >= 2.1){ //get pages from database $pageposts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'page' AND post_parent = '$post_parent' ORDER BY menu_order"); }else{ @@ -71,8 +78,13 @@ function pageMash_getPages($post_parent){ if ($pageposts == true){ //if $pageposts == true then it does have sub-page(s), so list them. echo (0 === $post_parent) ? '
Just drag the pages up or down to change the page order and left or right to change the page's parent, then hit 'update'.
- The icon to the left of each page shows if it has child pages, double click anywhere on that item to toggle expand|collapse of it's children.
+ The icon to the left of each page shows if it has child pages, double click on that item to toggle expand|collapse of it's children.
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.
@@ -137,29 +152,38 @@ function pageMash_main(){ function pageMash_head(){ //stylesheet & javascript to go in page header - global $pageMash_rel_dir; + global $pageMash_rel_dir, $CollapsePagesOnLoad; - wp_deregister_script('prototype');//remove prototype since it is incompatible with mootools + wp_deregister_script('prototype');//remove prototype since it is incompatible with mootools wp_enqueue_script('pagemash_mootools', '/'.$pageMash_rel_dir.'nest-mootools.v1.11.js', false, false); //code is not compatible with other releases of moo wp_enqueue_script('pagemash_nested', '/'.$pageMash_rel_dir.'nested.js', array('pagemash_mootools'), false); wp_enqueue_script('pagemash_inlineEdit', '/'.$pageMash_rel_dir.'inlineEdit.v1.2.js', array('pagemash_mootools'), false); wp_enqueue_script('pagemash', '/'.$pageMash_rel_dir.'pagemash.js', array('pagemash_mootools'), false); add_action('admin_head', 'pageMash_add_css', 1); - + } function pageMash_add_css(){ - global $pageMash_abs_dir; + global $pageMash_abs_dir, $CollapsePagesOnLoad; + if($CollapsePagesOnLoad): ?> + + - diff --git a/reorder.php b/reorder.php deleted file mode 100644 index 6a9c097..0000000 --- a/reorder.php +++ /dev/null @@ -1,15 +0,0 @@ -posts SET menu_order='$position' WHERE ID='$pageid'"; //setup db query - $wpdb->query($postquery); //update pages in db - $position += 1; //increment position var -endforeach; - -update_option("exclude_pages", $_GET['exclude'], '', 'yes'); - -echo "pagemashed"; -?> diff --git a/saveList.php b/saveList.php index eb9c29c..0d01ef0 100644 --- a/saveList.php +++ b/saveList.php @@ -14,7 +14,9 @@ if(!$_POST['m']) die('no data'); //die if no data is sent error_reporting(E_ALL); require_once('myjson.php'); //JSON decode lib -require_once('./../../../wp-config.php'); //config to connect to database +//require_once('./../../../wp-config.php'); //config to connect to database + include_once "../../../wp-config.php"; + include_once "../../../wp-settings.php"; global $wpdb, $excludePages; $excludePages = array(); @@ -46,7 +48,7 @@ function saveList($parent, $children) { $wpdb->query($postquery); //$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET menu_order = %d, post_parent = %s WHERE ID = %d" ), $i, $parent, $id ); echo $postquery; echo "\n"; - + if (isset($v->children[0])) {saveList($id, $v->children);} $i++; }