From 22eff379c52140f7a41c1dcd86215d87950f6d43 Mon Sep 17 00:00:00 2001 From: Pierre Dargham Date: Wed, 22 Mar 2023 11:54:17 +0100 Subject: [PATCH] Use config/application.php constant for WP_CUBI_WEBHOOKS_SECRET --- src/DeployTrait.php | 8 +++++++- src/WordPressTrait.php | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/DeployTrait.php b/src/DeployTrait.php index fd4e847..8f9f0b8 100644 --- a/src/DeployTrait.php +++ b/src/DeployTrait.php @@ -293,9 +293,15 @@ protected function rsync($fromHost, $fromUser, $fromPath, $toHost, $toUser, $toP protected function sendWebhookHttpRequest($site_url, $webhook) { + $this->loadWpConfig(); + + if (!defined('WP_CUBI_WEBHOOKS_SECRET')) { + return; + } + $url = self::trailingslashit($site_url); $url .= "?wp-cubi-webhooks-run=" . $webhook; - $url .= "&wp-cubi-webhooks-secret=" . \RoboFile::WP_CUBI_WEBHOOKS_SECRET; + $url .= "&wp-cubi-webhooks-secret=" . WP_CUBI_WEBHOOKS_SECRET; $cmd = new Command('curl'); $cmd = $cmd->arg($url) diff --git a/src/WordPressTrait.php b/src/WordPressTrait.php index f0a85f1..eeb8bcd 100644 --- a/src/WordPressTrait.php +++ b/src/WordPressTrait.php @@ -371,4 +371,15 @@ protected function wpActivatePlugins() ->arg('view_query_monitor') ->execute(); } + + protected function loadWpConfig() + { + $config_vars = \RoboFile::ROOT . '/' . \RoboFile::PATH_FILE_CONFIG_VARS; + $config_application = \RoboFile::ROOT . '/' . \RoboFile::PATH_FILE_CONFIG_APPLICATION; + $config_local = \RoboFile::ROOT . '/' . \RoboFile::PATH_FILE_CONFIG_LOCAL; + + defined('WP_CUBI_CONFIG') || define('WP_CUBI_CONFIG', require $config_vars); + require_once $config_application; + require_once $config_local; + } }