forked from LiveCarta/LiveCartaWP
1
.gitignore
vendored
1
.gitignore
vendored
@@ -28,5 +28,6 @@ htdocs/wp-content/themes/*
|
||||
!htdocs/wp-content/themes/index.php
|
||||
|
||||
!htdocs/wp-content/plugins/wp-rest-api-event
|
||||
!htdocs/wp-content/plugins/subscribe-to-lc
|
||||
|
||||
vendor/
|
||||
|
||||
3
htdocs/wp-config-local-sample.php
Normal file → Executable file
3
htdocs/wp-config-local-sample.php
Normal file → Executable file
@@ -9,3 +9,6 @@ define('DOMAIN_CURRENT_SITE', 'local_domain_current_site');
|
||||
|
||||
define('LAWCARTA_SUBDOMAIN', 'app');
|
||||
define('LAWCARTA_PORT', '');
|
||||
|
||||
define('LAWCARTA_WP_REST_API_URL', 'http://app.livecarta.loc/v1');
|
||||
define('LAWCARTA_WP_REST_API_EVENT_LOG_URL', 'http://app.livecarta.loc/v1/event/add');
|
||||
|
||||
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');
|
||||
});
|
||||
25
htdocs/wp-content/plugins/wp-rest-api-event/HttpClient.php
Normal file → Executable file
25
htdocs/wp-content/plugins/wp-rest-api-event/HttpClient.php
Normal file → Executable file
@@ -7,6 +7,21 @@ namespace app\wpRestApiEvent;
|
||||
*/
|
||||
class HttpClient
|
||||
{
|
||||
/**
|
||||
* @param string $eventType
|
||||
* @param $data
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public function logEvent(string $eventType, $data)
|
||||
{
|
||||
$data['event'] = [
|
||||
'slug' => $eventType,
|
||||
];
|
||||
|
||||
return $this->doPostRequest(LAWCARTA_WP_REST_API_EVENT_LOG_URL, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return null|string
|
||||
@@ -44,10 +59,12 @@ class HttpClient
|
||||
]);
|
||||
$sysLogId = null;
|
||||
/** @var \WP_HTTP_Requests_Response $httpResponse */
|
||||
$httpResponse = $response['http_response'];
|
||||
if ($httpResponse->get_status() == 200) {
|
||||
$body = isset($response['body']) ? json_decode($response['body'], true) : null;
|
||||
$sysLogId = $body['sysLogId'] ?? null;
|
||||
if(!empty($response['http_response'])){
|
||||
$httpResponse = $response['http_response'];
|
||||
if ($httpResponse->get_status() == 200) {
|
||||
$body = isset($response['body']) ? json_decode($response['body'], true) : null;
|
||||
$sysLogId = $body['sysLogId'] ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
return $sysLogId;
|
||||
|
||||
65
htdocs/wp-content/plugins/wp-rest-api-event/event/EventSubscriber.php
Normal file → Executable file
65
htdocs/wp-content/plugins/wp-rest-api-event/event/EventSubscriber.php
Normal file → Executable file
@@ -49,6 +49,16 @@ class EventSubscriber
|
||||
*/
|
||||
private static $server;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private static $userIp;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private static $sessionId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@@ -56,8 +66,9 @@ class EventSubscriber
|
||||
|
||||
public static function onInit()
|
||||
{
|
||||
add_action('wpcf7_after_flamingo', [self::class, 'onDemoRequest']);
|
||||
apply_filters('parse_request', [self::class, 'onParseRequest']);
|
||||
apply_filters('http_response', [self::class, 'onResponse'], 0);
|
||||
// apply_filters('http_response', [self::class, 'onResponse'], 0);
|
||||
//apply_filters('shutdown', [self::class, 'onResponse'], 0);
|
||||
register_shutdown_function([self::class, 'onShutdown']);
|
||||
apply_filters('pre_http_request', [self::class, 'onRequest'], 0);
|
||||
@@ -89,15 +100,24 @@ class EventSubscriber
|
||||
]));
|
||||
}
|
||||
|
||||
public static function onDemoRequest()
|
||||
{
|
||||
$client = HttpClient::create();
|
||||
$client->logEvent('demo-request', self::getSuperGlobals());
|
||||
}
|
||||
|
||||
public static function setGlobals()
|
||||
{
|
||||
self::$get = $_GET;
|
||||
self::$post = $_POST;
|
||||
self::$cookie = $_COOKIE;
|
||||
self::$session = $_SESSION;
|
||||
self::$env = $_ENV;
|
||||
self::$request = $_REQUEST;
|
||||
self::$server = $_SERVER;
|
||||
self::$get = $_GET;
|
||||
self::$post = $_POST;
|
||||
self::$cookie = $_COOKIE;
|
||||
self::$session = $_SESSION;
|
||||
self::$env = $_ENV;
|
||||
self::$request = $_REQUEST;
|
||||
self::$server = $_SERVER;
|
||||
self::$userIp = self::getTheUserIp();
|
||||
self::$sessionId = $_COOKIE['PHPSESSID'] ?? null;
|
||||
|
||||
|
||||
if (function_exists('getallheaders')) {
|
||||
self::$headers = getallheaders();
|
||||
@@ -112,13 +132,28 @@ class EventSubscriber
|
||||
private static function getSuperGlobals()
|
||||
{
|
||||
return [
|
||||
'request' => self::$request,
|
||||
'server' => self::$server,
|
||||
'get' => self::$get,
|
||||
'post' => self::$post,
|
||||
'cookie' => self::$cookie,
|
||||
'env' => self::$env,
|
||||
'headers' => self::$headers
|
||||
'request' => self::$request,
|
||||
'server' => self::$server,
|
||||
'get' => self::$get,
|
||||
'post' => self::$post,
|
||||
'cookie' => self::$cookie,
|
||||
'env' => self::$env,
|
||||
'headers' => self::$headers,
|
||||
'user_ip' => self::$userIp,
|
||||
'session_id' => self::$sessionId,
|
||||
];
|
||||
}
|
||||
|
||||
private static function getTheUserIp()
|
||||
{
|
||||
if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) {
|
||||
$ip = $_SERVER['HTTP_CLIENT_IP'];
|
||||
} elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
} else {
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
|
||||
return $ip;
|
||||
}
|
||||
}
|
||||
93
htdocs/wp-content/themes/lawcarta/assets/js/customPopups.js
Normal file
93
htdocs/wp-content/themes/lawcarta/assets/js/customPopups.js
Normal file
@@ -0,0 +1,93 @@
|
||||
|
||||
window.customConfirm = function(msg, okCallback, cancelCallback) {
|
||||
|
||||
var confirmHtml = '<div class="modal confirm fade" id="modal-confirm" tabindex="-1" role="dialog" aria-hidden="false">' +
|
||||
'<div class="modal-dialog">' +
|
||||
'<div class="modal-body">' +
|
||||
'<div class="cont">' + msg +'</div>' +
|
||||
'</div>' +
|
||||
'<div class="modal-footer">' +
|
||||
'<div class="cont">' +
|
||||
'<a href="#" class="cancel" id="modal-confirm-cancel">CANCEL</a>' +
|
||||
'<input type="submit" value="Ok" class="button" id="modal-confirm-ok">' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
|
||||
var okCallbackWrap = function(e){
|
||||
e.preventDefault();
|
||||
if (okCallback) okCallback();
|
||||
$('#modal-confirm').modal('hide');
|
||||
};
|
||||
|
||||
var cancelCallbackWrap = function(e){
|
||||
e.preventDefault();
|
||||
if (cancelCallback) cancelCallback();
|
||||
$('#modal-confirm').modal('hide');
|
||||
};
|
||||
|
||||
var removeCallback = function(){
|
||||
document.getElementById('modal-confirm-ok').removeEventListener("click", okCallbackWrap , false);
|
||||
document.getElementById('modal-confirm-cancel').removeEventListener("click", cancelCallbackWrap , false);
|
||||
};
|
||||
|
||||
document.body.insertAdjacentHTML('beforeEnd', confirmHtml);
|
||||
removeCallback();
|
||||
document.getElementById('modal-confirm-ok').addEventListener("click", okCallbackWrap , false);
|
||||
document.getElementById('modal-confirm-cancel').addEventListener("click", cancelCallbackWrap , false);
|
||||
|
||||
$('#modal-confirm').on('hidden.bs.modal', function(){
|
||||
removeCallback();
|
||||
document.body.removeChild(document.getElementById('modal-confirm'));
|
||||
});
|
||||
|
||||
$('#modal-confirm').modal();
|
||||
|
||||
};
|
||||
|
||||
window.customAlert = function(msg) {
|
||||
|
||||
var confirmHtml = '<div class="modal confirm fade" id="modal-alert" tabindex="-1" role="dialog" aria-hidden="false">' +
|
||||
'<div class="modal-dialog">' +
|
||||
'<div class="modal-body">' +
|
||||
'<div class="cont">' + msg +'</div>' +
|
||||
'</div>' +
|
||||
'<div class="modal-footer">' +
|
||||
'<div class="cont">' +
|
||||
'<input type="submit" value="Ok" class="button" data-dismiss="modal">' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
|
||||
document.body.insertAdjacentHTML('beforeEnd', confirmHtml);
|
||||
|
||||
$('#modal-alert').on('hidden.bs.modal', function(){
|
||||
document.body.removeChild(document.getElementById('modal-alert'));
|
||||
});
|
||||
|
||||
$('#modal-alert').modal();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
window.customCopyLink = function(copylink) {
|
||||
|
||||
|
||||
var copyToClipboard = function(str) {
|
||||
var el = document.createElement('textarea');
|
||||
el.classList.add('can-copy');
|
||||
el.value = str;
|
||||
document.body.appendChild(el);
|
||||
el.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(el);
|
||||
$('#modal-copylink').modal('hide');
|
||||
window.customAlert('Link is copied to the clipboard');
|
||||
};
|
||||
|
||||
copyToClipboard(copylink);
|
||||
|
||||
};
|
||||
@@ -18,16 +18,7 @@
|
||||
<div class="fb-text">
|
||||
<p>With one-on-one support from our team, you can focus on writing and we'll get your book e-ready and print-ready in no time. Personalize your book settings to control how your book is used and publish new editions and revisions instantly. A fully flexible publishing solution from start to finish.</p>
|
||||
<div class="sub-input">
|
||||
<div id="mc_embed_signup">
|
||||
<form action="https://lawcarta.us12.list-manage.com/subscribe/post?u=f1055fdbaf5889ec432f2821f&id=a6bf932f34" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate="">
|
||||
<div id="mc_embed_signup_scroll">
|
||||
<input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="Enter your Email" required="">
|
||||
|
||||
<div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_f1055fdbaf5889ec432f2821f_a6bf932f34" tabindex="-1" value=""></div>
|
||||
<input type="submit" value="Request a demo" name="subscribe" id="mc-embedded-subscribe" class="button mp-top-right">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php the_widget( 'SubscribeToLc_Widget', [], ['code' => 'a6bf932f34'] ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -58,15 +58,7 @@ get_header();
|
||||
<div class="sb-line2">You can unsubscribe at any time.</div>
|
||||
</div>
|
||||
<div class="sub-input">
|
||||
<div id="mc_embed_signup">
|
||||
<form action="https://lawcarta.us12.list-manage.com/subscribe/post?u=f1055fdbaf5889ec432f2821f&id=a6bf932f34" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate="">
|
||||
<div id="mc_embed_signup_scroll">
|
||||
<input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="Enter your Email" required="">
|
||||
<div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_f1055fdbaf5889ec432f2821f_a6bf932f34" tabindex="-1" value=""></div>
|
||||
<input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button xxl mp-top-right">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php the_widget( 'SubscribeToLc_Widget', [], ['code' => 'a6bf932f34'] ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -78,15 +78,7 @@
|
||||
<div class="sb-line2">You can unsubscribe at any time.</div>
|
||||
</div>
|
||||
<div class="sub-input">
|
||||
<div id="mc_embed_signup">
|
||||
<form action="https://livecarta.us12.list-manage.com/subscribe/post?u=f1055fdbaf5889ec432f2821f&id=a0685621c3" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate="">
|
||||
<div id="mc_embed_signup_scroll">
|
||||
<input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="Enter your Email" required="">
|
||||
<div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_f1055fdbaf5889ec432f2821f_a0685621c3" tabindex="-1" value=""></div>
|
||||
<input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button xxl mp-top-right">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php the_widget( 'SubscribeToLc_Widget', [], ['code' => 'a0685621c3'] ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -81,6 +81,7 @@
|
||||
<script src="<?= get_theme_file_uri('/assets/js/promoImage.js'); ?>"></script>
|
||||
<script src="<?= get_theme_file_uri('/assets/js/sliderScript.js'); ?>"></script>
|
||||
<script src="<?= get_theme_file_uri('/assets/js/promoPopup.js'); ?>"></script>
|
||||
<script src="<?= get_theme_file_uri('/assets/js/customPopups.js'); ?>"></script>
|
||||
<?php if(0):?>
|
||||
<!-- Twitter universal website tag code -->
|
||||
<script>
|
||||
|
||||
@@ -58,16 +58,9 @@ get_header();
|
||||
<div class="sb-line2">You can unsubscribe at any time.</div>
|
||||
</div>
|
||||
<div class="sub-input">
|
||||
<div id="mc_embed_signup">
|
||||
<form action="https://lawcarta.us12.list-manage.com/subscribe/post?u=f1055fdbaf5889ec432f2821f&id=a0685621c3" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate="">
|
||||
<div id="mc_embed_signup_scroll">
|
||||
<input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="Enter your Email" required>
|
||||
|
||||
<div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_f1055fdbaf5889ec432f2821f_a0685621c3" tabindex="-1" value=""></div>
|
||||
<input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button xxl mp-top-right">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
the_widget( 'SubscribeToLc_Widget', [], ['code' => 'a0685621c3'] );
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user