PluginProbe ʕ •ᴥ•ʔ
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 4.0.1
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v4.0.1
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 / header-footer / cpt-api.php
elementskit-lite / modules / header-footer Last commit date
assets 3 weeks ago theme-hooks 4 years ago views 1 year ago activator.php 2 years ago cpt-api.php 4 years ago cpt-hooks.php 2 years ago cpt.php 1 year ago init.php 3 weeks ago
cpt-api.php
118 lines
1 <?php
2 namespace ElementsKit_Lite;
3
4 defined( 'ABSPATH' ) || exit;
5
6 class ElementsKit_HeaderFooterBuilder_Api extends Core\Handler_Api {
7
8 public function config() {
9 $this->prefix = 'my-template';
10 $this->param = '/(?P<id>\w+)/';
11 }
12
13 public function get_update() {
14
15 if ( ! current_user_can( 'manage_options' ) ) {
16 return;
17 }
18
19 $id = $this->request['id'];
20 $open_editor = $this->request['open_editor'];
21
22 $title = ( $this->request['title'] == '' ) ? ( 'ElementsKit_Lite Template #' . time() ) : $this->request['title'];
23 $activation = $this->request['activation'];
24 $type = $this->request['type'];
25 $condition_a = ( $type == 'section' ) ? '' : $this->request['condition_a'];
26 $condition_singular = ( $type == 'section' ) ? '' : $this->request['condition_singular'];
27 $condition_singular_id = ( $type == 'section' ) ? '' : ( is_array( $this->request['condition_singular_id'] ) ? implode( ',', $this->request['condition_singular_id'] ) : $this->request['condition_singular_id'] );
28
29 $post_data = array(
30 'post_title' => $title,
31 'post_status' => 'publish',
32 'post_type' => 'elementskit_template',
33 );
34
35 $post = get_post( $id );
36
37 if ( $post == null ) {
38 // $post_data['post_author'] = $this->request['post_author'];
39 $id = wp_insert_post( $post_data );
40 } else {
41 $post_data['ID'] = $id;
42 wp_update_post( $post_data );
43 }
44
45 update_post_meta( $id, '_wp_page_template', 'elementor_canvas' );
46 update_post_meta( $id, 'elementskit_template_activation', $activation );
47 update_post_meta( $id, 'elementskit_template_type', $type );
48 update_post_meta( $id, 'elementskit_template_condition_a', $condition_a );
49 update_post_meta( $id, 'elementskit_template_condition_singular', $condition_singular );
50 update_post_meta( $id, 'elementskit_template_condition_singular_id', $condition_singular_id );
51
52 // if wpml is active and wpml not set for this post
53 if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
54 global $sitepress;
55 $wpml_element_type = apply_filters( 'wpml_element_type', 'elementskit_template' );
56 $sitepress->set_element_language_details( $id, $wpml_element_type, false, $sitepress->get_current_language(), null, false );
57 }
58
59 if ( $open_editor == 'true' ) {
60 $url = get_admin_url() . '/post.php?post=' . $id . '&action=elementor';
61 wp_safe_redirect( $url );
62 exit;
63 } else {
64 $cond = ucwords(
65 str_replace(
66 '_',
67 ' ',
68 $condition_a
69 . ( ( $condition_a == 'singular' )
70 ? ( ( $condition_singular != '' )
71 ? ( ' > ' . $condition_singular
72 . ( ( $condition_singular_id != '' )
73 ? ' > ' . $condition_singular_id
74 : '' ) )
75 : '' )
76 : '' )
77 )
78 );
79
80 return array(
81 'saved' => true,
82 'data' => array(
83 'id' => $id,
84 'title' => $title,
85 'type' => $type,
86 'activation' => $activation,
87 'cond_text' => $cond,
88 'type_html' => ( ucfirst( $type ) . ( ( $activation == 'yes' )
89 ? ( '<span class="ekit-headerfooter-status ekit-headerfooter-status-active">' . esc_html__( 'Active', 'elementskit-lite' ) . '</span>' )
90 : ( '<span class="ekit-headerfooter-status ekit-headerfooter-status-inactive">' . esc_html__( 'Inactive', 'elementskit-lite' ) . '</span>' ) ) ),
91 ),
92 );
93 }
94 }
95
96 public function get_get() {
97 if ( ! current_user_can( 'manage_options' ) ) {
98 return;
99 }
100 $id = $this->request['id'];
101 $post = get_post( $id );
102 if ( $post != null ) {
103 return array(
104 'title' => $post->post_title,
105 'status' => $post->post_status,
106 'activation' => get_post_meta( $post->ID, 'elementskit_template_activation', true ),
107 'type' => get_post_meta( $post->ID, 'elementskit_template_type', true ),
108 'condition_a' => get_post_meta( $post->ID, 'elementskit_template_condition_a', true ),
109 'condition_singular' => get_post_meta( $post->ID, 'elementskit_template_condition_singular', true ),
110 'condition_singular_id' => get_post_meta( $post->ID, 'elementskit_template_condition_singular_id', true ),
111 );
112 }
113 return true;
114 }
115
116 }
117 new ElementsKit_HeaderFooterBuilder_Api();
118