CMS Tree Page View - Version 0.7.6

Version Description

  • You can now view items in the trash. i bit closer to a complete take over of the pages-page :)
Download this release

Release Info

Developer eskapism
Plugin Icon wp plugin CMS Tree Page View
Version 0.7.6
Comparing to
See all releases

Code changes from version 0.7.5 to 0.7.6

Files changed (4) hide show
  1. functions.php +45 -14
  2. index.php +5 -2
  3. readme.txt +4 -1
  4. scripts/cms_tree_page_view.js +27 -6
functions.php CHANGED
@@ -61,12 +61,15 @@ function cms_tpv_admin_init() {
61
  "after" => __("after", 'cms-tree-page-view'),
62
  "inside" => __("inside", 'cms-tree-page-view'),
63
  "Can_not_add_sub_page_when_status_is_draft" => __("Sorry, can't create a sub page to a page with status \"draft\".", 'cms-tree-page-view'),
 
 
64
  "Add_new_page_inside" => __("Add new page inside", 'cms-tree-page-view'),
65
  "Status_draft" => __("draft", 'cms-tree-page-view'),
66
  "Status_future" => __("future", 'cms-tree-page-view'),
67
  "Status_password" => __("protected", 'cms-tree-page-view'), // is "protected" word better than "password" ?
68
  "Status_pending" => __("pending", 'cms-tree-page-view'),
69
  "Status_private" => __("private", 'cms-tree-page-view'),
 
70
  "Password_protected_page" => __("Password protected page", 'cms-tree-page-view'),
71
  "Adding_page" => __("Adding page...", 'cms-tree-page-view'),
72
  );
@@ -327,7 +330,6 @@ function cms_tpv_print_common_tree_stuff($post_type = "") {
327
  [country_flag_url] => http://localhost/wordpress3/wp-content/plugins/sitepress-multilingual-cms/res/flags/en.png
328
  )
329
  */
330
-
331
 
