PluginProbe
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 4.0.4
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v4.0.4
4.0.4 4.0.3 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 All 183 releases
elementskit-lite / modules / layout-manager / layout-import-api.php
layout-import-api.php
49 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ElementsKit_Lite\Modules\Layout_Manager;
3
4 defined( 'ABSPATH' ) || exit;
5
6 use Elementor\Core\Common\Modules\Ajax\Module as Ajax;
7
8 class Layout_Import_Api {
9 public function __construct() {
10 add_action( 'elementor/ajax/register_actions', array( $this, 'register_ajax_actions' ) );
11 }
12
13 public function register_ajax_actions( Ajax $ajax ) {
14 $ajax->register_ajax_action(
15 'get_elementskit_template_data',
16 function( $data ) {
17 if ( ! current_user_can( 'edit_posts' ) ) {
18 throw new \Exception( 'Access Denied' );
19 }
20
21 if ( ! empty( $data['editor_post_id'] ) ) {
22 $editor_post_id = absint( $data['editor_post_id'] );
23
24 if ( ! get_post( $editor_post_id ) ) {
25 throw new \Exception( esc_html__( 'Post not found', 'elementskit-lite' ) );
26 }
27
28 \Elementor\Plugin::instance()->db->switch_to_post( $editor_post_id );
29 }
30
31 if ( empty( $data['template_id'] ) ) {
32 throw new \Exception( esc_html__( 'Template id missing', 'elementskit-lite' ) );
33 }
34
35 $result = $this->get_template_data( $data );
36
37 return $result;
38 }
39 );
40 }
41
42 private function get_template_data( array $args ) {
43 $source = new Library_Source();
44 $data = $source->get_data( $args );
45 return $data;
46 }
47
48 }
49