Version Description
(January 2018) = - Add nonce check when moving page and adding new pages.
Download this release
Release Info
| Developer | eskapism |
| Plugin | |
| Version | 2.7 |
| Comparing to | |
| See all releases | |
Code changes from version 2.6.9 to 2.7
- README.md +12 -0
- css/arrow-left.gif +0 -0
- css/page_white_text.png +0 -0
- index.php +8 -2
- js/scripts.js +50 -48
- readme.txt +4 -1
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# WordPress Admin Menu Tree Page View
|
| 2 |
+
|
| 3 |
+
Plugin that gives you access to all pages on all pages.
|
| 4 |
+
|
| 5 |
+
Let me give you a screenshot:
|
| 6 |
+
|
| 7 |
+

|
| 8 |
+
|
| 9 |
+
## Download
|
| 10 |
+
|
| 11 |
+
You can [download the plugin from wordpress.org](https://wordpress.org/plugins/admin-menu-tree-page-view/).
|
| 12 |
+
Remember to [give it a nice review](https://wordpress.org/support/view/plugin-reviews/admin-menu-tree-page-view) if you like it!.
|
css/arrow-left.gif
CHANGED
|
File without changes
|
css/page_white_text.png
CHANGED
|
File without changes
|
index.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
Plugin Name: Admin Menu Tree Page View
|
| 4 |
Plugin URI: http://eskapism.se/code-playground/admin-menu-tree-page-view/
|
| 5 |
Description: Get a tree view of all your pages directly in the admin menu. Search, edit, view and add pages - all with just one click away!
|
| 6 |
-
Version: 2.
|
| 7 |
Author: Pär Thernström
|
| 8 |
Author URI: http://eskapism.se/
|
| 9 |
License: GPL2
|
|
@@ -38,7 +38,7 @@ add_action('wp_ajax_admin_menu_tree_page_view_move_page', 'admin_menu_tree_page_
|
|
| 38 |
|
| 39 |
function admin_menu_tree_page_view_admin_init() {
|
| 40 |
|
| 41 |
-
define( "admin_menu_tree_page_view_VERSION", "2.
|
| 42 |
define( "admin_menu_tree_page_view_URL", WP_PLUGIN_URL . '/admin-menu-tree-page-view/' );
|
| 43 |
define( "admin_menu_tree_page_view_DIR", WP_PLUGIN_DIR . '/admin-menu-tree-page-view/' );
|
| 44 |
|
|
@@ -74,7 +74,9 @@ function admin_menu_tree_page_view_admin_init() {
|
|
| 74 |
"Add_new_page_here" => __("Add new page after", 'admin-menu-tree-page-view'),
|
| 75 |
"Add_new_page_inside" => __("Add new page inside", 'admin-menu-tree-page-view'),
|
| 76 |
"Untitled" => __("Untitled", 'admin-menu-tree-page-view'),
|
|
|
|
| 77 |
);
|
|
|
|
| 78 |
wp_localize_script( "admin_menu_tree_page_view", 'amtpv_l10n', $oLocale);
|
| 79 |
}
|
| 80 |
|
|
@@ -346,6 +348,8 @@ function admin_menu_tree_page_page() {
|
|
| 346 |
*/
|
| 347 |
function admin_menu_tree_page_view_add_page() {
|
| 348 |
|
|
|
|
|
|
|
| 349 |
global $wpdb;
|
| 350 |
|
| 351 |
/*
|
|
@@ -481,6 +485,8 @@ function admin_menu_tree_page_view_add_page() {
|
|
| 481 |
// code from my other plugin cms tree page view
|
| 482 |
function admin_menu_tree_page_view_move_page() {
|
| 483 |
|
|
|
|
|
|
|
| 484 |
/*
|
| 485 |
Array ( [action] => admin_menu_tree_page_view_move_page [post_to_update_id] => 567 [direction] => down )
|
| 486 |
*/
|
| 3 |
Plugin Name: Admin Menu Tree Page View
|
| 4 |
Plugin URI: http://eskapism.se/code-playground/admin-menu-tree-page-view/
|
| 5 |
Description: Get a tree view of all your pages directly in the admin menu. Search, edit, view and add pages - all with just one click away!
|
| 6 |
+
Version: 2.7
|
| 7 |
Author: Pär Thernström
|
| 8 |
Author URI: http://eskapism.se/
|
| 9 |
License: GPL2
|
| 38 |
|
| 39 |
function admin_menu_tree_page_view_admin_init() {
|
| 40 |
|
| 41 |
+
define( "admin_menu_tree_page_view_VERSION", "2.7" );
|
| 42 |
define( "admin_menu_tree_page_view_URL", WP_PLUGIN_URL . '/admin-menu-tree-page-view/' );
|
| 43 |
define( "admin_menu_tree_page_view_DIR", WP_PLUGIN_DIR . '/admin-menu-tree-page-view/' );
|
| 44 |
|
| 74 |
"Add_new_page_here" => __("Add new page after", 'admin-menu-tree-page-view'),
|
| 75 |
"Add_new_page_inside" => __("Add new page inside", 'admin-menu-tree-page-view'),
|
| 76 |
"Untitled" => __("Untitled", 'admin-menu-tree-page-view'),
|
| 77 |
+
'nonce' => wp_create_nonce('admin-menu-tree-page-view')
|
| 78 |
);
|
| 79 |
+
|
| 80 |
wp_localize_script( "admin_menu_tree_page_view", 'amtpv_l10n', $oLocale);
|
| 81 |
}
|
| 82 |
|
| 348 |
*/
|
| 349 |
function admin_menu_tree_page_view_add_page() {
|
| 350 |
|
| 351 |
+
check_ajax_referer('admin-menu-tree-page-view', 'amtpv-nonce');
|
| 352 |
+
|
| 353 |
global $wpdb;
|
| 354 |
|
| 355 |
/*
|
| 485 |
// code from my other plugin cms tree page view
|
| 486 |
function admin_menu_tree_page_view_move_page() {
|
| 487 |
|
| 488 |
+
check_ajax_referer('admin-menu-tree-page-view', 'amtpv-nonce');
|
| 489 |
+
|
| 490 |
/*
|
| 491 |
Array ( [action] => admin_menu_tree_page_view_move_page [post_to_update_id] => 567 [direction] => down )
|
| 492 |
*/
|
js/scripts.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
|
| 2 |
jQuery(function($) {
|
| 3 |
-
|
| 4 |
// @todo: this is only needed for WordPress earlier than 3.2?
|
| 5 |
setTimeout(function() {
|
| 6 |
jQuery("#toplevel_page_admin-menu-tree-page-tree_main").addClass("wp-menu-open");
|
| 7 |
}, 100);
|
| 8 |
-
|
| 9 |
// search/filter pages
|
| 10 |
$("li.admin-menu-tree-page-filter input").keyup(function(e) {
|
| 11 |
var ul = $(this).closest("ul.admin-menu-tree-page-tree");
|
|
@@ -23,7 +23,7 @@ jQuery(function($) {
|
|
| 23 |
}
|
| 24 |
ul.highlight(s);
|
| 25 |
hits.show();
|
| 26 |
-
|
| 27 |
// hits can be childs of hidden li:s, so we must show the parents of the hits too
|
| 28 |
hits.each(function(i, elm) {
|
| 29 |
var parent = elm.parentNode;
|
|
@@ -34,7 +34,7 @@ jQuery(function($) {
|
|
| 34 |
parent.show();
|
| 35 |
}
|
| 36 |
});
|
| 37 |
-
|
| 38 |
// if no hits: tell the user so we have less confusion. confusion is bad.
|
| 39 |
var nohits_div = ul.find("div.admin-menu-tree-page-filter-nohits");
|
| 40 |
if (hits.length === 0) {
|
|
@@ -42,7 +42,7 @@ jQuery(function($) {
|
|
| 42 |
} else {
|
| 43 |
nohits_div.hide();
|
| 44 |
}
|
| 45 |
-
|
| 46 |
});
|
| 47 |
|
| 48 |
// clear/reset filter and show all pages again
|
|
@@ -55,7 +55,7 @@ jQuery(function($) {
|
|
| 55 |
ul.unhighlight();
|
| 56 |
ul.find("div.admin-menu-tree-page-filter-nohits").hide();
|
| 57 |
});
|
| 58 |
-
|
| 59 |
// label = hide in and focus input
|
| 60 |
$("li.admin-menu-tree-page-filter label, li.admin-menu-tree-page-filter input").click(function() {
|
| 61 |
var $t = $(this);
|
|
@@ -64,23 +64,23 @@ jQuery(function($) {
|
|
| 64 |
});
|
| 65 |
|
| 66 |
var trees = jQuery("ul.admin-menu-tree-page-tree");
|
| 67 |
-
|
| 68 |
// add links to expand/collapse
|
| 69 |
trees.find("li.admin-menu-tree-page-view-has-childs > div").after("<div class='admin-menu-tree-page-expand' title='Show/Hide child pages' />");
|
| 70 |
trees.on("click", "div.admin-menu-tree-page-expand", function(e) {
|
| 71 |
-
|
| 72 |
e.preventDefault();
|
| 73 |
var $t = $(this);
|
| 74 |
var $li = $t.closest("li");
|
| 75 |
var $a = $li.find("a:first");
|
| 76 |
var $ul = $li.find("ul:first");
|
| 77 |
-
|
| 78 |
var isOpen = false;
|
| 79 |
if ($ul.is(":visible")) {
|
| 80 |
$ul.slideUp(function() {
|
| 81 |
$li.addClass("admin-menu-tree-page-view-closed").removeClass("admin-menu-tree-page-view-opened");
|
| 82 |
});
|
| 83 |
-
|
| 84 |
} else {
|
| 85 |
$ul.slideDown(function() {
|
| 86 |
$li.addClass("admin-menu-tree-page-view-opened").removeClass("admin-menu-tree-page-view-closed");
|
|
@@ -112,7 +112,7 @@ jQuery(function($) {
|
|
| 112 |
var popupdiv = li.find("div.amtpv-editpopup:first");
|
| 113 |
var linkwrap = li.find("div.amtpv-linkwrap:first");
|
| 114 |
//var popup_linkwrap = popupdiv.closest("div.amtpv-linkwrap");
|
| 115 |
-
|
| 116 |
if (e.type == "mouseenter" || e.type == "mouseover") {
|
| 117 |
|
| 118 |
var ul = t.closest("ul.admin-menu-tree-page-tree");
|
|
@@ -125,7 +125,7 @@ jQuery(function($) {
|
|
| 125 |
popupdiv.addClass("amtpv-editpopup-hover");
|
| 126 |
linkwrap.addClass("amtpv-linkwrap-hover");
|
| 127 |
}
|
| 128 |
-
|
| 129 |
} else if (e.type == "mouseleave" || e.type == "mouseout") {
|
| 130 |
|
| 131 |
// don't hide if related target is the shadow of the menu, aka #adminmenushadow
|
|
@@ -133,27 +133,27 @@ jQuery(function($) {
|
|
| 133 |
if (e.relatedTarget && e.relatedTarget.id == "adminmenushadow") {
|
| 134 |
do_hide = false;
|
| 135 |
}
|
| 136 |
-
|
| 137 |
// also don't hide if wrap div has .amtpv-editpopup-is-working
|
| 138 |
if (linkwrap.hasClass("amtpv-editpopup-is-working")) {
|
| 139 |
do_hide = false;
|
| 140 |
}
|
| 141 |
-
|
| 142 |
if (do_hide) {
|
| 143 |
popupdiv.removeClass("amtpv-editpopup-hover");
|
| 144 |
linkwrap.removeClass("amtpv-linkwrap-hover");
|
| 145 |
}
|
| 146 |
-
|
| 147 |
}
|
| 148 |
});
|
| 149 |
-
|
| 150 |
//
|
| 151 |
trees.on("mouseenter mouseleave", "div.amtpv-editpopup", function(e) {
|
| 152 |
var t = $(this);
|
| 153 |
var li = t.closest("li");
|
| 154 |
var popupdiv = li.find("div.amtpv-editpopup:first");
|
| 155 |
var linkwrap = li.find("div.amtpv-linkwrap:first");
|
| 156 |
-
|
| 157 |
if (e.type == "mouseenter" || e.type == "mouseover") {
|
| 158 |
t.addClass("amtpv-editpopup-hover-hover");
|
| 159 |
} else if (e.type == "mouseleave" || e.type == "mouseout") {
|
|
@@ -163,7 +163,7 @@ jQuery(function($) {
|
|
| 163 |
}
|
| 164 |
}
|
| 165 |
});
|
| 166 |
-
|
| 167 |
// edit/view links
|
| 168 |
trees.on("click", "div.amtpv-editpopup-edit, div.amtpv-editpopup-view", function(e) {
|
| 169 |
|
|
@@ -171,7 +171,7 @@ jQuery(function($) {
|
|
| 171 |
var t = $(this);
|
| 172 |
var link = t.data("link");
|
| 173 |
var new_win = false;
|
| 174 |
-
|
| 175 |
if ( ($.client.os == "Mac" && (e.metaKey || e.shiftKey)) || ($.client.os != "Mac" && e.ctrlKey) ) {
|
| 176 |
new_win = true;
|
| 177 |
}
|
|
@@ -180,9 +180,9 @@ jQuery(function($) {
|
|
| 180 |
} else {
|
| 181 |
document.location = link;
|
| 182 |
}
|
| 183 |
-
|
| 184 |
});
|
| 185 |
-
|
| 186 |
// add links
|
| 187 |
trees.on("click", "div.amtpv-editpopup-add-after, div.amtpv-editpopup-add-inside", function(e) {
|
| 188 |
|
|
@@ -192,7 +192,7 @@ jQuery(function($) {
|
|
| 192 |
var popup_linkwrap = popup.closest("div.amtpv-linkwrap");
|
| 193 |
var editpopup_add = popup.find("div.amtpv-editpopup-add");
|
| 194 |
var editpopup_editview = popup.find("div.amtpv-editpopup-editview");
|
| 195 |
-
|
| 196 |
// hide all divs
|
| 197 |
// @todo: should put all in one div, and hide just that one
|
| 198 |
popup.find("> div").hide();
|
|
@@ -204,10 +204,10 @@ jQuery(function($) {
|
|
| 204 |
if (t.hasClass("amtpv-editpopup-add-inside")) {
|
| 205 |
type = "inside";
|
| 206 |
}
|
| 207 |
-
|
| 208 |
// remove possibly previous added add-stuff
|
| 209 |
popup.find("form.amtpv-editpopup-addpages").remove();
|
| 210 |
-
|
| 211 |
var add_pages = $("<form />")
|
| 212 |
.addClass("amtpv-editpopup-addpages")
|
| 213 |
.insertAfter(editpopup_add)
|
|
@@ -227,10 +227,10 @@ jQuery(function($) {
|
|
| 227 |
add_pages.append( $("<div class='amtpv-editpopup-addpages-names'><label class='amtpv-editpopup-addpages-label'>Name(s)</label>") );
|
| 228 |
add_pages.append( $("<ul class='amtpv-editpopup-addpages-names-ul'><li><span></span><input class='amtpv-editpopup-addpages-name' type='text' value=''/></li></ul>") );
|
| 229 |
//add_pages.append( $("<div class='amtpv-editpopup-addpages-addpage'><a href='#'>+ page</a></div></div>"));
|
| 230 |
-
|
| 231 |
add_pages.append( $("<div class='amtpv-editpopup-addpages-submit'><input type='submit' class='button-primary' value='Add' /> or <a href='#' class='amtpv-editpopup-addpages-cancel'>cancel</a></div>"));
|
| 232 |
add_pages.find(".amtpv-editpopup-addpages-name").focus();
|
| 233 |
-
|
| 234 |
add_pages.find("ul.amtpv-editpopup-addpages-names-ul").sortable({
|
| 235 |
"xaxis": "y",
|
| 236 |
"containment": 'parent',
|
|
@@ -239,9 +239,9 @@ jQuery(function($) {
|
|
| 239 |
"handle": "span:first",
|
| 240 |
"placeholder": "ui-state-highlight"
|
| 241 |
});
|
| 242 |
-
|
| 243 |
return;
|
| 244 |
-
|
| 245 |
});
|
| 246 |
|
| 247 |
// add new page-link
|
|
@@ -252,7 +252,7 @@ jQuery(function($) {
|
|
| 252 |
t.parent().prev("ul.amtpv-editpopup-addpages-names-ul").append( newelm );
|
| 253 |
newelm.find("input").focus();
|
| 254 |
});
|
| 255 |
-
|
| 256 |
// when typing in the input, add another input if we are at the last input
|
| 257 |
// this way we don't have to click that "add page" button. less clicks = more productive.
|
| 258 |
trees.on("keyup", "input.amtpv-editpopup-addpages-name", function(e) {
|
|
@@ -260,7 +260,7 @@ jQuery(function($) {
|
|
| 260 |
var t = $(this);
|
| 261 |
var ul = t.closest("ul");
|
| 262 |
var li = t.closest("li");
|
| 263 |
-
|
| 264 |
// if this input is the last one, and we have entered something, add another one
|
| 265 |
var isLast = (li.index() == ul.find("li").length-1);
|
| 266 |
if (isLast && t.val() !== "") {
|
|
@@ -268,9 +268,9 @@ jQuery(function($) {
|
|
| 268 |
ul.append( newelm );
|
| 269 |
newelm.show();
|
| 270 |
}
|
| 271 |
-
|
| 272 |
});
|
| 273 |
-
|
| 274 |
// cancel-link
|
| 275 |
trees.on("click", "a.amtpv-editpopup-addpages-cancel", function(e) {
|
| 276 |
|
|
@@ -279,19 +279,19 @@ jQuery(function($) {
|
|
| 279 |
var t = $(this),
|
| 280 |
popup = t.closest("div.amtpv-editpopup"),
|
| 281 |
linkwrap = popup.closest("div.amtpv-linkwrap");
|
| 282 |
-
|
| 283 |
popup.find(".amtpv-editpopup-addpages").hide().remove();
|
| 284 |
popup.find("> div").show();
|
| 285 |
-
|
| 286 |
linkwrap.removeClass("amtpv-editpopup-is-working");
|
| 287 |
});
|
| 288 |
-
|
| 289 |
// woho, add da pages!
|
| 290 |
trees.on("submit", "form.amtpv-editpopup-addpages", function(e) {
|
| 291 |
// fetch all .amtpv-editpopup-addpages-name for this popup
|
| 292 |
-
|
| 293 |
e.preventDefault();
|
| 294 |
-
|
| 295 |
var t = $(this);
|
| 296 |
var post_id = t.closest("div.amtpv-linkwrap").data("post-id");
|
| 297 |
var popup = t.closest("div.amtpv-editpopup");
|
|
@@ -304,7 +304,7 @@ jQuery(function($) {
|
|
| 304 |
arr_names.push( $(elm).val() );
|
| 305 |
}
|
| 306 |
});
|
| 307 |
-
|
| 308 |
// we must at least have one name
|
| 309 |
// @todo: make this a bit better looking
|
| 310 |
if (arr_names.length === 0) {
|
|
@@ -313,21 +313,22 @@ jQuery(function($) {
|
|
| 313 |
}
|
| 314 |
|
| 315 |
popup.find("div.amtpv-editpopup-addpages-submit input").val("Adding...");
|
| 316 |
-
|
| 317 |
// detect after or inside
|
| 318 |
// var type = popup.find(".amtpv-editpopup-addpages-type").val();
|
| 319 |
var type = popup.find("input[name=amtpv-editpopup-addpages-position]:checked").val();
|
| 320 |
-
|
| 321 |
// post status
|
| 322 |
var post_status = popup.find("#amtpv-editpopup-addpages-publish-select").val();
|
| 323 |
-
|
| 324 |
var data = {
|
| 325 |
"action": 'admin_menu_tree_page_view_add_page',
|
| 326 |
"pageID": post_id,
|
| 327 |
"type": type,
|
| 328 |
"page_titles": arr_names,
|
| 329 |
"post_type": "page",
|
| 330 |
-
"post_status": post_status
|
|
|
|
| 331 |
};
|
| 332 |
|
| 333 |
jQuery.post(ajaxurl, data, function(response) {
|
|
@@ -347,7 +348,7 @@ jQuery(function($) {
|
|
| 347 |
});
|
| 348 |
|
| 349 |
});
|
| 350 |
-
|
| 351 |
// make the tree sortable
|
| 352 |
$("ul.admin-menu-tree-page-tree, ul.admin-menu-tree-page-tree ul").sortable({
|
| 353 |
"axis": "y",
|
|
@@ -370,7 +371,7 @@ jQuery(function($) {
|
|
| 370 |
var li = $(ui.item);
|
| 371 |
var a = li.find("a:first");
|
| 372 |
var post_id = a.data("post-id");
|
| 373 |
-
|
| 374 |
// check if we have a post above
|
| 375 |
var prev = li.prev();
|
| 376 |
var aboveOrNextItem;
|
|
@@ -386,7 +387,7 @@ jQuery(function($) {
|
|
| 386 |
}
|
| 387 |
// get id of above or below post
|
| 388 |
var aboveOrNextPostID = $(aboveOrNextItem).find("a:first").data("post-id");
|
| 389 |
-
|
| 390 |
// flytt upp = start > update
|
| 391 |
// flytt ner = start < update
|
| 392 |
var startindex = li.data("startindex");
|
|
@@ -397,17 +398,18 @@ jQuery(function($) {
|
|
| 397 |
} else {
|
| 398 |
direction = "down";
|
| 399 |
}
|
| 400 |
-
|
| 401 |
// now we have all we need, tell the server to do the move
|
| 402 |
$.post(ajaxurl, {
|
| 403 |
"action": "admin_menu_tree_page_view_move_page",
|
| 404 |
"post_to_update_id": post_id,
|
| 405 |
"direction": direction,
|
| 406 |
-
"aboveOrNextPostID": aboveOrNextPostID
|
|
|
|
| 407 |
}, function(data) {
|
| 408 |
// console.log(data);
|
| 409 |
});
|
| 410 |
-
|
| 411 |
}
|
| 412 |
});
|
| 413 |
|
| 1 |
|
| 2 |
jQuery(function($) {
|
| 3 |
+
|
| 4 |
// @todo: this is only needed for WordPress earlier than 3.2?
|
| 5 |
setTimeout(function() {
|
| 6 |
jQuery("#toplevel_page_admin-menu-tree-page-tree_main").addClass("wp-menu-open");
|
| 7 |
}, 100);
|
| 8 |
+
|
| 9 |
// search/filter pages
|
| 10 |
$("li.admin-menu-tree-page-filter input").keyup(function(e) {
|
| 11 |
var ul = $(this).closest("ul.admin-menu-tree-page-tree");
|
| 23 |
}
|
| 24 |
ul.highlight(s);
|
| 25 |
hits.show();
|
| 26 |
+
|
| 27 |
// hits can be childs of hidden li:s, so we must show the parents of the hits too
|
| 28 |
hits.each(function(i, elm) {
|
| 29 |
var parent = elm.parentNode;
|
| 34 |
parent.show();
|
| 35 |
}
|
| 36 |
});
|
| 37 |
+
|
| 38 |
// if no hits: tell the user so we have less confusion. confusion is bad.
|
| 39 |
var nohits_div = ul.find("div.admin-menu-tree-page-filter-nohits");
|
| 40 |
if (hits.length === 0) {
|
| 42 |
} else {
|
| 43 |
nohits_div.hide();
|
| 44 |
}
|
| 45 |
+
|
| 46 |
});
|
| 47 |
|
| 48 |
// clear/reset filter and show all pages again
|
| 55 |
ul.unhighlight();
|
| 56 |
ul.find("div.admin-menu-tree-page-filter-nohits").hide();
|
| 57 |
});
|
| 58 |
+
|
| 59 |
// label = hide in and focus input
|
| 60 |
$("li.admin-menu-tree-page-filter label, li.admin-menu-tree-page-filter input").click(function() {
|
| 61 |
var $t = $(this);
|
| 64 |
});
|
| 65 |
|
| 66 |
var trees = jQuery("ul.admin-menu-tree-page-tree");
|
| 67 |
+
|
| 68 |
// add links to expand/collapse
|
| 69 |
trees.find("li.admin-menu-tree-page-view-has-childs > div").after("<div class='admin-menu-tree-page-expand' title='Show/Hide child pages' />");
|
| 70 |
trees.on("click", "div.admin-menu-tree-page-expand", function(e) {
|
| 71 |
+
|
| 72 |
e.preventDefault();
|
| 73 |
var $t = $(this);
|
| 74 |
var $li = $t.closest("li");
|
| 75 |
var $a = $li.find("a:first");
|
| 76 |
var $ul = $li.find("ul:first");
|
| 77 |
+
|
| 78 |
var isOpen = false;
|
| 79 |
if ($ul.is(":visible")) {
|
| 80 |
$ul.slideUp(function() {
|
| 81 |
$li.addClass("admin-menu-tree-page-view-closed").removeClass("admin-menu-tree-page-view-opened");
|
| 82 |
});
|
| 83 |
+
|
| 84 |
} else {
|
| 85 |
$ul.slideDown(function() {
|
| 86 |
$li.addClass("admin-menu-tree-page-view-opened").removeClass("admin-menu-tree-page-view-closed");
|
| 112 |
var popupdiv = li.find("div.amtpv-editpopup:first");
|
| 113 |
var linkwrap = li.find("div.amtpv-linkwrap:first");
|
| 114 |
//var popup_linkwrap = popupdiv.closest("div.amtpv-linkwrap");
|
| 115 |
+
|
| 116 |
if (e.type == "mouseenter" || e.type == "mouseover") {
|
| 117 |
|
| 118 |
var ul = t.closest("ul.admin-menu-tree-page-tree");
|
| 125 |
popupdiv.addClass("amtpv-editpopup-hover");
|
| 126 |
linkwrap.addClass("amtpv-linkwrap-hover");
|
| 127 |
}
|
| 128 |
+
|
| 129 |
} else if (e.type == "mouseleave" || e.type == "mouseout") {
|
| 130 |
|
| 131 |
// don't hide if related target is the shadow of the menu, aka #adminmenushadow
|
| 133 |
if (e.relatedTarget && e.relatedTarget.id == "adminmenushadow") {
|
| 134 |
do_hide = false;
|
| 135 |
}
|
| 136 |
+
|
| 137 |
// also don't hide if wrap div has .amtpv-editpopup-is-working
|
| 138 |
if (linkwrap.hasClass("amtpv-editpopup-is-working")) {
|
| 139 |
do_hide = false;
|
| 140 |
}
|
| 141 |
+
|
| 142 |
if (do_hide) {
|
| 143 |
popupdiv.removeClass("amtpv-editpopup-hover");
|
| 144 |
linkwrap.removeClass("amtpv-linkwrap-hover");
|
| 145 |
}
|
| 146 |
+
|
| 147 |
}
|
| 148 |
});
|
| 149 |
+
|
| 150 |
//
|
| 151 |
trees.on("mouseenter mouseleave", "div.amtpv-editpopup", function(e) {
|
| 152 |
var t = $(this);
|
| 153 |
var li = t.closest("li");
|
| 154 |
var popupdiv = li.find("div.amtpv-editpopup:first");
|
| 155 |
var linkwrap = li.find("div.amtpv-linkwrap:first");
|
| 156 |
+
|
| 157 |
if (e.type == "mouseenter" || e.type == "mouseover") {
|
| 158 |
t.addClass("amtpv-editpopup-hover-hover");
|
| 159 |
} else if (e.type == "mouseleave" || e.type == "mouseout") {
|
| 163 |
}
|
| 164 |
}
|
| 165 |
});
|
| 166 |
+
|
| 167 |
// edit/view links
|
| 168 |
trees.on("click", "div.amtpv-editpopup-edit, div.amtpv-editpopup-view", function(e) {
|
| 169 |
|
| 171 |
var t = $(this);
|
| 172 |
var link = t.data("link");
|
| 173 |
var new_win = false;
|
| 174 |
+
|
| 175 |
if ( ($.client.os == "Mac" && (e.metaKey || e.shiftKey)) || ($.client.os != "Mac" && e.ctrlKey) ) {
|
| 176 |
new_win = true;
|
| 177 |
}
|
| 180 |
} else {
|
| 181 |
document.location = link;
|
| 182 |
}
|
| 183 |
+
|
| 184 |
});
|
| 185 |
+
|
| 186 |
// add links
|
| 187 |
trees.on("click", "div.amtpv-editpopup-add-after, div.amtpv-editpopup-add-inside", function(e) {
|
| 188 |
|
| 192 |
var popup_linkwrap = popup.closest("div.amtpv-linkwrap");
|
| 193 |
var editpopup_add = popup.find("div.amtpv-editpopup-add");
|
| 194 |
var editpopup_editview = popup.find("div.amtpv-editpopup-editview");
|
| 195 |
+
|
| 196 |
// hide all divs
|
| 197 |
// @todo: should put all in one div, and hide just that one
|
| 198 |
popup.find("> div").hide();
|
| 204 |
if (t.hasClass("amtpv-editpopup-add-inside")) {
|
| 205 |
type = "inside";
|
| 206 |
}
|
| 207 |
+
|
| 208 |
// remove possibly previous added add-stuff
|
| 209 |
popup.find("form.amtpv-editpopup-addpages").remove();
|
| 210 |
+
|
| 211 |
var add_pages = $("<form />")
|
| 212 |
.addClass("amtpv-editpopup-addpages")
|
| 213 |
.insertAfter(editpopup_add)
|
| 227 |
add_pages.append( $("<div class='amtpv-editpopup-addpages-names'><label class='amtpv-editpopup-addpages-label'>Name(s)</label>") );
|
| 228 |
add_pages.append( $("<ul class='amtpv-editpopup-addpages-names-ul'><li><span></span><input class='amtpv-editpopup-addpages-name' type='text' value=''/></li></ul>") );
|
| 229 |
//add_pages.append( $("<div class='amtpv-editpopup-addpages-addpage'><a href='#'>+ page</a></div></div>"));
|
| 230 |
+
|
| 231 |
add_pages.append( $("<div class='amtpv-editpopup-addpages-submit'><input type='submit' class='button-primary' value='Add' /> or <a href='#' class='amtpv-editpopup-addpages-cancel'>cancel</a></div>"));
|
| 232 |
add_pages.find(".amtpv-editpopup-addpages-name").focus();
|
| 233 |
+
|
| 234 |
add_pages.find("ul.amtpv-editpopup-addpages-names-ul").sortable({
|
| 235 |
"xaxis": "y",
|
| 236 |
"containment": 'parent',
|
| 239 |
"handle": "span:first",
|
| 240 |
"placeholder": "ui-state-highlight"
|
| 241 |
});
|
| 242 |
+
|
| 243 |
return;
|
| 244 |
+
|
| 245 |
});
|
| 246 |
|
| 247 |
// add new page-link
|
| 252 |
t.parent().prev("ul.amtpv-editpopup-addpages-names-ul").append( newelm );
|
| 253 |
newelm.find("input").focus();
|
| 254 |
});
|
| 255 |
+
|
| 256 |
// when typing in the input, add another input if we are at the last input
|
| 257 |
// this way we don't have to click that "add page" button. less clicks = more productive.
|
| 258 |
trees.on("keyup", "input.amtpv-editpopup-addpages-name", function(e) {
|
| 260 |
var t = $(this);
|
| 261 |
var ul = t.closest("ul");
|
| 262 |
var li = t.closest("li");
|
| 263 |
+
|
| 264 |
// if this input is the last one, and we have entered something, add another one
|
| 265 |
var isLast = (li.index() == ul.find("li").length-1);
|
| 266 |
if (isLast && t.val() !== "") {
|
| 268 |
ul.append( newelm );
|
| 269 |
newelm.show();
|
| 270 |
}
|
| 271 |
+
|
| 272 |
});
|
| 273 |
+
|
| 274 |
// cancel-link
|
| 275 |
trees.on("click", "a.amtpv-editpopup-addpages-cancel", function(e) {
|
| 276 |
|
| 279 |
var t = $(this),
|
| 280 |
popup = t.closest("div.amtpv-editpopup"),
|
| 281 |
linkwrap = popup.closest("div.amtpv-linkwrap");
|
| 282 |
+
|
| 283 |
popup.find(".amtpv-editpopup-addpages").hide().remove();
|
| 284 |
popup.find("> div").show();
|
| 285 |
+
|
| 286 |
linkwrap.removeClass("amtpv-editpopup-is-working");
|
| 287 |
});
|
| 288 |
+
|
| 289 |
// woho, add da pages!
|
| 290 |
trees.on("submit", "form.amtpv-editpopup-addpages", function(e) {
|
| 291 |
// fetch all .amtpv-editpopup-addpages-name for this popup
|
| 292 |
+
|
| 293 |
e.preventDefault();
|
| 294 |
+
|
| 295 |
var t = $(this);
|
| 296 |
var post_id = t.closest("div.amtpv-linkwrap").data("post-id");
|
| 297 |
var popup = t.closest("div.amtpv-editpopup");
|
| 304 |
arr_names.push( $(elm).val() );
|
| 305 |
}
|
| 306 |
});
|
| 307 |
+
|
| 308 |
// we must at least have one name
|
| 309 |
// @todo: make this a bit better looking
|
| 310 |
if (arr_names.length === 0) {
|
| 313 |
}
|
| 314 |
|
| 315 |
popup.find("div.amtpv-editpopup-addpages-submit input").val("Adding...");
|
| 316 |
+
|
| 317 |
// detect after or inside
|
| 318 |
// var type = popup.find(".amtpv-editpopup-addpages-type").val();
|
| 319 |
var type = popup.find("input[name=amtpv-editpopup-addpages-position]:checked").val();
|
| 320 |
+
|
| 321 |
// post status
|
| 322 |
var post_status = popup.find("#amtpv-editpopup-addpages-publish-select").val();
|
| 323 |
+
|
| 324 |
var data = {
|
| 325 |
"action": 'admin_menu_tree_page_view_add_page',
|
| 326 |
"pageID": post_id,
|
| 327 |
"type": type,
|
| 328 |
"page_titles": arr_names,
|
| 329 |
"post_type": "page",
|
| 330 |
+
"post_status": post_status,
|
| 331 |
+
"amtpv-nonce": window.amtpv_l10n.nonce
|
| 332 |
};
|
| 333 |
|
| 334 |
jQuery.post(ajaxurl, data, function(response) {
|
| 348 |
});
|
| 349 |
|
| 350 |
});
|
| 351 |
+
|
| 352 |
// make the tree sortable
|
| 353 |
$("ul.admin-menu-tree-page-tree, ul.admin-menu-tree-page-tree ul").sortable({
|
| 354 |
"axis": "y",
|
| 371 |
var li = $(ui.item);
|
| 372 |
var a = li.find("a:first");
|
| 373 |
var post_id = a.data("post-id");
|
| 374 |
+
|
| 375 |
// check if we have a post above
|
| 376 |
var prev = li.prev();
|
| 377 |
var aboveOrNextItem;
|
| 387 |
}
|
| 388 |
// get id of above or below post
|
| 389 |
var aboveOrNextPostID = $(aboveOrNextItem).find("a:first").data("post-id");
|
| 390 |
+
|
| 391 |
// flytt upp = start > update
|
| 392 |
// flytt ner = start < update
|
| 393 |
var startindex = li.data("startindex");
|
| 398 |
} else {
|
| 399 |
direction = "down";
|
| 400 |
}
|
| 401 |
+
|
| 402 |
// now we have all we need, tell the server to do the move
|
| 403 |
$.post(ajaxurl, {
|
| 404 |
"action": "admin_menu_tree_page_view_move_page",
|
| 405 |
"post_to_update_id": post_id,
|
| 406 |
"direction": direction,
|
| 407 |
+
"aboveOrNextPostID": aboveOrNextPostID,
|
| 408 |
+
"amtpv-nonce": window.amtpv_l10n.nonce
|
| 409 |
}, function(data) {
|
| 410 |
// console.log(data);
|
| 411 |
});
|
| 412 |
+
|
| 413 |
}
|
| 414 |
});
|
| 415 |
|
readme.txt
CHANGED
|
@@ -4,7 +4,7 @@ Donate link: http://eskapism.se/sida/donate/
|
|
| 4 |
Tags: admin, page, pages, page tree, hierarchy, cms, tree, view, admin menu, menu, change order, drag and drop
|
| 5 |
Requires at least: 3.8
|
| 6 |
Tested up to: 4.7
|
| 7 |
-
Stable tag: 2.
|
| 8 |
|
| 9 |
Get a tree view of all your pages directly in the admin menu. Search, edit, view, re-order/sort and add pages – all is just one click away!
|
| 10 |
|
|
@@ -60,6 +60,9 @@ Now the tree with the pages will be visible in the admin menu to the left.
|
|
| 60 |
|
| 61 |
== Changelog ==
|
| 62 |
|
|
|
|
|
|
|
|
|
|
| 63 |
= 2.6.9 =
|
| 64 |
- Make hidden page not clickable. Fixes https://wordpress.org/support/topic/hide-the-page
|
| 65 |
- Load icons localy instead. Fixes https://wordpress.org/support/topic/styles-loading-icon-pngs-over-http-instead-of-https
|
| 4 |
Tags: admin, page, pages, page tree, hierarchy, cms, tree, view, admin menu, menu, change order, drag and drop
|
| 5 |
Requires at least: 3.8
|
| 6 |
Tested up to: 4.7
|
| 7 |
+
Stable tag: 2.7
|
| 8 |
|
| 9 |
Get a tree view of all your pages directly in the admin menu. Search, edit, view, re-order/sort and add pages – all is just one click away!
|
| 10 |
|
| 60 |
|
| 61 |
== Changelog ==
|
| 62 |
|
| 63 |
+
= 2.7 (January 2018) =
|
| 64 |
+
- Add nonce check when moving page and adding new pages.
|
| 65 |
+
|
| 66 |
= 2.6.9 =
|
| 67 |
- Make hidden page not clickable. Fixes https://wordpress.org/support/topic/hide-the-page
|
| 68 |
- Load icons localy instead. Fixes https://wordpress.org/support/topic/styles-loading-icon-pngs-over-http-instead-of-https
|
screenshot-1.png
DELETED
|
Binary file
|
screenshot-2.png
DELETED
|
Binary file
|
screenshot-3.png
DELETED
|
Binary file
|
