CMS Tree Page View - Version 1.2.2

Version Description

  • Hide "inside" link if post type is draft, since you can't create new post inside a page with status draft (limitation/bug with Wordpress)
  • Added actions so other developers or plugins can control what pages/posts that are editiable and so on. Added filters are: cms_tree_page_view_post_can_edit, cms_tree_page_view_post_user_can_add_inside, cms_tree_page_view_post_user_can_add_after
Download this release

Release Info

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

Code changes from version 1.2.1 to 1.2.2

Files changed (5) hide show
  1. functions.php +60 -56
  2. index.php +1 -1
  3. readme.txt +9 -4
  4. scripts/cms_tree_page_view.js +37 -8
  5. styles/styles.css +21 -5
functions.php CHANGED
@@ -1,5 +1,36 @@
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  /**
4
  * Use the ajax action-thingie to catch our form with new pages
5
  * Add pages and then redirect to...?
@@ -897,12 +928,12 @@ function cms_tpv_print_common_tree_stuff($post_type = "") {
897
 
898
  <span class='cms_tpv_action_add_page'><?php echo $post_type_object->labels->add_new_item ?></span>
899
 
900
- <a href="#" title='<?php _e("Add new page after", "cms-tree-page-view")?>' class='cms_tpv_action_add_page_after'><?php _e("After", "cms-tree-page-view")?></a>
901
 
902
  <?php
903
  // if post type is hierarchical we can add pages inside
904
  if (cms_tpv_is_post_type_hierarchical($post_type_object)) {
905
- ?><a href="#" title='<?php _e("Add new page inside", "cms-tree-page-view")?>' class='cms_tpv_action_add_page_inside'><?php _e("Inside", "cms-tree-page-view")?></a><?php
906
  }
907
  // if post status = draft then we can not add pages inside because wordpress currently can not keep its parent if we edit the page
908
  ?>
@@ -931,7 +962,7 @@ function cms_tpv_print_common_tree_stuff($post_type = "") {
931
  </ul>
932
  </div>
933
 
934
- <div>
935
  <?php _e("Position", "cms-tree-page-view") ?><br>
936
  <label><input type="radio" name="cms_tpv_add_type" value="after"> <?php _e("After", "cms-tree-page-view") ?></label>
937
  <label><input type="radio" name="cms_tpv_add_type" value="inside"> <?php _e("Inside", "cms-tree-page-view") ?></label>
@@ -1016,50 +1047,6 @@ function cms_tpv_pages_page() {
1016
  ?></h2>
1017
 
1018
  <?php
1019
- /*
1020
- Not so much nagging, since I'm a nice guy.
1021
- <div class="bonny-plugins-inner-sidebar">
1022
- <h3>Support the author</h3>
1023
- <p>
1024
- If you like this plugin you are welcome to support the author by donating:
1025
- </p>
1026
- <form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="text-align: center">
1027
- <input type="hidden" name="cmd" value="_s-xclick">
1028
- <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHXwYJKoZIhvcNAQcEoIIHUDCCB0wCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYArzkksMbzVWCE3kMsAGZ6xe4p6CQcaIaH3w9JF5RS6Z8PIelZw26PHvfrQUVAUCL3IecfDVU0hjDCDfvmQe16lNZSVvy57uwk20ryOTf5IJ7Ujulw1G0T0Fpc7M9Mb0FRWblgnbETeEREzRZiGZBPfI+cn9rghM1Sb3xcYGWFfujELMAkGBSsOAwIaBQAwgdwGCSqGSIb3DQEHATAUBggqhkiG9w0DBwQIZb6E5mM+R7iAgbgoPH19h/wvJIJR8lPTFEg2qb4bpstEjDo5rgjbdWEBbVp1dtFXdDCf4Nbivm5yvk2Ugf5sDsX1OiOcotl/1E8tW5VesSIkYtVmTgBbr9wkWuZPT8RKrvRVSVgWHxwXV4/eYFwxDsheL04BZYUV6lPSSEBPnEtO4Rn2AfBKo/gYqfb8zdu23FpWKrUMlRQ2ETDFINliKnDNx59aFEbTP85eOQpqetm/fDQKtGebOSpFTJ3TxlM3U54coIIDhzCCA4MwggLsoAMCAQICAQAwDQYJKoZIhvcNAQEFBQAwgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tMB4XDTA0MDIxMzEwMTMxNVoXDTM1MDIxMzEwMTMxNVowgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDBR07d/ETMS1ycjtkpkvjXZe9k+6CieLuLsPumsJ7QC1odNz3sJiCbs2wC0nLE0uLGaEtXynIgRqIddYCHx88pb5HTXv4SZeuv0Rqq4+axW9PLAAATU8w04qqjaSXgbGLP3NmohqM6bV9kZZwZLR/klDaQGo1u9uDb9lr4Yn+rBQIDAQABo4HuMIHrMB0GA1UdDgQWBBSWn3y7xm8XvVk/UtcKG+wQ1mSUazCBuwYDVR0jBIGzMIGwgBSWn3y7xm8XvVk/UtcKG+wQ1mSUa6GBlKSBkTCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb22CAQAwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQCBXzpWmoBa5e9fo6ujionW1hUhPkOBakTr3YCDjbYfvJEiv/2P+IobhOGJr85+XHhN0v4gUkEDI8r2/rNk1m0GA8HKddvTjyGw/XqXa+LSTlDYkqI8OwR8GEYj4efEtcRpRYBxV8KxAW93YDWzFGvruKnnLbDAF6VR5w/cCMn5hzGCAZowggGWAgEBMIGUMIGOMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxFDASBgNVBAoTC1BheVBhbCBJbmMuMRMwEQYDVQQLFApsaXZlX2NlcnRzMREwDwYDVQQDFAhsaXZlX2FwaTEcMBoGCSqGSIb3DQEJARYNcmVAcGF5cGFsLmNvbQIBADAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTEwMTE2MjIyNzQyWjAjBgkqhkiG9w0BCQQxFgQUiaTKjuxCgwQjZm+TAmb0/tQbdWIwDQYJKoZIhvcNAQEBBQAEgYAn4V+IMVl19uvdDieOk8Wahvy1QYm+UfdMQn8ZuHOAswJ9vYreuqcradc4EL0kWH/o2/wzPWxoT3S2fqgdrVeKm8hnsXOWcpuFYMMu9fdLCe0wak8jpzTb02gm+LfYnK/dxe5FkgmzR2HN0tAdl+xlSUUApUZ1yZsXgWe9kFKZdg==-----END PKCS7-----">
1029
- <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
1030
- <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
1031
- </form>
1032
-
1033
- <p style="text-align: center">
1034
- <a href="http://flattr.com/thing/117882/CMS-Tree-Page-View-Plugin-for-WordPress" target="_blank">
1035
- <img src="http://api.flattr.com/button/flattr-badge-large.png" alt="Flattr this" title="Flattr this" border="0" /></a>
1036
- </p>
1037
-
1038
- <p>
1039
- You can also show your appreciation
1040
- by giving the plugin a <a href="http://wordpress.org/extend/plugins/cms-tree-page-view/">good rating over at the plugin directory</a>
1041
- or blog or tweet something nice about this plugin.
1042
- </p>
1043
-
1044
- <h3>Support</h3>
1045
- <p>If you have any problems with this plugins please check out the <a href="http://wordpress.org/tags/cms-tree-page-view?forum_id=10">support forum</a>.</p>
1046
-
1047
- <h3>More CMS related plugins</h3>
1048
- <p>These are some more plugins that enhance the CMS functionality of WordPress. Please check them out!</p>
1049
- <ul>
1050
- <li><a href="http://wordpress.org/extend/plugins/admin-menu-tree-page-view/">Admin Menu Tree Page View</a></li>
1051
- <li><a href="http://wordpress.org/extend/plugins/simple-history/">Simple History</a></li>
1052
- <li><a href="http://wordpress.org/extend/plugins/simple-fields/">Simple Fields</a></li>
1053
- <li><a href="http://wordpress.org/extend/plugins/simple-front-end-edit-buttons/">Simple Front End Edit Buttons</a></li>
1054
- </ul>
1055
-
1056
-
1057
- </div>
1058
- */
1059
- ?>
1060
-
1061
- <?php
1062
- // cms_tpv_show_annoying_box();
1063
  cms_tpv_print_common_tree_stuff($post_type);
