Conditions | 4 |
Paths | 1 |
Total Lines | 19 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
5 | public function onBeforeParse(&$content) |
||
6 | { |
||
7 | $parser = $this->owner; |
||
8 | // Check the shortcode type and convert wrapper to div if block type |
||
9 | // Regex examples: https://regex101.com/r/bFtD9o/3 |
||
10 | $content = preg_replace_callback( |
||
11 | '|<p( [^>]*?)?>\s*?\[((.*)([\s,].*)?)\]\s*?</p>|U', |
||
12 | function ($matches) use($parser) { |
||
13 | $shortcodeName = $matches[3]; |
||
14 | // Since we're only concerned with shortcodable objects we know the |
||
15 | // shortcode name will be the class name so don't have to look it up |
||
16 | return ($shortcodeName && $parser->registered($shortcodeName) |
||
17 | && Config::inst()->get($shortcodeName, 'shortcodable_is_block')) |
||
18 | ? "<div$matches[1]>[$matches[2]]</div>" |
||
19 | : $matches[0]; |
||
20 | }, |
||
21 | $content |
||
22 | ); |
||
23 | } |
||
24 | } |
||
25 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.