PluginProbe ʕ •ᴥ•ʔ
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager / 2.8.2
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager v2.8.2
3.1.9 3.1.8 3.1.7 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 trunk 1.3.7 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6 2.6.1 2.6.2 2.6.3 2.6.4 2.6.5 2.6.6 2.6.7 2.6.8 2.6.9 2.7 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9 2.9.1 2.9.2
folders / includes / tree.class.php
folders / includes Last commit date
class-affiliate.php 3 years ago class-polylang.php 3 years ago class-review-box.php 3 years ago class-upgrade-box.php 3 years ago class-wpml.php 3 years ago folders.class.php 3 years ago form.class.php 3 years ago media.replace.php 3 years ago plugin.updates.php 3 years ago plugins.class.php 3 years ago tree.class.php 3 years ago
tree.class.php
172 lines
1 <?php
2 if(!defined('ABSPATH')) exit;
3 class WCP_Tree {
4
5 public function __construct() {
6
7 }
8
9 public static function get_full_tree_data($post_type, $order_by = "", $order = "") {
10 $isAjax = (defined('DOING_AJAX') && DOING_AJAX)?1:0;
11 $type = filter_input(INPUT_GET, $post_type, FILTER_SANITIZE_STRING);
12 if((isset($type) && !empty($type)) || ! $isAjax) {
13 update_option("selected_" . $post_type . "_folder", "");
14 }
15 return self::get_folder_category_data($post_type, 0, 0, $order_by, $order);
16 }
17
18 public static function get_folder_category_data($post_type, $parent = 0, $parentStatus = 0, $order_by = "", $order = "") {
19
20 $arg = array(
21 'hide_empty' => false,
22 'parent' => $parent,
23 'hierarchical' => false,
24 'update_count_callback' => '_update_generic_term_count',
25 );
26 if(!empty($order_by) && !empty($order)) {
27 $arg['orderby'] = $order_by;
28 $arg['order'] = $order;
29 } else {
30 $arg['orderby'] = 'meta_value_num';
31 $arg['order'] = 'ASC';
32 $arg['meta_query'] = [[
33 'key' => 'wcp_custom_order',
34 'type' => 'NUMERIC',
35 ]];
36 }
37
38 $terms = get_terms( $post_type, $arg);
39
40 $string = "";
41 $sticky_string = "";
42 $child = 0;
43 $isAjax = (defined('DOING_AJAX') && DOING_AJAX)?1:0;
44 if(!empty($terms)) {
45 $child = count($terms);
46 foreach($terms as $key=>$term) {
47
48 if(!empty($order_by) && !empty($order)) {
49 update_term_meta($term->term_id, "wcp_custom_order", ($key+1));
50 }
51
52 $is_sticky = get_term_meta($term->term_id, "is_folder_sticky", true);
53
54 $status = get_term_meta($term->term_id, "is_active", true);
55 $return = self::get_folder_category_data($post_type, $term->term_id, $status, $order_by, $order);
56 $class = ($status == 1 && $return['child']>0)?"active":"";
57 $class .= ($return['child'])>0?" has-sub-tree":"";
58 $term_var = filter_input(INPUT_GET, "term", FILTER_SANITIZE_STRING);
59 $type = filter_input(INPUT_GET, $post_type, FILTER_SANITIZE_STRING);
60 if($post_type == "attachment") {
61 $class .= (isset($term_var) && $term_var == $term->slug)?" active-item active-term":"";
62 if(isset($type) && $type == $term->slug) {
63 update_option("selected_".$post_type."_folder", $term->term_id);
64 }
65 if(!isset($type) && $isAjax) {
66 $termId = get_option("selected_".$post_type."_folder");
67 $class .= ($termId == $term->term_id)?" active-item active-term":"";
68 }
69 } else {
70 $class .= (isset($type) && $type == $term->slug)?" active-item active-term":"";
71 if(isset($type) && $type == $term->slug) {
72 update_option("selected_" . $post_type . "_folder", $term->term_id);
73 }
74 if(!isset($type) && $isAjax) {
75 $termId = get_option("selected_".$post_type."_folder");
76 $class .= ($termId == $term->term_id)?" active-item active-term":"";
77 }
78 }
79 $status = get_term_meta($term->term_id, "is_highlighted", true);
80 $class .= ($status == 1)?" is-high":"";
81 $sticky_class = ($status == 1)?"is-high":"";
82 $count = ($term->trash_count != 0)?$term->trash_count:0;
83 if($is_sticky == 1) {
84 $class .= " is-sticky";
85 }
86
87 $count_sticky = ($term->trash_count != 0)?"<span class='folder-count'>{$term->trash_count}</span>":"";
88
89 if($is_sticky == 1) {
90 //$sticky_string .= "<li data-folder-id='{$term->term_id}' class='sticky-fldr {$sticky_class} sticky-folder-{$term->term_id}'><a href='javascript:;'><span class='folder-title'>{$term->name}</span>{$count_sticky}<span class='update-inline-record'><i class='pfolder-edit-folder'></i></span><span class='star-icon'><i class='pfolder-star'></i></span></a></li>";
91 }
92
93 /* Free/Pro URL Change*/
94 // $string .= "<li data-nonce='{$term_nonce}' data-star='{$highlight_nonce}' data-rename='{$rename_nonce}' data-delete='{$delete_nonce}' data-slug='{$term->slug}' class='ui-state-default route wcp_folder_{$term->term_id} {$class}' id='wcp_folder_{$term->term_id}' data-folder-id='{$term->term_id}'>";
95 // $string .= "<h3 class='title' title='{$term->name}' id='title_{$term->term_id}'>";
96 // $string .= "<span class='ui-icon'>";
97 // $string .= "<i class='wcp-icon pfolder-folder-close'></i>";
98 // $string .= "<input type='checkbox' class='checkbox' value='{$term->term_id}' />";
99 // $string .= "</span>";
100 // $string .= "<span class='title-text'>{$term->name}</span>";
101 // $string .= "{$count} <span class='update-inline-record'><i class='pfolder-edit-folder'></i></span> <span class='star-icon'><i class='pfolder-star'></i></span>";
102 // $string .= "<span class='folder-sticky-icon'><i class='pfolder-pin'></i></span>";
103 // //$string .= "<span class='move-folder-icon' ><i class='pfolder-move'></i></span>";
104 // $string .= "</h3>";
105 // $string .= "<span class='nav-icon'><i class='wcp-icon pfolder-arrow-down'></i></span>";
106 // $string .= "<ul class='space' id='space_{$term->term_id}'>";
107 // $string .= $return['string'];
108 // $string .= "</ul></li>";
109
110 // $parent = (empty($parent))?"#":$parent;
111 $nonce = wp_create_nonce('wcp_folder_term_'.$term->term_id);
112 $is_sticky = get_term_meta($term->term_id, "is_folder_sticky", true);
113 $status = get_term_meta($term->term_id, "is_highlighted", true);
114 $is_active = get_term_meta($term->term_id, "is_active", true);
115 $class = "";
116 if($is_sticky == 1) {
117 $class .= " is-sticky";
118 }
119 if($status == 1) {
120 $class .= " is-high";
121 }
122 if($is_active == 1) {
123 $class .= " jstree-open";
124 }
125
126 $string .= "<li id='{$term->term_id}' class='{$class}' data-slug='{$term->slug}' data-nonce='{$nonce}' data-folder='{$term->term_id}' data-child='{$child}' data-count='{$count}' data-parent='{$parent}'>
127 {$term->name}
128 <ul>{$return['string']}</ul>
129 </li>";
130
131 $sticky_string .= $return['sticky_string'];
132 }
133 }
134 return array(
135 'string' =>$string,
136 'sticky_string' =>$sticky_string,
137 'child' => $child
138 );
139 }
140
141 public static function get_option_data_for_select($post_type) {
142 $string = "<option value='0'>Parent Folder</option>";
143 $string .= self::get_folder_option_data($post_type, 0, '');
144 return $string;
145 }
146
147 public static function get_folder_option_data($post_type, $parent = 0, $space = "") {
148 $terms = get_terms( $post_type, array(
149 'hide_empty' => false,
150 'parent' => $parent,
151 'orderby' => 'meta_value_num',
152 'order' => 'ASC',
153 'hierarchical' => false,
154 'meta_query' => [[
155 'key' => 'wcp_custom_order',
156 'type' => 'NUMERIC',
157 ]]
158 ) );
159
160 $selected_term = get_option("selected_" . $post_type . "_folder");
161
162 $string = "";
163 if(!empty($terms)) {
164 foreach($terms as $term) {
165 $selected = ($selected_term == $term->term_id)?"selected":"";
166 $string .= "<option {$selected} value='{$term->term_id}'>{$space}{$term->name}</option>";
167 $string .= self::get_folder_option_data($post_type, $term->term_id, trim($space)."- ");
168 }
169 }
170 return $string;
171 }
172 }