forked from LiveCarta/LiveCartaWP
LAW-5279
This commit is contained in:
24
htdocs/wp-content/plugins/subscribe-to-lc/js/subscribe.js
Normal file
24
htdocs/wp-content/plugins/subscribe-to-lc/js/subscribe.js
Normal file
@@ -0,0 +1,24 @@
|
||||
$(document).ready(function () {
|
||||
$(".lc-subscrive-form").on("submit", function () {
|
||||
var form = $(this)
|
||||
var data = {email: form.find("#subscribe-email").val(), formId: form.find("#subscribe-from-id").val()}
|
||||
$.ajax({
|
||||
url: form.attr('action'),
|
||||
type: 'POST',
|
||||
data: JSON.stringify(data),
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
if (data.success) {
|
||||
msg = "<b>Almost finished...</b><br/><br/>We need to confirm your email address.<br/><br/>To complete the subscription process, please click the link in the email we just sent you."
|
||||
customAlert(msg);
|
||||
}
|
||||
form[0].reset()
|
||||
},
|
||||
error: function (jqXHR) {
|
||||
console.log(jqXHR)
|
||||
}
|
||||
});
|
||||
return false;
|
||||
})
|
||||
});
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
Plugin Name: SubscribeToLc_Widget
|
||||
Description: A plugin subscribe containing form thous sending email to livecarta API
|
||||
Version: 0.1
|
||||
Author: LiveCarta
|
||||
*/
|
||||
|
||||
class SubscribeToLc_Widget extends WP_Widget
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
'subscribe_to_lc_widget',
|
||||
__('Subscribe to lc Widget', 'subscribetolc'),
|
||||
[
|
||||
'classname' => 'subscribetolc_widget',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function widget($args, $instance)
|
||||
{
|
||||
extract($args);
|
||||
if (empty($code)) {
|
||||
return;
|
||||
}
|
||||
|
||||
wp_enqueue_script('subscribe-to-lc-js', plugin_dir_url(__FILE__).'js/subscribe.js');
|
||||
|
||||
?>
|
||||
|
||||
<div id="mc_embed_signup">
|
||||
<form action="<?= LAWCARTA_WP_REST_API_URL.'/subscribe/add-member' ?>" method="post" name="mc-embedded-subscribe-form" class="lc-subscrive-form">
|
||||
<div id="mc_embed_signup_scroll">
|
||||
<input type="email" value="" id="subscribe-email" name="Subscribe[email]" class="email" placeholder="Enter your Email" required>
|
||||
|
||||
<input type="hidden" id="subscribe-from-id" name="Subscribe[formId]" tabindex="-1" value="<?= $code ?>">
|
||||
<input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button xxl mp-top-right">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public function form($instance)
|
||||
{
|
||||
}
|
||||
|
||||
// Updating widget replacing old instances with new
|
||||
public function update($new_instance, $old_instance)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Register the widget */
|
||||
add_action('widgets_init', function () {
|
||||
register_widget('SubscribeToLc_Widget');
|
||||
});
|
||||
Reference in New Issue
Block a user