Replaced plugin with local copy, removed unused plugins, updated dependencies

This commit is contained in:
2026-03-05 15:38:17 +01:00
parent 4dec48155d
commit dc85447ee1
9 changed files with 109 additions and 484 deletions

1
.gitignore vendored
View File

@@ -21,6 +21,7 @@ htdocs/wp-content/mu-plugins/*
htdocs/wp-content/plugins/* htdocs/wp-content/plugins/*
!htdocs/wp-content/plugins/index.php !htdocs/wp-content/plugins/index.php
!htdocs/wp-content/plugins/faq !htdocs/wp-content/plugins/faq
!htdocs/wp-content/plugins/disable-image-threshold
htdocs/wp-content/themes/* htdocs/wp-content/themes/*
!htdocs/wp-content/themes/lawcarta !htdocs/wp-content/themes/lawcarta

View File

@@ -2,25 +2,23 @@
"name": "lawcarta/wordpress", "name": "lawcarta/wordpress",
"description": "LawCarta WordPress Site", "description": "LawCarta WordPress Site",
"require": { "require": {
"wpackagist-plugin/svg-support": "~2.5", "wpackagist-plugin/contact-form-7-mailchimp-extension": "~0.9",
"wpackagist-plugin/toggle-wpautop": "~1.3", "wpackagist-plugin/contact-form-7": "~6.1",
"wpackagist-plugin/tinymce-advanced": "~5.9", "wpackagist-plugin/duplicator": "~1.5",
"wpackagist-plugin/contact-form-7": "~5.7",
"wpackagist-plugin/flamingo": "~2.2", "wpackagist-plugin/flamingo": "~2.2",
"wpackagist-plugin/really-simple-captcha": "~2.0", "wpackagist-plugin/google-sitemap-generator": "~4.1",
"wpackagist-plugin/enhanced-media-library": "~2.8", "wpackagist-plugin/honeypot": "~2.3",
"wpackagist-plugin/wp-rest-api-v2-menus": "~0.12",
"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/wps-hide-login": "~1.9",
"humanmade/s3-uploads": "~2.3",
"wpackagist-plugin/google-sitemap-generator": "4.1.21",
"wpackagist-plugin/mailchimp-for-wp": "4.10.1", "wpackagist-plugin/mailchimp-for-wp": "4.10.1",
"wpackagist-plugin/duplicator": "~1.5" "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/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": "~3.0"
}, },
"repositories": [ "repositories": [
{ {

197
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "f87ae7cb9b1e86428b259057af11a038", "content-hash": "7757a6cea3935665988a9b67861c47bd",
"packages": [ "packages": [
{ {
"name": "aws/aws-crt-php", "name": "aws/aws-crt-php",
@@ -62,16 +62,16 @@
}, },
{ {
"name": "aws/aws-sdk-php", "name": "aws/aws-sdk-php",
"version": "3.371.4", "version": "3.371.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/aws/aws-sdk-php.git", "url": "https://github.com/aws/aws-sdk-php.git",
"reference": "957f8a5ecc30670c95dfc37a9d04660899fc44e0" "reference": "d40b962154a146901f71561519f9d9c5a3863a6e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/957f8a5ecc30670c95dfc37a9d04660899fc44e0", "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/d40b962154a146901f71561519f9d9c5a3863a6e",
"reference": "957f8a5ecc30670c95dfc37a9d04660899fc44e0", "reference": "d40b962154a146901f71561519f9d9c5a3863a6e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -153,45 +153,43 @@
"support": { "support": {
"forum": "https://github.com/aws/aws-sdk-php/discussions", "forum": "https://github.com/aws/aws-sdk-php/discussions",
"issues": "https://github.com/aws/aws-sdk-php/issues", "issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.371.4" "source": "https://github.com/aws/aws-sdk-php/tree/3.371.5"
}, },
"time": "2026-03-03T19:52:06+00:00" "time": "2026-03-04T19:06:59+00:00"
}, },
{ {
"name": "composer/installers", "name": "composer/installers",
"version": "v1.12.0", "version": "v2.3.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/composer/installers.git", "url": "https://github.com/composer/installers.git",
"reference": "d20a64ed3c94748397ff5973488761b22f6d3f19" "reference": "12fb2dfe5e16183de69e784a7b84046c43d97e8e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/composer/installers/zipball/d20a64ed3c94748397ff5973488761b22f6d3f19", "url": "https://api.github.com/repos/composer/installers/zipball/12fb2dfe5e16183de69e784a7b84046c43d97e8e",
"reference": "d20a64ed3c94748397ff5973488761b22f6d3f19", "reference": "12fb2dfe5e16183de69e784a7b84046c43d97e8e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"composer-plugin-api": "^1.0 || ^2.0" "composer-plugin-api": "^1.0 || ^2.0",
}, "php": "^7.2 || ^8.0"
"replace": {
"roundcube/plugin-installer": "*",
"shama/baton": "*"
}, },
"require-dev": { "require-dev": {
"composer/composer": "1.6.* || ^2.0", "composer/composer": "^1.10.27 || ^2.7",
"composer/semver": "^1 || ^3", "composer/semver": "^1.7.2 || ^3.4.0",
"phpstan/phpstan": "^0.12.55", "phpstan/phpstan": "^1.11",
"phpstan/phpstan-phpunit": "^0.12.16", "phpstan/phpstan-phpunit": "^1",
"symfony/phpunit-bridge": "^4.2 || ^5", "symfony/phpunit-bridge": "^7.1.1",
"symfony/process": "^2.3" "symfony/process": "^5 || ^6 || ^7"
}, },
"type": "composer-plugin", "type": "composer-plugin",
"extra": { "extra": {
"class": "Composer\\Installers\\Plugin", "class": "Composer\\Installers\\Plugin",
"branch-alias": { "branch-alias": {
"dev-main": "1.x-dev" "dev-main": "2.x-dev"
} },
"plugin-modifies-install-path": true
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
@@ -212,7 +210,6 @@
"description": "A multi-framework Composer library installer", "description": "A multi-framework Composer library installer",
"homepage": "https://composer.github.io/installers/", "homepage": "https://composer.github.io/installers/",
"keywords": [ "keywords": [
"Craft",
"Dolibarr", "Dolibarr",
"Eliasis", "Eliasis",
"Hurad", "Hurad",
@@ -233,7 +230,6 @@
"Whmcs", "Whmcs",
"WolfCMS", "WolfCMS",
"agl", "agl",
"aimeos",
"annotatecms", "annotatecms",
"attogram", "attogram",
"bitrix", "bitrix",
@@ -242,6 +238,7 @@
"cockpit", "cockpit",
"codeigniter", "codeigniter",
"concrete5", "concrete5",
"concreteCMS",
"croogo", "croogo",
"dokuwiki", "dokuwiki",
"drupal", "drupal",
@@ -252,7 +249,6 @@
"grav", "grav",
"installer", "installer",
"itop", "itop",
"joomla",
"known", "known",
"kohana", "kohana",
"laravel", "laravel",
@@ -261,6 +257,7 @@
"magento", "magento",
"majima", "majima",
"mako", "mako",
"matomo",
"mediawiki", "mediawiki",
"miaoxing", "miaoxing",
"modulework", "modulework",
@@ -280,9 +277,7 @@
"silverstripe", "silverstripe",
"sydes", "sydes",
"sylius", "sylius",
"symfony",
"tastyigniter", "tastyigniter",
"typo3",
"wordpress", "wordpress",
"yawik", "yawik",
"zend", "zend",
@@ -290,7 +285,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/composer/installers/issues", "issues": "https://github.com/composer/installers/issues",
"source": "https://github.com/composer/installers/tree/v1.12.0" "source": "https://github.com/composer/installers/tree/v2.3.0"
}, },
"funding": [ "funding": [
{ {
@@ -306,7 +301,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2021-09-13T08:19:44+00:00" "time": "2024-06-24T20:46:46+00:00"
}, },
{ {
"name": "guzzlehttp/guzzle", "name": "guzzlehttp/guzzle",
@@ -635,32 +630,44 @@
}, },
{ {
"name": "humanmade/s3-uploads", "name": "humanmade/s3-uploads",
"version": "2.3.0", "version": "3.0.13",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/humanmade/S3-Uploads.git", "url": "https://github.com/humanmade/S3-Uploads.git",
"reference": "3b995ba6d1ccde4354efb9564c3e244f871bbcda" "reference": "c09bd3057747b181eeb9c22e380da9d904ba260a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/humanmade/S3-Uploads/zipball/3b995ba6d1ccde4354efb9564c3e244f871bbcda", "url": "https://api.github.com/repos/humanmade/S3-Uploads/zipball/c09bd3057747b181eeb9c22e380da9d904ba260a",
"reference": "3b995ba6d1ccde4354efb9564c3e244f871bbcda", "reference": "c09bd3057747b181eeb9c22e380da9d904ba260a",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"aws/aws-sdk-php": "~3.18", "aws/aws-sdk-php": "^3.366",
"composer/installers": "~1.0" "composer/installers": "~1.0 || ^2.0",
"php": ">=8.0"
},
"require-dev": {
"humanmade/psalm-plugin-wordpress": "^3.1",
"pcov/clobber": "^2.0",
"phpunit/phpunit": "^9.6",
"vimeo/psalm": "^5.0",
"yoast/phpunit-polyfills": "^4.0"
}, },
"type": "wordpress-plugin", "type": "wordpress-plugin",
"autoload": {
"classmap": [
"inc/"
]
},
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"GPL-2.0+" "GPL-2.0+"
], ],
"authors": [ "authors": [
{ {
"name": "Human Made Limited", "name": "Human Made",
"email": "support@humanmade.co.uk", "homepage": "https://humanmade.com/"
"homepage": "http://hmn.md/"
} }
], ],
"description": "WordPress plugin to store uploads on S3", "description": "WordPress plugin to store uploads on S3",
@@ -672,7 +679,7 @@
"issues": "https://github.com/humanmade/s3-uploads/issues", "issues": "https://github.com/humanmade/s3-uploads/issues",
"source": "https://github.com/humanmade/s3-uploads" "source": "https://github.com/humanmade/s3-uploads"
}, },
"time": "2021-03-18T10:55:13+00:00" "time": "2026-02-25T17:57:09+00:00"
}, },
{ {
"name": "mtdowling/jmespath.php", "name": "mtdowling/jmespath.php",
@@ -1251,15 +1258,15 @@
}, },
{ {
"name": "wpackagist-plugin/contact-form-7", "name": "wpackagist-plugin/contact-form-7",
"version": "5.9.8", "version": "6.1.5",
"source": { "source": {
"type": "svn", "type": "svn",
"url": "https://plugins.svn.wordpress.org/contact-form-7/", "url": "https://plugins.svn.wordpress.org/contact-form-7/",
"reference": "tags/5.9.8" "reference": "tags/6.1.5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://downloads.wordpress.org/plugin/contact-form-7.5.9.8.zip" "url": "https://downloads.wordpress.org/plugin/contact-form-7.6.1.5.zip"
}, },
"require": { "require": {
"composer/installers": "^1.0 || ^2.0" "composer/installers": "^1.0 || ^2.0"
@@ -1268,22 +1275,22 @@
"homepage": "https://wordpress.org/plugins/contact-form-7/" "homepage": "https://wordpress.org/plugins/contact-form-7/"
}, },
{ {
"name": "wpackagist-plugin/disable-big-image-threshold", "name": "wpackagist-plugin/contact-form-7-mailchimp-extension",
"version": "1.0", "version": "0.9.76",
"source": { "source": {
"type": "svn", "type": "svn",
"url": "https://plugins.svn.wordpress.org/disable-big-image-threshold/", "url": "https://plugins.svn.wordpress.org/contact-form-7-mailchimp-extension/",
"reference": "tags/1.0" "reference": "tags/0.9.76"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://downloads.wordpress.org/plugin/disable-big-image-threshold.1.0.zip" "url": "https://downloads.wordpress.org/plugin/contact-form-7-mailchimp-extension.0.9.76.zip"
}, },
"require": { "require": {
"composer/installers": "^1.0 || ^2.0" "composer/installers": "^1.0 || ^2.0"
}, },
"type": "wordpress-plugin", "type": "wordpress-plugin",
"homepage": "https://wordpress.org/plugins/disable-big-image-threshold/" "homepage": "https://wordpress.org/plugins/contact-form-7-mailchimp-extension/"
}, },
{ {
"name": "wpackagist-plugin/duplicator", "name": "wpackagist-plugin/duplicator",
@@ -1303,24 +1310,6 @@
"type": "wordpress-plugin", "type": "wordpress-plugin",
"homepage": "https://wordpress.org/plugins/duplicator/" "homepage": "https://wordpress.org/plugins/duplicator/"
}, },
{
"name": "wpackagist-plugin/enhanced-media-library",
"version": "2.9.4",
"source": {
"type": "svn",
"url": "https://plugins.svn.wordpress.org/enhanced-media-library/",
"reference": "tags/2.9.4"
},
"dist": {
"type": "zip",
"url": "https://downloads.wordpress.org/plugin/enhanced-media-library.2.9.4.zip"
},
"require": {
"composer/installers": "^1.0 || ^2.0"
},
"type": "wordpress-plugin",
"homepage": "https://wordpress.org/plugins/enhanced-media-library/"
},
{ {
"name": "wpackagist-plugin/flamingo", "name": "wpackagist-plugin/flamingo",
"version": "2.6.1", "version": "2.6.1",
@@ -1341,15 +1330,15 @@
}, },
{ {
"name": "wpackagist-plugin/google-sitemap-generator", "name": "wpackagist-plugin/google-sitemap-generator",
"version": "4.1.21", "version": "4.1.23",
"source": { "source": {
"type": "svn", "type": "svn",
"url": "https://plugins.svn.wordpress.org/google-sitemap-generator/", "url": "https://plugins.svn.wordpress.org/google-sitemap-generator/",
"reference": "tags/4.1.21" "reference": "tags/4.1.23"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://downloads.wordpress.org/plugin/google-sitemap-generator.4.1.21.zip" "url": "https://downloads.wordpress.org/plugin/google-sitemap-generator.4.1.23.zip"
}, },
"require": { "require": {
"composer/installers": "^1.0 || ^2.0" "composer/installers": "^1.0 || ^2.0"
@@ -1357,6 +1346,24 @@
"type": "wordpress-plugin", "type": "wordpress-plugin",
"homepage": "https://wordpress.org/plugins/google-sitemap-generator/" "homepage": "https://wordpress.org/plugins/google-sitemap-generator/"
}, },
{
"name": "wpackagist-plugin/honeypot",
"version": "2.3.04",
"source": {
"type": "svn",
"url": "https://plugins.svn.wordpress.org/honeypot/",
"reference": "tags/2.3.04"
},
"dist": {
"type": "zip",
"url": "https://downloads.wordpress.org/plugin/honeypot.2.3.04.zip"
},
"require": {
"composer/installers": "^1.0 || ^2.0"
},
"type": "wordpress-plugin",
"homepage": "https://wordpress.org/plugins/honeypot/"
},
{ {
"name": "wpackagist-plugin/mailchimp-for-wp", "name": "wpackagist-plugin/mailchimp-for-wp",
"version": "4.10.1", "version": "4.10.1",
@@ -1395,15 +1402,15 @@
}, },
{ {
"name": "wpackagist-plugin/post-smtp", "name": "wpackagist-plugin/post-smtp",
"version": "2.9.14", "version": "3.8.0",
"source": { "source": {
"type": "svn", "type": "svn",
"url": "https://plugins.svn.wordpress.org/post-smtp/", "url": "https://plugins.svn.wordpress.org/post-smtp/",
"reference": "tags/2.9.14" "reference": "tags/3.8.0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://downloads.wordpress.org/plugin/post-smtp.2.9.14.zip" "url": "https://downloads.wordpress.org/plugin/post-smtp.3.8.0.zip"
}, },
"require": { "require": {
"composer/installers": "^1.0 || ^2.0" "composer/installers": "^1.0 || ^2.0"
@@ -1411,24 +1418,6 @@
"type": "wordpress-plugin", "type": "wordpress-plugin",
"homepage": "https://wordpress.org/plugins/post-smtp/" "homepage": "https://wordpress.org/plugins/post-smtp/"
}, },
{
"name": "wpackagist-plugin/post-types-order",
"version": "2.4.3",
"source": {
"type": "svn",
"url": "https://plugins.svn.wordpress.org/post-types-order/",
"reference": "tags/2.4.3"
},
"dist": {
"type": "zip",
"url": "https://downloads.wordpress.org/plugin/post-types-order.2.4.3.zip"
},
"require": {
"composer/installers": "^1.0 || ^2.0"
},
"type": "wordpress-plugin",
"homepage": "https://wordpress.org/plugins/post-types-order/"
},
{ {
"name": "wpackagist-plugin/really-simple-captcha", "name": "wpackagist-plugin/really-simple-captcha",
"version": "2.4", "version": "2.4",
@@ -1521,15 +1510,15 @@
}, },
{ {
"name": "wpackagist-plugin/wordpress-seo", "name": "wpackagist-plugin/wordpress-seo",
"version": "20.13", "version": "27.1.1",
"source": { "source": {
"type": "svn", "type": "svn",
"url": "https://plugins.svn.wordpress.org/wordpress-seo/", "url": "https://plugins.svn.wordpress.org/wordpress-seo/",
"reference": "tags/20.13" "reference": "tags/27.1.1"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://downloads.wordpress.org/plugin/wordpress-seo.20.13.zip" "url": "https://downloads.wordpress.org/plugin/wordpress-seo.27.1.1.zip"
}, },
"require": { "require": {
"composer/installers": "^1.0 || ^2.0" "composer/installers": "^1.0 || ^2.0"
@@ -1537,24 +1526,6 @@
"type": "wordpress-plugin", "type": "wordpress-plugin",
"homepage": "https://wordpress.org/plugins/wordpress-seo/" "homepage": "https://wordpress.org/plugins/wordpress-seo/"
}, },
{
"name": "wpackagist-plugin/wp-rest-api-v2-menus",
"version": "0.12.1",
"source": {
"type": "svn",
"url": "https://plugins.svn.wordpress.org/wp-rest-api-v2-menus/",
"reference": "tags/0.12.1"
},
"dist": {
"type": "zip",
"url": "https://downloads.wordpress.org/plugin/wp-rest-api-v2-menus.0.12.1.zip"
},
"require": {
"composer/installers": "^1.0 || ^2.0"
},
"type": "wordpress-plugin",
"homepage": "https://wordpress.org/plugins/wp-rest-api-v2-menus/"
},
{ {
"name": "wpackagist-plugin/wps-hide-login", "name": "wpackagist-plugin/wps-hide-login",
"version": "1.9.18", "version": "1.9.18",

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

@@ -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();