Merge pull request 'demo' (#7) from demo into master

Reviewed-on: LiveCarta/LiveCartaWP#7
This commit is contained in:
2026-03-19 12:04:07 +00:00
422 changed files with 800 additions and 1023 deletions

26
.dockerignore Normal file
View File

@@ -0,0 +1,26 @@
.git
.gitignore
.gitattributes
.github/
.vscode/
.idea/
.devcontainer/
.DS_Store
Thumbs.db
*.log
logs.conf
logs/
docker-compose.yml
compose.yml
.env
.env.*
wp-config-local.php
node_modules/
vendor/
**/.cache/
**/tmp/
**/temp/

56
.gitignore vendored
View File

@@ -1,36 +1,40 @@
!htdocs/
!wordpress/
htdocs/*
!htdocs/wp-content/
!htdocs/wp-config.php
!htdocs/wp-config-local-sample.php
!htdocs/sitemap.xml
wordpress/*
!wordpress/wp-content/
!wordpress/wp-config.php
!wordpress/wp-config-local-sample.php
!wordpress/sitemap.xml
htdocs/wp-content/*
!htdocs/wp-content/mu-plugins/
!htdocs/wp-content/plugins/
!htdocs/wp-content/themes/
!htdocs/wp-content/index.php
!htdocs/wp-content/sunrise.php
!htdocs/wp-content/uploads/
!htdocs/wp-content/uploads/.gitkeep
wordpress/wp-content/*
!wordpress/wp-content/mu-plugins/
!wordpress/wp-content/plugins/
!wordpress/wp-content/themes/
!wordpress/wp-content/index.php
!wordpress/wp-content/sunrise.php
!wordpress/wp-content/uploads/
!wordpress/wp-content/uploads/.gitkeep
htdocs/wp-content/mu-plugins/*
!htdocs/wp-content/mu-plugins/domain_mapping.php
wordpress/wp-content/mu-plugins/*
!wordpress/wp-content/mu-plugins/domain_mapping.php
htdocs/wp-content/plugins/*
!htdocs/wp-content/plugins/index.php
!htdocs/wp-content/plugins/faq
wordpress/wp-content/plugins/*
!wordpress/wp-content/plugins/index.php
!wordpress/wp-content/plugins/faq
!wordpress/wp-content/plugins/disable-image-threshold
htdocs/wp-content/themes/*
!htdocs/wp-content/themes/lawcarta
!htdocs/wp-content/themes/livecarta
!htdocs/wp-content/themes/redesign
!htdocs/wp-content/themes/index.php
wordpress/wp-content/themes/*
!wordpress/wp-content/themes/lawcarta
!wordpress/wp-content/themes/livecarta
!wordpress/wp-content/themes/redesign
!wordpress/wp-content/themes/index.php
!htdocs/wp-content/plugins/wp-rest-api-event
!htdocs/wp-content/plugins/subscribe-to-lc
!wordpress/wp-content/plugins/wp-rest-api-event
!wordpress/wp-content/plugins/subscribe-to-lc
vendor/
.DS_store
.devcontainer
.git*

17
Dockerfile Normal file
View File

@@ -0,0 +1,17 @@
FROM composer:latest AS setup
WORKDIR /src
COPY . .
RUN composer install --no-dev --optimize-autoloader
FROM wordpress:6.9.1-php8.5 AS app
ARG ENV_NAME
WORKDIR /usr/src/wordpress
RUN set -eux; \
find /etc/apache2 -name '*.conf' -type f -exec sed -ri -e "s!/var/www/html!$PWD!g" -e "s!Directory /var/www/!Directory $PWD!g" '{}' +; \
cp -s wp-config-docker.php wp-config.php
COPY --from=setup --chown=www-data:www-data /src/wordpress ./
COPY --from=setup --chown=www-data:www-data /src/environments/docker_container/ ./
COPY --from=setup --chown=www-data:www-data /src/environments/all/ ./
COPY --from=setup --chown=www-data:www-data /src/environments/${ENV_NAME}/robots.txt ./robots.txt

35
Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,35 @@
@Library('utils') _
def mapBranchNameToWPEnv(branchName) {
def envMap = [
master: 'new_prod',
main: 'new_prod',
develop: 'dev',
qa: 'qa',
demo: 'demo'
]
return envMap.get(branchName, 'development')
}
pipeline {
agent any
options {
withFolderProperties()
}
environment {
// LC_IMG_TAG = "${utils.mapBranchToEnv(env.BRANCH_NAME)}"
LC_IMG_TAG = 'qa_test'
WP_ENV = "${mapBranchNameToWPEnv(env.BRANCH_NAME)}"
}
stages {
stage('Build') {
steps {
sh "docker build --build-arg ENV_NAME=${WP_ENV} -t ${env.PUSH_REGISTRY}/${env.LC_WP_IMG}:${LC_IMG_TAG} ."
sh "docker push ${env.PUSH_REGISTRY}/${env.LC_WP_IMG}:${LC_IMG_TAG}"
}
}
}
}

View File

@@ -1,59 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="LawCarta wordpress project" default="build-without-tests">
<target name="build-without-tests"
depends="composer_install, replace, archive"
description="Build project and run all tests"/>
<target name="replace"
unless="replace.done"
description="Replace placeholders in config files" >
<replace dir="../environments" token="@lcAwsKey@" value="${lcAwsKey}"/>
<replace dir="../environments" token="@lcAwsSecretKey@" value="${lcAwsSecretKey}"/>
<replace dir="../environments" token="@lcWpMySqlHostDev@" value="${lcWpMySqlHostDev}"/>
<replace dir="../environments" token="@lcWpMySqlDbnameDev@" value="${lcWpMySqlDbnameDev}"/>
<replace dir="../environments" token="@lcWpMySqlUsernameDev@" value="${lcWpMySqlUsernameDev}"/>
<replace dir="../environments" token="@lcWpMySqlPasswordDev@" value="${lcWpMySqlPasswordDev}"/>
<replace dir="../environments" token="@lcWpMySqlHostQA@" value="${lcWpMySqlHostQA}"/>
<replace dir="../environments" token="@lcWpMySqlDbnameQA@" value="${lcWpMySqlDbnameQA}"/>
<replace dir="../environments" token="@lcWpMySqlUsernameQA@" value="${lcWpMySqlUsernameQA}"/>
<replace dir="../environments" token="@lcWpMySqlPasswordQA@" value="${lcWpMySqlPasswordQA}"/>
<replace dir="../environments" token="@lcWpMySqlHostDemo@" value="${lcWpMySqlHostDemo}"/>
<replace dir="../environments" token="@lcWpMySqlDbnameDemo@" value="${lcWpMySqlDbnameDemo}"/>
<replace dir="../environments" token="@lcWpMySqlUsernameDemo@" value="${lcWpMySqlUsernameDemo}"/>
<replace dir="../environments" token="@lcWpMySqlPasswordDemo@" value="${lcWpMySqlPasswordDemo}"/>
<replace dir="../environments" token="@lcWpMySqlHostStaging@" value="${lcWpMySqlHostStaging}"/>
<replace dir="../environments" token="@lcWpMySqlDbnameStaging@" value="${lcWpMySqlDbnameStaging}"/>
<replace dir="../environments" token="@lcWpMySqlUsernameStaging@" value="${lcWpMySqlUsernameStaging}"/>
<replace dir="../environments" token="@lcWpMySqlPasswordStaging@" value="${lcWpMySqlPasswordStaging}"/>
<replace dir="../environments" token="@lcWpMySqlHostProd@" value="${lcWpMySqlHostProd}"/>
<replace dir="../environments" token="@lcWpMySqlDbnameProd@" value="${lcWpMySqlDbnameProd}"/>
<replace dir="../environments" token="@lcWpMySqlUsernameProd@" value="${lcWpMySqlUsernameProd}"/>
<replace dir="../environments" token="@lcWpMySqlPasswordProd@" value="${lcWpMySqlPasswordProd}"/>
<property name="replace.done" value="true"/>
</target>
<target name="composer_install">
<exec dir="${basedir}/.." executable="composer" failonerror="true">
<arg line="install" />
</exec>
</target>
<target name="archive">
<tar compression="gzip" destfile="lc_wp.tar.gz" longfile="posix">
<tarfileset dir="${basedir}/..">
<include name="*/**" />
<exclude name="build/**" />
</tarfileset>
</tar>
</target>
</project>

View File

@@ -2,27 +2,23 @@
"name": "lawcarta/wordpress",
"description": "LawCarta WordPress Site",
"require": {
"guzzlehttp/guzzle": "^6.5",
"wpackagist-plugin/svg-support": "~2.5",
"wpackagist-plugin/toggle-wpautop": "~1.3",
"wpackagist-plugin/tinymce-advanced": "~5.9",
"wpackagist-plugin/contact-form-7": "~5.7",
"wpackagist-plugin/contact-form-7-mailchimp-extension": "~0.9",
"wpackagist-plugin/contact-form-7": "~6.1",
"wpackagist-plugin/duplicator": "~1.5",
"wpackagist-plugin/flamingo": "~2.2",
"wpackagist-plugin/really-simple-captcha": "~2.0",
"wpackagist-plugin/enhanced-media-library": "~2.8",
"wpackagist-plugin/menu-item-custom-fields": "~1.0.0",
"wpackagist-plugin/wp-rest-api-v2-menus": "~0.12",
"wpackagist-plugin/cf7-field-validation": "~1.1",
"wpackagist-plugin/google-sitemap-generator": "~4.1",
"wpackagist-plugin/honeypot": "~2.3",
"wpackagist-plugin/mailchimp-for-wp": "4.10.1",
"wpackagist-plugin/meta-tag-manager": "~3.3",
"wpackagist-plugin/post-smtp": "~3.8",
"wpackagist-plugin/really-simple-captcha": "~2",
"wpackagist-plugin/svg-support": "~2.5",
"wpackagist-plugin/taxonomy-terms-order": "~1.7",
"wpackagist-plugin/wordpress-seo": "~20",
"wpackagist-plugin/post-types-order": "~2",
"wpackagist-plugin/post-smtp": "~2.4",
"wpackagist-plugin/meta-tag-manager": "~3",
"wpackagist-plugin/disable-big-image-threshold": "~1",
"wpackagist-plugin/tinymce-advanced": "~5.9",
"wpackagist-plugin/toggle-wpautop": "~1.3",
"wpackagist-plugin/wordpress-seo": "~27.1",
"wpackagist-plugin/wps-hide-login": "~1.9",
"humanmade/s3-uploads": "^2.2",
"wpackagist-plugin/google-sitemap-generator": "4.1.21",
"wpackagist-plugin/mailchimp-for-wp": "4.10.1"
"humanmade/s3-uploads": "~3.0"
},
"repositories": [
{
@@ -32,15 +28,18 @@
],
"extra": {
"installer-paths": {
"htdocs/wp-content/plugins/{$name}/": [
"wordpress/wp-content/plugins/{$name}/": [
"type:wordpress-plugin"
],
"htdocs/wp-content/themes/{$name}/": [
"wordpress/wp-content/themes/{$name}/": [
"type:wordpress-theme"
]
}
},
"config": {
"vendor-dir": "htdocs/wp-content/vendor"
"vendor-dir": "wordpress/wp-content/vendor",
"allow-plugins": {
"composer/installers": true
}
}
}

997
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,21 +0,0 @@
<?php
define( 'DB_NAME', '@lcWpMySqlDbnameDev@' );
define( 'DB_USER', '@lcWpMySqlUsernameDev@' );
define( 'DB_PASSWORD', '@lcWpMySqlPasswordDev@' );
define( 'DB_HOST', '@lcWpMySqlHostDev@' );
define('DOMAIN_CURRENT_SITE', 'dev.livecarta.com');
define('LAWCARTA_SUBDOMAIN', 'app-dev');
define('LAWCARTA_PORT', '');
define('LAWCARTA_WP_REST_API_REQUEST_URL', 'https://app-dev.livecarta.com/v1/event/request');
define('LAWCARTA_WP_REST_API_RESPONSE_URL', 'https://app-dev.livecarta.com/v1/event/response');
define('LAWCARTA_ENVIRONMENT_NAME', 'dev');
define('LC_ALLOW_COOKIE_POPUP', true);
define('LC_GTM', 'GTM-KXTRR4Q');
$_SERVER['HTTPS'] = 'On';

View File

@@ -6,6 +6,8 @@ define( 'DB_PASSWORD', getenv('DB_PASSWORD') );
define( 'DB_HOST', getenv('DB_HOST') );
define('DOMAIN_CURRENT_SITE', getenv('DOMAIN_CURRENT_SITE'));
define('WP_HOME', getenv('WP_HOME'));
define('WP_SITEURL', getenv('WP_SITEURL'));
define('LAWCARTA_SUBDOMAIN', getenv('SUBDOMAIN'));
define('LAWCARTA_PORT', '');

View File

@@ -5,9 +5,9 @@ define( 'DB_USER', '@lcWpMySqlUsernameQA@' );
define( 'DB_PASSWORD', '@lcWpMySqlPasswordQA@' );
define( 'DB_HOST', '@lcWpMySqlHostQA@' );
define('DOMAIN_CURRENT_SITE', 'qa.livecarta.com');
define('DOMAIN_CURRENT_SITE', 'qa116.livecarta.com');
define('LAWCARTA_SUBDOMAIN', 'app-qa');
define('LAWCARTA_SUBDOMAIN', 'app-qa116');
define('LAWCARTA_PORT', '');
define('LAWCARTA_ENVIRONMENT_NAME', 'qa');

View File

@@ -1,24 +0,0 @@
$(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;
})
});

