PluginProbe ʕ •ᴥ•ʔ
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager / 2.5.3
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager v2.5.3
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 5 years ago class-polylang.php 5 years ago class-review-box.php 5 years ago class-wpml.php 5 years ago folders.class.php 5 years ago form.class.php 5 years ago plugin.updates.php 5 years ago tree.class.php 5 years ago
tree.class.php
155 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)?"<span class='total-count'>{$term->trash_count}</span>":"";
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='sticky-icon'><img src='".WCP_FOLDER_URL."assets/images/pin.png' /></span><span class='folder-title'>{$term->name}</span><span class='update-inline-record'></span>{$count_sticky}<span class='star-icon'></span></a></li>";
91 }
92
93 $delete_nonce = wp_create_nonce('wcp_folder_delete_term_'.$term->term_id);
94 $rename_nonce = wp_create_nonce('wcp_folder_rename_term_'.$term->term_id);
95 $highlight_nonce = wp_create_nonce('wcp_folder_highlight_term_'.$term->term_id);
96 $term_nonce = wp_create_nonce('wcp_folder_term_'.$term->term_id);
97 /* Free/Pro URL Change*/
98 $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}'>";
99 $string .= "<h3 class='title' title='{$term->name}' id='title_{$term->term_id}'>";
100 $string .= "<span class='ui-icon'>";
101 $string .= "<i class='wcp-icon pfolder-folder-close'></i>";
102 $string .= "<input type='checkbox' class='checkbox' value='{$term->term_id}' />";
103 $string .= "</span>";
104 $string .= "<span class='title-text'>{$term->name}</span>";
105 $string .= "{$count} <span class='update-inline-record'><i class='pfolder-edit-folder'></i></span> <span class='star-icon'><i class='pfolder-star'></i></span>";
106 $string .= "<span class='folder-sticky-icon'><i class='pfolder-pin'></i></span>";
107 // $string .= "<span class='move-folder-icon' ><i class='pfolder-move'></i></span>";
108 $string .= "</h3>";
109 $string .= "<span class='nav-icon'><i class='wcp-icon pfolder-arrow-down'></i></span>";
110 $string .= "<ul class='space' id='space_{$term->term_id}'>";
111 $string .= $return['string'];
112 $string .= "</ul></li>";
113
114 $sticky_string .= $return['sticky_string'];
115 }
116 }
117 return array(
118 'string' =>$string,
119 'sticky_string' =>$sticky_string,
120 'child' => $child
121 );
122 }
123
124 public static function get_option_data_for_select($post_type) {
125 $string = "<option value='0'>Parent Folder</option>";
126 $string .= self::get_folder_option_data($post_type, 0, '');
127 return $string;
128 }
129
130 public static function get_folder_option_data($post_type, $parent = 0, $space = "") {
131 $terms = get_terms( $post_type, array(
132 'hide_empty' => false,
133 'parent' => $parent,
134 'orderby' => 'meta_value_num',
135 'order' => 'ASC',
136 'hierarchical' => false,
137 'meta_query' => [[
138 'key' => 'wcp_custom_order',
139 'type' => 'NUMERIC',
140 ]]
141 ) );
142
143 $selected_term = get_option("selected_" . $post_type . "_folder");
144
145 $string = "";
146 if(!empty($terms)) {
147 foreach($terms as $term) {
148 $selected = ($selected_term == $term->term_id)?"selected":"";
149 $string .= "<option {$selected} value='{$term->term_id}'>{$space}{$term->name}</option>";
150 $string .= self::get_folder_option_data($post_type, $term->term_id, trim($space)."- ");
151 }
152 }
153 return $string;
154 }
155 }