CMS Tree Page View - Version 1.2.4

Version Description

  • Small design changes for the icons in the post overview screen
  • Added actions to check permissions when adding pages with AJAX
Download this release

Release Info

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

Code changes from version 1.2.3 to 1.2.4

functions.php CHANGED
@@ -92,13 +92,26 @@ function cms_tpv_add_pages() {
92
  // and then all pages after that one will get it's menu_order
93
  // increased by the same number as the number of new posts we're gonna add
94
 
 
 
 
95
  $post_parent = 0;
96
  if ("after" === $post_position) {
97
  $post_parent = $ref_post->post_parent;
 
98
  } elseif ("inside" === $post_position) {
99
  $post_parent = $ref_post->ID;
 
 
 
 
 
 
100
  }
101
 
 
 
 
102
 
103
  /*
104
  perhaps for wpml:
@@ -136,11 +149,11 @@ function cms_tpv_add_pages() {
136
  "menu_order" => $one_post->menu_order + $arr_post_names_count
137
  );
138
  $return_id = wp_update_post($post_update);
139
- if (0 ===$return_id) die("Error: could not update post with id " . $post_update->ID);
140
 
141
  }
142
 
143
- if ( ! $has_passed_ref_post && $ref_post->ID === $one_post->ID) {
144
  $has_passed_ref_post = TRUE;
145
  }
146
 
@@ -491,7 +504,7 @@ function cms_tpv_save_settings() {
491
  $options["dashboard"] = (array) $_POST["post-type-dashboard"];
492
  $options["menu"] = (array) $_POST["post-type-menu"];
493
  $options["postsoverview"] = (array) $_POST["post-type-postsoverview"];
494
-
495
  update_option('cms_tpv_options', $options); // enable this to show box
496
 
497
  }
@@ -743,7 +756,7 @@ function cms_tpv_print_common_tree_stuff($post_type = "") {
743
 
744
  global $sitepress, $cms_tpv_view, $wpdb;
745
 
746
- if (!$post_type) {
747
  $post_type = cms_tpv_get_selected_post_type();
748
  }
749
 
@@ -1207,8 +1220,8 @@ function cms_tpv_print_childs($pageID, $view = "all", $arrOpenChilds = null, $po
1207
 
1208
  $arr_page_css_styles = array();
1209
  $user_can_edit_page = apply_filters("cms_tree_page_view_post_can_edit", current_user_can( $post_type_object->cap->edit_post, $page_id), $page_id);
1210
- $user_can_add_inside = apply_filters("cms_tree_page_view_post_user_can_add_inside", current_user_can( $post_type_object->cap->edit_post, $page_id), $page_id);
1211
- $user_can_add_after = apply_filters("cms_tree_page_view_post_user_can_add_after", current_user_can( $post_type_object->cap->edit_post, $page_id), $page_id);
1212
 
1213
  if ( $user_can_edit_page ) {
1214
  $arr_page_css_styles[] = "cms_tpv_user_can_edit_page_yes";
@@ -1424,6 +1437,9 @@ function cms_tpv_get_childs() {
1424
  exit;
1425
  }
1426
 
 
 
 
1427
  function cms_tpv_add_page() {
1428
  global $wpdb;
1429
 
@@ -1679,7 +1695,8 @@ function cms_tpv_install() {
1679
  // set to current version
1680
  update_option('cms_tpv_version', CMS_TPV_VERSION);
1681
  }
1682
- #cms_tpv_install();
 
1683
 
1684
  /**
1685
  * setup some defaults
92
  // and then all pages after that one will get it's menu_order
93
  // increased by the same number as the number of new posts we're gonna add
94
 
95
+ $ok_to_continue_by_permission = TRUE;
96
+ $post_type_object = get_post_type_object($ref_post->post_type);
97
+
98
  $post_parent = 0;
99
  if ("after" === $post_position) {
100
  $post_parent = $ref_post->post_parent;
101
+ $ok_to_continue_by_permission = apply_filters("cms_tree_page_view_post_user_can_add_after", current_user_can( $post_type_object->cap->create_posts, $ref_post_id), $ref_post_id);
102
  } elseif ("inside" === $post_position) {
103
  $post_parent = $ref_post->ID;
104
+ $ok_to_continue_by_permission = apply_filters("cms_tree_page_view_post_user_can_add_inside", current_user_can( $post_type_object->cap->create_posts, $ref_post_id), $ref_post_id);
105
+ }
106
+
107
+ if ( ! $ok_to_continue_by_permission ) {
108
+ wp_die( __( 'Cheatin’ uh?' ) );
109
+ return FALSE;
110
  }
111
 
112
+ // $user_can_edit_page = apply_filters("cms_tree_page_view_post_can_edit", current_user_can( $post_type_object->cap->edit_post, $ref_post_id), $ref_post_id);
113
+
114
+
115
 
116
  /*
117
  perhaps for wpml:
149
  "menu_order" => $one_post->menu_order + $arr_post_names_count
150
  );
151
  $return_id = wp_update_post($post_update);
152
+ if (0 ===$return_id) die( "Error: could not update post with id " . $post_update->ID . "<br>Technical details: " . print_r($post_update) );
153
 
154
  }
155
 
156
+ if ( ! $has_passed_ref_post && $ref_post->ID === $one_post->ID ) {
157
  $has_passed_ref_post = TRUE;
158
  }
159
 
504
  $options["dashboard"] = (array) $_POST["post-type-dashboard"];
505
  $options["menu"] = (array) $_POST["post-type-menu"];
506
  $options["postsoverview"] = (array) $_POST["post-type-postsoverview"];
507
+
508
  update_option('cms_tpv_options', $options); // enable this to show box
509
 
510
  }
756
 
757
  global $sitepress, $cms_tpv_view, $wpdb;
758
 
759
+ if ( ! $post_type ) {
760
  $post_type = cms_tpv_get_selected_post_type();
761
  }
762
 
1220
 
1221
  $arr_page_css_styles = array();
1222
  $user_can_edit_page = apply_filters("cms_tree_page_view_post_can_edit", current_user_can( $post_type_object->cap->edit_post, $page_id), $page_id);
1223
+ $user_can_add_inside = apply_filters("cms_tree_page_view_post_user_can_add_inside", current_user_can( $post_type_object->cap->create_posts, $page_id), $page_id);
1224
+ $user_can_add_after = apply_filters("cms_tree_page_view_post_user_can_add_after", current_user_can( $post_type_object->cap->create_posts, $page_id), $page_id);
1225
 
1226
  if ( $user_can_edit_page ) {
1227
  $arr_page_css_styles[] = "cms_tpv_user_can_edit_page_yes";
1437
  exit;
1438
  }
1439
 
1440
+ /**
1441
+ * @TODO: check if this is used any longer? If not then delete it!
1442
+ */
1443
  function cms_tpv_add_page() {
1444
  global $wpdb;
1445
 
1695
  // set to current version
1696
  update_option('cms_tpv_version', CMS_TPV_VERSION);
1697
  }
1698
+
1699
+ // cms_tpv_install();
1700
 
1701
  /**
1702
  * setup some defaults
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. Use the tree view to edit, view, add pages and search pages (very 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: 1.2.3
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", "1.2.3");
31
  define( "CMS_TPV_NAME", "CMS Tree Page View");
32
 
33
  require(dirname(__FILE__)."/functions.php");
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. Use the tree view to edit, view, add pages and search pages (very 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: 1.2.4
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", "1.2.4");
31
  define( "CMS_TPV_NAME", "CMS Tree Page View");
32
 
33
  require(dirname(__FILE__)."/functions.php");
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.4
6
  Tested up to: 3.5
7
- Stable tag: 1.2.3
8
 
9
  Adds a tree view of all pages & custom posts. Get a great overview + options to drag & drop to reorder & option to add multiple pages.
10
 
@@ -105,6 +105,10 @@ Now the tree with the pages will be visible both on the dashboard and in the men
105
 
106
  == Changelog ==
107
 
 
 
 
 
108
  = 1.2.3 =
109
  - Removed an ugly pixel in the tree icon
110
  - Minor CSS changes to tree icon
4
  Tags: page, pages, posts, custom posts, tree, cms, dashboard, overview, drag-and-drop, rearrange, management, manage, admin
5
  Requires at least: 3.4
6
  Tested up to: 3.5
7
+ Stable tag: 1.2.4
8
 
9
  Adds a tree view of all pages & custom posts. Get a great overview + options to drag & drop to reorder & option to add multiple pages.
10
 
105
 
106
  == Changelog ==
107
 
108
+ = 1.2.4 =
109
+ - Small design changes for the icons in the post overview screen
110
+ - Added actions to check permissions when adding pages with AJAX
111
+
112
  = 1.2.3 =
113
  - Removed an ugly pixel in the tree icon
114
  - Minor CSS changes to tree icon
scripts/cms_tree_page_view.js CHANGED
@@ -897,6 +897,7 @@ jQuery(function($) {
897
  view_switch_list_a = view_switch_list.closest("a");
898
 
899
  view_switch.append(view_switch_list_a);
 
900
 
901
  }
902
 
897
  view_switch_list_a = view_switch_list.closest("a");
898
 
899
  view_switch.append(view_switch_list_a);
900
+ view_switch.append(" ");
901
 
902
  }
903
 
styles/styles.css CHANGED
@@ -478,7 +478,7 @@ for posts overview enabled mode
478
  }
479
 
480
  .view-switch-cstpv-icon-added a {
481
- display: inline-block;
482
  }
483
 
484
  #view-switch-tree {
478
  }
479
 
480
  .view-switch-cstpv-icon-added a {
481
+ display: inline-block !important;
482
  }
483
 
484
  #view-switch-tree {