PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 2.8.16
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v2.8.16
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 2.8.16, at includes/core/shortcodes/class-wpfnl-shortcode-optin.php

131 lines 3.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' => false,
56 'last_name' => false,
57 'phone' => false,
58 'website_url' => false,
59 'message' => false,
60 'data_to_checkout' => false,
61 'acceptance_checkbox' => false,
62 'notification_text' => '',
63 'post_action' => '',
64 'redirect_url' => '',
65 'admin_email' => wp_get_current_user()->user_email,
66 'admin_email_subject' => 'Opt-in form submission',
67 'btn_class' => '',
68 'register_as_subscriber' => false,
69 'subscription_permission' => false,
70 'subscription_permission_text' => '',
71 'first_name_label' => '',
72 'last_name_label' => '',
73 'email_label' => '',
74 'phone_label' => '',
75 'website_url_label' => '',
76 'message_label' => '',
77 'first_name_placeholder' => 'First Name',
78 'last_name_placeholder' => 'Last Name',
79 'email_placeholder' => 'Email',
80 'phone_placeholder' => 'Phone',
81 'website_url_placeholder' => 'Website Url',
82 'message_placeholder' => 'Write your message here...',
83 ),
84 $attributes
85 );
86 return $attributes;
87 }
88
89 /**
90 * Get wrapper classes
91 *
92 * @return array
93 */
94 protected function get_wrapper_classes() {
95 $classes = array( 'wpfnl', 'wpfnl-optin-form-wrapper', 'wpfnl-shortcode-optin-form-wrapper');
96 return $classes;
97 }
98
99
100 /**
101 * Content of optin form
102 *
103 * @return string
104 */
105 public function get_content() {
106 $classes = $this->get_wrapper_classes();
107 $recaptcha_setting = Wpfnl_functions::get_recaptcha_settings();
108 $is_recaptch = isset($recaptcha_setting['enable_recaptcha']) ? $recaptcha_setting['enable_recaptcha'] : '';
109 $site_key = isset($recaptcha_setting['recaptcha_site_key']) ? $recaptcha_setting['recaptcha_site_key'] : '';
110 $site_secret_key = isset($recaptcha_setting['recaptcha_site_secret']) ? $recaptcha_setting['recaptcha_site_secret'] : '';
111 $token_input = '';
112 $recaptch_script = '';
113 $is_recaptch_input = '';
114 $token_secret_key = '';
115 if('on' == $is_recaptch && '' != $site_key && '' != $site_secret_key){
116 $is_recaptch_input = '<input type="hidden" id="wpf-is-recapcha" name="wpf-is-recapcha" value="'.$is_recaptch.'"/>';
117 $token_input = '<input type="hidden" id="wpf-optin-g-token" name="wpf-optin-g-token" />';
118 $token_secret_key = '<input type="hidden" id="wpf-optin-g-secret-key" name="wpf-optin-g-secret-key" value="'.$site_secret_key.'" />';
119 $recaptch_script = '<script src="https://www.google.com/recaptcha/api.js?render='.$site_key.'"></script>';
120 }
121 ob_start();
122 do_action( 'wpfunnels/before_optin_form' );
123 require_once WPFNL_DIR.'/includes/core/shortcodes/templates/optin/form.php';
124 do_action( 'wpfunnels/after_optin_form' );
125 return '<div class="' . esc_attr( implode( ' ', $classes ) ) . '">' . ob_get_clean() . '</div>';
126 }
127
128
129
130 }
131