PluginProbe ʕ •ᴥ•ʔ
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager / 2.9.2
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager v2.9.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 plugins.class.php 3 years ago tree.class.php 3 years ago
tree.class.php
211 lines
1 <?php
2 /**
3 * Class Folders Tree
4 *
5 * @author : Premio <contact@premio.io>
6 * @license : GPL2
7 * */
8
9 if (! defined('ABSPATH')) {
10 exit;
11 }
12
13 class WCP_Tree
14 {
15
16
17 /**
18 * Define the core functionality to shoe taxonomies
19 *
20 * @since 1.0.0
21 */
22 public function __construct()
23 {
24
25 }//end __construct()
26
27
28 /**
29 * Get tree data into taxonomies (Root Folder)
30 *
31 * @since 1.0.0
32 * @access public
33 * @return $categories
34 */
35 public static function get_full_tree_data($postType, $orderBy="", $order="")
36 {
37 $isAjax = (defined('DOING_AJAX') && DOING_AJAX) ? 1 : 0;
38 $type = filter_input(INPUT_GET, $postType);
39 if ((isset($type) && !empty($type)) || ! $isAjax) {
40 update_option("selected_".$postType."_folder", "");
41 }
42
43 return self::get_folder_category_data($postType, 0, 0, $orderBy, $order);
44
45 }//end get_full_tree_data()
46
47
48 /**
49 * Get tree data into taxonomies (Child Folder)
50 *
51 * @since 1.0.0
52 * @access public
53 * @return $categories
54 */
55 public static function get_folder_category_data($postType, $parent=0, $parentStatus=0, $orderBy="", $order="")
56 {
57
58 $arg = [
59 'hide_empty' => false,
60 'parent' => $parent,
61 'hierarchical' => false,
62 'update_count_callback' => '_update_generic_term_count',
63 ];
64 if (!empty($orderBy) && !empty($order)) {
65 $arg['orderby'] = $orderBy;
66 $arg['order'] = $order;
67 } else {
68 $arg['orderby'] = 'meta_value_num';
69 $arg['order'] = 'ASC';
70 $arg['meta_query'] = [
71 [
72 'key' => 'wcp_custom_order',
73 'type' => 'NUMERIC',
74 ],
75 ];
76 }
77
78 $terms = get_terms($postType, $arg);
79
80 $string = "";
81 $sticky_string = "";
82 $child = 0;
83 $isAjax = (defined('DOING_AJAX') && DOING_AJAX) ? 1 : 0;
84 if (!empty($terms)) {
85 $child = count($terms);
86 foreach ($terms as $key => $term) {
87 if (!empty($orderBy) && !empty($order)) {
88 update_term_meta($term->term_id, "wcp_custom_order", ($key + 1));
89 }
90
91 $status = get_term_meta($term->term_id, "is_active", true);
92 $return = self::get_folder_category_data($postType, $term->term_id, $status, $orderBy, $order);
93 $type = filter_input(INPUT_GET, $postType);
94 if ($postType == "attachment") {
95 if (isset($type) && $type == $term->slug) {
96 update_option("selected_".$postType."_folder", $term->term_id);
97 }
98
99 if (!isset($type) && $isAjax) {
100 $termId = get_option("selected_".$postType."_folder");
101 }
102 } else {
103 if (isset($type) && $type == $term->slug) {
104 update_option("selected_".$postType."_folder", $term->term_id);
105 }
106
107 if (!isset($type) && $isAjax) {
108 $termId = get_option("selected_".$postType."_folder");
109 }
110 }
111
112 $count = ($term->trash_count != 0) ? $term->trash_count : 0;
113
114 // Free/Pro URL Change
115 $nonce = wp_create_nonce('wcp_folder_term_'.$term->term_id);
116 $is_sticky = get_term_meta($term->term_id, "is_folder_sticky", true);
117 $status = get_term_meta($term->term_id, "is_highlighted", true);
118 $is_active = get_term_meta($term->term_id, "is_active", true);
119 $class = "";
120 if ($is_sticky == 1) {
121 $class .= " is-sticky";
122 }
123
124 if ($status == 1) {
125 $class .= " is-high";
126 }
127
128 if ($is_active == 1) {
129 $class .= " jstree-open";
130 }
131
132 $string .= "<li id='".esc_attr($term->term_id)."' class='".esc_attr($class)."' data-slug='".esc_attr($term->slug)."' data-nonce='".esc_attr($nonce)."' data-folder='".esc_attr($term->term_id)."' data-child='".esc_attr($child)."' data-count='".esc_attr($count)."' data-parent='".esc_attr($parent)."'>
133 ".esc_attr($term->name)."
134 <ul>".$return['string']."</ul>
135 </li>";
136
137 $sticky_string .= $return['sticky_string'];
138 }//end foreach
139 }//end if
140
141 return [
142 'string' => $string,
143 'sticky_string' => $sticky_string,
144 'child' => $child,
145 ];
146
147 }//end get_folder_category_data()
148
149
150 /**
151 * Get option data into taxonomies (Parent Folder)
152 *
153 * @since 1.0.0
154 * @access public
155 * @return $categories
156 */
157 public static function get_option_data_for_select($postType)
158 {
159 $string = "<option value='0'>".esc_html__("Parent Folder", "folders")."</option>";
160 $string .= self::get_folder_option_data($postType, 0, '');
161 return $string;
162
163 }//end get_option_data_for_select()
164
165
166 /**
167 * Get option data into taxonomies (Child Folder)
168 *
169 * @since 1.0.0
170 * @access public
171 * @return $categories
172 */
173 public static function get_folder_option_data($postType, $parent=0, $space="")
174 {
175 $terms = get_terms(
176 $postType,
177 [
178 'hide_empty' => false,
179 'parent' => $parent,
180 'orderby' => 'meta_value_num',
181 'order' => 'ASC',
182 'hierarchical' => false,
183 'meta_query' => [
184 [
185 'key' => 'wcp_custom_order',
186 'type' => 'NUMERIC',
187 ],
188 ],
189 ]
190 );
191
192 $selected_term = get_option("selected_".$postType."_folder");
193
194 $string = "";
195 if (!empty($terms)) {
196 foreach ($terms as $term) {
197 if(isset($term->term_id) && isset($term->name)) {
198 $selected = ($selected_term == $term->term_id) ? "selected" : "";
199 $string .= "<option " . esc_attr($selected) . " value='" . esc_attr($term->term_id) . "'>" . esc_attr($space) . esc_attr($term->name) . "</option>";
200 $string .= self::get_folder_option_data($postType, $term->term_id, trim($space) . "- ");
201 }
202 }
203 }
204
205 return $string;
206
207 }//end get_folder_option_data()
208
209
210 }//end class
211