Version Description
- Fixed a couple of small bugs
- Prepare for translation
- Moved JS to own file
Download this release
Release Info
| Developer | eskapism |
| Plugin | |
| Version | 0.4 |
| Comparing to | |
| See all releases | |
Code changes from version 0.3 to 0.4
- index.php +25 -174
- readme.txt +14 -9
- screenshot-1.jpg +0 -0
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
- scripts.js +158 -0
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: Adds a tree of all your pages or custom posts. Use drag & drop to reorder your pages, and edit, view, add, and search your pages.
|
| 6 |
-
Version: 0.
|
| 7 |
Author: Pär Thernström
|
| 8 |
Author URI: http://eskapism.se/
|
| 9 |
License: GPL2
|
|
@@ -35,178 +35,28 @@ add_action("admin_init", "admin_menu_tree_page_view_admin_init");
|
|
| 35 |
add_action('wp_ajax_admin_menu_tree_page_view_add_page', 'admin_menu_tree_page_view_add_page');
|
| 36 |
|
| 37 |
function admin_menu_tree_page_view_admin_init() {
|
|
|
|
|
|
|
| 38 |
define( "admin_menu_tree_page_view_URL", WP_PLUGIN_URL . '/admin-menu-tree-page-view/' );
|
| 39 |
-
|
|
|
|
|
|
|
| 40 |
wp_enqueue_style("admin_menu_tree_page_view_styles", admin_menu_tree_page_view_URL . "styles.css", false, admin_menu_tree_page_view_VERSION);
|
| 41 |
wp_enqueue_script("jquery.highlight", admin_menu_tree_page_view_URL . "jquery.highlight.js", array("jquery"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
}
|
| 43 |
|
| 44 |
function admin_menu_tree_page_view_admin_head() {
|
| 45 |
-
?>
|
| 46 |
-
<script type="text/javascript">
|
| 47 |
-
jQuery(function($) {
|
| 48 |
-
|
| 49 |
-
setTimeout(function() {
|
| 50 |
-
jQuery("#toplevel_page_admin-menu-tree-page-tree_main").addClass("wp-menu-open");
|
| 51 |
-
}, 100);
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
// show menu when menu icon is clicked
|
| 55 |
-
jQuery(".admin-menu-tree-page-view-edit").click(function() {
|
| 56 |
-
|
| 57 |
-
var $this = $(this);
|
| 58 |
-
|
| 59 |
-
// check if this tree has a menu div defined
|
| 60 |
-
var wpsubmenu = $(this).closest("div.wp-submenu");
|
| 61 |
-
if (wpsubmenu.length == 1) {
|
| 62 |
-
|
| 63 |
-
var div_popup = wpsubmenu.find(".admin-menu-tree-page-view-popup");
|
| 64 |
-
var do_show = true;
|
| 65 |
-
if (div_popup.length == 0) {
|
| 66 |
-
// no menu div yet, create it
|
| 67 |
-
var html = "";
|
| 68 |
-
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>";
|
| 69 |
-
html += "<ul>";
|
| 70 |
-
html += "<li class='admin-menu-tree-page-view-popup-edit'><a href=''>Edit</a></li>";
|
| 71 |
-
html += "<li class='admin-menu-tree-page-view-popup-view'><a href=''>View</a></li>";
|
| 72 |
-
html += "<li class='admin-menu-tree-page-view-popup-add-here'><a href=''>Add new page here</a></li>";
|
| 73 |
-
html += "<li class='admin-menu-tree-page-view-popup-add-inside'><a href=''>Add new page inside</a></li>";
|
| 74 |
-
html += "</ul></div>";
|
| 75 |
-
var div_popup = $(html).appendTo(wpsubmenu);
|
| 76 |
-
div_popup.show(); // must do this..
|
| 77 |
-
div_popup.hide(); // ..or fade does not work first time
|
| 78 |
-
} else {
|
| 79 |
-
if (div_popup.is(":visible")) {
|
| 80 |
-
//do_show = false;
|
| 81 |
-
}
|
| 82 |
-
}
|
| 83 |
-
|
| 84 |
-
var a = $this.closest("a");
|
| 85 |
-
var link_text = a.text();
|
| 86 |
-
if (div_popup.find(".admin-menu-tree-page-view-popup-page").text() == link_text) {
|
| 87 |
-
do_show = false;
|
| 88 |
-
}
|
| 89 |
-
div_popup.find(".admin-menu-tree-page-view-popup-page").text( link_text );
|
| 90 |
-
var offset = $this.offset();
|
| 91 |
-
offset.top = (offset.top-3);
|
| 92 |
-
offset.left = (offset.left-3);
|
| 93 |
-
|
| 94 |
-
// store post_id
|
| 95 |
-
var post_id = a.attr("href").match(/post=([\w]+)/);
|
| 96 |
-
post_id = post_id[1];
|
| 97 |
-
div_popup.data("admin-menu-tree-page-view-current-post-id", post_id);
|
| 98 |
-
|
| 99 |
-
// setup edit and view links
|
| 100 |
-
var edit_link = "post.php?post="+post_id+"&action=edit";
|
| 101 |
-
div_popup.find(".admin-menu-tree-page-view-popup-edit a").attr("href", edit_link);
|
| 102 |
-
|
| 103 |
-
// view link, this is probably not such a safe way to this this. but let's try! :)
|
| 104 |
-
var view_link = "../?p=" + post_id;
|
| 105 |
-
div_popup.find(".admin-menu-tree-page-view-popup-view a").attr("href", view_link);
|
| 106 |
-
|
| 107 |
-
if (do_show) {
|
| 108 |
-
//console.log("show");
|
| 109 |
-
div_popup.fadeIn("fast");
|
| 110 |
-
} else {
|
| 111 |
-
// same popup, so close it
|
| 112 |
-
//console.log("hide");
|
| 113 |
-
div_popup.fadeOut("fast");
|
| 114 |
-
div_popup.find(".admin-menu-tree-page-view-popup-page").text("");
|
| 115 |
-
}
|
| 116 |
-
|
| 117 |
-
div_popup.offset( offset ); // must be last or position gets wrong somehow
|
| 118 |
-
|
| 119 |
-
}
|
| 120 |
-
|
| 121 |
-
return false;
|
| 122 |
-
});
|
| 123 |
-
|
| 124 |
-
// hide menu
|
| 125 |
-
$(".admin-menu-tree-page-view-popup-arrow").live("click", function() {
|
| 126 |
-
$(this).closest(".admin-menu-tree-page-view-popup").fadeOut("fast");
|
| 127 |
-
return false;
|
| 128 |
-
});
|
| 129 |
-
|
| 130 |
-
// add page
|
| 131 |
-
$(".admin-menu-tree-page-view-popup-add-here, .admin-menu-tree-page-view-popup-add-inside").live("click", function() {
|
| 132 |
-
var div_popup = $(this).closest(".admin-menu-tree-page-view-popup");
|
| 133 |
-
var post_id = div_popup.data("admin-menu-tree-page-view-current-post-id");
|
| 134 |
-
|
| 135 |
-
var type = "after";
|
| 136 |
-
if ($(this).hasClass("admin-menu-tree-page-view-popup-add-inside")) {
|
| 137 |
-
type = "inside";
|
| 138 |
-
}
|
| 139 |
-
|
| 140 |
-
var page_title = prompt("Enter name of new page", "Untitled");
|
| 141 |
-
if (page_title) {
|
| 142 |
-
|
| 143 |
-
var data = {
|
| 144 |
-
"action": 'admin_menu_tree_page_view_add_page',
|
| 145 |
-
"pageID": post_id,
|
| 146 |
-
"type": type,
|
| 147 |
-
"page_title": page_title,
|
| 148 |
-
"post_type": "page"
|
| 149 |
-
};
|
| 150 |
-
jQuery.post(ajaxurl, data, function(response) {
|
| 151 |
-
//alert(response);
|
| 152 |
-
if (response != "0") {
|
| 153 |
-
document.location = response;
|
| 154 |
-
}
|
| 155 |
-
});
|
| 156 |
-
|
| 157 |
-
} else {
|
| 158 |
-
return false;
|
| 159 |
-
}
|
| 160 |
-
|
| 161 |
-
});
|
| 162 |
-
|
| 163 |
-
// search/filter pages
|
| 164 |
-
$(".admin-menu-tree-page-filter input").keyup(function(e) {
|
| 165 |
-
var ul = $(this).closest(".admin-menu-tree-page-tree");
|
| 166 |
-
ul.find("li").hide();
|
| 167 |
-
ul.find(".admin-menu-tree-page-tree_headline,.admin-menu-tree-page-filter").show();
|
| 168 |
-
var s = $(this).val();
|
| 169 |
-
var selector = "li:AminMenuTreePageContains('"+s+"')";
|
| 170 |
-
var hits = ul.find(selector);
|
| 171 |
-
if (hits.length > 0 || s != "") {
|
| 172 |
-
ul.find(".admin-menu-tree-page-filter-reset").fadeIn("fast");
|
| 173 |
-
ul.unhighlight();
|
| 174 |
-
}
|
| 175 |
-
if (s == "") {
|
| 176 |
-
ul.find(".admin-menu-tree-page-filter-reset").fadeOut("fast");
|
| 177 |
-
}
|
| 178 |
-
ul.highlight(s);
|
| 179 |
-
hits.show();
|
| 180 |
-
|
| 181 |
-
});
|
| 182 |
-
|
| 183 |
-
// clear/reset filter and show all pages again
|
| 184 |
-
$(".admin-menu-tree-page-filter-reset").click(function() {
|
| 185 |
-
var $t = $(this);
|
| 186 |
-
var ul = $t.closest(".admin-menu-tree-page-tree");
|
| 187 |
-
ul.find("li").fadeIn("fast");
|
| 188 |
-
$t.fadeOut("fast");
|
| 189 |
-
$t.closest(".admin-menu-tree-page-filter").find("input").val("").focus();
|
| 190 |
-
ul.unhighlight();
|
| 191 |
-
});
|
| 192 |
-
|
| 193 |
-
// label = hide in and focus input
|
| 194 |
-
$(".admin-menu-tree-page-filter label").click(function() {
|
| 195 |
-
var $t = $(this);
|
| 196 |
-
$t.hide();
|
| 197 |
-
$t.closest(".admin-menu-tree-page-filter").find("input").focus();
|
| 198 |
-
});
|
| 199 |
-
|
| 200 |
-
});
|
| 201 |
-
// http://stackoverflow.com/questions/187537/is-there-a-case-insensitive-jquery-contains-selector
|
| 202 |
-
jQuery.expr[':'].AminMenuTreePageContains = function(a,i,m){
|
| 203 |
-
return (a.textContent || a.innerText || "").toLowerCase().indexOf(m[3].toLowerCase())>=0;
|
| 204 |
-
};
|
| 205 |
-
|
| 206 |
-
</script>
|
| 207 |
-
|
| 208 |
-
<?php
|
| 209 |
-
|
| 210 |
}
|
| 211 |
|
| 212 |
function admin_menu_tree_page_view_get_pages($args) {
|
|
@@ -239,7 +89,7 @@ function admin_menu_tree_page_view_get_pages($args) {
|
|
| 239 |
$status_span .= "<span class='admin-menu-tree-page-view-protected'></span>";
|
| 240 |
}
|
| 241 |
if ($one_page->post_status != "publish") {
|
| 242 |
-
$status_span .= "<span class='admin-menu-tree-page-view-status admin-menu-tree-page-view-status-{$one_page->post_status}'>
|
| 243 |
}
|
| 244 |
|
| 245 |
$output .= "<li class='$class'>";
|
|
@@ -279,11 +129,11 @@ function admin_menu_tree_page_view_admin_menu() {
|
|
| 279 |
$output = "
|
| 280 |
</a>
|
| 281 |
<ul class='admin-menu-tree-page-tree'>
|
| 282 |
-
<li class='admin-menu-tree-page-tree_headline'>Pages</li>
|
| 283 |
<li class='admin-menu-tree-page-filter'>
|
| 284 |
-
<label>Search
|
| 285 |
<input type='text' class='' />
|
| 286 |
-
<div class='admin-menu-tree-page-filter-reset' title='Reset
|
| 287 |
</li>
|
| 288 |
";
|
| 289 |
|
|
@@ -304,14 +154,14 @@ function admin_menu_tree_page_view_admin_menu() {
|
|
| 304 |
";
|
| 305 |
|
| 306 |
// add subitems to main menu
|
| 307 |
-
add_submenu_page("edit.php?post_type=page", "Tree View", $output, "edit_pages", "admin-menu-tree-page-tree", "admin_menu_tree_page_page");
|
| 308 |
|
| 309 |
}
|
| 310 |
|
| 311 |
function admin_menu_tree_page_page() {
|
| 312 |
?>
|
| 313 |
|
| 314 |
-
<h2>
|
| 315 |
<p>Nothing to see here. Move along! :)</p>
|
| 316 |
|
| 317 |
<?php
|
|
@@ -344,7 +194,7 @@ function admin_menu_tree_page_view_add_page() {
|
|
| 344 |
if (!$page_title) { $page_title = __("New page", 'cms-tree-page-view'); }
|
| 345 |
|
| 346 |
$ref_post = get_post($pageID);
|
| 347 |
-
|
| 348 |
if ("after" == $type) {
|
| 349 |
|
| 350 |
/*
|
|
@@ -385,6 +235,7 @@ function admin_menu_tree_page_view_add_page() {
|
|
| 385 |
$newPostID = wp_insert_post($post_new);
|
| 386 |
|
| 387 |
}
|
|
|
|
| 388 |
if ($newPostID) {
|
| 389 |
// return editlink for the newly created page
|
| 390 |
$editLink = get_edit_post_link($newPostID, '');
|
| 3 |
Plugin Name: Admin Menu Tree Page View
|
| 4 |
Plugin URI: http://eskapism.se/code-playground/admin-menu-tree-page-view/
|
| 5 |
Description: Adds a tree of all your pages or custom posts. Use drag & drop to reorder your pages, and edit, view, add, and search your pages.
|
| 6 |
+
Version: 0.4
|
| 7 |
Author: Pär Thernström
|
| 8 |
Author URI: http://eskapism.se/
|
| 9 |
License: GPL2
|
| 35 |
add_action('wp_ajax_admin_menu_tree_page_view_add_page', 'admin_menu_tree_page_view_add_page');
|
| 36 |
|
| 37 |
function admin_menu_tree_page_view_admin_init() {
|
| 38 |
+
|
| 39 |
+
define( "admin_menu_tree_page_view_VERSION", "0.4" );
|
| 40 |
define( "admin_menu_tree_page_view_URL", WP_PLUGIN_URL . '/admin-menu-tree-page-view/' );
|
| 41 |
+
|
| 42 |
+
load_plugin_textdomain('admin-menu-tree-page-view', false, "/admin-menu-tree-page-view/languages");
|
| 43 |
+
|
| 44 |
wp_enqueue_style("admin_menu_tree_page_view_styles", admin_menu_tree_page_view_URL . "styles.css", false, admin_menu_tree_page_view_VERSION);
|
| 45 |
wp_enqueue_script("jquery.highlight", admin_menu_tree_page_view_URL . "jquery.highlight.js", array("jquery"));
|
| 46 |
+
wp_enqueue_script("admin_menu_tree_page_view", admin_menu_tree_page_view_URL . "scripts.js", array("jquery"));
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
$oLocale = array(
|
| 50 |
+
"Edit" => __("Edit", 'admin-menu-tree-page-view'),
|
| 51 |
+
"View" => __("View", 'admin-menu-tree-page-view'),
|
| 52 |
+
"Add_new_page_here" => __("Add new page here", 'admin-menu-tree-page-view'),
|
| 53 |
+
"Add_new_page_inside" => __("Add new page inside", 'admin-menu-tree-page-view'),
|
| 54 |
+
"Untitled" => __("Untitled", 'admin-menu-tree-page-view'),
|
| 55 |
+
);
|
| 56 |
+
wp_localize_script( "admin_menu_tree_page_view", 'amtpv_l10n', $oLocale);
|
| 57 |
}
|
| 58 |
|
| 59 |
function admin_menu_tree_page_view_admin_head() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
}
|
| 61 |
|
| 62 |
function admin_menu_tree_page_view_get_pages($args) {
|
| 89 |
$status_span .= "<span class='admin-menu-tree-page-view-protected'></span>";
|
| 90 |
}
|
| 91 |
if ($one_page->post_status != "publish") {
|
| 92 |
+
$status_span .= "<span class='admin-menu-tree-page-view-status admin-menu-tree-page-view-status-{$one_page->post_status}'>".__($one_page->post_status)."</span>";
|
| 93 |
}
|
| 94 |
|
| 95 |
$output .= "<li class='$class'>";
|
| 129 |
$output = "
|
| 130 |
</a>
|
| 131 |
<ul class='admin-menu-tree-page-tree'>
|
| 132 |
+
<li class='admin-menu-tree-page-tree_headline'>" . __("Pages", "admin-menu-tree-page-view") . "</li>
|
| 133 |
<li class='admin-menu-tree-page-filter'>
|
| 134 |
+
<label>".__("Search", "admin-menu-tree-page-view")."</label>
|
| 135 |
<input type='text' class='' />
|
| 136 |
+
<div class='admin-menu-tree-page-filter-reset' title='".__("Reset search and show all pages", "admin-menu-tree-page-view")."'></div>
|
| 137 |
</li>
|
| 138 |
";
|
| 139 |
|
| 154 |
";
|
| 155 |
|
| 156 |
// add subitems to main menu
|
| 157 |
+
add_submenu_page("edit.php?post_type=page", "Admin Menu Tree Page View", $output, "edit_pages", "admin-menu-tree-page-tree", "admin_menu_tree_page_page");
|
| 158 |
|
| 159 |
}
|
| 160 |
|
| 161 |
function admin_menu_tree_page_page() {
|
| 162 |
?>
|
| 163 |
|
| 164 |
+
<h2>Admin Menu Tree Page View</h2>
|
| 165 |
<p>Nothing to see here. Move along! :)</p>
|
| 166 |
|
| 167 |
<?php
|
| 194 |
if (!$page_title) { $page_title = __("New page", 'cms-tree-page-view'); }
|
| 195 |
|
| 196 |
$ref_post = get_post($pageID);
|
| 197 |
+
|
| 198 |
if ("after" == $type) {
|
| 199 |
|
| 200 |
/*
|
| 235 |
$newPostID = wp_insert_post($post_new);
|
| 236 |
|
| 237 |
}
|
| 238 |
+
|
| 239 |
if ($newPostID) {
|
| 240 |
// return editlink for the newly created page
|
| 241 |
$editLink = get_edit_post_link($newPostID, '');
|
readme.txt
CHANGED
|
@@ -6,12 +6,13 @@ Requires at least: 3.0
|
|
| 6 |
Tested up to: 3.0
|
| 7 |
Stable tag: trunk
|
| 8 |
|
| 9 |
-
Get a tree view of all your pages directly in the admin menu.
|
| 10 |
|
| 11 |
== Description ==
|
| 12 |
|
| 13 |
-
This WordPress plugin adds all your pages to the admin menu, so all your pages will always be available within just one click
|
| 14 |
-
You can also add pages directly in the tree and you
|
|
|
|
| 15 |
|
| 16 |
Works perfect in CMS-like WordPress installations with lots of pages in a tree hierarchy.
|
| 17 |
|
|
@@ -21,24 +22,28 @@ I have made an even more advanced version of the tree, where you also can search
|
|
| 21 |
|
| 22 |
#### Donation and more plugins
|
| 23 |
* If you like this plugin don't forget to [donate to support further development](http://eskapism.se/sida/donate/).
|
| 24 |
-
* Check out some [more
|
| 25 |
|
| 26 |
== Installation ==
|
| 27 |
|
| 28 |
-
1. Upload the folder "
|
| 29 |
1. Activate the plugin through the "Plugins" menu in WordPress
|
| 30 |
1. Done!
|
| 31 |
|
| 32 |
-
Now the tree with the pages will be visible
|
| 33 |
|
| 34 |
== Screenshots ==
|
| 35 |
|
| 36 |
-
1. The menu page tree with all your pages. Pretty neat, eh?
|
| 37 |
-
2.
|
| 38 |
-
3. Search your pages in real time. Try it; it's wonderful! ;)
|
| 39 |
|
| 40 |
== Changelog ==
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
= 0.3 =
|
| 43 |
- Removed some notices
|
| 44 |
- Added a search/filter box. Search your pages in real time. I love it! :)
|
| 6 |
Tested up to: 3.0
|
| 7 |
Stable tag: trunk
|
| 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 |
|
| 11 |
== Description ==
|
| 12 |
|
| 13 |
+
This WordPress plugin adds all your pages to the admin menu, so all your pages will always be available within just one click,
|
| 14 |
+
no matter where you are in the admin area. You can also add pages directly in the tree and you can
|
| 15 |
+
quickly find your pages by using the search box.
|
| 16 |
|
| 17 |
Works perfect in CMS-like WordPress installations with lots of pages in a tree hierarchy.
|
| 18 |
|
| 22 |
|
| 23 |
#### Donation and more plugins
|
| 24 |
* If you like this plugin don't forget to [donate to support further development](http://eskapism.se/sida/donate/).
|
| 25 |
+
* Check out some [more WordPress CMS Plugins](http://wordpress.org/extend/plugins/profile/eskapism) by the same author.
|
| 26 |
|
| 27 |
== Installation ==
|
| 28 |
|
| 29 |
+
1. Upload the folder "admin-menu-tree-page-view" to "/wp-content/plugins/"
|
| 30 |
1. Activate the plugin through the "Plugins" menu in WordPress
|
| 31 |
1. Done!
|
| 32 |
|
| 33 |
+
Now the tree with the pages will be visible in the admin menu to the left.
|
| 34 |
|
| 35 |
== Screenshots ==
|
| 36 |
|
| 37 |
+
1. The menu page tree with all your pages. Pretty neat, eh? You add new pages too. And search your pages. In conclusion: with this plugin you will be a page kung fu master.
|
| 38 |
+
2. Search your pages in real time. Try it; it's wonderful! ;)
|
|
|
|
| 39 |
|
| 40 |
== Changelog ==
|
| 41 |
|
| 42 |
+
= 0.4 =
|
| 43 |
+
- Fixed a couple of small bugs
|
| 44 |
+
- Prepare for translation
|
| 45 |
+
- Moved JS to own file
|
| 46 |
+
|
| 47 |
= 0.3 =
|
| 48 |
- Removed some notices
|
| 49 |
- Added a search/filter box. Search your pages in real time. I love it! :)
|
screenshot-1.jpg
DELETED
|
Binary file
|
screenshot-1.png
ADDED
|
Binary file
|
screenshot-2.png
CHANGED
|
Binary file
|
screenshot-3.png
DELETED
|
Binary file
|
scripts.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|
| 9 |
+
// show menu when menu icon is clicked
|
| 10 |
+
jQuery(".admin-menu-tree-page-view-edit").click(function() {
|
| 11 |
+
|
| 12 |
+
var $this = $(this);
|
| 13 |
+
|
| 14 |
+
// check if this tree has a menu div defined
|
| 15 |
+
var wpsubmenu = $(this).closest("div.wp-submenu");
|
| 16 |
+
if (wpsubmenu.length == 1) {
|
| 17 |
+
|
| 18 |
+
var div_popup = wpsubmenu.find(".admin-menu-tree-page-view-popup");
|
| 19 |
+
var do_show = true;
|
| 20 |
+
if (div_popup.length == 0) {
|
| 21 |
+
// no menu div yet, create it
|
| 22 |
+
var html = "";
|
| 23 |
+
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>";
|
| 24 |
+
html += "<ul>";
|
| 25 |
+
html += "<li class='admin-menu-tree-page-view-popup-edit'><a href=''>"+amtpv_l10n.Edit+"</a></li>";
|
| 26 |
+
html += "<li class='admin-menu-tree-page-view-popup-view'><a href=''>"+amtpv_l10n.View+"</a></li>";
|
| 27 |
+
html += "<li class='admin-menu-tree-page-view-popup-add-here'><a href=''>"+amtpv_l10n.Add_new_page_here+"</a></li>";
|
| 28 |
+
html += "<li class='admin-menu-tree-page-view-popup-add-inside'><a href=''>"+amtpv_l10n.Add_new_page_inside+"</a></li>";
|
| 29 |
+
html += "</ul></div>";
|
| 30 |
+
var div_popup = $(html).appendTo(wpsubmenu);
|
| 31 |
+
div_popup.show(); // must do this..
|
| 32 |
+
div_popup.hide(); // ..or fade does not work first time
|
| 33 |
+
} else {
|
| 34 |
+
if (div_popup.is(":visible")) {
|
| 35 |
+
//do_show = false;
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
var a = $this.closest("a");
|
| 40 |
+
var link_text = a.text();
|
| 41 |
+
if (div_popup.find(".admin-menu-tree-page-view-popup-page").text() == link_text) {
|
| 42 |
+
do_show = false;
|
| 43 |
+
}
|
| 44 |
+
div_popup.find(".admin-menu-tree-page-view-popup-page").text( link_text );
|
| 45 |
+
var offset = $this.offset();
|
| 46 |
+
offset.top = (offset.top-3);
|
| 47 |
+
offset.left = (offset.left-3);
|
| 48 |
+
|
| 49 |
+
// store post_id
|
| 50 |
+
var post_id = a.attr("href").match(/post=([\w]+)/);
|
| 51 |
+
post_id = post_id[1];
|
| 52 |
+
div_popup.data("admin-menu-tree-page-view-current-post-id", post_id);
|
| 53 |
+
|
| 54 |
+
// setup edit and view links
|
| 55 |
+
var edit_link = "post.php?post="+post_id+"&action=edit";
|
| 56 |
+
div_popup.find(".admin-menu-tree-page-view-popup-edit a").attr("href", edit_link);
|
| 57 |
+
|
| 58 |
+
// view link, this is probably not such a safe way to this this. but let's try! :)
|
| 59 |
+
var view_link = "../?p=" + post_id;
|
| 60 |
+
div_popup.find(".admin-menu-tree-page-view-popup-view a").attr("href", view_link);
|
| 61 |
+
|
| 62 |
+
if (do_show) {
|
| 63 |
+
//console.log("show");
|
| 64 |
+
div_popup.fadeIn("fast");
|
| 65 |
+
} else {
|
| 66 |
+
// same popup, so close it
|
| 67 |
+
//console.log("hide");
|
| 68 |
+
div_popup.fadeOut("fast");
|
| 69 |
+
div_popup.find(".admin-menu-tree-page-view-popup-page").text("");
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
div_popup.offset( offset ); // must be last or position gets wrong somehow
|
| 73 |
+
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
return false;
|
| 77 |
+
});
|
| 78 |
+
|
| 79 |
+
// hide menu
|
| 80 |
+
$(".admin-menu-tree-page-view-popup-arrow").live("click", function() {
|
| 81 |
+
$(this).closest(".admin-menu-tree-page-view-popup").fadeOut("fast");
|
| 82 |
+
return false;
|
| 83 |
+
});
|
| 84 |
+
|
| 85 |
+
// add page
|
| 86 |
+
$(".admin-menu-tree-page-view-popup-add-here, .admin-menu-tree-page-view-popup-add-inside").live("click", function() {
|
| 87 |
+
var div_popup = $(this).closest(".admin-menu-tree-page-view-popup");
|
| 88 |
+
var post_id = div_popup.data("admin-menu-tree-page-view-current-post-id");
|
| 89 |
+
|
| 90 |
+
var type = "after";
|
| 91 |
+
if ($(this).hasClass("admin-menu-tree-page-view-popup-add-inside")) {
|
| 92 |
+
type = "inside";
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
var page_title = prompt("Enter name of new page", amtpv_l10n.Untitled);
|
| 96 |
+
if (page_title) {
|
| 97 |
+
|
| 98 |
+
var data = {
|
| 99 |
+
"action": 'admin_menu_tree_page_view_add_page',
|
| 100 |
+
"pageID": post_id,
|
| 101 |
+
"type": type,
|
| 102 |
+
"page_title": page_title,
|
| 103 |
+
"post_type": "page"
|
| 104 |
+
};
|
| 105 |
+
jQuery.post(ajaxurl, data, function(response) {
|
| 106 |
+
if (response != "0") {
|
| 107 |
+
document.location = response;
|
| 108 |
+
}
|
| 109 |
+
});
|
| 110 |
+
return false;
|
| 111 |
+
|
| 112 |
+
} else {
|
| 113 |
+
return false;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
});
|
| 117 |
+
|
| 118 |
+
// search/filter pages
|
| 119 |
+
$(".admin-menu-tree-page-filter input").keyup(function(e) {
|
| 120 |
+
var ul = $(this).closest(".admin-menu-tree-page-tree");
|
| 121 |
+
ul.find("li").hide();
|
| 122 |
+
ul.find(".admin-menu-tree-page-tree_headline,.admin-menu-tree-page-filter").show();
|
| 123 |
+
var s = $(this).val();
|
| 124 |
+
var selector = "li:AminMenuTreePageContains('"+s+"')";
|
| 125 |
+
var hits = ul.find(selector);
|
| 126 |
+
if (hits.length > 0 || s != "") {
|
| 127 |
+
ul.find(".admin-menu-tree-page-filter-reset").fadeIn("fast");
|
| 128 |
+
ul.unhighlight();
|
| 129 |
+
}
|
| 130 |
+
if (s == "") {
|
| 131 |
+
ul.find(".admin-menu-tree-page-filter-reset").fadeOut("fast");
|
| 132 |
+
}
|
| 133 |
+
ul.highlight(s);
|
| 134 |
+
hits.show();
|
| 135 |
+
});
|
| 136 |
+
|
| 137 |
+
// clear/reset filter and show all pages again
|
| 138 |
+
$(".admin-menu-tree-page-filter-reset").click(function() {
|
| 139 |
+
var $t = $(this);
|
| 140 |
+
var ul = $t.closest(".admin-menu-tree-page-tree");
|
| 141 |
+
ul.find("li").fadeIn("fast");
|
| 142 |
+
$t.fadeOut("fast");
|
| 143 |
+
$t.closest(".admin-menu-tree-page-filter").find("input").val("").focus();
|
| 144 |
+
ul.unhighlight();
|
| 145 |
+
});
|
| 146 |
+
|
| 147 |
+
// label = hide in and focus input
|
| 148 |
+
$(".admin-menu-tree-page-filter label, .admin-menu-tree-page-filter input").click(function() {
|
| 149 |
+
var $t = $(this);
|
| 150 |
+
$t.closest(".admin-menu-tree-page-filter").find("label").hide();
|
| 151 |
+
$t.closest(".admin-menu-tree-page-filter").find("input").focus();
|
| 152 |
+
});
|
| 153 |
+
|
| 154 |
+
});
|
| 155 |
+
// http://stackoverflow.com/questions/187537/is-there-a-case-insensitive-jquery-contains-selector
|
| 156 |
+
jQuery.expr[':'].AminMenuTreePageContains = function(a,i,m){
|
| 157 |
+
return (a.textContent || a.innerText || "").toLowerCase().indexOf(m[3].toLowerCase())>=0;
|
| 158 |
+
};
|
