diff --git a/.gitignore b/.gitignore index d1175ba..91cf196 100644 --- a/.gitignore +++ b/.gitignore @@ -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/ diff --git a/htdocs/wp-config-local-sample.php b/htdocs/wp-config-local-sample.php old mode 100644 new mode 100755 index 476cafc..28f686e --- a/htdocs/wp-config-local-sample.php +++ b/htdocs/wp-config-local-sample.php @@ -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'); diff --git a/htdocs/wp-content/plugins/subscribe-to-lc/js/subscribe.js b/htdocs/wp-content/plugins/subscribe-to-lc/js/subscribe.js new file mode 100644 index 0000000..46da64b --- /dev/null +++ b/htdocs/wp-content/plugins/subscribe-to-lc/js/subscribe.js @@ -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 = "Almost finished...

We need to confirm your email address.

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; + }) +}); diff --git a/htdocs/wp-content/plugins/subscribe-to-lc/subscribe-to-lc.php b/htdocs/wp-content/plugins/subscribe-to-lc/subscribe-to-lc.php new file mode 100644 index 0000000..078bc37 --- /dev/null +++ b/htdocs/wp-content/plugins/subscribe-to-lc/subscribe-to-lc.php @@ -0,0 +1,63 @@ + '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'); + + ?> + +
+
+
+ + + + +
+
+
+ + $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; diff --git a/htdocs/wp-content/plugins/wp-rest-api-event/event/EventSubscriber.php b/htdocs/wp-content/plugins/wp-rest-api-event/event/EventSubscriber.php old mode 100644 new mode 100755 index be1d323..99c1667 --- a/htdocs/wp-content/plugins/wp-rest-api-event/event/EventSubscriber.php +++ b/htdocs/wp-content/plugins/wp-rest-api-event/event/EventSubscriber.php @@ -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; + } } \ No newline at end of file diff --git a/htdocs/wp-content/themes/lawcarta/assets/js/customPopups.js b/htdocs/wp-content/themes/lawcarta/assets/js/customPopups.js new file mode 100644 index 0000000..fc29d94 --- /dev/null +++ b/htdocs/wp-content/themes/lawcarta/assets/js/customPopups.js @@ -0,0 +1,93 @@ + +window.customConfirm = function(msg, okCallback, cancelCallback) { + + var confirmHtml = ''; + + 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 = ''; + + 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); + +}; \ No newline at end of file diff --git a/htdocs/wp-content/themes/lawcarta/page-publish-your-book.php b/htdocs/wp-content/themes/lawcarta/page-publish-your-book.php index eeab3af..e0c71e3 100644 --- a/htdocs/wp-content/themes/lawcarta/page-publish-your-book.php +++ b/htdocs/wp-content/themes/lawcarta/page-publish-your-book.php @@ -18,16 +18,7 @@

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.

-
-
-
- - - - -
-
-
+ 'a6bf932f34'] ); ?>
diff --git a/htdocs/wp-content/themes/lawcarta/page_home.php b/htdocs/wp-content/themes/lawcarta/page_home.php index daff18d..31dafc8 100644 --- a/htdocs/wp-content/themes/lawcarta/page_home.php +++ b/htdocs/wp-content/themes/lawcarta/page_home.php @@ -58,15 +58,7 @@ get_header();
You can unsubscribe at any time.
-
-
-
- - - -
-
-
+ 'a6bf932f34'] ); ?>
diff --git a/htdocs/wp-content/themes/lawcarta/single.php b/htdocs/wp-content/themes/lawcarta/single.php index 46df04a..e6a0dfa 100644 --- a/htdocs/wp-content/themes/lawcarta/single.php +++ b/htdocs/wp-content/themes/lawcarta/single.php @@ -78,15 +78,7 @@
You can unsubscribe at any time.
-
-
-
- - - -
-
-
+ 'a0685621c3'] ); ?>
diff --git a/htdocs/wp-content/themes/livecarta/footer.php b/htdocs/wp-content/themes/livecarta/footer.php index 290f253..880f7ad 100644 --- a/htdocs/wp-content/themes/livecarta/footer.php +++ b/htdocs/wp-content/themes/livecarta/footer.php @@ -81,6 +81,7 @@ +