PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 1.6.4
Kubio AI Page Builder v1.6.4
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 4 years ago wpforms-filters.php 4 years ago
index.php
120 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 $createForminatorSampleForm = apply_filters( 'kubio_create_forminator_sample_form', true );
18 if ( $createForminatorSampleForm && 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
28 function kubio_get_kubio_contact_form_shortcode( $shortcode ) {
29
30 $matches_found = preg_match( '/shortcode="(.+)"/', $shortcode, $matches );
31 if ( ! $matches_found ) {
32 return null;
33 }
34 $inner_shortcode = $matches[1];
35
36 return Utils::shortcodeDecode( $inner_shortcode );
37
38 }
39
40 function kubio_contact_form_shortcode( $atts ) {
41
42 $atts = shortcode_atts(
43 array(
44 'shortcode' => '',
45 'use_shortcode_style' => '0',
46 'decode_data' => '1',
47 ),
48 $atts
49 );
50 if ( $atts['decode_data'] == '1' ) {
51 $atts['shortcode'] = Utils::shortcodeDecode( $atts['shortcode'] );
52 }
53
54 //stripslashes is fix for http://mantis.extendstudio.net/view.php?id=38520
55 $shortcode = stripslashes( $atts['shortcode'] );
56 $shortcodeHtml = '';
57 if ( shortcode_render_can_apply_forminator_filters( $shortcode ) ) {
58 if ( kubio_forminator_is_auth_form( $shortcode ) ) {
59 $shortcodeHtml = kubio_forminator_get_auth_placeholder();
60 }
61 if ( $atts['use_shortcode_style'] == '0' ) {
62 $shortcodeHtml = kubio_forminator_form_shortcode( $shortcode );
63 } else {
64 $shortcodeHtml = do_shortcode( $shortcode );
65 }
66 } else {
67 $shortcodeHtml = do_shortcode( $shortcode );
68 }
69 if ( ! $shortcodeHtml ) {
70 $shortcodeHtml = Utils::getEmptyShortcodePlaceholder();
71 }
72
73 return $shortcodeHtml;
74
75 }
76
77
78 function kubio_forminator_get_auth_placeholder() {
79 return '<p class="shortcode-placeholder-preview">Forminator\'s login and register forms are not visible if you are logged in</p>';
80 }
81
82 function kubio_forminator_is_auth_form( $shortcode ) {
83 $id_found = preg_match( '/id="(\d+)"/', $shortcode, $matches );
84 if ( ! $id_found ) {
85 return false;
86 }
87 $form_id = $matches[1];
88 $form_class = null;
89
90 //old
91 if ( class_exists( '\Forminator_Custom_Form_Model' ) ) {
92 $form_class = '\Forminator_Custom_Form_Model';
93 }
94 //new
95 if ( class_exists( '\Forminator_Form_Model' ) ) {
96 $form_class = '\Forminator_Form_Model';
97 }
98
99 if ( ! $form_class ) {
100 return false;
101 }
102 try {
103 $model = $form_class::model()->load( $form_id );
104 if ( ! $model ) {
105 return false;
106 }
107
108 return in_array( $model->settings['form-type'], array( 'login', 'registration' ) );
109 } catch ( \Exception $e ) {
110 return false;
111 }
112 }
113
114 function kubio_forminator_form_shortcode( $shortcode ) {
115
116 $html = do_shortcode( $shortcode );
117
118 return $html;
119 }
120