22 lines
563 B
PHP
22 lines
563 B
PHP
|
<?php
|
||
|
namespace App\Providers;
|
||
|
|
||
|
use Illuminate\Support\Str;
|
||
|
|
||
|
class ShortcodeProcessor
|
||
|
{
|
||
|
public function process($content)
|
||
|
{
|
||
|
return preg_replace_callback('/\[([\w_]+)([^\]]*)\]/', function ($matches) {
|
||
|
$shortcodeName = $matches[1];
|
||
|
$shortcodeAttributes = Str::of($matches[2])->trim()->replace("'", "\"")->__toString();
|
||
|
return "@shortcode('$shortcodeName', $shortcodeAttributes)";
|
||
|
}, $content);
|
||
|
}
|
||
|
|
||
|
public function processShortcodes($content)
|
||
|
{
|
||
|
return $this->process($content);
|
||
|
}
|
||
|
}
|