View File

@@ -1,63 +0,0 @@
<?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');
});

View File

@@ -1,80 +0,0 @@
<?php
namespace app\wpRestApiEvent;
/**
* Class HttpClient
* @package 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
*/
public function sendRequest($data)
{
return $this->doPostRequest(LAWCARTA_WP_REST_API_REQUEST_URL, $data);
}
/**
* @param $sysLogId
* @param $data
* @return string|\WP_Error
*/
public function sendResponse($sysLogId, $data)
{
$data['sysLogId'] = $sysLogId;
return $this->doPostRequest(LAWCARTA_WP_REST_API_RESPONSE_URL, $data);
}
/**
* @param $url
* @param $data
* @return string|\WP_Error
*/
private function doPostRequest($url, $data)
{
$response = wp_remote_post($url, [
'headers' => [
'Content-Type' => 'application/json',
],
'body' => json_encode($data),
'sslverify' => false
]);
$sysLogId = null;
/** @var \WP_HTTP_Requests_Response $httpResponse */
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;
}
/**
* @return HttpClient
*/
public static function create()
{
return new self();
}
}

View File

@@ -1,159 +0,0 @@
<?php
namespace app\wpRestApiEvent\event;
use app\wpRestApiEvent\HttpClient;
/**
* Class EventSubscriber
* @package app\wpRestApiEvent\event
*/
class EventSubscriber
{
/**
* @var array
*/
private static $request;
/**
* @var array
*/
private static $get;
/**
* @var array
*/
private static $post;
/**
* @var array
*/
private static $cookie;
/**
* @var array
*/
private static $session;
/**
* @var array
*/
private static $env;
/**
* @var array
*/
private static $headers;
/**
* @var array
*/
private static $server;
/**
* @var string
*/
private static $userIp;
/**
* @var string
*/
private static $sessionId;
/**
* @var string
*/
private static $parentSysLogId;
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('shutdown', [self::class, 'onResponse'], 0);
register_shutdown_function([self::class, 'onShutdown']);
apply_filters('pre_http_request', [self::class, 'onRequest'], 0);
self::onRequest();
}
public static function onRequest()
{
$client = HttpClient::create();
self::$parentSysLogId = $client->sendRequest(self::getSuperGlobals());
}
public static function onResponse(array $response, array $r, $url)
{
// todo: add response handler
}
public static function onParseRequest()
{
// todo: add request data from wp
}
public static function onShutdown()
{
$client = HttpClient::create();
$client->sendResponse(self::$parentSysLogId, array_merge(self::getSuperGlobals(), [
'headers_list' => headers_list(),
'response_code' => http_response_code()
]));
}
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::$userIp = self::getTheUserIp();
self::$sessionId = $_COOKIE['PHPSESSID'] ?? null;
if (function_exists('getallheaders')) {
self::$headers = getallheaders();
} elseif (function_exists('http_get_request_headers')) {
self::$headers = http_get_request_headers();
}
}
/**
* @return array
*/
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,
'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;
}
}

