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