PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution / 1.0.0
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution v1.0.0
4.9.2 4.9.1 4.9.0 2.0.0 2.1.0 2.2.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.0 2.5.1 3.0.0 3.1.0 3.1.1 4.0.0 4.0.1 4.1.0 4.1.1 4.2.0 4.2.1 4.3.0 4.3.1 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.6.7 4.6.8 4.6.9 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.7.5 4.7.6 4.7.7 4.7.8 4.7.9 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5 4.8.6 4.8.7 4.8.8 4.8.9 trunk 0.1.2-beta 0.1.3-beta 0.1.4-beta 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.5.0 1.5.1 1.6.0 1.6.1 1.7.0 1.8.0 1.8.1 1.9.0
shopengine / core / elementor-controls / ajax-select2-api.php
shopengine / core / elementor-controls Last commit date
assets 5 years ago ajax-select2-api.php 5 years ago ajax-select2.php 5 years ago control-manager.php 5 years ago image-choose.php 5 years ago init.php 5 years ago
ajax-select2-api.php
199 lines
1 <?php
2 namespace ShopEngine\Core\Elementor_Controls;
3
4 defined( 'ABSPATH' ) || exit;
5
6 class Controls_Ajax_Select2_Api extends \ShopEngine\Base\Api {
7
8 public function config(){
9 $this->prefix = 'ajaxselect2';
10 }
11
12
13 public function get_post_list(){
14
15 if(!current_user_can('edit_posts')){
16 return;
17 }
18
19 $query_args = [
20 'post_type' => 'post',
21 'post_status' => 'publish',
22 'posts_per_page' => 15,
23 ];
24
25 if(isset($this->request['ids'])){
26 $ids = explode(',', $this->request['ids']);
27 $query_args['post__in'] = $ids;
28 }
29 if(isset($this->request['s'])){
30 $query_args['s'] = $this->request['s'];
31 }
32
33 $query = new \WP_Query($query_args);
34 $options = [];
35 if($query->have_posts()):
36 while ($query->have_posts()) {
37 $query->the_post();
38 $options[] = [ 'id' => get_the_ID(), 'text' => get_the_title() ];
39 }
40 endif;
41
42 return ['results' => $options];
43 wp_reset_postdata();
44 }
45
46 public function get_page_list(){
47 if(!current_user_can('edit_posts')){
48 return;
49 }
50 $query_args = [
51 'post_type' => 'page',
52 'post_status' => 'publish',
53 'posts_per_page' => 15,
54 ];
55
56 if(isset($this->request['ids'])){
57 $ids = explode(',', $this->request['ids']);
58 $query_args['post__in'] = $ids;
59 }
60 if(isset($this->request['s'])){
61 $query_args['s'] = $this->request['s'];
62 }
63
64 $query = new \WP_Query($query_args);
65 $options = [];
66 if($query->have_posts()):
67 while ($query->have_posts()) {
68 $query->the_post();
69 $options[] = [ 'id' => get_the_ID(), 'text' => get_the_title() ];
70 }
71 endif;
72
73 return ['results' => $options];
74 wp_reset_postdata();
75 }
76
77 public function get_singular_list(){
78 $query_args = [
79 'post_status' => 'publish',
80 'posts_per_page' => 15,
81 'post_type' => 'any'
82 ];
83
84 if(isset($this->request['ids'])){
85 $ids = explode(',', $this->request['ids']);
86 $query_args['post__in'] = $ids;
87 }
88 if(isset($this->request['s'])){
89 $query_args['s'] = $this->request['s'];
90 }
91
92 $query = new \WP_Query($query_args);
93 $options = [];
94 if($query->have_posts()):
95 while ($query->have_posts()) {
96 $query->the_post();
97 $options[] = [ 'id' => get_the_ID(), 'text' => get_the_title() ];
98 }
99 endif;
100
101 return ['results' => $options];
102 wp_reset_postdata();
103 }
104
105 public function get_category(){
106
107 $taxonomy = 'category';
108 $query_args = [
109 'taxonomy' => ['category'], // taxonomy name
110 'orderby' => 'name',
111 'order' => 'DESC',
112 'hide_empty' => true,
113 'number' => 10
114 ];
115
116 if(isset($this->request['ids'])){
117 $ids = explode(',', $this->request['ids']);
118 $query_args['include'] = $ids;
119 }
120 if(isset($this->request['s'])){
121 $query_args['name__like'] = $this->request['s'];
122 }
123
124 $terms = get_terms( $query_args );
125
126
127 $options = [];
128
129 if(is_countable($terms) && count($terms) > 0):
130
131 foreach ($terms as $term) {
132 $options[] = [ 'id' => $term->term_id, 'text' => $term->name ];
133 }
134 endif;
135 return ['results' => $options];
136 }
137
138 public function get_product_list(){
139 $query_args = [
140 'post_type' => 'product',
141 'post_status' => 'publish',
142 'posts_per_page' => 15,
143 ];
144
145 if(isset($this->request['ids'])){
146 $ids = explode(',', $this->request['ids']);
147 $query_args['post__in'] = $ids;
148 }
149 if(isset($this->request['s'])){
150 $query_args['s'] = $this->request['s'];
151 }
152
153 $query = new \WP_Query($query_args);
154 $options = [];
155 if($query->have_posts()):
156 while ($query->have_posts()) {
157 $query->the_post();
158 $options[] = [ 'id' => get_the_ID(), 'text' => get_the_title() ];
159 }
160 endif;
161
162 return ['results' => $options];
163 wp_reset_postdata();
164 }
165
166 public function get_product_cat(){
167 $query_args = [
168 'taxonomy' => ['product_cat'], // taxonomy name
169 'orderby' => 'name',
170 'order' => 'DESC',
171 'hide_empty' => false,
172 'number' => 6
173 ];
174
175 if(isset($this->request['ids'])){
176 $ids = explode(',', $this->request['ids']);
177 $query_args['include'] = $ids;
178 }
179 if(isset($this->request['s'])){
180 $query_args['name__like'] = $this->request['s'];
181 }
182
183 $terms = get_terms( $query_args );
184
185
186 $options = [];
187
188 if(is_countable($terms) && count($terms) > 0):
189 foreach ($terms as $term) {
190 $options[] = [ 'id' => $term->term_id, 'text' => $term->name ];
191 }
192 endif;
193
194 return ['results' => $options];
195 }
196 }
197
198 new Controls_Ajax_Select2_Api();
199