PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.8.2
Kubio AI Page Builder v2.8.2
2.8.4 2.8.3 2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / lib / shortcodes / contact-form / index.php
kubio / lib / shortcodes / contact-form Last commit date
forminator-filters.php 4 years ago index.php 1 year ago wpforms-filters.php 1 year ago
index.php
118 lines
1 <?php
2
3 use Kubio\Core\Utils;
4
5 require __DIR__ . '/wpforms-filters.php';
6 require_once __DIR__ . '/forminator-filters.php';
7
8 add_shortcode( 'kubio_contact_form', 'kubio_contact_form_shortcode' );
9
10
11 function kubio_shortcode_is_kubio_contact_form( $shortcode ) {
12 return strpos( $shortcode, 'kubio_contact_form' ) !== false;
13 }
14
15
16 function kubio_forminator_create_sample_form() {
17 $can_create_sample = apply_filters( 'kubio_create_forminator_sample_form', true );
18 if ( $can_create_sample && class_exists( '\Forminator_Template_Contact_Form' ) && class_exists( '\Forminator_API' ) ) {
19 try {
20 $template = new \Forminator_Template_Contact_Form();
21 \Forminator_API::add_form( 'Kubio Contact Form', $template->fields(), $template->settings() );
22 } catch ( \Exception $e ) {
23 }
24 }
25 }
26
27 function kubio_get_kubio_contact_form_shortcode( $shortcode ) {
28
29 $matches_found = preg_match( '/shortcode="(.+)"/', $shortcode, $matches );
30 if ( ! $matches_found ) {
31 return null;
32 }
33 $inner_shortcode = $matches[1];
34
35 return Utils::shortcodeDecode( $inner_shortcode );
36 }
37
38 function kubio_contact_form_shortcode( $atts ) {
39
40 $atts = shortcode_atts(
41 array(
42 'shortcode' => '',
43 'use_shortcode_style' => '0',
44 'decode_data' => '1',
45 ),
46 $atts
47 );
48 if ( $atts['decode_data'] == '1' ) {
49 $atts['shortcode'] = Utils::shortcodeDecode( $atts['shortcode'] );
50 }
51
52 //stripslashes is fix for https://mantis.iconvert.pro//view.php?id=38520
53 $shortcode = stripslashes( $atts['shortcode'] );
54 $shortcode = wp_kses_post( $shortcode );
55 $shortcodeHtml = '';
56 if ( shortcode_render_can_apply_forminator_filters( $shortcode ) ) {
57 if ( kubio_forminator_is_auth_form( $shortcode ) ) {
58 $shortcodeHtml = kubio_forminator_get_auth_placeholder();
59 }
60 if ( $atts['use_shortcode_style'] == '0' ) {
61 $shortcodeHtml = kubio_forminator_form_shortcode( $shortcode );
62 } else {
63 $shortcodeHtml = do_shortcode( $shortcode );
64 }
65 } else {
66 $shortcodeHtml = do_shortcode( $shortcode );
67 }
68 if ( ! $shortcodeHtml ) {
69 $shortcodeHtml = Utils::getEmptyShortcodePlaceholder();
70 }
71
72 return $shortcodeHtml;
73 }
74
75
76 function kubio_forminator_get_auth_placeholder() {
77 return '<p class="shortcode-placeholder-preview">Forminator\'s login and register forms are not visible if you are logged in</p>';
78 }
79
80 function kubio_forminator_is_auth_form( $shortcode ) {
81 $id_found = preg_match( '/id="(\d+)"/', $shortcode, $matches );
82 if ( ! $id_found ) {
83 return false;
84 }
85 $form_id = $matches[1];
86 $form_class = null;
87
88 //old
89 if ( class_exists( '\Forminator_Custom_Form_Model' ) ) {
90 $form_class = '\Forminator_Custom_Form_Model';
91 }
92 //new
93 if ( class_exists( '\Forminator_Form_Model' ) ) {
94 $form_class = '\Forminator_Form_Model';
95 }
96
97 if ( ! $form_class ) {
98 return false;
99 }
100 try {
101 $model = $form_class::model()->load( $form_id );
102 if ( ! $model ) {
103 return false;
104 }
105
106 return in_array( $model->settings['form-type'], array( 'login', 'registration' ) );
107 } catch ( \Exception $e ) {
108 return false;
109 }
110 }
111
112 function kubio_forminator_form_shortcode( $shortcode ) {
113
114 $html = do_shortcode( $shortcode );
115
116 return $html;
117 }
118