Version Description
- moved JS and CSS to own folders
- can now add multiple pages at once
- can now set the status of the created page(s)
Download this release
Release Info
Developer | eskapism |
Plugin | Admin Menu Tree Page View |
Version | 1.4 |
Comparing to | |
See all releases |
Code changes from version 1.3 to 1.4
- arrow-left.gif → css/arrow-left.gif +0 -0
- lock.png → css/lock.png +0 -0
- page-small-minus.gif → css/page-small-minus.gif +0 -0
- page-small-plus.gif → css/page-small-plus.gif +0 -0
- page-small.gif → css/page-small.gif +0 -0
- page_white_text.png → css/page_white_text.png +0 -0
- styles.css → css/styles.css +193 -8
- index.php +111 -50
- jquery.biscuit.js → js/jquery.biscuit.js +0 -0
- jquery.client.js → js/jquery.client.js +0 -0
- jquery.highlight.js → js/jquery.highlight.js +0 -0
- jquery.ui.nestedSortable.js → js/jquery.ui.nestedSortable.js +0 -0
- js/scripts.js +348 -0
- readme.txt +6 -1
- scripts.js +0 -323
arrow-left.gif → css/arrow-left.gif
RENAMED
File without changes
|
lock.png → css/lock.png
RENAMED
File without changes
|
page-small-minus.gif → css/page-small-minus.gif
RENAMED
File without changes
|
page-small-plus.gif → css/page-small-plus.gif
RENAMED
File without changes
|
page-small.gif → css/page-small.gif
RENAMED
File without changes
|
page_white_text.png → css/page_white_text.png
RENAMED
File without changes
|
styles.css → css/styles.css
RENAMED
@@ -8,6 +8,14 @@
|
|
8 |
#adminmenu li.wp-has-current-submenu ul.admin-menu-tree-page-tree {
|
9 |
border-bottom-width: 0;
|
10 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
li.toplevel_page_admin-menu-tree-page-tree_main .wp-first-item {
|
12 |
display: none;
|
13 |
}
|
@@ -44,8 +52,10 @@ li.toplevel_page_admin-menu-tree-page-tree_main .wp-submenu a {
|
|
44 |
}
|
45 |
#adminmenu li .wp-submenu ul.admin-menu-tree-page-tree li a:hover {
|
46 |
background-color: #eaf2fa !important;
|
47 |
-
|
|
|
48 |
border-top: 1px solid #ccc;
|
|
|
49 |
/* box-shadow: 2px 2px 2px #DDDDDD; */
|
50 |
}
|
51 |
|
@@ -80,7 +90,7 @@ li.toplevel_page_admin-menu-tree-page-tree_main .wp-submenu a {
|
|
80 |
}
|
81 |
|
82 |
#adminmenu li ul.admin-menu-tree-page-tree a:hover .admin-menu-tree-page-view-edit:hover {
|
83 |
-
|
84 |
}
|
85 |
|
86 |
#adminmenu li ul.admin-menu-tree-page-tree a .admin-menu-tree-page-view-view-link {
|
@@ -88,10 +98,10 @@ li.toplevel_page_admin-menu-tree-page-tree_main .wp-submenu a {
|
|
88 |
}
|
89 |
|
90 |
/* sublevels */
|
91 |
-
#adminmenu li .wp-submenu ul.admin-menu-tree-page-tree li.admin-menu-tree-page-view-opened > div > a {
|
92 |
background-image: url(page-small-minus.gif) !important;
|
93 |
}
|
94 |
-
#adminmenu li .wp-submenu ul.admin-menu-tree-page-tree li.admin-menu-tree-page-view-closed > div > a {
|
95 |
background-image: url(page-small-plus.gif) !important;
|
96 |
}
|
97 |
|
@@ -342,16 +352,26 @@ ul.admin-menu-tree-page-tree span.child-count {
|
|
342 |
}
|
343 |
.amtpv-editpopup-hover:hover {
|
344 |
/* i know... hover hover! in sweden we call that "kaka på kaka" */
|
345 |
-
opacity: 1;
|
346 |
}
|
347 |
.amtpv-editpopup-editview,
|
348 |
.amtpv-editpopup-add
|
349 |
{
|
350 |
-
display: block;
|
|
|
351 |
}
|
352 |
.amtpv-editpopup-editview {
|
353 |
-
margin-bottom:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
354 |
}
|
|
|
355 |
/* "links" */
|
356 |
.amtpv-editpopup-edit,
|
357 |
.amtpv-editpopup-view,
|
@@ -368,6 +388,171 @@ ul.admin-menu-tree-page-tree span.child-count {
|
|
368 |
color: #D54E21;
|
369 |
}
|
370 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
371 |
.ui-nestedSortable-error {
|
372 |
border: 1px solid red;
|
373 |
-
}
|
8 |
#adminmenu li.wp-has-current-submenu ul.admin-menu-tree-page-tree {
|
9 |
border-bottom-width: 0;
|
10 |
}
|
11 |
+
|
12 |
+
/*
|
13 |
+
This works, but will break something?
|
14 |
+
#adminmenu * {
|
15 |
+
-moz-user-select: text !important;
|
16 |
+
}
|
17 |
+
*/
|
18 |
+
|
19 |
li.toplevel_page_admin-menu-tree-page-tree_main .wp-first-item {
|
20 |
display: none;
|
21 |
}
|
52 |
}
|
53 |
#adminmenu li .wp-submenu ul.admin-menu-tree-page-tree li a:hover {
|
54 |
background-color: #eaf2fa !important;
|
55 |
+
/*
|
56 |
+
border-bottom: 1px solid #ccc;
|
57 |
border-top: 1px solid #ccc;
|
58 |
+
*/
|
59 |
/* box-shadow: 2px 2px 2px #DDDDDD; */
|
60 |
}
|
61 |
|
90 |
}
|
91 |
|
92 |
#adminmenu li ul.admin-menu-tree-page-tree a:hover .admin-menu-tree-page-view-edit:hover {
|
93 |
+
/* background-image: url(http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.3/themes/ui-darkness/images/ui-icons_222222_256x240.png); */
|
94 |
}
|
95 |
|
96 |
#adminmenu li ul.admin-menu-tree-page-tree a .admin-menu-tree-page-view-view-link {
|
98 |
}
|
99 |
|
100 |
/* sublevels */
|
101 |
+
#adminmenu li .wp-submenu ul.admin-menu-tree-page-tree li.admin-menu-tree-page-view-opened > div > div > a {
|
102 |
background-image: url(page-small-minus.gif) !important;
|
103 |
}
|
104 |
+
#adminmenu li .wp-submenu ul.admin-menu-tree-page-tree li.admin-menu-tree-page-view-closed > div > div > a {
|
105 |
background-image: url(page-small-plus.gif) !important;
|
106 |
}
|
107 |
|
352 |
}
|
353 |
.amtpv-editpopup-hover:hover {
|
354 |
/* i know... hover hover! in sweden we call that "kaka på kaka" */
|
355 |
+
/* opacity: 1; */
|
356 |
}
|
357 |
.amtpv-editpopup-editview,
|
358 |
.amtpv-editpopup-add
|
359 |
{
|
360 |
+
/* display: block; */
|
361 |
+
/* display: inline; */
|
362 |
}
|
363 |
.amtpv-editpopup-editview {
|
364 |
+
margin-bottom: 10px;
|
365 |
+
}
|
366 |
+
|
367 |
+
.amtpv-editpopup-edit,
|
368 |
+
.amtpv-editpopup-view,
|
369 |
+
.amtpv-editpopup-add-after,
|
370 |
+
.amtpv-editpopup-add-inside
|
371 |
+
{
|
372 |
+
display: inline;
|
373 |
}
|
374 |
+
|
375 |
/* "links" */
|
376 |
.amtpv-editpopup-edit,
|
377 |
.amtpv-editpopup-view,
|
388 |
color: #D54E21;
|
389 |
}
|
390 |
|
391 |
+
.amtpv-editpopup-postid {
|
392 |
+
position: absolute;
|
393 |
+
top: 10px;
|
394 |
+
right: 10px;
|
395 |
+
color: #888;
|
396 |
+
}
|
397 |
+
|
398 |
+
.amtpv-editpopup-addpages {
|
399 |
+
display: block;
|
400 |
+
}
|
401 |
+
.amtpv-editpopup-addpages-addpage {
|
402 |
+
display: block;
|
403 |
+
/*
|
404 |
+
text-decoration: underline;
|
405 |
+
color: #21759B;
|
406 |
+
cursor: pointer;
|
407 |
+
*/
|
408 |
+
margin-left: 3px;
|
409 |
+
|
410 |
+
/* text-align: right; */
|
411 |
+
}
|
412 |
+
#adminmenu li ul.admin-menu-tree-page-tree li .amtpv-editpopup-addpages-addpage a:link,
|
413 |
+
#adminmenu li ul.admin-menu-tree-page-tree li .amtpv-editpopup-addpages-addpage a:visited,
|
414 |
+
#adminmenu li ul.admin-menu-tree-page-tree li .amtpv-editpopup-addpages-addpage a:hover,
|
415 |
+
#adminmenu li ul.admin-menu-tree-page-tree li .amtpv-editpopup-addpages-addpage a:active
|
416 |
+
{
|
417 |
+
font-size: 12px;
|
418 |
+
color: #21759B;
|
419 |
+
padding: 0 !important;
|
420 |
+
margin: 0;
|
421 |
+
background-image: none !important;
|
422 |
+
font-weight: normal !important;
|
423 |
+
}
|
424 |
+
#adminmenu li ul.admin-menu-tree-page-tree li .amtpv-editpopup-addpages-addpage a:hover,
|
425 |
+
#adminmenu li ul.admin-menu-tree-page-tree li .amtpv-editpopup-addpages-addpage a:active,
|
426 |
+
#adminmenu li ul.admin-menu-tree-page-tree li .amtpv-editpopup-addpages-addpage a:focus
|
427 |
+
{
|
428 |
+
color: #D54E21 !important;
|
429 |
+
}
|
430 |
+
#adminmenu li ul.admin-menu-tree-page-tree li .amtpv-editpopup-addpages-addpage a:focus {
|
431 |
+
outline: invert none medium;
|
432 |
+
}
|
433 |
+
|
434 |
+
.amtpv-editpopup-addpages-addpage:hover {
|
435 |
+
/* color: #D54E21; */
|
436 |
+
}
|
437 |
+
#adminmenu li .wp-submenu ul.admin-menu-tree-page-tree li div > a.amtpv-editpopup-addpages-cancel:link,
|
438 |
+
#adminmenu li .wp-submenu ul.admin-menu-tree-page-tree li div > a.amtpv-editpopup-addpages-cancel:visited,
|
439 |
+
#adminmenu li .wp-submenu ul.admin-menu-tree-page-tree li div > a.amtpv-editpopup-addpages-cancel:hover,
|
440 |
+
#adminmenu li .wp-submenu ul.admin-menu-tree-page-tree li div > a.amtpv-editpopup-addpages-cancel:active
|
441 |
+
{
|
442 |
+
text-decoration: none;
|
443 |
+
color: #21759B;
|
444 |
+
cursor: pointer;
|
445 |
+
background-image: none !important;
|
446 |
+
margin: 0;
|
447 |
+
padding: 0;
|
448 |
+
display: inline;
|
449 |
+
font-size: 12px;
|
450 |
+
font-weight: normal !important;
|
451 |
+
}
|
452 |
+
#adminmenu li .wp-submenu ul.admin-menu-tree-page-tree li div > a.amtpv-editpopup-addpages-cancel:hover {
|
453 |
+
color: #D54E21 !important;
|
454 |
+
}
|
455 |
+
|
456 |
+
.amtpv-editpopup-addpages-label
|
457 |
+
{
|
458 |
+
display: block;
|
459 |
+
margin-top: 10px;
|
460 |
+
}
|
461 |
+
|
462 |
+
.amtpv-editpopup-addpages-name {
|
463 |
+
/* width: 200px; */
|
464 |
+
}
|
465 |
+
|
466 |
+
.amtpv-editpopup-addpages-publish {
|
467 |
+
margin-top: 10px;
|
468 |
+
margin-bottom: 10px;
|
469 |
+
}
|
470 |
+
#amtpv-editpopup-addpages-publish-select option {
|
471 |
+
padding: 0;
|
472 |
+
}
|
473 |
+
.amtpv-editpopup-addpages-publish-checkbox-wrap {
|
474 |
+
display: block;
|
475 |
+
margin-top: 10px;
|
476 |
+
margin-bottom: 10px;
|
477 |
+
}
|
478 |
+
#amtpv-editpopup-addpages-publish-checkbox {
|
479 |
+
margin-right: 4px;
|
480 |
+
}
|
481 |
+
|
482 |
+
|
483 |
+
.amtpv-editpopup-addpages-headline {
|
484 |
+
font-weight: bold;
|
485 |
+
}
|
486 |
+
|
487 |
+
|
488 |
+
.amtpv-linkwrap {
|
489 |
+
border-bottom: 1px solid transparent !important;
|
490 |
+
border-top: 1px solid transparent !important;
|
491 |
+
}
|
492 |
+
.amtpv-linkwrap-hover {
|
493 |
+
background-color: #EAF2FA;
|
494 |
+
border-bottom: 1px solid #ccc;
|
495 |
+
border-top: 1px solid #ccc;
|
496 |
+
}
|
497 |
+
.amtpv-editpopup-hover-hover {
|
498 |
+
opacity: .9;
|
499 |
+
}
|
500 |
+
|
501 |
+
.amtpv-editpopup-addpages-submit {
|
502 |
+
margin-top: 10px;
|
503 |
+
}
|
504 |
+
.amtpv-editpopup-addpages-submit input {
|
505 |
+
cursor: pointer;
|
506 |
+
}
|
507 |
+
|
508 |
+
.amtpv-editpopup-addpages-names label,
|
509 |
+
.amtpv-editpopup-addpages-publish label
|
510 |
+
{
|
511 |
+
display: block;
|
512 |
+
}
|
513 |
+
|
514 |
+
#adminmenu li .wp-submenu ul.admin-menu-tree-page-tree li ul.amtpv-editpopup-addpages-names-ul {
|
515 |
+
display: block;
|
516 |
+
overflow: auto;
|
517 |
+
background-color: transparent;
|
518 |
+
}
|
519 |
+
.amtpv-editpopup-addpages-names-ul li {
|
520 |
+
/* clear: both; */
|
521 |
+
float: left;
|
522 |
+
width: 100%;
|
523 |
+
-moz-user-select: text !important;
|
524 |
+
}
|
525 |
+
.amtpv-editpopup-addpages-names-ul span {
|
526 |
+
background: transparent url(https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.3/themes/ui-darkness/images/ui-icons_222222_256x240.png) no-repeat -3px -228px;
|
527 |
+
margin-top: 7px;
|
528 |
+
margin-right: 3px;
|
529 |
+
float: left;
|
530 |
+
width: 6px;
|
531 |
+
height: 10px;
|
532 |
+
}
|
533 |
+
.amtpv-editpopup-addpages-names-ul span:hover {
|
534 |
+
/* background-image: url(https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.3/themes/ui-darkness/images/ui-icons_222222_256x240.png); */
|
535 |
+
}
|
536 |
+
|
537 |
+
.amtpv-editpopup-addpages-names-ul input {
|
538 |
+
float: left;
|
539 |
+
width: 175px;
|
540 |
+
-moz-user-select: text !important;
|
541 |
+
}
|
542 |
+
|
543 |
+
.amtpv-editpopup-addpages-position {
|
544 |
+
margin-top: 10px;
|
545 |
+
margin-bottom: 10px;
|
546 |
+
}
|
547 |
+
|
548 |
+
.amtpv-editpopup-addpages-position label {
|
549 |
+
display: inline;
|
550 |
+
margin-left: 4px;
|
551 |
+
}
|
552 |
+
.amtpv-editpopup-addpages-position option {
|
553 |
+
padding: 0;
|
554 |
+
}
|
555 |
+
|
556 |
.ui-nestedSortable-error {
|
557 |
border: 1px solid red;
|
558 |
+
}
|
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: 1.
|
7 |
Author: Pär Thernström
|
8 |
Author URI: http://eskapism.se/
|
9 |
License: GPL2
|
@@ -32,15 +32,17 @@ add_action('wp_ajax_admin_menu_tree_page_view_add_page', 'admin_menu_tree_page_v
|
|
32 |
|
33 |
function admin_menu_tree_page_view_admin_init() {
|
34 |
|
35 |
-
define( "admin_menu_tree_page_view_VERSION", "1.
|
36 |
define( "admin_menu_tree_page_view_URL", WP_PLUGIN_URL . '/admin-menu-tree-page-view/' );
|
|
|
37 |
|
38 |
-
wp_enqueue_style("admin_menu_tree_page_view_styles", admin_menu_tree_page_view_URL . "styles.css", false, admin_menu_tree_page_view_VERSION);
|
39 |
-
wp_enqueue_script("jquery.highlight", admin_menu_tree_page_view_URL . "jquery.highlight.js", array("jquery"));
|
40 |
-
wp_enqueue_script("jquery-cookie", admin_menu_tree_page_view_URL . "jquery.biscuit.js", array("jquery")); // renamed from cookie to fix problems with mod_security
|
41 |
-
wp_enqueue_script("jquery.ui.nestedSortable", admin_menu_tree_page_view_URL . "jquery.ui.nestedSortable.js", array("jquery", "jquery-ui-sortable"));
|
42 |
-
wp_enqueue_script("jquery.client", admin_menu_tree_page_view_URL . "jquery.client.js", array("jquery"));
|
43 |
-
wp_enqueue_script("
|
|
|
44 |
|
45 |
$oLocale = array(
|
46 |
"Edit" => __("Edit", 'admin-menu-tree-page-view'),
|
@@ -141,6 +143,8 @@ function admin_menu_tree_page_view_get_pages($args) {
|
|
141 |
$output .= "<li class='$class'>";
|
142 |
// first div used for nestedSortable
|
143 |
$output .= "<div>";
|
|
|
|
|
144 |
$output .= "<a href='$edit_link' data-post-id='".$one_page->ID."'>$status_span";
|
145 |
$output .= $title;
|
146 |
|
@@ -149,27 +153,30 @@ function admin_menu_tree_page_view_get_pages($args) {
|
|
149 |
$output .= "<span class='admin-menu-tree-page-view-view-link'>$permalink</span>";
|
150 |
$output .= "<span class='admin-menu-tree-page-view-edit'></span>";
|
151 |
|
|
|
|
|
152 |
// popup edit div
|
153 |
$output .= "
|
154 |
-
<
|
155 |
-
<
|
156 |
-
<
|
157 |
|
|
158 |
-
<
|
159 |
-
</
|
160 |
-
<
|
161 |
-
<
|
162 |
|
|
163 |
-
<
|
164 |
-
</
|
165 |
-
|
|
|
166 |
";
|
167 |
|
168 |
-
|
169 |
-
|
170 |
-
// close div for nestedSortable
|
171 |
$output .= "</div>";
|
172 |
|
|
|
|
|
173 |
|
174 |
// add child articles
|
175 |
$output .= $str_child_output;
|
@@ -252,16 +259,23 @@ function admin_menu_tree_page_view_add_page() {
|
|
252 |
[pageID] => cms-tpv-1318
|
253 |
type
|
254 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
*/
|
256 |
$type = $_POST["type"];
|
257 |
$pageID = (int) $_POST["pageID"];
|
258 |
-
#$pageID = str_replace("cms-tpv-", "", $pageID);
|
259 |
-
$page_title = trim($_POST["page_title"]);
|
260 |
$post_type = $_POST["post_type"];
|
261 |
$wpml_lang = isset($_POST["wpml_lang"]) ? $_POST["wpml_lang"] : "";
|
262 |
-
|
263 |
-
|
264 |
$ref_post = get_post($pageID);
|
|
|
|
|
|
|
|
|
265 |
|
266 |
if ("after" == $type) {
|
267 |
|
@@ -269,44 +283,91 @@ function admin_menu_tree_page_view_add_page() {
|
|
269 |
add page under/below ref_post
|
270 |
*/
|
271 |
|
272 |
-
|
273 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
|
275 |
-
// create a new page and then goto it
|
276 |
-
$post_new = array();
|
277 |
-
$post_new["menu_order"] = $ref_post->menu_order+1;
|
278 |
-
$post_new["post_parent"] = $ref_post->post_parent;
|
279 |
-
$post_new["post_type"] = "page";
|
280 |
-
$post_new["post_status"] = "draft";
|
281 |
-
$post_new["post_title"] = $page_title;
|
282 |
-
$post_new["post_content"] = "";
|
283 |
-
$post_new["post_type"] = $post_type;
|
284 |
-
$newPostID = wp_insert_post($post_new);
|
285 |
|
286 |
} else if ( "inside" == $type ) {
|
287 |
|
288 |
/*
|
289 |
add page inside ref_post
|
290 |
*/
|
|
|
|
|
291 |
|
292 |
-
|
293 |
-
|
|
|
294 |
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
|
305 |
}
|
306 |
|
307 |
-
if ($
|
308 |
// return editlink for the newly created page
|
309 |
-
$editLink = get_edit_post_link($
|
310 |
if ($wpml_lang) {
|
311 |
$editLink = add_query_arg("lang", $wpml_lang, $editLink);
|
312 |
}
|
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: 1.4
|
7 |
Author: Pär Thernström
|
8 |
Author URI: http://eskapism.se/
|
9 |
License: GPL2
|
32 |
|
33 |
function admin_menu_tree_page_view_admin_init() {
|
34 |
|
35 |
+
define( "admin_menu_tree_page_view_VERSION", "1.4" );
|
36 |
define( "admin_menu_tree_page_view_URL", WP_PLUGIN_URL . '/admin-menu-tree-page-view/' );
|
37 |
+
define( "admin_menu_tree_page_view_DIR", WP_PLUGIN_DIR . '/admin-menu-tree-page-view/' );
|
38 |
|
39 |
+
wp_enqueue_style("admin_menu_tree_page_view_styles", admin_menu_tree_page_view_URL . "css/styles.css", false, admin_menu_tree_page_view_VERSION);
|
40 |
+
wp_enqueue_script("jquery.highlight", admin_menu_tree_page_view_URL . "js/jquery.highlight.js", array("jquery"));
|
41 |
+
wp_enqueue_script("jquery-cookie", admin_menu_tree_page_view_URL . "js/jquery.biscuit.js", array("jquery")); // renamed from cookie to fix problems with mod_security
|
42 |
+
wp_enqueue_script("jquery.ui.nestedSortable", admin_menu_tree_page_view_URL . "js/jquery.ui.nestedSortable.js", array("jquery", "jquery-ui-sortable"));
|
43 |
+
wp_enqueue_script("jquery.client", admin_menu_tree_page_view_URL . "js/jquery.client.js", array("jquery"));
|
44 |
+
wp_enqueue_script("jquery-ui-sortable");
|
45 |
+
wp_enqueue_script("admin_menu_tree_page_view", admin_menu_tree_page_view_URL . "js/scripts.js", array("jquery"));
|
46 |
|
47 |
$oLocale = array(
|
48 |
"Edit" => __("Edit", 'admin-menu-tree-page-view'),
|
143 |
$output .= "<li class='$class'>";
|
144 |
// first div used for nestedSortable
|
145 |
$output .= "<div>";
|
146 |
+
// div used to make hover work and to put edit-popup outside the <a>
|
147 |
+
$output .= "<div class='amtpv-linkwrap' data-post-id='".$one_page->ID."'>";
|
148 |
$output .= "<a href='$edit_link' data-post-id='".$one_page->ID."'>$status_span";
|
149 |
$output .= $title;
|
150 |
|
153 |
$output .= "<span class='admin-menu-tree-page-view-view-link'>$permalink</span>";
|
154 |
$output .= "<span class='admin-menu-tree-page-view-edit'></span>";
|
155 |
|
156 |
+
$output .= "</a>";
|
157 |
+
|
158 |
// popup edit div
|
159 |
$output .= "
|
160 |
+
<div class='amtpv-editpopup'>
|
161 |
+
<div class='amtpv-editpopup-editview'>
|
162 |
+
<div class='amtpv-editpopup-edit' data-link='".$edit_link."'>".__("Edit", 'admin-menu-tree-page-view')."</div>
|
163 |
|
|
164 |
+
<div class='amtpv-editpopup-view' data-link='".$permalink."'>".__("View", 'admin-menu-tree-page-view')."</div>
|
165 |
+
</div>
|
166 |
+
<div class='amtpv-editpopup-add'>".__("Add new page", 'admin-menu-tree-page-view')."<br />
|
167 |
+
<div class='amtpv-editpopup-add-after'>".__("After", 'admin-menu-tree-page-view')."</div>
|
168 |
|
|
169 |
+
<div class='amtpv-editpopup-add-inside'>".__("Inside", 'admin-menu-tree-page-view')."</div>
|
170 |
+
</div>
|
171 |
+
<div class='amtpv-editpopup-postid'>".__("Post ID:", 'admin-menu-tree-page-view')." " . $one_page->ID."</div>
|
172 |
+
</div>
|
173 |
";
|
174 |
|
175 |
+
// close div used to make hover work and to put edit-popup outside the <a>
|
|
|
|
|
176 |
$output .= "</div>";
|
177 |
|
178 |
+
// close div for nestedSortable
|
179 |
+
$output .= "</div>";
|
180 |
|
181 |
// add child articles
|
182 |
$output .= $str_child_output;
|
259 |
[pageID] => cms-tpv-1318
|
260 |
type
|
261 |
)
|
262 |
+
action admin_menu_tree_page_view_add_page
|
263 |
+
pageID 448
|
264 |
+
page_titles[] pending inside
|
265 |
+
post_status pending
|
266 |
+
post_type page
|
267 |
+
type inside
|
268 |
*/
|
269 |
$type = $_POST["type"];
|
270 |
$pageID = (int) $_POST["pageID"];
|
|
|
|
|
271 |
$post_type = $_POST["post_type"];
|
272 |
$wpml_lang = isset($_POST["wpml_lang"]) ? $_POST["wpml_lang"] : "";
|
273 |
+
$page_titles = (array) $_POST["page_titles"];
|
|
|
274 |
$ref_post = get_post($pageID);
|
275 |
+
$post_status = $_POST["post_status"];
|
276 |
+
if (!$post_status) { $post_status = "draft"; }
|
277 |
+
|
278 |
+
$post_id_to_return = NULL;
|
279 |
|
280 |
if ("after" == $type) {
|
281 |
|
283 |
add page under/below ref_post
|
284 |
*/
|
285 |
|
286 |
+
if (!function_exists("admin_menu_tree_page_view_add_page_after")) {
|
287 |
+
function admin_menu_tree_page_view_add_page_after($ref_post_id, $page_title, $post_type, $post_status = "draft") {
|
288 |
+
|
289 |
+
global $wpdb;
|
290 |
+
|
291 |
+
$ref_post = get_post($ref_post_id);
|
292 |
+
// update menu_order of all pages below our page
|
293 |
+
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET menu_order = menu_order+2 WHERE post_parent = %d AND menu_order >= %d AND id <> %d ", $ref_post->post_parent, $ref_post->menu_order, $ref_post->ID ) );
|
294 |
+
|
295 |
+
// create a new page and then goto it
|
296 |
+
$post_new = array();
|
297 |
+
$post_new["menu_order"] = $ref_post->menu_order+1;
|
298 |
+
$post_new["post_parent"] = $ref_post->post_parent;
|
299 |
+
$post_new["post_type"] = "page";
|
300 |
+
$post_new["post_status"] = $post_status;
|
301 |
+
$post_new["post_title"] = $page_title;
|
302 |
+
$post_new["post_content"] = "";
|
303 |
+
$post_new["post_type"] = $post_type;
|
304 |
+
$newPostID = wp_insert_post($post_new);
|
305 |
+
return $newPostID;
|
306 |
+
}
|
307 |
+
}
|
308 |
+
|
309 |
+
$ref_post_id = $ref_post->ID;
|
310 |
+
$loopNum = 0;
|
311 |
+
foreach ($page_titles as $one_page_title) {
|
312 |
+
$newPostID = admin_menu_tree_page_view_add_page_after($ref_post_id, $one_page_title, $post_type, $post_status);
|
313 |
+
$new_post = get_post($newPostID);
|
314 |
+
$ref_post_id = $new_post->ID;
|
315 |
+
if ($loopNum == 0) {
|
316 |
+
$post_id_to_return = $newPostID;
|
317 |
+
}
|
318 |
+
$loopNum++;
|
319 |
+
}
|
320 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
321 |
|
322 |
} else if ( "inside" == $type ) {
|
323 |
|
324 |
/*
|
325 |
add page inside ref_post
|
326 |
*/
|
327 |
+
if (!function_exists("admin_menu_tree_page_view_add_page_inside")) {
|
328 |
+
function admin_menu_tree_page_view_add_page_inside($ref_post_id, $page_title, $post_type, $post_status = "draft") {
|
329 |
|
330 |
+
global $wpdb;
|
331 |
+
|
332 |
+
$ref_post = get_post($ref_post_id);
|
333 |
|
334 |
+
// update menu_order, so our new post is the only one with order 0
|
335 |
+
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET menu_order = menu_order+1 WHERE post_parent = %d", $ref_post->ID) );
|
336 |
+
|
337 |
+
$post_new = array();
|
338 |
+
$post_new["menu_order"] = 0;
|
339 |
+
$post_new["post_parent"] = $ref_post->ID;
|
340 |
+
$post_new["post_type"] = "page";
|
341 |
+
$post_new["post_status"] = $post_status;
|
342 |
+
$post_new["post_title"] = $page_title;
|
343 |
+
$post_new["post_content"] = "";
|
344 |
+
$post_new["post_type"] = $post_type;
|
345 |
+
$newPostID = wp_insert_post($post_new);
|
346 |
+
return $newPostID;
|
347 |
+
|
348 |
+
}
|
349 |
+
}
|
350 |
+
|
351 |
+
// add reversed
|
352 |
+
$ref_post_id = $ref_post->ID;
|
353 |
+
$page_titles = array_reverse($page_titles);
|
354 |
+
$loopNum = 0;
|
355 |
+
foreach ($page_titles as $one_page_title) {
|
356 |
+
$newPostID = admin_menu_tree_page_view_add_page_inside($ref_post_id, $one_page_title, $post_type, $post_status);
|
357 |
+
$new_post = get_post($newPostID);
|
358 |
+
// $ref_post_id = $new_post->ID;
|
359 |
+
if ($loopNum == 0) {
|
360 |
+
$post_id_to_return = $newPostID;
|
361 |
+
}
|
362 |
+
$loopNum++;
|
363 |
+
}
|
364 |
+
$post_id_to_return = $newPostID;
|
365 |
|
366 |
}
|
367 |
|
368 |
+
if ($post_id_to_return) {
|
369 |
// return editlink for the newly created page
|
370 |
+
$editLink = get_edit_post_link($post_id_to_return, '');
|
371 |
if ($wpml_lang) {
|
372 |
$editLink = add_query_arg("lang", $wpml_lang, $editLink);
|
373 |
}
|
jquery.biscuit.js → js/jquery.biscuit.js
RENAMED
File without changes
|
jquery.client.js → js/jquery.client.js
RENAMED
File without changes
|
jquery.highlight.js → js/jquery.highlight.js
RENAMED
File without changes
|
jquery.ui.nestedSortable.js → js/jquery.ui.nestedSortable.js
RENAMED
File without changes
|
js/scripts.js
ADDED
@@ -0,0 +1,348 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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");
|
12 |
+
ul.find("li").hide();
|
13 |
+
ul.find("li.admin-menu-tree-page-tree_headline,li.admin-menu-tree-page-filter").show();
|
14 |
+
var s = $(this).val();
|
15 |
+
var selector = "li:AminMenuTreePageContains('"+s+"')";
|
16 |
+
var hits = ul.find(selector);
|
17 |
+
if (hits.length > 0 || s != "") {
|
18 |
+
ul.find("div.admin-menu-tree-page-filter-reset").fadeIn("fast");
|
19 |
+
ul.unhighlight();
|
20 |
+
}
|
21 |
+
if (s == "") {
|
22 |
+
ul.find("div.admin-menu-tree-page-filter-reset").fadeOut("fast");
|
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;
|
30 |
+
if (parent) {
|
31 |
+
parent = $(parent);
|
32 |
+
// ul -> div -> ul
|
33 |
+
parent.parent().parent().addClass("admin-menu-tree-page-view-opened").removeClass("admin-menu-tree-page-view-closed");
|
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) {
|
41 |
+
nohits_div.show();
|
42 |
+
} else {
|
43 |
+
nohits_div.hide();
|
44 |
+
}
|
45 |
+
|
46 |
+
});
|
47 |
+
|
48 |
+
// clear/reset filter and show all pages again
|
49 |
+
$("div.admin-menu-tree-page-filter-reset").click(function() {
|
50 |
+
var $t = $(this);
|
51 |
+
var ul = $t.closest("ul.admin-menu-tree-page-tree");
|
52 |
+
ul.find("li").fadeIn("fast");
|
53 |
+
$t.fadeOut("fast");
|
54 |
+
$t.closest("li.admin-menu-tree-page-filter").find("input").val("").focus();
|
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);
|
62 |
+
$t.closest("li.admin-menu-tree-page-filter").find("label").hide();
|
63 |
+
$t.closest("li.admin-menu-tree-page-filter").find("input").focus();
|
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.find("div.admin-menu-tree-page-expand").live("click", 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");
|
87 |
+
});
|
88 |
+
isOpen = true;
|
89 |
+
}
|
90 |
+
|
91 |
+
var post_id = $a.attr("href").match(/\?post=([\d]+)/)[1];
|
92 |
+
var array_pos = $.inArray(post_id, admin_menu_tree_page_view_opened_posts);
|
93 |
+
if (array_pos > -1) {
|
94 |
+
// did exist in cookie
|
95 |
+
admin_menu_tree_page_view_opened_posts = admin_menu_tree_page_view_opened_posts.splice(array_pos+1, 1);
|
96 |
+
}
|
97 |
+
// array now has not our post_id. so add it if visible/open
|
98 |
+
if (isOpen) {
|
99 |
+
admin_menu_tree_page_view_opened_posts.push(post_id);
|
100 |
+
}
|
101 |
+
|
102 |
+
admin_menu_tree_page_view_save_opened_posts();
|
103 |
+
|
104 |
+
});
|
105 |
+
|
106 |
+
|
107 |
+
// mouse over to show edit-box
|
108 |
+
$("ul.admin-menu-tree-page-tree li div.amtpv-linkwrap:first-child").live("mouseenter mouseleave", function(e) {
|
109 |
+
|
110 |
+
var t = $(this);
|
111 |
+
var li = t.closest("li");
|
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");
|
119 |
+
|
120 |
+
// don't show if another one is in edit mode
|
121 |
+
if (ul.find("div.amtpv-editpopup-is-working").length > 0) {
|
122 |
+
} else {
|
123 |
+
ul.find("div.amtpv-editpopup").removeClass("amtpv-editpopup-hover");
|
124 |
+
ul.find("div.amtpv-linkwrap").removeClass("amtpv-linkwrap-hover");
|
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
|
132 |
+
var do_hide = true;
|
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 |
+
$("div.amtpv-editpopup").live("mouseenter mouseleave", function(e) {
|
150 |
+
var t = $(this);
|
151 |
+
var li = t.closest("li");
|
152 |
+
var popupdiv = li.find("div.amtpv-editpopup:first");
|
153 |
+
var linkwrap = li.find("div.amtpv-linkwrap:first")
|
154 |
+
|
155 |
+
if (e.type == "mouseenter" || e.type == "mouseover") {
|
156 |
+
t.addClass("amtpv-editpopup-hover-hover");
|
157 |
+
} else if (e.type == "mouseleave" || e.type == "mouseout") {
|
158 |
+
if (linkwrap.hasClass("amtpv-editpopup-is-working")) {
|
159 |
+
} else {
|
160 |
+
t.removeClass("amtpv-editpopup-hover-hover");
|
161 |
+
}
|
162 |
+
}
|
163 |
+
});
|
164 |
+
|
165 |
+
// don't allow clicks directly on .amtpv-editpopup. it's kinda confusing
|
166 |
+
$("div.amtpv-editpopup").live("click", function(e) {
|
167 |
+
//e.preventDefault();
|
168 |
+
});
|
169 |
+
|
170 |
+
// edit/view links
|
171 |
+
$("div.amtpv-editpopup-edit, div.amtpv-editpopup-view").live("click",function(e) {
|
172 |
+
e.preventDefault();
|
173 |
+
var t = $(this);
|
174 |
+
var link = t.data("link");
|
175 |
+
var new_win = false;
|
176 |
+
|
177 |
+
if ( ($.client.os == "Mac" && (e.metaKey || e.shiftKey)) || ($.client.os != "Mac" && e.ctrlKey) ) {
|
178 |
+
new_win = true;
|
179 |
+
}
|
180 |
+
if (new_win) {
|
181 |
+
window.open(link);
|
182 |
+
} else {
|
183 |
+
document.location = link;
|
184 |
+
}
|
185 |
+
|
186 |
+
});
|
187 |
+
|
188 |
+
// add links
|
189 |
+
$("div.amtpv-editpopup-add-after, div.amtpv-editpopup-add-inside").live("click", function(e) {
|
190 |
+
|
191 |
+
var t = $(this);
|
192 |
+
var post_id = t.closest("a").data("post-id");
|
193 |
+
var popup = t.closest("div.amtpv-editpopup");
|
194 |
+
var popup_linkwrap = popup.closest("div.amtpv-linkwrap");
|
195 |
+
var editpopup_add = popup.find("div.amtpv-editpopup-add");
|
196 |
+
var editpopup_editview = popup.find("div.amtpv-editpopup-editview");
|
197 |
+
|
198 |
+
// hide all divs
|
199 |
+
// @todo: should put all in one div, and hide just that one
|
200 |
+
popup.find("> div").hide();
|
201 |
+
|
202 |
+
// add class that tell us that we are in "adding-mode"/"working-mode"
|
203 |
+
popup_linkwrap.addClass("amtpv-editpopup-is-working");
|
204 |
+
|
205 |
+
var type = "after";
|
206 |
+
if (t.hasClass("amtpv-editpopup-add-inside")) {
|
207 |
+
type = "inside";
|
208 |
+
}
|
209 |
+
|
210 |
+
// remove possibly previous added add-stuff
|
211 |
+
popup.find("form.amtpv-editpopup-addpages").remove();
|
212 |
+
|
213 |
+
var add_pages = $("<form />")
|
214 |
+
.addClass("amtpv-editpopup-addpages")
|
215 |
+
.insertAfter(editpopup_add)
|
216 |
+
;
|
217 |
+
add_pages.append( "<div class='amtpv-editpopup-addpages-headline'>Add new page(s)</div>" );
|
218 |
+
add_pages.append( $("<input type='hidden' class='amtpv-editpopup-addpages-type' value='"+type+"' />") );
|
219 |
+
|
220 |
+
// var type = popup.find(".amtpv-editpopup-addpages-type").val();
|
221 |
+
if (type=="after") {
|
222 |
+
add_pages.append( $("<div class='amtpv-editpopup-addpages-position'><input checked='checked' type='radio' name='amtpv-editpopup-addpages-position' id='amtpv-editpopup-addpages-position-after' value='after' /><label for='amtpv-editpopup-addpages-position-after'>After</label> <input type='radio' name='amtpv-editpopup-addpages-position' id='amtpv-editpopup-addpages-position-inside' value='inside' /><label for='amtpv-editpopup-addpages-position-inside'>Inside</label> </div") );
|
223 |
+
} else if (type=="inside") {
|
224 |
+
add_pages.append( $("<div class='amtpv-editpopup-addpages-position'><input type='radio' name='amtpv-editpopup-addpages-position' id='amtpv-editpopup-addpages-position-after' value='after' /><label for='amtpv-editpopup-addpages-position-after'>After</label> <input checked='checked' type='radio' name='amtpv-editpopup-addpages-position' id='amtpv-editpopup-addpages-position-inside' value='inside' /><label for='amtpv-editpopup-addpages-position-inside'>Inside</label> </div") );
|
225 |
+
}
|
226 |
+
|
227 |
+
add_pages.append( $("<div class='amtpv-editpopup-addpages-publish'><label for='amtpv-editpopup-addpages-publish-select'>Status</label><select id='amtpv-editpopup-addpages-publish-select' name='status'><option value='publish'>Published</option><option value='pending'>Pending Review</option><option value='draft' selected='selected'>Draft</option></select></div") );
|
228 |
+
|
229 |
+
add_pages.append( $("<div class='amtpv-editpopup-addpages-names'><label class='amtpv-editpopup-addpages-label'>Name(s)</label>") );
|
230 |
+
add_pages.append( $("<ul class='amtpv-editpopup-addpages-names-ul'><li><span></span><input class='amtpv-editpopup-addpages-name' type='text' value=''/></li></ul>") );
|
231 |
+
add_pages.append( $("<div class='amtpv-editpopup-addpages-addpage'><a href='#'>+ page</a></div></div>"));
|
232 |
+
|
233 |
+
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>"));
|
234 |
+
add_pages.find(".amtpv-editpopup-addpages-name").focus();
|
235 |
+
|
236 |
+
add_pages.find("ul.amtpv-editpopup-addpages-names-ul").sortable({
|
237 |
+
"axis": "y",
|
238 |
+
"containment": 'parent',
|
239 |
+
"forceHelperSize": true,
|
240 |
+
"forcePlaceholderSize": true,
|
241 |
+
"handle": "span:first",
|
242 |
+
"cursor": "move"
|
243 |
+
});
|
244 |
+
|
245 |
+
return;
|
246 |
+
|
247 |
+
});
|
248 |
+
|
249 |
+
// add new page-link
|
250 |
+
$("div.amtpv-editpopup-addpages-addpage a").live("click", function(e) {
|
251 |
+
e.preventDefault();
|
252 |
+
var t = $(this);
|
253 |
+
var newelm = $("<li><span></span><input class='amtpv-editpopup-addpages-name' type='text' value=''/></li>");
|
254 |
+
t.parent().prev("ul.amtpv-editpopup-addpages-names-ul").append( newelm );
|
255 |
+
newelm.find("input").focus();
|
256 |
+
});
|
257 |
+
|
258 |
+
// cancel-link
|
259 |
+
$("a.amtpv-editpopup-addpages-cancel").live("click", function() {
|
260 |
+
var t = $(this);
|
261 |
+
var popup = t.closest("div.amtpv-editpopup");
|
262 |
+
var linkwrap = popup.closest("div.amtpv-linkwrap");
|
263 |
+
|
264 |
+
popup.find(".amtpv-editpopup-addpages").hide().remove();
|
265 |
+
popup.find("> div").show();
|
266 |
+
|
267 |
+
linkwrap.removeClass("amtpv-editpopup-is-working");
|
268 |
+
});
|
269 |
+
|
270 |
+
// woho, add da pages!
|
271 |
+
$("form.amtpv-editpopup-addpages").live("submit", function(e) {
|
272 |
+
// fetch all .amtpv-editpopup-addpages-name for this popup
|
273 |
+
|
274 |
+
e.preventDefault();
|
275 |
+
|
276 |
+
var t = $(this);
|
277 |
+
var post_id = t.closest("div.amtpv-linkwrap").data("post-id");
|
278 |
+
var popup = t.closest("div.amtpv-editpopup");
|
279 |
+
var names = popup.find(".amtpv-editpopup-addpages-name");
|
280 |
+
|
281 |
+
var arr_names = [];
|
282 |
+
names.each(function(i, elm) {
|
283 |
+
var name = $.trim($(elm).val());
|
284 |
+
if (name) {
|
285 |
+
arr_names.push( $(elm).val() );
|
286 |
+
}
|
287 |
+
});
|
288 |
+
|
289 |
+
// we must at least have one name
|
290 |
+
// @todo: make this a bit better looking
|
291 |
+
if (arr_names.length == 0) {
|
292 |
+
alert("Please enter a name for the new page");
|
293 |
+
return false;
|
294 |
+
}
|
295 |
+
|
296 |
+
popup.find("div.amtpv-editpopup-addpages-submit input").val("Adding...");
|
297 |
+
|
298 |
+
// detect after or inside
|
299 |
+
// var type = popup.find(".amtpv-editpopup-addpages-type").val();
|
300 |
+
var type = popup.find("input[name=amtpv-editpopup-addpages-position]:checked").val();
|
301 |
+
|
302 |
+
// post status
|
303 |
+
var post_status = popup.find("#amtpv-editpopup-addpages-publish-select").val();
|
304 |
+
|
305 |
+
var data = {
|
306 |
+
"action": 'admin_menu_tree_page_view_add_page',
|
307 |
+
"pageID": post_id,
|
308 |
+
"type": type,
|
309 |
+
"page_titles": arr_names,
|
310 |
+
"post_type": "page",
|
311 |
+
"post_status": post_status
|
312 |
+
};
|
313 |
+
|
314 |
+
jQuery.post(ajaxurl, data, function(response) {
|
315 |
+
if (response != "0") {
|
316 |
+
var new_win = false;
|
317 |
+
//if ( ($.client.os == "Mac" && (e.metaKey || e.shiftKey)) || ($.client.os != "Mac" && e.ctrlKey) ) {
|
318 |
+
// new_win = true;
|
319 |
+
//}
|
320 |
+
//return;
|
321 |
+
if (new_win) {
|
322 |
+
window.open(response);
|
323 |
+
} else {
|
324 |
+
document.location = response;
|
325 |
+
}
|
326 |
+
|
327 |
+
}
|
328 |
+
});
|
329 |
+
|
330 |
+
});
|
331 |
+
|
332 |
+
});
|
333 |
+
|
334 |
+
function admin_menu_tree_page_view_save_opened_posts() {
|
335 |
+
jQuery.cookie('admin-menu-tree-page-view-open-posts', admin_menu_tree_page_view_opened_posts.join(","));
|
336 |
+
}
|
337 |
+
|
338 |
+
// array with all post ids that are open
|
339 |
+
var admin_menu_tree_page_view_opened_posts = jQuery.cookie('admin-menu-tree-page-view-open-posts') || "";
|
340 |
+
admin_menu_tree_page_view_opened_posts = admin_menu_tree_page_view_opened_posts.split(",");
|
341 |
+
if (admin_menu_tree_page_view_opened_posts[0] == "") {
|
342 |
+
// admin_menu_tree_page_view_opened_posts = [];
|
343 |
+
}
|
344 |
+
|
345 |
+
// http://stackoverflow.com/questions/187537/is-there-a-case-insensitive-jquery-contains-selector
|
346 |
+
jQuery.expr[':'].AminMenuTreePageContains = function(a,i,m){
|
347 |
+
return (a.textContent || a.innerText || "").toLowerCase().indexOf(m[3].toLowerCase())>=0;
|
348 |
+
};
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://eskapism.se/sida/donate/
|
|
4 |
Tags: admin, page, pages, tree, view, admin menu, menu
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.0
|
7 |
-
Stable tag: 1.
|
8 |
|
9 |
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!
|
10 |
|
@@ -40,6 +40,11 @@ Now the tree with the pages will be visible in the admin menu to the left.
|
|
40 |
|
41 |
== Changelog ==
|
42 |
|
|
|
|
|
|
|
|
|
|
|
43 |
= 1.3 =
|
44 |
- An ul that was opened because of a search did not get the minus-sign
|
45 |
- New "popup" with actions when hovering a page. No more clicking to get to the actions. I really like it!
|
4 |
Tags: admin, page, pages, tree, view, admin menu, menu
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.0
|
7 |
+
Stable tag: 1.4
|
8 |
|
9 |
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!
|
10 |
|
40 |
|
41 |
== Changelog ==
|
42 |
|
43 |
+
= 1.4 =
|
44 |
+
- moved JS and CSS to own folders
|
45 |
+
- can now add multiple pages at once
|
46 |
+
- can now set the status of the created page(s)
|
47 |
+
|
48 |
= 1.3 =
|
49 |
- An ul that was opened because of a search did not get the minus-sign
|
50 |
- New "popup" with actions when hovering a page. No more clicking to get to the actions. I really like it!
|
scripts.js
DELETED
@@ -1,323 +0,0 @@
|
|
1 |
-
|
2 |
-
jQuery(function($) {
|
3 |
-
|
4 |
-
setTimeout(function() {
|
5 |
-
jQuery("#toplevel_page_admin-menu-tree-page-tree_main").addClass("wp-menu-open");
|
6 |
-
}, 100);
|
7 |
-
|
8 |
-
// show menu when menu icon is clicked
|
9 |
-
jQuery("span.admin-menu-tree-page-view-edit").click(function() {
|
10 |
-
|
11 |
-
var $this = $(this);
|
12 |
-
|
13 |
-
// check if this tree has a menu div defined
|
14 |
-
var wpsubmenu = $(this).closest("div.wp-submenu");
|
15 |
-
if (wpsubmenu.length == 1) {
|
16 |
-
|
17 |
-
var div_popup = wpsubmenu.find("div.admin-menu-tree-page-view-popup");
|
18 |
-
var do_show = true;
|
19 |
-
if (div_popup.length == 0) {
|
20 |
-
// no menu div yet, create it
|
21 |
-
var html = "";
|
22 |
-
html += "<div class='admin-menu-tree-page-view-popup'><span class='admin-menu-tree-page-view-popup-arrow'></span><span class='admin-menu-tree-page-view-popup-page'></span>";
|
23 |
-
html += "<ul>";
|
24 |
-
html += "<li class='admin-menu-tree-page-view-popup-edit'><a href=''>"+amtpv_l10n.Edit+"</a></li>";
|
25 |
-
html += "<li class='admin-menu-tree-page-view-popup-view'><a href=''>"+amtpv_l10n.View+"</a></li>";
|
26 |
-
html += "<li class='admin-menu-tree-page-view-popup-add-here'><a href=''>"+amtpv_l10n.Add_new_page_here+"</a></li>";
|
27 |
-
html += "<li class='admin-menu-tree-page-view-popup-add-inside'><a href=''>"+amtpv_l10n.Add_new_page_inside+"</a></li>";
|
28 |
-
html += "</ul></div>";
|
29 |
-
var div_popup = $(html).appendTo(wpsubmenu);
|
30 |
-
div_popup.show(); // must do this..
|
31 |
-
div_popup.hide(); // ..or fade does not work first time
|
32 |
-
} else {
|
33 |
-
if (div_popup.is(":visible")) {
|
34 |
-
//do_show = false;
|
35 |
-
}
|
36 |
-
}
|
37 |
-
|
38 |
-
var a = $this.closest("a");
|
39 |
-
var link_text = a.text();
|
40 |
-
if (div_popup.find("div.admin-menu-tree-page-view-popup-page").text() == link_text) {
|
41 |
-
do_show = false;
|
42 |
-
}
|
43 |
-
div_popup.find("div.admin-menu-tree-page-view-popup-page").text( link_text );
|
44 |
-
var offset = $this.offset();
|
45 |
-
offset.top = (offset.top-3);
|
46 |
-
offset.left = (offset.left-3);
|
47 |
-
|
48 |
-
// store post_id
|
49 |
-
var post_id = a.attr("href").match(/post=([\w]+)/);
|
50 |
-
post_id = post_id[1];
|
51 |
-
div_popup.data("admin-menu-tree-page-view-current-post-id", post_id);
|
52 |
-
|
53 |
-
// setup edit and view links
|
54 |
-
var edit_link = "post.php?post="+post_id+"&action=edit";
|
55 |
-
div_popup.find("div.admin-menu-tree-page-view-popup-edit a").attr("href", edit_link);
|
56 |
-
|
57 |
-
// view link, this is probably not such a safe way to this this. but let's try! :)
|
58 |
-
var view_link = $this.closest("li").find(".admin-menu-tree-page-view-view-link").text();
|
59 |
-
div_popup.find("div.admin-menu-tree-page-view-popup-view a").attr("href", view_link);
|
60 |
-
|
61 |
-
if (do_show) {
|
62 |
-
div_popup.fadeIn("fast");
|
63 |
-
} else {
|
64 |
-
// same popup, so close it
|
65 |
-
div_popup.fadeOut("fast");
|
66 |
-
div_popup.find("div.admin-menu-tree-page-view-popup-page").text("");
|
67 |
-
}
|
68 |
-
|
69 |
-
div_popup.offset( offset ); // must be last or position gets wrong somehow
|
70 |
-
|
71 |
-
}
|
72 |
-
|
73 |
-
return false;
|
74 |
-
});
|
75 |
-
|
76 |
-
// hide menu
|
77 |
-
$("span.admin-menu-tree-page-view-popup-arrow").live("click", function() {
|
78 |
-
$(this).closest("div.admin-menu-tree-page-view-popup").fadeOut("fast");
|
79 |
-
return false;
|
80 |
-
});
|
81 |
-
|
82 |
-
// add page
|
83 |
-
$(".admin-menu-tree-page-view-popup-add-here, .admin-menu-tree-page-view-popup-add-inside").live("click", function() {
|
84 |
-
var div_popup = $(this).closest("div.admin-menu-tree-page-view-popup");
|
85 |
-
var post_id = div_popup.data("admin-menu-tree-page-view-current-post-id");
|
86 |
-
|
87 |
-
var type = "after";
|
88 |
-
if ($(this).hasClass("admin-menu-tree-page-view-popup-add-inside")) {
|
89 |
-
type = "inside";
|
90 |
-
}
|
91 |
-
|
92 |
-
var page_title = prompt("Enter name of new page", amtpv_l10n.Untitled);
|
93 |
-
if (page_title) {
|
94 |
-
|
95 |
-
var data = {
|
96 |
-
"action": 'admin_menu_tree_page_view_add_page',
|
97 |
-
"pageID": post_id,
|
98 |
-
"type": type,
|
99 |
-
"page_title": page_title,
|
100 |
-
"post_type": "page"
|
101 |
-
};
|
102 |
-
jQuery.post(ajaxurl, data, function(response) {
|
103 |
-
if (response != "0") {
|
104 |
-
document.location = response;
|
105 |
-
}
|
106 |
-
});
|
107 |
-
return false;
|
108 |
-
|
109 |
-
} else {
|
110 |
-
return false;
|
111 |
-
}
|
112 |
-
|
113 |
-
});
|
114 |
-
|
115 |
-
// search/filter pages
|
116 |
-
$("li.admin-menu-tree-page-filter input").keyup(function(e) {
|
117 |
-
var ul = $(this).closest("ul.admin-menu-tree-page-tree");
|
118 |
-
ul.find("li").hide();
|
119 |
-
ul.find("li.admin-menu-tree-page-tree_headline,li.admin-menu-tree-page-filter").show();
|
120 |
-
var s = $(this).val();
|
121 |
-
var selector = "li:AminMenuTreePageContains('"+s+"')";
|
122 |
-
var hits = ul.find(selector);
|
123 |
-
if (hits.length > 0 || s != "") {
|
124 |
-
ul.find("div.admin-menu-tree-page-filter-reset").fadeIn("fast");
|
125 |
-
ul.unhighlight();
|
126 |
-
}
|
127 |
-
if (s == "") {
|
128 |
-
ul.find("div.admin-menu-tree-page-filter-reset").fadeOut("fast");
|
129 |
-
}
|
130 |
-
ul.highlight(s);
|
131 |
-
hits.show();
|
132 |
-
|
133 |
-
// hits can be childs of hidden li:s, so we must show the parents of the hits too
|
134 |
-
hits.each(function(i, elm) {
|
135 |
-
var parent = elm.parentNode;
|
136 |
-
console.log(parent);
|
137 |
-
if (parent) {
|
138 |
-
parent = $(parent);
|
139 |
-
// ul -> div -> ul
|
140 |
-
parent.parent().parent().addClass("admin-menu-tree-page-view-opened").removeClass("admin-menu-tree-page-view-closed");
|
141 |
-
//console.log(parent.parent());
|
142 |
-
parent.show();
|
143 |
-
}
|
144 |
-
});
|
145 |
-
|
146 |
-
// if no hits: tell the user so we have less confusion. confusion is bad.
|
147 |
-
var nohits_div = ul.find("div.admin-menu-tree-page-filter-nohits");
|
148 |
-
if (hits.length == 0) {
|
149 |
-
nohits_div.show();
|
150 |
-
} else {
|
151 |
-
nohits_div.hide();
|
152 |
-
}
|
153 |
-
|
154 |
-
});
|
155 |
-
|
156 |
-
// clear/reset filter and show all pages again
|
157 |
-
$("div.admin-menu-tree-page-filter-reset").click(function() {
|
158 |
-
var $t = $(this);
|
159 |
-
var ul = $t.closest("ul.admin-menu-tree-page-tree");
|
160 |
-
ul.find("li").fadeIn("fast");
|
161 |
-
$t.fadeOut("fast");
|
162 |
-
$t.closest("li.admin-menu-tree-page-filter").find("input").val("").focus();
|
163 |
-
ul.unhighlight();
|
164 |
-
ul.find("div.admin-menu-tree-page-filter-nohits").hide();
|
165 |
-
});
|
166 |
-
|
167 |
-
// label = hide in and focus input
|
168 |
-
$("li.admin-menu-tree-page-filter label, li.admin-menu-tree-page-filter input").click(function() {
|
169 |
-
var $t = $(this);
|
170 |
-
$t.closest("li.admin-menu-tree-page-filter").find("label").hide();
|
171 |
-
$t.closest("li.admin-menu-tree-page-filter").find("input").focus();
|
172 |
-
});
|
173 |
-
|
174 |
-
var trees = jQuery("ul.admin-menu-tree-page-tree");
|
175 |
-
|
176 |
-
// add links to expand/collapse
|
177 |
-
trees.find("li.admin-menu-tree-page-view-has-childs > div").after("<div class='admin-menu-tree-page-expand' title='Show/Hide child pages' />");
|
178 |
-
trees.find("div.admin-menu-tree-page-expand").live("click", function(e) {
|
179 |
-
|
180 |
-
e.preventDefault();
|
181 |
-
var $t = $(this);
|
182 |
-
var $li = $t.closest("li");
|
183 |
-
var $a = $li.find("a:first");
|
184 |
-
var $ul = $li.find("ul:first");
|
185 |
-
|
186 |
-
var isOpen = false;
|
187 |
-
if ($ul.is(":visible")) {
|
188 |
-
$ul.slideUp(function() {
|
189 |
-
$li.addClass("admin-menu-tree-page-view-closed").removeClass("admin-menu-tree-page-view-opened");
|
190 |
-
});
|
191 |
-
|
192 |
-
} else {
|
193 |
-
$ul.slideDown(function() {
|
194 |
-
$li.addClass("admin-menu-tree-page-view-opened").removeClass("admin-menu-tree-page-view-closed");
|
195 |
-
});
|
196 |
-
isOpen = true;
|
197 |
-
}
|
198 |
-
|
199 |
-
var post_id = $a.attr("href").match(/\?post=([\d]+)/)[1];
|
200 |
-
var array_pos = $.inArray(post_id, admin_menu_tree_page_view_opened_posts);
|
201 |
-
if (array_pos > -1) {
|
202 |
-
// did exist in cookie
|
203 |
-
admin_menu_tree_page_view_opened_posts = admin_menu_tree_page_view_opened_posts.splice(array_pos+1, 1);
|
204 |
-
}
|
205 |
-
// array now has not our post_id. so add it if visible/open
|
206 |
-
if (isOpen) {
|
207 |
-
admin_menu_tree_page_view_opened_posts.push(post_id);
|
208 |
-
}
|
209 |
-
|
210 |
-
admin_menu_tree_page_view_save_opened_posts();
|
211 |
-
|
212 |
-
});
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
// mouse over to show edit-box
|
217 |
-
$("ul.admin-menu-tree-page-tree li a:first-child").live("mouseenter mouseleave", function(e) {
|
218 |
-
//console.log("e", e);
|
219 |
-
var t = $(this);
|
220 |
-
var li = t.closest("li");
|
221 |
-
//console.log("li", li);
|
222 |
-
var popupdiv = li.find("span.amtpv-editpopup:first");
|
223 |
-
if (e.type == "mouseenter") {
|
224 |
-
var ul = t.closest("ul.admin-menu-tree-page-tree");
|
225 |
-
ul.find("span.amtpv-editpopup").removeClass("amtpv-editpopup-hover");
|
226 |
-
popupdiv.addClass("amtpv-editpopup-hover");
|
227 |
-
} else if (e.type == "mouseleave") {
|
228 |
-
// don't hide if related target is the shadow of the menu, aka #adminmenushadow
|
229 |
-
var do_hide = true;
|
230 |
-
if (e.relatedTarget && e.relatedTarget.id == "adminmenushadow") {
|
231 |
-
do_hide = false;
|
232 |
-
}
|
233 |
-
if (do_hide) {
|
234 |
-
popupdiv.removeClass("amtpv-editpopup-hover");
|
235 |
-
}
|
236 |
-
|
237 |
-
}
|
238 |
-
});
|
239 |
-
|
240 |
-
// don't allow clicks directly on .amtpv-editpopup. it's kinda confusing
|
241 |
-
$("span.amtpv-editpopup").live("click", function(e) {
|
242 |
-
e.preventDefault();
|
243 |
-
});
|
244 |
-
|
245 |
-
// edit/view links
|
246 |
-
$("span.amtpv-editpopup-edit, span.amtpv-editpopup-view").live("click",function(e) {
|
247 |
-
e.preventDefault();
|
248 |
-
var t = $(this);
|
249 |
-
var link = t.data("link");
|
250 |
-
var new_win = false;
|
251 |
-
|
252 |
-
if ( ($.client.os == "Mac" && (e.metaKey || e.shiftKey)) || ($.client.os != "Mac" && e.ctrlKey) ) {
|
253 |
-
new_win = true;
|
254 |
-
}
|
255 |
-
if (new_win) {
|
256 |
-
window.open(link);
|
257 |
-
} else {
|
258 |
-
document.location = link;
|
259 |
-
}
|
260 |
-
|
261 |
-
});
|
262 |
-
|
263 |
-
// add links
|
264 |
-
$("span.amtpv-editpopup-add-after, span.amtpv-editpopup-add-inside").live("click", function(e) {
|
265 |
-
|
266 |
-
var t = $(this);
|
267 |
-
var post_id = t.closest("a").data("post-id");
|
268 |
-
|
269 |
-
var type = "after";
|
270 |
-
if ($(this).hasClass("amtpv-editpopup-add-inside")) {
|
271 |
-
type = "inside";
|
272 |
-
}
|
273 |
-
|
274 |
-
var page_title = prompt("Enter name of new page", amtpv_l10n.Untitled);
|
275 |
-
if (page_title) {
|
276 |
-
|
277 |
-
var data = {
|
278 |
-
"action": 'admin_menu_tree_page_view_add_page',
|
279 |
-
"pageID": post_id,
|
280 |
-
"type": type,
|
281 |
-
"page_title": page_title,
|
282 |
-
"post_type": "page"
|
283 |
-
};
|
284 |
-
jQuery.post(ajaxurl, data, function(response) {
|
285 |
-
if (response != "0") {
|
286 |
-
var new_win = false;
|
287 |
-
if ( ($.client.os == "Mac" && (e.metaKey || e.shiftKey)) || ($.client.os != "Mac" && e.ctrlKey) ) {
|
288 |
-
new_win = true;
|
289 |
-
}
|
290 |
-
if (new_win) {
|
291 |
-
window.open(response);
|
292 |
-
} else {
|
293 |
-
document.location = response;
|
294 |
-
}
|
295 |
-
|
296 |
-
}
|
297 |
-
});
|
298 |
-
return false;
|
299 |
-
|
300 |
-
} else {
|
301 |
-
return false;
|
302 |
-
}
|
303 |
-
|
304 |
-
});
|
305 |
-
|
306 |
-
|
307 |
-
});
|
308 |
-
|
309 |
-
function admin_menu_tree_page_view_save_opened_posts() {
|
310 |
-
jQuery.cookie('admin-menu-tree-page-view-open-posts', admin_menu_tree_page_view_opened_posts.join(","));
|
311 |
-
}
|
312 |
-
|
313 |
-
// array with all post ids that are open
|
314 |
-
var admin_menu_tree_page_view_opened_posts = jQuery.cookie('admin-menu-tree-page-view-open-posts') || "";
|
315 |
-
admin_menu_tree_page_view_opened_posts = admin_menu_tree_page_view_opened_posts.split(",");
|
316 |
-
if (admin_menu_tree_page_view_opened_posts[0] == "") {
|
317 |
-
// admin_menu_tree_page_view_opened_posts = [];
|
318 |
-
}
|
319 |
-
|
320 |
-
// http://stackoverflow.com/questions/187537/is-there-a-case-insensitive-jquery-contains-selector
|
321 |
-
jQuery.expr[':'].AminMenuTreePageContains = function(a,i,m){
|
322 |
-
return (a.textContent || a.innerText || "").toLowerCase().indexOf(m[3].toLowerCase())>=0;
|
323 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|