PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution / 2.2.2
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution v2.2.2
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 / settings / api.php
shopengine / core / settings Last commit date
screens 4 years ago action.php 4 years ago api.php 4 years ago base.php 4 years ago
api.php
101 lines
1 <?php
2 namespace ShopEngine\Core\Settings;
3
4 use ShopEngine\Core\Register\Model;
5
6 defined('ABSPATH') || exit;
7
8 /**
9 * Class Api
10 *
11 * @package ShopEngine\Core\Builders
12 */
13 class Api extends \ShopEngine\Base\Api {
14
15 public function config() {
16
17 $this->prefix = 'settings';
18 $this->param = "";
19 }
20
21
22 public function post_save() {
23
24 $data = json_decode($this->request->get_body(), true);
25
26 if(!empty($data['widgets'])) {
27
28 Model::source('settings')->set_option('widgets', $data['widgets']);
29 }
30
31 if(!empty($data['modules'])) {
32
33 Model::source('settings')->set_option('modules', $data['modules']);
34 }
35
36 if(!empty($data['userdata'])) {
37
38 Model::source('settings')->set_option('userdata', $data['userdata']);
39 }
40
41 do_action('shopengine/core/settings/on_save');
42
43 return [
44 'status' => 'success',
45 'message' => esc_html__('settings saved successfully.', 'shopengine'),
46 ];
47 }
48
49
50 public function get_fields() {
51 $fields = array_merge(
52 Action::instance()->get_fields(),
53 ['sample_designs' => \ShopEngine\Core\Sample_Designs\Base::instance()->get_designs()]
54 );
55
56 return apply_filters('shopengine/core/settings/return_fields', $fields);
57 }
58
59 public function get_data() {
60 $data = Action::instance()->get_data();
61
62 return apply_filters('shopengine/core/settings/return_data', $data);
63 }
64
65 public function get_categories() {
66
67 $data = $this->request->get_params();
68
69 $query_args = [
70 'taxonomy' => ['product_cat'], // taxonomy name
71 'orderby' => 'name',
72 'order' => 'DESC',
73 'hide_empty' => false,
74 'number' => 10
75 ];
76
77 if(isset($data['only_parent'])){
78 $query_args['parent'] = 0;
79 }
80
81 if(isset($data['ids'])){
82 $ids = explode(',', $data['ids']);
83 $query_args['include'] = $ids;
84 }
85 if(isset($data['s'])){
86 $query_args['name__like'] = $data['s'];
87 }
88
89 $product_cat = get_terms($query_args);
90 $product_categories = [];
91 foreach($product_cat as $category) {
92 $product_categories[$category->term_id] = $category->name;
93 }
94 return [
95 'status' => 'success',
96 'result' => $product_categories,
97 'message' => esc_html__('categories fetched', 'shopengine')
98 ];
99 }
100 }
101