332
  if (empty($pages)) {
333
  echo '<div class="updated fade below-h2"><p>' . __("No posts found.", 'cms-tree-page-view') . '</p></div>';
@@ -337,7 +339,8 @@ function cms_tpv_print_common_tree_stuff($post_type = "") {
337
 
338
  <ul class="cms-tpv-subsubsub">
339
  <li><a class="cms_tvp_view_all <?php echo ($cms_tpv_view=="all") ? "current" : "" ?>" href="#"><?php _e("All", 'cms-tree-page-view') ?></a> |</li>
340
- <li><a class="cms_tvp_view_public <?php echo ($cms_tpv_view=="public") ? "current" : "" ?>" href="#"><?php _e("Public", 'cms-tree-page-view') ?></a></li>
 
341
 
342
  <?php
343
  if ($post_type_object->hierarchical) {
@@ -440,7 +443,7 @@ function cms_tpv_get_pages($args = null) {
440
  $defaults = array(
441
  "post_type" => "post",
442
  "parent" => "",
443
- "view" => "all" // all | public
444
  );
445
  $r = wp_parse_args( $args, $defaults );
446
 
@@ -460,6 +463,14 @@ function cms_tpv_get_pages($args = null) {
460
  }
461
  if ($r["view"] == "all") {
462
  $get_posts_args["post_status"] = "any"; // "any" seems to get all but auto-drafts
 
 
 
 
 
 
 
 
463
  } else {
464
  $get_posts_args["post_status"] = "publish";
465
  }
@@ -468,6 +479,7 @@ function cms_tpv_get_pages($args = null) {
468
  remove_action("get_pages", array('ScoperHardway', 'flt_get_pages'), 1, 2);
469
 
470
  #do_action_ref_array('parse_query', array(&$this));
 
471
  $pages = get_posts($get_posts_args);
472
 
473
  // filter out pages for wpml, by applying same filter as get_pages does
@@ -523,7 +535,12 @@ function cms_tpv_print_childs($pageID, $view = "all", $arrOpenChilds = null, $po
523
  $content = esc_html($onePage->post_content);
524
  $content = str_replace(array("\n","\r"), "", $content);
525
  $hasChildren = false;
526
- $arrChildPages = cms_tpv_get_pages("parent={$onePage->ID}&view=$view&post_type=$post_type");
 
 
 
 
 
527
 
528
  if ($arrChildPages) {
529
  $hasChildren = true;
@@ -669,7 +686,7 @@ function cms_tpv_get_childs() {
669
  header("Content-type: application/json");
670
 
671
  $action = $_GET["action"];
672
- $view = $_GET["view"]; // all | public
673
  $post_type = (isset($_GET["post_type"])) ? $_GET["post_type"] : null;
674
  $search = (isset($_GET["search_string"])) ? trim($_GET["search_string"]) : ""; // exits if we're doing a search
675
  if ($action) {
@@ -859,6 +876,11 @@ function cms_tpv_move_page() {
859
  $post_node = get_post($node_id);
860
  $post_ref_node = get_post($ref_node_id);
861
 
 
 
 
 
 
862
  if ( "inside" == $type ) {
863
 
864
  // post_node is moved inside ref_post_node
@@ -949,15 +971,9 @@ function cms_tpv_show_annoying_box() {
949
  if ($show_box) {
950
  ?>
951
  <div class="cms_tpv_annoying_little_box">
952
- <p class="cms_tpv_annoying_little_box_close"><a href="<?php echo add_query_arg("action", "cms_tpv_remove_annoying_box")?>">Close</a></p>
953
- <p><strong>Thank you for using this plugin!</strong> If you need help please check out the <a href="http://eskapism.se/code-playground/cms-tree-page-view/?utm_source=wordpress&utm_medium=banner&utm_campaign=promobox">plugin homepage</a> or the <a href="http://wordpress.org/tags/cms-tree-page-view?forum_id=10">support forum</a>.</p>
954
- <p>If you like this plugin, please <a href="http://eskapism.se/sida/donate/?utm_source=wordpress&utm_medium=banner&utm_campaign=promobox">support my work by donating</a> - or at least say something nice about this plugin in a blog post or tweet.</p>
955
- <!-- <p>Thank you</p>
956
- <p><img src="<?php echo CMS_TPV_URL ?>/images/signature.gif" alt="Pär Thernström's signature" /></p>
957
- <p>Pär Thernström
958
- <br /><a href="mailto:par.thernstrom@gmail.com">par.thernstrom@gmail.com</a>
959
- <br /><a href="twitter.com/eskapism">twitter.com/eskapism</a>
960
- </p> -->
961
  </div>
962
  <?php
963
  }
@@ -974,6 +990,7 @@ function bonny_d($var) {
974
 
975
 
976
  function cms_tpv_install() {
 
977
  // after upgrading/re-enabling the plugin, also re-enable the little please-donate-box
978
  update_option('cms_tpv_show_annoying_little_box', 1);
979
 
@@ -992,3 +1009,17 @@ function cms_tpv_install() {
992
  update_option('cms_tpv_version', CMS_TPV_VERSION);
993
  }
994
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  "after" => __("after", 'cms-tree-page-view'),
62
  "inside" => __("inside", 'cms-tree-page-view'),
63
  "Can_not_add_sub_page_when_status_is_draft" => __("Sorry, can't create a sub page to a page with status \"draft\".", 'cms-tree-page-view'),
64
+ "Can_not_add_sub_page_when_status_is_trash" => __("Sorry, can't create a sub page to a page with status \"trash\".", 'cms-tree-page-view'),
65
+ "Can_not_add_page_after_when_status_is_trash" => __("Sorry, can't create a page after a page with status \"trash\".", 'cms-tree-page-view'),
66
  "Add_new_page_inside" => __("Add new page inside", 'cms-tree-page-view'),
67
  "Status_draft" => __("draft", 'cms-tree-page-view'),
68
  "Status_future" => __("future", 'cms-tree-page-view'),
69
  "Status_password" => __("protected", 'cms-tree-page-view'), // is "protected" word better than "password" ?
70
  "Status_pending" => __("pending", 'cms-tree-page-view'),
71
  "Status_private" => __("private", 'cms-tree-page-view'),
72
+ "Status_trash" => __("trash", 'cms-tree-page-view'),
73
  "Password_protected_page" => __("Password protected page", 'cms-tree-page-view'),
74
  "Adding_page" => __("Adding page...", 'cms-tree-page-view'),
75
  );
330
  [country_flag_url] => http://localhost/wordpress3/wp-content/plugins/sitepress-multilingual-cms/res/flags/en.png
331
  )
332
  */
 
333
 
334
  if (empty($pages)) {
335
  echo '<div class="updated fade below-h2"><p>' . __("No posts found.", 'cms-tree-page-view') . '</p></div>';
339
 
340
  <ul class="cms-tpv-subsubsub">
341
  <li><a class="cms_tvp_view_all <?php echo ($cms_tpv_view=="all") ? "current" : "" ?>" href="#"><?php _e("All", 'cms-tree-page-view') ?></a> |</li>
342
+ <li><a class="cms_tvp_view_public <?php echo ($cms_tpv_view=="public") ? "current" : "" ?>" href="#"><?php _e("Public", 'cms-tree-page-view') ?></a> |</li>
343
+ <li><a class="cms_tvp_view_trash <?php echo ($cms_tpv_view=="trash") ? "current" : "" ?>" href="#"><?php _e("Trash", 'cms-tree-page-view') ?></a></li>
344
 
345
  <?php
346
  if ($post_type_object->hierarchical) {
443
  $defaults = array(
444
  "post_type" => "post",
445
  "parent" => "",
446
+ "view" => "all" // all | public | trash
447
  );
448
  $r = wp_parse_args( $args, $defaults );
449
 
463
  }
464
  if ($r["view"] == "all") {
465
  $get_posts_args["post_status"] = "any"; // "any" seems to get all but auto-drafts
466
+ } elseif ($r["view"] == "trash") {
467
+
468
+ $get_posts_args["post_status"] = "trash";
469
+
470
+ // if getting trash, just get all pages, don't care about parent?
471
+ // because otherwise we have to mix trashed pages and pages with other statuses. messy.
472
+ $get_posts_args["post_parent"] = null;
473
+
474
  } else {
475
  $get_posts_args["post_status"] = "publish";
476
  }
479
  remove_action("get_pages", array('ScoperHardway', 'flt_get_pages'), 1, 2);
480
 
481
  #do_action_ref_array('parse_query', array(&$this));
482
+ #print_r($get_posts_args);
483
  $pages = get_posts($get_posts_args);
484
 
485
  // filter out pages for wpml, by applying same filter as get_pages does
535
  $content = esc_html($onePage->post_content);
536
  $content = str_replace(array("\n","\r"), "", $content);
537
  $hasChildren = false;
538
+
539
+ // if viewing trash, don't get children. we watch them "flat" instead
540
+ if ($view == "trash") {
541
+ } else {
542
+ $arrChildPages = cms_tpv_get_pages("parent={$onePage->ID}&view=$view&post_type=$post_type");
543
+ }
544
 
545
  if ($arrChildPages) {
546
  $hasChildren = true;
686
  header("Content-type: application/json");
687
 
688
  $action = $_GET["action"];
689
+ $view = $_GET["view"]; // all | public | trash
690
  $post_type = (isset($_GET["post_type"])) ? $_GET["post_type"] : null;
691
  $search = (isset($_GET["search_string"])) ? trim($_GET["search_string"]) : ""; // exits if we're doing a search
692
  if ($action) {
876
  $post_node = get_post($node_id);
877
  $post_ref_node = get_post($ref_node_id);
878
 
879
+ // first check that post_node (moved post) is not in trash. we do not move them
880
+ if ($post_node->post_status == "trash") {
881
+ exit;
882
+ }
883
+
884
  if ( "inside" == $type ) {
885
 
886
  // post_node is moved inside ref_post_node
971
  if ($show_box) {
972
  ?>
973
  <div class="cms_tpv_annoying_little_box">
974
+ <p class="cms_tpv_annoying_little_box_close"><a href="<?php echo add_query_arg("action", "cms_tpv_remove_annoying_box")?>"><?php _e("Close", 'cms-tree-page-view') ?></a></p>
975
+ <p><?php _e('<strong>Thank you for using this plugin!</strong> If you need help please check out the <a href="http://eskapism.se/code-playground/cms-tree-page-view/?utm_source=wordpress&utm_medium=banner&utm_campaign=promobox">plugin homepage</a> or the <a href="http://wordpress.org/tags/cms-tree-page-view?forum_id=10">support forum</a>.', 'cms-tree-page-view') ?></p>
976
+ <p><?php _e('If you like this plugin, please <a href="http://eskapism.se/sida/donate/?utm_source=wordpress&utm_medium=banner&utm_campaign=promobox">support my work by donating</a> - or at least say something nice about this plugin in a blog post or tweet.', 'cms-tree-page-view') ?></p>
 
 
 
 
 
 
977
  </div>
978
  <?php
979
  }
990
 
991
 
992
  function cms_tpv_install() {
993
+
994
  // after upgrading/re-enabling the plugin, also re-enable the little please-donate-box
995
  update_option('cms_tpv_show_annoying_little_box', 1);
996
 
1009
  update_option('cms_tpv_version', CMS_TPV_VERSION);
1010
  }
1011
 
1012
+ // when plugins are loaded, check if current plugin version is same as stored
1013
+ // if not = it's an upgrade. right?
1014
+ function cms_tpv_plugins_loaded($a) {
1015
+ $installed_version = get_option('cms_tpv_version', 0);
1016
+ #echo "installed_version: $installed_version";
1017
+ #echo "<br>" . CMS_TPV_VERSION;
1018
+ if ($installed_version != CMS_TPV_VERSION) {
1019
+ // new version!
1020
+ // upgrade stored version to current version + show that annoying litte box again
1021
+ update_option('cms_tpv_version', CMS_TPV_VERSION);
1022
+ update_option('cms_tpv_show_annoying_little_box', 1);
1023
+ }
1024
+
1025
+ }
index.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: CMS Tree Page View
4
  Plugin URI: http://eskapism.se/code-playground/cms-tree-page-view/
5
  Description: Adds a CMS-like tree view of all your pages, like the view often found in a page-focused CMS. By using the tree you can edit, view, add pages and even search pages (useful if you have many pages). And with drag and drop you can rearrange the order of your pages. Page management won't get any easier than this!
6
- Version: 0.7.5
7
  Author: Pär Thernström
8
  Author URI: http://eskapism.se/
9
  License: GPL2
@@ -27,7 +27,7 @@ License: GPL2
27
 
28
  require("functions.php");
29
 
30
- define( "CMS_TPV_VERSION", "0.7.5");
31
  define( "CMS_TPV_URL", WP_PLUGIN_URL . '/cms-tree-page-view/');
32
  define( "CMS_TPV_NAME", "CMS Tree Page View");
33
 
@@ -48,6 +48,9 @@ add_action('wp_ajax_cms_tpv_add_page', 'cms_tpv_add_page');
48
  // activation
49
  register_activation_hook( WP_PLUGIN_DIR . "/cms-tree-page-view/index.php" , 'cms_tpv_install' );
50
 
 
 
 
51
  // hook onto query
52
  #add_action( 'parse_query', 'cms_tpv_parse_query' );
53
 
3
  Plugin Name: CMS Tree Page View
4
  Plugin URI: http://eskapism.se/code-playground/cms-tree-page-view/
5
  Description: Adds a CMS-like tree view of all your pages, like the view often found in a page-focused CMS. By using the tree you can edit, view, add pages and even search pages (useful if you have many pages). And with drag and drop you can rearrange the order of your pages. Page management won't get any easier than this!
6
+ Version: 0.7.6
7
  Author: Pär Thernström
8
  Author URI: http://eskapism.se/
9
  License: GPL2
27
 
28
  require("functions.php");
29
 
30
+ define( "CMS_TPV_VERSION", "0.7.6");
31
  define( "CMS_TPV_URL", WP_PLUGIN_URL . '/cms-tree-page-view/');
32
  define( "CMS_TPV_NAME", "CMS Tree Page View");
33
 
48
  // activation
49
  register_activation_hook( WP_PLUGIN_DIR . "/cms-tree-page-view/index.php" , 'cms_tpv_install' );
50
 
51
+ // catch upgrade
52
+ add_action('plugins_loaded', 'cms_tpv_plugins_loaded' , 1);
53
+
54
  // hook onto query
55
  #add_action( 'parse_query', 'cms_tpv_parse_query' );
56
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://eskapism.se/sida/donate/
4
  Tags: page, pages, posts, custom posts, tree, cms, dashboard, overview, drag-and-drop, rearrange, management, manage, admin
5
  Requires at least: 3.0
6
  Tested up to: 3.0
7
- Stable tag: 0.7.4
8
 
9
  Adds a CMS-like tree overview of your pages or custom posts. Rearrange the order of your pages (with drag and drop). Also edit, view, add, and search your pages.
10
 
@@ -73,6 +73,9 @@ Now the tree with the pages will be visible both on the dashboard and in the men
73
 
74
  == Changelog ==
75
 
 
 
 
76
  = 0.7.5 =
77
  - fixed some notice-errors and switched some deprecated functions
78
  - updated swedish translation
4
  Tags: page, pages, posts, custom posts, tree, cms, dashboard, overview, drag-and-drop, rearrange, management, manage, admin
5
  Requires at least: 3.0
6
  Tested up to: 3.0
7
+ Stable tag: 0.7.6
8
 
9
  Adds a CMS-like tree overview of your pages or custom posts. Rearrange the order of your pages (with drag and drop). Also edit, view, add, and search your pages.
10
 
73
 
74
  == Changelog ==
75
 
76
+ = 0.7.6 =
77
+ - You can now view items in the trash. i bit closer to a complete take over of the pages-page :)
78
+
79
  = 0.7.5 =
80
  - fixed some notice-errors and switched some deprecated functions
81
  - updated swedish translation
scripts/cms_tree_page_view.js CHANGED
@@ -141,6 +141,15 @@ jQuery(".cms_tpv_action_add_page_after").live("click", function() {
141
  var $this = jQuery(this);
142
  var post_type = cms_tpv_get_post_type(this);
143
  var selected_lang = cms_tpv_get_wpml_selected_lang(this);
 
 
 
 
 
 
 
 
 
144
  jPrompt(cmstpv_l10n.Enter_title_of_new_page, "", "CMS Tree Page View", function(new_page_title) {
145
  if (new_page_title) {
146
  $this.closest(".cms_tpv_container").html(cmstpv_l10n.Adding_page);
@@ -167,15 +176,22 @@ jQuery(".cms_tpv_action_add_page_inside").live("click", function() {
167
  var post_type = cms_tpv_get_post_type(this);
168
  var selected_lang = cms_tpv_get_wpml_selected_lang(this);
169
 
170
- // check page status, because we cant add a page inside a page with status draft
 
 
171
  // if we edit the page wordpress will forget the parent
172
  //$li.data("jstree").permalink;
173
  //var post_status = li.data("jstree").post_status;
174
- var post_status = $this.closest("li").data("jstree").post_status;
175
  if (post_status == "draft") {
176
  jAlert(cmstpv_l10n.Can_not_add_sub_page_when_status_is_draft);
177
  return false;
178
  }
 
 
 
 
 
 
179
 
180
  jPrompt(cmstpv_l10n.Enter_title_of_new_page, "", "CMS Tree Page View", function(new_page_title) {
181
  if (new_page_title) {
@@ -457,17 +473,20 @@ jQuery(".cms_tpv_close_all").live("click", function() {
457
  return false;
458
  });
459
 
460
- // view all or public
461
  jQuery(".cms_tvp_view_all").live("click", function() {
462
  cms_tvp_set_view("all", this);
463
- //jQuery(this).addClass("current");
464
  return false;
465
  });
466
  jQuery(".cms_tvp_view_public").live("click", function() {
467
  cms_tvp_set_view("public", this);
468
- //jQuery(this).addClass("current");
469
  return false;
470
  });
 
 
 
 
 
471
 
472
  // change lang
473
  jQuery("a.cms_tvp_switch_lang").live("click", function(e) {
@@ -506,7 +525,7 @@ function cms_tvp_set_view(view, elm) {
506
  var div_actions_for_post_type = cms_tpv_get_page_actions_div(elm);
507
  $wrapper.append(div_actions_for_post_type);
508
 
509
- $wrapper.find(".cms_tvp_view_all,.cms_tvp_view_public").removeClass("current");
510
  $wrapper.find(".cms_tpv_container").jstree("destroy").html("");
511
  cms_tpv_bind_clean_node();
512
 
@@ -514,6 +533,8 @@ function cms_tvp_set_view(view, elm) {
514
  $wrapper.find(".cms_tvp_view_all").addClass("current");
515
  } else if (view == "public") {
516
  $wrapper.find(".cms_tvp_view_public").addClass("current");
 
 
517
  } else {
518
 
519
  }
141
  var $this = jQuery(this);
142
  var post_type = cms_tpv_get_post_type(this);
143
  var selected_lang = cms_tpv_get_wpml_selected_lang(this);
144
+
145
+ var post_status = $this.closest("li").data("jstree").post_status;
146
+
147
+ // not allowed when status is trash
148
+ if (post_status == "trash") {
149
+ jAlert(cmstpv_l10n.Can_not_add_page_after_when_status_is_trash);
150
+ return false;
151
+ }
152
+
153
  jPrompt(cmstpv_l10n.Enter_title_of_new_page, "", "CMS Tree Page View", function(new_page_title) {
154
  if (new_page_title) {
155
  $this.closest(".cms_tpv_container").html(cmstpv_l10n.Adding_page);
176
  var post_type = cms_tpv_get_post_type(this);
177
  var selected_lang = cms_tpv_get_wpml_selected_lang(this);
178
 
179
+ var post_status = $this.closest("li").data("jstree").post_status;
180
+
181
+ // check page status, because we cant add a page inside a page with status draft or status trash
182
  // if we edit the page wordpress will forget the parent
183
  //$li.data("jstree").permalink;
184
  //var post_status = li.data("jstree").post_status;
 
185
  if (post_status == "draft") {
186
  jAlert(cmstpv_l10n.Can_not_add_sub_page_when_status_is_draft);
187
  return false;
188
  }
189
+
190
+ // not allowed when status is trash
191
+ if (post_status == "trash") {
192
+ jAlert(cmstpv_l10n.Can_not_add_sub_page_when_status_is_trash);
193
+ return false;
194
+ }
195
 
196
  jPrompt(cmstpv_l10n.Enter_title_of_new_page, "", "CMS Tree Page View", function(new_page_title) {
197
  if (new_page_title) {
473
  return false;
474
  });
475
 
476
+ // view all or public or trash
477
  jQuery(".cms_tvp_view_all").live("click", function() {
478
  cms_tvp_set_view("all", this);
 
479
  return false;
480
  });
481
  jQuery(".cms_tvp_view_public").live("click", function() {
482
  cms_tvp_set_view("public", this);
 
483
  return false;
484
  });
485
+ jQuery(".cms_tvp_view_trash").live("click", function() {
486
+ cms_tvp_set_view("trash", this);
487
+ return false;
488
+ });
489
+
490
 
491
  // change lang
492
  jQuery("a.cms_tvp_switch_lang").live("click", function(e) {
525
  var div_actions_for_post_type = cms_tpv_get_page_actions_div(elm);
526
  $wrapper.append(div_actions_for_post_type);
527
 
528
+ $wrapper.find(".cms_tvp_view_all, .cms_tvp_view_public, .cms_tvp_view_trash").removeClass("current");
529
  $wrapper.find(".cms_tpv_container").jstree("destroy").html("");
530
  cms_tpv_bind_clean_node();
531
 
533
  $wrapper.find(".cms_tvp_view_all").addClass("current");
534
  } else if (view == "public") {
535
  $wrapper.find(".cms_tvp_view_public").addClass("current");
536
+ } else if (view == "trash") {
537
+ $wrapper.find(".cms_tvp_view_trash").addClass("current");
538
  } else {
539
 
540
  }