1064
  ?>
1065
 
@@ -1150,6 +1137,7 @@ function cms_tpv_print_childs($pageID, $view = "all", $arrOpenChilds = null, $po
1150
  global $current_screen;
1151
  $screen = convert_to_screen("edit");
1152
  $screen->post_type = null;
 
1153
 
1154
  ob_start(); // some plugins, for example magic fields, return javascript and things here. we're not compatible with that, so just swallow any output
1155
  $posts_columns = get_column_headers($screen);
@@ -1216,18 +1204,32 @@ function cms_tpv_print_childs($pageID, $view = "all", $arrOpenChilds = null, $po
1216
  $title = __("<Untitled page>", 'cms-tree-page-view');
1217
  }
1218
  $title = esc_html($title);
1219
- #$title = html_entity_decode($title, ENT_COMPAT, "UTF-8");
1220
- #$title = html_entity_decode($title, ENT_COMPAT);
1221
 
1222
- // can edit?
1223
- if ( current_user_can( 'edit_page', $page_id ) ) {
1224
- $user_can_edit_page = true;
1225
- $user_can_edit_page_css = "cms_tpv_user_can_edit_page_yes";
 
 
 
 
 
 
 
 
 
1226
  } else {
1227
- $user_can_edit_page = false;
1228
- $user_can_edit_page_css = "cms_tpv_user_can_edit_page_no";
1229
  }
1230
 
 
 
 
 
 
 
 
 
1231
  // fetch columns
1232
  $str_columns = "";
1233
  foreach ( $posts_columns as $column_name => $column_display_name ) {
@@ -1282,7 +1284,7 @@ function cms_tpv_print_childs($pageID, $view = "all", $arrOpenChilds = null, $po
1282
  <?php /* "xhref": "<?php echo $editLink ?>", */ ?>
1283
  "id": "cms-tpv-<?php echo $onePage->ID ?>",
1284
  <?php /* "xtitle": "<?php _e("Click to edit. Drag to move.", 'cms-tree-page-view') ?>", */ ?>
1285
- "class": "<?php echo $user_can_edit_page_css ?>"
1286
  },
1287
  <?php echo $strState ?>
1288
  "metadata": {
@@ -1299,6 +1301,8 @@ function cms_tpv_print_childs($pageID, $view = "all", $arrOpenChilds = null, $po
1299
  "modified_author": "<?php echo $post_author ?>",
1300
  "columns": <?php echo $str_columns ?>,
1301
  "user_can_edit_page": "<?php echo (int) $user_can_edit_page ?>",
 
 
1302
  "post_title": "<?php echo $title ?>"
1303
  }
1304
  <?php
1
  <?php
2
 
3
+
4
+ /**
5
+ * Example how to use action cms_tree_page_view_post_can_edit to modify if a user can edit the page/post
6
+ */
7
+ /*
8
+ add_action("cms_tree_page_view_post_can_edit", function($can_edit, $post_id) {
9
+
10
+ if ($post_id === 163) $can_edit = FALSE;
11
+
12
+ return $can_edit;
13
+
14
+ }, 10, 2);
15
+
16
+
17
+ add_action("cms_tree_page_view_post_user_can_add_inside", function($can_edit, $post_id) {
18
+
19
+ if ($post_id === 233) $can_edit = FALSE;
20
+
21
+ return $can_edit;
22
+
23
+ }, 10, 2);
24
+
25
+ add_action("cms_tree_page_view_post_user_can_add_after", function($can_edit, $post_id) {
26
+
27
+ if ($post_id === 142) $can_edit = FALSE;
28
+
29
+ return $can_edit;
30
+
31
+ }, 10, 2);
32
+ */
33
+
34
  /**
35
  * Use the ajax action-thingie to catch our form with new pages
36
  * Add pages and then redirect to...?
928
 
929
  <span class='cms_tpv_action_add_page'><?php echo $post_type_object->labels->add_new_item ?></span>
930
 
931
+ <a class='cms_tpv_action_add_page_after' href="#" title='<?php _e("Add new page after", "cms-tree-page-view")?>' ><?php _e("After", "cms-tree-page-view")?></a>
932
 
933
  <?php
934
  // if post type is hierarchical we can add pages inside
935
  if (cms_tpv_is_post_type_hierarchical($post_type_object)) {
936
+ ?><a class='cms_tpv_action_add_page_inside' href="#" title='<?php _e("Add new page inside", "cms-tree-page-view")?>' ><?php _e("Inside", "cms-tree-page-view")?></a><?php
937
  }
938
  // if post status = draft then we can not add pages inside because wordpress currently can not keep its parent if we edit the page
939
  ?>
962
  </ul>
963
  </div>
964
 
965
+ <div class="cms_tpv_add_position">
966
  <?php _e("Position", "cms-tree-page-view") ?><br>
967
  <label><input type="radio" name="cms_tpv_add_type" value="after"> <?php _e("After", "cms-tree-page-view") ?></label>
968
  <label><input type="radio" name="cms_tpv_add_type" value="inside"> <?php _e("Inside", "cms-tree-page-view") ?></label>
1047
  ?></h2>
1048
 
1049
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1050
  cms_tpv_print_common_tree_stuff($post_type);
1051
  ?>
1052
 
1137
  global $current_screen;
1138
  $screen = convert_to_screen("edit");
1139
  $screen->post_type = null;
1140
+ $post_type_object = get_post_type_object($post_type);
1141
 
1142
  ob_start(); // some plugins, for example magic fields, return javascript and things here. we're not compatible with that, so just swallow any output
1143
  $posts_columns = get_column_headers($screen);
1204
  $title = __("<Untitled page>", 'cms-tree-page-view');
1205
  }
1206
  $title = esc_html($title);
 
 
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";
1215
+ } else {
1216
+ $arr_page_css_styles[] = "cms_tpv_user_can_edit_page_no";
1217
+ }
1218
+
1219
+ if ( $user_can_add_inside ) {
1220
+ $arr_page_css_styles[] = "cms_tpv_user_can_add_page_inside_yes";
1221
  } else {
1222
+ $arr_page_css_styles[] = "cms_tpv_user_can_add_page_inside_no";
 
1223
  }
1224
 
1225
+ if ( $user_can_add_after ) {
1226
+ $arr_page_css_styles[] = "cms_tpv_user_can_add_page_after_yes";
1227
+ } else {
1228
+ $arr_page_css_styles[] = "cms_tpv_user_can_add_page_after_no";
1229
+ }
1230
+
1231
+ $page_css = join(" ", $arr_page_css_styles);
1232
+
1233
  // fetch columns
1234
  $str_columns = "";
1235
  foreach ( $posts_columns as $column_name => $column_display_name ) {
1284
  <?php /* "xhref": "<?php echo $editLink ?>", */ ?>
1285
  "id": "cms-tpv-<?php echo $onePage->ID ?>",
1286
  <?php /* "xtitle": "<?php _e("Click to edit. Drag to move.", 'cms-tree-page-view') ?>", */ ?>
1287
+ "class": "<?php echo $page_css ?>"
1288
  },
1289
  <?php echo $strState ?>
1290
  "metadata": {
1301
  "modified_author": "<?php echo $post_author ?>",
1302
  "columns": <?php echo $str_columns ?>,
1303
  "user_can_edit_page": "<?php echo (int) $user_can_edit_page ?>",
1304
+ "user_can_add_page_inside": "<?php echo (int) $user_can_add_inside ?>",
1305
+ "user_can_add_page_after": "<?php echo (int) $user_can_add_after ?>",
1306
  "post_title": "<?php echo $title ?>"
1307
  }
1308
  <?php
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.1
7
  Author: Pär Thernström
8
  Author URI: http://eskapism.se/
9
  License: GPL2
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.2
7
  Author: Pär Thernström
8
  Author URI: http://eskapism.se/
9
  License: GPL2
readme.txt CHANGED
@@ -4,13 +4,14 @@ 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.1
8
 
9
- Adds a tree view of all pages & custom posts. Get a great overview + options to drag & drop to reorder and option to add multiple pages at once.
10
 
11
  == Description ==
12
 
13
  Adds a CMS-like tree overview of all your pages and custom posts to WordPress - much like the view often found in a page-focused CMS.
 
14
  Within this tree you can edit pages, view pages, add pages, search pages, and drag and drop pages to rearrange the order.
15
 
16
  CMS Tree Page View is a good alternative to plugins such as pageMash, WordPress Page Tree
@@ -37,7 +38,7 @@ Page management in WordPress won't get any easier than this!
37
  To show your pages on your website in the same order as they appear in this plugin, you must
38
  sort them by "menu order".
39
 
40
- ´
41
  // Example using query_posts
42
  $args = array(
43
  'orderby'=> 'menu_order',
@@ -49,7 +50,7 @@ $posts = query_posts($args);
49
  // Example using wp_query
50
  $query = new WP_Query( array( 'post_type' => 'page', 'orderby' => 'title menu_order', 'order' => 'ASC' ) );
51
 
52
- ´
53
 
54
  #### Screencast
55
  Watch this screencast to see how easy you could be managing your pages:
@@ -104,6 +105,10 @@ Now the tree with the pages will be visible both on the dashboard and in the men
104
 
105
  == Changelog ==
106
 
 
 
 
 
107
  = 1.2.1 =
108
  - Fixed wrong count if WPML where activated and future or private posts existed for a language
109
  - Show info message if no posts found after fetching posts with AJAX
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.2
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
 
11
  == Description ==
12
 
13
  Adds a CMS-like tree overview of all your pages and custom posts to WordPress - much like the view often found in a page-focused CMS.
14
+
15
  Within this tree you can edit pages, view pages, add pages, search pages, and drag and drop pages to rearrange the order.
16
 
17
  CMS Tree Page View is a good alternative to plugins such as pageMash, WordPress Page Tree
38
  To show your pages on your website in the same order as they appear in this plugin, you must
39
  sort them by "menu order".
40
 
41
+ `
42
  // Example using query_posts
43
  $args = array(
44
  'orderby'=> 'menu_order',
50
  // Example using wp_query
51
  $query = new WP_Query( array( 'post_type' => 'page', 'orderby' => 'title menu_order', 'order' => 'ASC' ) );
52
 
53
+ `
54
 
55
  #### Screencast
56
  Watch this screencast to see how easy you could be managing your pages:
105
 
106
  == Changelog ==
107
 
108
+ = 1.2.2 =
109
+ - Hide "inside" link if post type is draft, since you can't create new post inside a page with status draft (limitation/bug with Wordpress)
110
+ - Added actions so other developers or plugins can control what pages/posts that are editiable and so on. Added filters are: cms_tree_page_view_post_can_edit, cms_tree_page_view_post_user_can_add_inside, cms_tree_page_view_post_user_can_add_after
111
+
112
  = 1.2.1 =
113
  - Fixed wrong count if WPML where activated and future or private posts existed for a language
114
  - Show info message if no posts found after fetching posts with AJAX
scripts/cms_tree_page_view.js CHANGED
@@ -446,6 +446,7 @@ function cms_tpv_mouseover_li(e) {
446
  $edit = div_actions_for_post_type.find(".cms_tpv_action_edit");
447
  var editlink = $li.data("editlink");
448
  $edit.attr("href", editlink);
 
449
 
450
  // ..and some extras
451
  div_actions_for_post_type.find(".cms_tpv_page_actions_modified_time").text($li.data("modified_time"));
@@ -459,6 +460,22 @@ function cms_tpv_mouseover_li(e) {
459
  // add post id to data
460
  div_actions_for_post_type.data("post_id", $li.data("post_id"));
461
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
462
  // position and show action div
463
  var $a = $li.find("a");
464
  var width = $a.outerWidth(true);
@@ -483,18 +500,30 @@ function cms_tpv_mouseover_li(e) {
483
  div_actions_for_post_type.removeClass("cms_tpv_page_actions_visible_from_bottom");
484
  }
485
 
 
 
486
  // check if user is allowed to edit page
487
  var $cms_tpv_action_add_and_edit_page = div_actions_for_post_type.find(".cms_tpv_action_add_and_edit_page");
488
  if ($li.data("user_can_edit_page") === "0") {
489
- // nooope
490
- $edit.hide();
491
- $cms_tpv_action_add_and_edit_page.hide();
492
- } else {
493
- //$edit.show();
494
- $cms_tpv_action_add_and_edit_page.show();
495
- div_actions_for_post_type.addClass("cms_tpv_page_actions_visible");
 
 
 
 
 
 
 
 
 
 
 
496
  }
497
-
498
 
499
  }
500
  }
446
  $edit = div_actions_for_post_type.find(".cms_tpv_action_edit");
447
  var editlink = $li.data("editlink");
448
  $edit.attr("href", editlink);
449
+ $edit.removeClass("hidden");
450
 
451
  // ..and some extras
452
  div_actions_for_post_type.find(".cms_tpv_page_actions_modified_time").text($li.data("modified_time"));
460
  // add post id to data
461
  div_actions_for_post_type.data("post_id", $li.data("post_id"));
462
 
463
+
464
+ // check permissions, may the current user add page, after or inside
465
+ // If page has status draft then no one is allowed to add page inside
466
+ // div_actions_for_post_type.find(".cms_tpv_action_add_page_inside, .cms_tpv_action_add_page_inside").show();
467
+ div_actions_for_post_type.find(".cms_tpv_action_add_page_inside, .cms_tpv_action_add_page_inside").removeClass("hidden");
468
+
469
+ var inside_allowed = true;
470
+ if ("draft" === $li.data("post_status")) {
471
+ inside_allowed = false;
472
+ }
473
+
474
+ if (!inside_allowed) {
475
+ //div_actions_for_post_type.find(".cms_tpv_action_add_page_inside").hide();
476
+ }
477
+
478
+
479
  // position and show action div
480
  var $a = $li.find("a");
481
  var width = $a.outerWidth(true);
500
  div_actions_for_post_type.removeClass("cms_tpv_page_actions_visible_from_bottom");
501
  }
502
 
503
+ div_actions_for_post_type.addClass("cms_tpv_page_actions_visible");
504
+
505
  // check if user is allowed to edit page
506
  var $cms_tpv_action_add_and_edit_page = div_actions_for_post_type.find(".cms_tpv_action_add_and_edit_page");
507
  if ($li.data("user_can_edit_page") === "0") {
508
+ $edit.addClass("hidden");
509
+ }
510
+
511
+ $cms_tpv_add_position = div_actions_for_post_type.find(".cms_tpv_add_position");
512
+ $cms_tpv_add_position.removeClass("hidden");
513
+
514
+ $cms_tpv_action_add_page_after = div_actions_for_post_type.find(".cms_tpv_action_add_page_after");
515
+ $cms_tpv_action_add_page_after.removeClass("hidden");
516
+ if ($li.data("user_can_add_page_after") === "0") {
517
+ $cms_tpv_action_add_page_after.addClass("hidden");
518
+ $cms_tpv_add_position.addClass("hidden");
519
+ }
520
+
521
+ $cms_tpv_action_add_page_inside = div_actions_for_post_type.find(".cms_tpv_action_add_page_inside");
522
+ $cms_tpv_action_add_page_inside.removeClass("hidden");
523
+ if ($li.data("user_can_add_page_inside") === "0") {
524
+ $cms_tpv_action_add_page_inside.addClass("hidden");
525
+ $cms_tpv_add_position.addClass("hidden");
526
  }
 
527
 
528
  }
529
  }
