PluginProbe
Commerce7 for WordPress / trunk
Commerce7 for WordPress vtrunk
1.8.1 1.8.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.3 1.2.0 1.2.1 1.2.2 1.2.3 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.3.4 1.3.5 1.4.0 1.4.1 All 37 releases
wp-commerce7 / includes / elementor / elementor-loginform.php

elementor-loginform.php in Commerce7 for WordPress trunk, at includes/elementor/elementor-loginform.php

215 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Elementor widget:
4 *
5 * Created Date: Wednesday September 2nd 2020
6 * Author: Michael Bourne
7 * -----
8 * Last Modified: Thursday, January 9th 2025, 1:50:49 pm
9 * Modified By: Michael Bourne
10 * -----
11 * Copyright (c) 2020 URSA6
12 *
13 * @package wp-commerce7
14 * @author Michael Bourne
15 * @license GPL3
16 * @link https://ursa6.com
17 * @since 1.0.8
18 */
19
20 if ( ! defined( 'ABSPATH' ) ) {
21 return;
22 }
23
24
25 /**
26 * Create Account Widget class
27 */
28 class C7WP_Elementor_Loginform extends \Elementor\Widget_Base {
29
30
31 /**
32 * Get widget name.
33 *
34 * Retrieve Commerce7 widget name.
35 *
36 * @since 1.0.0
37 * @access public
38 *
39 * @return string Widget name.
40 */
41 public function get_name() {
42 return 'commerce7-loginform';
43 }
44
45 /**
46 * Get widget title.
47 *
48 * Retrieve Commerce7 widget title.
49 *
50 * @since 1.0.0
51 * @access public
52 *
53 * @return string Widget title.
54 */
55 public function get_title() {
56 return __( 'Login Form', 'wp-commerce7' );
57 }
58
59 /**
60 * Get widget icon.
61 *
62 * Retrieve Commerce7 widget icon.
63 *
64 * @since 1.0.0
65 * @access public
66 *
67 * @return string Widget icon.
68 */
69 public function get_icon() {
70 return 'c7icon-c7sm';
71 }
72
73 /**
74 * Get widget categories.
75 *
76 * Retrieve the list of categories the widget belongs to.
77 *
78 * @since 1.0.0
79 * @access public
80 *
81 * @return array Widget categories.
82 */
83 public function get_categories() {
84 return [ 'commerce7' ];
85 }
86
87 /**
88 * Retrieve widget keywords.
89 *
90 * @since 1.0.0
91 * @access public
92 *
93 * @return array Widget keywords.
94 */
95 public function get_keywords() {
96 return [ 'commerce7', 'login' ];
97 }
98
99 /**
100 * Register widget controls.
101 *
102 * Adds different input fields to allow the user to change and customize the widget settings.
103 *
104 * @since 1.0.0
105 * @access protected
106 */
107 protected function register_controls() { // phpcs:ignore
108
109 $this->start_controls_section(
110 'content_section',
111 [
112 'label' => __( 'Settings', 'wp-commerce7' ),
113 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
114 ]
115 );
116
117 $this->add_control(
118 'preview_notice',
119 [
120 'type' => \Elementor\Controls_Manager::RAW_HTML,
121 'raw' => '<div style="background: #fff3cd; border: 1px solid #ffeaa7; padding: 10px; border-radius: 4px; margin-bottom: 15px;"><strong>Preview Notice:</strong> The preview shown in your editor is for example purposes only, it does not reflect the redirect path you provide nor is it interactive.</div>',
122 'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
123 ]
124 );
125
126 $this->add_control(
127 'data',
128 [
129 'label' => __( 'Redirect To Path', 'wp-commerce7' ),
130 'type' => \Elementor\Controls_Manager::TEXT,
131 'placeholder' => __( '/profile', 'wp-commerce7' ),
132 ]
133 );
134
135 $this->end_controls_section();
136
137 }
138
139 /**
140 * Render Commerce widget output on the frontend.
141 *
142 * Written in PHP and used to generate the final HTML.
143 *
144 * @since 1.0.0
145 * @access protected
146 */
147 protected function render() {
148
149 $settings = $this->get_settings_for_display();
150
151 $data = esc_attr( $settings['data'] );
152
153 // Show preview in Elementor editor, shortcode on frontend
154 if ( \Elementor\Plugin::$instance->editor->is_edit_mode() || \Elementor\Plugin::$instance->preview->is_preview_mode() ) {
155 ?>
156 <div id="c7-login-form-placeholder" data-redirect-to="<?php echo esc_attr( $data ); ?>">
157 <form class="c7-form c7-form--login" data-sku="<?php echo esc_attr( $data ); ?>">
158 <div class="c7-form__field">
159 <label class="c7-required">Email</label>
160 <input name="email" tabindex="-1" disabled type="text">
161 </div>
162 <div class="c7-form__field">
163 <label class="c7-required">Password</label>
164 <input name="password" tabindex="-1" disabled type="password">
165 </div>
166 <div class="c7-form__buttons c7-form__buttons--wide">
167 <button type="submit" tabindex="-1" disabled class="c7-btn c7-btn--primary">
168 <span>Log in</span>
169 </button>
170 </div>
171 </form>
172 </div>
173 <?php
174 } else {
175 // Frontend - show actual shortcode
176 echo do_shortcode( '[c7wp type="loginform" data="' . $data . '"]' );
177 }
178
179 }
180
181 /**
182 * Render widget output in the editor.
183 *
184 * Written as a Backbone JavaScript template and used to generate the live preview.
185 *
186 * @since 1.0.0
187 * @access protected
188 */
189 protected function content_template() {
190 ?>
191 <#
192 var slugProvided = settings.data && settings.data.length > 0;
193 #>
194 <div id="c7-login-form-placeholder" data-redirect-to="{{{ settings.data }}}">
195 <form class="c7-form c7-form--login" data-sku="{{{ settings.data }}}">
196 <div class="c7-form__field">
197 <label class="c7-required">Email</label>
198 <input name="email" tabindex="-1" disabled type="text">
199 </div>
200 <div class="c7-form__field">
201 <label class="c7-required">Password</label>
202 <input name="password" tabindex="-1" disabled type="password">
203 </div>
204 <div class="c7-form__buttons c7-form__buttons--wide">
205 <button type="submit" tabindex="-1" disabled class="c7-btn c7-btn--primary">
206 <span>Log in</span>
207 </button>
208 </div>
209 </form>
210 </div>
211 <?php
212 }
213 public function render_plain_content( $instance = [] ) {}
214
215 }