From a9c22958b48e98fe6ac6363f18b23779df51443d Mon Sep 17 00:00:00 2001 From: Dennis Date: Tue, 6 Aug 2019 16:10:39 -0700 Subject: [PATCH 1/3] view data doesn't seem to pass into shortcode views without merging the data --- src/Compilers/ShortcodeCompiler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compilers/ShortcodeCompiler.php b/src/Compilers/ShortcodeCompiler.php index 9d30fd9..bbb9ff0 100644 --- a/src/Compilers/ShortcodeCompiler.php +++ b/src/Compilers/ShortcodeCompiler.php @@ -145,7 +145,7 @@ protected function renderShortcodes($value) // get view data public function viewData( $viewData ) { - $this->_viewData = $viewData; + $this->_viewData = array_merge($this->_viewData ?? [], $viewData); return $this; } From ae5ab5a0bf40d05f0429f129cc391ec5d4cf8ff0 Mon Sep 17 00:00:00 2001 From: galang-vehikl Date: Mon, 31 Jul 2023 11:16:33 -0400 Subject: [PATCH 2/3] upgrade to support laravel 9 --- composer.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 2df01fb..e22b83a 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "webwizo/laravel-shortcodes", "type": "library", - "description": "Wordpress like shortcodes for Laravel 5, 6, 7, and 8", + "description": "Wordpress like shortcodes for Laravel 5, 6, 7, 8, and 9", "keywords": [ "laravel", "wordpress", @@ -18,16 +18,16 @@ } ], "require": { - "illuminate/view": "5.6.x|5.7.x|5.8.x|^6.0|^7.0|^8.0", - "illuminate/support": "5.6.x|5.7.x|5.8.x|^6.0|^7.0|^8.0", - "illuminate/contracts": "5.6.x|5.7.x|5.8.x|^6.0|^7.0|^8.0", + "illuminate/view": "5.6.x|5.7.x|5.8.x|^6.0|^7.0|^8.0|^9.0|^10.0", + "illuminate/support": "5.6.x|5.7.x|5.8.x|^6.0|^7.0|^8.0|^9.0|^10.0", + "illuminate/contracts": "5.6.x|5.7.x|5.8.x|^6.0|^7.0|^8.0|^9.0|^10.0", "php": "^7.2|^8.0" }, "require-dev": { - "phpunit/phpunit": "^7.5|^8.0", - "orchestra/testbench": "~3.8.0", + "phpunit/phpunit": "^8.0|^9.0", + "orchestra/testbench": "~3.9.0|^4.0|^5.0|^6.0|^7.0|^8.0", "scrutinizer/ocular": "^1.5", - "squizlabs/php_codesniffer": "~2.3" + "squizlabs/php_codesniffer": "~2.3|^3.7" }, "autoload": { "classmap": [ @@ -55,4 +55,4 @@ } } } -} +} \ No newline at end of file From ef969b314476a1c07167f72567985cae3c420742 Mon Sep 17 00:00:00 2001 From: Nazar Boyko <192031926+nazar-boyko-vshred@users.noreply.github.com> Date: Mon, 7 Apr 2025 08:30:02 -0500 Subject: [PATCH 3/3] OTT-918: fix optional $attributes parameter (php8 warning) --- src/Compilers/Shortcode.php | 6 +++--- src/Compilers/ShortcodeCompiler.php | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Compilers/Shortcode.php b/src/Compilers/Shortcode.php index 6bd11c7..a18d121 100644 --- a/src/Compilers/Shortcode.php +++ b/src/Compilers/Shortcode.php @@ -29,14 +29,14 @@ class Shortcode implements Arrayable * Constructor * * @param string $name - * @param array $attributes * @param string $content + * @param array $attributes */ - public function __construct($name, $attributes = [], $content) + public function __construct($name, $content, $attributes = []) { $this->name = $name; - $this->attributes = $attributes; $this->content = $content; + $this->attributes = $attributes; } /** diff --git a/src/Compilers/ShortcodeCompiler.php b/src/Compilers/ShortcodeCompiler.php index bbb9ff0..ea49eec 100644 --- a/src/Compilers/ShortcodeCompiler.php +++ b/src/Compilers/ShortcodeCompiler.php @@ -37,7 +37,7 @@ class ShortcodeCompiler * @var array */ protected $data = []; - + protected $_viewData; /** @@ -141,7 +141,7 @@ protected function renderShortcodes($value) return preg_replace_callback("/{$pattern}/s", [$this, 'render'], $value); } - + // get view data public function viewData( $viewData ) { @@ -190,8 +190,8 @@ protected function compileShortcode($matches) // return shortcode instance return new Shortcode( $this->getName(), - $attributes, - $this->getContent() + $this->getContent(), + $attributes ); } @@ -373,7 +373,7 @@ protected function stripTag($m) return $m[1] . $m[6]; } - + /** * Get registered shortcodes *