PluginProbe
Visual Composer Website Builder / 45.16.4
Visual Composer Website Builder v45.16.4
45.16.4 45.16.3 45.16.2 45.16.1 45.2-beta.1 45.2-beta.2 45.2.0 45.3-beta.1 45.3.0 45.4-beta.1 45.4.0 45.4.1 45.4.1-beta.2 45.5-beta.1 45.5.0 45.6-beta.1 45.6.0 45.7-beta.1 45.7.0 45.8-beta.1 45.8.0 45.9.0 trunk 45.0 45.0-beta.1 All 42 releases
visualcomposer / visualcomposer / Helpers / PostsGridSourcePosts.php

PostsGridSourcePosts.php in Visual Composer Website Builder 45.16.4, at visualcomposer/Helpers/PostsGridSourcePosts.php

71 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace VisualComposer\Helpers;
4
5 if (!defined('ABSPATH')) {
6 header('Status: 403 Forbidden');
7 header('HTTP/1.1 403 Forbidden');
8 exit;
9 }
10
11 use VisualComposer\Framework\Container;
12 use VisualComposer\Framework\Illuminate\Support\Helper;
13
14 class PostsGridSourcePosts extends Container implements Helper
15 {
16 public function getPostsCategories()
17 {
18 $args = [
19 'type' => 'post',
20 'child_of' => 0,
21 'parent' => '',
22 'orderby' => 'parent',
23 'order' => 'ASC',
24 'hide_empty' => false,
25 'hierarchical' => 1,
26 'exclude' => '',
27 'include' => '',
28 'number' => '',
29 'taxonomy' => 'category',
30 'pad_counts' => false,
31
32 ];
33 // All this move to product
34 $categories = get_categories($args);
35
36 $result = [
37 [
38 'label' => __('All', 'visualcomposer'),
39 'value' => '',
40 ],
41 ];
42 $this->getCategoryChildsFull(0, 0, $categories, 0, $result);
43
44 return $result;
45 }
46
47 /**
48 * Get lists of categories.*
49 *
50 * @param $parentId
51 * @param $pos
52 * @param array $array
53 * @param $level
54 * @param array $dropdown - passed by reference
55 */
56 protected function getCategoryChildsFull($parentId, $pos, $array, $level, &$dropdown)
57 {
58 for ($i = $pos; $i < count($array); $i++) {
59 if ($array[ $i ]->category_parent == $parentId) {
60 $name = str_repeat('- ', $level) . $array[ $i ]->name;
61 $value = $array[ $i ]->term_id;
62 $dropdown[] = [
63 'label' => $name,
64 'value' => $value,
65 ];
66 $this->getCategoryChildsFull($array[ $i ]->term_id, $i, $array, $level + 1, $dropdown);
67 }
68 }
69 }
70 }
71