PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.12.13
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.12.13
3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 All 261 releases
wpfunnels / includes / core / shortcodes / class-wpfnl-shortcode-optin.php

class-wpfnl-shortcode-optin.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.12.13, at includes/core/shortcodes/class-wpfnl-shortcode-optin.php

177 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Optin shortcode class
4 *
5 * @package
6 */
7 namespace WPFunnels\Shortcodes;
8
9
10 use ElementorPro\Modules\Forms\Module;
11 use ElementorPro\Plugin;
12 use WPFunnels\Wpfnl_functions;
13
14 class WC_Shortcode_Optin {
15
16 /**
17 * Attributes
18 *
19 * @var array
20 */
21 protected $attributes = array();
22
23
24 /**
25 * WC Shortcode Optin constructor.
26 *
27 * @param array $attributes
28 */
29 public function __construct( $attributes = array() ) {
30 $this->attributes = $this->parse_attributes( $attributes );
31 }
32
33
34 /**
35 * Get shortcode attributes.
36 *
37 * @since 3.2.0
38 * @return array
39 */
40 public function get_attributes() {
41 return $this->attributes;
42 }
43
44
45 /**
46 * Parse attributes
47 *
48 * @param $attributes
49 *
50 * @return array
51 */
52 protected function parse_attributes( $attributes ) {
53 $attributes = shortcode_atts(
54 array(
55 // First Name Customization Attributes.
56 'first_name' => false,
57 'first_name_label' => '',
58 'first_name_placeholder' => 'First Name',
59 'first_name_required' => false,
60 'first_name_icon_url' => WPFNL_DIR_URL . '/public/assets/images/user-icon.svg',
61 'first_name_autocomplete' => '',
62 // Last Name Customization Attributes.
63 'last_name' => false,
64 'last_name_label' => '',
65 'last_name_placeholder' => 'Last Name',
66 'last_name_required' => false,
67 'last_name_icon_url' => WPFNL_DIR_URL . '/public/assets/images/user-icon.svg',
68 'last_name_autocomplete' => '',
69 // Phone Number Customization Attributes.
70 'phone' => false,
71 'phone_label' => '',
72 'phone_placeholder' => 'Phone',
73 'phone_required' => false,
74 'phone_icon_url' => WPFNL_DIR_URL . '/public/assets/images/phone.svg',
75 'phone_autocomplete' => '',
76 // Website URL Customization Attributes.
77 'website_url' => false,
78 'website_url_label' => '',
79 'website_url_placeholder' => 'Website Url',
80 'website_url_required' => false,
81 'website_url_icon_url' => WPFNL_DIR_URL . '/public/assets/images/web-url.svg',
82 'website_url_autocomplete' => '',
83 // Email Customization Attributes.
84 'email_label' => '',
85 'email_placeholder' => 'Email',
86 'show_required_mark' => false,
87 'email_icon_url' => WPFNL_DIR_URL . '/public/assets/images/email-open-icon.svg',
88 'show_input_fields_icon' => 'true',
89 // Message Customization Attributes.
90 'message' => false,
91 'message_label' => '',
92 'message_placeholder' => 'Write your message here...',
93 'message_required' => false,
94 'data_to_checkout' => false,
95 // Acceptance Checkbox Customization Attributes.
96 'acceptance_checkbox' => false,
97 'acceptance_checkbox_text' => 'I have read and agree the Terms & Condition.',
98 'acceptance_checkbox_required' => false,
99 'notification_text' => '',
100 'post_action' => '',
101 'redirect_url' => '',
102 'admin_email' => wp_get_current_user()->user_email,
103 'admin_email_subject' => 'Opt-in form submission',
104 'register_as_subscriber' => false,
105 'subscription_permission' => false,
106 'subscription_permission_text' => '',
107 'enable_mm_contact' => 'no',
108 'mm_contact_status' => 'pending',
109 'mm_lists' => '',
110 'mm_tags' => '',
111 // Submit Button Customization Attributes.
112 'btn_class' => '',
113 'button_text' => 'Submit',
114 'button_text_color' => '',
115 'button_bg_color' => '',
116 'button_hover_color' => '',
117 'button_hover_text_color' => '',
118 'button_border_radius' => '',
119 'button_font_size' => '',
120 'button_font_weight' => '',
121 'button_padding' => '',
122 'button_width' => '',
123 'button_icon' => '',
124 'button_icon_position' => 'before',
125 'button_id' => '',
126 'button_style' => '',
127 'button_align' => 'center',
128 'button_loader_type' => 'default',
129 ),
130 $attributes
131 );
132 return $attributes;
133 }
134
135 /**
136 * Get wrapper classes
137 *
138 * @return array
139 */
140 protected function get_wrapper_classes() {
141 $classes = array( 'wpfnl', 'wpfnl-optin-form-wrapper', 'wpfnl-shortcode-optin-form-wrapper');
142 return $classes;
143 }
144
145
146 /**
147 * Content of optin form
148 *
149 * @return string
150 */
151 public function get_content() {
152 $classes = $this->get_wrapper_classes();
153 $recaptcha_setting = Wpfnl_functions::get_recaptcha_settings();
154 $is_recaptch = isset($recaptcha_setting['enable_recaptcha']) ? $recaptcha_setting['enable_recaptcha'] : '';
155 $site_key = isset($recaptcha_setting['recaptcha_site_key']) ? $recaptcha_setting['recaptcha_site_key'] : '';
156 $site_secret_key = isset($recaptcha_setting['recaptcha_site_secret']) ? $recaptcha_setting['recaptcha_site_secret'] : '';
157 $token_input = '';
158 $recaptch_script = '';
159 $is_recaptch_input = '';
160 $token_secret_key = '';
161 if('on' == $is_recaptch && '' != $site_key && '' != $site_secret_key){
162 $is_recaptch_input = '<input type="hidden" id="wpf-is-recapcha" name="wpf-is-recapcha" value="'.$is_recaptch.'"/>';
163 $token_input = '<input type="hidden" id="wpf-optin-g-token" name="wpf-optin-g-token" />';
164 $token_secret_key = '<input type="hidden" id="wpf-optin-g-secret-key" name="wpf-optin-g-secret-key" value="'.$site_secret_key.'" />';
165 $recaptch_script = '<script src="https://www.google.com/recaptcha/api.js?render='.$site_key.'"></script>';
166 }
167 ob_start();
168 do_action( 'wpfunnels/before_optin_form' );
169 require WPFNL_DIR.'/includes/core/shortcodes/templates/optin/form.php';
170 do_action( 'wpfunnels/after_optin_form' );
171 return '<div class="' . esc_attr( implode( ' ', $classes ) ) . '">' . ob_get_clean() . '</div>';
172 }
173
174
175
176 }
177