View File

@@ -1,28 +0,0 @@
<?php
/*
Plugin Name: WP-REST-API Event
Version: 0.0.1
Description:
Author:
*/
function wp_rest_api_event_register() {
spl_autoload_register(function($class) {
$namespace = 'app\\wpRestApiEvent\\';
if (false === strpos($class, $namespace)) {
return false;
}
$filename = __DIR__ . '/' . str_replace('\\', '/', str_replace($namespace, '', $class)) . '.php';
if (!file_exists($filename)) {
return false;
}
include $filename;
return true;
});
\app\wpRestApiEvent\event\EventSubscriber::setGlobals();
add_action('init', [\app\wpRestApiEvent\event\EventSubscriber::class, 'onInit']);
}
wp_rest_api_event_register();

0
htdocs/wp-config.php → wordpress/wp-config.php Executable file → Normal file
View File

View File

@@ -0,0 +1,9 @@
<?php
/*
Plugin Name: Disable "BIG image" Threshold
Description: Disable the big image threshold in WordPress.
Author: LawCarta Team
Text Domain: disable-image-threshold
Version: 1.0
*/
add_filter('big_image_size_threshold', '__return_false');

View File

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 72 KiB

View File

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 228 KiB

After

Width:  |  Height:  |  Size: 228 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Some files were not shown because too many files have changed in this diff Show More