diff --git a/core/triggers/interface_99_modEasyurl_EasyurlTriggers.class.php b/core/triggers/interface_99_modEasyurl_EasyurlTriggers.class.php
index 2a45a3a..c96a6c8 100644
--- a/core/triggers/interface_99_modEasyurl_EasyurlTriggers.class.php
+++ b/core/triggers/interface_99_modEasyurl_EasyurlTriggers.class.php
@@ -158,6 +158,10 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf
$object->update($user, true);
}
+ if ($object->original_url != GETPOST('previous_original_url')) {
+ update_easy_url_link($object);
+ }
+
$actioncomm->label = $langs->trans('ObjectModifyTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref);
$actioncomm->create($user);
break;
diff --git a/lib/easyurl_function.lib.php b/lib/easyurl_function.lib.php
index b18e415..6138e67 100644
--- a/lib/easyurl_function.lib.php
+++ b/lib/easyurl_function.lib.php
@@ -179,3 +179,37 @@ function get_easy_url_link(CommonObject $object, string $urlType): int
return -1;
}
}
+
+/**
+ * Update easy url link
+ *
+ * @param CommonObject $object Object
+ * @return int 0 < on error, 1 = statusCode 200, 0 = other statusCode (ex : 404)
+ */
+function update_easy_url_link(CommonObject $object): int
+{
+ global $conf;
+
+ // Init the CURL session
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $conf->global->EASYURL_URL_YOURLS_API);
+ curl_setopt($ch, CURLOPT_HEADER, 0); // No header in the result
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return, do not echo result
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($ch, CURLOPT_POST, 1); // This is a POST request
+ curl_setopt($ch, CURLOPT_POSTFIELDS, [ // Data to POST
+ 'action' => 'update',
+ 'signature' => $conf->global->EASYURL_SIGNATURE_TOKEN_YOURLS_API,
+ 'format' => 'json',
+ 'shorturl' => $object->label,
+ 'url' => $object->original_url
+ ]);
+
+ // Fetch and return content
+ $data = curl_exec($ch);
+ curl_close($ch);
+
+ // Do something with the result
+ $data = json_decode($data);
+ return $data->statusCode == 200 ? 1 : 0;
+}
diff --git a/view/shortener/shortener_card.php b/view/shortener/shortener_card.php
index d1ce477..f3d3866 100644
--- a/view/shortener/shortener_card.php
+++ b/view/shortener/shortener_card.php
@@ -201,6 +201,7 @@
print '';
print '';
print '';
+ print '';
if ($backtopage) {
print '';
}