diff --git a/CHANGELOG.md b/CHANGELOG.md index 55aafbcf2..c940cd84f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ * Comment out `files-upload` deprecated message as this is not going to be removed * Added various public `Twig` class variables used by admin to address deprecated messages for PHP 8.2+ * Added `parse_url` to list of PHP functions supported in Twig Extension + * Added support for dynamic functions in `Parsedown` to stop deprecation messages in PHP 8.2+ # v1.7.40 ## 03/22/2023 diff --git a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php index 4ebf27e63..9b8bb9af8 100644 --- a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php +++ b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php @@ -25,7 +25,7 @@ trait ParsedownGravTrait public $completable_blocks = []; /** @var array */ public $continuable_blocks = []; - + public $plugins = []; /** @var Excerpts */ protected $excerpts; @@ -293,7 +293,12 @@ trait ParsedownGravTrait #[\ReturnTypeWillChange] public function __call($method, $args) { - if (isset($this->{$method}) === true) { + + if (isset($this->plugins[$method]) === true) { + $func = $this->plugins[$method]; + + return call_user_func_array($func, $args); + } elseif (isset($this->{$method}) === true) { $func = $this->{$method}; return call_user_func_array($func, $args); @@ -302,5 +307,13 @@ trait ParsedownGravTrait return null; } + public function __set($name, $value) + { + if (is_callable($value)) { + $this->plugins[$name] = $value; + } + + } + }