styles/styles.css CHANGED
@@ -297,25 +297,41 @@ p.cms_tpv_action_edit_and_view
297
  margin-top: 0em;
298
  }
299
  .cms_tpv_wrapper .cms_tpv_page_actions a {
300
- display: inline;
301
  background: transparent;
302
  text-decoration: underline;
303
  color: #21759B;
304
  font-weight: normal;
305
  padding: 0 .5em 0 0;
306
  margin-right: .2em;
 
 
 
307
  border-right: 1px solid #aaa;
308
  }
309
- .cms_tpv_wrapper .cms_tpv_page_actions a:last-child {
310
- border: none;
 
311
  }
312
 
313
- .cms_tpv_wrapper .cms_tpv_page_actions a:hover
314
- {
315
  color: #d54e21;
316
  background-color: transparent;
317
  }
318
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
319
  .cms_tpv_page_actions ul {
320
  display: block;
321
  overflow: auto;
297
  margin-top: 0em;
298
  }
299
  .cms_tpv_wrapper .cms_tpv_page_actions a {
 
300
  background: transparent;
301
  text-decoration: underline;
302
  color: #21759B;
303
  font-weight: normal;
304
  padding: 0 .5em 0 0;
305
  margin-right: .2em;
306
+ }
307
+
308
+ .cms_tpv_wrapper .cms_tpv_page_actions .cms_tpv_action_edit_and_view a {
309
  border-right: 1px solid #aaa;
310
  }
311
+
312
+ .cms_tpv_wrapper .cms_tpv_page_actions .cms_tpv_action_edit_and_view a:not(.hidden):last-of-type {
313
+ border-right: none;
314
  }
315
 
316
+ .cms_tpv_wrapper .cms_tpv_page_actions a:hover {
 
317
  color: #d54e21;
318
  background-color: transparent;
319
  }
320
 
321
+ /* applied to all (aka "first") */
322
+ .cms_tpv_wrapper .cms_tpv_page_actions .cms_tpv_action_add_and_edit_page a:not(.hidden) {
323
+ /*background: red;*/
324
+ padding: 0;
325
+ margin: 0;
326
+ }
327
+ /* tricky way to get non first not hidden */
328
+ .cms_tpv_wrapper .cms_tpv_page_actions .cms_tpv_action_add_and_edit_page a:not(.hidden) ~ a:not(.hidden) {
329
+ /*background: yellow;*/
330
+ border-left: 1px solid #aaa;
331
+ padding-left: .5em;
332
+ margin-left: .2em;
333
+ }
334
+
335
  .cms_tpv_page_actions ul {
336
  display: block;
337
  overflow: auto;