PluginProbe ʕ •ᴥ•ʔ
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager / 3.1.2
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager v3.1.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 1 year ago class-email-signup.php 1 year ago class-help.php 1 year ago class-polylang.php 1 year ago class-review-box.php 1 year ago class-upgrade-box.php 1 year ago class-wpml.php 1 year ago folders.class.php 1 year ago form.class.php 1 year ago form.fields.php 1 year ago import.export.class.php 1 year ago media.replace.php 1 year ago notifications.class.php 1 year ago plugins.class.php 1 year ago svg.class.php 1 year ago tree.class.php 1 year ago
tree.class.php
222 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 'taxonomy' => $postType,
60 'hide_empty' => false,
61 'parent' => $parent,
62 'hierarchical' => false,
63 'update_count_callback' => '_update_generic_term_count',
64 ];
65 if (!empty($orderBy) && !empty($order)) {
66 $arg['orderby'] = $orderBy;
67 $arg['order'] = $order;
68 } else {
69 $arg['orderby'] = 'meta_value_num';
70 $arg['order'] = 'ASC';
71 $arg['meta_query'] = [
72 [
73 'key' => 'wcp_custom_order',
74 'type' => 'NUMERIC',
75 ],
76 ];
77 }
78
79 $terms = get_terms($arg);
80
81 $string = "";
82 $sticky_string = "";
83 $child = 0;
84 $isAjax = (defined('DOING_AJAX') && DOING_AJAX) ? 1 : 0;
85 if (!empty($terms)) {
86 $child = count($terms);
87 foreach ($terms as $key => $term) {
88 if (!empty($orderBy) && !empty($order)) {
89 update_term_meta($term->term_id, "wcp_custom_order", ($key + 1));
90 }
91
92 $status = get_term_meta($term->term_id, "is_active", true);
93 $return = self::get_folder_category_data($postType, $term->term_id, $status, $orderBy, $order);
94 $type = filter_input(INPUT_GET, $postType);
95 if ($postType == "attachment") {
96 if (isset($type) && $type == $term->slug) {
97 update_option("selected_".$postType."_folder", $term->term_id);
98 }
99
100 if (!isset($type) && $isAjax) {
101 $termId = get_option("selected_".$postType."_folder");
102 }
103 } else {
104 if (isset($type) && $type == $term->slug) {
105 update_option("selected_".$postType."_folder", $term->term_id);
106 }
107
108 if (!isset($type) && $isAjax) {
109 $termId = get_option("selected_".$postType."_folder");
110 }
111 }
112
113 $count = ($term->trash_count != 0) ? $term->trash_count : 0;
114
115 // Free/Pro URL Change
116 $nonce = wp_create_nonce('wcp_folder_term_'.$term->term_id);
117
118 $folder_info = get_term_meta($term->term_id, "folder_info", true);
119 $folder_info = shortcode_atts([
120 'is_sticky' => 0,
121 'is_high' => 0,
122 'is_locked' => 0,
123 'is_active' => 0,
124 ], $folder_info);
125
126 $status = intval($folder_info['is_high']);
127 $is_active = intval($folder_info['is_active']);
128 $is_sticky = intval($folder_info['is_sticky']);
129
130 $class = "";
131 if ($is_sticky == 1) {
132 $class .= " is-sticky";
133 }
134
135 if ($status == 1) {
136 $class .= " is-high";
137 }
138
139 if ($is_active == 1) {
140 $class .= " jstree-open";
141 }
142
143 $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)."'>
144 ".esc_attr($term->name)."
145 <ul>".$return['string']."</ul>
146 </li>";
147
148 $sticky_string .= $return['sticky_string'];
149 }//end foreach
150 }//end if
151
152 return [
153 'string' => $string,
154 'sticky_string' => $sticky_string,
155 'child' => $child,
156 ];
157
158 }//end get_folder_category_data()
159
160
161 /**
162 * Get option data into taxonomies (Parent Folder)
163 *
164 * @since 1.0.0
165 * @access public
166 * @return $categories
167 */
168 public static function get_option_data_for_select($postType)
169 {
170 $string = "<option value='0'>".esc_html__("Parent Folder", "folders")."</option>";
171 $string .= self::get_folder_option_data($postType, 0, '');
172 return $string;
173
174 }//end get_option_data_for_select()
175
176
177 /**
178 * Get option data into taxonomies (Child Folder)
179 *
180 * @since 1.0.0
181 * @access public
182 * @return $categories
183 */
184 public static function get_folder_option_data($postType, $parent=0, $space="")
185 {
186 $terms = get_terms(
187 [
188 'taxonomy' => $postType,
189 'hide_empty' => false,
190 'parent' => $parent,
191 'orderby' => 'meta_value_num',
192 'order' => 'ASC',
193 'hierarchical' => false,
194 'meta_query' => [
195 [
196 'key' => 'wcp_custom_order',
197 'type' => 'NUMERIC',
198 ],
199 ],
200 ]
201 );
202
203 $selected_term = get_option("selected_".$postType."_folder");
204
205 $string = "";
206 if (!empty($terms)) {
207 foreach ($terms as $term) {
208 if(isset($term->term_id) && isset($term->name)) {
209 $selected = ($selected_term == $term->term_id) ? "selected" : "";
210 $string .= "<option " . esc_attr($selected) . " value='" . esc_attr($term->term_id) . "'>" . esc_attr($space) . esc_attr($term->name) . "</option>";
211 $string .= self::get_folder_option_data($postType, $term->term_id, trim($space) . "- ");
212 }
213 }
214 }
215
216 return $string;
217
218 }//end get_folder_option_data()
219
220
221 }//end class
222