From 382761bae55b5b36d44bbc79fc38879a3f8d650f Mon Sep 17 00:00:00 2001 From: Marius Veltan Date: Fri, 16 Feb 2018 11:39:27 +0200 Subject: [PATCH] Implement fix to issue requesting wp-load.php --- gitium/gitium-webhook.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gitium/gitium-webhook.php b/gitium/gitium-webhook.php index 47f2807..6369323 100644 --- a/gitium/gitium-webhook.php +++ b/gitium/gitium-webhook.php @@ -17,8 +17,12 @@ header( 'Content-Type: text/html' ); define( 'SHORTINIT', true ); -//$wordpress_loader = $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php'; -$wordpress_loader = filter_input(INPUT_SERVER, 'DOCUMENT_ROOT', FILTER_SANITIZE_STRING) . '/wp-load.php'; + +$current_dir = __DIR__; +// Find the WP core root by splitting the script path with "wp-content/plugins" as delimiter. +list( $web_root, $rest ) = explode( 'wp-content/plugins', $current_dir, 2 ); +// Now put together the path to wp-load.php. +$wordpress_loader = $web_root . '/wp-load.php'; require_once $wordpress_loader; require_once __DIR__ . '/functions.php';