PluginProbe ʕ •ᴥ•ʔ
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 4.0.0
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v4.0.0
4.0.2 4.0.1 4.0.0 3.10.02 3.10.01 3.9.10 3.9.9 3.9.8 3.9.7 3.9.5 3.9.6 3.9.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.3.1 2.3.1.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.4.0 2.5.0 2.5.1 2.5.10 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.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.2 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.6.0 3.6.1 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8.0 3.8.1 3.8.2 3.9.0 3.9.1 3.9.2 trunk 1.2.6 1.2.7 1.2.9 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.11 1.5.12 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.0.9.1 2.0.9.2 2.0.9.3
elementskit-lite / modules / widget-builder / api / common.php
elementskit-lite / modules / widget-builder / api Last commit date
common.php 3 weeks ago
common.php
126 lines
1 <?php
2 namespace ElementsKit_Lite\Modules\Widget_Builder\Api;
3
4 defined( 'ABSPATH' ) || exit;
5
6 class Common extends \ElementsKit_Lite\Core\Handler_Api {
7
8 public function config() {
9 $this->prefix = 'widget-builder';
10 $this->param = '/(?P<id>\w+(|[-]\w+))/';
11 }
12
13 private function fix_title( $title ) {
14 return ( $title == '' ) ? ( 'ElementsKit_Lite Custom Widget #' . time() ) : $title;
15 }
16
17 private function current_user_can_save_widget() {
18 return is_user_logged_in() && current_user_can( 'manage_options' ) && ( ! is_multisite() || is_super_admin() );
19 }
20
21 public function post_push() {
22
23 if ( ! $this->current_user_can_save_widget() ) {
24
25 return array(
26 'success' => false,
27 'message' => array(
28 esc_html__( 'Not enough permission.', 'elementskit-lite' ),
29 ),
30 );
31 }
32
33 $id = $this->request['id'];
34 $data = json_decode( $this->request['data'] );
35
36 if ( ! property_exists( $data, 'title' ) || ! property_exists( $data, 'tabs' ) || ! ( $data->tabs instanceof \stdClass ) ) {
37 return array(
38 'success' => false,
39 'message' => array(
40 esc_html__( 'Invalid data.', 'elementskit-lite' ),
41 ),
42 );
43 }
44
45 $title = $this->fix_title( $data->title );
46
47 $widget_data = array(
48 'post_title' => $title,
49 'post_status' => 'publish',
50 'post_type' => 'elementskit_widget',
51 );
52
53 $widget = get_post( $id );
54
55 if ( $widget == null ) {
56 $id = wp_insert_post( $widget_data );
57 } else {
58 $widget_data['ID'] = $id;
59 wp_update_post( $widget_data );
60 }
61 update_post_meta( $id, '_elementor_edit_mode', 'builder' );
62 update_post_meta( $id, '_wp_page_template', 'elementor_canvas' );
63
64 $data->push_id = $id;
65
66 //update_post_meta( $id, '_wp_page_template', 'elementor_canvas' );
67 update_post_meta( $id, 'elementskit_custom_widget_data', $data );
68 \ElementsKit_Lite\Modules\Widget_Builder\Widget_File::instance()->create( $data, $id );
69
70 return array(
71 'success' => true,
72 'message' => array(
73 esc_html__( 'Widget data saved!', 'elementskit-lite' ),
74 ),
75 'push_id' => $id,
76 );
77 }
78
79 public function post_pull() {
80
81 if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
82
83 return array(
84 'success' => false,
85 'message' => array(
86 esc_html__( 'Not enough permission.', 'elementskit-lite' ),
87 ),
88 );
89 }
90
91 $id = $this->request['id'];
92 $default = array(
93 'title' => 'New Widget',
94 'icon' => 'eicon-cog',
95 'categories' => array( 'basic' ),
96 'push_id' => $id,
97 'markup' => '',
98 'css' => '',
99 'js' => '',
100 'css_includes' => '',
101 'js_includes' => '',
102 'tabs' => array(
103 'content' => array(),
104 'style' => array(),
105 'advanced' => array(),
106 ),
107 );
108
109 $widget_data = get_post_meta( $id, 'elementskit_custom_widget_data', true );
110
111 return is_object( $widget_data ) ? $widget_data : $default;
112 }
113
114
115 public function post_import() {
116
117 //$id = $this->request['id'];
118
119 return array(
120 'success' => true,
121 'message' => 'hi',
122 //'file' => $this->request
123 );
124 }
125 }
126