PluginProbe ʕ •ᴥ•ʔ
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager / 2.9.4
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager v2.9.4
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 2 years ago class-review-box.php 2 years ago class-upgrade-box.php 3 years ago class-wpml.php 3 years ago folders.class.php 2 years ago form.class.php 3 years ago media.replace.php 2 years ago plugins.class.php 3 years ago tree.class.php 2 years ago
tree.class.php
221 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
117 $folder_info = get_term_meta($term->term_id, "folder_info", true);
118 $folder_info = shortcode_atts([
119 'is_sticky' => 0,
120 'is_high' => 0,
121 'is_locked' => 0,
122 'is_active' => 0,
123 ], $folder_info);
124
125 $status = intval($folder_info['is_high']);
126 $is_active = intval($folder_info['is_active']);
127 $is_sticky = intval($folder_info['is_sticky']);
128
129 $class = "";
130 if ($is_sticky == 1) {
131 $class .= " is-sticky";
132 }
133
134 if ($status == 1) {
135 $class .= " is-high";
136 }
137
138 if ($is_active == 1) {
139 $class .= " jstree-open";
140 }
141
142 $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)."'>
143 ".esc_attr($term->name)."
144 <ul>".$return['string']."</ul>
145 </li>";
146
147 $sticky_string .= $return['sticky_string'];
148 }//end foreach
149 }//end if
150
151 return [
152 'string' => $string,
153 'sticky_string' => $sticky_string,
154 'child' => $child,
155 ];
156
157 }//end get_folder_category_data()
158
159
160 /**
161 * Get option data into taxonomies (Parent Folder)
162 *
163 * @since 1.0.0
164 * @access public
165 * @return $categories
166 */
167 public static function get_option_data_for_select($postType)
168 {
169 $string = "<option value='0'>".esc_html__("Parent Folder", "folders")."</option>";
170 $string .= self::get_folder_option_data($postType, 0, '');
171 return $string;
172
173 }//end get_option_data_for_select()
174
175
176 /**
177 * Get option data into taxonomies (Child Folder)
178 *
179 * @since 1.0.0
180 * @access public
181 * @return $categories
182 */
183 public static function get_folder_option_data($postType, $parent=0, $space="")
184 {
185 $terms = get_terms(
186 $postType,
187 [
188 'hide_empty' => false,
189 'parent' => $parent,
190 'orderby' => 'meta_value_num',
191 'order' => 'ASC',
192 'hierarchical' => false,
193 'meta_query' => [
194 [
195 'key' => 'wcp_custom_order',
196 'type' => 'NUMERIC',
197 ],
198 ],
199 ]
200 );
201
202 $selected_term = get_option("selected_".$postType."_folder");
203
204 $string = "";
205 if (!empty($terms)) {
206 foreach ($terms as $term) {
207 if(isset($term->term_id) && isset($term->name)) {
208 $selected = ($selected_term == $term->term_id) ? "selected" : "";
209 $string .= "<option " . esc_attr($selected) . " value='" . esc_attr($term->term_id) . "'>" . esc_attr($space) . esc_attr($term->name) . "</option>";
210 $string .= self::get_folder_option_data($postType, $term->term_id, trim($space) . "- ");
211 }
212 }
213 }
214
215 return $string;
216
217 }//end get_folder_option_data()
218
219
220 }//end class
221